15 #include <mrpt/containers/yaml.h>
30 auto cfgIn = c[
"selected_ring_ids"];
40 "YAML configuration must have an entry `selected_ring_ids` "
41 "with a scalar or sequence.");
43 for (
const auto& n : cfgIn.asSequenceRange())
selected_ring_ids.insert(n.as<
int>());
52 MRPT_LOG_DEBUG_STREAM(
"Loading these params:\n" << c);
67 const auto& pc = *pcPtr;
74 pcPtr->GetRuntimeClass()->className);
76 if (outSelected) outSelected->reserve(outSelected->size() + pc.size() / 10);
82 pcPtr->GetRuntimeClass()->className);
84 if (outNonSel) outNonSel->reserve(outNonSel->size() + pc.size() / 10);
87 outSelected || outNonSel,
88 "At least one of 'output_layer_selected' or "
89 "'output_layer_non_selected' must be provided.");
91 const auto& xs = pc.getPointsBufferRef_x();
94 const auto* ptrR = pc.getPointsBufferRef_ring();
95 if (!ptrR || ptrR->empty())
98 "Error: this filter needs the input layer '%s' to has an "
99 "'ring' point channel.",
103 const auto& Rs = *ptrR;
104 ASSERT_EQUAL_(Rs.size(), xs.size());
105 const size_t N = xs.size();
107 size_t countSel = 0, countNon = 0;
109 for (
size_t i = 0; i < N; i++)
111 const auto R = Rs[i];
113 mrpt::maps::CPointsMap* trg =
nullptr;
117 trg = outSelected.get();
122 trg = outNonSel.get();
126 if (trg) trg->insertPointFrom(pc, i);
129 MRPT_LOG_DEBUG_STREAM(
130 "[FilterByRing] Input points=" << N <<
" selected=" << countSel
131 <<
" non-selected=" << countNon);