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)
50 int sizeX = InX->size();
51 int sizeY = InY->size();
52 int sizeZ = InZ->size();
53 if( (sizeX == sizeY) && (sizeY==sizeZ) )
55 for(i=0; i<sizeX; i++)
57 _InX.push_back( (*InX)[i] );
58 _InY.push_back( (*InY)[i] );
59 _InZ.push_back( (*InZ)[i] );
62 printf("\n The lists Of vectors have diferents sizes");
65 //-----------------------------------------------------------------------------------------
66 //AUTOMATIC METHOD (INITIAL AND ADDING)
67 void ExtractControlPoints2D::GetInitialControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
69 AutoControlPoints *autoc = new AutoControlPoints();
76 autoc->SetNumSplineInterpolation((int)_numinterspline);
77 autoc->CalculeInitialControlPoints(&_InX,&_InY,&_InZ);
78 autoc->GetInitialControlPoints(pOutX,pOutY,pOutZ);
82 //-----------------------------------------------------------------------------------------
83 //AUTOMATIC METHOD (INITIAL, ADDING AND SAMPLING)
84 void ExtractControlPoints2D::GetControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
86 AutoControlPoints *autoc = new AutoControlPoints();
93 autoc->SetNumSplineInterpolation((int)_numinterspline);
94 autoc->CalculeControlPoints(&_InX,&_InY,&_InZ);
95 autoc->GetControlPoints(pOutX,pOutY,pOutZ);
99 //-----------------------------------------------------------------------------------------
100 //SET THE SAMPLING (PERCENT) FOR THE REGULAR SAMPLING METHOD
101 void ExtractControlPoints2D::SetSamplingControlPoints(double val)
105 _numsampling = _InX.size()* (val/100);
108 //-----------------------------------------------------------------------------------------
109 //REGULAR SAMPLING METHOD
110 void ExtractControlPoints2D::GetSamplingControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
119 int points = (int)(_InX.size()/_numsampling);
120 for (int i=0; i<(int)(_InX.size()); i++, h++)
124 pOutX->push_back( _InX[i] );
125 pOutY->push_back( _InY[i] );
126 pOutZ->push_back( _InZ[i] );
132 //-----------------------------------------------------------------------------------------
133 void ExtractControlPoints2D::SetNumberOfSplineInterpolation(double val)
135 _numinterspline = val;
137 //------------------------------------------------------------------------------