[vtkusers] problem with “vtkDelaunay3D”

fan ding fan.ding.hust at gmail.com
Mon Jul 3 09:41:09 EDT 2006


I try to write a c++ using vtkDelaunay3D.all the project links well.but when
it runs ,some expect happens. I can 't find the reason.I think I am
right.Ichang the source,everything works
well.I think something is wrong with vtkDelaunay3D.

void main()
 {
//   vtkCubeSource *cubeData = vtkCubeSource::New();

 vtkPoints *points=vtkPoints::New();
    vtkPolyData * profile=vtkPolyData::New();
    srand((unsigned)time(NULL));
    float x,y,z;
 x=y=z=0;
 for(int i=0;i<25;i++)
 {
  x=rand()%100/100.0;
     y=rand()%100/100.0;
     z=rand()%100/100.0;
     points->InsertPoint(i, x, y, z);
  printf("the %d point: %f,%f,%f\n",i,x,y,z);
 }

    profile->SetPoints(points);

// Delaunay3D is used to triangulate the points. The Tolerance is the
distance
// that nearly coincident points are merged together. (Delaunay does better
if
// points are well spaced.) The alpha value is the radius of circumcircles,
// circumspheres. Any mesh entity whose circumcircle is smaller than this
// value is output.
//
 vtkDelaunay3D *del=vtkDelaunay3D::New();
    del->SetInput (profile);
//  del-> BoundingTriangulationOn();
    del-> SetTolerance (0.001);
    del-> SetAlpha (0.2);
    del-> BoundingTriangulationOff();

 // Shrink the result to help see it better.
     vtkShrinkFilter *shrink=vtkShrinkFilter::New();
    shrink->SetInput((vtkDataSet *)del->GetOutput());
    shrink->SetShrinkFactor( 0.9);

 vtkPolyDataMapper * map=vtkPolyDataMapper::New();
    map->SetInput ((vtkPolyData *)(shrink->GetOutput()));

 vtkActor * triangulation=vtkActor::New();
    triangulation->SetMapper(map);
    triangulation->GetProperty()->SetColor(1, 0, 0);

// Create graphics stuff
//
 vtkRenderer *ren1=vtkRenderer::New();
 vtkRenderWindow *renWin=vtkRenderWindow::New();
    renWin->AddRenderer( ren1);
 vtkRenderWindowInteractor *iren=vtkRenderWindowInteractor::New();
    iren-> SetRenderWindow( renWin);

// Add the actors to the renderer, set the background and size
//
ren1-> AddActor (triangulation);
ren1-> SetBackground (1, 1, 1);
renWin-> SetSize( 250, 250);

renWin-> Render();
iren->Start();
map->Delete();
triangulation->Delete();
del->Delete();
profile->Delete();
points->Delete();

 }

thanks a lot!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060703/11ee260e/attachment.htm>


More information about the vtkusers mailing list