]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModelBullEyeSector.cpp
Support #1768 CREATIS Licence insertion
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourModelBullEyeSector.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 "manualContourModelBullEyeSector.h"
27
28
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
32
33 manualContourModelBullEyeSector::manualContourModelBullEyeSector()
34 : manualContourModel()
35 {
36 }
37
38 manualContourModelBullEyeSector::~manualContourModelBullEyeSector()
39 {
40 }
41
42
43 // ----------------------------------------------------------------------------
44 manualContourModelBullEyeSector * manualContourModelBullEyeSector :: Clone()  // virtual
45 {
46         manualContourModelBullEyeSector * clone = new manualContourModelBullEyeSector();
47         CopyAttributesTo(clone);
48         return clone;
49 }
50
51 // ---------------------------------------------------------------------------
52
53 void manualContourModelBullEyeSector::CopyAttributesTo( manualContourModelBullEyeSector * cloneObject)
54 {
55         // Fathers object
56         manualContourModel::CopyAttributesTo(cloneObject);
57 }
58
59 //----------------------------------------------------------------
60 int manualContourModelBullEyeSector::GetTypeModel() //virtual
61 {
62         return 5;
63 }
64
65
66 //----------------------------------------------------------------
67 void manualContourModelBullEyeSector::SetSector(        double radioA,
68                                                 double radioB,
69                                                 double ang,
70                                                 double angDelta)
71 {
72         _radioA         = radioA;
73         _radioB         = radioB;
74         _ang            = ang*3.14159265/180.0;
75         _angDelta       = angDelta*3.14159265/180.0;
76 }
77
78 //----------------------------------------------------------------
79 void manualContourModelBullEyeSector::GetSector(
80                                                 double *radioA,
81                                                 double *radioB,
82                                                 double *ang,
83                                                 double *angDelta)
84 {
85         *radioA         = _radioA;
86         *radioB         = _radioB;
87         *ang            = _ang;
88         *angDelta       = _angDelta;
89 }
90
91 // ----------------------------------------------------------------------------
92 void manualContourModelBullEyeSector::SetCenter(double cx,double cy)
93 {
94         _cx = cx;
95         _cy = cy;
96 }
97
98 //----------------------------------------------------------------
99 void manualContourModelBullEyeSector::SetSize(double ww,double hh)
100 {
101         _ww = ww;
102         _hh = hh;
103 }
104
105 //----------------------------------------------------------------
106 void manualContourModelBullEyeSector::GetSpline_i_Point(int i, double *x, double *y, double *z)
107 {
108 //EED004
109
110         int ii,nps;
111 //      double x,y,z;
112         double ang,angcos, angsin;
113         double radio;
114
115         nps     =  GetNumberOfPointsSpline() - 3;
116
117         if (i==GetNumberOfPointsSpline()-1)
118         {
119                 i=0;
120         }
121
122         if (i<=nps/2)
123         {
124                 ii=i;
125                 radio=_radioA;
126         } else {
127                 ii=nps-i+1;
128                 radio=_radioB;
129         }
130         ang = ((double)ii/(nps/2))*_angDelta + _ang;
131         angcos =  cos(ang);
132         angsin =  sin(ang);
133
134         *x = _ww*radio*angcos + _cx;
135         *y = _hh*radio*angsin + _cy;
136         
137 //EED 21 mars 2012  FLIP probleme  ..PLOP..     
138 //      *z= 900;
139         *z= -900;
140 }
141
142 //----------------------------------------------------------------
143 void manualContourModelBullEyeSector::Save(FILE *ff) // virtual
144 {
145         manualContourModel::Save(ff);
146         fprintf(ff,"rA= %f rB= %f ang= %f deltaAng= %f\n", _radioA,_radioB, _ang , _angDelta);
147 }
148
149 //----------------------------------------------------------------
150 void manualContourModelBullEyeSector::Open(FILE *ff) // virtual
151 {
152         char tmp[255];
153         fscanf(ff,"%s",tmp); // TypeModel
154         fscanf(ff,"%s",tmp); // ##
155
156         manualContourModel::Open(ff);
157
158
159         fscanf(ff,"%s",tmp); // radioA=
160         fscanf(ff,"%s",tmp); // radioA
161         _radioA = atof(tmp);
162
163         fscanf(ff,"%s",tmp); // radioB=
164         fscanf(ff,"%s",tmp); // radioB
165         _radioB = atof(tmp);
166
167         fscanf(ff,"%s",tmp); // ang=
168         fscanf(ff,"%s",tmp); // ang
169         _ang = atof(tmp);
170
171         fscanf(ff,"%s",tmp); // deltaAng=
172         fscanf(ff,"%s",tmp); // deltaAng
173         _angDelta = atof(tmp);
174 }
175
176