]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelCircle.cpp
f606f98a5c95510e5aff41a21a7078727199f6c9
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourModelCircle.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 "manualContourModelCircle.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31
32 manualContourModelCircle::manualContourModelCircle()
33 : manualContourModel()
34 {
35 }
36
37 manualContourModelCircle::~manualContourModelCircle()
38 {
39 }
40
41
42 // ----------------------------------------------------------------------------
43 manualContourModelCircle * manualContourModelCircle :: Clone()  // virtual
44 {
45         manualContourModelCircle * clone = new manualContourModelCircle();
46         CopyAttributesTo(clone);
47         return clone;
48 }
49
50 // ---------------------------------------------------------------------------
51
52 void manualContourModelCircle::CopyAttributesTo( manualContourModelCircle * cloneObject)
53 {
54         // Fathers object
55         manualContourModel::CopyAttributesTo(cloneObject);
56 }
57
58 //----------------------------------------------------------------
59 int manualContourModelCircle::GetTypeModel() //virtual
60 {
61         return 3;
62 }
63
64 //----------------------------------------------------------------
65 void manualContourModelCircle::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
66 {
67         double angle = _deltaAngle*i;
68         *x = _radio*cos(angle) + _centerX;
69         *y = _radio*sin(angle) + _centerY;
70         *z = _centerZ;
71 }
72
73 //
74 // ---------------------------------------------------------------------------
75 void manualContourModelCircle::UpdateSpline() // virtal
76 {
77         manualPoint     *mpA,*mpB;
78         double difX,difY;
79     int np      = GetSizeLstPoints( );
80         int nps = GetNumberOfPointsSpline();
81         _deltaAngle=(3.14159265*2)/(nps-1);
82
83         if (np==2){
84                 mpA                     = GetManualPoint(0);
85                 mpB                     = GetManualPoint(1);
86                 difX            = mpA->GetX() - mpB->GetX();
87                 difY            = mpA->GetY() - mpB->GetY();
88                 _radio          = sqrt( difX*difX + difY*difY );
89                 _centerX        = mpA->GetX();
90                 _centerY        = mpA->GetY();
91                 _centerZ        = mpA->GetZ();
92         } else {
93                 _radio          = -1;
94                 _centerX        = -1;
95                 _centerY        = -1;
96                 _centerZ        = -1;
97         }
98 }