[vtkusers] trying to clip a polyData with an other

David.Pont at ForestResearch.co.nz David.Pont at ForestResearch.co.nz
Tue Mar 16 15:03:45 EST 2004


Hi Laurent,
   I have not worked with volumes (yet...) but I see vtkClipVolume in vtk 4
which uses an implicit function just like vtkClipPolyData. vtkCutter may
also be interesting for you, clip to remove cells, cut to show cell data on
the clip/cut surface, ie you may want to use both, with the same implicit
function.
   Dave P


                                                                                                               
                      Laurent Mundeleer                                                                        
                      <lmundele at ulb.ac.        To:       David.Pont at ForestResearch.co.nz                       
                      be>                      cc:       vtk <vtkusers at vtk.org>                                
                      Sent by:                 Subject:  Re: [vtkusers] trying to clip a polyData with an      
                      vtkusers-admin at vt         other                                                          
                      k.org                                                                                    
                                                                                                               
                                                                                                               
                      16/03/2004 22:27                                                                         
                                                                                                               
                                                                                                               




Hi David,

you're right, that's a great idea :)
Do you know how I could do the same with volumes?

Thanks David,

Laurent

David.Pont at ForestResearch.co.nz wrote:

>Hi Laurent,
>   just another thought, if you want to clip with an ovoid of specific
size
>you could use vtkSphere, SetTransform where vtkTransform->Scale is
>something other than (x,x,x), eg: (2,1,1) to get an ovoid with known
>dimensions. vtkSuperquadric is more general but do you really need that
>much flexibility in shape?
>In either case rendering a polygonized implicit surface (with opacity<1 or
>as wireframe) will give visual feedback of size.
>   Dave P
>
>
>
>

>                      Laurent Mundeleer

>                      <lmundele at ulb.ac.        To:
David.Pont at ForestResearch.co.nz
>                      be>                      cc:       vtk
<vtkusers at vtk.org>
>                      Sent by:                 Subject:  Re: [vtkusers]
trying to clip a polyData with an
>                      vtkusers-admin at vt         other

>                      k.org

>

>

>                      12/03/2004 21:17

>

>

