mmcfilters
Public API documentation
Loading...
Searching...
No Matches
ContourSideAttributeComputer.hpp
1#pragma once
2
3#include "AttributeComputerDomain.hpp"
4#include "AttributeComputerFamily.hpp"
5#include "../detail/AttributeKernelSupport.hpp"
6#include "detail/ContourSideAttributeMaterialization.hpp"
7#include "detail/ContourSideFiniteWindowComputation.hpp"
8#include "../../utils/Contract.hpp"
9
10#include <array>
11#include <concepts>
12#include <span>
13#include <string_view>
14
15namespace mmcfilters::attributes::computers {
16
17namespace detail {
18
19namespace kernel {
20
26template <std::floating_point Real>
27inline void computeContourSideAttributes(const AttributeComputeContext<Real>& context, const ContourSideRequest& request) {
28 if (!request.any()) {
29 return;
30 }
31
32 const std::vector<ContourSideCounts> sideCounts = computeContourSideCounts(context.tree);
33 materializeContourSideAttributes(context, request, sideCounts);
34}
35
36} // namespace kernel
37
38template <std::floating_point Real> inline void validateContourSideContext(const AttributeComputeContext<Real>& context) {
39 requireAttributeBufferShape(context.tree, context.buffer, context.attrNames);
40 requireRequestedAttributeColumns(context);
41 local_attributes::detail::validateFiniteWindowLocalAttributeInput(context.tree);
42}
43
44} // namespace detail
45
63 public:
65 static constexpr std::string_view familyName = "contour-side";
66
68 static constexpr AttributeComputerFamily family = AttributeComputerFamily::ContourSide;
69
71 static constexpr AttributeComputerDomain domain = AttributeComputerDomain::Topology;
72
76 inline static constexpr std::array<Attribute, 6> producedAttributes{ContourPixels, ContourPerimeter, ContourSideNorth,
77 ContourSideWest, ContourSideEast, ContourSideSouth};
78
91 template <std::floating_point Real> static void compute(const AttributeComputeContext<Real>& context) {
92 const detail::ContourSideRequest request = detail::ContourSideRequest::from(context.requestedAttributes);
93 MMCFILTERS_CONTRACT_CHECKED_ONLY(detail::validateContourSideContext(context));
94 detail::kernel::computeContourSideAttributes(context, request);
95 }
96
97 public:
106 template <std::floating_point Real> static void computeUnitRows(const UnitAttributeComputeContext<Real>& context) {
107 detail::ContourSideAttributeMaterialization::materializeUnitContourSideAttributes(context.tree, context.unitPixels, context.buffer,
108 context.attrNames, context.requestedAttributes);
109 }
110};
111
112} // namespace mmcfilters::attributes::computers
#define MMCFILTERS_CONTRACT_CHECKED_ONLY(...)
Executes validation statements only when defensive checks are enabled.
Definition Contract.hpp:67
static constexpr std::array< Attribute, 6 > producedAttributes
Canonical list of scalar contour attributes materialized by this computer.
static constexpr AttributeComputerDomain domain
Execution domain required by the computer.
static void computeUnitRows(const UnitAttributeComputeContext< Real > &context)
Materializes contour-side attributes for one-pixel unit supports.
static void compute(const AttributeComputeContext< Real > &context)
Computes requested contour-side scalar attributes for live nodes.
static constexpr std::string_view familyName
Family name used in dependency-plan diagnostics.
static constexpr AttributeComputerFamily family
Stable family id used by the scheduler.
Owning result for one computed scalar attribute layout and buffer.