]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkExtrusion.cxx
deb13b8110ab074a1c78fab89ec206c7fff5ab7d
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkExtrusion.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 "bbcreaVtkExtrusion.h"
5 #include "bbcreaVtkPackage.h"
6
7 /* ------ Not exist in windows  old VTK version ---------
8   #include <vtkTrimmedExtrusionFilter.h>
9 */
10
11 #include <vtkLinearExtrusionFilter.h>
12 #include <vtkTriangleFilter.h>
13
14 namespace bbcreaVtk
15 {
16
17 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,Extrusion)
18 BBTK_BLACK_BOX_IMPLEMENTATION(Extrusion,bbtk::AtomicBlackBox);
19 //===== 
20 // 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)
21 //===== 
22 void Extrusion::Process()
23 {
24
25 // THE MAIN PROCESSING METHOD BODY
26 //   Here we simply set the input 'In' value to the output 'Out'
27 //   And print out the output value
28 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
29 //    void bbSet{Input|Output}NAME(const TYPE&)
30 //    const TYPE& bbGet{Input|Output}NAME() const 
31 //    Where :
32 //    * NAME is the name of the input/output
33 //      (the one provided in the attribute 'name' of the tag 'input')
34 //    * TYPE is the C++ type of the input/output
35 //      (the one provided in the attribute 'type' of the tag 'input')
36 //    bbSetOutputOut( bbGetInputIn() );
37 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
38   
39     if (bbGetInputIn()!=NULL)
40     {
41         if ((bbGetInputType()>=0) && (bbGetInputType()<=1))
42         {
43 /* ------ Not exist in windows  old VTK version ---------
44                                 vtkTrimmedExtrusionFilter *extrusion = vtkTrimmedExtrusionFilter::New();
45                                 extrusion->SetExtrusionDirection(1,1,1);
46                                 extrusion->SetInputData( bbGetInputIn() );
47                                 extrusion->SetTrimSurfaceData( bbGetInputIn2() );
48                                 if (bbGetInputType()==0)
49                                 {
50                                         extrusion->SetExtrusionStrategy(vtkTrimmedExtrusionFilter::BOUNDARY_EDGES);
51                                 } else {
52                                         extrusion->SetExtrusionStrategy(vtkTrimmedExtrusionFilter::ALL_EDGES);
53                                 }
54                                 extrusion->Update();
55                                 bbSetOutputOut( extrusion->GetTrimSurface() );
56 */
57         }  // if Type 0 1
58             
59         if (bbGetInputType()==2)
60         {
61             // Apply linear extrusion
62              vtkLinearExtrusionFilter *extrude=vtkLinearExtrusionFilter::New();
63              extrude->SetInputData( bbGetInputIn() );
64              extrude->SetExtrusionTypeToNormalExtrusion();
65              extrude->SetVector(0, -1, 0);
66              extrude->SetScaleFactor(-7);
67              extrude->Update();
68              vtkTriangleFilter *triangleFilter = vtkTriangleFilter::New();
69             triangleFilter->SetInputData( extrude->GetOutput() );
70             triangleFilter->Update( );
71              bbSetOutputOut( triangleFilter->GetOutput() );
72         } // if Type 2
73         
74     } // if bbGetInputIn
75     
76 }
77 //===== 
78 // 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)
79 //===== 
80 void Extrusion::bbUserSetDefaultValues()
81 {
82
83 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
84 //    Here we initialize the input 'In' to 0
85    bbSetInputIn(NULL);
86     bbSetInputType(0);
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 Extrusion::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 Extrusion::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