[vtkusers] vtkBooleanOperationPolyDataFilter on multiple objects: resut depends on intersection order
Michele Conconi
michele.conconi at unibo.it
Thu Jul 5 04:15:38 EDT 2012
Hi everybody,
I am playing with this new class vtkBooleanOperationPolyDataFilter (to the
developer: great job!)
I am tring to intersect multiple objects. Anyway the result I get can be
affected from the order I choose for the subsequent intersections. In
particular, some order wrong polydata containing disconnected faces. I guess
it is a problem similar to the one proposed by Eric Fahlgren, for wich I
found no suggested solution
(http://vtk.1045678.n5.nabble.com/vtkBooleanOperationPolyDataFilter-including-disconnected-faces-td5161564.html).
Thanks in advance for any hint.
Cheers
Michele
Here are the stl files I used
http://vtk.1045678.n5.nabble.com/file/n5714450/obj1.stl obj1.stl
http://vtk.1045678.n5.nabble.com/file/n5714450/obj2.stl obj2.stl
http://vtk.1045678.n5.nabble.com/file/n5714450/obj3.stl obj3.stl
And here is the test code
#include <vtkVersion.h>
#include <vtkBooleanOperationPolyDataFilter.h>
#include <vtkActor.h>
#include <vtkPolyDataReader.h>
#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkRenderer.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>
#include <vtkSphereSource.h>
#include <vtkSTLReader.h>
int main()
{
vtkSTLReader *Reader1 = vtkSTLReader::New();
vtkSTLReader *Reader2 = vtkSTLReader::New();
vtkSTLReader *Reader3 = vtkSTLReader::New();
Reader1->SetFileName("obj1.stl");
Reader2->SetFileName("obj2.stl");
Reader3->SetFileName("obj3.stl");
vtkSmartPointer<vtkBooleanOperationPolyDataFilter> booleanOperation =
vtkSmartPointer<vtkBooleanOperationPolyDataFilter>::New();
vtkSmartPointer<vtkBooleanOperationPolyDataFilter> booleanOperation2 =
vtkSmartPointer<vtkBooleanOperationPolyDataFilter>::New();
booleanOperation->SetOperationToIntersection();
booleanOperation2->SetOperationToIntersection();
//WORKING INTERSECTION ORDER
booleanOperation->SetInput( 0, Reader1->GetOutput() );
booleanOperation->SetInput( 1, Reader3->GetOutput() );
booleanOperation2->SetInput( 0, booleanOperation->GetOutput() );
booleanOperation2->SetInput( 1, Reader2->GetOutput() );
//ALTERNATIVE NOT WORKING INTERSECTION ORDERS
// -------- 1 ------------
//booleanOperation->SetInput( 0, Reader1->GetOutput() );
//booleanOperation->SetInput( 1, Reader2->GetOutput() );
//booleanOperation2->SetInput( 0, booleanOperation->GetOutput() );
//booleanOperation2->SetInput( 1, Reader3->GetOutput() );
// -------- 2 ----------
//booleanOperation->SetInput( 0, Reader2->GetOutput() );
//booleanOperation->SetInput( 1, Reader3->GetOutput() );
//booleanOperation2->SetInput( 0, booleanOperation->GetOutput() );
//booleanOperation2->SetInput( 1, Reader1->GetOutput() );
vtkSmartPointer<vtkPolyDataMapper> booleanOperationMapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
vtkSmartPointer<vtkActor> booleanOperationActor =
vtkSmartPointer<vtkActor>::New();
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
vtkSmartPointer<vtkRenderWindowInteractor> renWinInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
booleanOperationMapper->SetInputConnection(
booleanOperation2->GetOutputPort() );
booleanOperationMapper->ScalarVisibilityOff();
booleanOperationActor->SetMapper( booleanOperationMapper );
renderer->AddViewProp(booleanOperationActor);
renderer->SetBackground(.1, .2, .3);
renderWindow->AddRenderer( renderer );
renWinInteractor->SetRenderWindow( renderWindow );
renderWindow->Render();
renWinInteractor->Start();
return EXIT_SUCCESS;
}
LA RICERCA C’È E SI VEDE:
5 per mille all'Università di Bologna - C.F.: 80007010376
http://www.unibo.it/5permille
Questa informativa è inserita in automatico dal sistema al fine esclusivo della realizzazione dei fini istituzionali dell’ente.
More information about the vtkusers
mailing list