From c8b9358215029d1dd702a24e2dc7242a464c038b Mon Sep 17 00:00:00 2001 From: Arnaud Botella Date: Mon, 3 Mar 2025 15:03:54 +0100 Subject: [PATCH 1/2] fix(Facets): add more api around opposite facet --- include/geode/mesh/core/detail/facet_storage.hpp | 16 ++++++++++++---- include/geode/mesh/core/solid_edges.hpp | 3 +++ include/geode/mesh/core/solid_facets.hpp | 3 +++ include/geode/mesh/core/surface_edges.hpp | 3 +++ src/geode/mesh/core/solid_edges.cpp | 12 +++++++++--- src/geode/mesh/core/solid_facets.cpp | 12 +++++++++--- src/geode/mesh/core/surface_edges.cpp | 12 +++++++++--- 7 files changed, 48 insertions(+), 13 deletions(-) diff --git a/include/geode/mesh/core/detail/facet_storage.hpp b/include/geode/mesh/core/detail/facet_storage.hpp index 31d324fdf..abece3913 100644 --- a/include/geode/mesh/core/detail/facet_storage.hpp +++ b/include/geode/mesh/core/detail/facet_storage.hpp @@ -43,14 +43,22 @@ namespace geode static constexpr auto ATTRIBUTE_NAME = "facet_vertices"; friend class bitsery::Access; + public: + [[nodiscard]] bool is_opposite( + index_t facet_id, const VertexContainer& vertices ) const + { + const OrientedVertexCycle other_oriented_cycle{ vertices }; + const OrientedVertexCycle oriented_cycle{ vertices_->value( + facet_id ) }; + return oriented_cycle.is_opposite( other_oriented_cycle ); + } + protected: FacetStorage() - : counter_( - facet_attribute_manager_ + : counter_( facet_attribute_manager_ .template find_or_create_attribute< VariableAttribute, index_t >( "counter", 1u, { false, false } ) ), - vertices_( - facet_attribute_manager_ + vertices_( facet_attribute_manager_ .template find_or_create_attribute< VariableAttribute, VertexContainer >( attribute_name(), VertexContainer(), diff --git a/include/geode/mesh/core/solid_edges.hpp b/include/geode/mesh/core/solid_edges.hpp index 76e1c7406..3f7392ad5 100644 --- a/include/geode/mesh/core/solid_edges.hpp +++ b/include/geode/mesh/core/solid_edges.hpp @@ -76,6 +76,9 @@ namespace geode [[nodiscard]] std::optional< index_t > edge_from_vertices( const std::array< index_t, 2 >& vertices ) const; + [[nodiscard]] bool is_opposite( + index_t edge_id, const std::array< index_t, 2 >& vertices ) const; + /*! * Access to the manager of attributes associated with edges. */ diff --git a/include/geode/mesh/core/solid_facets.hpp b/include/geode/mesh/core/solid_facets.hpp index ef7a015b3..1f54b9e66 100644 --- a/include/geode/mesh/core/solid_facets.hpp +++ b/include/geode/mesh/core/solid_facets.hpp @@ -70,6 +70,9 @@ namespace geode [[nodiscard]] std::optional< index_t > facet_from_vertices( const PolyhedronFacetVertices& vertices ) const; + [[nodiscard]] bool is_opposite( + index_t facet_id, const PolyhedronFacetVertices& vertices ) const; + /*! * Access to the manager of attributes associated with facets. */ diff --git a/include/geode/mesh/core/surface_edges.hpp b/include/geode/mesh/core/surface_edges.hpp index 59803bd87..b9805042f 100644 --- a/include/geode/mesh/core/surface_edges.hpp +++ b/include/geode/mesh/core/surface_edges.hpp @@ -74,6 +74,9 @@ namespace geode [[nodiscard]] std::optional< index_t > edge_from_vertices( const std::array< index_t, 2 >& vertices ) const; + [[nodiscard]] bool is_opposite( + index_t edge_id, const std::array< index_t, 2 >& vertices ) const; + /*! * Access to the manager of attributes associated with edges. */ diff --git a/src/geode/mesh/core/solid_edges.cpp b/src/geode/mesh/core/solid_edges.cpp index f6224fc1d..6c2107c95 100644 --- a/src/geode/mesh/core/solid_edges.cpp +++ b/src/geode/mesh/core/solid_edges.cpp @@ -96,9 +96,7 @@ namespace geode } template < index_t dimension > - SolidEdges< dimension >::SolidEdges() - { - } + SolidEdges< dimension >::SolidEdges() = default; template < index_t dimension > SolidEdges< dimension >::~SolidEdges() = default; @@ -132,6 +130,14 @@ namespace geode return impl_->find_edge( vertices ); } + template < index_t dimension > + bool SolidEdges< dimension >::is_opposite( + index_t edge_id, const std::array< index_t, 2 >& vertices ) const + { + check_edge_id( *this, edge_id ); + return impl_->is_opposite( edge_id, vertices ); + } + template < index_t dimension > void SolidEdges< dimension >::update_edge_vertices( absl::Span< const index_t > old2new, SolidEdgesKey ) diff --git a/src/geode/mesh/core/solid_facets.cpp b/src/geode/mesh/core/solid_facets.cpp index 5ba8c6ca0..7980998d9 100644 --- a/src/geode/mesh/core/solid_facets.cpp +++ b/src/geode/mesh/core/solid_facets.cpp @@ -165,9 +165,7 @@ namespace geode } template < index_t dimension > - SolidFacets< dimension >::SolidFacets() - { - } + SolidFacets< dimension >::SolidFacets() = default; template < index_t dimension > SolidFacets< dimension >::~SolidFacets() = default; @@ -201,6 +199,14 @@ namespace geode return impl_->find_facet( vertices ); } + template < index_t dimension > + bool SolidFacets< dimension >::is_opposite( + index_t facet_id, const PolyhedronFacetVertices& vertices ) const + { + check_facet_id( *this, facet_id ); + return impl_->is_opposite( facet_id, vertices ); + } + template < index_t dimension > std::vector< index_t > SolidFacets< dimension >::update_facet_vertices( absl::Span< const index_t > old2new, SolidFacetsKey ) diff --git a/src/geode/mesh/core/surface_edges.cpp b/src/geode/mesh/core/surface_edges.cpp index 9efe8bb55..629a07cd2 100644 --- a/src/geode/mesh/core/surface_edges.cpp +++ b/src/geode/mesh/core/surface_edges.cpp @@ -90,9 +90,7 @@ namespace geode }; template < index_t dimension > - SurfaceEdges< dimension >::SurfaceEdges() - { - } + SurfaceEdges< dimension >::SurfaceEdges() = default; template < index_t dimension > SurfaceEdges< dimension >::SurfaceEdges( @@ -185,6 +183,14 @@ namespace geode return impl_->find_edge( vertices ); } + template < index_t dimension > + bool SurfaceEdges< dimension >::is_opposite( + index_t edge_id, const std::array< index_t, 2 >& vertices ) const + { + check_edge_id( *this, edge_id ); + return impl_->is_opposite( edge_id, vertices ); + } + template < index_t dimension > AttributeManager& SurfaceEdges< dimension >::edge_attribute_manager() const { From 28ef72a0114a8144c56f549f30957c2d8ab4aafa Mon Sep 17 00:00:00 2001 From: BotellaA <3213882+BotellaA@users.noreply.github.com> Date: Mon, 3 Mar 2025 14:04:48 +0000 Subject: [PATCH 2/2] Apply prepare changes --- include/geode/mesh/core/detail/facet_storage.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/geode/mesh/core/detail/facet_storage.hpp b/include/geode/mesh/core/detail/facet_storage.hpp index abece3913..660bb8165 100644 --- a/include/geode/mesh/core/detail/facet_storage.hpp +++ b/include/geode/mesh/core/detail/facet_storage.hpp @@ -55,10 +55,12 @@ namespace geode protected: FacetStorage() - : counter_( facet_attribute_manager_ + : counter_( + facet_attribute_manager_ .template find_or_create_attribute< VariableAttribute, index_t >( "counter", 1u, { false, false } ) ), - vertices_( facet_attribute_manager_ + vertices_( + facet_attribute_manager_ .template find_or_create_attribute< VariableAttribute, VertexContainer >( attribute_name(), VertexContainer(),