#include "area.hh" /*** Constructeurs ***/ Area::Area(const Building &_building, const string &_name, const float &_x1, const float &_y1, const float &_z1, const float &_x2, const float &_y2, const float &_z2) { building = (Building *) &_building ; name = _name ; float x_min, x_max, y_min, y_max, z_min, z_max ; 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 ; } p_min = Point3D(x_min, y_min, z_min) ; p_max = Point3D(x_max, y_max, z_max) ; #ifdef DEBUG_2 cout << "Area created : "<< area_name << p_min << "," << p_max << endl ; #endif // DEBUG_2 } Area::Area(const Area &a) { building = a.building ; name = a.name ; p_min = a.p_min ; p_max = a.p_max ; } /*** Accesseurs lecture ***/ Building* Area::get_building(void) const { return building ; } string Area::get_name() const { return name ; } Point3D Area::get_p_min() const { return p_min ; } Point3D Area::get_p_max() const { return p_max ; } /*** Accesseurs écriture ***/ void Area::set_building(const Building &_building) { building = (Building *) &_building ; } void Area::set_name(const string &_name) { name = _name ; } void Area::set_x_min(const float &v) { p_min.set_x(v) ; } void Area::set_y_min(const float &v) { p_min.set_y(v) ; } void Area::set_z_min(const float &v) { p_min.set_z(v) ; } void Area::set_x_max(const float &v) { p_max.set_x(v) ; } void Area::set_y_max(const float &v) { p_max.set_y(v) ; } void Area::set_z_max(const float &v) { p_max.set_z(v) ; } void Area::set_p_min(const Point3D &p) { p_min = p ; } void Area::set_p_max(const Point3D &p) { p_max = p ; } bool Area::contains_point(const Point3D &p) const { return p.get_x() >= p_min.get_x() && p.get_x() <= p_max.get_x() && p.get_y() >= p_min.get_y() && p.get_y() <= p_max.get_y() && p.get_z() >= p_min.get_z() && p.get_z() <= p_max.get_z() ; } bool Area::operator==(const Area &a) const { if (this == &a) return true ; return building == a.building && name == a.name && p_min == a.p_min && p_max == a.p_max ; } bool Area::operator!=(const Area &a) const { return !(*this == a) ; } ostream &operator<<(ostream &os, const Area &a) { os << a.name << ';' << a.p_min.get_x() << ';' << a.p_max.get_x() << ';' << a.p_min.get_y() << ';' << a.p_max.get_y() << ';' << a.p_min.get_z() << ';' << a.p_max.get_z() ; return os ; }