Go to the documentation of this file.00001
00011 #include <boost/algorithm/string.hpp>
00012 #include <interactive_world_tools/Room.h>
00013 #include <stdexcept>
00014
00015 using namespace std;
00016 using namespace rail::interactive_world;
00017
00018 Room::Room(const string &name, const string &frame_id) : name_(name), frame_id_(frame_id)
00019 {
00020 }
00021
00022 const string &Room::getName() const
00023 {
00024 return name_;
00025 }
00026
00027 void Room::setName(const string &name)
00028 {
00029 name_ = name;
00030 }
00031
00032 const string &Room::getFrameID() const
00033 {
00034 return frame_id_;
00035 }
00036
00037 void Room::setFrameID(const string &frame_id)
00038 {
00039 frame_id_ = frame_id;
00040 }
00041
00042 const vector<Surface> &Room::getSurfaces() const
00043 {
00044 return surfaces_;
00045 }
00046
00047 size_t Room::getNumSurfaces() const
00048 {
00049 return surfaces_.size();
00050 }
00051
00052 const Surface &Room::getSurface(const size_t index) const
00053 {
00054
00055 if (index < surfaces_.size())
00056 {
00057 return surfaces_[index];
00058 } else
00059 {
00060 throw std::out_of_range("Room::getSurface : Surface index does not exist.");
00061 }
00062 }
00063
00064 void Room::addSurface(const Surface &room)
00065 {
00066 surfaces_.push_back(room);
00067 }
00068
00069 void Room::removeSurface(const size_t index)
00070 {
00071
00072 if (index < surfaces_.size())
00073 {
00074 surfaces_.erase(surfaces_.begin() + index);
00075 } else
00076 {
00077 throw std::out_of_range("Room::removeSurface : Surface index does not exist.");
00078 }
00079 }
00080
00081 const Surface &Room::findSurface(const string &name) const
00082 {
00083
00084 string name_uc = boost::to_upper_copy(name);
00085 for (size_t i = 0; i < surfaces_.size(); i++)
00086 {
00087
00088 if (boost::to_upper_copy(surfaces_[i].getName()) == name_uc)
00089 {
00090 return surfaces_[i];
00091 }
00092
00093
00094 for (size_t j = 0; j < surfaces_[i].getNumAliases(); j++)
00095 {
00096 if (boost::to_upper_copy(surfaces_[i].getAlias(j)) == name_uc)
00097 {
00098 return surfaces_[i];
00099 }
00100 }
00101 }
00102 throw std::out_of_range("Room::findSurface : Surface name does not exist.");
00103 }