21using InputSet = uint64_t;
97 static constexpr int max_orientation = 15;
122 for (
size_t i = 0; i <
sizeof(InputSet); ++i) s |= InputSet(m_input_set[i]) << (8 * i);
125 void set_input_set(InputSet s)
127 for (
size_t i = 0; i <
sizeof(InputSet); ++i) m_input_set[i] = uint8_t(s >> (8 * i));
131 uint8_t m_input_set[
sizeof(InputSet)] = {};
138 for (
size_t i = 0; i < N; ++i)
139 for (
size_t j = i + 1; j < N; ++j)
140 if (v[i] > v[j]) ++inversions;
141 return (inversions % 2 == 0) ? 1 : -1;
147 m_orientation = int8_t(std::clamp(o, -max_orientation, max_orientation));
185 sizeof(SurfaceTagAttributes) == 3 +
sizeof(InputSet),
186 "keep the surface tags byte-sized");
Definition SurfaceTagAttributes.h:24
int8_t m_is_bbox_fs
Which bbox side this simplex is on; -1 for none.
Definition SurfaceTagAttributes.h:48
int8_t m_orientation
The input's orientation on this simplex: a signed count of input sheets lying on it,...
Definition SurfaceTagAttributes.h:96
int orientation_along(const std::array< size_t, N > &v) const
The orientation measured against the simplex ordered as v (which must be its vertices).
Definition SurfaceTagAttributes.h:152
InputSet input_set() const
The INPUT SET: which inputs this simplex covers, bit i for input i. At most max_inputs,...
Definition SurfaceTagAttributes.h:119
static int ascending_parity(const std::array< size_t, N > &v)
+1 if v is an even permutation of its ascending sort, -1 if odd. N is 2 or 3.
Definition SurfaceTagAttributes.h:135
static constexpr int max_inputs
One input per bit of InputSet: the width is set there, and only there.
Definition SurfaceTagAttributes.h:130
void set_orientation(int o)
Store an orientation already measured against the ascending vertex order, clamped.
Definition SurfaceTagAttributes.h:145
bool m_is_surface_fs
Is this simplex part of the tracked surface.
Definition SurfaceTagAttributes.h:46
void set_orientation_along(const std::array< size_t, N > &v, int o)
Store orientation o, measured against the simplex ordered as v.
Definition SurfaceTagAttributes.h:159
int8_t m_surface_class
Which tracked surface this simplex belongs to, for applications that track more than one....
Definition SurfaceTagAttributes.h:65
void merge(const SurfaceTagAttributes &attr)
Definition SurfaceTagAttributes.h:175