vtk Boolean Operation Poly Data Filter

Hello, I have a vtkBooleanOperationPolyDataFilter and I want to add two polydata.

I keep getting this error:

Input port 0 of algorithm vtkBooleanOperationPolyDataFilter(0x7fd03000e4e0) has 0 connections but is not optional.
Input port 1 of algorithm vtkBooleanOperationPolyDataFilter(0x7fd03000e4e0) has 0 connections but is not optional.

Can someone give me the general syntax structure for this input and output connection.

For my system, vtkBooleanOperationPolyDataFilter has the methods SetInputConnection, SetInputData, and AddInputData.

Thank you. Any help would be greatly appreciated.

You can use

  booleanOperation->SetInputData( 0, input1 );
  booleanOperation->SetInputData( 1, input2 );

or

  booleanOperation->SetInputConnection( 0, filter1->GetOutputPort() );
  booleanOperation->SetInputConnection( 1, filter2->GetOutputPort() );

Here is a full example on how to use it, linked from the Doxygen documentation for the filter: https://vtk.org/gitweb?p=VTK.git;a=blob;f=Filters/General/Testing/Cxx/TestBooleanOperationPolyDataFilter.cxx

What type/class does input1 and input2 have to be. I have a vtkAppendPolyData object that I would like to pass in.

Also, do you know how to convert a vtkAppendPolyData to vtkDataObject?

Thank you by the way!

Both inputs need to be a vtkPolyData, and consist of only triangles.

vtkAppendPolyData is a filter that produces a vtkPolyData. It is not an object that you can convert to a vtkDataObject.

You can set it up in a pipeline as follows:

vtkBooleanOperationPolyDataFilter* booleanFilter = ...;
vtkAppendPolyData* appendPolyData = ...;
booleanFilter->SetInputConnection(0, appendPolyData->GetOutputPort());

Thank you so much Cory Quammen!

It worked! :slight_smile:
By any chance do you know how I would pass a vtkBooleanOperationPolyDataFilter to vtkDelaunay3D() so that I can create a mapper and actor and render it?

vtkDelaunay3D* delaunay = ...;
delaunay->SetInputConnection(booleanFilter->GetOutputPort(0));

Setting up the mapper and actor can then be done the same as in https://vtk.org/gitweb?p=VTK.git;a=blob;f=Filters/General/Testing/Cxx/TestBooleanOperationPolyDataFilter.cxx, but instead of

mapper->SetInputConnection( boolFilter->GetOutputPort( 0 ) );

you would have

mapper->SetInputConnection( delaunay->GetOutputPort( 0 ) );

Thank you for helping me out. I really appreciate. After I added what you said in the previous post, I got these errors:

ERROR: In /work/standalone-x64-build/VTK-source/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 709
vtkCompositeDataPipeline (0x915f840): Input port 0 of algorithm vtkBooleanOperationPolyDataFilter(0x7f48bc00eda0) has 0 connections but is not optional.

ERROR: In /work/standalone-x64-build/VTK-source/Common/ExecutionModel/vtkDemandDrivenPipeline.cxx, line 709
vtkCompositeDataPipeline (0x915f840): Input port 1 of algorithm vtkBooleanOperationPolyDataFilter(0x7f48bc00eda0) has 0 connections but is not optional.

I don’t know what went wrong. Could you look at my code. It would really help me out. By the way, the purpose of the code is to render a convex volume from multiple contours.Thanks.

code.txt (2.4 KB)

  • Why not use Cylinder