mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
Convert hull to static method; inline all_sg_gens and exclude parameters for future testing.
This commit is contained in:
@@ -45,9 +45,14 @@ public:
|
|||||||
cgl::Buffer<vec4> vbo;
|
cgl::Buffer<vec4> vbo;
|
||||||
cgl::VertexArray vao;
|
cgl::VertexArray vao;
|
||||||
|
|
||||||
template<class T>
|
explicit Slice(const tc::Group &g) : group(g) {
|
||||||
Slice(const tc::Group &g, T all_sg_gens, const std::vector<std::vector<int>> &exclude) : group(g) {
|
auto gens = generators(group);
|
||||||
auto mesh = merge(hull<N>(g, exclude));
|
auto combos = Combos<int>(gens, 3);
|
||||||
|
std::vector<std::vector<int>> exclude = {{0, 1, 2}};
|
||||||
|
|
||||||
|
auto all_sg_gens = combos;
|
||||||
|
|
||||||
|
auto mesh = Mesh<N>::hull(g, generators(g), all_sg_gens);
|
||||||
ibo.put(mesh);
|
ibo.put(mesh);
|
||||||
|
|
||||||
vao.ipointer(0, ibo, 4, GL_UNSIGNED_INT);
|
vao.ipointer(0, ibo, 4, GL_UNSIGNED_INT);
|
||||||
|
|||||||
@@ -70,29 +70,6 @@ namespace {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//template<unsigned N, class T>
|
|
||||||
//auto hull(const tc::Group &group, T all_sg_gens, const std::vector<std::vector<int>> &exclude) {
|
|
||||||
// std::vector<Prims<N>> parts;
|
|
||||||
// auto g_gens = generators(group);
|
|
||||||
// for (const std::vector<int> &sg_gens : all_sg_gens) {
|
|
||||||
// bool excluded = false;
|
|
||||||
// for (const auto &test : exclude) {
|
|
||||||
// if (sg_gens == test) {
|
|
||||||
// excluded = true;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (excluded) continue;
|
|
||||||
//
|
|
||||||
// const auto &base = triangulate<N>(group, sg_gens);
|
|
||||||
// const auto &tiles = tile<N>(base, group, g_gens, sg_gens);
|
|
||||||
// for (const auto &tile : tiles) {
|
|
||||||
// parts.push_back(tile);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return parts;
|
|
||||||
//}
|
|
||||||
|
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
class Mesh {
|
class Mesh {
|
||||||
public:
|
public:
|
||||||
@@ -102,7 +79,10 @@ public:
|
|||||||
|
|
||||||
Mesh(const tc::Group &g_, std::vector<int> ctx_, size_t cols);
|
Mesh(const tc::Group &g_, std::vector<int> ctx_, size_t cols);
|
||||||
|
|
||||||
Mesh(const tc::Group &g_, std::vector<int> ctx_);
|
static Mesh<N> fill(const tc::Group &g, std::vector<int> ctx);
|
||||||
|
|
||||||
|
template<class SC>
|
||||||
|
static Mesh<N> hull(const tc::Group &g, std::vector<int> ctx, const SC &sub_ctxs);
|
||||||
|
|
||||||
Mesh<N> recontext(std::vector<int> ctx_);
|
Mesh<N> recontext(std::vector<int> ctx_);
|
||||||
|
|
||||||
@@ -200,17 +180,16 @@ Mesh<N>::Mesh(const tc::Group &g_, std::vector<int> ctx_, size_t cols)
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
Mesh<N>::Mesh(const tc::Group &g_, std::vector<int> ctx_)
|
Mesh<N> Mesh<N>::fill(const tc::Group &g, std::vector<int> ctx) {
|
||||||
: g(&g_), ctx(std::move(ctx_)) {
|
if (ctx.size() + 1 != N)
|
||||||
if (ctx.size() + 1 != N) // todo make static assert
|
|
||||||
throw std::logic_error("ctx size must be one less than N");
|
throw std::logic_error("ctx size must be one less than N");
|
||||||
|
|
||||||
const auto &combos = Combos(ctx, ctx.size() - 1);
|
const auto &combos = Combos(ctx, (int)ctx.size() - 1);
|
||||||
|
|
||||||
std::vector<Mesh<N>> meshes;
|
std::vector<Mesh<N>> meshes;
|
||||||
|
|
||||||
for (const auto &sctx : combos) {
|
for (const auto &sub_ctx : combos) {
|
||||||
Mesh<N - 1> base(*g, sctx);
|
auto base = Mesh<N - 1>::fill(g, sub_ctx);
|
||||||
auto parts = base.tile(ctx);
|
auto parts = base.tile(ctx);
|
||||||
parts.erase(parts.begin(), parts.begin() + 1);
|
parts.erase(parts.begin(), parts.begin() + 1);
|
||||||
|
|
||||||
@@ -221,34 +200,26 @@ Mesh<N>::Mesh(const tc::Group &g_, std::vector<int> ctx_)
|
|||||||
meshes.push_back(fanned);
|
meshes.push_back(fanned);
|
||||||
}
|
}
|
||||||
|
|
||||||
prims = merge(meshes).prims;
|
return merge(meshes);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
Mesh<1>::Mesh(const tc::Group &g_, std::vector<int> ctx_) : g(&g_), ctx(std::move(ctx_)) {
|
Mesh<1> Mesh<1>::fill(const tc::Group &g, std::vector<int> ctx) {
|
||||||
if (not ctx.empty())
|
if (not ctx.empty())
|
||||||
throw std::logic_error("ctx must be empty for a trivial Mesh.");
|
throw std::logic_error("ctx must be empty for a trivial Mesh.");
|
||||||
|
|
||||||
prims.setZero(1, 1);
|
return Mesh<1>(g, ctx, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
auto hull(const tc::Group &g, const std::vector<std::vector<int>> &exclude) {
|
template<class SC>
|
||||||
|
Mesh<N> Mesh<N>::hull(const tc::Group &g, const std::vector<int> ctx, const SC &sub_ctxs) {
|
||||||
std::vector<Mesh<N>> parts;
|
std::vector<Mesh<N>> parts;
|
||||||
|
|
||||||
auto ctx = generators(g);
|
|
||||||
auto sub_ctxs = Combos(ctx, N - 1);
|
|
||||||
|
|
||||||
for (const auto &sub_ctx : sub_ctxs) {
|
for (const auto &sub_ctx : sub_ctxs) {
|
||||||
bool excluded = std::any_of(
|
auto face = Mesh<N>::fill(g, sub_ctx).tile(ctx);
|
||||||
exclude.begin(), exclude.end(),
|
parts.insert(parts.end(), face.begin(), face.end());
|
||||||
[&](auto e) { return e == sub_ctx; }
|
|
||||||
);
|
|
||||||
if (excluded) continue;
|
|
||||||
|
|
||||||
auto sub_parts = Mesh<N>(g, sub_ctx).tile(ctx);
|
|
||||||
parts.insert(parts.end(), sub_parts.begin(), sub_parts.end());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return parts;
|
return merge(parts);
|
||||||
}
|
}
|
||||||
@@ -18,9 +18,9 @@ mat5 wander(float time) {
|
|||||||
r *= rot<5>(1, 2, time * .13f);
|
r *= rot<5>(1, 2, time * .13f);
|
||||||
r *= rot<5>(0, 1, time * .20f);
|
r *= rot<5>(0, 1, time * .20f);
|
||||||
|
|
||||||
// r *= rot<5>(0, 3, time * .17f);
|
r *= rot<5>(0, 3, time * .17f);
|
||||||
// r *= rot<5>(1, 3, time * .25f);
|
r *= rot<5>(1, 3, time * .25f);
|
||||||
// r *= rot<5>(2, 3, time * .12f);
|
r *= rot<5>(2, 3, time * .12f);
|
||||||
|
|
||||||
// r *= rot<5>(1, 4, time * .27f);
|
// r *= rot<5>(1, 4, time * .27f);
|
||||||
|
|
||||||
@@ -66,16 +66,12 @@ public:
|
|||||||
|
|
||||||
std::cout << utilInfo();
|
std::cout << utilInfo();
|
||||||
|
|
||||||
std::vector<int> symbol = {5, 3, 2, 2};
|
std::vector<int> symbol = {3, 4, 3, 2};
|
||||||
root << .80, .02, .02, .02, .02;
|
root << .80, .02, .02, .02, .02;
|
||||||
|
|
||||||
auto group = tc::schlafli(symbol);
|
auto group = tc::schlafli(symbol);
|
||||||
|
|
||||||
auto gens = generators(group);
|
slice = std::make_unique<Slice<4>>(group);
|
||||||
auto combos = Combos<int>(gens, 3);
|
|
||||||
std::vector<std::vector<int>> exclude = {{0, 1, 2}};
|
|
||||||
|
|
||||||
slice = std::make_unique<Slice<4>>(group, combos, exclude);
|
|
||||||
ren = std::make_unique<SliceRenderer<4>>();
|
ren = std::make_unique<SliceRenderer<4>>();
|
||||||
|
|
||||||
ubo = std::make_unique<cgl::Buffer<Matrices>>();
|
ubo = std::make_unique<cgl::Buffer<Matrices>>();
|
||||||
|
|||||||
Reference in New Issue
Block a user