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