Wildmeshing Toolkit
SimplexCollection.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vector>
4 #include <wmtk/Mesh.hpp>
5 #include "Simplex.hpp"
8 
9 namespace wmtk::simplex {
11 {
12 public:
13  SimplexCollection(const Mesh& mesh, std::vector<Simplex>&& simplices = {})
14  : m_mesh{mesh}
15  , m_simplices(std::move(simplices))
18  {
19  m_simplices.reserve(100);
20  }
21 
25  const std::vector<Simplex>& simplex_vector() const { return m_simplices; }
29  std::vector<Simplex> simplex_vector(const PrimitiveType& ptype) const;
30 
31  const Mesh& mesh() const;
32 
36  std::vector<Tuple> simplex_vector_tuples(PrimitiveType ptype) const;
37 
43  void add(const Simplex& simplex);
44 
45  void add(const SimplexCollection& simplex_collection);
46 
47  void add(const PrimitiveType ptype, const std::vector<Tuple>& tuple_vec);
48 
49  void add(const PrimitiveType ptype, const Tuple& tuple);
53  void sort_and_clean();
54  void sort();
55 
61  bool contains(const Simplex& simplex) const;
62 
69  const SimplexCollection& collection_a,
70  const SimplexCollection& collection_b);
71 
78  const SimplexCollection& collection_a,
79  const SimplexCollection& collection_b);
80 
87  const SimplexCollection& collection_a,
88  const SimplexCollection& collection_b);
89 
90 
91  auto begin() { return m_simplices.begin(); }
92  auto end() { return m_simplices.end(); }
93  auto begin() const { return m_simplices.begin(); }
94  auto end() const { return m_simplices.end(); }
95  auto cbegin() const { return m_simplices.cbegin(); }
96  auto cend() const { return m_simplices.cend(); }
97 
98  bool operator==(const SimplexCollection& other) const;
99 
100  inline size_t size() const { return m_simplices.size(); }
101 
102  void reserve(const size_t new_cap);
103 
104 
105 protected:
106  const Mesh& m_mesh;
107  std::vector<Simplex> m_simplices;
108 
109 protected:
112 };
113 } // namespace wmtk::simplex
static bool are_simplex_collections_equal(const SimplexCollection &collection_a, const SimplexCollection &collection_b)
Check if the two simplex collections are equal.
void reserve(const size_t new_cap)
void add(const Simplex &simplex)
Add simplex to the collection.
static SimplexCollection get_union(const SimplexCollection &collection_a, const SimplexCollection &collection_b)
Get union of two simplex collections.
bool contains(const Simplex &simplex) const
Check if simplex is contained in collection.
const std::vector< Simplex > & simplex_vector() const
Return const reference to the simplex vector.
static SimplexCollection get_intersection(const SimplexCollection &collection_a, const SimplexCollection &collection_b)
Get intersection of two simplex collections.
bool operator==(const SimplexCollection &other) const
internal::SimplexEqualFunctor m_simplex_is_equal
internal::SimplexLessFunctor m_simplex_is_less
void sort_and_clean()
Sort simplex vector and remove duplicates.
SimplexCollection(const Mesh &mesh, std::vector< Simplex > &&simplices={})
std::vector< Tuple > simplex_vector_tuples(PrimitiveType ptype) const
Return vector of all simplices of the requested type, as tuples.