[vtkusers] Loss of precision vtkCutter with vtkPlanes with vtk 5.10.1

Rémy Trichet remy.trichet at zimmercas.com
Wed Feb 13 11:43:38 EST 2013


Hi,

I am trying to use a vtkCutter with vtkPlanes as CutFunction, and then get the output.
I set a vtkPlane with a normal (0.0, 0.0, 1.0) and an origin of (-1.0, -1.0, 0.5).
My source is half a sphere centered on (-1.0,-1.0,0.5) and with z > 0.5.
When I do the cut, and try to get the output, this is empty.
I try to cut the entire sphere instead of only a half with the same vtkPlane and get the output (with vtkPolyData::GetPoint(i)) and
I see that the resulting points have a z = 0.49999999046325684 instead of 0.5, which explains that the output is empty when I use half the sphere.
I am only using doubles and the vtk methods I am calling return also doubles, so I am wondering why this happens, and if I am doing something wrong?

Here is the sample  :

   vtkSmartPointer<vtkPlane> plane3 = vtkSmartPointer<vtkPlane>::New();
   plane3->SetNormal(0.0,0.0,1.0);
   plane3->SetOrigin(-1.0,-1.0, 0.5);
   vtkSmartPointer<vtkSTLReader> roiModelReader =
      vtkSmartPointer<vtkSTLReader>::New();
   roiModelReader->SetFileName("HalfSphere.stl");
   roiModelReader->Update();
   vtkSmartPointer<vtkCutter> cutterForROI =
      vtkSmartPointer<vtkCutter>::New();
   cutterForROI->SetInputConnection(roiModelReader->GetOutputPort());

   cutterForROI->SetCutFunction(plane3);
   cutterForROI->Update();
   vtkPointSet* dataSet = cutterForROI->GetOutput();
   int nbrPoints = dataSet->GetNumberOfPoints(); // = 0 with half the sphere
   double* point;
   for(int i = 0; i<nbrPoints; ++i)
      {
         point = dataSet->GetPoint(i); // point[2] = 0. 0.49999999046325684 when using the whole sphere
      }



Thanks,

Remy Trichet
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20130213/d56a1836/attachment.htm>


More information about the vtkusers mailing list