[vtkusers] Re: Pb using vtkAppendPolyData & vtkPolyDataConnectivityFilter - Error in a vtk class?
TDeschamps at lbl.gov
TDeschamps at lbl.gov
Thu Apr 17 14:15:57 EDT 2003
Dear vtkUsers,
Trying to find a solution to my problem, I went on studying the
vtkPolyDataConnectivityFilter.cxx file, and I've found something which
explains why it takes so long, but I am not sure if it is done on
purpose or if it is a mistake:
If I try to use this filter to get all connected regions:
vtkPolyDataConnectivityFilter * connectivity =
vtkPolyDataConnectivityFilter::New ();
connectivity -> SetInput( myPolyData );
connectivity -> SetExtractionModeToSpecifiedRegions();
connectivity -> Update();
Then the following code returns
myPolyData -> GetNumberOfLines(); --> 29552
myPolyData -> GetNumberOfPoints(); --> 29572
connectivity -> GetNumberOfExtractedRegions(); --> 228
connectivity -> AddSpecifiedRegion(10);
connectivity -> Update();
connectivity -> GetOutput() -> GetNumberOfLines(); --> 194
connectivity -> GetOutput() -> GetNumberOfPoints(); --> 29572!!!
The number of points in one of the regions is exactly the same than the
total number of points. If I append all the regions with
vtkAppendPolyData the total number of points will therefore be 228 x
29572 > 6.10^6, while it should be 29572 only.
Notice that the number of lines is correct.
So my question is: is there something I did not catch in the way this
filter works, or is it an error?
Thomas (tdeschamps at lbl.gov)
----- Original Message -----
From: Thomas Deschamps <tdeschamps at lbl.gov>
Date: Wednesday, April 16, 2003 3:36 pm
Subject: Re: Pb using vtkAppendPolyData & vtkPolyDataConnectivityFilter
> 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