1 #include "manualBaseModel.h"
3 // ----------------------------------------------------------------------------
4 manualBaseModel::manualBaseModel()
7 _sizePointsContour = 100; //JSTG 25-02-08 The change in the inisialization of these variable is critical.
11 // ----------------------------------------------------------------------------
12 manualBaseModel::~manualBaseModel()
14 int i,size=_lstPoints.size();
15 for (i=0;i<size; i++){
21 // ----------------------------------------------------------------------------
22 int manualBaseModel::AddPoint(double x,double y,double z)
24 manualPoint *mp = new manualPoint();
28 return _lstPoints.size()-1;
30 // ----------------------------------------------------------------------------
31 int manualBaseModel::InsertPoint(double x,double y,double z)
33 double dd,ddmin=9999999;
38 int i,ii,iii,size=_lstPoints.size();
39 double j,MaxDivisions=20,porcentage;
44 for ( i=0 ; i<size ; i++ )
48 x1=_lstPoints[ii]->GetX();
49 y1=_lstPoints[ii]->GetY();
50 z1=_lstPoints[ii]->GetZ();
51 x2=_lstPoints[iii]->GetX();
52 y2=_lstPoints[iii]->GetY();
53 z2=_lstPoints[iii]->GetZ();
54 for (j=0; j<=MaxDivisions; j++)
56 porcentage=(j/MaxDivisions);
57 xx=(x2-x1)*porcentage+x1;
58 yy=(y2-y1)*porcentage+y1;
59 zz=(z2-z1)*porcentage+z1;
60 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
71 InsertPoint_id(ibak,x,y,z);
75 // ----------------------------------------------------------------------------
76 void manualBaseModel::InsertPoint_id(int id, double x, double y, double z)
78 manualPoint *mp = new manualPoint();
80 std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + id;
81 _lstPoints.insert(itNum,mp);
83 // ----------------------------------------------------------------------------
85 void manualBaseModel::DeletePoint(int i)
87 std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + i;
88 _lstPoints.erase(itNum);
90 // ----------------------------------------------------------------------------
91 void manualBaseModel::DeleteAllPoints()
93 int i,size=_lstPoints.size();
95 _lstPoints.erase( _lstPoints.begin() );
98 // ----------------------------------------------------------------------------
100 void manualBaseModel::MovePoint(int i,double dx,double dy,double dz)
102 manualPoint *mp=_lstPoints[i];
103 double x=mp->GetX()+dx;
104 double y=mp->GetY()+dy;
105 double z=mp->GetZ()+dz;
108 // ----------------------------------------------------------------------------
109 void manualBaseModel::MoveLstPoints(double dx,double dy,double dz)
113 // ----------------------------------------------------------------------------
114 void manualBaseModel::MoveAllPoints(double dx,double dy,double dz)
116 int i,size=_lstPoints.size();
117 for (i=0;i<size;i++){
118 MovePoint(i,dx,dy,dz);
123 // ----------------------------------------------------------------------------
128 int manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int type)
130 double range = i_range+1;
132 double xx,yy,zz,dd,ddmin=9999999;
134 int i,size=_lstPoints.size();
135 for (i=0;i<size;i++){
136 manualPoint *mp=_lstPoints[i];
143 if ((fabs(xx-x)<range) && (fabs(yy-y)<range) && (fabs(zz-z)<range)) {
144 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
153 if ((fabs(yy-y)<range) && (fabs(zz-z)<range)) {
154 dd=sqrt( (yy-y)*(yy-y) + (zz-z)*(zz-z) );
163 if ((fabs(xx-x)<range) && (fabs(zz-z)<range)) {
164 dd=sqrt( (xx-x)*(xx-x) + (zz-z)*(zz-z) );
173 if ((fabs(xx-x)<range) && (fabs(yy-y)<range) ) {
174 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) );
184 // ----------------------------------------------------------------------------
185 int manualBaseModel::IsPoint(double x, double y)
189 int i,size=_lstPoints.size();
190 for (i=0;i<size;i++){
191 manualPoint *mp=_lstPoints[i];
195 //RaC Be Careful!! Cast to have a point like the one in the params 27-09-09
196 if(x==(int)xx && y==(int)yy )
204 // ----------------------------------------------------------------------------
205 manualPoint* manualBaseModel::GetManualPoint(int id)
207 return _lstPoints[id];
209 // ----------------------------------------------------------------------------
210 int manualBaseModel::GetSizeLstPoints()
212 return _lstPoints.size();
215 // ----------------------------------------------------------------------------
216 manualBaseModel * manualBaseModel :: Clone() // virtual
218 manualBaseModel * clone = new manualBaseModel();
219 CopyAttributesTo(clone);
223 // ----------------------------------------------------------------------------
224 int manualBaseModel::GetTypeModel() //virtual
237 // ---------------------------------------------------------------------------
239 void manualBaseModel::CopyAttributesTo( manualBaseModel * cloneObject)
241 int i, size = GetSizeLstPoints();
242 for( i=0; i<size; i++ )
244 cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
249 // ---------------------------------------------------------------------------
250 void manualBaseModel::AddManualPoint( manualPoint* theManualPoint )
252 _lstPoints.push_back( theManualPoint );
255 void manualBaseModel::Open(FILE *ff) // virtual
258 void manualBaseModel::Save(FILE *ff) // virtual
262 void manualBaseModel::SaveData(FILE *ff)// virtual
267 // ---------------------------------------------------------------------------
268 void manualBaseModel::SetNumberOfPointsSpline(int size)
270 _sizePointsContour = size;
273 double manualBaseModel::GetPathSize()
278 void manualBaseModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By)
282 void manualBaseModel::GetSpline_i_Point(int i, double *x, double *y, double *z)
284 //RaC 20-09-09 IF it's a points contour
285 if(GetTypeModel()==7){
286 if (_lstPoints.size()==0)
305 void manualBaseModel::GetSpline_t_Point(double t, double *x, double *y, double *z)
309 // ---------------------------------------------------------------------------
310 int manualBaseModel::GetNumberOfPointsSpline()
313 //RaC 20-09-09 IF it's a points contour
314 if(GetTypeModel()==7){
315 return _lstPoints.size();
317 return _sizePointsContour;
320 // ---------------------------------------------------------------------------
321 void manualBaseModel::UpdateSpline()
325 // ---------------------------------------------------------------------------
326 std::vector<manualBaseModel*> manualBaseModel::ExploseModel( )
328 std::vector<manualBaseModel*> lstTmp;
329 lstTmp.push_back(this);
333 // ---------------------------------------------------------------------------
334 double manualBaseModel::GetPathArea()
338 void manualBaseModel::GetNearestPointAndNormal(double *p, double *rp, double *rn)
341 void manualBaseModel::SetCloseContour(bool closeContour)
344 bool manualBaseModel::IfCloseContour()
348 //CMRU 17-08-09----------------------------------------------------------------------------
349 void manualBaseModel::SetLabel(std::string newLabel)
353 void manualBaseModel::SetRealSize(double newRealSize)
357 double manualBaseModel::GetRealSize()
362 std::string manualBaseModel::GetLabel()
366 void manualBaseModel::OpenData(FILE *ff)
369 //----------------------------------------------------------------------------