]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/manualContour/manualContourModel.cpp
947e614bd77f90dfe4d3c581249f885ee699b8c5
[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                 _delta_JSTG = (double) (np) / double (_sizePointsContour-1 );  //Without the -1 the curve is not close
341         }
342 //-----------------------------------------------------------------------------------------------------------
343 }
344
345 //---------------------------------------------------------------------------------
346
347 /*void manualContourModel::GetSplineiPoint(int i, double &x, double &y, double &z)
348 {
349         double delta=(double)(_lstPoints.size()) / (double)(_sizePointsContour);
350         double t = delta*(double)i;
351         GetSplinePoint(t, x, y, z);
352 }*/
353
354 //-----------------------------------------------------------------------------
355
356 //JSTG 25-02-08 ---------------------------------------------------------------
357 void manualContourModel::GetSpline_i_Point(int i, double *x, double *y, double *z) // virtal
358 {
359         GetSpline_t_Point(i*_delta_JSTG,x,y,z);
360 }
361
362 // ----------------------------------------------------------------------------
363
364 //JSTG 25-02-08 ---------------------------------------------------------------
365 void manualContourModel::GetSpline_t_Point(double t, double *x, double *y, double *z)
366 {
367                 if (_lstPoints.size()==0)
368         {
369                 *x      = 0;
370                 *y      = 0;
371                 *z      = 0;
372         }
373         if (_lstPoints.size()==1)
374         {
375                 manualPoint     *mp;
376                 mp      = GetManualPoint(0);
377                 *x      = mp->GetX();
378                 *y      = mp->GetY();
379                 *z      = mp->GetZ();
380         }
381         if (_lstPoints.size()>=2)
382         {
383                 *x      = _cntSplineX->Evaluate(t);
384                 *y      = _cntSplineY->Evaluate(t);
385                 *z      = _cntSplineZ->Evaluate(t);
386         }
387 }
388
389 // ----------------------------------------------------------------------------
390
391
392 /*void manualContourModel::GetSplinePoint(double t, double &x, double &y, double &z)
393 {
394         if (_lstPoints.size()==0)
395         {
396                 x       = 0;
397                 y       = 0;
398                 z       = 0;
399         }
400         if (_lstPoints.size()==1)
401         {
402                 manualPoint     *mp;
403                 mp      = GetManualPoint(0);
404                 x       = mp->GetX();
405                 y       = mp->GetY();
406                 z       = mp->GetZ();
407         }
408         if (_lstPoints.size()>=2)
409         {
410                 x       = _cntSplineX->Evaluate(t);
411                 y       = _cntSplineY->Evaluate(t);
412                 z       = _cntSplineZ->Evaluate(t);
413         }
414 }*/
415 // ----------------------------------------------------------------------------
416 double manualContourModel::GetPathSize()
417 {
418         double result = 0;
419         double x1,y1,z1;
420         double x2,y2,z2;
421
422 // JSTG 25-02-08 -----------------------------
423         //double t,delta;
424         //int i,np,nps;
425         int i;
426 //--------------------------------------------
427
428         if (_lstPoints.size()==2)
429         {
430                 x1=_lstPoints[0]->GetX();
431                 y1=_lstPoints[0]->GetY();
432                 z1=_lstPoints[0]->GetZ();
433                 x2=_lstPoints[1]->GetX();
434                 y2=_lstPoints[1]->GetY();
435                 z2=_lstPoints[1]->GetZ();
436                 result = sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1) );
437         }
438         if (_lstPoints.size()>2)
439         {
440
441 // JSTG 25-02-08 ------------------------------------------
442                 //np  = _lstPoints.size( );
443                 //nps = 200;
444                 //delta=( double ) ( np  ) / ( double ) ( nps  );
445                 UpdateSpline();
446                 //GetSplinePoint(0,x1,y1,z1);
447                 GetSpline_i_Point(0,&x1,&y1,&z1);
448
449                 //for( i = 1; i < nps; i++ )
450                 for( i = 1; i < GetNumberOfPointsSpline(); i++ )
451                 {
452                         //t = delta * (double)i;
453                         //GetSplinePoint(t,x2,y2,z2);
454                         GetSpline_i_Point(i,&x2,&y2,&z2);
455 //---------------------------------------------------------
456                         result=result + sqrt( (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1) + (z2-z1)*(z2-z1) );
457                         x1=x2;
458                         y1=y2;
459                         z1=z2;
460                 }// for
461         }
462
463         return result;
464 }
465 // ----------------------------------------------------------------------------
466 double manualContourModel::GetPathArea()
467 {
468         double result = 555;
469         if ((_lstPoints.size()>=3) && IfCloseContour()==true )
470         {
471                 double area;
472 //JSTG 25-02-08 ---------------------------------------------
473                 //double ti,tj;
474 //-----------------------------------------------------------
475                 double x1,y1,z1;
476                 double x2,y2,z2;
477                 bool okArea=true;
478                 int i, j;
479
480                 // This uses Green's theorem:
481                 // A = 1/2 * sum( xiyi+1 - xi+1yi); pO == pN
482                 // A < 0 -> A = |A| (a negative value could raise because points are
483                 // given in clockwise order).
484
485 //JSTG 25-02-08 -------------------------------------------------
486                 //int np  = _lstPoints.size( );
487                 //int nps = 200;
488                 int nps = GetNumberOfPointsSpline();
489                 //double delta=( double ) ( np  ) / ( double ) ( nps  );
490                 UpdateSpline();
491                 for( i = 0, area = 0.0; i < nps; i++ )
492                 {
493                         j = ( i + 1 ) % nps;
494                         //ti = delta * (double)i;
495                         //tj = delta * (double)j;
496                         //GetSplinePoint(ti,x1,y1,z1);
497                         //GetSplinePoint(tj,x2,y2,z2);
498                         GetSpline_i_Point(i,&x1,&y1,&z1);
499                         GetSpline_i_Point(j,&x2,&y2,&z2);
500 //----------------------------------------------------------------
501                         area +=
502                                         (x1 * y2 ) -
503                                         ( x2 * y1 );
504                         if (z1!=z2)
505                         {
506                                 okArea=false;
507                         }
508                 }// for
509                 area /= 2.0;
510                 area = fabs( area );
511
512 /*
513                 for( i = 0, area = 0.0; i < _lstPoints.size(); i++ )
514                 {
515                         j = ( i + 1 ) % _lstPoints.size();
516                         //  Area
517                         area +=
518                                         (_lstPoints[i]->GetX() * _lstPoints[j]->GetY() ) -
519                                         ( _lstPoints[j]->GetX() * _lstPoints[i]->GetY() );
520                         if (_lstPoints[0]->GetZ()!=_lstPoints[i]->GetZ())
521                         {
522                                 okArea=false;
523                         }
524                 } // rof
525                 area /= 2.0;
526                 area = fabs( area );
527 */
528
529                 if (okArea==true)
530                 {
531                         result = area;
532                 } else {
533                         result = -1;
534                 }
535
536         } else {
537                 result = 0;
538         }
539         return result;
540 }
541
542 // ----------------------------------------------------------------------------
543 // p[x,y,z]   :  data in
544 // rp[x,y,z]  :  data out  result point
545 // rn[x,y,z]  :  data out   result normal
546
547 void manualContourModel::GetNearestPointAndNormal(double *p, double *rp,  double *rn)
548 {
549         double  distMin=999999999;
550         double  dist,dx,dy,dz;
551         double  x1,y1,z1;
552         double  x2,y2,z2;
553         int             i,np,nps;
554
555 //JSTG 25-02-08 -------------------
556         //double  tback;
557         int iback;
558         //double        t,delta;
559 //---------------------------------
560
561         np      = _lstPoints.size( );
562         if (np>=2)
563         {
564 // JSTG 25-02-08 ------------------------------------------
565                 //nps           = 200;
566                 nps = GetNumberOfPointsSpline();
567                 //delta = ( double ) ( np  ) / ( double ) ( nps  );
568                 UpdateSpline();
569                 //GetSplinePoint(0,x1,y1,z1);
570                 GetSpline_i_Point(0,&x1,&y1,&z1);
571                 for( i = 0; i < nps; i++ )
572                 {
573                         //t = delta * (double)i;
574                         //GetSplinePoint(t,x1,y1,z1);
575                         GetSpline_i_Point(i,&x1,&y1,&z1);
576 //----------------------------------------------------------
577                         dx= x1-p[0];
578                         dy= y1-p[1];
579                         dz= z1-p[2];
580                         dist = sqrt( dx*dx + dy*dy + dz*dz );
581                         if (dist<distMin)
582                         {
583                                 distMin  = dist;
584 //JSTG                  tback = t;
585                                 iback = i;
586                                 rp[0] = x1;
587                                 rp[1] = y1;
588                                 rp[2] = z1;
589                                 rn[0] = x2-x1;
590                                 rn[1] = y2-y1;
591                                 rn[2] = z2-z1;
592                         }
593                         x2=x1;
594                         y2=y1;
595                         z2=z1;
596                 }// for
597
598 // JSTG 25-02-08 ------------------------------------------
599                 //if (tback==0)
600                 if (iback==0)
601                 {
602                         //t = delta * (double)1.0;
603                         //GetSplinePoint(t,x1,y1,z1);
604                         GetSpline_i_Point(i,&x1,&y1,&z1);
605 //----------------------------------------------------------
606                         rn[0]=rp[0]-x1;
607                         rn[1]=rp[1]-y1;
608                         rn[2]=rp[2]-z1;
609                 }
610         }
611         else
612         {
613                 rp[0] = 0;
614                 rp[1] = 0;
615                 rp[2] = 0;
616                 rn[0] = -1;
617                 rn[1] = 0;
618                 rn[2] = 0;
619         }
620 }
621
622 // ----------------------------------------------------------------------------
623 manualContourModel * manualContourModel :: Clone() // virtual
624 {
625         manualContourModel * clone = new manualContourModel();
626         CopyAttributesTo(clone);
627         return clone;
628 }
629
630 // ----------------------------------------------------------------------------
631 void manualContourModel::Open(FILE *ff) // virtual
632 {
633         char tmp[255];
634         int i;
635         int numberOfControlPoints;
636         double x,y,z;
637
638         fscanf(ff,"%s",tmp); // NumberOfControlPoints
639         fscanf(ff,"%s",tmp); // ##
640         numberOfControlPoints = atoi(tmp);
641         for (i=0;i<numberOfControlPoints;i++)
642         {
643                 fscanf(ff,"%s",tmp); // X
644                 x = atof(tmp);
645                 fscanf(ff,"%s",tmp); // Y
646                 y = atof(tmp);
647                 fscanf(ff,"%s",tmp); // Z
648                 z = atof(tmp);
649                 AddPoint(x,y,z);
650         }
651 }
652
653 // ----------------------------------------------------------------------------
654 int manualContourModel::GetTypeModel() //virtual
655 {
656         // 0 spline
657         // 1 spline
658         // 2 rectangle
659         // 3 circle
660         // 4 BullEye
661         // 5 BullEyeSector
662         // 6 Line
663         return 1;
664 }
665
666 // ----------------------------------------------------------------------------
667 void manualContourModel::Save(FILE *ff) // virtual
668 {
669         int i,size=_lstPoints.size();
670         fprintf(ff,"TypeModel %d\n", GetTypeModel() );
671         fprintf(ff,"NumberOfControlPoints %d\n",size);
672         for (i=0;i<size;i++)
673         {
674                 manualPoint *mp=_lstPoints[i];
675                 fprintf(ff,"%f %f %f\n", mp->GetX(), mp->GetY(), mp->GetZ() );
676         }
677 }
678 //CMRU 03-09-09-----------------------------------------------------------------------------------------------
679 void manualContourModel::SaveData(FILE *ff)
680 {
681         std::string etiqueta = GetLabel();
682         if(etiqueta.empty())
683                 fprintf(ff,"Label: NO_LABEL\n");
684         else
685                 fprintf(ff,"Label: %s\n",etiqueta.c_str());
686         fprintf(ff,"Real_Size: %f\n",GetRealSize());
687 }
688
689 void manualContourModel::OpenData(FILE *ff)
690 {
691         char tmp[255];
692
693         fscanf(ff,"%s",tmp); // Label:
694         fscanf(ff,"%s",tmp); // value
695         std::cout<<tmp<<std::endl;
696         //if(strcmp(tmp != "NO_LABEL") // JPR
697         if(strcmp(tmp,"NO_LABEL") != 0)
698                 SetLabel(tmp);
699
700         fscanf(ff,"%s",tmp); // Real_size
701         fscanf(ff,"%s",tmp);// #
702
703         //tmp.ToDouble(&tmp);
704         SetRealSize(atof(tmp));
705 }
706
707 //------------------------------------------------------------------------------------------------------------
708
709 // ---------------------------------------------------------------------------
710
711 void manualContourModel::CopyAttributesTo( manualContourModel * cloneObject)
712 {
713         // Fathers object
714         //XXXX::CopyAttributesTo(cloneObject);
715
716         cloneObject->SetCloseContour( this->IfCloseContour() );
717         int i, size = GetSizeLstPoints();
718         for( i=0; i<size; i++ )
719         {
720                 cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
721         }
722         cloneObject->SetNumberOfPointsSpline( GetNumberOfPointsSpline () );
723         cloneObject->SetCloseContour( _closeContour );
724         cloneObject->UpdateSpline();
725 }
726
727
728 // ---------------------------------------------------------------------------
729 void manualContourModel::AddManualPoint( manualPoint* theManualPoint )//private
730 {
731         _lstPoints.push_back( theManualPoint );
732 }
733
734 std::vector<manualBaseModel*> manualContourModel::ExploseModel(  )
735 {
736         std::vector<manualBaseModel*> lstTmp;
737         lstTmp.push_back(this);
738         return lstTmp;
739 }
740
741
742 // ----------------------------------------------------------------------------
743 void manualContourModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By)
744 {
745         manualPoint * mp;
746
747         int i, size = GetSizeLstPoints();
748
749         for( i=0; i<size; i++ )
750         {
751                 mp = GetManualPoint( i );
752
753                 mp->SetPointX( mp->GetX()*Ax + Bx );
754                 mp->SetPointY( mp->GetY()*Ay + By );
755         }
756 }
757
758
759 //CMRU 17-08-09----------------------------------------------------------------------------
760 void manualContourModel::SetLabel(std::string newLabel)
761 {
762         _label = newLabel;
763 }
764
765 void manualContourModel::SetRealSize(double newRealSize) 
766 {
767         _realSize = newRealSize;
768 }
769
770 double manualContourModel::GetRealSize()
771 {
772         return _realSize;
773 }
774
775 std::string manualContourModel::GetLabel()
776 {
777         return _label;
778 }
779 //----------------------------------------------------------------------------