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 )
202 // ----------------------------------------------------------------------------
203 manualPoint* manualBaseModel::GetManualPoint(int id)
205 return _lstPoints[id];
207 // ----------------------------------------------------------------------------
208 int manualBaseModel::GetSizeLstPoints()
210 return _lstPoints.size();
213 // ----------------------------------------------------------------------------
214 manualBaseModel * manualBaseModel :: Clone() // virtual
216 manualBaseModel * clone = new manualBaseModel();
217 CopyAttributesTo(clone);
221 // ----------------------------------------------------------------------------
222 int manualBaseModel::GetTypeModel() //virtual
235 // ---------------------------------------------------------------------------
237 void manualBaseModel::CopyAttributesTo( manualBaseModel * cloneObject)
239 int i, size = GetSizeLstPoints();
240 for( i=0; i<size; i++ )
242 cloneObject->AddManualPoint( GetManualPoint( i )->Clone() );
247 // ---------------------------------------------------------------------------
248 void manualBaseModel::AddManualPoint( manualPoint* theManualPoint )
250 _lstPoints.push_back( theManualPoint );
253 void manualBaseModel::Open(FILE *ff) // virtual
256 void manualBaseModel::Save(FILE *ff) // virtual
260 void manualBaseModel::SaveData(FILE *ff)// virtual
265 // ---------------------------------------------------------------------------
266 void manualBaseModel::SetNumberOfPointsSpline(int size)
268 _sizePointsContour = size;
271 double manualBaseModel::GetPathSize()
276 void manualBaseModel::Transform_Ax_Plus_B (double Ax, double Bx, double Ay, double By)
280 void manualBaseModel::GetSpline_i_Point(int i, double *x, double *y, double *z)
282 //RaC 20-09-09 IF it's a points contour
283 if(GetTypeModel()==7){
284 if (_lstPoints.size()==0)
303 void manualBaseModel::GetSpline_t_Point(double t, double *x, double *y, double *z)
307 // ---------------------------------------------------------------------------
308 int manualBaseModel::GetNumberOfPointsSpline()
311 //RaC 20-09-09 IF it's a points contour
312 if(GetTypeModel()==7){
313 return _lstPoints.size();
315 return _sizePointsContour;
318 // ---------------------------------------------------------------------------
319 void manualBaseModel::UpdateSpline()
323 // ---------------------------------------------------------------------------
324 std::vector<manualBaseModel*> manualBaseModel::ExploseModel( )
326 std::vector<manualBaseModel*> lstTmp;
327 lstTmp.push_back(this);
331 // ---------------------------------------------------------------------------
332 double manualBaseModel::GetPathArea()
336 void manualBaseModel::GetNearestPointAndNormal(double *p, double *rp, double *rn)
339 void manualBaseModel::SetCloseContour(bool closeContour)
342 bool manualBaseModel::IfCloseContour()
346 //CMRU 17-08-09----------------------------------------------------------------------------
347 void manualBaseModel::SetLabel(std::string newLabel)
351 void manualBaseModel::SetRealSize(double newRealSize)
355 double manualBaseModel::GetRealSize()
360 std::string manualBaseModel::GetLabel()
364 void manualBaseModel::OpenData(FILE *ff)
367 //----------------------------------------------------------------------------