bbSetOutputNewImage( clivp->GetColorLayerImageViewManager()->GetImageChangeInformation(0) );
bbSetOutputLookupTable( clivp->GetColorLayerImageViewManager()->GetLookupTable(0) );
-printf("EED ColorLayerImageView::Process A ptrLookupTable:%p\n",clivp->GetColorLayerImageViewManager()->GetLookupTable(0));
-printf("EED ColorLayerImageView::Process B ptrLookupTable:%p\n",bbGetOutputLookupTable() );
-
if (firsttime==true)
{
firsttime=false;
int &iGeneral, int sizeSegment,
std::vector<double> *lstInX,std::vector<double> *lstInY, std::vector<double> *lstInZ,
std::vector<double> *lstOutX,std::vector<double> *lstOutY, std::vector<double> *lstOutZ,
- std::vector<int> *lstIndexsOut )
+ std::vector<int> *lstIndexsOut, bool open )
{
creaContoursFactory f;
manualContourModel *m;
m = (manualContourModel*)f.getContourModel( bbGetInputType() );
m->SetNumberOfPointsSpline( bbGetInputNbPoints() );
- m->SetCloseContour( bbGetInputOpenClose() );
+ m->SetCloseContour( open );
for (i=iGeneral;i<size;i++)
{
m->AddPoint( (*lstInX)[i] , (*lstInY)[i] , (*lstInZ)[i] );
delete m;
}
+
+void ManualContourModel_Box::RedistributionPoints( std::vector<double> *lstOutX,
+ std::vector<double> *lstOutY,
+ std::vector<double> *lstOutZ,
+ std::vector<int> *lstIndexsOut )
+{
+ printf("EED Warnning! ManualContourModel_Box::RedistributionPoints Start\n");
+
+ std::vector<double> lstRstX;
+ std::vector<double> lstRstY;
+ std::vector<double> lstRstZ;
+
+ int iLstIndexOut,sizeLstIndexOut=lstIndexsOut->size();
+ int ii, iGeneral=0;
+ int size;
+
+ for (iLstIndexOut=0; iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)
+ {
+//printf("EED ManualContourModel_Box::RedistributionPoints iLstIndexOut=%d \n", iLstIndexOut);
+
+ lstRstX.clear();
+ lstRstY.clear();
+ lstRstZ.clear();
+
+ size=(*lstIndexsOut)[iLstIndexOut];
+ if (size>2)
+ {
+ double dist=0,dist2,distSeg,delta;
+ double dd,dx,dy,dz;
+ int i,k;
+ for (i=iGeneral+1; i<iGeneral+size;i++)
+ {
+ dx=(*lstOutX)[i]-(*lstOutX)[i-1];
+ dy=(*lstOutY)[i]-(*lstOutY)[i-1];
+ dz=(*lstOutZ)[i]-(*lstOutZ)[i-1];
+ dist = dist+sqrt( dx*dx + dy*dy + dz*dz );
+ } //for
+ delta=dist/(size-1);
+
+ lstRstX.push_back( (*lstOutX)[iGeneral] );
+ lstRstY.push_back( (*lstOutY)[iGeneral] );
+ lstRstZ.push_back( (*lstOutZ)[iGeneral] );
+ for (i=iGeneral+1; i<iGeneral+size;i++)
+ {
+//printf("EED ManualContourModel_Box::RedistributionPointsi=%d \n", i-iGeneral );
+
+ dist2 = 0;
+ for (k=iGeneral+1; k<iGeneral+size;k++)
+ {
+ dx=(*lstOutX)[k]-(*lstOutX)[k-1];
+ dy=(*lstOutY)[k]-(*lstOutY)[k-1];
+ dz=(*lstOutZ)[k]-(*lstOutZ)[k-1];
+ distSeg = sqrt( dx*dx + dy*dy + dz*dz );
+ ii=i-iGeneral;
+ if ( dist2+distSeg>=ii*delta)
+ {
+ dd=(ii*delta-dist2)/distSeg;
+ if (distSeg==0)
+ {
+ dd=0;
+ } // if distSeg == 0
+ lstRstX.push_back( (*lstOutX)[k-1] + dd*dx );
+ lstRstY.push_back( (*lstOutY)[k-1] + dd*dy );
+ lstRstZ.push_back( (*lstOutZ)[k-1] + dd*dz );
+ k=iGeneral+size;
+ } else {
+ if (k==iGeneral+size-1)
+ {
+ dd=1;
+ lstRstX.push_back( (*lstOutX)[k-1] + dd*dx );
+ lstRstY.push_back( (*lstOutY)[k-1] + dd*dy );
+ lstRstZ.push_back( (*lstOutZ)[k-1] + dd*dz );
+// printf("EED ManualContourModel_Box::RedistributionPoints iLstIndexOut=%d i=%d k=%d dist2+distSeg=%f ii*delta=%f dif=%f \n", iLstIndexOut,i-iGeneral, k-iGeneral, dist2+distSeg , ii*delta , (dist2+distSeg) - ii*delta);
+ }
+ }// if dist2
+ dist2=dist2+distSeg;
+ } // for k
+ } //for i
+
+
+ if (lstRstX.size()!=size)
+ {
+ printf("EED Warnning! ManualContourModel_Box::RedistributionPoints >> This list is not coherent iLstIndexOut=%d lstRstX.size()=%d size=%d\n",iLstIndexOut, lstRstX.size(), size);
+ }
+
+ for (i=iGeneral; i<iGeneral+size;i++)
+ {
+ ii=i-iGeneral;
+ (*lstOutX)[i] = lstRstX[ii];
+ (*lstOutY)[i] = lstRstY[ii];
+ (*lstOutZ)[i] = lstRstZ[ii];
+ } // for i
+
+ } // if size>2
+
+ iGeneral=iGeneral+size;
+
+ }// for iLstIndexOut
+
+ printf("EED Warnning! ManualContourModel_Box::RedistributionPoints End\n");
+
+}
+
+
+
+void ManualContourModel_Box::ShiftValues( std::vector<double> *lstInX,
+ std::vector<double> *lstInY,
+ std::vector<double> *lstInZ,
+ std::vector<int> *lstIndexsIn )
+{
+ int iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size();
+ int ii, iGeneral=0;
+ int size,size2;
+ double dist,distMin;
+ int i,iBack;
+ double dx,dy,dz;
+
+ std::vector<double> LstTmpX;
+ std::vector<double> LstTmpY;
+ std::vector<double> LstTmpZ;
+
+ if (sizeLstIndexIn>=2)
+ {
+ for (iLstIndexIn=0; iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
+ {
+ size = (*lstIndexsIn)[iLstIndexIn];
+ size2 = (*lstIndexsIn)[iLstIndexIn+1];
+
+ //find min distance and iBack
+ distMin = 10000000;
+ iBack = 0;
+ for ( i=0 ; i<size2 ; i++ )
+ {
+ dx = (*lstInX)[iGeneral]-(*lstInX)[iGeneral+size+i];
+ dy = (*lstInY)[iGeneral]-(*lstInY)[iGeneral+size+i];
+ dz = (*lstInZ)[iGeneral]-(*lstInZ)[iGeneral+size+i];
+ dist= sqrt( dx*dx + dy*dy + dz*dz );
+ if ( dist<distMin )
+ {
+ iBack = i;
+ distMin = dist;
+ }
+ } // for dist
+
+
+ if (iBack!=0)
+ {
+ LstTmpX.clear();
+ LstTmpY.clear();
+ LstTmpZ.clear();
+ for (i=0 ; i<size2 ; i++)
+ {
+ ii= (i+iBack)%size2;
+ LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
+ LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
+ LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
+ } // for i
+ for (i=0 ; i<size2 ; i++)
+ {
+ (*lstInX)[iGeneral+size+i] = LstTmpX[i];
+ (*lstInY)[iGeneral+size+i] = LstTmpY[i];
+ (*lstInZ)[iGeneral+size+i] = LstTmpZ[i];
+ } // for i
+ }
+
+ iGeneral=iGeneral+size;
+ } // for iLstIndexIn
+ } // sizeLstIndexIn
+}
+
+
+
void ManualContourModel_Box::Process()
{
// THE MAIN PROCESSING METHOD BODY
// std::cout << "Output value = " <<bbGetOutputOut() << std::endl;
+ // First Step Spline Interpolation
std::vector<double> lstInX=bbGetInputLstControlPointsX();
std::vector<double> lstInY=bbGetInputLstControlPointsY();
std::vector<double> lstInZ=bbGetInputLstControlPointsZ();
lstIndexsIn.push_back( lstInX.size() );
}
+ ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn );
+
+
int i,size=lstIndexsIn.size();
int iGeneral=0;
for (i=0;i<size;i++)
+ {
+ ProcessBySegment( bbGetInputType() ,
+ iGeneral, lstIndexsIn[i] ,
+ &lstInX , &lstInY , &lstInZ,
+ &lstOutX , &lstOutY , &lstOutZ,
+ &lstIndexsOut,bbGetInputOpenClose() );
+ } // for
+
+ RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+
+
+
+ // Second Step Transpose the vectors
+ lstInX.clear();
+ lstInY.clear();
+ lstInZ.clear();
+ lstIndexsIn.clear();
+ size = bbGetInputNbPoints();
+ int j,size2 = lstIndexsOut.size();
+ for (i=0;i<size;i++)
+ {
+ for (j=0;j<size2;j++)
+ {
+ lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
+ lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
+ lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
+ } // for j
+ lstIndexsIn.push_back( size2 );
+ } // for i
+ lstOutX.clear();
+ lstOutY.clear();
+ lstOutZ.clear();
+ lstIndexsOut.clear();
+
+
+ // Third step Interponation 2
+ size=lstIndexsIn.size();
+ iGeneral=0;
+ for (i=0;i<size;i++)
{
ProcessBySegment( bbGetInputType() ,
iGeneral, lstIndexsIn[i] ,
&lstInX,&lstInY,&lstInZ,
&lstOutX,&lstOutY,&lstOutZ,
- &lstIndexsOut);
+ &lstIndexsOut,false);
} // for
+
+
+ RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+
+
+ // Second Step Transpose the vectors
+ lstInX.clear();
+ lstInY.clear();
+ lstInZ.clear();
+ lstIndexsIn.clear();
+ size = bbGetInputNbPoints();
+ size2 = lstIndexsOut.size();
+ for (i=0;i<size;i++)
+ {
+ for (j=0;j<size2;j++)
+ {
+ lstInX.push_back( lstOutX[ j*lstIndexsOut[j] + i ] );
+ lstInY.push_back( lstOutY[ j*lstIndexsOut[j] + i ] );
+ lstInZ.push_back( lstOutZ[ j*lstIndexsOut[j] + i ] );
+ } // for j
+ lstIndexsIn.push_back( size2 );
+ } // for i
+ lstOutX.clear();
+ lstOutY.clear();
+ lstOutZ.clear();
+ lstIndexsOut.clear();
+
+ bbSetOutputLstContourPointsX(lstInX);
+ bbSetOutputLstContourPointsY(lstInY);
+ bbSetOutputLstContourPointsZ(lstInZ);
+ bbSetOutputLstIndexsOut(lstIndexsIn);
+
+
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+printf("EED Warnning ..... ManualContourModel_Box::Process Clean this ...............\n");
+
+/*
bbSetOutputLstContourPointsX(lstOutX);
bbSetOutputLstContourPointsY(lstOutY);
bbSetOutputLstContourPointsZ(lstOutZ);
bbSetOutputLstIndexsOut(lstIndexsOut);
+*/
}
//=====
void Process();
+void ShiftValues( std::vector<double> *lstInX,
+ std::vector<double> *lstInY,
+ std::vector<double> *lstOuZ,
+ std::vector<int> *lstIndexsIn );
+
+
void ProcessBySegment(
int Type,
int &iGeneral, int sizeSegment,
std::vector<double> *lstInX,std::vector<double> *lstInY, std::vector<double> *lstInZ,
std::vector<double> *lstOutX,std::vector<double> *lstOutY, std::vector<double> *lstOutZ,
- std::vector<int> *lstIndexsOut );
+ std::vector<int> *lstIndexsOut,
+ bool open );
+
+void RedistributionPoints( std::vector<double> *lstOutX,
+ std::vector<double> *lstOutY,
+ std::vector<double> *lstOutZ,
+ std::vector<int> *lstIndexsOut );
+
//=====
--- /dev/null
+//=====
+// 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)
+//=====
+#include "bbcreaMaracasVisuReadCreaContourFile.h"
+#include "bbcreaMaracasVisuPackage.h"
+namespace bbcreaMaracasVisu
+{
+
+BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ReadCreaContourFile)
+BBTK_BLACK_BOX_IMPLEMENTATION(ReadCreaContourFile,bbtk::AtomicBlackBox);
+//=====
+// 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()
+{
+
+// 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;
+
+ 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;
+
+
+ std::vector<double> LstX;
+ std::vector<double> LstY;
+ std::vector<double> LstZ;
+ std::vector<int> LstIndexs;
+
+ 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++)
+ {
+ 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)
+ {
+ 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
+ } // iControlPoint
+ } // TypeModel
+ fscanf(ff,"%s",tmp); // TypeView
+ fscanf(ff,"%s",tmp); //
+
+ } // for i NumberOfContours
+ fclose(ff);
+ bbSetOutputLstX( LstX );
+ bbSetOutputLstY( LstY );
+ bbSetOutputLstZ( LstZ );
+ bbSetOutputLstIndexs( LstIndexs );
+
+ } else {
+ printf("EED Warnning! ReadCreaContourFile::Process %s is not a creaContour .roi file\n",bbGetInputFileNameRoi() );
+ } // if --CreaContour--
+ } // if ff
+ } // if FileNameRoi
+
+}
+//=====
+// 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::bbUserSetDefaultValues()
+{
+
+// SET HERE THE DEFAULT INPUT/OUTPUT VALUES OF YOUR BOX
+// Here we initialize the input 'In' to 0
+ bbSetInputFileNameRoi("");
+ bbSetInputFromDirection(0);
+
+}
+//=====
+// 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::bbUserInitializeProcessing()
+{
+
+// THE INITIALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should allocate the internal/output pointers
+// if any
+
+
+}
+//=====
+// 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::bbUserFinalizeProcessing()
+{
+
+// THE FINALIZATION METHOD BODY :
+// Here does nothing
+// but this is where you should desallocate the internal/output pointers
+// if any
+
+}
+}
+// EO namespace bbcreaMaracasVisu
+
+
--- /dev/null
+//=====
+// 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)
+//=====
+#ifndef __bbcreaMaracasVisuReadCreaContourFile_h_INCLUDED__
+#define __bbcreaMaracasVisuReadCreaContourFile_h_INCLUDED__
+
+#include "bbcreaMaracasVisu_EXPORT.h"
+#include "bbtkAtomicBlackBox.h"
+#include "iostream"
+
+namespace bbcreaMaracasVisu
+{
+
+class bbcreaMaracasVisu_EXPORT ReadCreaContourFile
+ :
+ public bbtk::AtomicBlackBox
+{
+ BBTK_BLACK_BOX_INTERFACE(ReadCreaContourFile,bbtk::AtomicBlackBox);
+//=====
+// 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)
+//=====
+ BBTK_DECLARE_INPUT(FileNameRoi,std::string);
+ BBTK_DECLARE_INPUT(FromDirection,int);
+
+ BBTK_DECLARE_OUTPUT(LstX,std::vector<double>);
+ BBTK_DECLARE_OUTPUT(LstY,std::vector<double>);
+ BBTK_DECLARE_OUTPUT(LstZ,std::vector<double>);
+ BBTK_DECLARE_OUTPUT(LstIndexs,std::vector<int>);
+ BBTK_PROCESS(Process);
+ void Process();
+//=====
+// 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)
+//=====
+};
+
+BBTK_BEGIN_DESCRIBE_BLACK_BOX(ReadCreaContourFile,bbtk::AtomicBlackBox);
+ BBTK_NAME("ReadCreaContourFile");
+ BBTK_AUTHOR("InfoDev");
+ BBTK_DESCRIPTION("No Description.");
+ BBTK_CATEGORY("empty");
+
+ BBTK_INPUT(ReadCreaContourFile,FileNameRoi,"creaContour file (*.roi)",std::string,"");
+ BBTK_INPUT(ReadCreaContourFile,FromDirection,"(default 0) 0:XY 1:YZ 2:XZ",int,"");
+
+ BBTK_OUTPUT(ReadCreaContourFile,LstX,"Vetor X",std::vector<double>,"");
+ BBTK_OUTPUT(ReadCreaContourFile,LstY,"Vetor Y",std::vector<double>,"");
+ BBTK_OUTPUT(ReadCreaContourFile,LstZ,"Vetor Z",std::vector<double>,"");
+ BBTK_OUTPUT(ReadCreaContourFile,LstIndexs,"List of : number of elements by segments",std::vector<int>,"");
+
+BBTK_END_DESCRIBE_BLACK_BOX(ReadCreaContourFile);
+//=====
+// 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)
+//=====
+}
+// EO namespace bbcreaMaracasVisu
+
+#endif // __bbcreaMaracasVisuReadCreaContourFile_h_INCLUDED__
+
//----------------------------------------------------------------------------
vtkLookupTable* ColorLayerImageViewManager::GetLookupTable(int id)
{
-printf("EED ColorLayerImageViewManager::GetLookupTable 0 \n");
if (_colorLayerImageViewLst[id]!=NULL)
{
-printf("EED ColorLayerImageViewManager::GetLookupTable 1 \n");
return _colorLayerImageViewLst[id]->GetThresholdTable( );
} // if
-printf("EED ColorLayerImageViewManager::GetLookupTable 2 \n");
return NULL;
}
//----------------------------------------------------------------------------
vtkLookupTable* LayerImageBase::GetThresholdTable()
{
-printf("EED LayerImageBase::GetThresholdTable\n");
return _thresholdTable;
}