]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkCutter.cxx
2b7c9aed7ef57599f5e19a0f21e8c8797862dd7a
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkCutter.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 "bbcreaVtkCutter.h"
5 #include "bbcreaVtkPackage.h"
6 #include "vtkCutter.h"
7 #include "vtkStripper.h"
8 #include "vtkPlane.h"
9 #
10 namespace bbcreaVtk
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Cutter)
14 BBTK_BLACK_BOX_IMPLEMENTATION(Cutter,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 Cutter::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 //    bbSetOutputOut( bbGetInputIn() );
33 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
34   
35   
36   
37   
38   
39   //  See example in:
40   //  https://kitware.github.io/vtk-examples/site/Cxx/VisualizationAlgorithms/Cutter/
41   
42         vtkCutter       *cutter;
43     vtkPolyData *poly;
44         vtkStripper     *strips;
45
46         vtkPlane        *plane;
47         plane  = vtkPlane::New();
48         plane->SetOrigin(0,0,30);
49         plane->SetNormal(0,0,1);
50         
51         cutter = vtkCutter::New();
52         cutter->SetInputData( bbGetInputIn() );
53     cutter->SetCutFunction( plane );
54     cutter->Update();
55         
56         strips = vtkStripper::New();
57     strips->SetInputData( cutter->GetOutput() );
58     strips->Update();
59     poly = vtkPolyData::New();
60     poly->SetPoints( strips->GetOutput()->GetPoints() );
61     poly->SetPolys( strips->GetOutput()->GetLines() );
62         
63         bbSetOutputOut( poly );
64 //      bbSetOutputOut( cutter->GetOutput() );
65         
66         
67 }
68 //===== 
69 // 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)
70 //===== 
71 void Cutter::bbUserSetDefaultValues()
72 {
73
74 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
75 //    Here we initialize the input 'In' to 0
76 //   bbSetInputIn(NULL);
77   
78 }
79 //===== 
80 // 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)
81 //===== 
82 void Cutter::bbUserInitializeProcessing()
83 {
84
85 //  THE INITIALIZATION METHOD BODY :
86 //    Here does nothing 
87 //    but this is where you should allocate the internal/output pointers 
88 //    if any 
89
90   
91 }
92 //===== 
93 // 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)
94 //===== 
95 void Cutter::bbUserFinalizeProcessing()
96 {
97
98 //  THE FINALIZATION METHOD BODY :
99 //    Here does nothing 
100 //    but this is where you should desallocate the internal/output pointers 
101 //    if any
102   
103 }
104 }
105 // EO namespace bbcreaVtk
106
107