74 [[nodiscard]]
constexpr label_t label(Node node)
const
76 auto [
index, offset] = derived().indexAndOffset(node);
77 return label_[
index][offset];
80 [[nodiscard]] label_t label(Code code)
const
82 auto [
index, offset] = derived().indexAndOffset(code);
83 return label_[
index][offset];
86 [[nodiscard]] label_t label(Key key)
const {
return label(derived().toCode(key)); }
88 [[nodiscard]] label_t label(Point coord, depth_t depth = 0)
const
90 return label(derived().toCode(coord, depth));
112 template <
class Derived2>
125 template <
class Derived2>
136 void swap(
LabelMap& other)
noexcept { std::swap(prop_criteria_, other.prop_criteria_); }
142 [[nodiscard]]
constexpr Derived& derived() {
return *
static_cast<Derived*
>(
this); }
144 [[nodiscard]]
constexpr Derived
const& derived()
const
146 return *
static_cast<Derived const*
>(
this);
153 void initRoot() { label_[derived().rootIndex()][derived().rootOffset()].clear(); }
159 void fill(index_t
index, index_t parent_index, index_t parent_offset)
161 intensity_[
index].fill(intensity_[parent_index][parent_offset]);
170 void clearImpl(index_t
index) {}
176 void updateBlock(pos_t block)
181 void updateNode(index_t
index, index_t offset, index_t children_index)
183 switch (intensityPropagationCriteria()) {
184 case PropagationCriteria::MIN:
185 intensity_[
index][offset] =
min(intensity_[children_index]);
187 case PropagationCriteria::MAX:
188 intensity_[
index][offset] =
max(intensity_[children_index]);
190 case PropagationCriteria::MEAN:
191 intensity_[
index][offset] = mean(intensity_[children_index]);
200 [[nodiscard]]
constexpr bool isCollapsible(index_t
index)
const
202 return std::all_of(std::begin(intensity_[
index]) + 1, std::end(intensity_[
index]),
203 [t = intensity_[
index].front()](
auto e) {
return e == t; });
206 void preparePrune(Index node) {}
212 [[nodiscard]]
static constexpr MapType mapType()
noexcept {
return MapType::INTENSITY; }
214 [[nodiscard]]
static constexpr bool canReadData(MapType mt)
noexcept
216 return mapType() == mt;
219 template <
class InputIt>
220 std::size_t serializedSize(InputIt first, InputIt last)
const
222 return std::distance(first, last) * N *
sizeof(intensity_t);
225 template <
class OutputIt>
226 void readNodes(
ReadBuffer& in, OutputIt first, OutputIt last)
228 for (; first != last; ++first) {
229 if (first->offsets.all()) {
230 in.read(intensity_[first->index].data(), N *
sizeof(intensity_t));
232 std::array<intensity_t, N> intensity;
233 in.read(intensity.data(), N *
sizeof(intensity_t));
234 for (index_t i = 0; N != i; ++i) {
235 if (first->offsets[i]) {
236 intensity_[first->index][i] = intensity[i];
243 template <
class BlockRange>
244 void writeBlocks(
WriteBuffer& out, BlockRange
const& blocks)
const
246 for (
auto block : blocks) {
253 std::deque<LabelSet> label_;
255 template <
class Derived2, std::
size_t N2>
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > max(Geometry const &g)
Returns the maximum coordinate of the minimum spanning axis-aligned bounding box of a geometry.
constexpr Vec< Geometry::dimension(), typename Geometry::value_type > min(Geometry const &g)
Returns the minimum coordinate of the minimum spanning axis-aligned bounding box of a geometry.