mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 12:02:47 -05:00
add some notes and static assertions about template sizes
This commit is contained in:
@@ -80,6 +80,7 @@ struct Combos {
|
|||||||
const std::vector<T> &vals;
|
const std::vector<T> &vals;
|
||||||
size_t k;
|
size_t k;
|
||||||
|
|
||||||
|
// todo make k a template argument
|
||||||
Combos(const std::vector<T> &vals, size_t k) : vals(vals), k(k) {
|
Combos(const std::vector<T> &vals, size_t k) : vals(vals), k(k) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
*/
|
*/
|
||||||
template<unsigned N>
|
template<unsigned N>
|
||||||
struct Primitive {
|
struct Primitive {
|
||||||
|
static_assert(N > 0, "Primitives must contain at least one point. Primitive<0> or lower is impossible.");
|
||||||
|
|
||||||
std::array<unsigned, N> inds;
|
std::array<unsigned, N> inds;
|
||||||
|
|
||||||
Primitive() = default;
|
Primitive() = default;
|
||||||
@@ -230,7 +232,7 @@ Mesh<N> triangulate(
|
|||||||
const tc::Group &context,
|
const tc::Group &context,
|
||||||
const std::vector<int> &g_gens
|
const std::vector<int> &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");
|
throw std::logic_error("g_gens size must be one less than N");
|
||||||
|
|
||||||
const auto &combos = Combos(g_gens, g_gens.size() - 1);
|
const auto &combos = Combos(g_gens, g_gens.size() - 1);
|
||||||
@@ -247,12 +249,15 @@ Mesh<N> triangulate(
|
|||||||
return merge(meshes);
|
return merge(meshes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Single-index primitives should not be further triangulated.
|
||||||
|
*/
|
||||||
template<>
|
template<>
|
||||||
Mesh<1> triangulate<1>(
|
Mesh<1> triangulate<1>(
|
||||||
const tc::Group &context,
|
const tc::Group &context,
|
||||||
const std::vector<int> &g_gens
|
const std::vector<int> &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");
|
throw std::logic_error("g_gens must be empty for a trivial Mesh");
|
||||||
|
|
||||||
Mesh<1> res;
|
Mesh<1> res;
|
||||||
|
|||||||
Reference in New Issue
Block a user