]> Creatis software - bbtk.git/blob - packages/std/src/bbstdSaveLstPoints.cxx
#3492 SaveLstPoints
[bbtk.git] / packages / std / src / bbstdSaveLstPoints.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 "bbstdSaveLstPoints.h"
5 #include "bbstdPackage.h"
6 namespace bbstd
7 {
8
9 BBTK_ADD_BLACK_BOX_TO_PACKAGE(std,SaveLstPoints)
10 BBTK_BLACK_BOX_IMPLEMENTATION(SaveLstPoints,bbtk::AtomicBlackBox);
11
12 //===== 
13 // 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)
14 //===== 
15 void SaveLstPoints::Process()
16 {
17 // THE MAIN PROCESSING METHOD BODY
18 //   Here we simply set the input 'In' value to the output 'Out'
19 //   And print out the output value
20 // INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
21 //    void bbSet{Input|Output}NAME(const TYPE&)
22 //    const TYPE& bbGet{Input|Output}NAME() const 
23 //    Where :
24 //    * NAME is the name of the input/output
25 //      (the one provided in the attribute 'name' of the tag 'input')
26 //    * TYPE is the C++ type of the input/output
27 //      (the one provided in the attribute 'type' of the tag 'input')
28 //    bbSetOutputOut( bbGetInputIn() );
29 //    std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
30     
31     printf("EED SaveLstPoints::Process Start  \n");
32     std::string filenameX;
33     std::string filenameY;
34     std::string filenameZ;
35     std::vector<int> lstIndexs      = bbGetInputLstIndexs();
36     std::vector<double> lstParams   = bbGetInputParams();
37     std::vector<double> lstX        = bbGetInputLstX();
38     std::vector<double> lstY        = bbGetInputLstY();
39     std::vector<double> lstZ        = bbGetInputLstZ();
40     if (bbGetInputType()==0)
41     {
42         FILE *ffx;
43         FILE *ffy;
44         FILE *ffz;
45         int iPoint,sizeLstPoints;
46         int iParams,sizeParams=lstParams.size();
47         int ii,size,iAcum;
48         for (iParams=0; iParams<sizeParams; iParams++)
49         {
50             if (iParams<lstIndexs.size())
51             {
52                 iAcum   = 0;
53                 size    = lstParams[iParams];
54                 for (ii=0; ii<size; ii++)
55                 {
56                     iAcum = iAcum+lstIndexs[ii];
57                 } // for ii
58                 //            printf( "SaveLstPoints::Process %d %d\n", iAcum, lstIndexs[iParams]);
59                 sizeLstPoints   = lstIndexs[iParams];
60                 filenameX       = bbGetInputFileNameBase()+"-X-"+std::to_string( (int)(lstParams[iParams]) ) +".pnt" ;
61                 filenameY       = bbGetInputFileNameBase()+"-Y-"+std::to_string( (int)(lstParams[iParams]) ) +".pnt" ;
62                 filenameZ       = bbGetInputFileNameBase()+"-Z-"+std::to_string( (int)(lstParams[iParams]) ) +".pnt" ;
63                 ffx              = fopen(filenameX.c_str(), "w+" );
64                 ffy              = fopen(filenameY.c_str(), "w+" );
65                 ffz              = fopen(filenameZ.c_str(), "w+" );
66                 for (iPoint=0;iPoint<sizeLstPoints;iPoint++)
67                 {
68                     fprintf(ffx,"%f ", lstX[iPoint+iAcum]);
69                     fprintf(ffy,"%f ", lstY[iPoint+iAcum]);
70                     fprintf(ffz,"%f ", lstZ[iPoint+iAcum]);
71                 } // for iPoint
72                 fclose(ffx);
73                 fclose(ffy);
74                 fclose(ffz);
75             } // if iParams < lstIndexs.size()
76         } // for iParams
77     } // Type == O
78
79     printf("EED SaveLstPoints::Process End  \n");
80
81 }
82
83 //===== 
84 // 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)
85 //===== 
86 void SaveLstPoints::bbUserSetDefaultValues()
87 {
88   //  SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
89   //    Here we initialize the input 'In' to 0
90    bbSetInputType(0);
91 }
92
93 //===== 
94 // 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)
95 //===== 
96 void SaveLstPoints::bbUserInitializeProcessing()
97 {
98   //  THE INITIALIZATION METHOD BODY :
99   //    Here does nothing
100   //    but this is where you should allocate the internal/output pointers
101   //    if any
102 }
103
104 //===== 
105 // 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)
106 //===== 
107 void SaveLstPoints::bbUserFinalizeProcessing()
108 {
109   //  THE FINALIZATION METHOD BODY :
110   //    Here does nothing
111   //    but this is where you should desallocate the internal/output pointers
112   //    if any
113 }
114
115 } // EO namespace bbstd
116
117