47{
48 std::unordered_map<uint64_t, int> edge_use;
49 std::unordered_map<int, int> local;
50 for (
const int f : faces) {
51 const stl_triangle_vertex_indices &t = mesh.indices[size_t(
f)];
52 for (int i = 0; i < 3; ++i) {
53 ++edge_use[
edge_key(t[i], t[(i + 1) % 3])];
54 local.emplace(t[i], int(local.size()));
55 }
56 }
57 euler = int(
local.size()) - int(edge_use.size()) + int(faces.size());
58
59 std::unordered_map<int, int> parent;
60 const std::function<int(
int)>
find = [&](
int x) {
61 while (parent[x] != x)
62 x = parent[x] = parent[parent[x]];
63 return x;
64 };
65 for (const auto &[key, uses] : edge_use)
66 if (uses == 1)
67 for (const int v : { int(key >> 32), int(uint32_t(key)) })
68 parent.emplace(v, v);
69 for (const auto &[key, uses] : edge_use)
70 if (uses == 1) {
71 const int a =
find(
int(key >> 32)), b =
find(
int(uint32_t(key)));
72 if (a != b)
73 parent[b] = a;
74 }
75 std::unordered_map<int, int> roots;
76 for (const auto &[v, p] : parent)
78 loops = int(roots.size());
79}
@ local
Definition Time.hpp:13
static double f(double x, double z_sin, double z_cos, bool vertical, bool flip)
Definition FillGyroid.cpp:124
RaycastManager::TrItems::iterator find(RaycastManager::TrItems &items, const RaycastManager::TrKey &key)
Definition RaycastManager.cpp:298
uint64_t edge_key(int a, int b)
Definition texture_unwrap_dump.cpp:37