]> Creatis software - creaMaracasVisu.git/blob - bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx
#3266 creaMaracasVisu Feature New Normal - ManualContour_Box by segments
[creaMaracasVisu.git] / bbtk / src / bbcreaMaracasVisuManualContourModel_Box.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 "bbcreaMaracasVisuManualContourModel_Box.h"
5 #include "bbcreaMaracasVisuPackage.h"
6
7 #include <creaContoursFactory.h>
8
9
10 namespace bbcreaMaracasVisu
11 {
12
13 BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualContourModel_Box)
14 BBTK_BLACK_BOX_IMPLEMENTATION(ManualContourModel_Box,bbtk::AtomicBlackBox);
15 //===== 
16 // 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)
17 //===== 
18
19
20 void ManualContourModel_Box::ProcessBySegment(  
21                         int Type, 
22                         int &iGeneral, int sizeSegment,
23                         std::vector<double> *lstInX,std::vector<double> *lstInY, std::vector<double> *lstInZ,
24                         std::vector<double> *lstOutX,std::vector<double> *lstOutY, std::vector<double> *lstOutZ,
25                         std::vector<int>        *lstIndexsOut )
26 {
27         creaContoursFactory f;
28         manualContourModel      *m;
29         int i,size=iGeneral+sizeSegment;
30
31         double x,y,z;
32
33         m = (manualContourModel*)f.getContourModel( bbGetInputType() );
34         m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
35         m->SetCloseContour( bbGetInputOpenClose() );
36         for (i=iGeneral;i<size;i++)
37         {
38                 m->AddPoint( (*lstInX)[i] , (*lstInY)[i] , (*lstInZ)[i] );
39         } // for
40         m->UpdateSpline();
41         int sizeContour = bbGetInputNbPoints();
42         for (i=0;i<sizeContour;i++)
43         {
44                 m->GetSpline_i_Point(i,&x,&y,&z);
45                 lstOutX->push_back(x);
46                 lstOutY->push_back(y);
47                 lstOutZ->push_back(z);
48         } // for
49         iGeneral=iGeneral+sizeSegment;
50         lstIndexsOut->push_back( sizeContour );
51         delete m;
52 }
53
54 void ManualContourModel_Box::Process()
55 {
56 // THE MAIN PROCESSING METHOD BODY
57 //   Here we simply set the input 'In' value to the output 'Out'
58 //   And print out the output value
59 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
60 //    void bbSet{Input|Output}NAME(const TYPE&)
61 //    const TYPE& bbGet{Input|Output}NAME() const 
62 //    Where :
63 //    * NAME is the name of the input/output
64 //      (the one provided in the attribute 'name' of the tag 'input')
65 //    * TYPE is the C++ type of the input/output
66 //      (the one provided in the attribute 'type' of the tag 'input')
67
68 //    bbSetOutputOut( bbGetInputIn() );
69 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
70
71
72         std::vector<double> lstInX=bbGetInputLstControlPointsX();
73         std::vector<double> lstInY=bbGetInputLstControlPointsY();
74         std::vector<double> lstInZ=bbGetInputLstControlPointsZ();
75
76         if ( (lstInX.size()!=lstInY.size()) || (lstInY.size()!=lstInZ.size()) ) 
77         { 
78                 printf("Warnning !!  .. ManualContourModel_Box: The list X Y Z, no have the same number of elements \n");
79                 return;
80         }
81
82         std::vector<int>        lstIndexsIn=bbGetInputLstIndexsIn();
83         std::vector<int>        lstIndexsOut;
84         std::vector<double> lstOutX;
85         std::vector<double> lstOutY;
86         std::vector<double> lstOutZ;
87
88         if (bbGetInputLstIndexsIn().size()==0)
89         {
90                 lstIndexsIn.push_back( lstInX.size() );
91         }
92
93         int i,size=lstIndexsIn.size();
94         int iGeneral=0;
95         for (i=0;i<size;i++)
96         {
97                 ProcessBySegment(       bbGetInputType() , 
98                                                         iGeneral, lstIndexsIn[i] ,
99                                                         &lstInX,&lstInY,&lstInZ,
100                                                         &lstOutX,&lstOutY,&lstOutZ,
101                                                         &lstIndexsOut);
102         } // for
103         bbSetOutputLstContourPointsX(lstOutX);  
104         bbSetOutputLstContourPointsY(lstOutY);  
105         bbSetOutputLstContourPointsZ(lstOutZ);
106         bbSetOutputLstIndexsOut(lstIndexsOut);  
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 ManualContourModel_Box::bbUserSetDefaultValues()
113 {
114
115 //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX 
116 //    Here we initialize the input 'In' to 0
117    bbSetInputType(1);
118    bbSetInputOpenClose(false);
119    bbSetInputNbPoints(100);
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 ManualContourModel_Box::bbUserInitializeProcessing()
126 {
127
128 //  THE INITIALIZATION METHOD BODY :
129 //    Here does nothing 
130 //    but this is where you should allocate the internal/output pointers 
131 //    if any 
132
133   
134 }
135 //===== 
136 // 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)
137 //===== 
138 void ManualContourModel_Box::bbUserFinalizeProcessing()
139 {
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 }
148 // EO namespace bbcreaMaracasVisu
149
150