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) )
44 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
45 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
46 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
47 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
48 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
49 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
50 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
51 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
55 vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
56 vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
57 clean1->SetInputData( bbGetInputIn1() );
58 clean2->SetInputData( bbGetInputIn2() );
61 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
62 vtkTriangleFilter *triangle2 = vtkTriangleFilter::New();
63 triangle1->SetInputData( clean1->GetOutput() );
64 triangle2->SetInputData( clean2->GetOutput() );
68 //TRIANGLE FILTER NOT NEEDED, this can handle non triangle meshes.
71 // vtkPolyDataBooleanFilter is not a vtk filter (this one yes: vtkBooleanOperationPolyDataFilter )
72 // https://github.com/zippy84/vtkbool
73 // vtkPolyDataBooleanFilter is a local code creaVtk lib
74 vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
76 // booleanOperation->SetInputData(0, triangle1->GetOutput() );
77 // booleanOperation->SetInputData(1, triangle2->GetOutput() );
79 booleanOperation->SetInputData(0, bbGetInputIn1() );
80 booleanOperation->SetInputData(1, bbGetInputIn2() );
82 if (bbGetInputOperation()==0 )
84 booleanOperation->SetOperModeToUnion();
86 if (bbGetInputOperation()==1 )
88 booleanOperation->SetOperModeToIntersection();
90 if (bbGetInputOperation()==2 )
92 booleanOperation->SetOperModeToDifference();
96 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
97 booleanOperation->SetInputData(0, triangle1->GetOutput() );
98 booleanOperation->SetInputData(1, triangle2->GetOutput() );
99 if (bbGetInputOperation()==0 )
101 booleanOperation->SetOperationToUnion();
103 if (bbGetInputOperation()==1 )
105 booleanOperation->SetOperationToIntersection();
107 if (bbGetInputOperation()==2 )
109 booleanOperation->SetOperationToDifference();
110 booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
114 booleanOperation->Update();
116 vtkPoints *points = booleanOperation->GetOutput()->GetPoints();
119 // vtkFillHolesFilter *fillHolesFilter = vtkFillHolesFilter::New();
120 // fillHolesFilter->SetInputData( booleanOperation->GetOutput() );
121 // fillHolesFilter->SetHoleSize(100000.0);
122 // fillHolesFilter->Update();
123 // bbSetOutputOut( fillHolesFilter->GetOutput() );
127 *Added boxes(triangleFilter and CleanPolyData) to handle this outside the box
130 //vtkTriangleFilter *triangleEnd = vtkTriangleFilter::New();
131 //triangleEnd->SetInputData( booleanOperation->GetOutput() );
132 //triangleEnd->Update();
134 vtkCleanPolyData *cleanEnd = vtkCleanPolyData::New();
135 cleanEnd->SetInputData( booleanOperation->GetOutput() );
137 bbSetOutputOut( cleanEnd->GetOutput() );
140 bbSetOutputOut( booleanOperation->GetOutput() );
142 bbSetOutputOut( NULL );
146 bbSetOutputOut( NULL );
147 printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
148 } // if In1 In2 != NULL
152 // 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)
154 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
156 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
157 // Here we initialize the input 'In' to 0
160 bbSetInputOperation(0);
161 bbSetInputReorientDifferenceCells(true);
162 bbSetOutputOut(NULL);
166 // 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)
168 void BooleanOperationPolyDataFilter::bbUserInitializeProcessing()
170 // THE INITIALIZATION METHOD BODY :
172 // but this is where you should allocate the internal/output pointers
177 // 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)
179 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
181 // THE FINALIZATION METHOD BODY :
183 // but this is where you should desallocate the internal/output pointers
187 } // EO namespace bbcreaVtk