]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp
#2989 creaMaracasVisu Bug New Normal - ManualContourModel duplicate last point...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / manualContour / manualContourModel.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 "manualContourModel.h"
27
28 // ----------------------------------------------------------------------------
29 // ----------------------------------------------------------------------------
30 // ----------------------------------------------------------------------------
31
32 manualContourModel::manualContourModel()
33 {
34     _cntSplineX = vtkKochanekSpline::New( );
35     _cntSplineY = vtkKochanekSpline::New( );
36     _cntSplineZ = vtkKochanekSpline::New( );
37
38         this->SetCloseContour(true);
39
40     _cntSplineX->SetDefaultTension( 0 );
41         _cntSplineX->SetDefaultBias( 0 );
42         _cntSplineX->SetDefaultContinuity( 0 );
43
44     _cntSplineY->SetDefaultTension( 0 );
45         _cntSplineY->SetDefaultBias( 0 );
46         _cntSplineY->SetDefaultContinuity( 0 );
47
48     _cntSplineZ->SetDefaultTension( 0 );
49         _cntSplineZ->SetDefaultBias( 0 );
50         _cntSplineZ->SetDefaultContinuity( 0 );
51
52 //JSTG 25-02-08 -------------------------------------------------------------------------------------------------
53
54         // this parameter is reset in the  VIRTUAL manualContourBaseControler::Configure
55         _sizePointsContour      = 100;                  //JSTG 25-02-08 The change in the inisialization of these variable is critical.
56
57         _delta_JSTG                     = 0.0;
58 //---------------------------------------------------------------------------------------------------------------
59
60 //CMRU 17-08-09 -------------------------------------------------------------------------------------------------
61         _realSize                       = 0.0;
62         _label                          = "";
63 //---------------------------------------------------------------------------------------------------------------
64
65 }
66
67 // ----------------------------------------------------------------------------
68 manualContourModel::~manualContourModel()
69 {
70         int i,size=_lstPoints.size();
71         for (i=0;i<size; i++){
72                 delete _lstPoints[i];
73         }
74         _lstPoints.clear();
75
76         _cntSplineX->RemoveAllPoints();
77         _cntSplineY->RemoveAllPoints();
78         _cntSplineZ->RemoveAllPoints();
79
80         _cntSplineX->Delete();
81         _cntSplineY->Delete();
82         _cntSplineZ->Delete();
83 }
84 // ----------------------------------------------------------------------------
85 int manualContourModel::AddPoint(double x,double y,double z)
86 {
87    manualPoint *mp = new manualPoint();
88    mp->SetPoint(x,y,z);
89    AddManualPoint(mp);
90    //UpdateSpline();
91
92    return _lstPoints.size()-1;
93 }
94 // ----------------------------------------------------------------------------
95 int manualContourModel::InsertPoint(double x,double y,double z)
96 {
97         double dd,ddmin=9999999;
98         int    ibak=0;
99         double xx,x1,x2;
100         double yy,y1,y2;
101         double zz,z1,z2;
102         int i,ii,iii,size=_lstPoints.size();
103         double j,MaxDivisions=20,porcentage;
104         int sizeB=size;
105
106         if (_closeContour==false)
107         {
108                 size=size-1;
109         }
110
111         double jbak;
112
113         for ( i=0 ; i<size ; i++ )
114         {
115                 ii=i % sizeB ;
116                 iii=(i+1) % sizeB;
117                 x1=_lstPoints[ii]->GetX();
118                 y1=_lstPoints[ii]->GetY();
119                 z1=_lstPoints[ii]->GetZ();
120                 x2=_lstPoints[iii]->GetX();
121                 y2=_lstPoints[iii]->GetY();
122                 z2=_lstPoints[iii]->GetZ();
123                 for (j=0; j<=MaxDivisions; j++)
124                 {
125                         porcentage=(j/MaxDivisions);
126                         xx=(x2-x1)*porcentage+x1;
127                         yy=(y2-y1)*porcentage+y1;
128                         zz=(z2-z1)*porcentage+z1;
129                         dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
130                         if ( dd<ddmin )
131                         {
132                                 ddmin=dd;
133                                 ibak=iii;
134                                 jbak=j;
135                         }
136                 }
137         }
138
139         if (_closeContour==false)
140         {
141                 if ( (ibak==1) && (jbak==0) )
142                 {
143                         ibak=0;
144                 }
145                 if ( ( ibak==size ) && ( jbak==MaxDivisions ) )
146                 {
147                         ibak=sizeB;
148                 }
149         }
150
151
152 //JSTG - 25-04-08 ----------------------------------------------------------
153         //manualPoint *mp = new manualPoint();
154         //mp->SetPoint(x,y,z);
155         //std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + ibak;
156         //_lstPoints.insert(itNum,mp);
157         InsertPoint_id(ibak,x,y,z);
158 //----------------------------------------------------------------------------
159
160         return ibak;
161 }
162 // ----------------------------------------------------------------------------
163 void manualContourModel::InsertPoint_id(int id, double x, double y, double z)
164 {
165         manualPoint *mp = new manualPoint();
166         mp->SetPoint(x,y,z);
167         std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + id;
168         _lstPoints.insert(itNum,mp);
169 }
170 // ----------------------------------------------------------------------------
171
172 void manualContourModel::DeletePoint(int i)
173 {
174         std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + i;
175    _lstPoints.erase(itNum);
176 }
177 // ----------------------------------------------------------------------------
178 void manualContourModel::DeleteAllPoints()
179 {
180         int i,size=_lstPoints.size();
181         for (i=0;i<size;i++){
182            _lstPoints.erase( _lstPoints.begin() );
183         }
184         this->UpdateSpline();
185 }
186 // ----------------------------------------------------------------------------
187
188 void manualContourModel::MovePoint(int i,double dx,double dy,double dz)
189 {
190         manualPoint *mp=_lstPoints[i];
191         double x=mp->GetX()+dx;
192         double y=mp->GetY()+dy;
193         double z=mp->GetZ()+dz;
194         mp->SetPoint(x,y,z);
195 }
196 // ----------------------------------------------------------------------------
197 void manualContourModel::MoveLstPoints(double dx,double dy,double dz)
198 {
199         // ToDo
200 }
201 // ----------------------------------------------------------------------------
202 void manualContourModel::MoveAllPoints(double dx,double dy,double dz)
203 {
204         int i,size=_lstPoints.size();
205         for (i=0;i<size;i++){
206                 MovePoint(i,dx,dy,dz);
207         }
208 }
209
210
211 // ----------------------------------------------------------------------------
212
213 // type=-1  x,y,z
214 // type=0       x,y
215 // type=1       y,z
216 // type=2       x,z
217 int      manualContourModel::GetIdPoint(double x, double y, double z, int i_range,int type)
218 {
219         double range = i_range+1;
220
221         double xx,yy,zz,dd,ddmin=9999999;
222         int ibak=-1;
223         int i,size=_lstPoints.size();
224         for (i=0;i<size;i++){
225                 manualPoint *mp=_lstPoints[i];
226                 xx=mp->GetX();
227                 yy=mp->GetY();
228                 zz=mp->GetZ();
229
230                 if (type==-1)
231                 {
232                         if ((fabs(xx-x)<range) && (fabs(yy-y)<range) && (fabs(zz-z)<range)) {
233                            dd=sqrt(   (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
234                            if (dd<ddmin){
235                                    ddmin=dd;
236                                    ibak=i;
237                            }
238                         }
239                 }
240                 if (type==0)
241                 {
242                         if ((fabs(yy-y)<range) && (fabs(zz-z)<range)) {
243                            dd=sqrt(   (yy-y)*(yy-y) + (zz-z)*(zz-z) );
244                            if (dd<ddmin){
245                                    ddmin=dd;
246                                    ibak=i;
247                            }
248                         }
249                 }
250                 if (type==1)
251                 {
252                         if ((fabs(xx-x)<range) && (fabs(zz-z)<range)) {
253                            dd=sqrt(   (xx-x)*(xx-x)  + (zz-z)*(zz-z) );
254                            if (dd<ddmin){
255                                    ddmin=dd;
256                                    ibak=i;
257                            }
258                         }
259                 }
260                 if (type==2)
261                 {
262                         if ((fabs(xx-x)<range) && (fabs(yy-y)<range) ) {
263                            dd=sqrt(   (xx-x)*(xx-x) + (yy-y)*(yy-y)  );
264                            if (dd<ddmin){
265                                    ddmin=dd;
266                                    ibak=i;
267                            }
268                         }
269                 }
270         }
271         return ibak;
272 }
273 // ----------------------------------------------------------------------------
274 manualPoint* manualContourModel::GetManualPoint(int id)
275 {
276         return _lstPoints[id];
277 }
278 // ----------------------------------------------------------------------------
279 int manualContourModel::GetSizeLstPoints()
280 {
281         return _lstPoints.size();
282 }
283 //----------------------------------------------------------------------------
284 int manualContourModel::GetNumberOfPointsSpline()
285 {
286         return _sizePointsContour;
287 }
288 //----------------------------------------------------------------------------
289 void manualContourModel::SetNumberOfPointsSpline(int size)
290 {
291         _sizePointsContour = size;
292 }
293
294 // ----------------------------------------------------------------------------
295
296 void manualContourModel::SetCloseContour(bool closeContour)
297 {
298         _closeContour = closeContour;
299         if (_closeContour==true)
300         {
301                 _cntSplineX->ClosedOn();
302                 _cntSplineY->ClosedOn();
303                 _cntSplineZ->ClosedOn();
304         } else {
305                 _cntSplineX->ClosedOff();
306                 _cntSplineY->ClosedOff();
307                 _cntSplineZ->ClosedOff();
308         }
309 }
310
311 // ----------------------------------------------------------------------------
312 bool manualContourModel::IfCloseContour()
313 {
314         return _closeContour;
315 }
316
317 // ----------------------------------------------------------------------------
318
319 void manualContourModel::UpdateSpline() // virtual
320 {
321         int i, np;
322     np  = _lstPoints.size();
323         manualPoint     *mp;
324         _cntSplineX->RemoveAllPoints();
325         _cntSplineY->RemoveAllPoints();
326         _cntSplineZ->RemoveAllPoints();
327     for( i = 0; i < np; i++ ) {
328                 mp = GetManualPoint(i);
329         _cntSplineX->AddPoint( i, mp->GetX() );
330         _cntSplineY->AddPoint( i, mp->GetY() );
331         _cntSplineZ->AddPoint( i, mp->GetZ() );
332     } //  rof
333
334 //JSTG 25-02-08 ---------------------------------------------------------------------------------------------
335         if (this->_closeContour==true)
336         {
337                 _delta_JSTG = (double) (np) / double (_sizePointsContour - 1);  //Without the -1 the curve is not close
338         } else {
339 //              _delta_JSTG = (double) (np-1) / double (_sizePointsContour );  //Without the -1 the curve is not close
340 //EED 9/7/2016          _delta_JSTG = (double) (np) / double (_sizePointsContour-1 );  //Without the -1 the curve is not close
341                 _delta_JSTG = (double) (np-1) / double (_sizePointsContour-1 );  //Without the -1 the curve is not close
342         }
343 //-----------------------------------------------------------------------------------------------------------
344 }
345
346 //---------------------------------------------------------------------------------
347
348 /*void manualContourModel::GetSplineiPoint(int i, double &x, double &y, double &z)
349 {
350         double delta=(double)(_lstPoints.size()) / (double)(_sizePointsContour);
351         double t = delta*(double)i;
352         GetSplinePoint(t, x, y, z);
353 }*/
354
355 //-----------------------------------------------------------------------------
356
357 //JSTG 25-02-08 ---------------------------------------------------------------
358 void manualContourModel::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
359 {
360         GetSpline_t_Point(i*_delta_JSTG,x,y,z);
361
362
363 // ----------------------------------------------------------------------------
364
365 //JSTG 25-02-08 ---------------------------------------------------------------
366 void manualContourModel::GetSpline_t_Point(double t, double *x, double *y, double *z)
367 {
368         if (_lstPoints.size()==0)
369         {
370                 *x      = 0;
371                 *y      = 0;
372                 *z      = 0;
373         }
374         if (_lstPoints.size()==1)
375         {
376                 manualPoint     *mp;
377                 mp      = GetManualPoint(0);
378                 *x      = mp->GetX();
379                 *y      = mp->GetY();
380                 *z      = mp->GetZ();
381         }
382         if (_lstPoints.size()>=2)
383         {
384                 *x      = _cntSplineX->Evaluate(t);
385                 *y      = _cntSplineY->Evaluate(t);
386                 *z      = _cntSplineZ->Evaluate(t);
387         }
388 }
389
390 // ----------------------------------------------------------------------------
391
392
393 /*void manualContourModel::GetSplinePoint(double t, double &x, double &y, double &z)
394 {
395         if (_lstPoints.size()==0)
396         {
397                 x       = 0;
398                 y       = 0;
399                 z       = 0;
400         }
401         if (_lstPoints.size()==1)
402         {
403                 manualPoint     *mp;
404                 mp      = GetManualPoint(0);
405                 x       = mp->GetX();
406                 y       = mp->GetY();
407                 z       = mp->GetZ();
408         }
409         if (_lstPoints.size()>=2)
410         {
411                 x       = _cntSplineX->Evaluate(t);
412                 y       = _cntSplineY->Evaluate(t);
413                 z       = _cntSplineZ->Evaluate(t);
414         }
415 }*/
416 // ----------------------------------------------------------------------------
417 double manualContourModel::GetPathSize()
418 {
419         double result = 0;
420         double x1,y1,z1;
421         double x2,y2,z2;
422
423 // JSTG 25-02-08 -----------------------------
424         //double t,delta;
425         //int i,np,nps;
426         int i;
427 //--------------------------------------------
428
429         if (_lstPoints.size()==2)
430         {
431                 x1=_lstPoints[0]->GetX();
432                 y1=_lstPoints[0]->GetY();
433                 z1=_lstPoints[0]->GetZ();
434                 x2=_lstPoints[1]->GetX();
435                 y2=_lstPoints[1]->GetY();
436                 z2=_lstPoints[1]->GetZ();
437                 result = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1) );
438         }
439         if (_lstPoints.size()>2)
440         {
441
442 // JSTG 25-02-08 ------------------------------------------
443                 //np  = _lstPoints.size( );
444                 //nps = 200;
445                 //delta=( double ) ( np  ) / ( double ) ( nps  );
446                 UpdateSpline();
447                 //GetSplinePoint(0,x1,y1,z1);
448                 GetSpline_i_Point(0,&x1,&y1,&z1);
449
450                 //for( i = 1; i < nps; i++ )
451                 for( i = 1; i < GetNumberOfPointsSpline(); i++ )
452                 {
453                         //t = delta * (double)i;
454                         //GetSplinePoint(t,x2,y2,z2);
455                         GetSpline_i_Point(i,&x2,&y2,&z2);
456 //---------------------------------------------------------
457                         result=result + sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1) );
458                         x1=x2;
459                         y1=y2;
460                         z1=z2;
461                 }// for
462         }
463
464         return result;
465 }
466 // ----------------------------------------------------------------------------
467 double manualContourModel::GetPathArea()
468 {
469         double result = 555;
470         if ((_lstPoints.size()>=3) && IfCloseContour()==true )
471         {
472                 double area;
473 //JSTG 25-02-08 ---------------------------------------------
474                 //double ti,tj;
475 //-----------------------------------------------------------
476                 double x1,y1,z1;
477                 double x2,y2,z2;
478                 bool okArea=true;
479                 int i, j;
480
481                 // This uses Green's theorem:
482                 // A = 1/2 * sum( xiyi+1 - xi+1yi); pO == pN
483                 // A < 0 -> A = |A| (a negative value could raise because points are
484                 // given in clockwise order).
485
486 //JSTG 25-02-08 -------------------------------------------------
487                 //int np  = _lstPoints.size( );
488                 //int nps = 200;
489                 int nps = GetNumberOfPointsSpline();
490                 //double delta=( double ) ( np  ) / ( double ) ( nps  );
491                 UpdateSpline();
492                 for( i = 0, area = 0.0; i < nps; i++ )
493                 {
494                         j = ( i + 1 ) % nps;
495                         //ti = delta * (double)i;
496                         //tj = delta * (double)j;
497                         //GetSplinePoint(ti,x1,y1,z1);
498                         //GetSplinePoint(tj,x2,y2,z2);
499                         GetSpline_i_Point(i,&x1,&y1,&z1);
500                         GetSpline_i_Point(j,&x2,&y2,&z2);
501 //----------------------------------------------------------------
502                         area +=
503                                         (x1 * y2 ) -
504                                         ( x2 * y1 );
505                         if (z1!=z2)
506                         {
507                                 okArea=false;
508                         }
509                 }// for
510                 area /= 2.0;
511                 area = fabs( area );
512
513 /*
514                 for( i = 0, area = 0.0; i < _lstPoints.size(); i++ )
515                 {
516                         j = ( i + 1 ) % _lstPoints.size();
517                         //  Area
518                         area +=
519                                         (_lstPoints[i]->GetX() * _lstPoints[j]->GetY() ) -
520                                         ( _lstPoints[j]->GetX() * _lstPoints[i]->GetY() );
521                         if (_lstPoints[0]->GetZ()!=_lstPoints[i]->GetZ())
522                         {
523                                 okArea=false;
524                         }
525                 } // rof
526                 area /= 2.0;
527                 area = fabs( area );
528 */
529
530                 if (okArea==true)
531                 {
532                         result = area;
533                 } else {
534                         result = -1;
535                 }
536
537         } else {
538                 result = 0;
539         }
540         return result;
541 }
542
543 // ----------------------------------------------------------------------------
544 // p[x,y,z]   :  data in
545 // rp[x,y,z]  :  data out  result point
546 // rn[x,y,z]  :  data out   result normal
547
548 void manualContourModel::GetNearestPointAndNormal(double *p, double *rp,  double *rn)
549 {
550         double  distMin=999999999;
551         double  dist,dx,dy,dz;
552         double  x1,y1,z1;
553         double  x2,y2,z2;
554         int             i,np,nps;
555
556 //JSTG 25-02-08 -------------------
557         //double  tback;
558         int iback;
559         //double        t,delta;
560 //---------------------------------
561
562         np      = _lstPoints.size( );
563         if (np>=2)
564         {
565 // JSTG 25-02-08 ------------------------------------------
566                 //nps           = 200;
567                 nps = GetNumberOfPointsSpline();
568                 //delta = ( double ) ( np  ) / ( double ) ( nps  );
569                 UpdateSpline();
570                 //GetSplinePoint(0,x1,y1,z1);
571                 GetSpline_i_Point(0,&x1,&y1,&z1);
572                 for( i = 0; i < nps; i++ )
573                 {
574                         //t = delta * (double)i;
575                         //GetSplinePoint(t,x1,y1,z1);
576                         GetSpline_i_Point(i,&x1,&y1,&z1);
577 //----------------------------------------------------------
578                         dx= x1-p[0];
579                         dy= y1-p[1];
580                         dz= z1-p[2];
581                         dist = sqrt( dx*dx + dy*dy + dz*dz );
582                         if (dist<distMin)
583                         {
584                                 distMin  = dist;
585 //JSTG                  tback = t;
586                                 iback = i;
587                                 rp[0] = x1;
588                                 rp[1] = y1;
589                                 rp[2] = z1;
590                                 rn[0] = x2-x1;
591                                 rn[1] = y2-y1;
592                                 rn[2] = z2-z1;
593                         }
594                         x2=x1;
595                         y2=y1;
596                         z2=z1;
597                 }// for
598
599 // JSTG 25-02-08 ------------------------------------------
600                 //if (tback==0)
601                 if (iback==0)
602                 {
603                         //t = delta * (double)1.0;
604                         //GetSplinePoint(t,x1,y1,z1);
605                         GetSpline_i_Point(i,&x1,&y1,&z1);
606 //----------------------------------------------------------
607                         rn[0]=rp[0]-x1;
608                         rn[1]=rp[1]-y1;
609                         rn[2]=rp[2]-z1;
610                 }
611         }
612         else
613         {
614                 rp[0] = 0;
615                 rp[1] = 0;
616                 rp[2] = 0;
617                 rn[0] = -1;
618                 rn[1] = 0;
619                 rn[2] = 0;
620         }
621 }
622
623 // ----------------------------------------------------------------------------
624 manualContourModel * manualContourModel :: Clone() // virtual
625 {
626         manualContourModel * clone = new manualContourModel();
627         CopyAttributesTo(clone);
628         return clone;
629 }
630
631 // ----------------------------------------------------------------------------
632 void manualContourModel::Open(FILE *ff) // virtual
633 {
634         char tmp[255];
635         int i;
636         int numberOfControlPoints;
637         double x,y,z;
638
639         fscanf(ff,"%s",tmp); // NumberOfControlPoints
640         fscanf(ff,"%s",tmp); // ##
641         numberOfControlPoints = atoi(tmp);
642         for (i=0;i<numberOfControlPoints;i++)
643         {
644                 fscanf(ff,"%s",tmp); // X
645                 x = atof(tmp);
646                 fscanf(ff,"%s",tmp); // Y
647                 y = atof(tmp);
648                 fscanf(ff,"%s",tmp); // Z
649                 z = atof(tmp);
650                 AddPoint(x,y,z);
651         }
652 }
653
654 // ----------------------------------------------------------------------------
655 int manualContourModel::GetTypeModel() //virtual
656 {
657         // 0 spline
658         // 1 spline
659         // 2 rectangle
660         // 3 circle
661         // 4 BullEye
662         // 5 BullEyeSector
663         // 6 Line
664         return 1;
665 }
666
667 // ----------------------------------------------------------------------------
668 void manualContourModel::Save(FILE *ff) // virtual
669 {
670         int i,size=_lstPoints.size();
671         fprintf(ff,"TypeModel %d\n", GetTypeModel() );
672         fprintf(ff,"NumberOfControlPoints %d\n",size);
673         for (i=0;i<size;i++)
674         {
675                 manualPoint *mp=_lstPoints[i];
676                 fprintf(ff,"%f %f %f\n", mp->GetX(), mp->GetY(), mp->GetZ() );
677         }
678 }
679 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
680 void manualContourModel::SaveData(FILE *ff)
681 {
682         std::string etiqueta = GetLabel();
683         if(etiqueta.empty())
684                 fprintf(ff,"Label: NO_LABEL\n");
685         else
686                 fprintf(ff,"Label: %s\n",etiqueta.c_str());
687         fprintf(ff,"Real_Size: %f\n",GetRealSize());
688 }
689
690 void manualContourModel::OpenData(FILE *ff)
691 {
692         char tmp[255];
693
694         fscanf(ff,"%s",tmp); // Label:
695         fscanf(ff,"%s",tmp); // value
696         std::cout<<tmp<<std::endl;
697         //if(strcmp(tmp != "NO_LABEL") // JPR
698         if(strcmp(tmp,"NO_LABEL") != 0)
699                 SetLabel(tmp);
700
701         fscanf(ff,"%s",tmp); // Real_size
702         fscanf(ff,"%s",tmp);// #
703
704         //tmp.ToDouble(&tmp);
705         SetRealSize(atof(tmp));
706 }
707
708 //------------------------------------------------------------------------------------------------------------
709
710 // ---------------------------------------------------------------------------
711
712 void manualContourModel::CopyAttributesTo( manualContourModel * cloneObject)
713 {
714         // Fathers object
715         //XXXX::CopyAttributesTo(cloneObject);
716
717         cloneObject->SetCloseContour( this->IfCloseContour() );
718         int i, size = GetSizeLstPoints();
719         for( i=0; i<size; i++ )
720         {
721                 cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
722         }
723         cloneObject->SetNumberOfPointsSpline( GetNumberOfPointsSpline () );
724         cloneObject->SetCloseContour( _closeContour );
725         cloneObject->UpdateSpline();
726 }
727
728
729 // ---------------------------------------------------------------------------
730 void manualContourModel::AddManualPoint( manualPoint* theManualPoint )//private
731 {
732         _lstPoints.push_back( theManualPoint );
733 }
734
735 std::vector<manualBaseModel*> manualContourModel::ExploseModel(  )
736 {
737         std::vector<manualBaseModel*> lstTmp;
738         lstTmp.push_back(this);
739         return lstTmp;
740 }
741
742
743 // ----------------------------------------------------------------------------
744 void manualContourModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By)
745 {
746         manualPoint * mp;
747
748         int i, size = GetSizeLstPoints();
749
750         for( i=0; i<size; i++ )
751         {
752                 mp = GetManualPoint( i );
753
754                 mp->SetPointX( mp->GetX()*Ax + Bx );
755                 mp->SetPointY( mp->GetY()*Ay + By );
756         }
757 }
758
759
760 //CMRU 17-08-09----------------------------------------------------------------------------
761 void manualContourModel::SetLabel(std::string newLabel)
762 {
763         _label = newLabel;
764 }
765
766 void manualContourModel::SetRealSize(double newRealSize) 
767 {
768         _realSize = newRealSize;
769 }
770
771 double manualContourModel::GetRealSize()
772 {
773         return _realSize;
774 }
775
776 std::string manualContourModel::GetLabel()
777 {
778         return _label;
779 }
780 //----------------------------------------------------------------------------