mmcfilters
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 "FilledShapeAttributeComputer.hpp"
10#include "GrayLevelStatsComputer.hpp"
11#include "MaxDistComputer.hpp"
12#include "MaxDistExactComputer.hpp"
13#include "MomentBasedAttributeComputer.hpp"
14#include "TreeTopologyComputer.hpp"
15#include "VolumeComputer.hpp"
16
17#include <algorithm>
18#include <array>
19#include <concepts>
20#include <cstddef>
21#include <cstdint>
22#include <string_view>
23#include <type_traits>
24#include <tuple>
25#include <vector>
26
27namespace mmcfilters::attributes::computers {
28
34namespace detail {
35
39template <class T> struct IsAttributeArray : std::false_type {};
40
44template <std::size_t N> struct IsAttributeArray<std::array<Attribute, N>> : std::true_type {};
45
49template <class T> inline constexpr bool IsAttributeArrayV = IsAttributeArray<std::remove_cvref_t<T>>::value;
50
51} // namespace detail
52
56template <class Computer>
57concept AttributeComputerProducesAttributes = requires { Computer::producedAttributes; } && detail::IsAttributeArrayV<decltype(Computer::producedAttributes)>;
58
62template <class Computer>
64 { Computer::familyName } -> std::convertible_to<std::string_view>;
65 { Computer::family } -> std::convertible_to<AttributeComputerFamily>;
66 { Computer::domain } -> std::convertible_to<AttributeComputerDomain>;
67};
68
72template <class Computer, class Real = float>
73concept TopologyAttributeComputer = std::floating_point<Real> && AttributeComputer<Computer> && Computer::domain == AttributeComputerDomain::Topology &&
74 requires(const AttributeComputeContext<Real>& context, const UnitAttributeComputeContext<Real>& unitContext) {
75 { Computer::compute(context) } -> std::same_as<void>;
76 { Computer::computeUnitRows(unitContext) } -> std::same_as<void>;
77 };
78
82template <class Computer, class Real = float, class T = std::uint8_t>
84 std::floating_point<Real> && AltitudeValue<T> && AttributeComputer<Computer> && Computer::domain == AttributeComputerDomain::Altitude &&
85 requires(const AltitudeAttributeComputeContext<Real, T>& context, const AltitudeUnitAttributeComputeContext<Real, T>& unitContext) {
86 { Computer::compute(context) } -> std::same_as<void>;
87 { Computer::computeUnitRows(unitContext) } -> std::same_as<void>;
88 };
89
96template <AttributeComputer Computer> [[nodiscard]] constexpr bool producesAttribute(Attribute attribute) noexcept {
97 const auto& attributes = Computer::producedAttributes;
98 return std::find(attributes.begin(), attributes.end(), attribute) != attributes.end();
99}
100
106template <AttributeComputer Computer> [[nodiscard]] constexpr std::size_t numProducedAttributes() noexcept { return Computer::producedAttributes.size(); }
107
113template <AttributeComputer Computer> [[nodiscard]] std::vector<Attribute> runtimeProducedAttributes() {
114 const auto& attributes = Computer::producedAttributes;
115 return {attributes.begin(), attributes.end()};
116}
117
124
128using AltitudeAttributeComputers = std::tuple<VolumeComputer, GrayLevelStatsComputer>;
129
137
138} // namespace mmcfilters::attributes::computers
std::tuple< AreaComputer, BoundingBoxComputer, TreeTopologyComputer, CentralMomentsComputer, HuMomentsComputer, MomentBasedAttributeComputer, BitquadAttributeComputer, ContourSideAttributeComputer, VolumeComputer, GrayLevelStatsComputer, MaxDistComputer, MaxDistExactComputer, FilledShapeAttributeComputer > RegisteredAttributeComputers
Canonical list used by contract tests to cover every public family.
std::tuple< VolumeComputer, GrayLevelStatsComputer > AltitudeAttributeComputers
Canonical list of altitude-aware families known to the pipeline.
std::vector< Attribute > runtimeProducedAttributes()
Materializes a computer's canonical output list as a runtime vector.
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.
std::tuple< AreaComputer, BoundingBoxComputer, TreeTopologyComputer, CentralMomentsComputer, HuMomentsComputer, MomentBasedAttributeComputer, BitquadAttributeComputer, ContourSideAttributeComputer, MaxDistComputer, MaxDistExactComputer, FilledShapeAttributeComputer > TopologyAttributeComputers
Canonical list of topology/support families known to the backend.
constexpr std::size_t numProducedAttributes() noexcept
Number of scalar descriptors declared by the family.
Computes the canonical subtree area attribute.
Bitquad scalar computer backed by finite-window computation.
Computes descriptors derived from the axis-aligned bounding box of the node support.
Computes geometric central moments up to third order.
Shape descriptors of the region enclosed by the external boundary.
Computes grey-level statistics derived from subtree aggregation.
Topology-only approximate distance-transform attribute computer.
Topology-only scalar computer for attributes derived from the node EDT.
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:39
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.