[vtkusers] vtkIntersectionPolyDataFilter problem

Roger Mason rmason at mun.ca
Mon Feb 10 10:53:26 EST 2014


Hello,

I need to find triangle-triangle intersections between two Delaunay2D 
triangulated surfaces.  I based my code on 
http://www.vtk.org/Wiki/VTK/Examples/Cxx/Filtering/Delaunay2D but I 
import two surfaces from files containing xyz data.  The tringulation 
seems to work as I can display the intersecting surfaces.

When I try to find the intersections using 
vtkIntersectionPolyDataFilter, the code compiles but I get runtime errors:

ERROR: In /build/vtk/src/VTK5.10.1/Filtering/vtkAlgorithm.cxx, line 873
vtkPainterPolyDataMapper (0x1b24f20): Attempt to get output port index 0 
for an algorithm with 0 output ports.

ERROR: In /build/vtk/src/VTK5.10.1/Filtering/vtkAlgorithm.cxx, line 873
vtkPainterPolyDataMapper (0x1b29a80): Attempt to get output port index 0 
for an algorithm with 0 output ports.

ERROR: In 
/build/vtk/src/VTK5.10.1/Filtering/vtkDemandDrivenPipeline.cxx, line 727
vtkStreamingDemandDrivenPipeline (0x1b20c60): Input port 0 of algorithm 
vtkIntersectionPolyDataFilter(0x1b206c0) has 0 connections but is not 
optional.

ERROR: In 
/build/vtk/src/VTK5.10.1/Filtering/vtkDemandDrivenPipeline.cxx, line 727
vtkStreamingDemandDrivenPipeline (0x1b20c60): Input port 1 of algorithm 
vtkIntersectionPolyDataFilter(0x1b206c0) has 0 connections but is not 
optional.

The errors seems to be from the last block of code below.  I tried 
compiling in Debug mode but got no more information.

Any help will be most appreciated.

Thanks,
Roger

Code:

.....
// Add the points to a polydata object
   vtkSmartPointer<vtkPolyData> polydata2 =
     vtkSmartPointer<vtkPolyData>::New();
   polydata2->SetPoints(points2);

   // Triangulate the points
   vtkSmartPointer<vtkDelaunay2D> delaunay1 =
   vtkSmartPointer<vtkDelaunay2D>::New();
   delaunay1->SetInput(polydata1);
   delaunay1->Update();

   // Triangulate the points
   vtkSmartPointer<vtkDelaunay2D> delaunay2 =
     vtkSmartPointer<vtkDelaunay2D>::New();
   delaunay2->SetInput( polydata2 );
   delaunay2->Update();

   // Visualize
   vtkSmartPointer<vtkPolyDataMapper> mapper1 =
     vtkSmartPointer<vtkPolyDataMapper>::New();
   mapper1->SetInputConnection(delaunay1->GetOutputPort());
   mapper1->ScalarVisibilityOff();

   vtkSmartPointer<vtkPolyDataMapper> mapper2 =
     vtkSmartPointer<vtkPolyDataMapper>::New();
   mapper2->SetInputConnection(delaunay2->GetOutputPort());
   mapper2->ScalarVisibilityOff();

   vtkSmartPointer<vtkActor> actor1 =
     vtkSmartPointer<vtkActor>::New();
   actor1->SetMapper(mapper1);
   actor1->GetProperty()->SetPointSize(4);
   actor1->GetProperty()->SetOpacity(.8);
   actor1->GetProperty()->SetColor(1,0,0);

   vtkSmartPointer<vtkActor> actor2 =
     vtkSmartPointer<vtkActor>::New();
   actor2->SetMapper(mapper2);
   actor2->GetProperty()->SetPointSize(4);
   actor2->GetProperty()->SetOpacity(.8);
   actor2->GetProperty()->SetColor(0,1,0);

    // Does not work? ...
   vtkSmartPointer<vtkIntersectionPolyDataFilter> 
intersectionPolyDataFilter =
     vtkSmartPointer<vtkIntersectionPolyDataFilter>::New();
   intersectionPolyDataFilter->SetInputConnection( 0, 
mapper1->GetOutputPort() );
   intersectionPolyDataFilter->SetInputConnection( 1, 
mapper2->GetOutputPort() );
   intersectionPolyDataFilter->Update();



More information about the vtkusers mailing list