[vtkusers] vtkConnectivityFilter and vtkStripper low performances

Nicolas Sarrasin nsarrasin at phenix-systems.com
Fri Jun 4 12:04:22 EDT 2010


Hi all,

I'm working on contour resulting from vtkCutter.
 From contour, I would like to get all points related to each regions of 
my contour.

My code works but I encounter some performance problems on a mesh : it 
takes 8min to compute the process and 70% of the computation is taken by 
vtkPolyDataConnectivityFilter and also vtkStripper is quite low.

For information, my mesh contains ~37000 triangles and a lot of holes

I have already done this before without using Vtk and it took me less 
time (less than 30sec) so I guess ther's should be some optimisation.

- one a hand, I would like to know if I use the best way to do what I want
- on the other hand, does anybody have an idea to optimize this code ?

Here is a pseudo code which illustrates my development :

slice = vtkCutter->getOutput();

vtkPolyDataConnectivityFilter filter;
filter->SetExtractionModeToAllRegions();
filter->SetInput(slice);
filter->Update();

nb_contours = filter->GetNumberOfExtractedRegions(); //- nb_contours : ~900

for i=0 to nb_contours
{

     //EXTRACTING EACH REGION OF THE CUTTER RESULT
     filter->InitializeSpecifiedRegionList();
     filter->AddSpecifiedRegion(idx);
     filter->Update();

     vtkPolyData contour;
     contour->DeepCopy(filter->GetOutput());
     contour->Update();

     //GETTING ALL LINES FROM EACH REGION
     vtkStripper stripper;
     stripper->SetInput(contour);
     stripper->Update();

     int numberOfLines = stripper->GetOutput()->GetNumberOfLines();

     vtkSmartPointer<vtkPoints> points = stripper->GetOutput()->GetPoints();
     vtkSmartPointer<vtkCellArray> lines = 
stripper->GetOutput()->GetLines();

     vtkIdType *indices;
     vtkIdType numberOfPoints;
     unsigned int lineCount = 0;

     for (lines->InitTraversal(); lines->GetNextCell(numberOfPoints, 
indices); lineCount++)
     {
     //GETTING ALL POINTS FROM LINES
         for (vtkIdType i = 0; i < numberOfPoints; i++)
         {
             double coord[3];
             points->GetPoint(indices[i], coord);

             //...
         }

     }
}

Please help me with this problem

Thanks by advance,

Nicolas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100604/a4c45046/attachment.htm>


More information about the vtkusers mailing list