[vtkusers] save cell and FindClosestPoint

David Doria daviddoria at gmail.com
Sun Sep 2 21:53:30 EDT 2012


n Sun, Sep 2, 2012 at 9:47 PM, kaouther <boutara.kaouther at gmail.com> wrote:
> hello everybody,
> I save a coordinate of  point selectsed in the file.xyz by code
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/PolyData/CellPointNeighbors
> selectedcells = vtkSmartPointer<vtkUnstructuredGrid>::New();
> selectedcells->ShallowCopy(extractSelection->GetOutput());
> writer =vtkSmartPointer<vtkSimplePointsWriter>::New();
> writer->SetFileName(this->FileName);
> writer->SetInputConnection(selectedcells->GetProducerPort());
> writer->Write();
> I developed a function to read the file , load the sphere and colored the
> cell records by code :
> vtkSmartPointer<vtkCellLocator> cellLocator =
>         vtkSmartPointer<vtkCellLocator>::New();
>         cellLocator->SetDataSet(atlas->GetOutput());
>         cellLocator->BuildLocator();
> double OnePoint[3];
>
>                 double closestPoint[3];//the coordinates of the closest point will be
> returned here //unused here
>                 double closestPointDist2; //the squared distance to the closest point will
> be returned here //unused here
>                 vtkIdType cellId; //the cell id of the cell containing the closest point
> will be returned here
>                 int subId; //this is rarely used (in triangle strips only, I believe)
> //unused here
>
>                 std::list<vtkIdType> CellIdList;
>                 mainCellMapper = vtkSmartPointer<vtkDataSetMapper>::New();
> OnePoint[0] = OsseletTab[k].x;
>                         OnePoint[1] = OsseletTab[k].y;
>                         OnePoint[2] = OsseletTab[k].z;
>
>                         cellLocator->FindClosestPoint(OnePoint, closestPoint, cellId, subId,
> closestPointDist2);
>
>                         CellIdList.push_back(cellId);
> I then select the CellIdList  but unfortunately i don't have the same cells
> why?
> http://vtk.1045678.n5.nabble.com/file/n5715782/1.png
> http://vtk.1045678.n5.nabble.com/file/n5715782/2.png
> help me please

Please make a minimal example
(http://www.vtk.org/Wiki/VTK/MinimalExample) of your problem.

David



More information about the vtkusers mailing list