]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.cxx
af15435ffdf8500aac153a788b7cd89cc5fef748
[creaVtk.git] / bbtk_creaVtk_PKG / src / bbcreaVtkMeshManager_tool.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 "bbcreaVtkMeshManager_tool.h"
5 #include "bbcreaVtkPackage.h"
6 namespace bbcreaVtk
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaVtk,MeshManager_tool)
10 BBTK_BLACK_BOX_IMPLEMENTATION(MeshManager_tool,bbtk::AtomicBlackBox);
11 //===== 
12 // 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)
13 //===== 
14 void MeshManager_tool::Process()
15 {
16 // THE MAIN PROCESSING METHOD BODY
17 //   Here we simply set the input 'In' value to the output 'Out'
18 //   And print out the output value
19 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
20 //    void bbSet{Input|Output}NAME(const TYPE&)
21 //    const TYPE& bbGet{Input|Output}NAME() const 
22 //    Where :
23 //    * NAME is the name of the input/output
24 //      (the one provided in the attribute 'name' of the tag 'input')
25 //    * TYPE is the C++ type of the input/output
26 //      (the one provided in the attribute 'type' of the tag 'input')
27 //    bbSetOutputOut( bbGetInputIn() );
28 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
29     
30     if (bbGetInputMeshManagerModel()!=NULL)
31     {
32         if (bbGetInputTool()==10) // Undo
33         {
34                 bbGetInputMeshManagerModel()->Undo();
35                 std::vector<double> outData = bbGetInputMeshManagerModel()->GetReferencePoint();
36                 std::vector<double> refNormal = bbGetInputMeshManagerModel()->GetReferenceNormal();
37                 outData.insert(outData.end(), refNormal.begin(), refNormal.end());
38                 bbSetOutputOut(outData);
39         } // if Tool 10 Undo
40         
41         if (bbGetInputTool()==20) // Redo
42         {
43                 bbGetInputMeshManagerModel()->Redo();
44                 std::vector<double> outData = bbGetInputMeshManagerModel()->GetReferencePoint();
45                 std::vector<double> refNormal = bbGetInputMeshManagerModel()->GetReferenceNormal();
46                 outData.insert(outData.end(), refNormal.begin(), refNormal.end());
47                 bbSetOutputOut(outData);
48         } // if Tool 20 Redo
49
50         if (bbGetInputTool()==30)  // Set
51         {
52             if (bbGetInputMesh()!=NULL){
53                 vtkPoints   *points = bbGetInputMesh()->GetPoints();
54                 if (points!=NULL)
55                 {
56                     bbGetInputMeshManagerModel()->SetMeshBase( bbGetInputMesh() );
57                 } // if points!=NULL
58             } // Mesh!=NULL
59         } // if Tool 30 Set
60
61         if (bbGetInputTool()==35)  // Set memory mode
62         {
63                 bbGetInputMeshManagerModel()->SetMeshMemoryMode( bbGetInputMesh() );
64         } // if Tool 35 Set memory mode
65                 if(bbGetInputTool() == 37) // Save State Memory Mode
66         {
67                 if(bbGetInputDoubleParams().size() == 8){       
68                                 std::vector<double> point = {bbGetInputDoubleParams()[0], bbGetInputDoubleParams()[1], bbGetInputDoubleParams()[2]};
69                                 bbGetInputMeshManagerModel()->SetReferencePoint(point);
70                                 std::vector<double> normVect = {bbGetInputDoubleParams()[3], bbGetInputDoubleParams()[4], bbGetInputDoubleParams()[5]};
71                                 bbGetInputMeshManagerModel()->SetReferenceNormal(normVect);
72                         bbGetInputMeshManagerModel()->SaveMemoryMode();
73                 }
74         }
75         if (bbGetInputTool()==32)  // Copy and Set
76         {
77                 bbGetInputMeshManagerModel()->CopySetMeshBase( bbGetInputMesh() );
78         } // if Tool 35 Set memory mode
79
80         
81         if (bbGetInputTool()==40) // ResetMeshTemp
82         {
83             bbGetInputMeshManagerModel()->ResetMeshTemp();
84         } // if Tool 40 Reset
85         
86         if(bbGetInputTool() == 50) // Set Array of Meshes
87         {
88                 if(bbGetInputMeshes().size() > 1)
89                 {
90                         bbGetInputMeshManagerModel()->ReplaceMesh(bbGetInputMeshes());
91                     }
92         }
93         if(bbGetInputTool() == 60) // Select Mesh by Name
94         {
95                 if(!bbGetInputStringParam().empty())
96                 {
97                         bbGetInputMeshManagerModel()->SelectMeshByName(bbGetInputStringParam());
98                     }
99         }
100         if(bbGetInputTool() == 70) // Delete Current Mesh
101         {
102                     bbGetInputMeshManagerModel()->DeleteCurrentMesh();
103         }
104     } else {
105         printf("EED Warning! MeshManager_tool : MeshManagerModel not defined. \n");
106     }// if MeshManagerModel != NULL
107     
108 }
109
110 //===== 
111 // 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)
112 //===== 
113 void MeshManager_tool::bbUserSetDefaultValues()
114 {
115 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
116 //    Here we initialize the input 'In' to 0
117    bbSetInputTool(0);
118    bbSetInputMesh(NULL);
119    bbSetInputMeshManagerModel(NULL);
120 }
121
122 //===== 
123 // 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)
124 //===== 
125 void MeshManager_tool::bbUserInitializeProcessing()
126 {
127 //  THE INITIALIZATION METHOD BODY :
128 //    Here does nothing 
129 //    but this is where you should allocate the internal/output pointers 
130 //    if any
131 }
132 //===== 
133 // 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)
134 //===== 
135 void MeshManager_tool::bbUserFinalizeProcessing()
136 {
137 //  THE FINALIZATION METHOD BODY :
138 //    Here does nothing 
139 //    but this is where you should desallocate the internal/output pointers 
140 //    if any
141 }
142
143 } // EO namespace bbcreaVtk
144
145