[vtkusers] Please help: 3D Delaunay

Bryn Lloyd blloyd at vision.ee.ethz.ch
Tue Dec 8 05:07:41 EST 2009


BTW.

To access the indices of the 4 points of each tetrahedron, you can use 
the function:

vtkUnstructuredGrid::GetCellPoints (vtkIdType cellId, vtkIdList *ptIds)


In order to write the grid to a file, which is more readable use the 
vtkUnstructuredGridWriter and set the file type to ASCII.

Cheers
Bryn



Bryn Lloyd wrote:
> Hi Julio,
> 
> Try the function
> 
> vtkUnstructuredGrid::GetPoint(int i, double p[3])
> 
> it will copy the coordinates of a given point i into the double array p.
> 
> delaunay->GetOutput() is a vtkUnstructuredGrid (is a vtkPointSet).
> 
> 
> -Bryn
> 
> 
> 
> Julio Pastrana wrote:
>> Hello vtk experts,
>>
>> I really really need some help with the vtkDelaunay3D.
>>
>> I am using the example that computes the Convexhull with vtkDelaunay3D.
>> Nevertheless, I am having a really hard time to get the calculated
>> vertices coordinates. I just need the X,Y,Z coordinates after the
>> delaunay triangulation, the points that satisfied the delaunay
>> condition.
>>
>> I was trying with <vtkXMLUnstructuredGridWriter> but the output file 
>> is something I cannot understand.
>>
>> Is there some one out there that could help me out???
>> I just need to extract the x,y,z coordinates out of the UnstructuredGrid
>> I have also tried with GetPointCells and GetCellPoints but so far no
>> luck.
>>
>> I am attaching the code
>>
>> Thank you very much for your help
>> Sincerely,
>> Julio
>>
>> CODE: 
>> ----------------------------------------------------------------------------------------------------------- 
>>
>>   //Create some random points
>>  
>>   vtkSmartPointer<vtkPoints> Points = vtkSmartPointer< vtkPoints
>>> ::New();
>>   vtkSmartPointer<vtkCellArray> Vertices =
>> vtkSmartPointer<vtkCellArray>::New();
>>  
>>  //point cloud;
>>   for(unsigned int i = 0; i < 50; i++)
>>     {
>>     vtkIdType pid[1];
>>     float x = drand48()*30;
>>     float y = drand48()*30;
>>     float z = drand48()*30;
>>     //cerr << x << "\t" << y << "\t" << z <<"\n";
>>         pid[0] = Points->InsertNextPoint(x,y,z);
>>     Vertices->InsertNextCell ( 1,pid );
>>     }
>>  
>>   vtkSmartPointer< vtkPolyData> Polydata =
>> vtkSmartPointer<vtkPolyData>::New();
>>   Polydata->SetPoints(Points);
>>   Polydata->SetVerts(Vertices);
>>     // Create the convex hull of the point cloud
>>   vtkSmartPointer< vtkDelaunay3D > delaunay = vtkSmartPointer<
>> vtkDelaunay3D >::New();
>>   delaunay->SetAlpha(2);
>>   delaunay->SetTolerance(0.5);
>>   delaunay->BoundingTriangulationOff ();
>>
>>   cerr << "Alpha value :"<< delaunay->GetAlpha () << "\tTolerance "<<
>> delaunay->GetTolerance() << "\n";
>>   delaunay->SetInput(Polydata);
>>   delaunay->Update();
>>
>>
>>  
>>   vtkSmartPointer<vtkXMLUnstructuredGridWriter> OutputWriter =
>> vtkSmartPointer<vtkXMLUnstructuredGridWriter>::New();
>>   OutputWriter->SetFileName("output.vtu");
>>   OutputWriter->SetInput(delaunay->GetOutput());
>>   OutputWriter->Write();
>>  
>>
>>
>>   vtkSmartPointer<vtkUnstructuredGrid> dataSet
>> =vtkSmartPointer<vtkUnstructuredGrid>::New();
>>   dataSet = delaunay->GetOutput();
>>   cerr << "Numver of cells : "  << dataSet->GetNumberOfCells () << "\n";
>>  
>>
>>   //HOW DO I GET THE X,Y,Z coordinates
>>   //Out of the delaunay->GetOutput()
>> ----------------------------------------------------------------------------------------------------------- 
>>
>>
>> _______________________________________________
>> 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
>>
> 
> _______________________________________________
> 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
> 


-- 
-------------------------------------------------
Bryn Lloyd
Computer Vision Laboratory
ETH Zürich, Sternwartstrasse 7, ETF C110
CH - 8092 Zürich, Switzerland
Tel: +41 44 63 26668
Fax: +41 44 63 21199
-------------------------------------------------



More information about the vtkusers mailing list