1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "ExtractControlPoints2D.h"
29 ExtractControlPoints2D::ExtractControlPoints2D()
31 _numinterspline = 100;
35 ExtractControlPoints2D::~ExtractControlPoints2D()
38 //-----------------------------------------------------------------------------------------
39 void ExtractControlPoints2D::ResetControlPoints()
43 //-----------------------------------------------------------------------------------------
44 void ExtractControlPoints2D::SetContour(std::vector<double>*InX, std::vector<double>*InY,std::vector<double>*InZ)
49 int sizeX = InX->size();
50 int sizeY = InY->size();
51 int sizeZ = InZ->size();
52 if( (sizeX == sizeY) && (sizeY==sizeZ) )
54 for(int i=0; i<sizeX; i++)
56 _InX.push_back( (*InX)[i] );
57 _InY.push_back( (*InY)[i] );
58 _InZ.push_back( (*InZ)[i] );
63 printf("\n The lists Of vectors have diferents sizes");
66 //-----------------------------------------------------------------------------------------
67 //AUTOMATIC METHOD (INITIAL AND ADDING)
68 void ExtractControlPoints2D::GetInitialControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
70 AutoControlPoints *autoc = new AutoControlPoints();
77 autoc->SetNumSplineInterpolation((int)_numinterspline);
78 autoc->CalculeInitialControlPoints(&_InX,&_InY,&_InZ);
79 autoc->GetInitialControlPoints(pOutX,pOutY,pOutZ);
83 //-----------------------------------------------------------------------------------------
84 //AUTOMATIC METHOD (INITIAL, ADDING AND SAMPLING)
85 void ExtractControlPoints2D::GetControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
87 AutoControlPoints *autoc = new AutoControlPoints();
94 autoc->SetNumSplineInterpolation((int)_numinterspline);
95 autoc->CalculeControlPoints(&_InX,&_InY,&_InZ);
96 autoc->GetControlPoints(pOutX,pOutY,pOutZ);
100 //-----------------------------------------------------------------------------------------
101 //SET THE SAMPLING (PERCENT) FOR THE REGULAR SAMPLING METHOD
102 void ExtractControlPoints2D::SetSamplingControlPoints(double val)
106 _numsampling = _InX.size()* (val/100);
109 //-----------------------------------------------------------------------------------------
110 //REGULAR SAMPLING METHOD
111 void ExtractControlPoints2D::GetSamplingControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
120 int points = (int)(_InX.size()/_numsampling);
121 for (int i=0; i<(int)(_InX.size()); i++, h++)
125 pOutX->push_back( _InX[i] );
126 pOutY->push_back( _InY[i] );
127 pOutZ->push_back( _InZ[i] );
133 //-----------------------------------------------------------------------------------------
134 void ExtractControlPoints2D::SetNumberOfSplineInterpolation(double val)
136 _numinterspline = val;
138 //------------------------------------------------------------------------------