mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
soft-remove "dim" from Mesh
This commit is contained in:
@@ -26,19 +26,15 @@ size_t num_gens_from_key(size_t key) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Simplexes {
|
struct Mesh {
|
||||||
int dim;
|
// int dim;
|
||||||
std::vector<int> vals;
|
std::vector<int> vals;
|
||||||
|
|
||||||
Simplexes() : dim(0), vals() {}
|
Mesh() : vals() {}
|
||||||
|
|
||||||
explicit Simplexes(int dim) : dim(dim), vals() {}
|
explicit Mesh(std::vector<int> &vals) : vals(vals) {}
|
||||||
|
|
||||||
Simplexes(int dim, std::vector<int> &vals) : dim(dim), vals(vals) {}
|
|
||||||
|
|
||||||
explicit Simplexes(const std::vector<Simplexes> &parts) {
|
|
||||||
dim = parts[0].dim;
|
|
||||||
|
|
||||||
|
explicit Mesh(const std::vector<Mesh> &parts) {
|
||||||
size_t count = 0;
|
size_t count = 0;
|
||||||
for (const auto &part : parts) {
|
for (const auto &part : parts) {
|
||||||
count += part.size();
|
count += part.size();
|
||||||
@@ -55,17 +51,17 @@ struct Simplexes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void flip() {
|
void flip() {
|
||||||
if (dim == 0)
|
// if (dim == 0)
|
||||||
return;
|
// return;
|
||||||
for (int i = 0; i < vals.size(); i += dim + 1) {
|
// for (int i = 0; i < vals.size(); i += dim + 1) {
|
||||||
std::swap(vals[i], vals[i + 1]);
|
// std::swap(vals[i], vals[i + 1]);
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GeomGen {
|
struct GeomGen {
|
||||||
std::vector<std::vector<std::optional<tc::Cosets>>> coset_memo;
|
std::vector<std::vector<std::optional<tc::Cosets>>> coset_memo;
|
||||||
std::vector<std::optional<Simplexes>> triangulate_memo;
|
std::vector<std::optional<Mesh>> triangulate_memo;
|
||||||
tc::Group &context;
|
tc::Group &context;
|
||||||
|
|
||||||
explicit GeomGen(tc::Group &g) : context(g) {
|
explicit GeomGen(tc::Group &g) : context(g) {
|
||||||
@@ -148,7 +144,7 @@ struct GeomGen {
|
|||||||
return solve_sg(sg_gens);
|
return solve_sg(sg_gens);
|
||||||
}
|
}
|
||||||
|
|
||||||
Simplexes recontext(std::vector<int> &g_gens, std::vector<int> &sg_gens, const Simplexes &items) {
|
Mesh recontext(std::vector<int> &g_gens, std::vector<int> &sg_gens, const Mesh &items) {
|
||||||
auto s_sg_gens = prepare_gens(g_gens, sg_gens);
|
auto s_sg_gens = prepare_gens(g_gens, sg_gens);
|
||||||
auto table = solve_g(g_gens);
|
auto table = solve_g(g_gens);
|
||||||
auto path = solve_g(sg_gens).path;
|
auto path = solve_g(sg_gens).path;
|
||||||
@@ -157,7 +153,7 @@ struct GeomGen {
|
|||||||
|
|
||||||
auto map = path.walk<int, int>(0, s_sg_gens, coset_map);
|
auto map = path.walk<int, int>(0, s_sg_gens, coset_map);
|
||||||
|
|
||||||
Simplexes ret(items.dim);
|
Mesh ret;
|
||||||
ret.vals.reserve(items.size());
|
ret.vals.reserve(items.size());
|
||||||
for (const auto val : items.vals) {
|
for (const auto val : items.vals) {
|
||||||
ret.vals.push_back(map[val]);
|
ret.vals.push_back(map[val]);
|
||||||
@@ -167,13 +163,13 @@ struct GeomGen {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
Simplexes tile(std::vector<int> &g_gens, std::vector<int> &sg_gens, const Simplexes &items) {
|
Mesh tile(std::vector<int> &g_gens, std::vector<int> &sg_gens, const Mesh &items) {
|
||||||
Simplexes base = recontext(g_gens, sg_gens, items);
|
Mesh base = recontext(g_gens, sg_gens, items);
|
||||||
auto s_sg_gens = prepare_gens(g_gens, sg_gens);
|
auto s_sg_gens = prepare_gens(g_gens, sg_gens);
|
||||||
auto table = solve_g(g_gens);
|
auto table = solve_g(g_gens);
|
||||||
auto path = _solve(g_gens, sg_gens).path;
|
auto path = _solve(g_gens, sg_gens).path;
|
||||||
|
|
||||||
auto simplex_map = [table](Simplexes from, int gen) -> Simplexes {
|
auto simplex_map = [table](Mesh from, int gen) -> Mesh {
|
||||||
for (auto &coset : from.vals) {
|
for (auto &coset : from.vals) {
|
||||||
coset = table.get(coset, gen);
|
coset = table.get(coset, gen);
|
||||||
}
|
}
|
||||||
@@ -181,15 +177,15 @@ struct GeomGen {
|
|||||||
return from;
|
return from;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto r = path.walk<Simplexes, int>(base, group_gens(), simplex_map);
|
auto r = path.walk<Mesh, int>(base, group_gens(), simplex_map);
|
||||||
|
|
||||||
return Simplexes(r);
|
return Mesh(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
Simplexes triangulate(std::vector<int> &g_gens);
|
Mesh triangulate(std::vector<int> &g_gens);
|
||||||
|
|
||||||
Simplexes _triangulate(std::vector<int> &g_gens) {
|
Mesh _triangulate(std::vector<int> &g_gens) {
|
||||||
Simplexes S(g_gens.size());
|
Mesh S;
|
||||||
if (g_gens.empty()) {
|
if (g_gens.empty()) {
|
||||||
S.vals.push_back(0);
|
S.vals.push_back(0);
|
||||||
return S;
|
return S;
|
||||||
@@ -198,8 +194,8 @@ struct GeomGen {
|
|||||||
auto sub_simps = triangulate(sg_gens);
|
auto sub_simps = triangulate(sg_gens);
|
||||||
int start = sub_simps.size();
|
int start = sub_simps.size();
|
||||||
sub_simps = tile(g_gens, sg_gens, sub_simps);
|
sub_simps = tile(g_gens, sg_gens, sub_simps);
|
||||||
for (int l = start; l < sub_simps.size(); l += S.dim) {
|
for (int l = start; l < sub_simps.size(); l += g_gens.size()) {
|
||||||
for (int m = l; m < l + S.dim; m++) {
|
for (int m = l; m < l + g_gens.size(); m++) {
|
||||||
S.vals.push_back(sub_simps.vals[m]);
|
S.vals.push_back(sub_simps.vals[m]);
|
||||||
}
|
}
|
||||||
S.vals.push_back(0);
|
S.vals.push_back(0);
|
||||||
@@ -210,7 +206,7 @@ struct GeomGen {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Simplexes GeomGen::triangulate(std::vector<int> &g_gens) {
|
Mesh GeomGen::triangulate(std::vector<int> &g_gens) {
|
||||||
int key = get_key_from_gens(g_gens);
|
int key = get_key_from_gens(g_gens);
|
||||||
if (!triangulate_memo[key]) {
|
if (!triangulate_memo[key]) {
|
||||||
triangulate_memo[key] = _triangulate(g_gens);
|
triangulate_memo[key] = _triangulate(g_gens);
|
||||||
|
|||||||
Reference in New Issue
Block a user