Wildmeshing Toolkit
make_unique.cpp
Go to the documentation of this file.
1 #include "make_unique.hpp"
2 #include <algorithm>
5 
6 
7 namespace wmtk::simplex::utils {
8 std::vector<Simplex> make_unique(const Mesh& m, const std::vector<Simplex>& s)
9 {
10  std::vector<Simplex> ret = s;
11 
12  std::sort(ret.begin(), ret.end(), internal::SimplexLessFunctor{m});
13  ret.erase(std::unique(ret.begin(), ret.end(), internal::SimplexEqualFunctor{m}), ret.end());
14 
15  return ret;
16 }
17 std::vector<Tuple>
18 make_unique_tuples(const Mesh& m, const std::vector<Tuple>& ts, PrimitiveType primitive)
19 {
20  std::vector<Simplex> simps;
21  simps.reserve(ts.size());
22  std::transform(ts.begin(), ts.end(), std::back_inserter(simps), [&](const Tuple& t) {
23  return Simplex(m, primitive, t);
24  });
25 
26  simps = make_unique(m, simps);
27  std::vector<Tuple> ret;
28  ret.reserve(simps.size());
29 
30  std::transform(simps.begin(), simps.end(), std::back_inserter(ret), [](const Simplex& s) {
31  return s.tuple();
32  });
33  ;
34 
35  return ret;
36 }
37 } // namespace wmtk::simplex::utils
std::vector< Tuple > make_unique_tuples(const Mesh &m, const std::vector< Tuple > &ts, PrimitiveType primitive)
Definition: make_unique.cpp:18
std::vector< Simplex > make_unique(const Mesh &m, const std::vector< Simplex > &s)
Definition: make_unique.cpp:8