//=====
// 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)
//=====
+
+
+/*
+
void ReadCreaContourFile::Process()
{
std::vector<double> LstX;
std::vector<double> LstY;
std::vector<double> LstZ;
- std::vector<int> LstIndexs;
+ std::vector<int> LstIndexs;
if (bbGetInputFileNameRoi().compare("")==0)
{
LstY.push_back(zz);
LstZ.push_back( (y*(-1)) + (dimY-1) );
} // if FromDirection
- } // iControlPoint
+ } // for iControlPoint
} // TypeModel
fscanf(ff,"%s",tmp); // TypeView
fscanf(ff,"%s",tmp); //
} // if --CreaContour--
} // if ff
} // if FileNameRoi
+
+ bbSetOutputLstX( LstX );
+ bbSetOutputLstY( LstY );
+ bbSetOutputLstZ( LstZ );
+ bbSetOutputLstIndexs( LstIndexs );
+}
+
+
+ */
+
+
+
+void ReadCreaContourFile::Process()
+{
+
+// THE MAIN PROCESSING METHOD BODY
+// Here we simply set the input 'In' value to the output 'Out'
+// And print out the output value
+// INPUT/OUTPUT ACCESSORS ARE OF THE FORM :
+// void bbSet{Input|Output}NAME(const TYPE&)
+// const TYPE& bbGet{Input|Output}NAME() const
+// Where :
+// * NAME is the name of the input/output
+// (the one provided in the attribute 'name' of the tag 'input')
+// * TYPE is the C++ type of the input/output
+// (the one provided in the attribute 'type' of the tag 'input')
+
+// bbSetOutputOut( bbGetInputIn() );
+// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+
+ std::map<int, std::vector<double> > mapX;
+ std::map<int, std::vector<double> > mapY;
+ std::map<int, std::vector<double> > mapZ;
+
+ if (bbGetInputFileNameRoi().compare("")==0)
+ {
+ printf("EED Warnning! ReadCreaContourFile::Process FileNameRoi EMPTY\n");
+ } else {
+ char tmp[255];
+ FILE *ff= fopen(bbGetInputFileNameRoi().c_str(),"r");
+ if (ff==NULL)
+ {
+ printf("EED Warnning! ReadCreaContourFile::Process Wrong file %s\n", bbGetInputFileNameRoi().c_str() );
+ } else {
+ fscanf(ff,"%s",tmp); // --CreaContour--
+ std::string tmpStr(tmp);
+ if (tmpStr.compare("--CreaContour--")==0 )
+ {
+ int iContour,iControlPoint;
+ int dimX, dimY,dimZ;
+ int NumberOfContours;
+ double x,y,z,zz;
+ int TypeModel;
+ int NumberOfControlPoints;
+ fscanf(ff,"%s",tmp); // version
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); // ImageDimensions
+ fscanf(ff,"%d",&dimX); //
+ fscanf(ff,"%d",&dimY); //
+ fscanf(ff,"%d",&dimZ); //
+ fscanf(ff,"%s",tmp); // ImageSpacing
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); // NumberOfContours
+ fscanf(ff,"%d",&NumberOfContours); //
+ for (iContour=0 ; iContour<NumberOfContours ; iContour++)
+ {
+ std::vector<double> LstX;
+ std::vector<double> LstY;
+ std::vector<double> LstZ;
+
+ fscanf(ff,"%s",tmp); // Instant
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); zz=atof(tmp); // zz
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); //
+ fscanf(ff,"%s",tmp); // TypeModel
+ fscanf(ff,"%d",&TypeModel); //
+ if ((TypeModel==1) || (TypeModel==6) )
+ {
+ fscanf(ff,"%s",tmp); // NumberOfControlPoints
+ fscanf(ff,"%d",&NumberOfControlPoints); //
+// LstIndexs.push_back( NumberOfControlPoints );
+ for (iControlPoint=0 ; iControlPoint<NumberOfControlPoints ; iControlPoint++)
+ {
+ fscanf(ff,"%s",tmp); x=atof(tmp); // x
+ fscanf(ff,"%s",tmp); y=atof(tmp); // y
+ fscanf(ff,"%s",tmp); z=atof(tmp); // z
+ if (bbGetInputFromDirection()==0) // XY
+ {
+ LstX.push_back(x);
+ LstY.push_back(y);
+ LstZ.push_back(zz);
+ } // if FromDirection
+ if (bbGetInputFromDirection()==1) // YZ
+ {
+ LstX.push_back(zz);
+ LstY.push_back(x);
+ LstZ.push_back(y);
+ } // if FromDirection
+ if (bbGetInputFromDirection()==2) // XZ
+ {
+ LstX.push_back(x);
+ LstY.push_back(zz);
+ LstZ.push_back( (y*(-1)) + (dimY-1) );
+ } // if FromDirection
+ } // for iControlPoint
+ mapX[zz] = LstX;
+ mapY[zz] = LstY;
+ mapZ[zz] = LstZ;
+ } // TypeModel
+ fscanf(ff,"%s",tmp); // TypeView
+ fscanf(ff,"%s",tmp); //
+
+ } // for i NumberOfContours
+ fclose(ff);
+ } else {
+ printf("EED Warnning! ReadCreaContourFile::Process %s is not a creaContour .roi file\n",bbGetInputFileNameRoi().c_str() );
+ } // if --CreaContour--
+ } // if ff
+ } // if FileNameRoi
+
+ std::vector<double> LstX;
+ std::vector<double> LstY;
+ std::vector<double> LstZ;
+ std::vector<int> LstIndexs;
+
+ // Order block by zz
+ for( std::map<int, std::vector<double> >::iterator iter = mapX.begin();
+ iter != mapX.end();
+ ++iter )
+ {
+ int i,size = iter->second.size();
+ LstIndexs.push_back( size );
+ for (i=0;i<size;i++)
+ {
+ LstX.push_back( iter->second[i] );
+ } // for i
+ } // for mapX
+
+ for( std::map<int, std::vector<double> >::iterator iter = mapY.begin();
+ iter != mapY.end();
+ ++iter )
+ {
+ int i,size = iter->second.size();
+ for (i=0;i<size;i++)
+ {
+ LstY.push_back( iter->second[i] );
+ } // for i
+ } // for mapY
+
+ for( std::map<int, std::vector<double> >::iterator iter = mapZ.begin();
+ iter != mapZ.end();
+ ++iter )
+ {
+ int i,size = iter->second.size();
+ for (i=0;i<size;i++)
+ {
+ LstZ.push_back( iter->second[i] );
+ } // for i
+ } // for mapZ
+
bbSetOutputLstX( LstX );
bbSetOutputLstY( LstY );
bbSetOutputLstZ( LstZ );
bbSetOutputLstIndexs( LstIndexs );
}
+
//=====
// 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)
//=====