Go to the documentation of this file.
9 #ifndef EAGINE_SHAPES_TOPOLOGY_HPP
10 #define EAGINE_SHAPES_TOPOLOGY_HPP
36 std::uint8_t bee) noexcept
37 : _triangles{{&a, &b}}
38 , _edge_indices{{aeb, aee, beb, bee}} {}
43 EAGINE_ASSERT(i >= 0 && i < 2);
50 -> std::tuple<unsigned, unsigned> {
51 EAGINE_ASSERT(i >= 0 && i < 2);
57 std::array<mesh_triangle*, 2> _triangles;
58 std::array<std::uint8_t, 4> _edge_indices;
73 , _indices{{a, b, c}} {}
80 static auto setup_adjacent(
83 const topology_data& d) noexcept
84 -> std::tuple<bool, std::uint8_t, std::uint8_t, std::uint8_t, std::uint8_t>;
89 EAGINE_ASSERT(v >= 0 && v < 3);
98 EAGINE_ASSERT(v >= 0 && v < 3);
107 EAGINE_ASSERT(v >= 0 && v < 3);
119 return _indices[(v + 2) % 3];
123 auto curri(std::size_t i)
const noexcept ->
unsigned {
127 static auto prevv(std::size_t i) noexcept ->
unsigned {
131 auto previ(std::size_t i)
const noexcept ->
unsigned {
132 return _indices[prevv(i)];
135 static auto nextv(std::size_t i) noexcept ->
unsigned {
139 auto nexti(std::size_t i)
const noexcept ->
unsigned {
140 return _indices[nextv(i)];
143 static auto narrow(std::size_t i) noexcept -> std::uint8_t {
144 return limit_cast<std::uint8_t>(i);
147 std::size_t _tri_idx{~0U};
148 std::array<unsigned, 3> _indices{};
149 std::array<mesh_triangle*, 3> _adjacent{{
nullptr,
nullptr,
nullptr}};
150 std::array<std::uint8_t, 3> _opposite{{0, 0, 0}};
161 std::shared_ptr<generator> gen,
164 : _gen{std::move(gen)} {
165 _scan_topology(var, vav);
182 auto print_dot(std::ostream& out)
const -> std::ostream&;
185 template <
typename I>
186 static auto to_index(I i) noexcept
187 -> std::enable_if_t<std::is_integral_v<I>,
unsigned> {
188 return limit_cast<unsigned>(i);
193 std::shared_ptr<generator> _gen;
194 std::vector<mesh_triangle> _triangles;
195 flat_map<std::tuple<unsigned, unsigned>, mesh_edge> _edges;
201 #if !EAGINE_LINK_LIBRARY || defined(EAGINE_IMPLEMENTING_LIBRARY)
202 #include <eagine/shapes/topology.inl>
205 #endif // EAGINE_SHAPES_TOPOLOGY_HPP
auto edge_vertices(span_size_t i) const noexcept -> std::tuple< unsigned, unsigned >
Returns a pair of vertex indices (0,1 or 2) defining the i-th edge.
Definition: topology.hpp:49
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
static constexpr auto span_size(T v) noexcept
Converts argument to span size type.
Definition: types.hpp:59
Common code is placed in this namespace.
Definition: eagine.hpp:21
Class storing information about a mesh tirangular face.
Definition: topology.hpp:65
auto opposite_vertex(span_size_t v) const noexcept -> unsigned
Returns opposite vertex index (0,1 or 2) in the v-th adjacent triangle.
Definition: topology.hpp:106
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
Class holding information about the topology of a generated shape.
Definition: topology.hpp:157
@ position
Vertex position.
Class designating an vertex attribute variant in a shape generator.
Definition: vertex_attrib.hpp:104
auto opposite_index(span_size_t v) const noexcept -> unsigned
Returns the in-mesh index of the v-th adjacent vertex.
Definition: topology.hpp:115
auto vertex_index(span_size_t v) const noexcept
Returns the v-th vertex index.
Definition: topology.hpp:88
Class storing information about an edge between two mesh faces.
Definition: topology.hpp:28
auto triangle(span_size_t i) const noexcept -> const mesh_triangle &
Returns one of the two adjacent triangle faces.
Definition: topology.hpp:42
static constexpr auto std_size(T v) noexcept
Converts argument to std size type.
Definition: types.hpp:52
span_size_t drawing_variant
Alias for shape drawing variant index type.
Definition: gen_base.hpp:31
topology(std::shared_ptr< generator > gen, drawing_variant var, vertex_attrib_variant vav)
Construction from a generator, drawing and attribute variant.
Definition: topology.hpp:160
auto triangle(span_size_t i) const noexcept -> const mesh_triangle &
Returns the i-th triangle in the mesh.
Definition: topology.hpp:178
auto adjacent_triangle(span_size_t v) const noexcept -> const mesh_triangle *
Returns the triangle adjacent through the v-th edge.
Definition: topology.hpp:96
auto triangle_count() const noexcept -> span_size_t
Returns the number of triangles in the mesh.
Definition: topology.hpp:173
auto index() const noexcept -> span_size_t
Returns the index of this triangle within the mesh.
Definition: topology.hpp:76
topology(const std::shared_ptr< generator > &gen)
Construction from a shape generator.
Definition: topology.hpp:169