#include "area.hh" Area::Area(const string &_name, const float &_x1, const float &_x2, const float &_y1, const float &_y2, const float &_z1, const float &_z2) { area_name = _name ; if (_x1 < _x2 && _y1 > _y2) // Le premier point de la pièce est en haut à gauche { x_min = _x1 ; x_max = _x2 ; y_min = _y2 ; // on inverse les Y y_max = _y1 ; } else if (_x1 > _x2 && _y1 < _y2) // Le premier point de la pièce est en bas à droite { x_min = _x2 ; // on inverse les X x_max = _x1 ; y_min = _y1 ; y_max = _y2 ; } else if (_x1 > _x2 && _z1 > _z2) // Le premier point de la pièce est en haut à droite { x_min = _x2 ; // on inverse les X x_max = _x1 ; z_min = _z2 ; // on inverse les Y z_max = _z1 ; } else // Le premier point de la pièce est en bas à gauche ou autres cas (par ex. coordonnées nulles) { x_min = _x1 ; x_max = _x2 ; y_min = _y1 ; y_max = _y2 ; } if (_z1 < _z2) { z_min = _z1 ; z_max = _z2 ; } else { z_min = _z2 ; z_max = _z1 ; } #ifdef DEBUG_2 cout << "Area créée ("<< area_name << ',' << x_min << ',' << y_min << ',' << x_max << ',' << y_max << ',' << z_min << ',' << z_max << ")" << endl ; #endif // DEBUG_2 } Area::Area(const Area &a) { area_name = a.area_name; x_min = a.x_min; x_max = a.x_max; y_min = a.y_min; y_max = a.y_max; z_min = a.z_min; z_max = a.z_max; } bool Area::containsPoint(const Point &p)const { if (p.getX() >= x_min && p.getX() <= x_max && p.getY() >= y_min && p.getY() <= y_max && p.getZ() >= z_min && p.getZ() <= z_max ) return true; return false; } bool Area::operator==(const Area &a)const { if (area_name == a.area_name && x_min == a.x_min && x_max == a.x_max && y_min == a.y_min && y_max == a.y_max && z_min == a.z_min && z_max == a.z_max ) return true ; return false ; } ostream &operator<<(ostream &os, const Area &a) { os << a.area_name << ';' << a.x_min << ';' << a.x_max << ';' << a.y_min << ';' << a.y_max << ';' << a.z_min << ';' << a.z_max ; return os ; }