//===== // 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 "bbcreaMaracasVisuManualContourModel_Box.h" #include "bbcreaMaracasVisuPackage.h" #include namespace bbcreaMaracasVisu { BBTK_ADD_BLACK_BOX_TO_PACKAGE(creaMaracasVisu,ManualContourModel_Box) 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::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::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, std::vector *lstInZ, std::vector *lstIndexsIn ) { int iLstIndexIn,sizeLstIndexIn=lstIndexsIn->size(); int ii, iGeneral=0; int size,size2; double dist,distMin; int i,iBack; int ig; double dx,dy,dz; std::vector LstTmpX; std::vector LstTmpY; std::vector LstTmpZ; if (sizeLstIndexIn>=2) { for (iLstIndexIn=0; iLstIndexIn *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; int ig; 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) { 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