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 "manualContourModelBullEye.h"
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31 // ----------------------------------------------------------------------------
33 manualContourModelBullEye::manualContourModelBullEye()
34 : manualContourModel()
36 _numberPointsSlineBySector=101; // impaire
39 manualContourModelBullEye::~manualContourModelBullEye()
44 // ----------------------------------------------------------------------------
45 manualContourModelBullEye * manualContourModelBullEye :: Clone() // virtual
47 manualContourModelBullEye * clone = new manualContourModelBullEye();
48 CopyAttributesTo(clone);
52 // ---------------------------------------------------------------------------
54 void manualContourModelBullEye::CopyAttributesTo( manualContourModelBullEye * cloneObject)
57 manualContourModel::CopyAttributesTo(cloneObject);
60 //----------------------------------------------------------------
61 int manualContourModelBullEye::GetTypeModel() //virtual
66 //----------------------------------------------------------------
67 int manualContourModelBullEye::GetNumberOfPointsSplineSectorBulleEje()
69 return _numberPointsSlineBySector;
72 //----------------------------------------------------------------
73 void manualContourModelBullEye::SetNumberOfPointsSplineSectorBulleEje(int numpoints)
75 this->_numberPointsSlineBySector = numpoints;
78 //----------------------------------------------------------------
79 void manualContourModelBullEye::AddSector( double radioA,
84 manualContourModelBullEyeSector *modelSector = new manualContourModelBullEyeSector();
85 modelSector->SetSector(radioA,radioB,ang,angDelta);
86 modelSector->SetNumberOfPointsSpline( this->GetNumberOfPointsSplineSectorBulleEje() );
87 _lstModelBullEyeSector.push_back(modelSector);
90 //----------------------------------------------------------------
91 manualContourModelBullEyeSector * manualContourModelBullEye::GetModelSector(int id)
93 return _lstModelBullEyeSector[id];
96 //----------------------------------------------------------------
97 void manualContourModelBullEye::GetSector(int id,
103 _lstModelBullEyeSector[id]->GetSector(radioA,radioB,ang,angDelta);
106 void manualContourModelBullEye::UpdateSpline() // virtual
108 manualContourModel::UpdateSpline();
110 if (this->GetSizeLstPoints()>2){
113 manualPoint *mpA = GetManualPoint(0);
114 manualPoint *mpB = GetManualPoint(2);
115 cx = (mpA->GetX() + mpB->GetX()) / 2.0;
116 cy = (mpA->GetY() + mpB->GetY()) / 2.0;
117 ww = fabs( mpA->GetX() - mpB->GetX() )/2.0;
118 hh = fabs( mpA->GetY() - mpB->GetY() )/2.0;
119 int i,size = _lstModelBullEyeSector.size();
122 _lstModelBullEyeSector[i]->SetCenter(cx,cy);
123 _lstModelBullEyeSector[i]->SetSize(ww,hh);
129 //----------------------------------------------------------------
130 void manualContourModelBullEye::ResetSectors()
132 int i,size=_lstModelBullEyeSector.size();
135 delete _lstModelBullEyeSector[i];
137 _lstModelBullEyeSector.clear();
140 //----------------------------------------------------------------
141 int manualContourModelBullEye::GetSizeOfSectorLst()
143 return _lstModelBullEyeSector.size();
146 //----------------------------------------------------------------
147 void manualContourModelBullEye::Save(FILE *ff) // virtual
149 manualContourModel::Save(ff);
150 int i,size = GetSizeOfSectorLst();
151 fprintf(ff,"numberOfSections %d \n",size);
152 for ( i=0 ; i<size ; i++ )
154 _lstModelBullEyeSector[i]->Save(ff);
158 //----------------------------------------------------------------
159 void manualContourModelBullEye::Open(FILE *ff) // virtual
161 manualContourModel::Open(ff);
167 int numberOfSections;
168 // double radioA,radioB,ang,deltaAng;
170 fscanf(ff,"%s",tmp); // NumberOfSections
171 fscanf(ff,"%s",tmp); // ##
172 numberOfSections = atoi(tmp);
173 for (i=0;i<numberOfSections;i++)
176 _lstModelBullEyeSector[i]->Open(ff);
181 // ----------------------------------------------------------------------------
182 std::vector<manualBaseModel*> manualContourModelBullEye::ExploseModel( )
185 std::vector<manualBaseModel*> lstTmp;
186 int i,iSize=_lstModelBullEyeSector.size();
187 for (i=0;i<iSize;i++)
189 lstTmp.push_back( _lstModelBullEyeSector[i] );