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"
10 #include "vtkCleanPolyData.h"
11 #include "vtkTriangleFilter.h"
17 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BooleanOperationPolyDataFilter)
18 BBTK_BLACK_BOX_IMPLEMENTATION(BooleanOperationPolyDataFilter,bbtk::AtomicBlackBox);
20 // 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)
22 void BooleanOperationPolyDataFilter::Process()
25 // THE MAIN PROCESSING METHOD BODY
26 // Here we simply set the input 'In' value to the output 'Out'
27 // And print out the output value
28 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
29 // void bbSet{Input|Output}NAME(const TYPE&)
30 // const TYPE& bbGet{Input|Output}NAME() const
32 // * NAME is the name of the input/output
33 // (the one provided in the attribute 'name' of the tag 'input')
34 // * TYPE is the C++ type of the input/output
35 // (the one provided in the attribute 'type' of the tag 'input')
36 // bbSetOutputOut( bbGetInputIn() );
37 // std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
39 if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) )
42 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
43 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
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 vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
51 vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
52 clean1->SetInputData( bbGetInputIn1() );
53 clean2->SetInputData( bbGetInputIn2() );
56 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
57 vtkTriangleFilter *triangle2 = vtkTriangleFilter::New();
58 triangle1->SetInputData( clean1->GetOutput() );
59 triangle2->SetInputData( clean2->GetOutput() );
63 vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
64 booleanOperation->SetInputData(0, triangle1->GetOutput() );
65 booleanOperation->SetInputData(1, triangle2->GetOutput() );
66 if (bbGetInputOperation()==0 )
68 booleanOperation->SetOperModeToUnion();
70 if (bbGetInputOperation()==1 )
72 booleanOperation->SetOperModeToIntersection();
74 if (bbGetInputOperation()==2 )
76 booleanOperation->SetOperModeToDifference();
80 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
81 booleanOperation->SetInputData(0, triangle1->GetOutput() );
82 booleanOperation->SetInputData(1, triangle2->GetOutput() );
83 if (bbGetInputOperation()==0 )
85 booleanOperation->SetOperationToUnion();
87 if (bbGetInputOperation()==1 )
89 booleanOperation->SetOperationToIntersection();
91 if (bbGetInputOperation()==2 )
93 booleanOperation->SetOperationToDifference();
94 booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
98 booleanOperation->Update();
99 bbSetOutputOut( booleanOperation->GetOutput() );
101 printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
102 } // if In1 In2 != NULL
106 // 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)
108 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
110 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
111 // Here we initialize the input 'In' to 0
114 bbSetInputOperation(0);
115 bbSetInputReorientDifferenceCells(true);
116 bbSetOutputOut(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::bbUserInitializeProcessing()
124 // THE INITIALIZATION METHOD BODY :
126 // but this is where you should allocate the internal/output pointers
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::bbUserFinalizeProcessing()
135 // THE FINALIZATION METHOD BODY :
137 // but this is where you should desallocate the internal/output pointers
141 } // EO namespace bbcreaVtk