[vtkusers] Loss of precision vtkCutter with vtkPlanes with vtk 5.10.1 - Reposting
Rémy Trichet
remy.trichet at zimmercas.com
Thu Feb 14 12:08:00 EST 2013
I tried to post on vtkusers but had no success yet, so I am trying on vtk-developers.
Remy
From: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] On Behalf Of Rémy Trichet
Sent: Wednesday, February 13, 2013 11:44 AM
To: vtkusers at vtk.org
Subject: [vtkusers] Loss of precision vtkCutter with vtkPlanes with vtk 5.10.1
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/20130214/15b07f45/attachment.htm>
More information about the vtkusers
mailing list