[vtkusers] vtkClipPolyData with vtkBox doesn't work

Eric E. Monson emonson at cs.duke.edu
Mon Feb 1 10:46:18 EST 2010


Hey Adeline,

Yes, it looks like you're running into the same sort of problem as with vtkExtractPolyDataGeometry -- since none of your points or cells are completely inside or outside the box, you are either clipping none of them, or clipping all of them. If you move the box widget over so it overlaps one of the ends of the box you want clipped, you'll see that it removes or leaves that end of the box, depending on whether Inside Out is checked or not. (I'll attach a screen shot of this.)

ParaView uses a slight variant of vtkClipDataSet for the clip filter, but from the documentation it sounds like it it should do what you want. The Plane, as you said, seems to do what it's supposed to and cuts cells that intersect the plane, but the Box and Sphere don't seem to cut the underlying geometry. 

It's got to be something about how cutting with a single plane will guarantee straight edges on the clipped geometry, so when cells are clipped they can be split right at the plane boundary, but when you have something like a box or sphere, individual cells might get split into quite complicated shapes where the surfaces intersect... 

Hopefully someone else will know more of the details of why using a box or sphere as the implicit function for clipping give results like this, whereas a plane cuts nicely.

Sorry such a seemingly simple operation is giving you so much trouble.
-Eric



On Feb 1, 2010, at 7:41 AM, Adeline Joliet wrote:

> Hello again,
> 
> sorry for not having replied for such a long time...
> So i used Paraview to reproduce my "simpel" pipeline.. 
> 
> Generate a Box
> Apply the Clipping
> 
> And.. it doesn't work.. I have attached 2 screenshot, before and after the apply. We can see the clipping box, but when I click on Apply
> Nothing is clipped.. the cube just change a bit his color..
> 
> Howerver if I use "plane" as a clipping function.. it works...
> 
> Regards,
> Adeline
> 
> From: frederic.danesi at dinccs.com
> To: adeline_joli at hotmail.com; emonson at cs.duke.edu
> CC: vtkusers at vtk.org
> Subject: RE: [vtkusers] vtkClipPolyData with vtkBox doesn't work
> Date: Mon, 18 Jan 2010 11:01:24 +0100
> 
> … it’s not cutting …
> Your polydata (output of a cube source) is rendered as a set of cells (quad or triangle for example). Extracting does not cut … it remove some cells : if a cell is overlapping your section plane, it will not cut the cell … it will consider the cell as outside your selection …
>  
> However, if the problem remains while using vtkClipPolyData, then there is another problem somewhere …
> Hopefully, paraview will help you figure that out.
>  
> Fred.
>  
> Cordialement,
> F.Danesi
> --
> Responsable Développement Informatique et Travail Collaboratif
> Centre Technique DINCCS (Centre Technique Dédié à l’Ingénierie Numérique, la Conception Collaborative et la Simulation)
> MICADO / DINCCS
> Pôle de Haute Technologie, BP 90005
> 08005 Charleville-Mézières Cedex
> Tel. : +33 (0) 3.24.41.69.55 / +33 (0) 6.62.76.13.32
> Email : frederic.danesi at dinccs.com
> Web : www.afmicado.com / www.dinccs.com
>  
> -----
>  
> DISCLAIMER :
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
>  
> De : Adeline Joliet [mailto:adeline_joli at hotmail.com] 
> Envoyé : lundi 18 janvier 2010 10:56
> À : frederic.danesi at dinccs.com; emonson at cs.duke.edu
> Cc : vtkusers at vtk.org
> Objet : RE: [vtkusers] vtkClipPolyData with vtkBox doesn't work
>  
> Hello frederic,
> 
> yes I know the subject is about vtkClipPolyData but meanwhile I found the vtkExtractPolyDataGeometry.
> "vtkExtractPolyDataGeometry extracts from its input  all cells that are either completely inside or outside of a specified implicit function."
> 
> that's exactly what I would like to do (it's a kind of cutting no ?) anyway the problem it's the same either withvtkExtractPolyDataGeometry or vtkClipPolyData 
> 
> not also that in the code I initialized vtkCubeSource * rectangle = vtkCubeSource::New(); instead of simpleCube...
> 
> And thank you for the tip ! I didn't know that, I will try right now.
> 
> Regards,
> Adeline
> 
> 
> From: frederic.danesi at dinccs.com
> To: adeline_joli at hotmail.com; emonson at cs.duke.edu
> CC: vtkusers at vtk.org
> Subject: RE: [vtkusers] vtkClipPolyData with vtkBox doesn't work
> Date: Mon, 18 Jan 2010 10:35:54 +0100
> 
>  
> Hi,
>  
> The subject is about vtkClipPolyData, but in your code you are using vtkExtractPolyDataGeometry as a clipper …
> This filter does not cut anything ! vtkExtractPolyDataGeometry extracts from its input  all cells that are either completely inside or outside of a specified implicit function.
>  
> All you have to do here is change your filter …
>  
> Just a quick tip : when I am stuck like this on common filters, I usually try my pipeline by building it manually into Paraview. You can directly see the results or change the filter parameters (such as the bounds, the implicit function you’re using, …).
>  
> HTH,
> Fred.
>  
> Cordialement,
> F.Danesi
> --
> Responsable Développement Informatique et Travail Collaboratif
> Centre Technique DINCCS (Centre Technique Dédié à l’Ingénierie Numérique, la Conception Collaborative et la Simulation)
> MICADO / DINCCS
> Pôle de Haute Technologie, BP 90005
> 08005 Charleville-Mézières Cedex
> Tel. : +33 (0) 3.24.41.69.55 / +33 (0) 6.62.76.13.32
> Email : frederic.danesi at dinccs.com
> Web : www.afmicado.com / www.dinccs.com
>  
> -----
>  
> DISCLAIMER :
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.
>  
> De : vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] De la part de Adeline Joliet
> Envoyé : vendredi 15 janvier 2010 16:42
> À : emonson at cs.duke.edu
> Cc : vtkusers at vtk.org
> Objet : Re: [vtkusers] vtkClipPolyData with vtkBox doesn't work
>  
> Hello,
> 
> Ok, here a simple code
> 
> 
> // this is the futur cuted polydata..
>  vtkCubeSource * rectangle = vtkCubeSource::New();
>                 
> simpleCube->SetCenter(0,0,0);
> simpleCube->SetXLength(150);
> simpleCube->SetYLength(40);
> simpleCube->SetZLength(100);
> 
> 
> vtkBox * boxFunc = vtkBox::New();
> 
>  // a 20x20x20 box.
> // I displayed a vtkCubeSource with the same bounds and it clearly intersect with the rectangle...
> 
>  double testBounds[6];
>  testBounds[0] = -10.0;
>  testBounds[1] = 10.0;
>  testBounds[2] = -10.0;
>  testBounds[3] = 10.0;
>  testBounds[4] = -10;
>  testBounds[5] = 10.0;
> 
>  boxFunc->SetBounds(testBounds);
> 
>  vtkExtractPolyDataGeometry * clipper3 = vtkExtractPolyDataGeometry::New();
> 
>  clipper3->SetInput(simpleCube);
>  clipper3->SetImplicitFunction(boxFunc);
>  clipper3->ExtractInsideOn();
>  clipper3->Update();
> 
> 
> // Rendering stuff...
>  vtkPolyDataMapper *map2 = vtkPolyDataMapper::New();
>  map2->SetInput(clipper2->GetOutput());
> 
>  vtkActor* act2 = vtkActor::New();
>  act2->SetMapper(map2);
>  act2->SetProperty( this->CubeProperty);
>  this->CurrentRenderer->AddActor(act2);
> 
> 
> And renctangle is not displated.... if I se tExtractInsideOff rectangle is displayed
> but not cuted...
> 
> Regards,
> Adeline
> 
> Subject: Re: [vtkusers] vtkClipPolyData with vtkBox doesn't work
> From: emonson at cs.duke.edu
> Date: Fri, 15 Jan 2010 10:10:00 -0500
> CC: vtkusers at vtk.org
> To: adeline_joli at hotmail.com
> 
> Hello Adeline,
>  
> (Please reply to the whole list so others can help if they have ideas, too.)
>  
> Okay, if setting the bounds manually doesn't work, maybe you can post a more complete code sample and someone will be able to play with it or spot the problem.
>  
> Good luck,
> -Eric
>  
>  
> On Jan 15, 2010, at 5:00 AM, Adeline Joliet wrote:
>  
> Hello Eric,
> 
> Thank's for the answer.
> 
> "So, are you seeing nothing when you render your scene?"
> Actually no, nothing appends my Polydata is not "cuted" it's exactly the same size
> 
> Then I tried InsideOutOn() and now nothing is dislplayed.
> 
> I don't know where I can be wrong.. I will try again to set the bounds manually, but not sure that's the problem..
> 
> Regards,
> Adeline
> Subject: Re: [vtkusers] vtkClipPolyData with vtkBox doesn't work
> From: emonson at cs.duke.edu
> Date: Thu, 14 Jan 2010 14:28:52 -0500
> CC: vtkusers at vtk.org
> To: adeline_joli at hotmail.com
> 
> Hello Adeline,
>  
> So, are you seeing nothing when you render your scene? One thing to be careful of when using a box for your clip function is which direction the default normals of the box faces point -- this defines whether the clip leaves the inside intact or cuts out the inside of the box. Maybe this isn't the problem you're having, but you could try setting 
>  
> clipper->InsideOutOn();
>  
> and see if anything shows up.
>  
> Otherwise, there are examples of clipping with the vtkBoxWidget and it's GetPlanes method in {vtksource}/Widgets/Testing/Cxx/BoxWidget.cxx and {vtksource}/Examples/GUI/Python/BoxWidget.py in case those could help you track down the problem or approach it in another way. 
>  
> Talk to you later,
> -Eric
>  
> ------------------------------------------------------
> Eric E Monson
> Duke Visualization Technology Group
>  
>  
> On Jan 14, 2010, at 12:29 PM, Adeline Joliet wrote:
>  
> Hello,
> 
> I'm trying to cut un polydata using vtkClipPolyData with a vtkBox as implicit function.
> 
> my Polydata is simply a rectangle (x = 100, y = 50, z= 20). I'd like to cut this rectangle to obtain
> only the part of the middle.. (so i'd like to cut to a right side AND a left side...)
> 
> here is the code
> 
>  vtkBox * cuting = vtkBox::New();
>   double boundy[6];
> 
>   //m_image is a vtkImageData that represent a cube (my rectangle polydata interect this cube, so the bounds should be correct...)
>   m_image->GetBounds(boundy);
> 
>   cuting->SetBounds(boundy);
>  
> vtkClipPolyData * clipper = vtkClipPolyData::New();
> clipper->SetInput(newPolyData);
> clipper->SetClipFunction(cuting);
> 
> // and then I display clipper->GetOutput...
> 
> the thing is that i tried with vtkPlane and it works... but the problem is that i need if a use
> vtkPlane I can cut only One side....
> 
> 
> any help would be appreciated,
> Than's
> 
> Adeline
> 
> Windows 7 : Trouvez le PC qui vous convient! Découvrez notre offre !_______________________________________________
> Powered by www.kitware.com
> 
> Visit other Kitware open-source projects athttp://www.kitware.com/opensource/opensource.html
> 
> Please keep messages on-topic and check the VTK FAQ at:http://www.vtk.org/Wiki/VTK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>  
>  
> Faites une bonne action avec Bing Solidaire ! C'est ici !
>  
>  
> Vous cherchez l'intégrale des clips de Michael Jackson ? Bing ! Trouvez !
> Ce message entrant est certifié sans virus connu.
> Analyse effectuée par AVG - www.avg.fr
> Version: 8.5.432 / Base de données virale: 270.14.141/2622 - Date: 01/14/10 19:35:00
>  
> Windows 7 : Trouvez le PC qui vous convient! Découvrez notre offre !
> Ce message entrant est certifié sans virus connu.
> Analyse effectuée par AVG - www.avg.fr
> Version: 8.5.432 / Base de données virale: 270.14.148/2629 - Date: 01/17/10 19:35:00
> 
> Vous cherchez l'intégrale des clips de Michael Jackson ? Bing ! Trouvez ! <beforeclip.jpg><afterclip.jpg>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100201/7b401fe1/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: BoxClipOverlappingEnd.jpg
Type: image/jpg
Size: 59108 bytes
Desc: not available
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100201/7b401fe1/attachment.jpg>


More information about the vtkusers mailing list