[vtkusers] vtkSurfaceReconstruction coordinate error

David E DeMarle dave.demarle at kitware.com
Tue Feb 18 08:47:49 EST 2014


This was fixed yesterday in the master branch I think.
See: http://review.source.kitware.com/#/c/14367/
Try back porting that fix to your VTK 5.10 an let us know if it fixes the
problem for you.



David E DeMarle
Kitware, Inc.
R&D Engineer
21 Corporate Drive
Clifton Park, NY 12065-8662
Phone: 518-881-4909


On Tue, Feb 18, 2014 at 7:48 AM, Nens <nicolas.narbonne at gmail.com> wrote:

> Hello,
>
> I have a problem to draw the correct surface. Indeep, the surface created
> by
> the code bellow don't have the correct coordinate. The surface seems good
> but values are false.
>
> I try to reset origin and spinning, but i didn't find how to do this good.
>
> I use vtk 5.
>
> *Code :*
>
>  vtkSmartPointer<vtkPolyData> polydata =
> vtkSmartPointer<vtkPolyData>::New();
>         polydata->SetPoints(points);
>         double bounds0[6];
>         polydata->GetBounds(bounds0);
>         // Find min and max z
>         double min0z = bounds0[4];
>         double max0z = bounds0[5];
>         std::cout << "min0z: " << min0z << std::endl;
>         std::cout << "max0z: " << max0z << std::endl;
>
>
>         // // Construct the surface and create isosurface.
>         vtkSmartPointer<vtkSurfaceReconstructionFilter> surf =
> vtkSmartPointer<vtkSurfaceReconstructionFilter>::New();
> #if VTK_MAJOR_VERSION <= 5
>         surf->SetInput(polydata);
> #else
>         surf->SetInputData(polydata);
> #endif
>         surf->Update();
>
>         std::cout << "t 0" <<  std::endl;
>
>         // Create a new instance of the same type as surf->GetOutput() and
> make it
>         // a shallow copy
>         vtkImageData* signedDist  = surf->GetOutput()->NewInstance();
>         signedDist->ShallowCopy(surf->GetOutput());
>
> //               vtkInformation* signedDistInfo =
> surf->GetOutputPortInformation(0);
> //        vtkInformation* signedDistInfo = polydata->GetInformation();
> //        double *spacing = signedDistInfo->Get(vtkDataObject::SPACING());
> //        signedDist->SetSpacing(spacing);
> //------------------------------------->crash
>
> std::cout << "t 1" <<  std::endl;
>
> //        signedDist->SetSpacing((bounds0[1] - bounds0[0])/XY.dim1()
> ,(bounds0[3] - bounds0[2])/XY.dim2()  , (bounds0[5] - bounds0[4]) );
>
>         std::cout << "bounds : " << bounds0[0] <<" / "<<  bounds0[1] <<" /
> "<< bounds0[2] <<" / "<< bounds0[3] <<" / "<< bounds0[4] <<" / "<<
> bounds0[5] <<" / "<< std::endl;
>         std::cout << "dim XY : "<< XY.dim1()<<" / "<< XY.dim2() <<
> std::endl;
>         std::cout << "dim field : "<< field.dim1()<<" / "<< field.dim2() <<
> std::endl;
>         std::cout << bounds0[1]-bounds0[0] / XY.dim1()<<" 000 "
> <<bounds0[3]-bounds0[2] / XY.dim2() <<  std::endl;
>
>         std::cout << "t 2" <<  std::endl;
>
> //        double *origin = signedDistInfo->Get(vtkDataObject::ORIGIN());
>         signedDist->SetOrigin(bounds0[0],bounds0[2], bounds0[4]);
> //        signedDist->SetOrigin(0,0, 0);
>
>         std::cout << "t 3" <<  std::endl;
>
>         vtkSmartPointer<vtkContourFilter> contourFilter =
> vtkSmartPointer<vtkContourFilter>::New();
> //        contourFilter->SetInputConnection(surf->GetOutputPort());
>         contourFilter->SetInput(signedDist);
>         double bounds1[6];
>         contourFilter->GetOutput()->GetBounds(bounds1);
>
>         // Find min and max z
>         double min1z = bounds1[4];
>         double max1z = bounds1[5];
>         std::cout << "min1z: " << min1z << std::endl;
>         std::cout << "max1z: " << max1z << std::endl;
>
>          // 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.
>         vtkSmartPointer<vtkReverseSense> reverse =
> vtkSmartPointer<vtkReverseSense>::New();
>         reverse->SetInput(contourFilter->GetOutput());
>         reverse->ReverseCellsOn();
>         reverse->ReverseNormalsOn();
>         reverse->Update();
>
>
>         // // Color surface
>         vtkPolyData* outputPolyData = reverse->GetOutput();
>
>         double bounds[6];
>         outputPolyData->GetBounds(bounds);
>
>         // Find min and max z
>         double minz = bounds[4];
>         double maxz = bounds[5];
>         std::cout << "minz: " << minz << std::endl;
>         std::cout << "maxz: " << maxz << std::endl;
>
>
> *Console return :*
>
> min0z: -3.63994                       // correct values
> max0z: 8.62691                       //
> t 0
> t 1
> bounds : -100 / 100 / -100 / 100 / -3.63994 / 8.62691 /
> dim XY : 21 / 41
> dim field : 21 / 41
> 104.762 000 102.439
> t 2
> t 3
> min1z: 1
> max1z: -1
> minz: -1.93855                     // wrong values
> maxz: -0.409277                  //
>
>
>
>
>
> --
> View this message in context:
> http://vtk.1045678.n5.nabble.com/vtkSurfaceReconstruction-coordinate-error-tp5725988.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140218/d21f122d/attachment.html>


More information about the vtkusers mailing list