Wildmeshing Toolkit
SimplexComparisons.hxx
Go to the documentation of this file.
1 #pragma once
2 #include <wmtk/Mesh.hpp>
3 #include "SimplexComparisons.hpp"
4 
5 namespace wmtk::simplex::utils {
6 
7 
8 inline bool SimplexComparisons::equal(const Mesh& m, const Simplex& s0, const Simplex& s1)
9 {
10 #if defined(WMTK_ENABLE_SIMPLEX_ID_CACHING)
11  return s0 == s1;
12 #else
13  const auto s0pt = s0.primitive_type();
14  const auto s1pt = s1.primitive_type();
15  const auto s0id = m.id(s0);
16  const auto s1id = m.id(s1);
17  return std::tie(s0pt, s0id) == std::tie(s1pt, s1id);
18 #endif
19  // return equal(m, s0.tuple(), s0.primitive_type(), s1.tuple(), s1.primitive_type());
20 }
22  const Mesh& m,
23  const Tuple& a,
24  PrimitiveType a_pt,
25  const Tuple& b,
26  PrimitiveType b_pt)
27 {
28  return a_pt == b_pt && equal(m, a_pt, a, b);
29 }
31  const Mesh& m,
32  PrimitiveType primitive_type,
33  const Tuple& a,
34  const Tuple& b)
35 {
36  return a == b || m.id(a, primitive_type) == m.id(b, primitive_type);
37 }
38 
39 inline bool SimplexComparisons::equal(const Mesh& m, const IdSimplex& s0, const IdSimplex& s1)
40 {
41  return s0 == s1;
42 }
43 
44 inline bool SimplexComparisons::less(const Mesh& m, const Simplex& s0, const Simplex& s1)
45 {
46 #if defined(WMTK_ENABLE_SIMPLEX_ID_CACHING)
47  return s0 < s1;
48 #else
49  const auto s0pt = s0.primitive_type();
50  const auto s1pt = s1.primitive_type();
51  const auto s0id = m.id(s0);
52  const auto s1id = m.id(s1);
53  return std::tie(s0pt, s0id) < std::tie(s1pt, s1id);
54 #endif
55  // return less(m, s0.tuple(), s0.primitive_type(), s1.tuple(), s1.primitive_type());
56 }
57 
58 inline bool SimplexComparisons::less(const Mesh& m, const IdSimplex& s0, const IdSimplex& s1)
59 {
60  return s0 < s1;
61 }
62 
64  const Mesh& m,
65  const Tuple& a,
66  PrimitiveType a_pt,
67  const Tuple& b,
68  PrimitiveType b_pt)
69 {
70  if (a_pt == b_pt) {
71  return less(m, a_pt, a, b);
72  } else {
73  return a_pt < b_pt;
74  }
75 }
77  const Mesh& m,
78  PrimitiveType primitive_type,
79  const Tuple& a,
80  const Tuple& b)
81 {
82  if (a == b) {
83  return false;
84  }
85  return m.id(a, primitive_type) < m.id(b, primitive_type);
86 }
87 } // namespace wmtk::simplex::utils
int64_t id(const Tuple &tuple, PrimitiveType type) const
return the global id of the Tuple of the given dimension
Definition: Mesh.hpp:1021
PrimitiveType primitive_type() const
Definition: Simplex.hpp:51
static bool equal(const Mesh &m, const Simplex &s0, const Simplex &s1)
static bool less(const Mesh &m, const Simplex &s0, const Simplex &s1)