<html><div style='background-color:'><P><FONT face="Times New Roman, Times, Serif" size=2>Sebastien,</FONT></P>
<P><FONT face="Times New Roman, Times, Serif" size=2> This might be a result of the way implicit functions are evaluated. If there is a polygon defined by four points and your implicit loop outlines a circle as below</FONT></P>
<P><FONT face="Courier New, Courier, Monospace">+--+<BR>| O|<BR>+--+</FONT></P>
<P><FONT face="Geneva, Arial, Sans-serif"><FONT face="Times New Roman, Times, Serif" size=2>the implicit function is evaluated only at the four points, which will all be "out" so the cell will not be clipped. If we move the implicit circle<BR></FONT></P>
<P><FONT face="Courier New, Courier, Monospace">+--O +-. <BR>| | | \<BR>+--+ +--+</FONT></P>
<P><FONT face="Times New Roman, Times, Serif" size=2>the top right point is "in" and the linear interpolation used in clipping will give a result something like shown. The nett effect is a mixture of polygons where you expected none, and holes where you expected polygons. Your polygons probably are being clipped, just not the way you would expect.</FONT></P>
<P><FONT face="Times New Roman, Times, Serif" size=2>A solution I have used is to pass the polydata to be clipped (your DEM) through vtkLinearSubdivisionFilter with 2 or 3 iterations (be careful, the execution time increases rapidly...). This subdivides polygons (recursively) and produces smaller polygons which thus sample the implicit function more accurately. The problem is that a lot of polygons are produced unecessarily beyond the region you are clipping. I suppose you could decimate afterwards, if your DEM does not consume all your memory first!</FONT></P>
<P><FONT face="Times New Roman" size=2>I have been thinking about a smarter solution: make a clipper which does adaptive refinement of the clip boundary, ie on cells which are to be clipped, keep subdividing until the implicit value reaches a given threshold. This would give more like the 'expected' behaviour, and do so quite efficiently.... but I have no time...</FONT></P>
<P><FONT face="Times New Roman, Times, Serif" size=2> hope this helps,</FONT></FONT><FONT face="Times New Roman, Times, Serif" size=2> Dave Pont</FONT></P>
<DIV></DIV>
<DIV></DIV>>From: "Sebastien_MARAUX" <MARAUX@ONDIM.FR>
<DIV></DIV>>To: "vtk mailing list" <VTKUSERS@PUBLIC.KITWARE.COM>
<DIV></DIV>>Subject: [vtkusers] vtkClipPolyData does not clip properly.
<DIV></DIV>>Date: Wed, 5 Jun 2002 20:37:45 +0200
<DIV></DIV>>
<DIV></DIV>>Hello,
<DIV></DIV>>
<DIV></DIV>>With selection Loop as an implicit
<DIV></DIV>>function, vtkClipPolyData does not
<DIV></DIV>>clip as I think it should : It only
<DIV></DIV>>keeps faces entirely contained by
<DIV></DIV>>the clip volume, instead of producing
<DIV></DIV>>new triangles when faces are partially
<DIV></DIV>>contained by the clip volume.
<DIV></DIV>>
<DIV></DIV>>Usually, vtkClipPolyData is able to produce
<DIV></DIV>>new triangles to respect clipping Volume,
<DIV></DIV>>
<DIV></DIV>>How can I obtain those triangles ?
<DIV></DIV>>Is there a probleme with InsideOutOn ?
<DIV></DIV>>
<DIV></DIV>>here is my code :
<DIV></DIV>>
<DIV></DIV>>/*============================================*/
<DIV></DIV>> vtkIdList *DEMPoints = vtkIdList::New();
<DIV></DIV>> vtkImplicitSelectionLoop *clipLoop = vtkImplicitSelectionLoop::New();
<DIV></DIV>> points->Reset();
<DIV></DIV>>
<DIV></DIV>> // recuperation de la cellule courante
<DIV></DIV>> dataGISClean->GetCellPoints(i,DEMPoints);
<DIV></DIV>>
<DIV></DIV>> clipLoop->SetLoop(points);
<DIV></DIV>> clipLoop->SetNormal(0.0,1.0,0.0); // my y is height cause of vrml export
<DIV></DIV>>
<DIV></DIV>> // ajout du clipping du mnt selon les polygones
<DIV></DIV>> vtkClipPolyData *clipper3=vtkClipPolyData::New();
<DIV></DIV>> clipper3->SetInput(pdn->GetOutput());
<DIV></DIV>> clipper3->GenerateClipScalarsOn();
<DIV></DIV>> clipper3->SetClipFunction(clipLoop);
<DIV></DIV>> clipper3->GenerateClippedOutputOff();
<DIV></DIV>> clipper3->InsideOutOn();
<DIV></DIV>> clipper3->SetValue(0.5);
<DIV></DIV>> clipper3->Update();
<DIV></DIV>>
<DIV></DIV>> cout <<I <<dataGISClean- ? <<?>GetNumberOfPolys() <<ENDL; DIV <>> cout <<"nombre de polygones : " <<CLIPPER3->GetOutput()->GetNumberOfPolys() <<ENDL; DIV <>>
<DIV></DIV>> if (dataGISClean->GetNumberOfCells() > 0){
<DIV></DIV>> vtkIdList *listCells = vtkIdList::New();
<DIV></DIV>> for (j=0;j<CLIPPER3->GetOutput()->GetNumberOfCells();j++)
<DIV></DIV>> {
<DIV></DIV>> listCells->InsertNextId(j);
<DIV></DIV>> }
<DIV></DIV>>
<DIV></DIV>> //clipper3->GetOutput() does not contain a properly clipped DEM
<DIV></DIV>> dataGIS1->CopyCells(clipper3->GetOutput(),listCells);
<DIV></DIV>> }
<DIV></DIV>>/*===============================================================*/
<DIV></DIV>>
<DIV></DIV>>
<DIV></DIV>>Sebastien MARAUX
<DIV></DIV></I></div><br clear=all><hr>Chat with friends online, try MSN Messenger: <a href='http://g.msn.com/1HM504201/40'>Click Here</a><br></html>