]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkBooleanOperationPolyDataFilter.cxx
9017e5bdcb66b9ef2683d8d05139f6fe920a18d1
[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                 }
76                 booleanOperation->Update();
77                 bbSetOutputOut( booleanOperation->GetOutput() );
78         } else {
79                 printf("EED Warnning!  BooleanOperationPolyDataFilter::Process   vtkPolyData In1 or In2  is EMPTY\n");
80         } // if In1 In2 != NULL
81 }
82 //===== 
83 // 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)
84 //===== 
85 void BooleanOperationPolyDataFilter::bbUserSetDefaultValues()
86 {
87
88 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
89 //    Here we initialize the input 'In' to 0
90    bbSetInputIn1(NULL);
91    bbSetInputIn2(NULL);
92    bbSetInputOperation(0);
93   
94 }
95 //===== 
96 // 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)
97 //===== 
98 void BooleanOperationPolyDataFilter::bbUserInitializeProcessing()
99 {
100
101 //  THE INITIALIZATION METHOD BODY :
102 //    Here does nothing 
103 //    but this is where you should allocate the internal/output pointers 
104 //    if any 
105
106   
107 }
108 //===== 
109 // 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)
110 //===== 
111 void BooleanOperationPolyDataFilter::bbUserFinalizeProcessing()
112 {
113
114 //  THE FINALIZATION METHOD BODY :
115 //    Here does nothing 
116 //    but this is where you should desallocate the internal/output pointers 
117 //    if any
118   
119 }
120 }
121 // EO namespace bbcreaVtk
122
123