[vtkusers] About Delaunay3D triangulation

Syed Hassan Amin sha1 at doc.ic.ac.uk
Mon Nov 7 15:50:41 EST 2005


Dear friends,
  When I do triangulation using vtkDelaunay3D , I get lots of 
disconnected triangles. Can any body give me any suggestions on how to 
improve this . I mean how to get triangles which are nicely connected to 
each other.  Here is my code :-

vtkPoints *pts=vtkPoints::New();   
    vcl_ifstream myread(path,vcl_ios::in);
    double pt3d[3];
    char sp;
    if (!myread)
                vcl_cout<<"File not opened for reading "<<vcl_endl;
    else
    {
        int i=0;
        while (!(myread.eof()))
        {
        myread>>pt3d[0]>>sp>>pt3d[1]>>sp>>pt3d[2];
    //    cout<<pt3d[0]<<" "<<pt3d[1]<<" "<<pt3d[2]<<endl;
        //Insert points into vtkPoints   
        pts->InsertPoint(i++,pt3d[0],pt3d[1],pt3d[2]);
    /*(    if (pt3d[2]!=0)
            pts->InsertPoint(i++,pt3d[0],pt3d[1],pt3d[2]);
        else
            cout<<pt3d[0]<<" "<<pt3d[1]<<" "<<pt3d[2]<<endl;*/
        }
    }
    myread.close();   
    vtkPolyData *profile=vtkPolyData::New();
    profile->SetPoints(pts);
    //Delaunay3D
    vtkDelaunay3D *del=vtkDelaunay3D::New();
    del->SetInput(profile);
    del->SetTolerance(0.01);
    del->SetAlpha(2);
    //del->BoundingTriangulationOff();
    vtkShrinkFilter *shrink=vtkShrinkFilter::New();
    shrink->SetInput(del->GetOutput());
    shrink->SetShrinkFactor(0.7);
    vtkDataSetWriter *writer = vtkDataSetWriter::New();
    //char* filename="c://myfile.vtk";
    writer -> SetFileName(vtkFPath);
    writer -> SetInput(shrink->GetOutput());
    writer -> Update();

Thanks for any help,

Hassan Amin



More information about the vtkusers mailing list