[vtkusers] Holes in mesh after vtkBooleanOperationPolyDataFilter

Malsoaz James jmalsoaz at yahoo.fr
Tue May 22 05:15:03 EDT 2012


Hi VTK users,

I'm using the vtkBooleanOperationPolyDataFilter to apply boolean operations to polydata. Unfortunately, I got unexpected results (holes in the mesh).

You can see here http://www.hostingpics.net/viewer.php?id=210273error.png an example.
I'm creating a cylinder, then I'm adding a cube and finally I'm adding another cylinder. The holes appear with the last operation.


Can someone explain me the reason(s) of these results ?

Here are my source code :
vtkCylinderSource * cylinder1 = vtkCylinderSource::New();
cylinder1->SetCenter(0, 10, 0);
cylinder1->SetHeight(50);
cylinder1->SetRadius(5);
cylinder1->SetResolution(100);
cylinder1->Update();

vtkTriangleFilter * cylinder1Triangle = vtkTriangleFilter::New();
cylinder1Triangle->SetInput(cylinder1->GetOutput());
cylinder1Triangle->Update();

cylinder1->Delete();

vtkCubeSource * cube = vtkCubeSource::New();
cube->SetCenter(0, 10, 0);
cube->SetXLength(50);
cube->SetYLength(20);
cube->SetZLength(10);
cube->Update();

vtkTriangleFilter *cubeTriangle = vtkTriangleFilter::New();
cubeTriangle->SetInput(cube->GetOutput());
cubeTriangle->Update();

cube->Delete();

vtkCylinderSource * cylinder2 = vtkCylinderSource::New();
cylinder2->SetCenter(-25, 15, 0);
cylinder2->SetHeight(30);
cylinder2->SetRadius(3);
cylinder2->SetResolution(100);
cylinder2->Update();

vtkTriangleFilter * cylinder2Triangle = vtkTriangleFilter::New();
cylinder2Triangle->SetInput(cylinder2->GetOutput());
cylinder2Triangle->Update();

cylinder2->Delete();

vtkBooleanOperationPolyDataFilter * add1 = vtkBooleanOperationPolyDataFilter::New();
add1->SetOperationToUnion();
add1->SetInput(0, cylinder1Triangle->GetOutput());
add1->SetInput(1, cubeTriangle->GetOutput());
add1->Update();

cubeTriangle->Delete();
cylinder1Triangle->Delete();

vtkBooleanOperationPolyDataFilter * add = vtkBooleanOperationPolyDataFilter::New();
add->SetOperationToUnion();
add->SetInput(0, add1->GetOutput());
add->SetInput(1, cylinder2Triangle->GetOutput());
add->Update();

add1->Delete();
cylinder2Triangle->Delete();

Am I doing something wrong in the use of vtkBooleanOperationPolyDataFilter ?

Thank you.
Best
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120522/313dc492/attachment.htm>


More information about the vtkusers mailing list