2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
4 #include "bbcreaVtkBooleanOperationPolyDataFilter.h"
5 #include "bbcreaVtkPackage.h"
7 // #include "vtkBooleanOperationPolyDataFilter.h"
8 #include "vtkPolyDataBooleanFilter.h"
11 #include "vtkCleanPolyData.h"
12 #include "vtkTriangleFilter.h"
13 #include "vtkFillHolesFilter.h"
19 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BooleanOperationPolyDataFilter)
20 BBTK_BLACK_BOX_IMPLEMENTATION(BooleanOperationPolyDataFilter,bbtk::AtomicBlackBox);
22 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
24 void BooleanOperationPolyDataFilter::Process()
27 // THE MAIN PROCESSING METHOD BODY
28 // Here we simply set the input 'In' value to the output 'Out'
29 // And print out the output value
30 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
31 // void bbSet{Input|Output}NAME(const TYPE&)
32 // const TYPE& bbGet{Input|Output}NAME() const
34 // * NAME is the name of the input/output
35 // (the one provided in the attribute 'name' of the tag 'input')
36 // * TYPE is the C++ type of the input/output
37 // (the one provided in the attribute 'type' of the tag 'input')
38 // bbSetOutputOut( bbGetInputIn() );
39 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
41 if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) )
43 //TRIANGLE FILTER NOT NEEDED, this can handle non triangle meshes.
46 // vtkPolyDataBooleanFilter is not a vtk filter (this one yes: vtkBooleanOperationPolyDataFilter )
47 // https://github.com/zippy84/vtkbool
48 // vtkPolyDataBooleanFilter is a local code creaVtk lib
49 vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
51 // booleanOperation->SetInputData(0, triangle1->GetOutput() );
52 // booleanOperation->SetInputData(1, triangle2->GetOutput() );
54 booleanOperation->SetInputData(0, bbGetInputIn1() );
55 booleanOperation->SetInputData(1, bbGetInputIn2() );
57 if (bbGetInputOperation()==0 )
59 booleanOperation->SetOperModeToUnion();
61 if (bbGetInputOperation()==1 )
63 booleanOperation->SetOperModeToIntersection();
65 if (bbGetInputOperation()==2 )
67 booleanOperation->SetOperModeToDifference();
71 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
72 booleanOperation->SetInputData(0, triangle1->GetOutput() );
73 booleanOperation->SetInputData(1, triangle2->GetOutput() );
74 if (bbGetInputOperation()==0 )
76 booleanOperation->SetOperationToUnion();
78 if (bbGetInputOperation()==1 )
80 booleanOperation->SetOperationToIntersection();
82 if (bbGetInputOperation()==2 )
84 booleanOperation->SetOperationToDifference();
85 booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
89 booleanOperation->Update();
91 vtkPoints *points = booleanOperation->GetOutput()->GetPoints();
94 // vtkFillHolesFilter *fillHolesFilter = vtkFillHolesFilter::New();
95 // fillHolesFilter->SetInputData( booleanOperation->GetOutput() );
96 // fillHolesFilter->SetHoleSize(100000.0);
97 // fillHolesFilter->Update();
98 // bbSetOutputOut( fillHolesFilter->GetOutput() );
101 *Added boxes(triangleFilter and CleanPolyData) to handle this outside the box
103 vtkTriangleFilter *triangleEnd = vtkTriangleFilter::New();
104 vtkCleanPolyData *cleanEnd = vtkCleanPolyData::New();
105 bbSetOutputOut( cleanEnd->GetOutput() );
108 bbSetOutputOut( booleanOperation->GetOutput() );
110 bbSetOutputOut( NULL );
114 bbSetOutputOut( NULL );
115 printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
116 } // if In1 In2 != NULL
120 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
122 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
124 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
125 // Here we initialize the input 'In' to 0
128 bbSetInputOperation(0);
129 bbSetInputReorientDifferenceCells(true);
130 bbSetOutputOut(NULL);
134 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
136 void BooleanOperationPolyDataFilter::bbUserInitializeProcessing()
138 // THE INITIALIZATION METHOD BODY :
140 // but this is where you should allocate the internal/output pointers
145 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
147 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
149 // THE FINALIZATION METHOD BODY :
151 // but this is where you should desallocate the internal/output pointers
155 } // EO namespace bbcreaVtk