diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-11-27 23:03:57 +0100 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2023-11-27 23:03:57 +0100 |
commit | aa2ecacd2e477eb5748f060d33138e0c12c0634f (patch) | |
tree | d0360b420ecddaf6b9986c004ea3e0b962c9ca1b /c++/core | |
parent | 0cf04f2d1ba5ed2a18fe9f3501f363cb3ff76c9f (diff) |
codec,core,tools: Adding dangling experimental changes
Diffstat (limited to 'c++/core')
-rw-r--r-- | c++/core/mcts.h | 5 | ||||
-rw-r--r-- | c++/core/platonic.h | 103 | ||||
-rw-r--r-- | c++/core/string_literal.h | 2 | ||||
-rw-r--r-- | c++/core/templates.h | 6 |
4 files changed, 115 insertions, 1 deletions
diff --git a/c++/core/mcts.h b/c++/core/mcts.h new file mode 100644 index 0000000..30eed2f --- /dev/null +++ b/c++/core/mcts.h @@ -0,0 +1,5 @@ +#pragma once + +namespace saw { + +} diff --git a/c++/core/platonic.h b/c++/core/platonic.h new file mode 100644 index 0000000..eefe99f --- /dev/null +++ b/c++/core/platonic.h @@ -0,0 +1,103 @@ +#pragma once + +#include "error.h" + +namespace saw { +namespace impl { +/** + * + */ +template<typename Prec, uint8_t N> +struct platonic_helper { + static_assert(always_false<Prec,N>, "Unsupported platonic body. Alternatively it's not a platonic body"); +}; + +template<typename Prec> +struct platonic_helper<Prec,4u> { + static constexpr surface_edges = 3u; +/* + static constexpr std::array<std::array<Prec,3u>, 4u> normals = { + {0.0, 0.0, -1.0}, // 1 + {}, // 2 + {}, // 3 + {} // 4 + }; +*/ +}; + +template<typename Prec> +struct platonic_helper<Prec,6u> { + static constexpr surface_edges = 4u; + + static constexpr std::array<std::array<Prec,3u>, 6u> normals = { + { 1.0, 0.0, 0.0}, // 1 + {-1.0, 0.0, 0.0}, // 2 + { 0.0, 1.0, 0.0}, // 3 + { 0.0,-1.0, 0.0}, // 4 + { 0.0, 0.0, 1.0}, // 5 + { 0.0, 0.0,-1.0} // 6 + }; +}; + +template<typename Prec> +struct platonic_helper<Prec,20u> { + static constexpr uint8_t surface_edges = 3u; +/* + static constexpr std::array<std::array<Prec,3u>, 20u> normals = { + {}, // 1 + {}, // 2 + {}, // 3 + {}, // 4 + {}, // 5 + {}, // 6 + {}, // 7 + {}, // 8 + {}, // 9 + {}, // 10 + {}, // 11 + {}, // 12 + {}, // 13 + {}, // 14 + {}, // 15 + {}, // 16 + {}, // 17 + {}, // 18 + {}, // 19 + {} // 20 + }; +*/ +}; +} +/** + * Container for describing each platonic body with + * helpers describing the orientation of each body. + */ +template<typename T, typename Prec, uint8_t N> +class platonic { +private: + /** + * Storage for the surfaces + */ + std::array<T,N> surfaces_; +public: + constexpr uint8_t get_surface_edge_size() constexpr { + return platonic_helper<T,N>::surface_edges; + } + + constexpr uint8_t get_surface_size() constexpr { + return N; + } + + T& at(uint8_t i){ + return surface_.at(i); + } + + const T& at(uint8_t i) const { + return surface_.at(i); + } + + constexpr std::array<Prec, 3>& get_surface_normal(size_t i) constexpr { + + } +}; +} diff --git a/c++/core/string_literal.h b/c++/core/string_literal.h index 7373d5c..30f62fd 100644 --- a/c++/core/string_literal.h +++ b/c++/core/string_literal.h @@ -51,7 +51,7 @@ public: }; template <typename T, T... Chars> -constexpr string_literal<T, sizeof...(Chars)+1u> operator""_sl() { +constexpr string_literal<T, sizeof...(Chars) + 1u> operator""_sl() { return string_literal<T, sizeof...(Chars) + 1u>{{Chars..., '\0'}}; } } // namespace saw diff --git a/c++/core/templates.h b/c++/core/templates.h index e2851a0..2eb0f7e 100644 --- a/c++/core/templates.h +++ b/c++/core/templates.h @@ -105,6 +105,8 @@ struct ct_multiply<T, V0, VN...> { namespace impl { template<typename T, size_t i> struct ct_convert_digits_table_helper { + static_assert(i <= 15, "Only conversion up to hex is supported"); + static constexpr std::array<T, 16> table = { '0', '1', '2', '3', '4', '5', '6', '7', @@ -119,18 +121,21 @@ template<uint64_t Num, uint64_t Base, uint64_t... Digs> struct ct_convert_digits_helper { static constexpr size_t size = ct_convert_digits_helper<Num / Base, Base, Num % Base, Digs...>::size; static constexpr std::array<uint64_t, size> value = ct_convert_digits_helper<Num / Base, Base, Num % Base, Digs...>::value; + static constexpr string_literal literal = ct_convert_digits_helper<Num / Base, Base, Num % Base, Digs...>::literal; }; template<uint64_t Base, uint64_t... Digs> struct ct_convert_digits_helper<0, Base, Digs...> { static constexpr size_t size = sizeof...(Digs); static constexpr std::array<uint64_t, size> value = {Digs...}; + static constexpr string_literal literal = {{ct_convert_digits_table_helper<char, Digs>::value..., '\0'}}; }; template<uint64_t Base> struct ct_convert_digits_helper<0, Base> { static constexpr size_t size = 0; static constexpr std::array<uint64_t, 1> value = {0}; + static constexpr string_literal literal = "0"_sl; }; } @@ -140,5 +145,6 @@ struct ct_convert_to_digits { static constexpr size_t size = impl::ct_convert_digits_helper<Num, Base>::size; static constexpr std::array<uint64_t, size> value = impl::ct_convert_digits_helper<Num, Base>::value; + static constexpr string_literal literal = impl::ct_convert_digits_helper<Num,Base>::literal; }; } |