]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx
#3274 BooleanOperationPolyDataFilter BoxWidget ClipPolyData VoxelGrid
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkBooleanOperationPolyDataFilter.cxx
1 //===== 
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)
3 //===== 
4 #include "bbcreaVtkBooleanOperationPolyDataFilter.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include "vtkBooleanOperationPolyDataFilter.h"
8 #include "vtkCleanPolyData.h"
9 #include "vtkTriangleFilter.h"
10
11 namespace bbcreaVtk
12 {
13
14 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,BooleanOperationPolyDataFilter)
15 BBTK_BLACK_BOX_IMPLEMENTATION(BooleanOperationPolyDataFilter,bbtk::AtomicBlackBox);
16 //===== 
17 // 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)
18 //===== 
19 void BooleanOperationPolyDataFilter::Process()
20 {
21
22 // THE MAIN PROCESSING METHOD BODY
23 //   Here we simply set the input 'In' value to the output 'Out'
24 //   And print out the output value
25 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
26 //    void bbSet{Input|Output}NAME(const TYPE&)
27 //    const TYPE& bbGet{Input|Output}NAME() const 
28 //    Where :
29 //    * NAME is the name of the input/output
30 //      (the one provided in the attribute 'name' of the tag 'input')
31 //    * TYPE is the C++ type of the input/output
32 //      (the one provided in the attribute 'type' of the tag 'input')
33 //    bbSetOutputOut( bbGetInputIn() );
34 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35   
36         if ((bbGetInputIn1()!=NULL)  && (bbGetInputIn2()!=NULL) )
37         {
38
39 printf("EED Warnning BooleanOperationPolyDataFilter::Process  Put this code at the end of CreateMesh.. or create 2 new boxes\n");
40 printf("EED Warnning BooleanOperationPolyDataFilter::Process  Put this code at the end of CreateMesh.. or create 2 new boxes\n");
41 printf("EED Warnning BooleanOperationPolyDataFilter::Process  Put this code at the end of CreateMesh.. or create 2 new boxes\n");
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                 vtkCleanPolyData *clean1 = vtkCleanPolyData::New();
48                 vtkCleanPolyData *clean2 = vtkCleanPolyData::New();
49                 clean1->SetInputData( bbGetInputIn1() );
50                 clean2->SetInputData( bbGetInputIn2() );
51                 clean1->Update();
52                 clean2->Update();
53                 vtkTriangleFilter *triangle1 = vtkTriangleFilter::New();
54                 vtkTriangleFilter *triangle2 = vtkTriangleFilter::New();
55                 triangle1->SetInputData( clean1->GetOutput() );
56                 triangle2->SetInputData( clean2->GetOutput() );
57                 triangle1->Update();
58                 triangle2->Update();
59
60                 vtkBooleanOperationPolyDataFilter *booleanOperation = vtkBooleanOperationPolyDataFilter::New();
61                 booleanOperation->SetInputData(0, triangle1->GetOutput() );
62                 booleanOperation->SetInputData(1, triangle2->GetOutput() );
63
64                 if (bbGetInputOperation()==0 )
65                 {
66                         booleanOperation->SetOperationToUnion();
67                 }
68                 if (bbGetInputOperation()==1 )
69                 {
70                         booleanOperation->SetOperationToIntersection();
71                 }
72                 if (bbGetInputOperation()==2 )
73                 {
74                         booleanOperation->SetOperationToDifference();
75             booleanOperation->SetReorientDifferenceCells( bbGetInputReorientDifferenceCells() );
76         }
77                 booleanOperation->Update();
78                 bbSetOutputOut( booleanOperation->GetOutput() );
79         } else {
80                 printf("EED Warnning!  BooleanOperationPolyDataFilter::Process   vtkPolyData In1 or In2  is EMPTY\n");
81         } // if In1 In2 != NULL
82 }
83 //===== 
84 // 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)
85 //===== 
86 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
87 {
88
89 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
90 //    Here we initialize the input 'In' to 0
91    bbSetInputIn1(NULL);
92    bbSetInputIn2(NULL);
93    bbSetInputOperation(0);
94    bbSetInputReorientDifferenceCells(true);
95   
96 }
97 //===== 
98 // 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)
99 //===== 
100 void BooleanOperationPolyDataFilter::bbUserInitializeProcessing()
101 {
102
103 //  THE INITIALIZATION METHOD BODY :
104 //    Here does nothing 
105 //    but this is where you should allocate the internal/output pointers 
106 //    if any 
107
108   
109 }
110 //===== 
111 // 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)
112 //===== 
113 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
114 {
115
116 //  THE FINALIZATION METHOD BODY :
117 //    Here does nothing 
118 //    but this is where you should desallocate the internal/output pointers 
119 //    if any
120   
121 }
122 }
123 // EO namespace bbcreaVtk
124
125