]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelRotationTool.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourModelRotationTool.cpp
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 "manualContourModelRotationTool.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31
32 manualContourModelRotationTool::manualContourModelRotationTool()
33 {
34 }
35
36 //----------------------------------------------------------------
37
38 manualContourModelRotationTool::~manualContourModelRotationTool()
39 {
40 }
41
42
43 // ----------------------------------------------------------------------------
44 manualContourModelRotationTool * manualContourModelRotationTool :: Clone()  // virtual
45 {
46         manualContourModelRotationTool * clone = new manualContourModelRotationTool();
47         CopyAttributesTo(clone);
48         return clone;
49 }
50
51 // ---------------------------------------------------------------------------
52 void manualContourModelRotationTool::CopyAttributesTo( manualContourModelRotationTool * cloneObject)
53 {
54         // Fathers object
55         manualContourModelRotationTool::CopyAttributesTo(cloneObject);
56 }
57
58 //----------------------------------------------------------------
59 int manualContourModelRotationTool::GetTypeModel() //virtual
60 {
61         return 8;
62 }
63
64 //----------------------------------------------------------------
65 void manualContourModelRotationTool::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
66 {
67         int nps = GetNumberOfPointsSpline();
68         //Spline points of the circle
69         if(i<nps-2)
70         {
71                 double angle = _deltaAngle*i;
72                 *x = _radio*cos(angle) + _centerX;
73                 *y = _radio*sin(angle) + _centerY;
74                 *z = _centerZ;
75         }
76         //Spline points of the reference line
77         if(i==nps-2)
78         {
79                 *x = _centerX;
80                 *y = _centerY;
81                 *z = _centerZ;
82         }
83         //Spline points of the movable line
84         if(i==nps-1)
85         {
86                 manualPoint *mpA= GetManualPoint(2);
87                 *x = mpA->GetX();
88                 *y = mpA->GetY();
89                 *z = _centerZ;
90         }
91         
92 }
93
94 // ---------------------------------------------------------------------------
95 void manualContourModelRotationTool:: UpdateSpline()
96 {       
97         manualPoint     *mpA,*mpB,*mpC;
98         double difX,difY;
99         double x, y; 
100     int np      = GetSizeLstPoints( );
101         int nps = GetNumberOfPointsSpline();
102         _deltaAngle=(3.14159265*2)/(nps-1-2);
103
104         if (np==3)
105         {
106                 mpA                     = GetManualPoint(0);
107                 mpB                     = GetManualPoint(1);
108                 mpC                     = GetManualPoint(2);
109                 difX            = mpA->GetX() - mpB->GetX();
110                 difY            = mpA->GetY() - mpB->GetY();
111                 _radio          = sqrt( difX*difX + difY*difY );
112                 _centerX        = mpA->GetX();
113                 _centerY        = mpA->GetY();
114                 _centerZ        = mpA->GetZ();
115
116                 x= mpC->GetX() - mpA->GetX();
117                 y= mpC->GetY() - mpA->GetY();
118                 _angle= atan(y/x)*180/(3.14159265);
119                 cout << "Scale" <<_radio <<endl;
120                 cout << "Angle" <<_angle <<endl;
121                 cout<< "Center"<<_centerX<<","<<_centerY<<endl;
122         } 
123         else 
124         {
125                 _radio          = -1;
126                 _centerX        = -1;
127                 _centerY        = -1;
128                 _centerZ        = -1;
129                 _angle          = -1;
130         }
131 }
132
133 //----------------------------------------------------------------
134 double manualContourModelRotationTool::getRadio()
135 {
136         return _radio;
137 }
138
139 //----------------------------------------------------------------
140 double manualContourModelRotationTool::getAngle()
141 {
142         return _angle;
143 }
144
145
146 std::vector<double> manualContourModelRotationTool::getCenter()
147 {
148         manualPoint *mpCenter   = GetManualPoint(0);
149         std::vector<double> centro(2,0);
150         centro[0]=mpCenter->GetX();
151         centro[1]=mpCenter->GetY();
152         return centro;
153
154 }