X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=bbtk%2Fsrc%2FbbcreaMaracasVisuManualContourModel_Box.cxx;h=8ad078e6d20b6ae2669f8a5a6975edc9ae60e0da;hb=39ac649f6a07b1646505a9d8c418f72bd76fc64e;hp=eee2c1958b6b44cca78c413eb5b588cceb343279;hpb=8ff1bd01f3b914e504bf3260fdcc79d026dfac68;p=creaMaracasVisu.git diff --git a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx index eee2c19..8ad078e 100644 --- a/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx +++ b/bbtk/src/bbcreaMaracasVisuManualContourModel_Box.cxx @@ -27,9 +27,7 @@ void ManualContourModel_Box::ProcessBySegment( creaContoursFactory f; manualContourModel *m; int i,size=iGeneral+sizeSegment; - double x,y,z; - m = (manualContourModel*)f.getContourModel( bbGetInputType() ); m->SetNumberOfPointsSpline( bbGetInputNbPoints() ); m->SetCloseContour( open ); @@ -57,24 +55,18 @@ void ManualContourModel_Box::RedistributionPoints( std::vector *lstOutX, std::vector *lstOutZ, std::vector *lstIndexsOut ) { - printf("EED Warnning! ManualContourModel_Box::RedistributionPoints Start\n"); - std::vector lstRstX; std::vector lstRstY; std::vector lstRstZ; - int iLstIndexOut,sizeLstIndexOut=lstIndexsOut->size(); int ii, iGeneral=0; int size; - for (iLstIndexOut=0; iLstIndexOut2) { @@ -89,7 +81,6 @@ void ManualContourModel_Box::RedistributionPoints( std::vector *lstOutX, 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] ); @@ -129,13 +120,10 @@ void ManualContourModel_Box::RedistributionPoints( std::vector *lstOutX, 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 *lstOutX, (*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::ClockwisePoints( std::vector *lstInX, + std::vector *lstInY, + std::vector *lstInZ, + std::vector *lstIndexsIn ) +{ + int iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size(); + int i,iGeneral=0; + int size,size2; + double cx,cy,cz; + double px,py,pz; + double backpx,backpy,backpz; + double ang; + char dir=-1; + bool dirx,diry,dirz; + int flagAng=0; + float backang; + double tmp; + + // For each contour + for (iLstIndexIn=0; iLstIndexIn2) // for contour with more than 2 points + { + cx = 0; + cy = 0; + cz = 0; + dirx = true; + diry = true; + dirz = true; + for ( i=0 ; i0) + { + if (backang2 + iGeneral = iGeneral+size; + } // for iLstIndexIn +} void ManualContourModel_Box::ShiftValues( std::vector *lstInX, std::vector *lstInY, @@ -167,18 +250,15 @@ void ManualContourModel_Box::ShiftValues( std::vector *lstInX, 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 *lstInX, distMin = dist; } } // for dist - - if (iBack!=0) { LstTmpX.clear(); @@ -215,7 +293,6 @@ void ManualContourModel_Box::ShiftValues( std::vector *lstInX, (*lstInZ)[iGeneral+size+i] = LstTmpZ[i]; } // for i } - iGeneral=iGeneral+size; } // for iLstIndexIn } // sizeLstIndexIn @@ -240,35 +317,29 @@ void ManualContourModel_Box::Process() // bbSetOutputOut( bbGetInputIn() ); // std::cout << "Output value = " < lstInX=bbGetInputLstControlPointsX(); std::vector lstInY=bbGetInputLstControlPointsY(); std::vector lstInZ=bbGetInputLstControlPointsZ(); - if ( (lstInX.size()!=lstInY.size()) || (lstInY.size()!=lstInZ.size()) ) { printf("Warnning !! .. ManualContourModel_Box: The list X Y Z, no have the same number of elements \n"); return; } - std::vector lstIndexsIn=bbGetInputLstIndexsIn(); std::vector lstIndexsOut; std::vector lstOutX; std::vector lstOutY; std::vector lstOutZ; - if (bbGetInputLstIndexsIn().size()==0) { lstIndexsIn.push_back( lstInX.size() ); } - - if (bbGetInputDoubleContour()==1) { + ClockwisePoints( &lstInX , &lstInY , &lstInZ , &lstIndexsIn ); ShiftValues( &lstInX , &lstInY , &lstInZ , &lstIndexsIn ); } // DoubleContour - int i,size=lstIndexsIn.size(); int iGeneral=0; for (i=0;i