]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkClipPolyData.cxx
#3523 Add to BoxWidget box Transform option
[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     printf("EED ClipPolyData::Process Start\n");
37     
38         if ((bbGetInputIn()!=NULL)  && (bbGetInputImplicitFunction()!=NULL) )
39         {
40                 if (bbGetInputType()==0)
41                 {
42                         vtkClipPolyData *clip = vtkClipPolyData::New();
43                         clip->SetInputData( bbGetInputIn() );
44                         clip->SetClipFunction( bbGetInputImplicitFunction() );
45                         clip->GenerateClipScalarsOn();
46                         clip->GenerateClippedOutputOff();
47                         if (bbGetInputInside()==true)
48                         {
49                                 clip->InsideOutOn();
50                         } else {
51                                 clip->InsideOutOff();
52                         }
53                         clip->Update();
54                         bbSetOutputOut( clip->GetOutput() );
55                 } // Type 0
56                 if (bbGetInputType()==1)
57                 {
58                         vtkExtractPoints *clip = vtkExtractPoints::New();
59                         clip->SetInputData( bbGetInputIn() );
60                         clip->SetImplicitFunction( bbGetInputImplicitFunction() );
61                         if (bbGetInputInside()==true)
62                         {
63                                 clip->ExtractInsideOn();
64                         } else {
65                                 clip->ExtractInsideOff();
66                         }
67                         clip->Update();
68                         bbSetOutputOut( clip->GetOutput() );
69                 } // type 1
70         } else {
71                 printf("EED Warnning!  ClipPolyData::Process  In or ImplicitFunction is EMPTY\n");
72         } // if In ImplicitFunction != NULL
73
74 }
75 //===== 
76 // 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)
77 //===== 
78 void ClipPolyData::bbUserSetDefaultValues()
79 {
80
81 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
82 //    Here we initialize the input 'In' to 0
83    bbSetInputIn( NULL );
84    bbSetInputType( 0 );
85    bbSetInputInside( true );
86    bbSetInputImplicitFunction( NULL );
87   
88 }
89 //===== 
90 // 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)
91 //===== 
92 void ClipPolyData::bbUserInitializeProcessing()
93 {
94
95 //  THE INITIALIZATION METHOD BODY :
96 //    Here does nothing 
97 //    but this is where you should allocate the internal/output pointers 
98 //    if any 
99
100   
101 }
102 //===== 
103 // 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)
104 //===== 
105 void ClipPolyData::bbUserFinalizeProcessing()
106 {
107
108 //  THE FINALIZATION METHOD BODY :
109 //    Here does nothing 
110 //    but this is where you should desallocate the internal/output pointers 
111 //    if any
112   
113 }
114 }
115 // EO namespace bbcreaVtk
116
117