[vtkusers] Re: Pb using vtkAppendPolyData & vtkPolyDataConnectivityFilter

Thomas Deschamps tdeschamps at lbl.gov
Wed Apr 16 18:36:43 EDT 2003


Dear vtkUsers,

I am still trying to select some 2D contours which are smaller or equal 
to a given number of lines (not all contours are closed)

I've found something that I don't understand using 
vtkPolyDataConnectivityFilter & vtkAppendPolyData.
Using the code mentionned in the previous thread, i've realized that the 
myPolyData is strangely modified by this routine. If I keep a copy of my 
object and I compare them after, I can see that:

Before:
  Verts = 0x87bd290
  Lines = 0x862cbb0
  Polys = 0x862cc58
  Strips = 0x8624f80

After
  Verts = 0x0
  Lines = 0x85a3ea8
  Polys = 0x0
  Strips = 0x0

And I've found another strange behavior: if I rerun the same routine on 
my new polydata, it takes MUCH longer (x10).
All this time is takent by connectivity -> Update();
It is like the polydata created by vtkAppendPolyData takes more time to 
be accessed by  the method SetExtractionModeToSpecifiedRegions();
Anyone has an idea?

Thomas

Thomas Deschamps wrote:

> Hi vtkUsers,
>
> I am using vtkAppendPolyData for selecting contours which have a 
> certain length among all the contours I have.
> My problem is that it takes a LOT of time.
>
> The following code remove all the closed contours which have a length 
> smaller than contourLength
>           void function( int contourLength, vtkPolyData * myPolyData )
> {
>    vtkPolyDataConnectivityFilter * connectivity = 
> vtkPolyDataConnectivityFilter::New ();
>    connectivity -> SetInput( myPolyData );
>    connectivity -> SetExtractionModeToSpecifiedRegions();
>    connectivity -> Update();
>
>    vtkPolyData * localPolyData = vtkPolyData::New();
>    int nbRegions = connectivity -> GetNumberOfExtractedRegions();
>              for( int i = 0 ; i < nbRegions ; i++ ) {
>        vtkAppendPolyData * append = vtkAppendPolyData::New();
>        connectivity -> AddSpecifiedRegion(i);
>        connectivity -> Update();
>        int nbLines = connectivity -> GetOutput() -> GetNumberOfLines();
>                                     if( nbLines >= contourLength )
>            append -> AddInput( connectivity -> GetOutput() );
>                      append -> AddInput( localPolyData );
>        append -> Update();
>        localPolyData -> DeepCopy( append -> GetOutput());
>        connectivity -> DeleteSpecifiedRegion(i);
>        append -> Delete();
>     }
>                          myPolyData -> DeepCopy( localPolyData );
>     localPolyData -> Delete();
>     connectivity -> Delete();
> }
>
> You may ask why I am not using the "append" outside of the loop.
> This is because it looks like append -> AddInput() is not making a 
> copy of the input polydata, but keeps track of the pointer, even if 
> this pointer is modified in the future. Therefore it was not working 
> like that.
>
> When the number of contours is > 1000, and when each contour is 
> between 4 and 700 lines, it takes 30 minutes...
> There is surely something more efficient that what I am doing, but I 
> don't know what.
> Thank you for reading this.
>
> Thomas (tdeschamps at lbl.gov)
>
>
>





More information about the vtkusers mailing list