Wildmeshing Toolkit
IdSimplexCollection.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <wmtk/Mesh.hpp>
5 #include "IdSimplex.hpp"
6 
7 namespace wmtk::simplex {
9 {
10 public:
11  IdSimplexCollection(const Mesh& mesh, std::vector<IdSimplex>&& simplices = {})
12  : m_mesh{mesh}
13  , m_simplices(std::move(simplices))
14  {
15  m_simplices.reserve(100);
16  }
17 
21  const std::vector<IdSimplex>& simplex_vector() const { return m_simplices; }
25  std::vector<IdSimplex> simplex_vector(const PrimitiveType& ptype) const;
26 
27  const Mesh& mesh() const;
28 
32  std::vector<Tuple> simplex_vector_tuples(PrimitiveType ptype) const;
33 
39  void add(const IdSimplex& simplex);
40 
41  void add(const IdSimplexCollection& simplex_collection);
42 
43  void add(const PrimitiveType ptype, const std::vector<Tuple>& tuple_vec);
44 
45  void add(const PrimitiveType ptype, const Tuple& tuple);
49  void sort_and_clean();
50  void sort();
51 
57  bool contains(const IdSimplex& simplex) const;
58 
65  const IdSimplexCollection& collection_a,
66  const IdSimplexCollection& collection_b);
67 
74  const IdSimplexCollection& collection_a,
75  const IdSimplexCollection& collection_b);
76 
83  const IdSimplexCollection& collection_a,
84  const IdSimplexCollection& collection_b);
85 
86 
87  auto begin() { return m_simplices.begin(); }
88  auto end() { return m_simplices.end(); }
89  auto begin() const { return m_simplices.begin(); }
90  auto end() const { return m_simplices.end(); }
91  auto cbegin() const { return m_simplices.cbegin(); }
92  auto cend() const { return m_simplices.cend(); }
93 
94  bool operator==(const IdSimplexCollection& other) const;
95 
96  inline size_t size() const { return m_simplices.size(); }
97 
98  void reserve(const size_t new_cap);
99 
100 
101 protected:
102  const Mesh& m_mesh;
103  std::vector<IdSimplex> m_simplices;
104 };
105 } // namespace wmtk::simplex
void sort_and_clean()
Sort simplex vector and remove duplicates.
static IdSimplexCollection get_intersection(const IdSimplexCollection &collection_a, const IdSimplexCollection &collection_b)
Get intersection of two simplex collections.
void add(const IdSimplex &simplex)
Add simplex to the collection.
bool operator==(const IdSimplexCollection &other) const
static IdSimplexCollection get_union(const IdSimplexCollection &collection_a, const IdSimplexCollection &collection_b)
Get union of two simplex collections.
std::vector< Tuple > simplex_vector_tuples(PrimitiveType ptype) const
Return vector of all simplices of the requested type, as tuples.
const std::vector< IdSimplex > & simplex_vector() const
Return const reference to the simplex vector.
bool contains(const IdSimplex &simplex) const
Check if simplex is contained in collection.
IdSimplexCollection(const Mesh &mesh, std::vector< IdSimplex > &&simplices={})
static bool are_simplex_collections_equal(const IdSimplexCollection &collection_a, const IdSimplexCollection &collection_b)
Check if the two simplex collections are equal.