AutoControlPoints.cxx

Go to the documentation of this file.
00001 #include "AutoControlPoints.h"
00002 //------------------------------------------------------------------------------------------------------------------------------------------
00003 //CLASS: AutoControlPoints -----------------------------------------------------------------------------------------------------------------
00004 //------------------------------------------------------------------------------------------------------------------------------------------
00005 //Constructor
00006 AutoControlPoints::AutoControlPoints()
00007 {
00008          _pathsize = 0;
00009          _numspline = 100;
00010 }
00011 //Destructor
00012 AutoControlPoints::~AutoControlPoints()
00013 {
00014 }
00015 //------------------------------------------------------------------------------------------------------------------------------------------
00016 int AutoControlPoints::GetSizeVector(std::vector<double>*Vector)
00017    {
00018            if(Vector != NULL)
00019            {
00020                         return _SizeVectorIn = Vector->size();
00021            }
00022            else
00023            {
00024                         return _SizeVectorIn = -1;
00025            }
00026    }
00027 //------------------------------------------------------------------------------------------------------------------------------------------
00028 void AutoControlPoints::PointLeft ( std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ,
00029                                                                 double* lex, double* ley, double* lez )
00030 {
00031         double LeftX = 1000;
00032         int pos = 0;
00033         int size = GetSizeVector(InX);
00034         if(size != -1)
00035         {
00036                 for(int i=0; i< size; i++)
00037                 {
00038                         if(  (*InX)[i] < LeftX  )
00039                         {
00040                                 LeftX = (*InX)[i];
00041                                 pos = i;
00042                         }
00043                 }
00044                 *lex = (*InX)[pos];
00045                 *ley = (*InY)[pos];
00046                 *lez = (*InZ)[pos];
00047         }
00048 }
00049 //------------------------------------------------------------------------------------------------------------------------------------------
00050 void AutoControlPoints::PointRight( std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ,
00051                                                                 double* rix, double* riy, double* riz )
00052 {
00053           double RightX = 0;
00054           int pos = 0;
00055           int size = GetSizeVector(InX);
00056           if(size != -1)
00057           {
00058                 for(int i=0; i< size; i++)
00059                 {
00060                   if(  (*InX)[i] > RightX  )
00061                   {
00062                           RightX = (*InX)[i];
00063                           pos = i;      
00064                   }
00065                 }
00066                 *rix = (*InX)[pos];
00067                 *riy = (*InY)[pos];
00068                 *riz = (*InZ)[pos];
00069           }
00070 }
00071 //------------------------------------------------------------------------------------------------------------------------------------------
00072 void AutoControlPoints::PointHigh ( std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ,
00073                                                                 double* hix, double* hiy, double* hiz )
00074 {
00075         double HighY=-1;
00076         int pos = 0;
00077         int size = InX->size();
00078         if(size > 0){
00079                 HighY = (*InY)[0];
00080                 for(int i = 1; i < size; i++){
00081                         if((*InY)[i] < HighY){
00082                                 HighY = (*InY)[i];
00083                                 pos = i;
00084                         }
00085                 }
00086                 *hix = (*InX)[pos];
00087                 *hiy = (*InY)[pos];
00088                 *hiz = (*InZ)[pos];
00089         }
00090         
00091 /*JCP 29-09-08
00092         int size = GetSizeVector(InX);
00093         if(size != -1)
00094         {
00095                 for(int i=0; i< _SizeVectorIn; i++)
00096                 {
00097                         if(  (*InY)[i] < HighY  )
00098                         {
00099                                 HighY = (*InY)[i];
00100                                 pos = i;
00101                         }
00102                 }
00103                 *hix = (*InX)[pos];
00104                 *hiy = (*InY)[pos];
00105                 *hiz = (*InZ)[pos];
00106         }
00107 JCP 29-09-08*/
00108         
00109 }
00110 
00111 //------------------------------------------------------------------------------------------------------------------------------------------
00112 void AutoControlPoints::PointLow (      std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ,
00113                                                                         double *lox, double *loy, double *loz)
00114 {
00115         double LowY = 0;
00116         int pos = 0;
00117         int size = GetSizeVector(InX);
00118         if(size != 0)
00119         {
00120                 for(int i=0; i< _SizeVectorIn; i++)
00121                 {
00122                         if(  (*InY)[i] > LowY  )
00123                         {
00124                                 LowY = (*InY)[i];
00125                                 pos = i;
00126                         }
00127                 } 
00128                 *lox = (*InX)[pos];
00129                 *loy = (*InY)[pos];
00130                 *loz = (*InZ)[pos];
00131         }
00132 }
00133 //------------------------------------------------------------------------------------------------------------------------------------------
00134 void AutoControlPoints::TwoPoints ( std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ )
00135 {
00136         double hiX=0,hiY=0,hiZ=0;
00137         PointHigh ( InX,InY,InZ,&hiX,&hiY,&hiZ );
00138         
00139         double leX=0,leY=0,leZ=0;
00140         PointLeft ( InX,InY,InZ,&leX,&leY,&leZ );
00141         
00142         double loX=0,loY=0,loZ=0;
00143         PointLow  ( InX,InY,InZ,&loX,&loY,&loZ );
00144 
00145         double riX=0,riY=0,riZ=0;
00146         PointRight( InX,InY,InZ,&riX,&riY,&riZ );
00147 
00148         double distHiLo = sqrt( pow(hiX-loX,2) + pow(hiY-loY,2) );
00149         double distRiLe = sqrt( pow(riX-leX,2) + pow(riY-leY,2) );
00150                 
00151         _controlpointsX.clear();
00152         _controlpointsY.clear();
00153         _controlpointsZ.clear();
00154         if(distHiLo >= distRiLe)
00155         {
00156                 _controlpointsX.push_back(hiX);
00157                 _controlpointsY.push_back(hiY);
00158                 _controlpointsZ.push_back(hiZ);
00159                         
00160                 _controlpointsX.push_back(loX);
00161                 _controlpointsY.push_back(loY);
00162                 _controlpointsZ.push_back(loZ);
00163         }
00164         else
00165         {
00166                 _controlpointsX.push_back(riX);
00167                 _controlpointsY.push_back(riY);
00168                 _controlpointsZ.push_back(riZ);
00169 
00170                 _controlpointsX.push_back(leX);
00171                 _controlpointsY.push_back(leY);
00172                 _controlpointsZ.push_back(leZ);
00173         }
00174 }
00175 //------------------------------------------------------------------------------------------------------------------------------------------
00176 void AutoControlPoints::CircleCenter(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ, double *cx, double *cy, double *r)
00177 {
00178         double hiX=0,hiY=0,hiZ=0;
00179         PointHigh ( InX,InY,InZ,&hiX,&hiY,&hiZ );
00180 
00181         double leX=0,leY=0,leZ=0;
00182         PointLeft ( InX,InY,InZ,&leX,&leY,&leZ );
00183                 
00184         double loX=0,loY=0,loZ=0;
00185         PointLow  ( InX,InY,InZ,&loX,&loY,&loZ );
00186 
00187         double riX=0,riY=0,riZ=0;
00188         PointRight( InX,InY,InZ,&riX,&riY,&riZ );
00189 
00190         *cx = (riX+leX)/2;
00191         *cy = (hiY+loY)/2;
00192         *r = sqrt(pow(leX-*cx,2)+pow(hiY-*cy,2)) + 7;
00193 }
00194 //------------------------------------------------------------------------------------------------------------------------------------------
00195 void AutoControlPoints::CirclePoints(double cx, double cy, double r, double grad, double *x, double *y)
00196 {
00197         double alpha = (2*3.14159265*grad)/360;
00198 
00199         *x = cx + (r*cos(alpha));
00200         *y = cy + (r*sin(alpha));
00201 }
00202 //------------------------------------------------------------------------------------------------------------------------------------------
00203  void AutoControlPoints::ChargeSpline( )
00204  {
00205          int size = _controlpointsX.size();
00206          if(size != 0)
00207          {
00208                 _mContourModel = new manualContourModel();
00209                 if( _controlpointsX.size() == 2 )
00210                 {
00211                         _mContourModel->SetCloseContour(false);
00212                 }
00213                 if( _controlpointsX.size() > 2 )
00214                 {
00215                         _mContourModel->SetCloseContour(true);
00216                 }
00217 
00218                 _mContourModel->DeleteAllPoints();
00219                 _mContourModel->SetNumberOfPointsSpline(_numspline);
00220                 for(int i=0; i<size; i++)
00221                 {
00222                         _mContourModel->AddPoint(_controlpointsX[i],_controlpointsY[i],_controlpointsZ[i]);
00223                 }
00224                 _mContourModel->UpdateSpline();
00225                 int numspline = _mContourModel->GetNumberOfPointsSpline();
00226                 double x,y,z;
00227                 _chargecontrolpointsX.clear();
00228                 _chargecontrolpointsY.clear();
00229                 _chargecontrolpointsZ.clear();
00230                 for(int j=0; j<numspline; j++)
00231                 {
00232                         _mContourModel->GetSpline_i_Point(j,&x,&y,&z);
00233                         _chargecontrolpointsX.push_back(x);
00234                         _chargecontrolpointsY.push_back(y);
00235                         _chargecontrolpointsZ.push_back(z);
00236                 }
00237                 _pathsize = _mContourModel->GetPathSize();
00238 //printf("\nPATH SIZE = %f",_pathsize);
00239 
00240                  std::ofstream file1;
00241                 file1.open( "4_SplinePoints.txt" );
00242 
00243                 for(int i = 0; i < numspline; i++){
00244                         file1<<"X= "<<_chargecontrolpointsX[i] << "\tY= "<<_chargecontrolpointsY[i] << "\tZ= "<<_chargecontrolpointsZ[i]<<std::endl;
00245                 }
00246                 file1.close();
00247          }
00248         
00249  }
00250  //Given the coordinates of two points, it calculates the slope
00251 double AutoControlPoints::Slope(double x0, double y0, double x1, double y1)
00252 {
00253         double m = (y1-y0)/(x1-x0);
00254         return m;
00255 }
00256 //----------------------------------------------------------------------------------------------------------------------------------------
00257 //Given the coordinates of two points, it calculates the normal and it's slope 
00258 double AutoControlPoints::Normal(double x0, double y0, double* m, double xi)
00259 {
00260         double y;
00261         *m = -(1/(*m));
00262         y = ((*m)*(xi - x0)) + y0;
00263         return y;
00264 }
00265 //----------------------------------------------------------------------------------------------------------------------------------------
00266 void AutoControlPoints::Intersection(double x01, double y01, double x02, double y02, double mn, double m2, double* x, double* y)
00267 {
00268         *x = ( y02-y01-(m2*x02)+(mn*x01) )/(mn-m2);
00269         *y = m2*(*x-x02)+y02;
00270 }
00271 //-----------------------------------------------------------------------------------------------------------------------------------------
00275 void AutoControlPoints::InterCircle(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
00276 {
00277         double cx,cy,r;
00278         CircleCenter(InX,InY,InZ,&cx,&cy,&r);
00279 
00280         //GENERATE THE CIRCLE'S POINTS
00281         int i;
00282         double grad,x,y,n;
00283         std::vector<double>tempX;
00284         std::vector<double>tempY;
00285         tempX.clear();
00286         tempY.clear();
00287         n = 1;
00288         grad = 0;
00289         for(i=0; i<360/n; i++)
00290         {
00291                 CirclePoints(cx,cy,r,grad,&x,&y);
00292                 tempX.push_back(x);
00293                 tempY.push_back(y);
00294                 grad = grad + n;
00295         }
00296 
00297         //FIND THE INTERSECTIONS BETWEEN THE CIRCLE AND THE CONTOUR
00298         int j,jj;
00299         bool interRad = false;
00300         double m1, /*mn=0,*/ m2,xinter,yinter,xmin,ymin,min,dist; // JPRx
00301         _intercircleX.clear();
00302         _intercircleY.clear();
00303         _intercircleDist.clear();
00304         _interbewteencircleX.clear();
00305         _interbewteencircleY.clear();
00306         _interbewteencircleDist.clear();
00307         _interbewteencirclePos.clear();
00308 
00309 //EED 22 Sep 2008
00310 //      FILE *fd, *fexp;
00311 //      fd = fopen("C:/bbtk_JS/data/tempCircle.txt","w");
00312 //      fexp = fopen("C:/bbtk_JS/data/InterCircle.txt","w");
00313 //      fprintf(fexp,"\npos     min             xmin    ymin    xcir    ycir");
00314 
00315         //std::ofstream file1;
00316     //file1.open( "Temp.txt" ); 
00317         
00318         for(i=0; i<(int)(tempX.size()); i++)
00319         {
00320 //              fprintf(fd,"\n Para X = %f, Y = %f",tempX[i],tempY[i]);
00321                 _circleX.push_back(tempX[i]);
00322                 _circleY.push_back(tempY[i]);
00323                 m1 = Slope(tempX[i],tempY[i],cx,cy);//slope of the radius
00324                 min = 9999;
00325                 for(j=0; j<(int)(InX->size()); j++)
00326                 {
00327                         jj = (j+1)%(InX->size());
00328                         m2 = Slope((*InX)[j],(*InY)[j],(*InX)[jj],(*InY)[jj]);//Slope of the vector between the adjacent points
00329                         Intersection(tempX[i],tempY[i],(*InX)[j],(*InY)[j],m1,m2,&xinter,&yinter);
00330 
00331 //JCP 26-09-2008
00332                         //If the point of intersection is between two points of the contour
00333                         if( ((xinter>=(*InX)[j]) && (xinter<=(*InX)[jj]))||((xinter<=(*InX)[j]) && (xinter>=(*InX)[jj]) ))
00334                         {
00335                                 dist = sqrt(pow(tempX[i]-xinter,2) + pow(tempY[i]-yinter,2));
00336                                 if(dist<min)
00337                                 {
00338                                         min = dist;
00339                                         xmin = xinter;
00340                                         ymin = yinter;
00341                                 }
00342                         }
00343 //JCP 26-09-2008
00344 /*JCP 26-09-2008
00345                         if((*InX)[j]<=(*InX)[jj])
00346                         {
00347                                 if( (xinter>=(*InX)[j]) && (xinter<=(*InX)[jj]) )               //Intersection entre le cercle et le contour
00348                                 {
00349                                         dist = sqrt(pow(tempX[i]-xinter,2) + pow(tempY[i]-yinter,2));
00350                                         if(dist<min)
00351                                         {
00352                                                 min = dist;
00353                                                 xmin = xinter;
00354                                                 ymin = yinter;
00355                                         }
00356                                 }
00357                         }
00358                         if((*InX)[j]>(*InX)[jj])
00359                         {
00360                                 if( (xinter<=(*InX)[j]) && (xinter>=(*InX)[jj]) )               //Intersection entre le cercle et le contour
00361                                 {
00362                                         dist = sqrt(pow(tempX[i]-xinter,2) + pow(tempY[i]-yinter,2));
00363                                         if(dist<min)
00364                                         {
00365                                                 min = dist;
00366                                                 xmin = xinter;
00367                                                 ymin = yinter;
00368                                         }
00369                                 }
00370                         }
00371 JCP 26-09-2008*/
00372                 }
00373 
00374 
00375 
00376 //              fprintf(fd,"\n => x_int = %f, y_int = %f, dist_int = %f",xmin,ymin,min);
00377 //              fprintf(fexp,"\n%d      %f      %f      %f      %f      %f",i,min,xmin,ymin,tempX[i],tempY[i]);
00378 //JCP 26-09-08 If the distance of the intersection is bigger than the radio we have to invert the segment
00379                 if(min>=r)
00380                 {
00381                         interRad = true;
00382                         _interbewteencirclePos.push_back(i);
00383                         _interbewteencircleX.push_back(xmin);
00384                         _interbewteencircleY.push_back(ymin);
00385                         _interbewteencircleDist.push_back( sqrt(pow(cx-xmin,2)+pow(cy-ymin,2)) );
00386 
00387                         //      file1<<i<<std::endl;
00388                 }else{
00389 //JCP 26-09-08          if(min<r)
00390 //JCP 26-09-08          {
00391                         _intercircleX.push_back(xmin);
00392                         _intercircleY.push_back(ymin);
00393                         _intercircleDist.push_back(min);
00394                 //      file1<<"\t"<<i<<std::endl;
00395                 }
00396         }
00397         //file1.close();
00398 //      fclose(fd);
00399 //      fclose(fexp);
00400 
00401         //WHEN THERE IS RADIAL INTERSECTION
00402         vectorFunctions *vecf = new vectorFunctions();
00403 
00404 //EED 22 Sep 2008
00405 //      FILE *fdata;
00406 //      fdata = fopen("C:/bbtk_JS/data/autoCPdata.txt","w");
00407         if(interRad == true)
00408         {
00409                 std::vector<double> tempXX;
00410                 std::vector<double> tempYY;
00411                 std::vector<double> tempDD;
00412                 tempXX.clear();
00413                 tempYY.clear();
00414                 tempDD.clear();
00415 //Copy of the first points in the array until the first intersection is found           
00416                 for(i=0; i<_interbewteencirclePos[0]; i++)
00417                 {
00418                         tempXX.push_back(_intercircleX[i]);
00419                         tempYY.push_back(_intercircleY[i]);
00420                         tempDD.push_back(_intercircleDist[i]);
00421 //                      fprintf(fdata,"\n%f     %f      %f",_intercircleDist[i],_intercircleX[i],_intercircleY[i]);
00422                 }
00423                 int sizep = _interbewteencirclePos.size();
00424 //Copy all the points where there is an intersection with the center but inverted
00425 //JCP 26-09-08          for(i=_interbewteencirclePos[sizep-1],j=sizep-1; i>=_interbewteencirclePos[0]; i--,j--)
00426                 for(i=sizep-1; i >= 0;i--)
00427                 {
00428 //JCP 26-09-08                  tempXX.push_back(_interbewteencircleX[j]);
00429 //JCP 26-09-08                  tempYY.push_back(_interbewteencircleY[j]);
00430 //JCP 26-09-08                  tempDD.push_back(_interbewteencircleDist[j]);
00431                         tempXX.push_back(_interbewteencircleX[i]);
00432                         tempYY.push_back(_interbewteencircleY[i]);
00433                         tempDD.push_back(_interbewteencircleDist[i]);
00434 //                      fprintf(fdata,"\n%f     %f      %f",_interbewteencircleDist[j],_interbewteencircleX[j],_interbewteencircleY[j]);
00435                 }
00436                 for(i=_interbewteencirclePos[0]; i<(int)(_intercircleX.size()); i++)
00437                 {
00438                         tempXX.push_back(_intercircleX[i]);
00439                         tempYY.push_back(_intercircleY[i]);
00440                         tempDD.push_back(_intercircleDist[i]);
00441 //                      fprintf(fdata,"\n%f     %f      %f",_intercircleDist[i],_intercircleX[i],_intercircleY[i]);
00442                 }
00443                 
00444                 _intercircleX.clear();
00445                 _intercircleY.clear();
00446                 _intercircleDist.clear();
00447                 vecf->copyVector(&tempXX,&_intercircleX);
00448                 vecf->copyVector(&tempYY,&_intercircleY);
00449                 vecf->copyVector(&tempDD,&_intercircleDist);
00450         }       
00451 //      fclose(fdata);
00452 
00453         //DELETE!!
00454 
00455         std::ofstream file1;
00456     file1.open( "1_Intersection.txt" );
00457 
00458         for(int i = 0; i < (int)(_intercircleX.size()); i++){
00459                 file1<<"X= "<<_intercircleX[i] << "\tY= "<<_intercircleY[i] << "\tDist= "<<_intercircleDist[i]<<std::endl;
00460         }
00461         file1.close();
00462                 
00463 
00464         delete vecf;
00465 }
00466 //-----------------------------------------------------------------------------------------------------------------------------------------
00467 void AutoControlPoints::maxminLocal()
00468 {
00469         int i;
00470         _posmaxlocal.clear();
00471         _posminlocal.clear();
00472         _posminmaxlocal.clear();
00473         _maxlocalX.clear();
00474         _maxlocalY.clear();
00475         _minlocalX.clear();
00476         _minlocalY.clear();
00477         _minmaxlocalX.clear();
00478         _minmaxlocalY.clear();
00479         
00480         if(_intercircleDist.size() != 0)
00481         {
00482 //JCP 26 - 09 - 08 This change was du to the posibility of having a maximum or a minimum value in the limits of 
00483 //JCP 26 - 09 - 08 the array
00484                 double lastdist, currentdist, nextdist;
00485                 for(i=0; i < (int)(_intercircleDist.size()); i++)
00486                 {
00487                         //FOR MAXIMUM LOCAL
00488 //JCP 26-09-08
00489                         currentdist = _intercircleDist[i];
00490                         if(i == 0){
00491                                 lastdist = _intercircleDist[_intercircleDist.size()-1];
00492                                 nextdist = _intercircleDist[i+1];
00493                         }else if (i == (int)(_intercircleDist.size())-1){
00494                                 lastdist = _intercircleDist[i-1];
00495                                 nextdist = _intercircleDist[0];
00496                         }else{
00497                                 lastdist = _intercircleDist[i-1];                               
00498                                 nextdist = _intercircleDist[i+1];
00499                         }
00500                         
00501 
00502 //JCP 26-09-08                  if( (_intercircleDist[i-1]<_intercircleDist[i]) && (_intercircleDist[i]>_intercircleDist[i+1]))
00503                         if(lastdist < currentdist && currentdist > nextdist)
00504                         {
00505                                 _posmaxlocal.push_back(i);
00506                                 _maxlocalX.push_back(_intercircleX[i]);
00507                                 _maxlocalY.push_back(_intercircleY[i]);
00508                                 _minmaxlocalX.push_back(_intercircleX[i]);
00509                                 _minmaxlocalY.push_back(_intercircleY[i]);
00510                                 _posminmaxlocal.push_back(i);
00511                         }
00512                         //FOR MINIMUM LOCAL
00513 //JCP 26-09-08                  if( (_intercircleDist[i-1]>_intercircleDist[i]) && (_intercircleDist[i]<_intercircleDist[i+1]))
00514                         if(lastdist > currentdist && currentdist < nextdist)
00515                         {
00516                                 _posminlocal.push_back(i);
00517                                 _minlocalX.push_back(_intercircleX[i]);
00518                                 _minlocalY.push_back(_intercircleY[i]);
00519                                 _minmaxlocalX.push_back(_intercircleX[i]);
00520                                 _minmaxlocalY.push_back(_intercircleY[i]);
00521                                 _posminmaxlocal.push_back(i);
00522                         }
00523                 }
00524         }
00525 
00526         vectorFunctions *vecf   = new vectorFunctions();
00527         std::vector<double> tempZ;
00528         tempZ.clear();
00529         
00530         vecf->copyVector(&_minlocalX,&_controlpointsX); 
00531         vecf->copyVector(&_minlocalY,&_controlpointsY);
00532         for(i=0; i<(int)(_minlocalX.size()); i++)
00533         {
00534                 tempZ.push_back(_controlpointsZ[0]);
00535         }
00536         vecf->copyVector(&tempZ,&_controlpointsZ);
00537 
00538 //JCP 26-09-08  
00539         std::ofstream file1;
00540     file1.open( "2_MaxMin.txt" );
00541 
00542         for(int i = 0; i < (int)(_controlpointsX.size()); i++){
00543                 file1<<"X= "<<_controlpointsX[i] << "\tY= "<<_controlpointsY[i] << "\tZ= "<<_controlpointsZ[i]<<std::endl;
00544         }
00545         file1.close();
00546 //JCP 26-09-08
00547         delete vecf;
00548 }
00549 //-----------------------------------------------------------------------------------------------------------------------------------------
00550 //ELIMINATES THE POINTS WITH A DISTANCE < val
00551 void AutoControlPoints::fixBetweenPoints(double val)
00552 {
00553         int size = _controlpointsX.size();
00554         double dist;
00555         if(size != 0)
00556         {
00557                 std::vector<double> tempX;
00558                 std::vector<double> tempY;
00559                 std::vector<double>     tempZ;
00560                 tempX.clear();
00561                 tempY.clear();
00562                 tempZ.clear();
00563 
00564                 int ii;
00565                 vectorFunctions *vecf = new vectorFunctions();
00566                 for(int i=0; i<size; i++)
00567                 {
00568                         ii = (i+1)%size;
00569                         dist = sqrt(pow(_controlpointsX[i]-_controlpointsX[ii],2)+pow(_controlpointsY[i]-_controlpointsY[ii],2));
00570                         if(dist>val)
00571                         {
00572                                 tempX.push_back(_controlpointsX[i]);
00573                                 tempY.push_back(_controlpointsY[i]);
00574                                 tempZ.push_back(_controlpointsZ[i]);
00575                         }
00576                 }
00577                 _controlpointsX.clear();
00578                 _controlpointsY.clear();
00579                 _controlpointsZ.clear();
00580 
00581                 vecf->copyVector(&tempX,&_controlpointsX);
00582                 vecf->copyVector(&tempY,&_controlpointsY);
00583                 vecf->copyVector(&tempZ,&_controlpointsZ);
00584 
00585                 std::ofstream file1;
00586                 file1.open( "3_PointsFixed.txt" );
00587 
00588                 for(int i = 0; i < (int)(_controlpointsX.size()); i++){
00589                         file1<<"X= "<<_controlpointsX[i] << "\tY= "<<_controlpointsY[i] << "\tZ= "<<_controlpointsZ[i]<<std::endl;
00590                 }
00591                 file1.close();
00592 
00593                 delete vecf;
00594         }
00595 }
00596 //-----------------------------------------------------------------------------------------------------------------------------------------
00597 //ALL THE INTERSECTIONS
00598 void AutoControlPoints::InterBetweenContours(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
00599 {
00600         _intervectorX.clear();
00601         _intervectorY.clear();
00602         ChargeSpline();
00603 
00604         int i,ii,j,jj;
00605         double m1,mn,m2,xinter,yinter;
00606         if(_chargecontrolpointsX.size() > 1) //These condition exists because there is a method for find the initial control points 
00607         {
00608 //EED 22 Sep 2008
00609 //              FILE *fd;
00610 //              fd = fopen("C:/bbtk_JS/data/interBetweenContours.txt","w");
00611                 for(i=0; i<(int)(_chargecontrolpointsX.size()); i++)
00612                 {
00613                         ii = (i+1)%(_chargecontrolpointsX.size());
00614 
00615                         m1 = Slope(_chargecontrolpointsX[i],_chargecontrolpointsY[i],_chargecontrolpointsX[ii],_chargecontrolpointsY[ii]);
00616                         mn = m1;
00617                         Normal(_chargecontrolpointsX[i],_chargecontrolpointsY[i],&mn,_chargecontrolpointsX[i]+1);
00618 //                      fprintf(fd,"\n Para X = %f, Y = %f",_chargecontrolpointsX[i],_chargecontrolpointsY[i]);
00619 
00620                         Vector *vecX = new Vector();
00621                         Vector *vecY = new Vector();
00622                         vecX->set_var(_chargecontrolpointsX[i]);
00623                         vecY->set_var(_chargecontrolpointsY[i]);
00624 
00625                         for(j=0; j<(int)(InX->size()); j++)
00626                         {
00627                                 jj = (j+1)%(InX->size());
00628                                 m2 = Slope((*InX)[j],(*InY)[j],(*InX)[jj],(*InY)[jj]);
00629                                 Intersection(_chargecontrolpointsX[i],_chargecontrolpointsY[i],(*InX)[j],(*InY)[j],mn,m2,&xinter,&yinter);
00630 
00631                                 if(((*InX)[j] <= xinter && xinter <= (*InX)[jj]) || (xinter<=(*InX)[j] && xinter>=(*InX)[jj])){
00632                                         vecX->set_vec(xinter);
00633                                         vecY->set_vec(yinter);
00634                                 }
00635 /*JCP 29-09-08
00636                                 if( (*InX)[j]<=(*InX)[jj] )
00637                                 {
00638                                         if( (xinter>=(*InX)[j]) && (xinter<=(*InX)[jj]) )
00639                                         {
00640                                                 //If the point is a CP, the intersection is itself.
00641                                                 if((xinter==_chargecontrolpointsX[i]) && (yinter==_chargecontrolpointsY[i]))
00642                                                 {
00643                                                         vecX->set_vec(xinter);
00644                                                         vecY->set_vec(yinter);
00645 //                                                      fprintf(fd,"\n => x_int = %f, y_int = %f",xinter,yinter);
00646                                                 }
00647                                                 else
00648                                                 {
00649                                                         vecX->set_vec(xinter);
00650                                                         vecY->set_vec(yinter);
00651 //                                                      fprintf(fd,"\n => x_int = %f, y_int = %f",xinter,yinter);
00652                                                 }
00653                                         }
00654                                 }
00655                                 if( (*InX)[j]>(*InX)[jj] )
00656                                 {
00657                                         if( (xinter<=(*InX)[j]) && (xinter>=(*InX)[jj]) )
00658                                         {
00659                                                 //If the point is a CP, the intersection is itself.
00660                                                 if((xinter==_chargecontrolpointsX[i]) && (yinter==_chargecontrolpointsY[i]))
00661                                                 {
00662                                                         vecX->set_vec(xinter);
00663                                                         vecY->set_vec(yinter);
00664 //                                                      fprintf(fd,"\n => x_int = %f, y_int = %f",xinter,yinter);
00665                                                 }
00666                                                 else
00667                                                 {
00668                                                         vecX->set_vec(xinter);
00669                                                         vecY->set_vec(yinter);
00670 //                                                      fprintf(fd,"\n => x_int = %f, y_int = %f",xinter,yinter);
00671                                                 }
00672                                         }
00673                                 }
00674 JCP 29-09-08*/
00675                         }//FOR2
00676                         _intervectorX.push_back(*vecX);
00677                         _intervectorY.push_back(*vecY);
00678                         //DELETE!!
00679                         delete vecX;
00680                         delete vecY;
00681                 }//FOR1
00682 //              fclose(fd);
00683         }//IF
00684 }
00685 //-----------------------------------------------------------------------------------------------------------------------------------------
00686 void AutoControlPoints::GetInterBetweenContours(std::vector<Vector>*interVX, std::vector<Vector>*interVY)
00687 {
00688         interVX->clear();
00689         interVY->clear();
00690         int size = _intervectorX.size();
00691         int i;
00692         if(size != 0)
00693         {
00694                 for(i=0; i<size; i++)
00695                 {
00696                         interVX->push_back(_intervectorX[i]);
00697                         interVY->push_back(_intervectorY[i]);
00698                 }
00699         }
00700 }
00701 //-----------------------------------------------------------------------------------------------------------------------------------------
00702 //ONLY THE LOGICAL INTERSECTIONS
00703 void AutoControlPoints::IntersectionPoints()
00704 {
00705         if(_intervectorX.size() != 0)
00706         {               
00707                 _interpointsX.clear();
00708                 _interpointsY.clear();
00709 
00710 //EED
00711 //              FILE *fd;
00712 //              fd = fopen("C:/bbtk_JS/data/IntersectionPoints.txt","w");
00713                 double dist,min;
00714                 int i,j,posj;
00715 
00716                 posj = -1;
00717                 min = 9999;
00718 /*JCP 30-08-09 
00719                 for(j=0; j<_intervectorX[0].getsize_vec(); j++)
00720                 {
00721                         dist = sqrt( pow( _intervectorX[0].get_vec(j)-_intervectorX[0].get_var(),2 ) + pow( _intervectorY[0].get_vec(j)-_intervectorY[0].get_var(),2 ) );
00722                         if( dist < min )
00723                         {
00724                                 min = dist;
00725                                 posj = j;
00726                         }
00727                 }
00728                 if(posj != -1)
00729                 {
00730                         _interpointsX.push_back(_intervectorX[0].get_vec(posj));
00731                         _interpointsY.push_back(_intervectorY[0].get_vec(posj));
00732 //                      fprintf(fd,"\n Para X = %f, Y = %f",_intervectorX[0].get_var(),_intervectorY[0].get_var());
00733 //                      fprintf(fd,"\n => x_int = %f, y_int = %f",_interpointsX[0],_interpointsY[0]);
00734                 }
00735                 if(posj == -1)
00736                 {
00737                         printf("\n\n There is an invalid intersection: Must see AutoControlPoints::IntersectionPoints() method");
00738                 }
00739 JCP 30-08-09 */
00740                 for(i=0; i<(int)(_intervectorX.size()); i++){
00741                         min = 9999;
00742                         posj = -1;
00743                         for(j=0; j<_intervectorX[i].getsize_vec(); j++) {
00744                                 dist  = sqrt( pow( _intervectorX[i].get_vec(j)-_intervectorX[i].get_var(),2 ) + pow( _intervectorY[i].get_vec(j)-_intervectorX[i].get_var(),2 ) );
00745                                 if( dist < min ){
00746                                         min = dist;
00747                                         posj = j;
00748                                 }
00749                         }
00750                         _interpointsX.push_back(_intervectorX[i].get_vec(posj));
00751                         _interpointsY.push_back(_intervectorY[i].get_vec(posj));                
00752                 }
00753 /*JCP 30-09-08
00754                 for(i=1; i<_intervectorX.size(); i++)
00755                 {
00756                         min = 9999;
00757                         posj = -1;
00758 //                      fprintf(fd,"\n Para X = %f, Y = %f",_intervectorX[i].get_var(),_intervectorY[i].get_var());
00759                         for(j=0; j<_intervectorX[i].getsize_vec(); j++)
00760                         {
00761                                 //TYPE: LE PLUS PRES VOISIN
00762                                 dist  = sqrt( pow( _intervectorX[i].get_vec(j)-_interpointsX[i-1],2 ) + pow( _intervectorY[i].get_vec(j)-_interpointsY[i-1],2 ) );
00763                                 //TYPE: LE PLUS PRES DANS LA MÊME DROITE
00764                                 //dist = sqrt(pow(_intervectorX[i].get_vec(j)-_intervectorX[i].get_var(),2)+pow(_intervectorY[i].get_vec(j)-_intervectorY[i].get_var(),2));
00765                                 
00766                                 if( dist < min )
00767                                 {
00768                                         min = dist;
00769                                         posj = j;
00770                                 }
00771                         }
00772                         _interpointsX.push_back(_intervectorX[i].get_vec(posj));
00773                         _interpointsY.push_back(_intervectorY[i].get_vec(posj));
00774 //                      fprintf(fd,"\n => x_int = %f, y_int = %f",_interpointsX[i],_interpointsY[i]);
00775                 }
00776 JCP 30-09-08*/
00777 //              fclose(fd);
00778         }
00779 }
00780 //-----------------------------------------------------------------------------------------------------------------------------------------
00781 void AutoControlPoints::GetIntersectionPoints(std::vector<Vector>*interVX, std::vector<Vector>*interVY)
00782 {
00783         int size = _interpointsX.size();
00784         int i;
00785         if(size != 0)
00786         {
00787                 Vector *vecX = new Vector();
00788                 Vector *vecY = new Vector();
00789                 interVX->clear();
00790                 interVY->clear();
00791                 for(i=0; i<size; i++)
00792                 {
00793                         vecX->set_var(_controlpointsZ[0]);
00794                         vecX->set_vec(_interpointsX[i]);
00795                         vecY->set_var(_controlpointsZ[0]);
00796                         vecY->set_vec(_interpointsY[i]);
00797                         interVX->push_back(*vecX);
00798                         interVY->push_back(*vecY);
00799                 }
00800                 delete vecX;
00801                 delete vecY;
00802         }
00803 }
00804 //-----------------------------------------------------------------------------------------------------------------------------------------
00805 //ERROR BETWEEN THE LOGICAL INTERSECTIONS
00806 void AutoControlPoints::ErrorBetweenContours()
00807 {
00808         _errorpos = -1;
00809         if(_interpointsX.size() != 0)
00810         {
00811                 _errorvector.clear();
00812                 int i;
00813 //EED 22 Sep 2008
00814 
00815 //              FILE *fd;
00816 //              fd = fopen("C:/bbtk_JS/data/interErrorData.txt","w");
00817                 for(i=0; i<(int)(_interpointsX.size()); i++)
00818                 {
00819                         _errorvector.push_back( (sqrt( pow( _interpointsX[i]-_intervectorX[i].get_var(),2 ) + pow( _interpointsY[i]-_intervectorY[i].get_var(),2 ) )/_pathsize)*100 );
00820 //                      fprintf(fd,"\n%d        %f",i,_errorvector[i]);
00821                 }
00822 //              fclose(fd);
00823                 double max = -1;
00824                 for(i=0; i<(int)(_errorvector.size()); i++)
00825                 {
00826                         if(_interpointsX[i] != -1)
00827                         {
00828                                 if(_errorvector[i]>max)
00829                                 {
00830                                         max = _errorvector[i];
00831                                         _errorpos = i;
00832                                 }
00833                         }
00834                 }
00835         }
00836 }
00837 //-----------------------------------------------------------------------------------------------------------------------------------------
00838 void AutoControlPoints::GetErrorBetweenContours( std::vector<double>*vec )
00839 {
00840         vec->clear();
00841         vectorFunctions *vf = new vectorFunctions();
00842         vf->copyVector(&_errorvector,vec);
00843         delete vf;
00844 }
00845 //-----------------------------------------------------------------------------------------------------------------------------------------
00846 void AutoControlPoints::AddControlPoint(bool activate)
00847 {
00848         if(_errorpos != -1)
00849         {
00850                 double xmax = _interpointsX[(int)_errorpos];
00851                 double ymax = _interpointsY[(int)_errorpos];
00852                 double xx       = _intervectorX[(int)_errorpos].get_var();
00853                 double yy       = _intervectorY[(int)_errorpos].get_var();
00854 printf("\n XMAX = %f, YMAX = %f, XX = %f, YY = %f",xmax,ymax,xx,yy);
00855 
00856                 int i,ii,j,posA=-1,posB=-1;
00857                 bool findA=false, findB=false;
00858                 //CASE A
00859                 for(i=(int)_errorpos; findA!=true; i++)
00860                 {
00861                         ii = i%_errorvector.size();
00862                         for(j=0; j<(int)(_controlpointsX.size()); j++)
00863                         {
00864                                 if( ((float)_controlpointsX[j]-1.5<=(float)_intervectorX[ii].get_var()) && ((float)_intervectorX[ii].get_var()<=(float)_controlpointsX[j]+1.5) &&
00865                                         ((float)_controlpointsY[j]-1.5<=(float)_intervectorY[ii].get_var()) && ((float)_intervectorY[ii].get_var()<=(float)_controlpointsY[j]+1.5) )
00866                                 {
00867                                         findA = true;
00868                                         posA = j;
00869                                 }
00870                         }
00871                 }
00872                 //CASE B
00873                 for(i=(int)_errorpos; findB!=true; i--)
00874                 {
00875                         if(_errorpos==-1)
00876                         {
00877                                 i = _errorvector.size();
00878                         }
00879                         for(j=0; j<(int)(_controlpointsX.size()); j++)
00880                         {
00881                                 if( ((float)_controlpointsX[j]-1.5<=(float)_intervectorX[i].get_var()) && ((float)_intervectorX[i].get_var()<=(float)_controlpointsX[j]+1.5) &&
00882                                         ((float)_controlpointsY[j]-1.5<=(float)_intervectorY[i].get_var()) && ((float)_intervectorY[i].get_var()<=(float)_controlpointsY[j]+1.5) )
00883                                 {
00884                                         findB = true;
00885                                         posB = j;
00886                                 }
00887                         }
00888                 }
00889                 if(posA == posB)
00890                 {
00891                         posB = posA-1;
00892                 }
00893                 if(posA<posB)
00894                 {
00895                         posA = posB+1;
00896                         if(posB = _controlpointsX.size()-1)  // ?!? // JPRx     // ?!? EED
00897                         {
00898                                 posA = 0;
00899                         }
00900                 }
00901 printf("\n POSA = %d, X = %f, Y = %f",posA,_controlpointsX[posA],_controlpointsY[posA]);
00902 printf("\n POSB = %d, X = %f, Y = %f",posB,_controlpointsX[posB],_controlpointsY[posB]);
00903                 _posA = posA;
00904                 _posB = posB;
00905                 int id = -1;
00906                 if(((posA!=-1)&&(posB!=-1)))
00907                 {
00908                         id = posA;
00909                 }
00910 printf("\n ID = %d",id);
00911                 if(id != -1)
00912                 {
00913                         std::vector<double> tempX;
00914                         std::vector<double> tempY;
00915                         std::vector<double> tempZ;
00916                         for(i=0; i<(int)(_controlpointsX.size()); i++)
00917                         {
00918                                 if(i == id)
00919                                 {
00920                                         tempX.push_back(xmax);
00921                                         tempY.push_back(ymax);
00922                                         tempZ.push_back(_controlpointsZ[0]);
00923                                 }
00924                                 tempX.push_back(_controlpointsX[i]);
00925                                 tempY.push_back(_controlpointsY[i]);
00926                                 tempZ.push_back(_controlpointsZ[i]);
00927                         }
00928                 
00929                         if(activate == true)
00930                         {
00931                                 vectorFunctions *vf = new vectorFunctions();
00932                                 vf->copyVector(&tempX,&_controlpointsX);
00933                                 vf->copyVector(&tempY,&_controlpointsY);
00934                                 vf->copyVector(&tempZ,&_controlpointsZ);
00935                                 delete vf;
00936                         }
00937                 
00938                 }
00939         }//IF-(principal)
00940 }
00941 //-----------------------------------------------------------------------------------------------------------------------------------------
00942 void AutoControlPoints::InterBetweenControl( )
00943 {
00944         _intervecXX.clear();
00945         _intervecYY.clear();
00946         
00947         int i,ii,j,jj;
00948         double m1,mn,m2,xinter,yinter;
00949         if(_chargecontrolpointsX.size() > 1) //These condition exists because there is a method for find the initial control points 
00950         {
00951 //EED 22 Sep 2008
00952 
00953 //              FILE *fd;
00954 //              fd = fopen("C:/bbtk_JS/data/InterBetweenControl.txt","w");
00955                 for(i=0; i<(int)(_chargecontrolpointsX.size())-1; i++)
00956                 {
00957                         ii = (i+1)%(_chargecontrolpointsX.size());
00958                         m1 = Slope(_chargecontrolpointsX[i],_chargecontrolpointsY[i],_chargecontrolpointsX[ii],_chargecontrolpointsY[ii]);
00959                         mn = m1;
00960                         Normal(_chargecontrolpointsX[i],_chargecontrolpointsY[i],&mn,_chargecontrolpointsX[i]+1);
00961 //                      fprintf(fd,"\n Para X = %f, Y = %f",_chargecontrolpointsX[i],_chargecontrolpointsY[i]);
00962 
00963                         Vector *vecX = new Vector();
00964                         Vector *vecY = new Vector();
00965                         vecX->set_var(_chargecontrolpointsX[i]);
00966                         vecY->set_var(_chargecontrolpointsY[i]);
00967 
00968                         for(j=0; j<(int)(_chargecontrolpointsX.size()); j++)
00969                         {
00970                                 jj = (j+1)%(_chargecontrolpointsX.size());
00971                                 m2 = Slope(_chargecontrolpointsX[j],_chargecontrolpointsY[j],_chargecontrolpointsX[jj],_chargecontrolpointsY[jj]);
00972                                 Intersection(_chargecontrolpointsX[i],_chargecontrolpointsY[i],_chargecontrolpointsX[j],_chargecontrolpointsY[j],mn,m2,&xinter,&yinter);
00973                                 if( _chargecontrolpointsX[j]<=_chargecontrolpointsX[jj] )
00974                                 {
00975                                         if( (xinter>=_chargecontrolpointsX[j]) && (xinter<=_chargecontrolpointsX[jj]) )
00976                                         {
00977                                                 if(((float)xinter==(float)_chargecontrolpointsX[i]) && ((float)yinter==(float)_chargecontrolpointsY[i]))
00978                                                 {
00979                                                 }
00980                                                 else
00981                                                 {
00982 //                                                      fprintf(fd,"\n => x_int = %f, y_int = %f",xinter,yinter);
00983                                                         vecX->set_vec(xinter);
00984                                                         vecY->set_vec(yinter);
00985                                                 }
00986                                         }
00987                                 }
00988                                 if( _chargecontrolpointsX[j]>_chargecontrolpointsX[jj] )
00989                                 {
00990                                         if( (xinter<=_chargecontrolpointsX[j]) && (xinter>=_chargecontrolpointsX[jj]) )
00991                                         {
00992                                                 if(((float)xinter==(float)_chargecontrolpointsX[i]) && ((float)yinter==(float)_chargecontrolpointsY[i]))
00993                                                 {
00994                                                 }
00995                                                 else
00996                                                 {
00997 //                                                      fprintf(fd,"\n => x_int = %f, y_int = %f",xinter,yinter);
00998                                                         vecX->set_vec(xinter);
00999                                                         vecY->set_vec(yinter);
01000                                                 }
01001                                         }
01002                                 }
01003                         }//FOR2
01004                         _intervecXX.push_back(*vecX);
01005                         _intervecYY.push_back(*vecY);
01006                         
01007                         //DELETE!!
01008                         delete vecX;
01009                         delete vecY;
01010 
01011                 }//FOR1
01012 //              fclose(fd);
01013         }//IF
01014 }
01015 //-----------------------------------------------------------------------------------------------------------------------------------------
01016 void AutoControlPoints::fixBetweenControl()
01017 {
01018         _interitselfX.clear();
01019         _interitselfY.clear();
01020         int i,j;
01021         float vecx,vecy,varx,vary;
01022 //      FILE *fd;
01023 //      fd = fopen("C:/bbtk_JS/data/InterBetweenControlFix.txt","w");
01024         for(i=0; i<(int)(_intervecXX.size()); i++)
01025         {
01026                 Vector *vx = new Vector();
01027                 Vector *vy = new Vector();
01028                 vx->set_var(_intervecXX[i].get_var());
01029                 vy->set_var(_intervecYY[i].get_var());
01030 //              fprintf(fd,"\n Para X = %f, Y = %f",_intervecXX[i].get_var(),_intervecYY[i].get_var());
01031                 for(j=0; j<_intervecXX[i].getsize_vec(); j++)
01032                 {
01033                         vecx = _intervecXX[i].get_vec(j);
01034                         varx = _intervecXX[i].get_var();
01035                         vecy = _intervecYY[i].get_vec(j);
01036                         vary = _intervecYY[i].get_var();
01037                         if(  (vecx == varx) && (vecy == vary) )
01038                         {
01039                         }
01040                         else
01041                         {
01042                                 vx->set_vec((double)vecx);
01043                                 vy->set_vec((double)vecy);
01044 //                              fprintf(fd,"\n => x_int = %f, y_int = %f",vecx,vecy);
01045                         }
01046                 }
01047                 _interitselfX.push_back(*vx);
01048                 _interitselfY.push_back(*vy);
01049                 delete vx;
01050                 delete vy;
01051         }
01052 //      fclose(fd);
01053 }
01054 //-----------------------------------------------------------------------------------------------------------------------------------------
01055 void AutoControlPoints::PossibleIntersections( std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ )
01056 {
01057         InterBetweenContours(InX,InY,InZ);      //_intervectorX
01058         //InterBetweenControl();                                //_intervecXX
01059         //fixBetweenControl();                          //_interitselfX
01060         
01061         std::vector<Vector> tempX;
01062         std::vector<Vector> tempY;
01063         tempX.clear();
01064         tempY.clear();
01065         int i,j,k;
01066         //double dist1,dist2; // JPRx
01067 //EED 22 Sep 2008
01068 //      FILE *fd;
01069 /*
01070         bool ready;
01071         fd = fopen("C:/bbtk_JS/data/InterPossibleIntersections.txt","w");
01072 
01073 
01074         for(i=0; i<_intervectorX.size(); i++)
01075         {
01076                 fprintf(fd,"\n Para X = %f, Y = %f",_intervectorX[i].get_var(),_intervectorY[i].get_var());
01077                 Vector *vx = new Vector();
01078                 Vector *vy = new Vector();
01079                 vx->set_var(_intervectorX[i].get_var());
01080                 vy->set_var(_intervectorY[i].get_var());
01081                 ready = false;
01082                 for(j=0; j<_intervectorX[i].getsize_vec() ; j++)
01083                 {
01084                         dist1 = sqrt( pow(_intervectorX[i].get_var()-_intervectorX[i].get_vec(j),2) + pow(_intervectorY[i].get_var()-_intervectorY[i].get_vec(j),2) );
01085                         for(k=0; (k<_interitselfX[i].getsize_vec()) && (ready!=true); k++)
01086                         {
01087                                 dist2 = sqrt( pow(_interitselfX[i].get_var()-_interitselfX[i].get_vec(k),2) + pow(_interitselfY[i].get_var()-_interitselfY[i].get_vec(k),2) );
01088                                 if(dist2>dist1)
01089                                 {
01090                                         fprintf(fd,"\n => x_int = %f, y_int = %f",_intervectorX[i].get_vec(j),_intervectorY[i].get_vec(j));
01091                                         vx->set_vec(_intervectorX[i].get_vec(j));
01092                                         vy->set_vec(_intervectorY[i].get_vec(j));
01093                                         ready == true;
01094                                 }
01095                         }
01096                 }
01097                 tempX.push_back(*vx);
01098                 tempY.push_back(*vy);
01099                 delete vx;
01100                 delete vy;
01101         }
01102         fclose(fd);
01103         
01104         _intervectorX.clear();
01105         _intervectorY.clear();
01106         Vector *vv = new Vector();
01107         vv->copyVector(&tempX,&_intervectorX);
01108         vv->copyVector(&tempY,&_intervectorY);
01109         
01110         //vv->printVector(&_intervectorX);
01111 */
01112         std::vector<double> arrX; 
01113         std::vector<double> arrY;
01114         std::vector<double>::iterator itx;
01115         std::vector<double>::iterator ity;
01116         std::vector<double>::iterator itxx;
01117         std::vector<double>::iterator ityy;
01118         double distA, distB;
01119         if(_intervectorX.size() != 0)
01120         {
01121 //              fd = fopen("C:/bbtk_JS/data/InterPossibleIntersections.txt","w");
01122                 for(i=0; i<(int)(_intervectorX.size()); i++)
01123                 {
01124 //                      fprintf(fd,"\n Para X = %f, Y = %f",_intervectorX[i].get_var(),_intervectorY[i].get_var());
01125                         if(_intervectorX[i].getsize_vec() > 1)
01126                         {
01127                                 arrX.clear();
01128                                 arrY.clear();
01129                                 for(j=0; j<_intervectorX[i].getsize_vec(); j++)
01130                                 {
01131                                         arrX.push_back(_intervectorX[i].get_vec(j));
01132                                         arrY.push_back(_intervectorY[i].get_vec(j));
01133                                 }
01134 //printf("\n arrX Size = %d",arrX.size());
01135                                 itx = arrX.begin();
01136                                 ity = arrY.begin();
01137                                 itxx = arrX.begin()+1;
01138                                 ityy = arrY.begin()+1;
01139                                 for(j=0; j<(int)(arrX.size())-1; j++)
01140                                 {
01141                                         // I
01142                                         if( (*itx > _intervectorX[i].get_var())  && (*ity < _intervectorY[i].get_var()) && 
01143                                                 (*itxx > _intervectorX[i].get_var()) && (*ityy < _intervectorY[i].get_var()) )
01144                                         {
01145                                                 distA = sqrt( pow(*itx-_intervectorX[i].get_var(),2) + pow(*ity-_intervectorY[i].get_var(),2) );
01146                                                 distB = sqrt( pow(*itxx-_intervectorX[i].get_var(),2) + pow(*ityy-_intervectorY[i].get_var(),2) );
01147                                                 if(distA<distB)
01148                                                 {
01149                                                         arrX.erase(itxx);
01150                                                         arrY.erase(ityy);
01151                                                 }
01152                                                         if(distA>distB)
01153                                                 {
01154                                                         arrX.erase(itx);
01155                                                         arrY.erase(ity);
01156                                                         itxx++;
01157                                                         ityy++;
01158                                                 }       
01159                                         }
01160                                         // II
01161                                         else if( (*itx < _intervectorX[i].get_var())  && (*ity < _intervectorY[i].get_var()) && 
01162                                                 (*itxx < _intervectorX[i].get_var()) && (*ityy < _intervectorY[i].get_var()) )
01163                                         {
01164                                                 distA = sqrt( pow(*itx-_intervectorX[i].get_var(),2) + pow(*ity-_intervectorY[i].get_var(),2) );
01165                                                 distB = sqrt( pow(*itxx-_intervectorX[i].get_var(),2) + pow(*ityy-_intervectorY[i].get_var(),2) );
01166                                                 if(distA<distB)
01167                                                 {
01168                                                         arrX.erase(itxx);
01169                                                         arrY.erase(ityy);
01170                                                 }
01171                                                 if(distA>distB)
01172                                                 {
01173                                                         arrX.erase(itx);
01174                                                         arrY.erase(ity);
01175                                                         itxx++;
01176                                                         ityy++;
01177                                                 }       
01178                                         }
01179                                         // III
01180                                         else if( (*itx < _intervectorX[i].get_var())  && (*ity > _intervectorY[i].get_var()) && 
01181                                                 (*itxx < _intervectorX[i].get_var()) && (*ityy > _intervectorY[i].get_var()) )
01182                                         {
01183                                                 distA = sqrt( pow(*itx-_intervectorX[i].get_var(),2) + pow(*ity-_intervectorY[i].get_var(),2) );
01184                                                 distB = sqrt( pow(*itxx-_intervectorX[i].get_var(),2) + pow(*ityy-_intervectorY[i].get_var(),2) );
01185                                                 if(distA<distB)
01186                                                 {
01187                                                         arrX.erase(itxx);
01188                                                         arrY.erase(ityy);
01189                                                 }
01190                                                 if(distA>distB)
01191                                                 {
01192                                                         arrX.erase(itx);
01193                                                         arrY.erase(ity);
01194                                                         itxx++;
01195                                                         ityy++;
01196                                                 }       
01197                                         }
01198                                         // IV
01199                                         else if( ((double)*itx > _intervectorX[i].get_var())  && (*ity > _intervectorY[i].get_var()) && 
01200                                                 ((double)*itxx > _intervectorX[i].get_var()) && (*ityy > _intervectorY[i].get_var()) )
01201                                         {
01202                                                 distA = sqrt( pow(*itx-_intervectorX[i].get_var(),2) + pow(*ity-_intervectorY[i].get_var(),2) );
01203                                                 distB = sqrt( pow(*itxx-_intervectorX[i].get_var(),2) + pow(*ityy-_intervectorY[i].get_var(),2) );
01204                                                 if(distA<distB)
01205                                                 {
01206                                                         arrX.erase(itxx);
01207                                                         arrY.erase(ityy);
01208                                                 }
01209                                                 if(distA>distB)
01210                                                 {
01211                                                         arrX.erase(itx);
01212                                                         arrY.erase(ity);
01213                                                         itxx++;
01214                                                         ityy++;
01215                                                 }       
01216                                         }
01217                                         else
01218                                         {
01219                                                 itx++;
01220                                                 ity++;
01221                                                 itxx++;
01222                                                 ityy++;
01223                                         }
01224                                 }
01225                                 _intervectorX[i].resetVec();
01226                                 _intervectorY[i].resetVec();
01227 //printf("\n _intervector(%d) Size = %d",i,_intervectorX[i].getsize_vec());
01228                                 for(k=0; k<(int)(arrX.size()); k++)
01229                                 {
01230 //printf("\n arr(%d) X = %f, Y = %f",k,arrX[k],arrY[k]);
01231 //                                      fprintf(fd,"\n => x_int = %f, y_int = %f",arrX[k],arrY[k]);
01232                                         _intervectorX[i].set_vec(arrX[k]);
01233                                         _intervectorY[i].set_vec(arrY[k]);
01234                                 }
01235                         }
01236                 }
01237         }
01238 
01239         //DELETE!!
01240 //      delete vv;
01241 
01242 }
01243 //-----------------------------------------------------------------------------------------------------------------------------------------
01244 void AutoControlPoints::ControlInContour(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
01245 {
01246         int i,j;
01247         _contIncontpos.clear(); 
01248         bool find = false;
01249         double range = 2;
01250         for(i=0; i<(int)(_controlpointsX.size()); i++)
01251         {
01252                 find = false;
01253                 for(j=0; (j<(int)(InX->size())) && (find!=true); j++)
01254                 {
01255                         if( ((*InX)[j]-range<=_controlpointsX[i]) && (_controlpointsX[i]<=(*InX)[j]+range) && ((*InY)[j]-range<=_controlpointsY[i]) && (_controlpointsY[i]<=(*InY)[j]+range) )
01256                         {
01257                                 _contIncontpos.push_back(j);
01258                                 find = true;
01259                         }
01260                 }
01261         }
01262 }
01263 //-----------------------------------------------------------------------------------------------------------------------------------------
01264 void AutoControlPoints::NearMaxError2Control()
01265 {
01266         if(_interpointsX.size() != 0)
01267         {
01268                 AddControlPoint(false);
01269 
01270                 double distA = sqrt( pow(_interpointsX[_errorpos]-_controlpointsX[_posA],2) + pow(_interpointsY[_errorpos]-_controlpointsY[_posA],2) );
01271                 double distB = sqrt( pow(_interpointsX[_errorpos]-_controlpointsX[_posB],2) + pow(_interpointsY[_errorpos]-_controlpointsY[_posB],2) );
01272                 double nearp = -1;
01273                 if(distA<distB)
01274                 {
01275                         nearp = distA;
01276                         _posn = _posA;
01277 
01278                 }
01279                 else
01280                 {
01281                         nearp = distB;
01282                         _posn = _posB;
01283                 }
01284         }
01285 }
01286 //-----------------------------------------------------------------------------------------------------------------------------------------
01287 void AutoControlPoints::MoveControlPointInContour(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
01288 {
01289 int i;
01290 /*
01291 //PRINTF---------------------------------------------------------------
01292 printf("\n CONTROL POINTS BEFORE MOVEMENT");
01293 for(i=0; i<_controlpointsX.size(); i++)
01294 {
01295         printf("\n X = %f, Y = %f",_controlpointsX[i],_controlpointsY[i]);
01296 }
01297 //---------------------------------------------------------------------
01298 */
01299         vectorFunctions *vf = new vectorFunctions();
01300         fixBetweenPoints(5.0);
01301         PossibleIntersections(InX,InY,InZ);
01302         IntersectionPoints();
01303         ErrorBetweenContours();
01304         //double promIn = vf->promVector(&_errorvector,false); // JPRx
01305 
01306         std::vector<double> tempX;
01307         std::vector<double> tempY;
01308         std::vector<double> tempZ;
01309         tempX.clear();
01310         tempY.clear();
01311         tempZ.clear();
01312         
01313         vf->copyVector(&_controlpointsX,&tempX);
01314         vf->copyVector(&_controlpointsY,&tempY);
01315         vf->copyVector(&_controlpointsZ,&tempZ);
01316         _controlpointsX.clear();
01317         _controlpointsY.clear();
01318         _controlpointsZ.clear();
01319 
01320         for(i=0; i<(int)(tempX.size()); i++)
01321         {
01322                 if(i==_posn)
01323                 {
01324                         _controlpointsX.push_back( (*InX)[_contIncontpos[_posn]] );
01325                         _controlpointsY.push_back( (*InY)[_contIncontpos[_posn]] );
01326                         _controlpointsZ.push_back( (*InZ)[_contIncontpos[_posn]] );
01327                 }
01328                 else
01329                 {
01330                         _controlpointsX.push_back( tempX[i] );
01331                         _controlpointsY.push_back( tempY[i] );
01332                         _controlpointsZ.push_back( tempZ[i] );
01333                 }
01334         }
01335 
01336         fixBetweenPoints(5.0);
01337         PossibleIntersections(InX,InY,InZ);
01338         IntersectionPoints();
01339         ErrorBetweenContours();
01340         double promactualIn = vf->promVector(&_errorvector,false);
01341         double prom;
01342         double promactual;
01343         
01344         int posact;
01345         //int pos1; // JPRx
01346         //double prom1final; // JPRx
01347         int pos2;
01348         double prom2final;
01349 
01350         //DIRECTION 1
01351         int direction = 1;
01352         posact = _posn;
01353         prom = -1;
01354         promactual = promactualIn;
01355         _controlpointsX.clear();
01356         _controlpointsY.clear();
01357         _controlpointsZ.clear();
01358         for(i=0; promactual > prom; i++)
01359         {
01360                 prom = promactual;
01361                 for(i=0; i<(int)(tempX.size()); i++)
01362                 {
01363                         if(i==_posn)
01364                         {
01365                                 _controlpointsX.push_back( (*InX)[_contIncontpos[posact]] );
01366                                 _controlpointsY.push_back( (*InY)[_contIncontpos[posact]] );
01367                                 _controlpointsZ.push_back( (*InZ)[_contIncontpos[posact]] );
01368                         }
01369                         else
01370                         {
01371                                 _controlpointsX.push_back( tempX[i] );
01372                                 _controlpointsY.push_back( tempY[i] );
01373                                 _controlpointsZ.push_back( tempZ[i] );
01374                         }
01375                 }
01376                 if(direction == 1)
01377                 {
01378                         posact = posact+1;
01379                 }
01380                 if(direction == -1)
01381                 {
01382                         posact = posact-1;
01383                 }
01384                 fixBetweenPoints(5.0);
01385                 PossibleIntersections(InX,InY,InZ);
01386                 IntersectionPoints();
01387                 ErrorBetweenContours();
01388                 promactual = vf->promVector(&_errorvector,false);
01389 //printf("\n The point in the position %d, has moved %d times",_posn,i);
01390         }
01391         pos2 = posact;
01392         prom2final = promactual;
01393 
01394         delete vf;
01395 }
01396 //--------------------------------------------------------------------------------------------------------------------------------
01397 double AutoControlPoints::MoveAndAverage(int dir, std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
01398 {
01399         /*
01400 //PRINTF---------------------------------------------------------------
01401         int i;
01402         printf("\n CONTROL POINTS BEFORE MOVEMENT");
01403         for(i=0; i<_controlpointsX.size(); i++)
01404         {
01405                 printf("\n X = %f, Y = %f",_controlpointsX[i],_controlpointsY[i]);
01406         }
01407         for(i=0; i<_contIncontpos.size(); i++)
01408         {
01409                 printf("\n contIncont pos = %d",_contIncontpos[i]);
01410         }
01411 */
01412 //IMPLEMENTATION-------------------------------------------------------
01413         if( (_contIncontpos.size() != 0) && (_controlpointsX.size() != 0) )
01414         {
01415                 vectorFunctions *vf = new vectorFunctions();
01416                 std::vector<double>::iterator itx;
01417                 std::vector<double>::iterator ity;
01418                 std::vector<double> tempX;
01419                 std::vector<double> tempY;
01420                 tempX.clear();
01421                 tempY.clear();
01422                 vf->copyVector(&_controlpointsX,&tempX);
01423                 vf->copyVector(&_controlpointsY,&tempY);
01424                 int i,j /*,pos = 0*/ ;  // JPRx
01425                 double prom1=0,promactual1=1;
01426                 //double prom2=0,promactual2=1; // JPRx
01427                 int h = 0;
01428                 int hh = 1;
01429                 if(_contIncontpos[h]>_contIncontpos[hh])
01430                 {
01431                         itx = _controlpointsX.begin();
01432                         ity = _controlpointsY.begin();
01433                         for(i=_contIncontpos[h],j=_contIncontpos[h]; (i>_contIncontpos[hh]) && (promactual1>prom1); i--)
01434                         {
01435                                 if(j == (int)(InX->size()))
01436                                 {
01437                                         j = 0;
01438                                 }
01439                                 prom1 = promactual1;
01440                                 *itx = (*InX)[j];
01441                                 *ity = (*InY)[j];
01442                                 printf("\n itx = %f, ity = %f", *itx,*ity);
01443                                 fixBetweenPoints(5.0);
01444                                 PossibleIntersections(InX,InY,InZ);
01445                                 IntersectionPoints();
01446                                 ErrorBetweenContours();
01447                                 promactual1 = vf->promVector(&_errorvector,false);
01448                                 j++;
01449                         }
01450                 }
01451                 if(_contIncontpos[h]<_contIncontpos[hh])
01452                 {
01453                         itx = _controlpointsX.begin();
01454                         ity = _controlpointsY.begin();
01455                         for(i=_contIncontpos[h],j=_contIncontpos[h]; (i<_contIncontpos[hh]) && (promactual1>prom1); i++)
01456                         {
01457                                 if(j == -1)
01458                                 {
01459                                         j = InX->size()-1;
01460                                 }
01461                                 prom1 = promactual1;
01462                                 *itx = (*InX)[j];
01463                                 *ity = (*InY)[j];
01464                                 printf("\n itx = %f, ity = %f", *itx,*ity);
01465                                 fixBetweenPoints(5.0);
01466                                 PossibleIntersections(InX,InY,InZ);
01467                                 IntersectionPoints();
01468                                 ErrorBetweenContours();
01469                                 promactual1 = vf->promVector(&_errorvector,false);
01470                                 j--;
01471                         }
01472                 }
01473                 delete vf;
01474         }
01475         return 99999;
01476 }
01477 //--------------------------------------------------------------------------------------------------------------------------------
01478 void AutoControlPoints::MoveControlPoints(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
01479 {
01480         ControlInContour(InX,InY,InZ);
01481         NearMaxError2Control();
01482         MoveAndAverage(1,InX,InY,InZ);
01483 }
01484 //-----------------------------------------------------------------------------------------------------------------------------------------
01485 void AutoControlPoints::GetNewPoints( std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ )
01486 {
01487         vectorFunctions *vf = new vectorFunctions();
01488         double prom,maxerror;
01489         
01490         InterCircle(InX,InY,InZ);
01491         maxminLocal();
01492         fixBetweenPoints(5.0);
01493         PossibleIntersections(InX,InY,InZ);
01494         IntersectionPoints();
01495         ErrorBetweenContours();
01496         prom = vf->promVector(&_errorvector,false);
01497         vf->maxVector(&_errorvector,&maxerror);
01498 printf("\n");
01499         if( maxerror>3.0 )
01500         {
01501                 _controlpointsX.clear();
01502                 _controlpointsY.clear();
01503                 _controlpointsZ.clear();
01504                 vf->copyVector(&_minmaxlocalX,&_controlpointsX);
01505                 vf->copyVector(&_minmaxlocalY,&_controlpointsY);
01506                 for(int i=0; i<(int)(_minmaxlocalX.size()); i++)
01507                 {
01508                         _controlpointsZ.push_back( (*InZ)[0] );
01509                 }
01510                 fixBetweenPoints(5.0);
01511                 PossibleIntersections(InX,InY,InZ);
01512                 IntersectionPoints();
01513                 ErrorBetweenContours();
01514                 prom = vf->promVector(&_errorvector,false);
01515                 vf->maxVector(&_errorvector,&maxerror);
01516 printf("\n");
01517         }
01518 
01519         std::vector<double> cpX;
01520         std::vector<double> cpY;
01521         std::vector<double> cpZ;
01522         cpX.clear();
01523         cpY.clear();
01524         cpZ.clear();
01525         vf->copyVector(&_controlpointsX,&cpX);
01526         vf->copyVector(&_controlpointsY,&cpY);
01527         vf->copyVector(&_controlpointsZ,&cpZ);
01528         int i;
01529 
01530         for(i=0; (i<10)&&(maxerror>0.5)&&(prom>0.15); i++ )
01531         {
01532                 AddControlPoint(true);
01533                 fixBetweenPoints(5.0);
01534                 PossibleIntersections(InX,InY,InZ);
01535                 IntersectionPoints();
01536                 ErrorBetweenContours();
01537                 prom = vf->promVector(&_errorvector,false);
01538                 vf->maxVector(&_errorvector,&maxerror);
01539                 printf("\n %d ",i);
01540         }
01541 
01542         if(i == 10)
01543         {
01544                 _controlpointsX.clear();
01545                 _controlpointsY.clear();
01546                 _controlpointsZ.clear();
01547                 int inicontrolpoints = cpX.size();
01548                 double inipercentage = (inicontrolpoints*100)/InX->size();
01549                 int h=0;
01550                 if(inicontrolpoints<10)
01551                 {
01552                         int points = (int)((inipercentage*3*InX->size())/100);
01553                         for (int i=0; i<(int)(InX->size()); i++, h++)
01554                         {
01555                                 if( h == points )
01556                                 {
01557                                         _controlpointsX.push_back( (*InX)[i] );
01558                                         _controlpointsY.push_back( (*InY)[i] );
01559                                         _controlpointsZ.push_back( (*InZ)[i] );
01560                                         h = 0;
01561                                 }
01562                         }
01563                 }
01564                 if(inicontrolpoints>=10)
01565                 {
01566                         int points = (int)((inipercentage*2*InX->size())/100);
01567                         for (int i=0; i<(int)(InX->size()); i++, h++)
01568                         {
01569                                 if( h == points )
01570                                 {
01571                                         _controlpointsX.push_back( (*InX)[i] );
01572                                         _controlpointsY.push_back( (*InY)[i] );
01573                                         _controlpointsZ.push_back( (*InZ)[i] );
01574                                         h = 0;
01575                                 }
01576                         }
01577                 }
01578         }
01579 /*
01580         fixBetweenPoints(5.0);
01581         PossibleIntersections(InX,InY,InZ);
01582         IntersectionPoints();
01583         ErrorBetweenContours();
01584         prom = vf->promVector(&_errorvector,false);
01585         vf->maxVector(&_errorvector,&maxerror);
01586 
01587 
01588 printf("\n Error Average  = %f",prom);
01589 printf("\n Error Max  = %f",maxerror);
01590         AddControlPoint(false);
01591 */
01592 /*
01593         //if( (prom>1) || (maxerror>2))
01594         if( prom>0.2 )
01595         {
01596 printf("\n Error Average is grater than 1 !!");
01597                 MoveControlPoints(InX,InY,InZ);
01598         }
01599 */
01600         delete vf;
01601 }
01602 //------------------------------------------------------------------------------------------------------------------------------------------
01603 void AutoControlPoints::GetInitialNewPoints(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ )
01604 {
01605         vectorFunctions *vf = new vectorFunctions();
01606         double prom,maxerror;
01607         
01608         InterCircle(InX,InY,InZ);
01609         maxminLocal();
01610         fixBetweenPoints(5.0);
01611         PossibleIntersections(InX,InY,InZ);
01612         IntersectionPoints();
01613         ErrorBetweenContours();
01614         prom = vf->promVector(&_errorvector,false);
01615         vf->maxVector(&_errorvector,&maxerror);
01616         
01617         if( maxerror>3.0 )
01618         {
01619                 _controlpointsX.clear();
01620                 _controlpointsY.clear();
01621                 _controlpointsZ.clear();
01622                 vf->copyVector(&_minmaxlocalX,&_controlpointsX);
01623                 vf->copyVector(&_minmaxlocalY,&_controlpointsY);
01624                 for(int i=0; i<(int)(_minmaxlocalX.size()); i++)
01625                 {
01626                         _controlpointsZ.push_back( (*InZ)[0] );
01627                 }
01628                 fixBetweenPoints(5.0);
01629                 PossibleIntersections(InX,InY,InZ);
01630                 IntersectionPoints();
01631                 ErrorBetweenContours();
01632                 prom = vf->promVector(&_errorvector,false);
01633                 vf->maxVector(&_errorvector,&maxerror);
01634         }
01635 
01636         std::vector<double> cpX;
01637         std::vector<double> cpY;
01638         std::vector<double> cpZ;
01639         cpX.clear();
01640         cpY.clear();
01641         cpZ.clear();
01642         vf->copyVector(&_controlpointsX,&cpX);
01643         vf->copyVector(&_controlpointsY,&cpY);
01644         vf->copyVector(&_controlpointsZ,&cpZ);
01645 
01646         double promini = prom; 
01647 
01648         int i;
01649         for(i=0; (i<10)&&(maxerror>0.5)&&(prom>0.15); i++ )
01650         {
01651                 AddControlPoint(true);
01652                 fixBetweenPoints(5.0);
01653                 PossibleIntersections(InX,InY,InZ);
01654                 IntersectionPoints();
01655                 ErrorBetweenContours();
01656                 prom = vf->promVector(&_errorvector,false);
01657                 vf->maxVector(&_errorvector,&maxerror);
01658         }
01659 
01660         if( i==10 || prom > promini)
01661         {
01662                 _controlpointsX.clear();
01663                 _controlpointsY.clear();
01664                 _controlpointsZ.clear();
01665                 vf->copyVector(&cpX,&_controlpointsX);
01666                 vf->copyVector(&cpY,&_controlpointsY);
01667                 vf->copyVector(&cpZ,&_controlpointsZ);
01668         }
01669         delete vf;
01670 }
01671 //------------------------------------------------------------------------------------------------------------------------------------------
01672 void AutoControlPoints::CalculeControlPoints(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
01673 {
01674 
01675         _controlpointsX.clear();
01676         _controlpointsY.clear();
01677         _controlpointsZ.clear();
01678         _controlpointsZ.push_back((*InZ)[0]);
01679         GetNewPoints( InX,InY,InZ );
01680 }
01681 //-----------------------------------------------------------------------------------------------------------------------------------------
01682 void AutoControlPoints::CalculeInitialControlPoints(std::vector<double>*InX, std::vector<double>*InY, std::vector<double>*InZ)
01683 {
01684 
01685         _controlpointsX.clear();
01686         _controlpointsY.clear();
01687         _controlpointsZ.clear();
01688         _controlpointsZ.push_back((*InZ)[0]);
01689         GetInitialNewPoints( InX,InY,InZ );
01690 }
01691 //-----------------------------------------------------------------------------------------------------------------------------------------
01692 void AutoControlPoints::GetControlPoints(std::vector<double>*OutX, std::vector<double>*OutY, std::vector<double>*OutZ)
01693 {
01694         vectorFunctions *vf = new vectorFunctions();
01695         OutX->clear();
01696         OutY->clear();
01697         OutZ->clear();
01698         vf->copyVector(&_controlpointsX,OutX);
01699         vf->copyVector(&_controlpointsY,OutY);
01700         vf->copyVector(&_controlpointsZ,OutZ);
01701         delete vf;
01702 }
01703 //-----------------------------------------------------------------------------------------------------------------------------------------
01704 void AutoControlPoints::GetInitialControlPoints(std::vector<double>*OutX, std::vector<double>*OutY, std::vector<double>*OutZ)
01705 {
01706         vectorFunctions *vf = new vectorFunctions();
01707         OutX->clear();
01708         OutY->clear();
01709         OutZ->clear();
01710         vf->copyVector(&_controlpointsX,OutX);
01711         vf->copyVector(&_controlpointsY,OutY);
01712         vf->copyVector(&_controlpointsZ,OutZ);
01713         delete vf;
01714 }
01715 
01716 //-----------------------------------------------------------------------------------------------------------------------------------------
01717 void AutoControlPoints::SetNumSplineInterpolation(int num)
01718 {
01719         _numspline = num;
01720 }
01721 //-----------------------------------------------------------------------------------------------------------------------------------------
01722 //-----------------------------------------------------------------------------------------------------------------------------------------
01723 //-----------------------------------------------------------------------------------------------------------------------------------------
01724  
01725  

Generated on 18 Mar 2010 for creaMaracasVisu_lib by  doxygen 1.6.1