EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
EBGeometry_LabelId.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2026 Robert Marskar <robert.marskar@sintef.no>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
11#ifndef EBGEOMETRY_LABELID_HPP
12#define EBGEOMETRY_LABELID_HPP
13
14// Std includes
15#include <cstdint>
16#include <type_traits>
17
18// Our includes
19#include "EBGeometry_GPU.hpp"
20
21namespace EBGeometry {
22
31template <class Tag>
32struct LabelId
33{
37 static constexpr uint32_t NoneValue = 0xFFFFFFFFU;
38
42 uint32_t m_value = NoneValue;
43
47 constexpr LabelId() noexcept = default;
48
54 constexpr explicit LabelId(const uint32_t a_value) noexcept : m_value(a_value)
55 {}
56
61 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
62 static constexpr LabelId
63 none() noexcept
64 {
65 return LabelId();
66 }
67
72 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
73 constexpr uint32_t
74 value() const noexcept
75 {
76 return m_value;
77 }
78
83 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
84 constexpr bool
85 isNone() const noexcept
86 {
87 return m_value == NoneValue;
88 }
89
95 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
96 constexpr bool
97 operator==(const LabelId& a_other) const noexcept
98 {
99 return m_value == a_other.m_value;
100 }
101
107 [[nodiscard]] EBGEOMETRY_HOST_DEVICE
108 constexpr bool
109 operator!=(const LabelId& a_other) const noexcept
110 {
111 return m_value != a_other.m_value;
112 }
113};
114
119{
120};
121
126
127static_assert(std::is_trivially_copyable_v<SurfaceLabelId> && sizeof(SurfaceLabelId) == sizeof(uint32_t),
128 "SurfaceLabelId must be a plain 32-bit value, for copies to a device");
129
134{
135};
136
142
143static_assert(std::is_trivially_copyable_v<MaterialLabelId> && sizeof(MaterialLabelId) == sizeof(uint32_t),
144 "MaterialLabelId must be a plain 32-bit value, for copies to a device");
145
146} // namespace EBGeometry
147
148#endif
GPU portability layer: host/device decoration macros and backend detection.
#define EBGEOMETRY_HOST_DEVICE
Mark a function as callable from both host and device code (no-op on host compilers).
Definition EBGeometry_GPU.hpp:80
Namespace containing all of EBGeometry's functionality.
Definition EBGeometry_Affine.hpp:26
LabelId< SurfaceLabelTag > SurfaceLabelId
The number of a surface label: SurfaceLabel() names surfaces, and the tape and ExprIndex number the n...
Definition EBGeometry_LabelId.hpp:125
LabelId< MaterialLabelTag > MaterialLabelId
The number of a material label: MaterialLabel() names the material of a region (see Overlay()),...
Definition EBGeometry_LabelId.hpp:141
The number of a label, typed by what it labels, so that a number of one kind cannot index a table of ...
Definition EBGeometry_LabelId.hpp:33
constexpr uint32_t value() const noexcept
The number, for indexing an array of your own.
Definition EBGeometry_LabelId.hpp:74
constexpr bool isNone() const noexcept
Whether this is no label.
Definition EBGeometry_LabelId.hpp:85
constexpr bool operator!=(const LabelId &a_other) const noexcept
Inequality.
Definition EBGeometry_LabelId.hpp:109
static constexpr LabelId none() noexcept
No label.
Definition EBGeometry_LabelId.hpp:63
uint32_t m_value
The number.
Definition EBGeometry_LabelId.hpp:42
static constexpr uint32_t NoneValue
The number of no label.
Definition EBGeometry_LabelId.hpp:37
constexpr bool operator==(const LabelId &a_other) const noexcept
Equality.
Definition EBGeometry_LabelId.hpp:97
constexpr LabelId() noexcept=default
No label.
The tag of material labels (MaterialLabel()).
Definition EBGeometry_LabelId.hpp:134
The tag of surface labels (SurfaceLabel()).
Definition EBGeometry_LabelId.hpp:119