[vtkusers] Please help: 3D Delaunay

Julio Pastrana pastrana at bgt.uni-hannover.de
Tue Dec 8 04:43:06 EST 2009


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()
-----------------------------------------------------------------------------------------------------------




More information about the vtkusers mailing list