]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkLinearExtrusionFilter.cxx
Clean code
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkLinearExtrusionFilter.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 "bbcreaVtkLinearExtrusionFilter.h"
5 #include "bbcreaVtkPackage.h"
6 #include <vtkReverseSense.h>
7
8 namespace bbcreaVtk
9 {
10
11 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,LinearExtrusionFilter)
12 BBTK_BLACK_BOX_IMPLEMENTATION(LinearExtrusionFilter,bbtk::AtomicBlackBox);
13 //===== 
14 // 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)
15 //===== 
16 void LinearExtrusionFilter::Process()
17 {
18 // THE MAIN PROCESSING METHOD BODY
19 //   Here we simply set the input 'In' value to the output 'Out'
20 //   And print out the output value
21 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
22 //    void bbSet{Input|Output}NAME(const TYPE&)
23 //    const TYPE& bbGet{Input|Output}NAME() const 
24 //    Where :
25 //    * NAME is the name of the input/output
26 //      (the one provided in the attribute 'name' of the tag 'input')
27 //    * TYPE is the C++ type of the input/output
28 //      (the one provided in the attribute 'type' of the tag 'input')
29 //    bbSetOutputOut( bbGetInputIn() );
30 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
31     
32     if (extrude!=NULL)
33     {
34         extrude->Delete();
35         extrude=NULL;
36     }
37     if (triangleFilter!=NULL)
38     {
39         triangleFilter->Delete();
40         triangleFilter=NULL;
41     }
42
43     if (bbGetInputIn()!=NULL)
44     {
45         std::vector<double>     dir             = bbGetInputDirection();
46                                 extrude         = vtkLinearExtrusionFilter::New();
47                                 triangleFilter  = vtkTriangleFilter::New();
48
49                 
50         extrude->SetInputData( bbGetInputIn() );
51         extrude->SetExtrusionTypeToNormalExtrusion();
52         if (dir.size()==3)
53         {
54             extrude->SetVector( dir[0],dir[1],dir[2] );
55         } else {
56             extrude->SetVector(1, 0, 0);
57         }
58         extrude->SetScaleFactor( bbGetInputScalarFactor()/3  );
59         extrude->Update();
60         triangleFilter->SetInputData( extrude->GetOutput() );
61         triangleFilter->Update( );
62         
63         vtkPolyData *outputPolydata = triangleFilter->GetOutput();
64         if (bbGetInputScalarFactor()>1 )
65         {
66             vtkReverseSense * reverseSense = vtkReverseSense::New();
67             reverseSense->SetInputData( triangleFilter->GetOutput() );
68             reverseSense->ReverseNormalsOff();
69             reverseSense->ReverseCellsOn();
70             reverseSense->Update();
71             outputPolydata=reverseSense->GetOutput();
72         }
73         bbSetOutputOut( outputPolydata );
74     } else {
75         bbSetOutputOut( NULL );
76     }// if bbGetInputIn
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 LinearExtrusionFilter::bbUserSetDefaultValues()
83 {
84 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
85 //    Here we initialize the input 'In' to 0
86     extrude         = NULL;
87     triangleFilter  = NULL;
88     bbSetInputIn(NULL);
89     std::vector<double> dir;
90     dir.push_back(1);
91     dir.push_back(0);
92     dir.push_back(0);
93     bbSetInputDirection( dir );
94     bbSetInputScalarFactor(0);
95     bbSetOutputOut( NULL );
96 }
97
98 //===== 
99 // 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)
100 //===== 
101 void LinearExtrusionFilter::bbUserInitializeProcessing()
102 {
103 //  THE INITIALIZATION METHOD BODY :
104 //    Here does nothing 
105 //    but this is where you should allocate the internal/output pointers 
106 //    if any
107 }
108
109 //===== 
110 // 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)
111 //===== 
112 void LinearExtrusionFilter::bbUserFinalizeProcessing()
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 }  // EO namespace bbcreaVtk
121
122