MorphologicalAttributeFilters
Public API documentation
Loading...
Searching...
No Matches
AttributeComputerRegistry.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "AttributeComputerDomain.hpp"
4#include "AttributeComputerFamily.hpp"
5#include "AreaComputer.hpp"
6#include "BitquadAttributeComputer.hpp"
7#include "BoundingBoxComputer.hpp"
8#include "ContourSideAttributeComputer.hpp"
9#include "GrayLevelStatsComputer.hpp"
10#include "MaxDistComputer.hpp"
11#include "MomentBasedAttributeComputer.hpp"
12#include "TreeTopologyComputer.hpp"
13#include "VolumeComputer.hpp"
14
15#include <algorithm>
16#include <array>
17#include <concepts>
18#include <cstddef>
19#include <cstdint>
20#include <string_view>
21#include <type_traits>
22#include <tuple>
23#include <vector>
24
25namespace mmcfilters::attributes::computers {
26
32namespace detail {
33
37template <class T>
38struct IsAttributeArray : std::false_type {};
39
43template <std::size_t N>
44struct IsAttributeArray<std::array<Attribute, N>> : std::true_type {};
45
49template <class T>
51
52} // namespace detail
53
57template <class Computer>
59 requires {
60 Computer::producedAttributes;
61 } &&
62 detail::IsAttributeArrayV<decltype(Computer::producedAttributes)>;
63
67template <class Computer>
70 requires {
71 { Computer::familyName } -> std::convertible_to<std::string_view>;
72 { Computer::family } -> std::convertible_to<AttributeComputerFamily>;
73 { Computer::domain } -> std::convertible_to<AttributeComputerDomain>;
74 };
75
79template <class Computer, class Real = float>
81 std::floating_point<Real> &&
83 Computer::domain == AttributeComputerDomain::Topology &&
84 requires(
85 const AttributeComputeContext<Real>& context,
86 const UnitAttributeComputeContext<Real>& unitContext) {
87 { Computer::compute(context) } -> std::same_as<void>;
88 { Computer::computeUnitRows(unitContext) } -> std::same_as<void>;
89 };
90
94template <class Computer, class Real = float, class T = std::uint8_t>
96 std::floating_point<Real> &&
99 Computer::domain == AttributeComputerDomain::Altitude &&
100 requires(
101 const AltitudeAttributeComputeContext<Real, T>& context,
102 const AltitudeUnitAttributeComputeContext<Real, T>& unitContext) {
103 { Computer::compute(context) } -> std::same_as<void>;
104 { Computer::computeUnitRows(unitContext) } -> std::same_as<void>;
105 };
106
110template <AttributeComputer Computer>
111[[nodiscard]] constexpr bool producesAttribute(Attribute attribute) noexcept
112{
113 const auto& attributes = Computer::producedAttributes;
114 return std::find(attributes.begin(), attributes.end(), attribute) != attributes.end();
115}
116
120template <AttributeComputer Computer>
121[[nodiscard]] constexpr std::size_t numProducedAttributes() noexcept
122{
123 return Computer::producedAttributes.size();
124}
125
129template <AttributeComputer Computer>
130[[nodiscard]] std::vector<Attribute> runtimeProducedAttributes()
131{
132 const auto& attributes = Computer::producedAttributes;
133 return {attributes.begin(), attributes.end()};
134}
135
139using TopologyAttributeComputers = std::tuple<
148
152using AltitudeAttributeComputers = std::tuple<
155 MaxDistComputer>;
156
171 MaxDistComputer>;
172
173} // namespace mmcfilters::attributes::computers
std::tuple< AreaComputer, BoundingBoxComputer, TreeTopologyComputer, CentralMomentsComputer, HuMomentsComputer, MomentBasedAttributeComputer, BitquadAttributeComputer, ContourSideAttributeComputer > TopologyAttributeComputers
Canonical list of topology/support families known to the backend.
std::vector< Attribute > runtimeProducedAttributes()
Materializes a computer's canonical output list as a runtime vector.
std::tuple< VolumeComputer, GrayLevelStatsComputer, MaxDistComputer > AltitudeAttributeComputers
Canonical list of altitude-aware families known to the pipeline.
std::tuple< AreaComputer, BoundingBoxComputer, TreeTopologyComputer, CentralMomentsComputer, HuMomentsComputer, MomentBasedAttributeComputer, BitquadAttributeComputer, ContourSideAttributeComputer, VolumeComputer, GrayLevelStatsComputer, MaxDistComputer > RegisteredAttributeComputers
Canonical list used by contract tests to cover every public family.
constexpr bool producesAttribute(Attribute attribute) noexcept
Tests whether Computer is the declared producer of attribute.
constexpr bool IsAttributeArrayV
Convenience value for checking whether a type is a canonical attribute array.
constexpr std::size_t numProducedAttributes() noexcept
Number of scalar descriptors declared by the family.
Computes the canonical subtree area attribute.
Computes descriptors derived from the axis-aligned bounding box of the node support.
Computes geometric central moments up to third order.
Computes grey-level statistics derived from subtree aggregation.
Computes higher-level shape descriptors derived from second-order central moments.
Computes structural descriptors that depend only on the tree topology.
Computes cumulative grey-level volume descriptors on the hierarchy.
Value types accepted by generic altitude helpers.
Definition Altitude.hpp:42
Computer concept for families that require a typed altitude span.
Verifies that a computer declares its canonical output list.
Verifies the complete static protocol of one attribute computer.
Computer concept for families that do not read node altitudes.
Owning result for one computed scalar attribute layout and buffer.