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");
53 vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
54 vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
55 clean1->SetInputData( bbGetInputIn1() );
56 clean2->SetInputData( bbGetInputIn2() );
59 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
60 vtkTriangleFilter *triangle2 = vtkTriangleFilter::New();
61 triangle1->SetInputData( clean1->GetOutput() );
62 triangle2->SetInputData( clean2->GetOutput() );
66 // vtkPolyDataBooleanFilter is not a vtk filter (this one yes: vtkBooleanOperationPolyDataFilter )
67 // https://github.com/zippy84/vtkbool
68 // vtkPolyDataBooleanFilter is a local code creaVtk lib
69 vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
71 booleanOperation->SetInputData(0, triangle1->GetOutput() );
72 booleanOperation->SetInputData(1, triangle2->GetOutput() );
74 // booleanOperation->SetInputData(0, bbGetInputIn1() );
75 // booleanOperation->SetInputData(1, bbGetInputIn2() );
77 if (bbGetInputOperation()==0 )
79 booleanOperation->SetOperModeToUnion();
81 if (bbGetInputOperation()==1 )
83 booleanOperation->SetOperModeToIntersection();
85 if (bbGetInputOperation()==2 )
87 booleanOperation->SetOperModeToDifference();
91 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
92 booleanOperation->SetInputData(0, triangle1->GetOutput() );
93 booleanOperation->SetInputData(1, triangle2->GetOutput() );
94 if (bbGetInputOperation()==0 )
96 booleanOperation->SetOperationToUnion();
98 if (bbGetInputOperation()==1 )
100 booleanOperation->SetOperationToIntersection();
102 if (bbGetInputOperation()==2 )
104 booleanOperation->SetOperationToDifference();
105 booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
109 booleanOperation->Update();
111 vtkPoints *points = booleanOperation->GetOutput()->GetPoints();
114 // vtkFillHolesFilter *fillHolesFilter = vtkFillHolesFilter::New();
115 // fillHolesFilter->SetInputData( booleanOperation->GetOutput() );
116 // fillHolesFilter->SetHoleSize(100000.0);
117 // fillHolesFilter->Update();
118 // bbSetOutputOut( fillHolesFilter->GetOutput() );
119 bbSetOutputOut( booleanOperation->GetOutput() );
121 bbSetOutputOut( NULL );
125 bbSetOutputOut( NULL );
126 printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
127 } // if In1 In2 != NULL
131 // 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)
133 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
135 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
136 // Here we initialize the input 'In' to 0
139 bbSetInputOperation(0);
140 bbSetInputReorientDifferenceCells(true);
141 bbSetOutputOut(NULL);
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::bbUserInitializeProcessing()
149 // THE INITIALIZATION METHOD BODY :
151 // but this is where you should allocate the internal/output pointers
156 // 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)
158 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
160 // THE FINALIZATION METHOD BODY :
162 // but this is where you should desallocate the internal/output pointers
166 } // EO namespace bbcreaVtk