owlps/owlps-positioning/area.hh

185 lines
3.4 KiB
C++
Raw Normal View History

#ifndef _OWLPS_POSITIONING_AREA_HH_
#define _OWLPS_POSITIONING_AREA_HH_
class Building ;
#include "point3d.hh"
#include <string>
#include <ostream>
/// Represents an homogeneous area (typically a room) of a Building
class Area
{
protected:
Building *building ; ///< The Building in which the Area is
std::string name ; ///< Name of the Area
Point3D p_min ; ///< First coordinate of the Area
Point3D p_max ; ///< Second coordinate of the Area
public:
/// \brief Constructs an Area from a Building, a name and two 3-float
/// defined points (or default constructor)
Area(const Building *_building = NULL,
const std::string &_name = "Unnamed area",
const float &_x1 = 0, const float &_y1 = 0, const float &_z1 = 0,
const float &_x2 = 0, const float &_y2 = 0, const float &_z2 = 0) ;
/// Copy constructor
Area(const Area &a) ;
~Area(void) {} ///< Destructor (do nothing)
/** @name Read accessors */
//@{
Building* get_building(void) const ; ///< #building read accessor
const std::string& get_name(void) const ; ///< #name read accessor
const Point3D& get_p_min(void) const ; ///< #p_min read accessor
const Point3D& get_p_max(void) const ; ///< #p_max read accessor
//@}
/** @name Write accessors */
//@{
/// #building write accessor
void set_building(const Building *_building) ;
/// #name write accessor
void set_name(const std::string &_name) ;
/// Sets the X of #p_min
void set_x_min(const float &v) ;
/// Sets the Y of #p_min
void set_y_min(const float &v) ;
/// Sets the Z of #p_min
void set_z_min(const float &v) ;
/// Sets the X of #p_max
void set_x_max(const float &v) ;
/// Sets the Y of #p_max
void set_y_max(const float &v) ;
/// Sets the Z of #p_max
void set_z_max(const float &v) ;
/// #p_min write accessor
void set_p_min(const Point3D &p) ;
/// #p_max write accessor
void set_p_max(const Point3D &p) ;
//@}
/** @name Operations */
//@{
/// Checks if a Point3D is into the Area
bool contains_point(const Point3D &p) const ;
//@}
/** @name Operators */
//@{
bool operator==(const Area &a) const ;
bool operator!=(const Area &a) const ;
//@}
/// Displays an Area
friend std::ostream &operator<<(std::ostream &os, const Area &a) ;
} ;
/* *** Read accessors *** */
inline Building* Area::get_building() const
{
return building ;
}
inline const std::string& Area::get_name() const
{
return name ;
}
inline const Point3D& Area::get_p_min() const
{
return p_min ;
}
inline const Point3D& Area::get_p_max() const
{
return p_max ;
}
/* *** Write accessors *** */
inline void Area::set_building(const Building *_building)
{
building = (Building *) _building ;
}
inline void Area::set_name(const std::string &_name)
{
name = _name ;
}
inline void Area::set_x_min(const float &v)
{
p_min.set_x(v) ;
}
inline void Area::set_y_min(const float &v)
{
p_min.set_y(v) ;
}
inline void Area::set_z_min(const float &v)
{
p_min.set_z(v) ;
}
inline void Area::set_x_max(const float &v)
{
p_max.set_x(v) ;
}
inline void Area::set_y_max(const float &v)
{
p_max.set_y(v) ;
}
inline void Area::set_z_max(const float &v)
{
p_max.set_z(v) ;
}
inline void Area::set_p_min(const Point3D &p)
{
p_min = p ;
}
inline void Area::set_p_max(const Point3D &p)
{
p_max = p ;
}
/* *** Operators *** */
inline bool Area::operator!=(const Area &a) const
{
return !(*this == a) ;
}
#endif // _OWLPS_POSITIONING_AREA_HH_