X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk%2Fsrc%2FbbcreaMaracasVisuManualContourModel_Box.cxx;h=9a20b5f9946f5446ed7decb03e0cee07424f6f44;hb=9efc4d8bf8fa16e76153eb2efccc5057a79f3d29;hp=d9e1663ec76a4af65ea123c3acff1b91d625ca41;hpb=05c4abbebf824bbbbaaab135acf6c888662dff69;p=creaMaracasVisu.git diff --git a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx index d9e1663..9a20b5f 100644 --- a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx @@ -15,9 +15,192 @@ BBTK_BLACK_BOX_IMPLEMENTATION(ManualContourModel_Box,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 ManualContourModel_Box::Process() + + +void ManualContourModel_Box::ProcessBySegment( + int Type, + int &iGeneral, int sizeSegment, + std::vector *lstInX,std::vector *lstInY, std::vector *lstInZ, + std::vector *lstOutX,std::vector *lstOutY, std::vector *lstOutZ, + std::vector *lstIndexsOut, bool open ) { + creaContoursFactory f; + manualContourModel *m; + int i,size=iGeneral+sizeSegment; + double x,y,z; + m = (manualContourModel*)f.getContourModel( bbGetInputType() ); + m->SetNumberOfPointsSpline( bbGetInputNbPoints() ); + m->SetCloseContour( open ); + for (i=iGeneral;iAddPoint( (*lstInX)[i] , (*lstInY)[i] , (*lstInZ)[i] ); + } // for + m->UpdateSpline(); + int sizeContour = bbGetInputNbPoints(); + for (i=0;iGetSpline_i_Point(i,&x,&y,&z); + lstOutX->push_back(x); + lstOutY->push_back(y); + lstOutZ->push_back(z); + } // for + iGeneral=iGeneral+sizeSegment; + lstIndexsOut->push_back( sizeContour ); + delete m; +} + + +void ManualContourModel_Box::RedistributionPoints( std::vector *lstOutX, + std::vector *lstOutY, + std::vector *lstOutZ, + std::vector *lstIndexsOut ) +{ + std::vector lstRstX; + std::vector lstRstY; + std::vector lstRstZ; + int iLstIndexOut,sizeLstIndexOut=lstIndexsOut->size(); + int ii, iGeneral=0; + int size; + for (iLstIndexOut=0; iLstIndexOut2) + { + double dist=0,dist2,distSeg,delta; + double dd,dx,dy,dz; + int i,k; + for (i=iGeneral+1; i=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; i2 + iGeneral=iGeneral+size; + }// for iLstIndexOut +} + + +void ManualContourModel_Box::ShiftValues( std::vector *lstInX, + std::vector *lstInY, + std::vector *lstInZ, + std::vector *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 LstTmpX; + std::vector LstTmpY; + std::vector LstTmpZ; + if (sizeLstIndexIn>=2) + { + for (iLstIndexIn=0; iLstIndexIn lstIndexsIn=bbGetInputLstIndexsIn(); + std::vector lstIndexsOut; + std::vector lstOutX; + std::vector lstOutY; + std::vector lstOutZ; + if (bbGetInputLstIndexsIn().size()==0) { -// m->InsertPoint( bbGetInputLstControlPointsX()[i] , bbGetInputLstControlPointsY()[i] , bbGetInputLstControlPointsZ()[i] ); - m->AddPoint( bbGetInputLstControlPointsX()[i] , bbGetInputLstControlPointsY()[i] , bbGetInputLstControlPointsZ()[i] ); - } // for - m->UpdateSpline(); - size = bbGetInputNbPoints(); + lstIndexsIn.push_back( lstInX.size() ); + } + if (bbGetInputDoubleContour()==1) + { + ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn ); + } // DoubleContour + int i,size=lstIndexsIn.size(); + int iGeneral=0; for (i=0;iGetSpline_i_Point(i,&x,&y,&z); - lstX.push_back(x); - lstY.push_back(y); - lstZ.push_back(z); + ProcessBySegment( bbGetInputType() , + iGeneral, lstIndexsIn[i] , + &lstInX , &lstInY , &lstInZ, + &lstOutX , &lstOutY , &lstOutZ, + &lstIndexsOut,bbGetInputOpenClose() ); } // for - bbSetOutputLstContourPointsX(lstX); - bbSetOutputLstContourPointsY(lstY); - bbSetOutputLstContourPointsZ(lstZ); - delete m; + if (bbGetInputDoubleContour()==0) + { + //////////////////// Set Out DoubleContour = 0 + bbSetOutputLstContourPointsX(lstOutX); + bbSetOutputLstContourPointsY(lstOutY); + bbSetOutputLstContourPointsZ(lstOutZ); + bbSetOutputLstIndexsOut(lstIndexsOut); + } else { + 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