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 "manualContourModelRotationTool.h"
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
32 manualContourModelRotationTool::manualContourModelRotationTool()
36 //----------------------------------------------------------------
38 manualContourModelRotationTool::~manualContourModelRotationTool()
43 // ----------------------------------------------------------------------------
44 manualContourModelRotationTool * manualContourModelRotationTool :: Clone() // virtual
46 manualContourModelRotationTool * clone = new manualContourModelRotationTool();
47 CopyAttributesTo(clone);
51 // ---------------------------------------------------------------------------
52 void manualContourModelRotationTool::CopyAttributesTo( manualContourModelRotationTool * cloneObject)
55 manualContourModelRotationTool::CopyAttributesTo(cloneObject);
58 //----------------------------------------------------------------
59 int manualContourModelRotationTool::GetTypeModel() //virtual
64 //----------------------------------------------------------------
65 void manualContourModelRotationTool::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
67 int nps = GetNumberOfPointsSpline();
68 //Spline points of the circle
71 double angle = _deltaAngle*i;
72 *x = _radio*cos(angle) + _centerX;
73 *y = _radio*sin(angle) + _centerY;
76 //Spline points of the reference line
83 //Spline points of the movable line
86 manualPoint *mpA= GetManualPoint(2);
94 // ---------------------------------------------------------------------------
95 void manualContourModelRotationTool:: UpdateSpline()
97 manualPoint *mpA,*mpB,*mpC;
100 int np = GetSizeLstPoints( );
101 int nps = GetNumberOfPointsSpline();
102 _deltaAngle=(3.14159265*2)/(nps-1-2);
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();
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;
133 //----------------------------------------------------------------
134 double manualContourModelRotationTool::getRadio()
139 //----------------------------------------------------------------
140 double manualContourModelRotationTool::getAngle()
146 std::vector<double> manualContourModelRotationTool::getCenter()
148 manualPoint *mpCenter = GetManualPoint(0);
149 std::vector<double> centro(2,0);
150 centro[0]=mpCenter->GetX();
151 centro[1]=mpCenter->GetY();