00001 /* 00002 * VisualizationFactory.cpp 00003 * 00004 * Created on: Mar 20, 2015 00005 * Author: Péter Fankhauser 00006 * Institute: ETH Zurich, Autonomous Systems Lab 00007 */ 00008 00009 #include <grid_map_visualization/visualizations/VisualizationFactory.hpp> 00010 #include <grid_map_visualization/visualizations/PointCloudVisualization.hpp> 00011 #include <grid_map_visualization/visualizations/FlatPointCloudVisualization.hpp> 00012 #include <grid_map_visualization/visualizations/VectorVisualization.hpp> 00013 #include <grid_map_visualization/visualizations/OccupancyGridVisualization.hpp> 00014 #include <grid_map_visualization/visualizations/GridCellsVisualization.hpp> 00015 #include <grid_map_visualization/visualizations/MapRegionVisualization.hpp> 00016 00017 // STL 00018 #include <algorithm> 00019 00020 namespace grid_map_visualization { 00021 00022 VisualizationFactory::VisualizationFactory(ros::NodeHandle& nodeHandle) 00023 : nodeHandle_(nodeHandle) 00024 { 00025 types_.push_back("point_cloud"); 00026 types_.push_back("flat_point_cloud"); 00027 types_.push_back("vectors"); 00028 types_.push_back("occupancy_grid"); 00029 types_.push_back("grid_cells"); 00030 types_.push_back("map_region"); 00031 } 00032 00033 VisualizationFactory::~VisualizationFactory() 00034 { 00035 } 00036 00037 bool VisualizationFactory::isValidType(const std::string& type) 00038 { 00039 return end(types_) != std::find(begin(types_), end(types_), type); 00040 } 00041 00042 std::shared_ptr<VisualizationBase> VisualizationFactory::getInstance(const std::string& type, 00043 const std::string& name) 00044 { 00045 // TODO: Make this nicer: http://stackoverflow.com/questions/9975672/c-automatic-factory-registration-of-derived-types 00046 if (type == "point_cloud") return std::shared_ptr<VisualizationBase>(new PointCloudVisualization(nodeHandle_, name)); 00047 if (type == "flat_point_cloud") return std::shared_ptr<VisualizationBase>(new FlatPointCloudVisualization(nodeHandle_, name)); 00048 if (type == "vectors") return std::shared_ptr<VisualizationBase>(new VectorVisualization(nodeHandle_, name)); 00049 if (type == "occupancy_grid") return std::shared_ptr<VisualizationBase>(new OccupancyGridVisualization(nodeHandle_, name)); 00050 if (type == "grid_cells") return std::shared_ptr<VisualizationBase>(new GridCellsVisualization(nodeHandle_, name)); 00051 if (type == "map_region") return std::shared_ptr<VisualizationBase>(new MapRegionVisualization(nodeHandle_, name)); 00052 return std::shared_ptr<VisualizationBase>(); 00053 } 00054 00055 } /* namespace grid_map_visualization */