17 bool allowEmptyName,
const std::string& classForLayerCreation)
19 mrpt::maps::CPointsMap::Ptr outPc;
21 if (layerName.empty())
26 THROW_EXCEPTION(
"Layer name cannot be empty");
29 if (
auto itLy = m.
layers.find(layerName); itLy != m.
layers.end())
31 outPc = std::dynamic_pointer_cast<mrpt::maps::CPointsMap>(itLy->second);
34 "Layer '%s' must be of point cloud type.", layerName.c_str());
38 auto o = mrpt::rtti::classFactory(classForLayerCreation);
41 "Could not create layer of type '%s' (wrong or "
42 "unregistered class name?)",
43 classForLayerCreation.c_str()));
45 auto newMap = std::dynamic_pointer_cast<mrpt::maps::CPointsMap>(o);
48 "Provided class name '%s' seems not to be derived from "
49 "mrpt::maps::CPointsMap",
50 classForLayerCreation.c_str()));
53 m.
layers[layerName] = newMap;