diff --git a/vis/include/combo_iterator.hpp b/vis/include/combo_iterator.hpp index f7aa005..866502f 100644 --- a/vis/include/combo_iterator.hpp +++ b/vis/include/combo_iterator.hpp @@ -80,6 +80,7 @@ struct Combos { const std::vector &vals; size_t k; + // todo make k a template argument Combos(const std::vector &vals, size_t k) : vals(vals), k(k) { } diff --git a/vis/include/geometry.hpp b/vis/include/geometry.hpp index cee00e3..a7f801b 100644 --- a/vis/include/geometry.hpp +++ b/vis/include/geometry.hpp @@ -13,6 +13,8 @@ */ template struct Primitive { + static_assert(N > 0, "Primitives must contain at least one point. Primitive<0> or lower is impossible."); + std::array inds; Primitive() = default; @@ -230,7 +232,7 @@ Mesh triangulate( const tc::Group &context, const std::vector &g_gens ) { - if (g_gens.size() + 1 != N) + if (g_gens.size() + 1 != N) // todo make static assert throw std::logic_error("g_gens size must be one less than N"); const auto &combos = Combos(g_gens, g_gens.size() - 1); @@ -247,12 +249,15 @@ Mesh triangulate( return merge(meshes); } +/** + * Single-index primitives should not be further triangulated. + */ template<> Mesh<1> triangulate<1>( const tc::Group &context, const std::vector &g_gens ) { - if (not g_gens.empty()) + if (not g_gens.empty()) // todo make static assert throw std::logic_error("g_gens must be empty for a trivial Mesh"); Mesh<1> res;