[vtkusers] Problem with surface reconstruction and contour filter in C++.

Andrew J. P. Maclean a.maclean at acfr.usyd.edu.au
Mon Oct 14 02:52:32 EDT 2002


I am using the latest nightly build (13-Oct-2002). 

 

I seem to be unable to reconstruct a surface using
vtkSurfaceReconstructionFilter in C++ with the following code:

 

// Filled a vtkPolyData structure with points from
//$VTK_DATA_ROOT/Data/cactus.3337.pts.

      nPts = polyData->GetNumberOfPoints(); 

      // A nPts = 3337 points

      polyData->GetBounds(bounds);

 

      polyData->Modified();

      surf->SetInput( polyData );

      surf->Update();

      nPts = ((vtkDataSet * )surf->GetOutput())->GetNumberOfPoints();

      // B nPts = 75760 points

      ((vtkDataSet * )surf->GetOutput())->GetBounds(bounds);

 

      // Contour at 0 to extract the surface.

      vtkContourFilter * cf = vtkContourFilter::New();

      cf->SetInput( (vtkDataSet * )surf->GetOutput());

      cf->SetValue(0,0.0);

      cf->Update();

      nPts = cf->GetOutput()->GetNumberOfPoints();

      // C nPts = 0 points

      cf->GetOutput()->GetBounds(bounds);

 

      // Sometimes the contouring algorithm can create a volume whose
gradient

      // vector and ordering of polygon (using the right hand rule) are 

      // inconsistent. vtkReverseSense cures this problem.  

      vtkReverseSense * rev = vtkReverseSense::New();

      rev->SetInput(cf->GetOutput());

      rev->ReverseCellsOn();

      rev->ReverseNormalsOn();

      rev->Update();

 

      polyData->DeepCopy(rev->GetOutput());

 

 

This is a translation of the TCL code in the example
reconstructSurface.tcl. 

polyData is a vtkPolyData structure filled with points from the file
$VTK_DATA_ROOT/Data/cactus.3337.pts

nPts at point A has the value: 3337. At B, npts = 75760, which is
expected as the surface

has been constructed. However at C, nPts is zero and the bounds all have
VTK_LARGE_FLOAT in them!

The contour filter doesn't seem to be producing any output. 

One oddity now is that I have had to put in the type conversion
(vtkDataSet * ) at the indicated points as a result of the VC7 compiler
telling me: 

'vtkDataSetToPolyDataFilter::SetInput' : cannot convert parameter 1 from
'vtkImageData *' to 'vtkDataSet *'

        Types pointed to are unrelated; conversion requires
reinterpret_cast, C-style cast or function-style cast

 

I thought that vtkContourFilter takes any dataset (and this is supported
by the documentation).

This type conversion did not have to be specified in the older nightly
builds ( before August).

Another oddity is that the TCL example code works OK ( I am using
TCL8.4.0).

 

 

Can someone please help?

 

Thanks

   Andrew

 

 

___________________________________________

Andrew J. P. Maclean

Postal:

Australian Centre for Field Robotics

The Rose Street Building J04

The University of Sydney  2006  NSW

AUSTRALIA

 

Room:  106

Phone: +61 2 9351 3283

Fax:   +61 2 9351 7474

       http://www.acfr.usyd.edu.au/

 

___________________________________________

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20021014/761593d0/attachment.htm>


More information about the vtkusers mailing list