]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/Contour/ExtractControlPoints2D.cxx
creaMaracasVisu Library
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / Contour / ExtractControlPoints2D.cxx
1 #include "ExtractControlPoints2D.h"
2
3 //Construction
4 ExtractControlPoints2D::ExtractControlPoints2D()
5 {
6         _numinterspline = 100;
7         _numsampling = 25;
8 }
9 //Destruction
10 ExtractControlPoints2D::~ExtractControlPoints2D()
11 {
12 }
13 //-----------------------------------------------------------------------------------------
14 void ExtractControlPoints2D::ResetControlPoints()
15 {
16
17 }
18 //-----------------------------------------------------------------------------------------
19 void ExtractControlPoints2D::SetContour(std::vector<double>*InX, std::vector<double>*InY,std::vector<double>*InZ)
20 {
21         _InX.clear();
22         _InY.clear();
23         _InZ.clear();
24         int sizeX = InX->size();
25         int sizeY = InY->size();
26         int sizeZ = InZ->size();
27         if( (sizeX == sizeY) && (sizeY==sizeZ) )
28         {
29                 for(int i=0; i<sizeX; i++)
30                 {
31                         _InX.push_back( (*InX)[i] );
32                         _InY.push_back( (*InY)[i] );
33                         _InZ.push_back( (*InZ)[i] );
34                 }
35         }
36         else
37         {
38                 printf("\n The lists Of vectors have diferents sizes");
39         }
40 }
41 //-----------------------------------------------------------------------------------------
42 //AUTOMATIC METHOD (INITIAL AND ADDING)
43 void ExtractControlPoints2D::GetInitialControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
44 {
45         AutoControlPoints *autoc = new AutoControlPoints();
46         pOutX->clear();
47         pOutY->clear();
48         pOutZ->clear();
49
50         if(_InX.size() != 0)
51         {
52                 autoc->SetNumSplineInterpolation(_numinterspline);
53                 autoc->CalculeInitialControlPoints(&_InX,&_InY,&_InZ);
54                 autoc->GetInitialControlPoints(pOutX,pOutY,pOutZ);
55         }
56         delete autoc;
57 }
58 //-----------------------------------------------------------------------------------------
59 //AUTOMATIC METHOD (INITIAL, ADDING AND SAMPLING)
60 void ExtractControlPoints2D::GetControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
61 {
62         AutoControlPoints *autoc = new AutoControlPoints();
63         pOutX->clear();
64         pOutY->clear();
65         pOutZ->clear();
66
67         if(_InX.size() != 0)
68         {
69                 autoc->SetNumSplineInterpolation(_numinterspline);
70                 autoc->CalculeControlPoints(&_InX,&_InY,&_InZ);
71                 autoc->GetControlPoints(pOutX,pOutY,pOutZ);
72         }
73         delete autoc;
74 }
75 //-----------------------------------------------------------------------------------------
76 //SET THE SAMPLING (PERCENT) FOR THE REGULAR SAMPLING METHOD
77 void ExtractControlPoints2D::SetSamplingControlPoints(double val)
78 {
79         if(_InX.size() != 0)
80         {
81                 _numsampling = _InX.size()* (val/100);
82         }
83 }
84 //-----------------------------------------------------------------------------------------
85 //REGULAR SAMPLING METHOD
86 void ExtractControlPoints2D::GetSamplingControlPoints(std::vector<double>*pOutX, std::vector<double>*pOutY, std::vector<double>*pOutZ)
87 {
88         pOutX->clear();
89         pOutY->clear();
90         pOutZ->clear();
91         if(_InX.size() != 0)
92         {
93                 int h = 1;
94                 int j=0;
95                 int points = (int)(_InX.size()/_numsampling);
96                 for (int i=0; i<_InX.size(); i++, h++)
97                 {
98                         if( h == points )
99                         {
100                                 pOutX->push_back( _InX[i] );
101                                 pOutY->push_back( _InY[i] );
102                                 pOutZ->push_back( _InZ[i] );
103                                 h = 0;
104                         }
105                 }
106         }
107 }
108 //-----------------------------------------------------------------------------------------
109 void ExtractControlPoints2D::SetNumberOfSplineInterpolation(double val)
110 {
111         _numinterspline = val;
112 }
113 //-----------------------------------------------------------------------------------------