Wildmeshing Toolkit
Loading...
Searching...
No Matches
PrimitiveType.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <stdexcept>
4#include <string_view>
5#include <vector>
6
7namespace wmtk {
8
9enum class PrimitiveType : int8_t { Vertex = 0, Edge = 1, Triangle = 2, Tetrahedron = 3 };
10
11
18constexpr inline int8_t get_primitive_type_id(PrimitiveType t)
19{
20 return static_cast<int8_t>(t);
21}
22
23constexpr inline PrimitiveType operator-(PrimitiveType pt, int8_t n) {
24 return static_cast<PrimitiveType>(static_cast<int8_t>(pt)-n);
25}
26constexpr inline PrimitiveType operator+(PrimitiveType pt, int8_t n) {
27 return static_cast<PrimitiveType>(static_cast<int8_t>(pt)+n);
28}
29
30constexpr inline bool operator==(PrimitiveType a, PrimitiveType b)
31{
33}
34constexpr inline bool operator!=(PrimitiveType a, PrimitiveType b)
35{
37}
38constexpr inline bool operator<(PrimitiveType a, PrimitiveType b)
39{
41}
42constexpr inline bool operator>(PrimitiveType a, PrimitiveType b)
43{
45}
46constexpr inline bool operator<=(PrimitiveType a, PrimitiveType b)
47{
49}
50constexpr inline bool operator>=(PrimitiveType a, PrimitiveType b)
51{
53}
54
55
59constexpr inline PrimitiveType get_primitive_type_from_id(int8_t id)
60{
61 return static_cast<PrimitiveType>(id);
62}
63
70int8_t get_max_primitive_type_id(const std::vector<PrimitiveType>& primitive_types);
71
72std::string_view primitive_type_name(PrimitiveType t);
73
74} // namespace wmtk
constexpr bool operator<=(PrimitiveType a, PrimitiveType b)
constexpr bool operator>=(PrimitiveType a, PrimitiveType b)
constexpr bool operator!=(PrimitiveType a, PrimitiveType b)
constexpr bool operator==(PrimitiveType a, PrimitiveType b)
std::string_view primitive_type_name(PrimitiveType t)
constexpr PrimitiveType get_primitive_type_from_id(int8_t id)
Get the primitive type corresponding to its unique integer id.
constexpr int8_t get_primitive_type_id(PrimitiveType t)
Get a unique integer id corresponding to each primitive type.
int8_t get_max_primitive_type_id(const std::vector< PrimitiveType > &primitive_types)
Get the maximum id for a list of primitive types.
constexpr PrimitiveType operator-(PrimitiveType pt, int8_t n)
constexpr bool operator<(PrimitiveType a, PrimitiveType b)
constexpr PrimitiveType operator+(PrimitiveType pt, int8_t n)
constexpr bool operator>(PrimitiveType a, PrimitiveType b)