-
Notifications
You must be signed in to change notification settings - Fork 15
/
TupleUtils.cpp
45 lines (40 loc) · 1.31 KB
/
TupleUtils.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <wmtk/utils/TupleUtils.hpp>
#include <algorithm>
namespace wmtk {
void unique_edge_tuples(const TetMesh& m, std::vector<TetMesh::Tuple>& edges)
{
std::stable_sort(
edges.begin(),
edges.end(),
[&](const TetMesh::Tuple& a, const TetMesh::Tuple& b) {
return a.eid(m) < b.eid(m);
}); // todo: use unique global id here would be very slow!
edges.erase(
std::unique(
edges.begin(),
edges.end(),
[&](const TetMesh::Tuple& a, const TetMesh::Tuple& b) { return a.eid(m) == b.eid(m); }),
edges.end());
}
void unique_directed_edge_tuples(const TetMesh& m, std::vector<TetMesh::Tuple>& edges)
{
std::stable_sort(
edges.begin(),
edges.end(),
[&](const TetMesh::Tuple& a, const TetMesh::Tuple& b) {
throw "check me!";
const int aeid = a.eid(m), beid = b.eid(m);
if (aeid == beid) return a.vid(m) < b.vid(m);
return aeid < beid;
});
edges.erase(
std::unique(
edges.begin(),
edges.end(),
[&](const TetMesh::Tuple& a, const TetMesh::Tuple& b) {
throw "check me!";
return a.eid(m) == b.eid(m) && a.vid(m) == b.vid(m);
}),
edges.end());
}
} // namespace wmtk