]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkClipPolyData.cxx
#3274 creaVtk Feature New Normal - BooleanOperationPolyDataFilter BoxWidget ClipPol...
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkClipPolyData.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 "bbcreaVtkClipPolyData.h"
5 #include "bbcreaVtkPackage.h"
6
7 #include "vtkExtractPoints.h"
8 #include "vtkClipPolyData.h"
9
10 namespace bbcreaVtk
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,ClipPolyData)
14 BBTK_BLACK_BOX_IMPLEMENTATION(ClipPolyData,bbtk::AtomicBlackBox);
15 //===== 
16 // 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)
17 //===== 
18 void ClipPolyData::Process()
19 {
20
21 // THE MAIN PROCESSING METHOD BODY
22 //   Here we simply set the input 'In' value to the output 'Out'
23 //   And print out the output value
24 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
25 //    void bbSet{Input|Output}NAME(const TYPE&)
26 //    const TYPE& bbGet{Input|Output}NAME() const 
27 //    Where :
28 //    * NAME is the name of the input/output
29 //      (the one provided in the attribute 'name' of the tag 'input')
30 //    * TYPE is the C++ type of the input/output
31 //      (the one provided in the attribute 'type' of the tag 'input')
32
33 //    bbSetOutputOut( bbGetInputIn() );
34 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
35   
36         if ((bbGetInputIn()!=NULL)  && (bbGetInputImplicitFunction()!=NULL) )
37         {
38                 if (bbGetInputType()==0)
39                 {
40                         vtkClipPolyData *clip = vtkClipPolyData::New();
41                         clip->SetInputData( bbGetInputIn() );
42                         clip->SetClipFunction( bbGetInputImplicitFunction() );
43                         clip->GenerateClipScalarsOn();
44                         clip->GenerateClippedOutputOff();
45                         if (bbGetInputInside()==true)
46                         {
47                                 clip->InsideOutOn();
48                         } else {
49                                 clip->InsideOutOff();
50                         }
51                         clip->Update();
52                         bbSetOutputOut( clip->GetOutput() );
53                 } // Type 0
54                 if (bbGetInputType()==1)
55                 {
56                         vtkExtractPoints *clip = vtkExtractPoints::New();
57                         clip->SetInputData( bbGetInputIn() );
58                         clip->SetImplicitFunction( bbGetInputImplicitFunction() );
59                         if (bbGetInputInside()==true)
60                         {
61                                 clip->ExtractInsideOn();
62                         } else {
63                                 clip->ExtractInsideOff();
64                         }
65                         clip->Update();
66                         bbSetOutputOut( clip->GetOutput() );
67                 } // type 1
68         } else {
69                 printf("EED Warnning!  ClipPolyData::Process  In or ImplicitFunction is EMPTY\n");
70         } // if In ImplicitFunction != NULL
71
72 }
73 //===== 
74 // 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)
75 //===== 
76 void ClipPolyData::bbUserSetDefaultValues()
77 {
78
79 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
80 //    Here we initialize the input 'In' to 0
81    bbSetInputIn( NULL );
82    bbSetInputType( 0 );
83    bbSetInputInside( true );
84    bbSetInputImplicitFunction( NULL );
85   
86 }
87 //===== 
88 // 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)
89 //===== 
90 void ClipPolyData::bbUserInitializeProcessing()
91 {
92
93 //  THE INITIALIZATION METHOD BODY :
94 //    Here does nothing 
95 //    but this is where you should allocate the internal/output pointers 
96 //    if any 
97
98   
99 }
100 //===== 
101 // 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)
102 //===== 
103 void ClipPolyData::bbUserFinalizeProcessing()
104 {
105
106 //  THE FINALIZATION METHOD BODY :
107 //    Here does nothing 
108 //    but this is where you should desallocate the internal/output pointers 
109 //    if any
110   
111 }
112 }
113 // EO namespace bbcreaVtk
114
115