Wildmeshing Toolkit
TopDimensionCofacesIterable.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <queue>
4 
5 #include <wmtk/Mesh.hpp>
10 
11 namespace wmtk::simplex {
12 
38 {
39 public:
43  enum IteratorPhase { Forward = 0, Intermediate = 1, Backward = 2, End = 3 };
44 
45  class Iterator
46  {
47  public:
48  Iterator(TopDimensionCofacesIterable& container, const Tuple& t = Tuple());
50  bool operator!=(const Iterator& other) const;
51  Tuple& operator*();
52  const Tuple& operator*() const;
53 
54  bool is_intermediate() const;
55 
56  private:
62  PrimitiveType pt(int64_t depth) const;
68  int64_t depth();
69 
73  void init(int64_t depth);
74 
101 
102  void add_neighbors_to_queue();
103 
104  private:
106 
107  Tuple m_t; // the tuple that iterates through the mesh
108  IteratorPhase m_phase = IteratorPhase::Forward; // for depth 1 and 2 iteration
109  bool m_is_intermediate = false;
110  };
111 
112 public:
114  const Mesh& mesh,
115  const Simplex& simplex,
116  const bool retrieve_intermediate_tuple = false);
117 
118  Iterator begin() { return Iterator(*this, m_simplex.tuple()); }
119  Iterator end() { return Iterator(*this); }
120 
121 private:
122  const Mesh& m_mesh;
124 
126 
128  int64_t m_q_front = 0;
130 };
131 
132 } // namespace wmtk::simplex
const Tuple & tuple() const
Definition: Simplex.hpp:53
Iterator & step_depth_1()
There are at max two d-simplices.
PrimitiveType pt(int64_t depth) const
Get the d - depth primitive type.
Iterator & step_depth_0()
Just return the simplex and stop.
int64_t depth()
Compute the depth from the mesh and the simplex type.
Iterator(TopDimensionCofacesIterable &container, const Tuple &t=Tuple())
void init(int64_t depth)
Depending on the depth, the iterator must be initialized differently.
Iterator & step_depth_2()
Iterate around simplex to find all d-simplices.
Iterator & step_depth_3()
Use breadth first search to find all d-simplices.
Iterating through the d-simplices of a mesh can be done in different ways, depending on the simplex d...
IteratorPhase
The IteratorPhase is only used for depth 1 and 2.
TopDimensionCofacesIterable(const Mesh &mesh, const Simplex &simplex, const bool retrieve_intermediate_tuple=false)
simplex::internal::VisitedArray< int64_t > m_visited