10 #include <mrpt/core/exceptions.h>
11 #include <mrpt/maps/CSimpleMap.h>
19 const auto& lstCmds =
cli->argCmd.getValue();
21 if (lstCmds.size() != 2 || !
cli->arg_min_corner.isSet() ||
22 !
cli->arg_max_corner.isSet() || !
cli->arg_output.isSet())
28 const auto cornerMin =
29 mrpt::math::TPoint3D::FromString(
cli->arg_min_corner.getValue());
30 const auto cornerMax =
31 mrpt::math::TPoint3D::FromString(
cli->arg_max_corner.getValue());
33 const auto bbox = mrpt::math::TBoundingBox(cornerMin, cornerMax);
37 mrpt::maps::CSimpleMap outSM;
39 for (
const auto& [posePDF, sf, twist] : sm)
42 const auto p = posePDF->getMeanVal();
44 if (!bbox.containsPoint(p.translation()))
continue;
46 outSM.insert(posePDF, sf, twist);
49 const auto outFil =
cli->arg_output.getValue();
51 std::cout <<
"Writing trimmed simplemap with " << outSM.size()
52 <<
" keyframes to '" << outFil <<
"'" << std::endl;
54 outSM.saveToFile(outFil);
64 std::cerr <<
"Error: missing or unknown subcommand.\n";
72 sm-cli trim <filename> --min-corner "[xmin ymin zmin]" --max-corner "[xmax ymax zmax]" --output <OUTPUT.simplemap>
76 return showErrorMsg ? 1 : 0;