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 printf("EED BooleanOperationPolyDataFilter::Process Start In1=%p In2=%p\n", bbGetInputIn1(), bbGetInputIn2() );
45 if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) )
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");
52 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
53 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
54 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
55 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
57 vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
58 vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
59 clean1->SetInputData( bbGetInputIn1() );
60 clean2->SetInputData( bbGetInputIn2() );
63 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
64 vtkTriangleFilter *triangle2 = vtkTriangleFilter::New();
65 triangle1->SetInputData( clean1->GetOutput() );
66 triangle2->SetInputData( clean2->GetOutput() );
70 // vtkPolyDataBooleanFilter is not a vtk filter (this one yes: vtkBooleanOperationPolyDataFilter )
71 // https://github.com/zippy84/vtkbool
72 // vtkPolyDataBooleanFilter is a local code creaVtk lib
73 vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
75 booleanOperation->SetInputData(0, triangle1->GetOutput() );
76 booleanOperation->SetInputData(1, triangle2->GetOutput() );
78 // booleanOperation->SetInputData(0, bbGetInputIn1() );
79 // booleanOperation->SetInputData(1, bbGetInputIn2() );
81 if (bbGetInputOperation()==0 )
83 booleanOperation->SetOperModeToUnion();
85 if (bbGetInputOperation()==1 )
87 booleanOperation->SetOperModeToIntersection();
89 if (bbGetInputOperation()==2 )
91 booleanOperation->SetOperModeToDifference();
95 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
96 booleanOperation->SetInputData(0, triangle1->GetOutput() );
97 booleanOperation->SetInputData(1, triangle2->GetOutput() );
98 if (bbGetInputOperation()==0 )
100 booleanOperation->SetOperationToUnion();
102 if (bbGetInputOperation()==1 )
104 booleanOperation->SetOperationToIntersection();
106 if (bbGetInputOperation()==2 )
108 booleanOperation->SetOperationToDifference();
109 booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
113 booleanOperation->Update();
115 vtkPoints *points = booleanOperation->GetOutput()->GetPoints();
118 vtkFillHolesFilter *fillHolesFilter = vtkFillHolesFilter::New();
119 fillHolesFilter->SetInputData( booleanOperation->GetOutput() );
120 fillHolesFilter->SetHoleSize(100000.0);
121 fillHolesFilter->Update();
122 bbSetOutputOut( fillHolesFilter->GetOutput() );
123 // bbSetOutputOut( booleanOperation->GetOutput() );
125 bbSetOutputOut( NULL );
129 bbSetOutputOut( NULL );
130 printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
131 } // if In1 In2 != NULL
135 // 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)
137 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
139 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
140 // Here we initialize the input 'In' to 0
143 bbSetInputOperation(0);
144 bbSetInputReorientDifferenceCells(true);
145 bbSetOutputOut(NULL);
149 // 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)
151 void BooleanOperationPolyDataFilter::bbUserInitializeProcessing()
153 // THE INITIALIZATION METHOD BODY :
155 // but this is where you should allocate the internal/output pointers
160 // 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)
162 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
164 // THE FINALIZATION METHOD BODY :
166 // but this is where you should desallocate the internal/output pointers
170 } // EO namespace bbcreaVtk