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 "GrayLevelStatsComputer.hpp"
10#include "MaxDistComputer.hpp"
11#include "MaxDistExactComputer.hpp"
12#include "MomentBasedAttributeComputer.hpp"
13#include "TreeTopologyComputer.hpp"
14#include "VolumeComputer.hpp"
15
16#include <algorithm>
17#include <array>
18#include <concepts>
19#include <cstddef>
20#include <cstdint>
21#include <string_view>
22#include <type_traits>
23#include <tuple>
24#include <vector>
25
26namespace mmcfilters::attributes::computers {
27
33namespace detail {
34
38template <class T> struct IsAttributeArray : std::false_type {};
39
43template <std::size_t N> struct IsAttributeArray<std::array<Attribute, N>> : std::true_type {};
44
48template <class T> inline constexpr bool IsAttributeArrayV = IsAttributeArray<std::remove_cvref_t<T>>::value;
49
50} // namespace detail
51
55template <class Computer>
56concept AttributeComputerProducesAttributes = requires { Computer::producedAttributes; } && detail::IsAttributeArrayV<decltype(Computer::producedAttributes)>;
57
61template <class Computer>
63 { Computer::familyName } -> std::convertible_to<std::string_view>;
64 { Computer::family } -> std::convertible_to<AttributeComputerFamily>;
65 { Computer::domain } -> std::convertible_to<AttributeComputerDomain>;
66};
67
71template <class Computer, class Real = float>
72concept TopologyAttributeComputer = std::floating_point<Real> && AttributeComputer<Computer> && Computer::domain == AttributeComputerDomain::Topology &&
73 requires(const AttributeComputeContext<Real>& context, const UnitAttributeComputeContext<Real>& unitContext) {
74 { Computer::compute(context) } -> std::same_as<void>;
75 { Computer::computeUnitRows(unitContext) } -> std::same_as<void>;
76 };
77
81template <class Computer, class Real = float, class T = std::uint8_t>
83 std::floating_point<Real> && AltitudeValue<T> && AttributeComputer<Computer> && Computer::domain == AttributeComputerDomain::Altitude &&
84 requires(const AltitudeAttributeComputeContext<Real, T>& context, const AltitudeUnitAttributeComputeContext<Real, T>& unitContext) {
85 { Computer::compute(context) } -> std::same_as<void>;
86 { Computer::computeUnitRows(unitContext) } -> std::same_as<void>;
87 };
88
95template <AttributeComputer Computer> [[nodiscard]] constexpr bool producesAttribute(Attribute attribute) noexcept {
96 const auto& attributes = Computer::producedAttributes;
97 return std::find(attributes.begin(), attributes.end(), attribute) != attributes.end();
98}
99
105template <AttributeComputer Computer> [[nodiscard]] constexpr std::size_t numProducedAttributes() noexcept { return Computer::producedAttributes.size(); }
106
112template <AttributeComputer Computer> [[nodiscard]] std::vector<Attribute> runtimeProducedAttributes() {
113 const auto& attributes = Computer::producedAttributes;
114 return {attributes.begin(), attributes.end()};
115}
116
123
127using AltitudeAttributeComputers = std::tuple<VolumeComputer, GrayLevelStatsComputer>;
128
136
137} // namespace mmcfilters::attributes::computers
std::tuple< VolumeComputer, GrayLevelStatsComputer > AltitudeAttributeComputers
Canonical list of altitude-aware families known to the pipeline.
std::tuple< AreaComputer, BoundingBoxComputer, TreeTopologyComputer, CentralMomentsComputer, HuMomentsComputer, MomentBasedAttributeComputer, BitquadAttributeComputer, ContourSideAttributeComputer, VolumeComputer, GrayLevelStatsComputer, MaxDistComputer, MaxDistExactComputer > RegisteredAttributeComputers
Canonical list used by contract tests to cover every public family.
std::vector< Attribute > runtimeProducedAttributes()
Materializes a computer's canonical output list as a runtime vector.
std::tuple< AreaComputer, BoundingBoxComputer, TreeTopologyComputer, CentralMomentsComputer, HuMomentsComputer, MomentBasedAttributeComputer, BitquadAttributeComputer, ContourSideAttributeComputer, MaxDistComputer, MaxDistExactComputer > TopologyAttributeComputers
Canonical list of topology/support families known to the backend.
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.
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.
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.