]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp
#3093 creaMaracasVisu Feature New Normal - Contour Information in pixels and image...
[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(double *spc)
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 = spc[0] * _lstPoints[0]->GetX();
432                 y1 = spc[1] * _lstPoints[0]->GetY();
433                 z1 = spc[2] * _lstPoints[0]->GetZ();
434                 x2 = spc[0] * _lstPoints[1]->GetX();
435                 y2 = spc[1] * _lstPoints[1]->GetY();
436                 z2 = spc[2] * _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                 x1 = spc[0] * x1; 
451                 y1 = spc[1] * y1; 
452                 z1 = spc[2] * z1; 
453                 //for( i = 1; i < nps; i++ )
454                 for( i = 1; i < GetNumberOfPointsSpline(); i++ )
455                 {
456                         //t = delta * (double)i;
457                         //GetSplinePoint(t,x2,y2,z2);
458                         GetSpline_i_Point(i,&x2,&y2,&z2);
459                         x2 = spc[0] * x2; 
460                         y2 = spc[1] * y2; 
461                         z2 = spc[2] * z2; 
462 //---------------------------------------------------------
463                         result=result + sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1) );
464                         x1=x2;
465                         y1=y2;
466                         z1=z2;
467                 }// for
468         }
469
470         return result;
471 }
472
473
474 // ----------------------------------------------------------------------------
475 double manualContourModel::GetPathArea(double *spc)
476 {
477         double result = 555;
478         if ((_lstPoints.size()>=3) && IfCloseContour()==true )
479         {
480                 double area;
481 //JSTG 25-02-08 ---------------------------------------------
482                 //double ti,tj;
483 //-----------------------------------------------------------
484                 double x1,y1,z1;
485                 double x2,y2,z2;
486                 bool okArea=true;
487                 int i, j;
488
489                 // This uses Green's theorem:
490                 // A = 1/2 * sum( xiyi+1 - xi+1yi); pO == pN
491                 // A < 0 -> A = |A| (a negative value could raise because points are
492                 // given in clockwise order).
493
494 //JSTG 25-02-08 -------------------------------------------------
495                 //int np  = _lstPoints.size( );
496                 //int nps = 200;
497                 int nps = GetNumberOfPointsSpline();
498                 //double delta=( double ) ( np  ) / ( double ) ( nps  );
499                 UpdateSpline();
500                 for( i = 0, area = 0.0; i < nps; i++ )
501                 {
502                         j = ( i + 1 ) % nps;
503                         //ti = delta * (double)i;
504                         //tj = delta * (double)j;
505                         //GetSplinePoint(ti,x1,y1,z1);
506                         //GetSplinePoint(tj,x2,y2,z2);
507                         GetSpline_i_Point(i,&x1,&y1,&z1);
508                         GetSpline_i_Point(j,&x2,&y2,&z2);
509 //----------------------------------------------------------------
510                         x1=spc[0]*x1;
511                         y1=spc[1]*y1;
512                         z1=spc[2]*z1;
513                         x2=spc[0]*x2;
514                         y2=spc[1]*y2;
515                         z2=spc[2]*z2;
516                         area +=
517                                         (x1 * y2 ) -
518                                         ( x2 * y1 );
519                         if (z1!=z2)
520                         {
521                                 okArea=false;
522                         }
523                 }// for
524                 area /= 2.0;
525                 area = fabs( area );
526
527 /*
528                 for( i = 0, area = 0.0; i < _lstPoints.size(); i++ )
529                 {
530                         j = ( i + 1 ) % _lstPoints.size();
531                         //  Area
532                         area +=
533                                         (_lstPoints[i]->GetX() * _lstPoints[j]->GetY() ) -
534                                         ( _lstPoints[j]->GetX() * _lstPoints[i]->GetY() );
535                         if (_lstPoints[0]->GetZ()!=_lstPoints[i]->GetZ())
536                         {
537                                 okArea=false;
538                         }
539                 } // rof
540                 area /= 2.0;
541                 area = fabs( area );
542 */
543
544                 if (okArea==true)
545                 {
546                         result = area;
547                 } else {
548                         result = -1;
549                 }
550
551         } else {
552                 result = 0;
553         }
554         return result;
555 }
556
557 // ----------------------------------------------------------------------------
558 // p[x,y,z]   :  data in
559 // rp[x,y,z]  :  data out  result point
560 // rn[x,y,z]  :  data out   result normal
561
562 void manualContourModel::GetNearestPointAndNormal(double *p, double *rp,  double *rn)
563 {
564         double  distMin=999999999;
565         double  dist,dx,dy,dz;
566         double  x1,y1,z1;
567         double  x2,y2,z2;
568         int             i,np,nps;
569
570 //JSTG 25-02-08 -------------------
571         //double  tback;
572         int iback;
573         //double        t,delta;
574 //---------------------------------
575
576         np      = _lstPoints.size( );
577         if (np>=2)
578         {
579 // JSTG 25-02-08 ------------------------------------------
580                 //nps           = 200;
581                 nps = GetNumberOfPointsSpline();
582                 //delta = ( double ) ( np  ) / ( double ) ( nps  );
583                 UpdateSpline();
584                 //GetSplinePoint(0,x1,y1,z1);
585                 GetSpline_i_Point(0,&x1,&y1,&z1);
586                 for( i = 0; i < nps; i++ )
587                 {
588                         //t = delta * (double)i;
589                         //GetSplinePoint(t,x1,y1,z1);
590                         GetSpline_i_Point(i,&x1,&y1,&z1);
591 //----------------------------------------------------------
592                         dx= x1-p[0];
593                         dy= y1-p[1];
594                         dz= z1-p[2];
595                         dist = sqrt( dx*dx + dy*dy + dz*dz );
596                         if (dist<distMin)
597                         {
598                                 distMin  = dist;
599 //JSTG                  tback = t;
600                                 iback = i;
601                                 rp[0] = x1;
602                                 rp[1] = y1;
603                                 rp[2] = z1;
604                                 rn[0] = x2-x1;
605                                 rn[1] = y2-y1;
606                                 rn[2] = z2-z1;
607                         }
608                         x2=x1;
609                         y2=y1;
610                         z2=z1;
611                 }// for
612
613 // JSTG 25-02-08 ------------------------------------------
614                 //if (tback==0)
615                 if (iback==0)
616                 {
617                         //t = delta * (double)1.0;
618                         //GetSplinePoint(t,x1,y1,z1);
619                         GetSpline_i_Point(i,&x1,&y1,&z1);
620 //----------------------------------------------------------
621                         rn[0]=rp[0]-x1;
622                         rn[1]=rp[1]-y1;
623                         rn[2]=rp[2]-z1;
624                 }
625         } else {
626                 rp[0] = 0;
627                 rp[1] = 0;
628                 rp[2] = 0;
629                 rn[0] = -1;
630                 rn[1] = 0;
631                 rn[2] = 0;
632         }
633 }
634
635 // ----------------------------------------------------------------------------
636 manualContourModel * manualContourModel :: Clone() // virtual
637 {
638         manualContourModel * clone = new manualContourModel();
639         CopyAttributesTo(clone);
640         return clone;
641 }
642
643 // ----------------------------------------------------------------------------
644 void manualContourModel::Open(FILE *ff) // virtual
645 {
646         char tmp[255];
647         int i;
648         int numberOfControlPoints;
649         double x,y,z;
650
651         fscanf(ff,"%s",tmp); // NumberOfControlPoints
652         fscanf(ff,"%s",tmp); // ##
653         numberOfControlPoints = atoi(tmp);
654         for (i=0;i<numberOfControlPoints;i++)
655         {
656                 fscanf(ff,"%s",tmp); // X
657                 x = atof(tmp);
658                 fscanf(ff,"%s",tmp); // Y
659                 y = atof(tmp);
660                 fscanf(ff,"%s",tmp); // Z
661                 z = atof(tmp);
662                 AddPoint(x,y,z);
663         }
664 }
665
666 // ----------------------------------------------------------------------------
667 int manualContourModel::GetTypeModel() //virtual
668 {
669         // 0 spline
670         // 1 spline
671         // 2 rectangle
672         // 3 circle
673         // 4 BullEye
674         // 5 BullEyeSector
675         // 6 Line
676         return 1;
677 }
678
679 // ----------------------------------------------------------------------------
680 void manualContourModel::Save(FILE *ff) // virtual
681 {
682         int i,size=_lstPoints.size();
683         fprintf(ff,"TypeModel %d\n", GetTypeModel() );
684         fprintf(ff,"NumberOfControlPoints %d\n",size);
685         for (i=0;i<size;i++)
686         {
687                 manualPoint *mp=_lstPoints[i];
688                 fprintf(ff,"%f %f %f\n", mp->GetX(), mp->GetY(), mp->GetZ() );
689         }
690 }
691 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
692 void manualContourModel::SaveData(FILE *ff)
693 {
694         std::string etiqueta = GetLabel();
695         if(etiqueta.empty())
696                 fprintf(ff,"Label: NO_LABEL\n");
697         else
698                 fprintf(ff,"Label: %s\n",etiqueta.c_str());
699         fprintf(ff,"Real_Size: %f\n",GetRealSize());
700 }
701
702 void manualContourModel::OpenData(FILE *ff)
703 {
704         char tmp[255];
705
706         fscanf(ff,"%s",tmp); // Label:
707         fscanf(ff,"%s",tmp); // value
708         std::cout<<tmp<<std::endl;
709         //if(strcmp(tmp != "NO_LABEL") // JPR
710         if(strcmp(tmp,"NO_LABEL") != 0)
711                 SetLabel(tmp);
712
713         fscanf(ff,"%s",tmp); // Real_size
714         fscanf(ff,"%s",tmp);// #
715
716         //tmp.ToDouble(&tmp);
717         SetRealSize(atof(tmp));
718 }
719
720 //------------------------------------------------------------------------------------------------------------
721
722 // ---------------------------------------------------------------------------
723
724 void manualContourModel::CopyAttributesTo( manualContourModel * cloneObject)
725 {
726         // Fathers object
727         //XXXX::CopyAttributesTo(cloneObject);
728
729         cloneObject->SetCloseContour( this->IfCloseContour() );
730         int i, size = GetSizeLstPoints();
731         for( i=0; i<size; i++ )
732         {
733                 cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
734         }
735         cloneObject->SetNumberOfPointsSpline( GetNumberOfPointsSpline () );
736         cloneObject->SetCloseContour( _closeContour );
737         cloneObject->UpdateSpline();
738 }
739
740
741 // ---------------------------------------------------------------------------
742 void manualContourModel::AddManualPoint( manualPoint* theManualPoint )//private
743 {
744         _lstPoints.push_back( theManualPoint );
745 }
746
747 std::vector<manualBaseModel*> manualContourModel::ExploseModel(  )
748 {
749         std::vector<manualBaseModel*> lstTmp;
750         lstTmp.push_back(this);
751         return lstTmp;
752 }
753
754
755 // ----------------------------------------------------------------------------
756 void manualContourModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By)
757 {
758         manualPoint * mp;
759
760         int i, size = GetSizeLstPoints();
761
762         for( i=0; i<size; i++ )
763         {
764                 mp = GetManualPoint( i );
765
766                 mp->SetPointX( mp->GetX()*Ax + Bx );
767                 mp->SetPointY( mp->GetY()*Ay + By );
768         }
769 }
770
771
772 //CMRU 17-08-09----------------------------------------------------------------------------
773 void manualContourModel::SetLabel(std::string newLabel)
774 {
775         _label = newLabel;
776 }
777
778 void manualContourModel::SetRealSize(double newRealSize) 
779 {
780         _realSize = newRealSize;
781 }
782
783 double manualContourModel::GetRealSize()
784 {
785         return _realSize;
786 }
787
788 std::string manualContourModel::GetLabel()
789 {
790         return _label;
791 }
792 //----------------------------------------------------------------------------