diff --git a/.idea/misc.xml b/.idea/misc.xml
index e8c6c13..dc13bd2 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -5,6 +5,7 @@
+
diff --git a/vis/CMakeLists.txt b/vis/CMakeLists.txt
index 394e3c0..cb493cd 100644
--- a/vis/CMakeLists.txt
+++ b/vis/CMakeLists.txt
@@ -5,13 +5,24 @@ add_custom_command(
COMMENT "copied shaders"
)
+add_custom_target(presets ALL DEPENDS preset_output)
+add_custom_command(
+ OUTPUT preset_output
+ COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/presets ${CMAKE_CURRENT_BINARY_DIR}/presets
+ COMMENT "copied preses"
+)
+
+find_package(yaml-cpp REQUIRED)
+
add_library(vis-util INTERFACE)
target_include_directories(vis-util INTERFACE include)
add_executable(vis src/main.cpp)
target_include_directories(vis PRIVATE include)
-target_link_libraries(vis PRIVATE tc glad glm glfw)
-add_dependencies(vis shaders)
+target_link_libraries(vis PRIVATE tc glad glm glfw yaml-cpp)
+add_dependencies(vis shaders presets)
add_executable(ctest src/combotest.cpp)
+target_link_libraries(ctest PRIVATE yaml-cpp)
target_include_directories(ctest PRIVATE include)
+add_dependencies(ctest presets)
diff --git a/vis/include/geometry.hpp b/vis/include/geometry.hpp
index 5d3ff2f..c4f8093 100644
--- a/vis/include/geometry.hpp
+++ b/vis/include/geometry.hpp
@@ -43,7 +43,7 @@ struct Primitive {
/**
* Produce a list of all generators for the group context. The range [0..group.ngens).
*/
-std::vector gens(const tc::Group &context) {
+std::vector generators(const tc::Group &context) {
std::vector g_gens(context.ngens);
std::iota(g_gens.begin(), g_gens.end(), 0);
return g_gens;
@@ -194,9 +194,9 @@ std::vector>> each_tile(
const auto table = solve(context, g_gens, {});
const auto path = solve(context, g_gens, sg_gens).path;
- auto _gens = gens(context);
+ auto _gens = generators(context);
- auto res = path.walk>, int>(base, gens(context), [&](auto from, auto gen) {
+ auto res = path.walk>, int>(base, generators(context), [&](auto from, auto gen) {
return apply(from, table, gen);
});
diff --git a/vis/presets/atlas-24-cell.yaml b/vis/presets/atlas-24-cell.yaml
new file mode 100644
index 0000000..2cc082c
--- /dev/null
+++ b/vis/presets/atlas-24-cell.yaml
@@ -0,0 +1,9 @@
+groups:
+ - symbol: [3, 4, 3, 2]
+ slices:
+ - root: [0.30, 0.03, 0.03, 0.03, 0.01]
+ color: [0.9, 0.3, 0.3]
+ - root: [1.00, 0.10, 0.10, 0.10, 0.02]
+ color: [0.3, 0.3, 0.3]
+ exclude:
+ - [0, 1, 2]
diff --git a/vis/presets/default.yaml b/vis/presets/default.yaml
new file mode 100644
index 0000000..2cc082c
--- /dev/null
+++ b/vis/presets/default.yaml
@@ -0,0 +1,9 @@
+groups:
+ - symbol: [3, 4, 3, 2]
+ slices:
+ - root: [0.30, 0.03, 0.03, 0.03, 0.01]
+ color: [0.9, 0.3, 0.3]
+ - root: [1.00, 0.10, 0.10, 0.10, 0.02]
+ color: [0.3, 0.3, 0.3]
+ exclude:
+ - [0, 1, 2]
diff --git a/vis/shaders/solid.fs.glsl b/vis/shaders/solid.fs.glsl
index d8f9b8a..232d04a 100644
--- a/vis/shaders/solid.fs.glsl
+++ b/vis/shaders/solid.fs.glsl
@@ -1,6 +1,6 @@
#version 430
-layout(location=2) uniform vec4 col;
+layout(location=2) uniform vec3 col;
layout(location=0) in vec3 pos;
layout(location=2) in vec3 normal;
@@ -12,6 +12,6 @@ void main() {
float bright = abs(dot(normal, normalize(vec3(-0.6, 1, 2))));
bright = .6 + .3 * bright * depth;
- color = col;
+ color = vec4(col, 1);
color.xyz *= bright;
}
diff --git a/vis/src/combotest.cpp b/vis/src/combotest.cpp
index 6438fba..dc2e294 100644
--- a/vis/src/combotest.cpp
+++ b/vis/src/combotest.cpp
@@ -1,15 +1,14 @@
-#include
#include
+#include
+#include
int main() {
- auto cs = Combos({7, 2, 3}, 2);
+ auto cfg = YAML::LoadFile("presets/default.yaml");
- auto beg = cs.begin();
- auto end = cs.end();
-
- while (beg != end) {
- const auto &c = *(++beg);
- for (const auto &e : c) std::cout << e << " ";
+ for (const auto &group : cfg["groups"]) {
+// std::cout << group["symbol"] << std::endl;
+ auto s = group["symbol"].as>();
+ for (const auto e : s) std::cout << e << " ";
std::cout << std::endl;
}
}
diff --git a/vis/src/main.cpp b/vis/src/main.cpp
index e9f531c..9c94fde 100644
--- a/vis/src/main.cpp
+++ b/vis/src/main.cpp
@@ -17,6 +17,7 @@
#include
#include
+#include
#ifdef _WIN32
extern "C" {
@@ -54,11 +55,19 @@ Matrices build(GLFWwindow *window, float st) {
}
template
-auto hull(const tc::Group &group, T begin, T end) {
+auto hull(const tc::Group &group, T all_sg_gens, const std::vector> &exclude) {
std::vector>> parts;
- auto g_gens = gens(group);
- while (begin != end) {
- const auto &sg_gens = *(++begin);
+ auto g_gens = generators(group);
+ for (const std::vector &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(group, sg_gens);
const auto &tiles = each_tile(base, group, g_gens, sg_gens);
for (const auto &tile : tiles) {
@@ -108,12 +117,12 @@ public:
template
struct Slice {
GLenum mode;
- vec4 color;
+ vec3 color;
cgl::VertexArray vao;
cgl::Buffer vbo;
cgl::Buffer> ibo;
- Slice(GLenum mode, vec4 color) : mode(mode), color(color), vao(), ibo(), vbo() {}
+ Slice(GLenum mode, vec3 color) : mode(mode), color(color), vao(), ibo(), vbo() {}
Slice(Slice &) = delete;
@@ -126,11 +135,12 @@ struct Slice {
}
template
- static Slice build(const tc::Group &g, const C &coords, vec4 color, T begin, T end) {
+ static Slice build(const tc::Group &g, const C &coords, vec3 color, T all_sg_gens,
+ const std::vector> &exclude) {
Slice res(GL_POINTS, color);
res.vbo.put(points(g, coords));
- res.ibo.put(merge(hull(g, begin, end)));
+ res.ibo.put(merge(hull(g, all_sg_gens, exclude)));
res.vao.ipointer(0, res.ibo, 4, GL_UNSIGNED_INT);
return res;
@@ -156,24 +166,39 @@ void run(GLFWwindow *window) {
.stage(sh.slice)
.stage(sh.solid);
- auto group = tc::schlafli({5, 3, 3, 2});
+ auto scene = YAML::LoadFile("presets/default.yaml");
- const auto combos = Combos({0, 1, 2, 3, 4}, 3);
+ auto slices = std::vector>();
- const auto coord = (vec5) {1.0, 0.1, 0.1, 0.1, 0.025};
+ for (const auto &group_info : scene["groups"]) {
+ auto symbol = group_info["symbol"].as>();
+ auto group = tc::schlafli(symbol);
+ auto gens = generators(group);
- auto slices = {
- Slice<4>::build(
- group,
- coord * 0.3,
- {0.9f, 0.3f, 0.3f, 1.0f},
- combos.begin(), combos.end()),
- Slice<4>::build(
- group,
- coord,
- {0.3f, 0.3f, 0.3f, 1.0f},
- combos.begin()++, combos.end()),
- };
+ if (group_info["slices"].IsDefined()) {
+ for (const auto &slice_info : group_info["slices"]) {
+ auto root = slice_info["root"].as();
+ auto color = slice_info["color"].as();
+ auto exclude = std::vector>();
+
+ if (slice_info["exclude"].IsDefined()) {
+ exclude = slice_info["exclude"].as>>();
+ }
+
+ if (slice_info["subgroups"].IsDefined()) {
+ auto subgroups = slice_info["subgroups"].as>>();
+ slices.push_back(Slice<4>::build(
+ group, root, color, subgroups, exclude
+ ));
+ } else {
+ auto combos = Combos(gens, 3);
+ slices.push_back(Slice<4>::build(
+ group, root, color, combos, exclude
+ ));
+ }
+ }
+ }
+ }
auto ubo = cgl::Buffer();
glBindBufferBase(GL_UNIFORM_BUFFER, 1, ubo);
@@ -194,7 +219,7 @@ void run(GLFWwindow *window) {
slice_pipe.bound([&]() {
for (const auto &slice : slices) {
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, slice.vbo);
- glProgramUniform4fv(sh.solid, 2, 1, &slice.color.front());
+ glProgramUniform3fv(sh.solid, 2, 1, &slice.color.front());
slice.draw();
}
});