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