diff --git a/vis/include/combinations.hpp b/vis/include/combinations.hpp index 615e9e6..3101601 100644 --- a/vis/include/combinations.hpp +++ b/vis/include/combinations.hpp @@ -50,4 +50,4 @@ std::set set_union(const std::set &a, const std::set &b) { std::inserter(result, result.end()) ); return result; -} \ No newline at end of file +} diff --git a/vis/include/solver.hpp b/vis/include/solver.hpp index 9159c0f..c8d823b 100644 --- a/vis/include/solver.hpp +++ b/vis/include/solver.hpp @@ -79,10 +79,10 @@ public: Mesh(const tc::Group &g_, std::vector ctx_, size_t cols); - static Mesh fill(const tc::Group &g, std::vector ctx); + static Mesh fill(const tc::Group &g, const std::vector &ctx); - template - static Mesh hull(const tc::Group &g, std::vector ctx, const SC &sub_ctxs); +// template +// static Mesh hull(const tc::Group &g, const std::vector &ctx, const SC &sub_ctxs); Mesh recontext(std::vector ctx_); @@ -187,7 +187,7 @@ Mesh::Mesh(const tc::Group &g_, std::vector ctx_, size_t cols) } template -Mesh Mesh::fill(const tc::Group &g, std::vector ctx) { +Mesh Mesh::fill(const tc::Group &g, const std::vector &ctx) { if (ctx.size() + 1 != N) throw std::logic_error("ctx size must be one less than N"); @@ -212,22 +212,45 @@ Mesh Mesh::fill(const tc::Group &g, std::vector ctx) { } template<> -Mesh<1> Mesh<1>::fill(const tc::Group &g, std::vector ctx) { +Mesh<1> Mesh<1>::fill(const tc::Group &g, const std::vector &ctx) { if (not ctx.empty()) throw std::logic_error("ctx must be empty for a trivial Mesh."); return Mesh<1>(g, ctx, 1); } -template -template -Mesh Mesh::hull(const tc::Group &g, const std::vector ctx, const SC &sub_ctxs) { +template +Mesh fill_each_tile_merge(const tc::Group &g, const C &ctx, const SC &sub_ctxs) { std::vector> parts; for (const auto &sub_ctx : sub_ctxs) { - auto face = Mesh::fill(g, sub_ctx).each_tile(ctx); - parts.insert(parts.end(), face.begin(), face.end()); + auto root = Mesh::fill(g, sub_ctx); + auto faces = root.each_tile(ctx); + parts.insert(parts.end(), faces.begin(), faces.end()); } return merge(parts); } + +template +Mesh fill_each_tile_merge(const tc::Group &g, const SC &sub_ctxs) { + return fill_each_tile_merge(g, generators(g), sub_ctxs); +} + +template +Mesh fill_each_recontext_merge(const tc::Group &g, const C &ctx, const SC &sub_ctxs) { + std::vector> parts; + + for (const auto &sub_ctx : sub_ctxs) { + auto root = Mesh::fill(g, sub_ctx); + auto face = root.recontext(ctx); + parts.insert(parts.end(), face); + } + + return merge(parts); +} + +template +Mesh fill_each_recontext_merge(const tc::Group &g, const SC &sub_ctxs) { + return fill_each_recontext_merge(g, generators(g), sub_ctxs); +} diff --git a/vis/src/main.cpp b/vis/src/main.cpp index a4c30de..d359a89 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -50,14 +50,14 @@ public: 4, 5) { using namespace nanogui; - Window *window = new Window(this, "Sample Window"); + auto *window = new Window(this, "Sample Window"); window->setPosition(Vector2i(15, 15)); window->setFixedWidth(250); window->setLayout(new BoxLayout(Orientation::Vertical)); - auto pause = new ToolButton(window, ENTYPO_ICON_CONTROLLER_PAUS); - pause->setFlags(Button::ToggleButton); - pause->setChangeCallback([&](bool value) { this->paused = value; }); +// auto pause = new ToolButton(window, ENTYPO_ICON_CONTROLLER_PAUS); +// pause->setFlags(Button::ToggleButton); +// pause->setChangeCallback([&](bool value) { this->paused = value; }); performLayout(); @@ -73,31 +73,13 @@ public: {0, 1, 2}, } ); - auto mesh = Mesh<4>::hull(group, ctx, selected_ctxs); + auto mesh = fill_each_tile_merge<4>(group, selected_ctxs); auto &slice = slices.emplace_back(group); slice.setMesh(mesh); slice.root << .80, .02, .02, .02, .02; } - { - std::vector symbol = {3, 4, 3, 2}; - auto group = tc::schlafli(symbol); - auto ctx = generators(group); - - auto selected_ctxs = set_union( - combinations(std::vector{0, 2, 3, 4}, 3), - combinations(std::vector{1, 2, 3, 4}, 3) - ); - - auto mesh = Mesh<4>::hull(group, ctx, selected_ctxs); - - auto &slice = slices.emplace_back(group); - slice.setMesh(mesh); - slice.root << .80, .02, .02, .03, .04; - slice.color << 0.9, 0.1, 0.1; - } - ren = std::make_unique>(); ubo = std::make_unique>(); @@ -134,7 +116,7 @@ public: } }; -int main(int argc, char ** argv) { +int main(int argc, char **argv) { try { nanogui::init(); @@ -153,4 +135,4 @@ int main(int argc, char ** argv) { } return 0; -} \ No newline at end of file +}