15 #include <mrpt/containers/yaml.h>
16 #include <mrpt/math/TPoint3D.h>
34 "At least one 'output_layer_between' or "
35 "'output_layer_outside' must be provided.");
40 c[
"center"].isSequence() && c[
"center"].asSequence().size() == 3);
42 auto cc = c[
"center"].asSequence();
44 for (
int i = 0; i < 3; i++)
52 mrpt::system::COutputLogger::setLoggerName(
"FilterByRange");
59 MRPT_LOG_DEBUG_STREAM(
"Loading these params:\n" << c);
75 "Input point cloud layer '%s' was not found.",
78 const auto& pc = *pcPtr;
84 pcPtr->GetRuntimeClass()->className);
86 if (outBetween) outBetween->reserve(outBetween->size() + pc.size() / 10);
92 pcPtr->GetRuntimeClass()->className);
94 if (outOutside) outOutside->reserve(outOutside->size() + pc.size() / 10);
96 const auto& xs = pc.getPointsBufferRef_x();
97 const auto& ys = pc.getPointsBufferRef_y();
98 const auto& zs = pc.getPointsBufferRef_z();
103 for (
size_t i = 0; i < xs.size(); i++)
105 const float sqrNorm =
106 (mrpt::math::TPoint3Df(xs[i], ys[i], zs[i]) -
params_.
center)
109 const bool isInside = sqrNorm >= sqrMin && sqrNorm <= sqrMax;
111 auto* targetPc = isInside ? outBetween.get() : outOutside.get();
113 if (targetPc) targetPc->insertPointFrom(pc, i);