]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/Contour/ExtractControlPoints2D.cxx
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / Contour / ExtractControlPoints2D.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 #include "ExtractControlPoints2D.h"
27
28 //Construction
29 ExtractControlPoints2D::ExtractControlPoints2D()
30 {
31         _numinterspline = 100;
32         _numsampling = 25;
33 }
34 //Destruction
35 ExtractControlPoints2D::~ExtractControlPoints2D()
36 {
37 }
38 //-----------------------------------------------------------------------------------------
39 void ExtractControlPoints2D::ResetControlPoints()
40 {
41
42 }
43 //-----------------------------------------------------------------------------------------
44 void ExtractControlPoints2D::SetContour(std::vector<double>*InX, std::vector<double>*InY,std::vector<double>*InZ)
45 {
46         _InX.clear();
47         _InY.clear();
48         _InZ.clear();
49         int sizeX = InX->size();
50         int sizeY = InY->size();
51         int sizeZ = InZ->size();
52         if( (sizeX == sizeY) && (sizeY==sizeZ) )
53         {
54                 for(int i=0; i<sizeX; i++)
55                 {
56                         _InX.push_back( (*InX)[i] );
57                         _InY.push_back( (*InY)[i] );
58                         _InZ.push_back( (*InZ)[i] );
59                 }
60         }
61         else
62         {
63                 printf("\n The lists Of vectors have diferents sizes");
64         }
65 }
66 //-----------------------------------------------------------------------------------------
67 //AUTOMATIC METHOD (INITIAL AND ADDING)
68 void ExtractControlPoints2D::GetInitialControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
69 {
70         AutoControlPoints *autoc = new AutoControlPoints();
71         pOutX->clear();
72         pOutY->clear();
73         pOutZ->clear();
74
75         if(_InX.size() != 0)
76         {
77                 autoc->SetNumSplineInterpolation((int)_numinterspline);
78                 autoc->CalculeInitialControlPoints(&_InX,&_InY,&_InZ);
79                 autoc->GetInitialControlPoints(pOutX,pOutY,pOutZ);
80         }
81         delete autoc;
82 }
83 //-----------------------------------------------------------------------------------------
84 //AUTOMATIC METHOD (INITIAL, ADDING AND SAMPLING)
85 void ExtractControlPoints2D::GetControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
86 {
87         AutoControlPoints *autoc = new AutoControlPoints();
88         pOutX->clear();
89         pOutY->clear();
90         pOutZ->clear();
91
92         if(_InX.size() != 0)
93         {
94                 autoc->SetNumSplineInterpolation((int)_numinterspline);
95                 autoc->CalculeControlPoints(&_InX,&_InY,&_InZ);
96                 autoc->GetControlPoints(pOutX,pOutY,pOutZ);
97         }
98         delete autoc;
99 }
100 //-----------------------------------------------------------------------------------------
101 //SET THE SAMPLING (PERCENT) FOR THE REGULAR SAMPLING METHOD
102 void ExtractControlPoints2D::SetSamplingControlPoints(double val)
103 {
104         if(_InX.size() != 0)
105         {
106                 _numsampling = _InX.size()* (val/100);
107         }
108 }
109 //-----------------------------------------------------------------------------------------
110 //REGULAR SAMPLING METHOD
111 void ExtractControlPoints2D::GetSamplingControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
112 {
113         pOutX->clear();
114         pOutY->clear();
115         pOutZ->clear();
116         if(_InX.size() != 0)
117         {
118                 int h = 1;
119                 //int j=0;  // JPRx
120                 int points = (int)(_InX.size()/_numsampling);
121                 for (int i=0; i<(int)(_InX.size()); i++, h++)
122                 {
123                         if( h == points )
124                         {
125                                 pOutX->push_back( _InX[i] );
126                                 pOutY->push_back( _InY[i] );
127                                 pOutZ->push_back( _InZ[i] );
128                                 h = 0;
129                         }
130                 }
131         }
132 }
133 //-----------------------------------------------------------------------------------------
134 void ExtractControlPoints2D::SetNumberOfSplineInterpolation(double val)
135 {
136         _numinterspline = val;
137 }
138 //------------------------------------------------------------------------------
139  
140