]> Creatis software - creaVtk.git/blob - bbtk_creaVtk_PKG/src/bbcreaVtkMeshManager_tool.cxx
ba2efcfc91168d00a3b2ff55221b0521c77d57cb
[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     printf("EED MeshManager_tool::Process  tool=%d   %s Ojo ------------------------\n", bbGetInputTool(), bbGetFullName().c_str() );
31     printf(" Mesh %p\n",  bbGetInputMesh() );
32     printf(" ManagerModel %p\n",  bbGetInputMeshManagerModel() );
33
34     if (bbGetInputMeshManagerModel()!=NULL)
35     {
36         if (bbGetInputTool()==10) // Undo
37         {
38                 bbGetInputMeshManagerModel()->Undo();
39                 std::vector<double> outData = bbGetInputMeshManagerModel()->GetReferencePoint();
40                 std::vector<double> refNormal = bbGetInputMeshManagerModel()->GetReferenceNormal();
41                 outData.insert(outData.end(), refNormal.begin(), refNormal.end());
42                 bbSetOutputOut(outData);
43         } // if Tool 10 Undo
44         
45         if (bbGetInputTool()==20) // Redo
46         {
47                 bbGetInputMeshManagerModel()->Redo();
48                 std::vector<double> outData = bbGetInputMeshManagerModel()->GetReferencePoint();
49                 std::vector<double> refNormal = bbGetInputMeshManagerModel()->GetReferenceNormal();
50                 outData.insert(outData.end(), refNormal.begin(), refNormal.end());
51                 bbSetOutputOut(outData);
52         } // if Tool 20 Redo
53
54         if (bbGetInputTool()==30)  // Set
55         {
56             if (bbGetInputMesh()!=NULL){
57                 vtkPoints   *points = bbGetInputMesh()->GetPoints();
58                 if (points!=NULL)
59                 {
60                     bbGetInputMeshManagerModel()->SetMeshBase( bbGetInputMesh() );
61                 } // if points!=NULL
62             } // Mesh!=NULL
63         } // if Tool 30 Set
64
65         if (bbGetInputTool()==35)  // Set memory mode
66         {
67                 bbGetInputMeshManagerModel()->SetMeshMemoryMode( bbGetInputMesh() );
68         } // if Tool 35 Set memory mode
69                 if(bbGetInputTool() == 37) // Save State Memory Mode
70         {
71                 if(bbGetInputDoubleParams().size() == 8){       
72                                 std::vector<double> point = {bbGetInputDoubleParams()[0], bbGetInputDoubleParams()[1], bbGetInputDoubleParams()[2]};
73                                 bbGetInputMeshManagerModel()->SetReferencePoint(point);
74                                 std::vector<double> normVect = {bbGetInputDoubleParams()[3], bbGetInputDoubleParams()[4], bbGetInputDoubleParams()[5]};
75                                 bbGetInputMeshManagerModel()->SetReferenceNormal(normVect);
76                         bbGetInputMeshManagerModel()->SaveMemoryMode();
77                 }
78         }
79         if (bbGetInputTool()==32)  // Copy and Set
80         {
81                 bbGetInputMeshManagerModel()->CopySetMeshBase( bbGetInputMesh() );
82         } // if Tool 35 Set memory mode
83
84         
85         if (bbGetInputTool()==40) // ResetMeshTemp
86         {
87             bbGetInputMeshManagerModel()->ResetMeshTemp();
88         } // if Tool 40 Reset
89         
90         if(bbGetInputTool() == 50) // Set Array of Meshes
91         {
92                 if(bbGetInputMeshes().size() > 1)
93                 {
94                         bbGetInputMeshManagerModel()->ReplaceMesh(bbGetInputMeshes());
95                     }
96         }
97         if(bbGetInputTool() == 60) // Select Mesh by Name
98         {
99                 if(!bbGetInputStringParam().empty())
100                 {
101                         bbGetInputMeshManagerModel()->SelectMeshByName(bbGetInputStringParam());
102                     }
103         }
104         if(bbGetInputTool() == 70) // Delete Current Mesh
105         {
106                     bbGetInputMeshManagerModel()->DeleteCurrentMesh();
107         }
108     } else {
109         printf("EED Warning! MeshManager_tool : MeshManagerModel not defined. \n");
110     }// if MeshManagerModel != NULL
111     
112 }
113
114 //===== 
115 // 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)
116 //===== 
117 void MeshManager_tool::bbUserSetDefaultValues()
118 {
119 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
120 //    Here we initialize the input 'In' to 0
121    bbSetInputTool(0);
122    bbSetInputMesh(NULL);
123    bbSetInputMeshManagerModel(NULL);
124 }
125
126 //===== 
127 // 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)
128 //===== 
129 void MeshManager_tool::bbUserInitializeProcessing()
130 {
131 //  THE INITIALIZATION METHOD BODY :
132 //    Here does nothing 
133 //    but this is where you should allocate the internal/output pointers 
134 //    if any
135 }
136 //===== 
137 // 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)
138 //===== 
139 void MeshManager_tool::bbUserFinalizeProcessing()
140 {
141 //  THE FINALIZATION METHOD BODY :
142 //    Here does nothing 
143 //    but this is where you should desallocate the internal/output pointers 
144 //    if any
145 }
146
147 } // EO namespace bbcreaVtk
148
149