>
>
>
>
>Hi David,
>
>Eureka, I've two holes in my sphere! :)
>Thanks for the tip. But it will be hardy to generate something with a
>specified size...
>
>Now I'd like to have a real sphere, not just a surface, but something
>full on the inside, that will be cut by an ovoide. That will be simplier
>to visualize.
>I don't know if it's possible with vtkPolyData but maybe with a volume
>(i'm not used to them), and using the clipVolume.
>
>Thanks again for your help,
>
>Laurent
>
>David.Pont at ForestResearch.co.nz wrote:
>
>
>
>>Hi Laurent,
>> OK I got it:
>>With your settings for the positions and sizes of the sphere and
>>superquadric I could see from the colours on the sphere  (scalars from
>>GenerateClipScalarsOn) that the superquadric was 'close' to the left and
>>right sides of the sphere (from SetScale(2,1,1)).
>>
>>There is a warning in the doc on vtkSuperquadric:
>>"Warning:
>>The Size and Thickness parameters control coefficients of superquadric
>>generation, and may do not exactly describe the size of the
superquadric."
>>
>>So I simply altered SetScale to 4,1,1 and got holes clipped on each side
>>
>>
>of
>
>
>>the sphere :-))
>>Because you can not see an implicit surface, it is hard to know when your
>>polydata and implicit surface are in contact.
>>I have inserted my code below, note at the bottom I have used a class
>>vtkImplicitPolygonizer to visualise the implicit surface. This is a class
>>
>>
>I
>
>
>>have implemented that creates polydata from an implicit surface, very
>>useful.... As you obviously work in C++ I have attached the source code,
>>
>>
>it
>
>
>>may be useful for you... and I should contribute it to vtk as it seems to
>>work OK and have a real use.....
>>
>> Happy clipping
>>    Dave P
>>
>>PS: thanks for the tip about responding to vtkusers and admin. I have
>>noticed this in the past and have not figured out how this happens. Mail
>>
>>
>>from the list is usually sent to or cc'd to just vtkusers. But when I
>reply
>
>
>>somehow vtkadmin gets added. We are forced to use a particular mail
>>
>>
>program
>
>
>>(which I hate with a passion), maybe it is finding vtkadmin in my address
>>book and adding it ???? I will look closer at this....
>>
>>
>>
>> // polygonal sphere
>> vtkSphereSource *pd1 = vtkSphereSource::New();
>>   pd1->SetThetaResolution( 16 );
>>   pd1->SetPhiResolution (  16 );
>>   pd1->SetCenter( 0, 5, 0 );
>>   pd1->SetRadius( 10.0 );
>>
>> vtkSuperquadric *sq1 = vtkSuperquadric::New();
>>   sq1->SetCenter(0,5,0);
>>   sq1->SetSize(5);
>>//    sq1->SetScale(2,1,1);
>>   sq1->SetScale(4,1,1);
>>   sq1->ToroidalOff();
>>
>> vtkClipPolyData *clipper = vtkClipPolyData::New();
>>   clipper->SetInput( pd1->GetOutput() );
>>   clipper->SetClipFunction( sq1 );
>>   clipper->GenerateClipScalarsOn();
>>
>> vtkPolyDataMapper *Mapper = vtkPolyDataMapper::New();
>>   Mapper->SetInput( clipper->GetOutput() );
>> vtkActor *Actor = vtkActor::New();
>>   Actor->SetMapper( Mapper );
>> Renderer->AddActor( Actor );
>>
>> // polygonise the superquadric
>>-------------------------------------------------------------------------
>> float bounds[6] = { -20, 20, -10, 10, -10, 10 };
>> vtkImplicitPolygonizer *ip1 = vtkImplicitPolygonizer::New();
>>   ip1->SetImplicitFunction( sq1 );
>>   ip1->SetBounds( bounds );
>>   ip1->SetNormalAngle( 30 );                  // use lower angle to
>>refine the surface more, default is 50
>>   ip1->SetMaximumAdaptations( 4 );    // use higher value to refine the
>>surface more, default is 3
>> vtkPolyDataMapper *Mapper2 = vtkPolyDataMapper::New();
>>   Mapper2->SetInput( ip1->GetOutput() );
>> vtkActor *Actor2 = vtkActor::New();
>>   Actor2->SetMapper( Mapper2 );
>>   Actor2->GetProperty()->SetRepresentationToWireframe();
>> Renderer->AddActor( Actor2 );
>>
>>
>>(See attached file: vtkImplicitPolygonizer.h)(See attached file:
>>vtkImplicitPolygonizer.cpp)
>>
>>
>>
>>
>>
>>
>
>
>
>>                     Laurent Mundeleer
>>
>>
>
>
>
>>                     <lmundele at ulb.ac.        To:
>>
>>
>David.Pont at ForestResearch.co.nz
>
>
>>                     be>                      cc:
>>
>>
>
>
>
>>                                              Subject:  Re: [vtkusers]
>>
>>
>trying to clip a polyData with an
>
>
>>                     11/03/2004 22:53          other
>>
>>
>
>
>
>
>
>
>
>
>
>>
>>
>>Hi David,
>>see my interlaced comments ;-)
>>
>>David.Pont at ForestResearch.co.nz wrote:
>>
>>
>>
>>
>>
>>>Hi Laurent,
>>> your sphere is at 0,0,0 radius 10, the superquadric is at 0,5,0 size 5.
>>>This means they do not really intersect. Try sphere radius 5, or
>>>superquadric size 10 for example. The superquadric should then clip a
>>>
>>>
>hole
>
>
>>>
>>>
>>>from the side of the sphere.
>>
>>
>>
>>
>>>
>>>
>>I've juste tried (the superquadric had scale (2,1,1) so before it should
>>cut the poly too) but no changes, also with a better resolution on the
>>sphere :( >>
>>>Note that you can use SetInsideOut or SetGenerateClippedOutput +
>>>GetClippedOutput to get the clipped piece also.
>>>
>>>
>>>
>>>
>>>
>>>
>>now I try to visualize this, but it's still empty
>>
>>
>>
>>
>>
>>>The implicit function is only evaluated at the sphere points. If the
>>>implicit surface only passes through the interior of a polygon no hole
>>>
>>>
>>>
>>>
>>will
>>
>>
>>
>>
>>>result. Increase Set*Resolution to get more points and thus more
accurate
>>>clipping. To remedy problems with accuracy in clipping general polydata
>>>
>>>
>>>
>>>
>>you
>>
>>
>>
>>
>>>can pass the polydata through vtkLinearSubdivisionFilter (2 or 3
>>>iterations) before clipping. This simply makes smaller polygons and more
>>>points, giving the clipper more accuracy.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>I've tried this filter, no more changes...
>>My clippedOutput is still empty but with a non-null length (???).
>>
>>
>>
>>
>>
>>>(NB: vtkSuperQuadric is actually vtkSuperquadric)
>>>
>>>
>>>
>>>
>>>
>>>
>>bad typing ;-)
>>
>>
>>
>>
>>
>>>I am responding OFF the list to avoid being accussed of sending SPAM to
a
>>>Mr Byron Hale, until I figure out what is going on there ! ...
>>>
>>>
>>>
>>>
>>>
>>>
>>I think you forward to vtkusers at vtk.org AND to vtkusers-admin at vtk.org,
>>maybe you should remove the second one?
>>
>>
>>
>>
>>
>>>regards
>>>  Dave P
>>>
>>>
>>>
>>>
>>>
>>>
>>thanks again
>>Regards,
>>Laurent
>>
>>
>>
>>
>>
>>>
>>>
>>>
>>
>>
>>
>>>                    Laurent Mundeleer
>>>
>>>
>>>
>>>
>>
>>
>>
>>>                    <lmundele at ulb.ac.        To:
>>>
>>>
>>>
>>>
>>David.Pont at ForestResearch.co.nz
>>
>>
>>
>>
>>>                    be>                      cc:
>>>
>>>
>>>
>>>
>>
>>
>>
>>>                                             Subject:  Re: [vtkusers]
>>>
>>>
>>>
>>>
>>trying to clip a polyData with an
>>
>>
>>
>>
>>>                    11/03/2004 03:55          other
>>>
>>>
>>>
>>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>>Hi David,
>>>
>>>me again. I do just the same with a vtkSuperquadric, but now it seems
>>>that nothing is clipped.
>>>
>>>---
>>>vtkSuperQuadric *s = vtkSuperQuadric::New();
>>>s->SetCenter(0,5,0);
>>>s->SetSize(5);
>>>s->SetScale(2,1,1);
>>>s->ToroidalOff();
>>>
>>>vtkClipPolyData *clipper = vtkClipPolyData::New();
>>>clipper->SetInput(tumorSample->GetInput()); // tumorSample has on input
>>>a vtkSphereSource (center: 0,0,0 ; Radius : 10)
>>>
>>>clipper->SetClipFunction(s);
>>>clipper->GenerateClipScalarsOn();
>>>clipper->Update();
>>>
>>>tumorSample->SetInput(clipper->GetOutput());
>>>aff->ChargerModel3D(tumorSample);
>>>
>>>---
>>>
>>>thanks again
>>>
>>>Laurent
>>>
>>>David.Pont at ForestResearch.co.nz wrote:
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>Hi Laurent,
>>>>There is no way in vtk to clip one polydata with another.
>>>>vtkClipPolyData evaluates an implicit function at each point position
in
>>>>the polydata and then clips each cell according to the implicit
function
>>>>value at its points. So you can only clip with implicit surfaces.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>(Actually
>>>
>>>
>>>
>>>
>>>
>>>
>>>>you can also clip using scalar values associated with the polydata.) So
>>>>clipping and cutting in vtk is only done with implicit surfaces. Check
>>>>
>>>>
>>>>
>>>>
>>the
>>
>>
>>
>>
>>>>class doc for vtkImplicitFunction and see its descendants for the list
>>>>
>>>>
>of
>
>
>>>>possible 'shapes' you can clip with.
>>>>GetOutput and SetThetaResolution belong to vtkSuperquadricSource which
>>>>produces a polygonal surface, good to look at, but no use for clipping.
>>>>vtkSuperquadric is an implicit surface, difficult to look at, but just
>>>>right for clipping.
>>>>
>>>>hope that clarifies...
>>>> Dave P
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>>                   Laurent Mundeleer
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>>                   <lmundele at ulb.ac.        To:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>David.Pont at ForestResearch.co.nz
>>>
>>>
>>>
>>>
>>>
>>>
>>>>                   be>                      cc:       vtk
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>><vtkusers at vtk.org>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>                   Sent by:                 Subject:  Re: [vtkusers]
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>trying to clip a polyData with an
>>>
>>>
>>>
>>>
>>>
>>>
>>>>                   vtkusers-admin at vt         other
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>>                   k.org
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>                   09/03/2004 22:11
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>>Hi David,
>>>>
>>>>thanks for your answer, the problem with vtkSuperquadric is that
there's
>>>>no GetOutput(), SetThetaResolution(),...
>>>>
>>>>Is there another way to do that?
>>>>
>>>>Thanks
>>>>
>>>>Laurent
>>>>
>>>>David.Pont at ForestResearch.co.nz wrote:
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>Laurent,
>>>>>vtkImplicitDataSet uses the data set scalars to perform clipping, I am
>>>>>not sure what scalars (if any) are produced by vtkSuperqadricSource.
>>>>>
>>>>>
>But
>
>
>>>>>
>>>>>
>>>>>
>>>>>
>>>I
>>>
>>>
>>>
>>>
>>>
>>>
>>>>>see there is vtkSuperquadric which can be passed directly to
>>>>>vtkClipPolydata->SetClipFunction.
>>>>>
>>>>>Dave P
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>>                  Laurent Mundeleer
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>>                  <lmundele at ulb.ac.        To:       vtk
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>><vtkusers at vtk.org>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>                  be>                      cc:
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>>                  Sent by:                 Subject:  [vtkusers] trying
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>to clip a polyData with an other
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>                  vtkusers-admin at vt
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>>                  k.org
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>                  08/03/2004 22:56
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>>Hi All,
>>>>>
>>>>>I'dl like to clip a vtkPolyData with another one.
>>>>>Here's my code, based on the examples:
>>>>>
>>>>>---------------------
>>>>>
>>>>>vtkImplicitDataSet *v = vtkImplicitDataSet::New();
>>>>>v->SetDataSet(ovoideSample->GetInput()); // ovoideSample has on input
a
>>>>>vtkSuperquadricSource
>>>>>
>>>>>vtkClipPolyData *clipper = vtkClipPolyData::New();
>>>>>clipper->SetInput(tumorSample->GetInput()); // tumorSample has on
input
>>>>>a vtkSphereSource
>>>>>
>>>>>clipper->SetClipFunction(v);
>>>>>clipper->GenerateClipScalarsOn();
>>>>>clipper->Update();
>>>>>
>>>>>tumorSample->SetInput(clipper->GetOutput());
>>>>>aff->ChargerModel3D(tumorSample);
>>>>>
>>>>>---------------------
>>>>>
>>>>>but after that my tumorSample is empty.
>>>>>What do i wrong?
>>>>>
>>>>>Thanks in advance,
>>>>>Regards
>>>>>
>>>>>Laurent
>>>>>
>>>>>
>>>>>_______________________________________________
>>>>>This is the private VTK discussion list.
>>>>>Please keep messages on-topic. Check the FAQ at: <
>>>>>http://public.kitware.com/cgi-bin/vtkfaq>
>>>>>Follow this link to subscribe/unsubscribe:
>>>>>http://www.vtk.org/mailman/listinfo/vtkusers
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>--
>********************************************
>Laurent Mundeleer
>Université Libre de Bruxelles (ULB)
>Service des Systèmes Logiques et Numériques (SLN) CP165/57
>50, Av. F.Roosevelt
>1050 Bruxelles
>Belgium
>tel : ++32.2.650.22.97
>fax : ++32.2.650.22.98
>e-mail : lmundele at ulb.ac.be
>********************************************
>
>_______________________________________________
>This is the private VTK discussion list.
>Please keep messages on-topic. Check the FAQ at: <
>http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtkusers
>
>_ >
>
>
>
>
>
>

--
********************************************
Laurent Mundeleer
Université Libre de Bruxelles (ULB)
Service des Systèmes Logiques et Numériques (SLN) CP165/57
50, Av. F.Roosevelt
1050 Bruxelles
Belgium
tel : ++32.2.650.22.97
fax : ++32.2.650.22.98
e-mail : lmundele at ulb.ac.be
********************************************

_______________________________________________
This is the private VTK discussion list.
Please keep messages on-topic. Check the FAQ at: <
http://public.kitware.com/cgi-bin/vtkfaq>
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers

_







More information about the vtkusers mailing list