[vtkusers] Re: problem with GetNumberOfPoints () and GetNumberOfCells ()

Dave Reed dreed at capital.edu
Thu Feb 21 19:14:26 EST 2002


> From: Marco Kassner <kassner at cs.tu-berlin.de>
> 
> Hello.
> 
> This is my first mail to the group.
> I develop a program which reads voxel data and calculates Spinmaps.
> Representing the data works easily but I have a problem to access the
> PolyData.
> I receive the result null for the function GetNumberOfPoints () and
> GetNumberOfCells ().
> 
> Please, can somebody tell me, which filter I still need or where the error
> is ?
> 
> It would be great, if somebody can help me.
>
> My program:
> 
> // first data read
>  vtkVolume16Reader *v16 = vtkVolume16Reader::New();
>     v16->SetDataDimensions(64,64);
>     v16->SetDataByteOrderToLittleEndian();
>     v16->SetFilePrefix ("D:\\VTK32\\vtkdata\\headsq\\quarter");
>     v16->SetImageRange(1, 93);
>     v16->SetDataSpacing (3.2, 3.2, 1.5);
> 
> // extract the skin
>   vtkContourFilter *skinExtractor = vtkContourFilter::New();
>     skinExtractor->SetInput(v16->GetOutput());
>     skinExtractor->SetValue(0, 500);
>   vtkStripper *skinStripper = vtkStripper::New();
>     skinStripper->SetInput(skinExtractor->GetOutput());
> 
> // forcing triangles
>   vtkTriangleFilter *skinTriangleFilter = vtkTriangleFilter:: New() ;
>     skinTriangleFilter->SetInput(skinStripper->GetOutput()) ;
> 
> // data reduce
>   vtkDecimate  *skinDecimate = vtkDecimate::New();
>     skinDecimate->SetInput(skinTriangleFilter->GetOutput());
>     skinDecimate->SetAspectRatio (20.0);
>     skinDecimate->SetInitialError (0.0005);
>     skinDecimate->SetErrorIncrement (0.001);
>     skinDecimate->SetMaximumIterations (10);
>     skinDecimate->SetMaximumNumberOfSquawks (0);
>     skinDecimate->PreserveEdgesOff () ;
> 
> // type PolyData
>   vtkPolyData *polydatatemp = vtkPolyData::New();
>     polydatatemp = skinDecimate->GetOutput() ;
> 
>     printf ("\nGetNumberOfPoints = %i",polydatatemp->GetNumberOfPoints()) ;    // output = 0
>     printf ("\nGetNumberOfCells = %i",polydatatemp->GetNumberOfCells()) ;      // output = 0
> 
> 
> 
>                                 Thanks, Marco



What are you trying to achieve?  I'm not an expert on the internal VTK
data structures, but I would think it only makes sense to ask a
vtkPolyData object about its number of polygons, not its number of cells.

Also, I don't think it makes sense to create triangle strips before
decimating. I thought the purpose of strips was to provide faster
rendering via OpenGL triangle strips.

Dave



More information about the vtkusers mailing list