std::vector<double> lstRstX;
std::vector<double> lstRstY;
std::vector<double> lstRstZ;
- int iLstIndexOut,sizeLstIndexOut=lstIndexsOut->size();
+ int iLstIndexOut,sizeLstIndexOut = lstIndexsOut->size();
int ii, iGeneral=0;
int size;
for (iLstIndexOut=0; iLstIndexOut<sizeLstIndexOut; iLstIndexOut++)
double dist=0,dist2,distSeg,delta;
double dd,dx,dy,dz;
int i,k;
- for (i=iGeneral+1; i<iGeneral+size;i++)
+ 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 );
+ 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);
+ 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];
+ 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)
+ ii = i-iGeneral;
+ if ( dist2+distSeg >= ii*delta )
{
dd=(ii*delta-dist2)/distSeg;
if (distSeg==0)
{
- dd=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)
+ if ( k==iGeneral+size-1 )
{
- dd=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;
+ dist2 = dist2+distSeg;
} // for k
} //for i
if (lstRstX.size()!=size)
backang=ang;
} // for i
-printf("EED ManualContourModel_Box::ClockwisePoints cx=%f cy=%f cz=%f flagAng=%d size=%d \n",cx,cy,cz,flagAng, size);
-//if (cy<=490) { flagAng = flagAng*(-1); }
// Step 3. Invert order of points
if (flagAng<0)
if (sizeLstIndexIn>=2)
{
+
+
for (iLstIndexIn=0; iLstIndexIn<sizeLstIndexIn-1; iLstIndexIn++)
{
size = (*lstIndexsIn)[iLstIndexIn];
distMin = 10000000;
iBack = 0;
-
+ // Comparing distance between two contours
+ // Both contours need the same size
for (ig=0; ig<size; ig++)
{
dist=0;
} // for ig size
-printf("EED ManualContourModel_Box::ShiftValues px=%f py=%f pz=%f iBack=%d/%d size=%d distMin=%f \n", (*lstInX)[iGeneral] , (*lstInY)[iGeneral] , (*lstInZ)[iGeneral], iBack, size2,size, distMin);
+//printf("EED ManualContourModel_Box::ShiftValues px=%f py=%f pz=%f iBack=%d/%d size=%d distMin=%f \n", (*lstInX)[iGeneral] , (*lstInY)[iGeneral] , (*lstInZ)[iGeneral], iBack, size2,size, distMin);
if (iBack!=0)
{
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
+ ii = (i+iBack)%size2;
+ if (ii<(size2-1)) // Skip the last item
+ {
+ LstTmpX.push_back( (*lstInX)[iGeneral+size+ii] );
+ LstTmpY.push_back( (*lstInY)[iGeneral+size+ii] );
+ LstTmpZ.push_back( (*lstInZ)[iGeneral+size+ii] );
+ }
+ } // for i
+
+ //Repeat the first item at the end to close the contour
+ LstTmpX.push_back( LstTmpX[0] );
+ LstTmpY.push_back( LstTmpY[0] );
+ LstTmpZ.push_back( LstTmpZ[0] );
+
for (i=0 ; i<size2 ; i++)
{
(*lstInX)[iGeneral+size+i] = LstTmpX[i];
bbSetOutputLstIndexsOut(lstIndexsOut);
} else {
RedistributionPoints(&lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+//EED 01/2021
ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
///////////// Second Step Transpose the vectors
lstInX.clear();