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 \n");
43 if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) )
45 //TRIANGLE FILTER NOT NEEDED, this can handle non triangle meshes.
48 // vtkPolyDataBooleanFilter is not a vtk filter (this one yes: vtkBooleanOperationPolyDataFilter )
49 // https://github.com/zippy84/vtkbool
50 // vtkPolyDataBooleanFilter is a local code creaVtk lib
51 vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
53 // booleanOperation->SetInputData(0, triangle1->GetOutput() );
54 // booleanOperation->SetInputData(1, triangle2->GetOutput() );
56 booleanOperation->SetInputData(0, bbGetInputIn1() );
57 booleanOperation->SetInputData(1, bbGetInputIn2() );
59 if (bbGetInputOperation()==0 )
61 booleanOperation->SetOperModeToUnion();
63 if (bbGetInputOperation()==1 )
65 booleanOperation->SetOperModeToIntersection();
67 if (bbGetInputOperation()==2 )
69 booleanOperation->SetOperModeToDifference();
73 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
74 booleanOperation->SetInputData(0, triangle1->GetOutput() );
75 booleanOperation->SetInputData(1, triangle2->GetOutput() );
76 if (bbGetInputOperation()==0 )
78 booleanOperation->SetOperationToUnion();
80 if (bbGetInputOperation()==1 )
82 booleanOperation->SetOperationToIntersection();
84 if (bbGetInputOperation()==2 )
86 booleanOperation->SetOperationToDifference();
87 booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
91 booleanOperation->Update();
93 vtkPoints *points = booleanOperation->GetOutput()->GetPoints();
96 // vtkFillHolesFilter *fillHolesFilter = vtkFillHolesFilter::New();
97 // fillHolesFilter->SetInputData( booleanOperation->GetOutput() );
98 // fillHolesFilter->SetHoleSize(100000.0);
99 // fillHolesFilter->Update();
100 // bbSetOutputOut( fillHolesFilter->GetOutput() );
103 *Added boxes(triangleFilter and CleanPolyData) to handle this outside the box
105 vtkTriangleFilter *triangleEnd = vtkTriangleFilter::New();
106 vtkCleanPolyData *cleanEnd = vtkCleanPolyData::New();
107 bbSetOutputOut( cleanEnd->GetOutput() );
110 bbSetOutputOut( booleanOperation->GetOutput() );
112 bbSetOutputOut( NULL );
116 bbSetOutputOut( NULL );
117 printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
118 } // if In1 In2 != NULL
122 // 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)
124 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
126 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
127 // Here we initialize the input 'In' to 0
130 bbSetInputOperation(0);
131 bbSetInputReorientDifferenceCells(true);
132 bbSetOutputOut(NULL);
136 // 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)
138 void BooleanOperationPolyDataFilter::bbUserInitializeProcessing()
140 // THE INITIALIZATION METHOD BODY :
142 // but this is where you should allocate the internal/output pointers
147 // 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)
149 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
151 // THE FINALIZATION METHOD BODY :
153 // but this is where you should desallocate the internal/output pointers
157 } // EO namespace bbcreaVtk