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"
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 printf("EED BooleanOperationPolyDataFilter::Process Start In1=%p In2=%p\n", bbGetInputIn1(), bbGetInputIn2() );
43 if ((bbGetInputIn1()!=NULL) && (bbGetInputIn2()!=NULL) )
46 vtkPoints *points1 = bbGetInputIn1()->GetPoints();
47 vtkPoints *points2 = bbGetInputIn2()->GetPoints();
48 printf("EED BooleanOperationPolyDataFilter::Process Number of points 1 %ld\n", points1->GetNumberOfPoints() );
49 printf("EED BooleanOperationPolyDataFilter::Process Number of points 2 %ld\n", points2->GetNumberOfPoints() );
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");
56 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
57 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
58 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
59 printf("EED Warnning BooleanOperationPolyDataFilter::Process Put this code at the end of CreateMesh.. or create 2 new boxes\n");
60 vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
61 vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
62 clean1->SetInputData( bbGetInputIn1() );
63 clean2->SetInputData( bbGetInputIn2() );
66 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
67 vtkTriangleFilter *triangle2 = vtkTriangleFilter::New();
68 triangle1->SetInputData( clean1->GetOutput() );
69 triangle2->SetInputData( clean2->GetOutput() );
73 vtkPolyDataBooleanFilter *booleanOperation = vtkPolyDataBooleanFilter::New();
74 booleanOperation->SetInputData(0, triangle1->GetOutput() );
75 booleanOperation->SetInputData(1, triangle2->GetOutput() );
76 if (bbGetInputOperation()==0 )
78 booleanOperation->SetOperModeToUnion();
80 if (bbGetInputOperation()==1 )
82 booleanOperation->SetOperModeToIntersection();
84 if (bbGetInputOperation()==2 )
86 booleanOperation->SetOperModeToDifference();
90 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
91 booleanOperation->SetInputData(0, triangle1->GetOutput() );
92 booleanOperation->SetInputData(1, triangle2->GetOutput() );
93 if (bbGetInputOperation()==0 )
95 booleanOperation->SetOperationToUnion();
97 if (bbGetInputOperation()==1 )
99 booleanOperation->SetOperationToIntersection();
101 if (bbGetInputOperation()==2 )
103 booleanOperation->SetOperationToDifference();
104 booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
108 booleanOperation->Update();
109 vtkPoints *points = booleanOperation->GetOutput()->GetPoints();
112 bbSetOutputOut( booleanOperation->GetOutput() );
114 bbSetOutputOut( NULL );
117 bbSetOutputOut( NULL );
118 printf("EED Warnning! BooleanOperationPolyDataFilter::Process vtkPolyData In1 or In2 is EMPTY\n");
119 } // if In1 In2 != NULL
121 printf("EED BooleanOperationPolyDataFilter::Process End \n" );
125 // 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)
127 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
129 // SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
130 // Here we initialize the input 'In' to 0
133 bbSetInputOperation(0);
134 bbSetInputReorientDifferenceCells(true);
135 bbSetOutputOut(NULL);
139 // 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)
141 void BooleanOperationPolyDataFilter::bbUserInitializeProcessing()
143 // THE INITIALIZATION METHOD BODY :
145 // but this is where you should allocate the internal/output pointers
150 // 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)
152 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
154 // THE FINALIZATION METHOD BODY :
156 // but this is where you should desallocate the internal/output pointers
160 } // EO namespace bbcreaVtk