World.cpp
Go to the documentation of this file.
00001 
00011 #include <interactive_world_tools/World.h>
00012 #include <stdexcept>
00013 #include <ros/ros.h>
00014 
00015 using namespace std;
00016 using namespace rail::interactive_world;
00017 
00018 World::World()
00019 {
00020 }
00021 
00022 const vector<Room> &World::getRooms() const
00023 {
00024   return rooms_;
00025 }
00026 
00027 size_t World::getNumRooms() const
00028 {
00029   return rooms_.size();
00030 }
00031 
00032 const Room &World::getRoom(const size_t index) const
00033 {
00034   // check the index value first
00035   if (index < rooms_.size())
00036   {
00037     return rooms_[index];
00038   } else
00039   {
00040     throw std::out_of_range("World::getRoom : Room index does not exist.");
00041   }
00042 }
00043 
00044 void World::addRoom(const Room &room)
00045 {
00046   rooms_.push_back(room);
00047 }
00048 
00049 void World::removeRoom(const size_t index)
00050 {
00051   // check the index value first
00052   if (index < rooms_.size())
00053   {
00054     rooms_.erase(rooms_.begin() + index);
00055   } else
00056   {
00057     throw std::out_of_range("World::removeRoom : Room index does not exist.");
00058   }
00059 }
00060 
00061 vector<const Surface *> World::findSurfaces(const string &name)
00062 {
00063   vector<const Surface *> surfaces;
00064   // go through each room
00065   for (size_t i = 0; i < rooms_.size(); i++)
00066   {
00067     try
00068     {
00069       // check the current room
00070       const Surface &s = rooms_[i].findSurface(name);
00071       surfaces.push_back(&s);
00072     } catch (std::out_of_range &e)
00073     {
00074       // ignore, try the next room
00075     }
00076   }
00077 
00078   return surfaces;
00079 }


interactive_world_tools
Author(s): Russell Toris
autogenerated on Thu Jun 6 2019 21:34:15