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) );
70 InsertPoint_id(ibak,x,y,z);
74 // ----------------------------------------------------------------------------
75 void manualBaseModel::InsertPoint_id(int id, double x, double y, double z)
77 manualPoint *mp = new manualPoint();
79 std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + id;
80 _lstPoints.insert(itNum,mp);
82 // ----------------------------------------------------------------------------
84 void manualBaseModel::DeletePoint(int i)
86 std::vector<manualPoint*>::iterator itNum = _lstPoints.begin() + i;
87 _lstPoints.erase(itNum);
89 // ----------------------------------------------------------------------------
90 void manualBaseModel::DeleteAllPoints()
92 int i,size=_lstPoints.size();
94 _lstPoints.erase( _lstPoints.begin() );
97 // ----------------------------------------------------------------------------
99 void manualBaseModel::MovePoint(int i,double dx,double dy,double dz)
101 manualPoint *mp=_lstPoints[i];
102 double x=mp->GetX()+dx;
103 double y=mp->GetY()+dy;
104 double z=mp->GetZ()+dz;
107 // ----------------------------------------------------------------------------
108 void manualBaseModel::MoveLstPoints(double dx,double dy,double dz)
112 // ----------------------------------------------------------------------------
113 void manualBaseModel::MoveAllPoints(double dx,double dy,double dz)
115 int i,size=_lstPoints.size();
116 for (i=0;i<size;i++){
117 MovePoint(i,dx,dy,dz);
121 // ----------------------------------------------------------------------------
126 int manualBaseModel::GetIdPoint(double x, double y, double z, int i_range,int type)
128 double range = i_range+1;
130 double xx,yy,zz,dd,ddmin=9999999;
132 int i,size=_lstPoints.size();
133 for (i=0;i<size;i++){
134 manualPoint *mp=_lstPoints[i];
141 if ((fabs(xx-x)<range) && (fabs(yy-y)<range) && (fabs(zz-z)<range)) {
142 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) + (zz-z)*(zz-z) );
151 if ((fabs(yy-y)<range) && (fabs(zz-z)<range)) {
152 dd=sqrt( (yy-y)*(yy-y) + (zz-z)*(zz-z) );
161 if ((fabs(xx-x)<range) && (fabs(zz-z)<range)) {
162 dd=sqrt( (xx-x)*(xx-x) + (zz-z)*(zz-z) );
171 if ((fabs(xx-x)<range) && (fabs(yy-y)<range) ) {
172 dd=sqrt( (xx-x)*(xx-x) + (yy-y)*(yy-y) );
182 // ----------------------------------------------------------------------------
183 int manualBaseModel::IsPoint(double x, double y)
187 int i,size=_lstPoints.size();
188 for (i=0;i<size;i++){
189 manualPoint *mp=_lstPoints[i];
193 //RaC Be Careful!! Cast to have a point like the one in the params 27-09-09
194 if(x==(int)xx && y==(int)yy )
201 // ----------------------------------------------------------------------------
202 manualPoint* manualBaseModel::GetManualPoint(int id)
204 return _lstPoints[id];
206 // ----------------------------------------------------------------------------
207 int manualBaseModel::GetSizeLstPoints()
209 return _lstPoints.size();
212 // ----------------------------------------------------------------------------
213 manualBaseModel * manualBaseModel :: Clone() // virtual
215 manualBaseModel * clone = new manualBaseModel();
216 CopyAttributesTo(clone);
220 // ----------------------------------------------------------------------------
221 int manualBaseModel::GetTypeModel() //virtual
234 // ---------------------------------------------------------------------------
236 void manualBaseModel::CopyAttributesTo( manualBaseModel * cloneObject)
238 int i, size = GetSizeLstPoints();
239 for( i=0; i<size; i++ )
241 cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
245 // ---------------------------------------------------------------------------
246 void manualBaseModel::AddManualPoint( manualPoint* theManualPoint )
248 _lstPoints.push_back( theManualPoint );
250 // ---------------------------------------------------------------------------
251 void manualBaseModel::Open(FILE *ff) // virtual
254 // ---------------------------------------------------------------------------
255 void manualBaseModel::Save(FILE *ff) // virtual
258 // ---------------------------------------------------------------------------
259 void manualBaseModel::SaveData(FILE *ff)// virtual
264 // ---------------------------------------------------------------------------
265 void manualBaseModel::SetNumberOfPointsSpline(int size)
267 _sizePointsContour = size;
269 // ---------------------------------------------------------------------------
270 double manualBaseModel::GetPathSize()
274 // ---------------------------------------------------------------------------
275 void manualBaseModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By)
278 // ---------------------------------------------------------------------------
279 void manualBaseModel::GetSpline_i_Point(int i, double *x, double *y, double *z)
281 //RaC 20-09-09 IF it's a points contour
282 if(GetTypeModel()==7){
283 if (_lstPoints.size()==0)
300 void manualBaseModel::GetSpline_t_Point(double t, double *x, double *y, double *z)
304 // ---------------------------------------------------------------------------
305 int manualBaseModel::GetNumberOfPointsSpline()
308 //RaC 20-09-09 IF it's a points contour
309 if(GetTypeModel()==7){
310 return _lstPoints.size();
312 return _sizePointsContour;
315 // ---------------------------------------------------------------------------
316 void manualBaseModel::UpdateSpline()
320 // ---------------------------------------------------------------------------
321 std::vector<manualBaseModel*> manualBaseModel::ExploseModel( )
323 std::vector<manualBaseModel*> lstTmp;
324 lstTmp.push_back(this);
328 // ---------------------------------------------------------------------------
329 double manualBaseModel::GetPathArea()
333 void manualBaseModel::GetNearestPointAndNormal(double *p, double *rp, double *rn)
336 void manualBaseModel::SetCloseContour(bool closeContour)
339 bool manualBaseModel::IfCloseContour()
343 //CMRU 17-08-09----------------------------------------------------------------------------
344 void manualBaseModel::SetLabel(std::string newLabel)
348 void manualBaseModel::SetRealSize(double newRealSize)
352 double manualBaseModel::GetRealSize()
357 std::string manualBaseModel::GetLabel()
361 void manualBaseModel::OpenData(FILE *ff)
364 //----------------------------------------------------------------------------