Skip to content

Commit

Permalink
Merge pull request #1098 from Geode-solutions/fix/facet-storage-opposite
Browse files Browse the repository at this point in the history
fix(Facets): add more api around opposite facet
  • Loading branch information
MelchiorSchuh authored Mar 3, 2025
2 parents a7179fa + 28ef72a commit c95b238
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 9 deletions.
10 changes: 10 additions & 0 deletions include/geode/mesh/core/detail/facet_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ 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_(
Expand Down
3 changes: 3 additions & 0 deletions include/geode/mesh/core/solid_edges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 3 additions & 0 deletions include/geode/mesh/core/solid_facets.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
3 changes: 3 additions & 0 deletions include/geode/mesh/core/surface_edges.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
12 changes: 9 additions & 3 deletions src/geode/mesh/core/solid_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down
12 changes: 9 additions & 3 deletions src/geode/mesh/core/solid_facets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 )
Expand Down
12 changes: 9 additions & 3 deletions src/geode/mesh/core/surface_edges.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,7 @@ namespace geode
};

template < index_t dimension >
SurfaceEdges< dimension >::SurfaceEdges()
{
}
SurfaceEdges< dimension >::SurfaceEdges() = default;

template < index_t dimension >
SurfaceEdges< dimension >::SurfaceEdges(
Expand Down Expand Up @@ -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
{
Expand Down

0 comments on commit c95b238

Please sign in to comment.