std::vector<double> *lstOutZ,
std::vector<int> *lstIndexsOut )
{
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN start\n");
std::vector<double> lstTmp1X;
std::vector<double> lstTmp1Y;
std::vector<double> lstTmp1Z;
double distAcum;
double minDistAcum;
-
// ------------ Wave 1 -----------------
ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut,0,&lstTmp1X,&lstTmp1Y,&lstTmp1Z);
// Increment
for ( iContour=0; iContour<nbContours-1 ; iContour++ )
{
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN iContour=%d\n",iContour);
beta = 0;
alpha = 0;
// find Alpha
{
lstContourExeption.push_back( iContour+1 );
} //
- }
-
+ }
// Set Alpha y Beta
-
-
Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-// if(lstTmp2Y[0]==385) { alpha=bbGetInputParam()[1]; beta=bbGetInputParam()[2]; printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN ---385-- \n"); }
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wve 1 alpha=%f beta=%f z=%f sc1=%f sc2=%f\n",alpha,beta,lstTmp2Y[0], sizeContour1,sizeContour2 );
-
PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour+1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
sizeContour1 = sizeContour2;
CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
// Increment
for ( iContour=nbContours-1; iContour>=0 ; iContour-- )
{
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN iContour=%d\n",iContour);
beta = 0;
alpha = 0;
// find Alpha
Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
-// if(lstTmp2Y[0]==385) { alpha=bbGetInputParam()[1]; beta=bbGetInputParam()[2]; printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN ---385-- \n"); }
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave 2 alpha=%f beta=%f z=%f sc1=%f sc2=%f\n",alpha,beta,lstTmp2Y[0], sizeContour1,sizeContour2 );
-
PutPointsInContour(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ, iContour-1 ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
sizeContour1 = sizeContour2;
CopyContour2InContour1( &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ , &lstTmp1X,&lstTmp1Y,&lstTmp1Z );
// ------------ Wave 3 -----------------
- printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave3 los que faltan");
+ double alpha1,alpha2;
+ double beta1,beta2;
double iExtra,sizeExtra=lstContourExeption.size();
for ( iExtra=0 ; iExtra<sizeExtra ; iExtra++ )
{
- printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN wave3 los que faltan %d \n", lstContourExeption[iExtra] );
ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, lstContourExeption[iExtra]-1 , &lstTmp1X,&lstTmp1Y,&lstTmp1Z);
sizeContour1 = SizeContour( &lstTmp1X, &lstTmp1Y, &lstTmp1Z );
ExtractContour(lstOutX,lstOutY,lstOutZ,lstIndexsOut, lstContourExeption[iExtra]+1 , &lstTmp3X,&lstTmp3Y,&lstTmp3Z);
sizeContour3 = SizeContour( &lstTmp3X, &lstTmp3Y, &lstTmp3Z );
- beta = 0.05;
- alpha = 0;
+ printf("EED Warnning! ManualContourModel_Box::RedistributionPointsAllContours_SIN wave3 posible inconsistent contour y=%f\n", lstTmp2Y[0] );
+
+// find Alpha
+ beta1 = 0.05;
+ alpha1 = 0;
minDistAcum = 999999999;
for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+0.1 )
{
- Redistribution_SIN( iAlpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+ Redistribution_SIN( iAlpha,beta1, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
if (distAcum<minDistAcum)
{
- alpha = iAlpha;
+ alpha1 = iAlpha;
minDistAcum = distAcum;
} // if integerDist
} // for alpha
minDistAcum = 999999999;
for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01)
{
- Redistribution_SIN( alpha,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+ Redistribution_SIN( alpha1,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
distAcum = IntegralDistanceTwoContours( &lstTmp1X,&lstTmp1Y,&lstTmp1Z , &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
if (distAcum<minDistAcum)
{
- beta = iBeta;
+ beta1 = iBeta;
minDistAcum = distAcum;
} // if integerDist
} // for beta
- Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
- beta = 0.05;
- alpha = 0;
+// find Alpha
+ beta2 = 0.05;
+ alpha2 = 0;
minDistAcum = 999999999;
for (iAlpha=0 ; iAlpha<1; iAlpha=iAlpha+0.1 )
{
- Redistribution_SIN( iAlpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
+ Redistribution_SIN( iAlpha,beta2, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
distAcum = IntegralDistanceTwoContours( &lstTmp3X,&lstTmp3Y,&lstTmp3Z , &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
if (distAcum<minDistAcum)
{
- alpha = iAlpha;
+ alpha2 = iAlpha;
minDistAcum = distAcum;
} // if integerDist
} // for alpha
minDistAcum = 999999999;
for (iBeta=0.0 ; iBeta<0.2; iBeta=iBeta+0.01)
{
- Redistribution_SIN( alpha,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
+ Redistribution_SIN( alpha2,iBeta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
distAcum = IntegralDistanceTwoContours( &lstTmp3X,&lstTmp3Y,&lstTmp3Z , &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
if (distAcum<minDistAcum)
{
- beta = iBeta;
+ beta2 = iBeta;
minDistAcum = distAcum;
} // if integerDist
} // for beta
+
+ if (beta2>beta1)
+ {
+ alpha = alpha2;
+ } else {
+ alpha = alpha1;
+ }
+ beta = ( beta1 + beta2 ) / 2;
Redistribution_SIN( alpha,beta, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
-
+ PutPointsInContour(&lstTmp2bX,&lstTmp2bY,&lstTmp2bZ, lstContourExeption[iExtra] ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
+
+// Redistribution_SIN( alpha1,beta1, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2aX,&lstTmp2aY,&lstTmp2aZ );
+// Redistribution_SIN( alpha2,beta2, &lstTmp2X,&lstTmp2Y,&lstTmp2Z ,sizeContour2, &lstTmp2bX,&lstTmp2bY,&lstTmp2bZ );
// Mixing2DistributionVectors(&lstTmp2aX,&lstTmp2aY,&lstTmp2aZ,&lstTmp2bX,&lstTmp2bY,&lstTmp2bZ, &lstTmp2cX,&lstTmp2cY,&lstTmp2cZ );
- PutPointsInContour(&lstTmp2cX,&lstTmp2cY,&lstTmp2cZ, lstContourExeption[iExtra] ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
-
+// PutPointsInContour(&lstTmp2cX,&lstTmp2cY,&lstTmp2cZ, lstContourExeption[iExtra] ,lstOutX,lstOutY,lstOutZ,lstIndexsOut);
+
+
} // for iExtra
+}
+
+
+
+void ManualContourModel_Box::Mixing2DistributionVectors( std::vector<double> *lstAX,
+ std::vector<double> *lstAY,
+ std::vector<double> *lstAZ,
+ std::vector<double> *lstBX,
+ std::vector<double> *lstBY,
+ std::vector<double> *lstBZ,
+ std::vector<double> *lstOutX,
+ std::vector<double> *lstOutY,
+ std::vector<double> *lstOutZ)
+{
+ (*lstOutX).clear();
+ (*lstOutY).clear();
+ (*lstOutZ).clear();
+ std::vector<double> lstTmpX;
+ std::vector<double> lstTmpY;
+ std::vector<double> lstTmpZ;
+ double dx,dy,dz;
+ double distA,distAT;
+ double distB,distBT;
+ int i,j,size;
+ int ii,sizeTmpX;
+ bool flagA,flagB;
+
+ distAT = 0;
+ distBT = 0;
+ i = 1;
+ j = 1;
+ size = (*lstAX).size();
+ lstTmpX.push_back( (*lstAX)[0] );
+ lstTmpY.push_back( (*lstAY)[0] );
+ lstTmpZ.push_back( (*lstAZ)[0] );
+ lstTmpX.push_back( (*lstBX)[0] );
+ lstTmpY.push_back( (*lstBY)[0] );
+ lstTmpZ.push_back( (*lstBZ)[0] );
+ while ((i<size )&& (j<size))
+ {
+ dx = (*lstAX)[i]-(*lstAX)[i-1];
+ dy = (*lstAY)[i]-(*lstAY)[i-1];
+ dz = (*lstAZ)[i]-(*lstAZ)[i-1];
+ distA = sqrt( dx*dx + dy*dy +dz*dz );
+ dx = (*lstBX)[j]-(*lstBX)[j-1];
+ dy = (*lstBY)[j]-(*lstBY)[j-1];
+ dz = (*lstBZ)[j]-(*lstBZ)[j-1];
+ distB = sqrt( dx*dx + dy*dy +dz*dz );
+ flagA = false;
+ flagB = false;
+ if ((distAT+distA)<(distBT+distB))
+ {
+ flagA=true;
+ } else if ((distAT+distA)>(distBT+distB))
+ {
+ flagB=true;
+ } else {
+ flagA=true;
+ flagB=true;
+ } // if distAT+distA distBT+distB
+
+ if (flagA==true)
+ {
+ lstTmpX.push_back( (*lstAX)[i] );
+ lstTmpY.push_back( (*lstAY)[i] );
+ lstTmpZ.push_back( (*lstAZ)[i] );
+ distAT = distAT+distA;
+ i++;
+ } // if flagA
+
+ if (flagB==true)
+ {
+ lstTmpX.push_back( (*lstBX)[j] );
+ lstTmpY.push_back( (*lstBY)[j] );
+ lstTmpZ.push_back( (*lstBZ)[j] );
+ distBT = distBT+distB;
+ j++;
+ } // if flagA
+
+ } // while i j
+ sizeTmpX = lstTmpX.size();
+ for (ii=0; ii<sizeTmpX; ii=ii+2)
+ {
+ (*lstOutX).push_back( lstTmpX[ii] );
+ (*lstOutY).push_back( lstTmpY[ii] );
+ (*lstOutZ).push_back( lstTmpZ[ii] );
+ } // for ii
+printf("EED ManualContourModel_Box::Mixing2DistributionVectors Y=%f size=%d sizeTmpX=%d sizeOut=%d \n",lstTmpY[0], size,sizeTmpX, (*lstOutX).size() );
-
-printf("ManualContourModel_Box::RedistributionPointsAllContours_SIN End\n");
-
}
+
+
if (bbGetInputParam()[0]==1)
{
RedistributionPointsAllContours_SIN( &lstOutX,&lstOutY,&lstOutZ,&lstIndexsOut);
+ ShiftValues( &lstOutX, &lstOutY, &lstOutZ, &lstIndexsOut );
}
// Step 3.4 Transpose the vectors
lstInX.clear();