Skip to content

Commit c95b238

Browse files
Merge pull request #1098 from Geode-solutions/fix/facet-storage-opposite
fix(Facets): add more api around opposite facet
2 parents a7179fa + 28ef72a commit c95b238

File tree

7 files changed

+46
-9
lines changed

7 files changed

+46
-9
lines changed

include/geode/mesh/core/detail/facet_storage.hpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ namespace geode
4343
static constexpr auto ATTRIBUTE_NAME = "facet_vertices";
4444
friend class bitsery::Access;
4545

46+
public:
47+
[[nodiscard]] bool is_opposite(
48+
index_t facet_id, const VertexContainer& vertices ) const
49+
{
50+
const OrientedVertexCycle other_oriented_cycle{ vertices };
51+
const OrientedVertexCycle oriented_cycle{ vertices_->value(
52+
facet_id ) };
53+
return oriented_cycle.is_opposite( other_oriented_cycle );
54+
}
55+
4656
protected:
4757
FacetStorage()
4858
: counter_(

include/geode/mesh/core/solid_edges.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ namespace geode
7676
[[nodiscard]] std::optional< index_t > edge_from_vertices(
7777
const std::array< index_t, 2 >& vertices ) const;
7878

79+
[[nodiscard]] bool is_opposite(
80+
index_t edge_id, const std::array< index_t, 2 >& vertices ) const;
81+
7982
/*!
8083
* Access to the manager of attributes associated with edges.
8184
*/

include/geode/mesh/core/solid_facets.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ namespace geode
7070
[[nodiscard]] std::optional< index_t > facet_from_vertices(
7171
const PolyhedronFacetVertices& vertices ) const;
7272

73+
[[nodiscard]] bool is_opposite(
74+
index_t facet_id, const PolyhedronFacetVertices& vertices ) const;
75+
7376
/*!
7477
* Access to the manager of attributes associated with facets.
7578
*/

include/geode/mesh/core/surface_edges.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ namespace geode
7474
[[nodiscard]] std::optional< index_t > edge_from_vertices(
7575
const std::array< index_t, 2 >& vertices ) const;
7676

77+
[[nodiscard]] bool is_opposite(
78+
index_t edge_id, const std::array< index_t, 2 >& vertices ) const;
79+
7780
/*!
7881
* Access to the manager of attributes associated with edges.
7982
*/

src/geode/mesh/core/solid_edges.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@ namespace geode
9696
}
9797

9898
template < index_t dimension >
99-
SolidEdges< dimension >::SolidEdges()
100-
{
101-
}
99+
SolidEdges< dimension >::SolidEdges() = default;
102100

103101
template < index_t dimension >
104102
SolidEdges< dimension >::~SolidEdges() = default;
@@ -132,6 +130,14 @@ namespace geode
132130
return impl_->find_edge( vertices );
133131
}
134132

133+
template < index_t dimension >
134+
bool SolidEdges< dimension >::is_opposite(
135+
index_t edge_id, const std::array< index_t, 2 >& vertices ) const
136+
{
137+
check_edge_id( *this, edge_id );
138+
return impl_->is_opposite( edge_id, vertices );
139+
}
140+
135141
template < index_t dimension >
136142
void SolidEdges< dimension >::update_edge_vertices(
137143
absl::Span< const index_t > old2new, SolidEdgesKey )

src/geode/mesh/core/solid_facets.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,7 @@ namespace geode
165165
}
166166

167167
template < index_t dimension >
168-
SolidFacets< dimension >::SolidFacets()
169-
{
170-
}
168+
SolidFacets< dimension >::SolidFacets() = default;
171169

172170
template < index_t dimension >
173171
SolidFacets< dimension >::~SolidFacets() = default;
@@ -201,6 +199,14 @@ namespace geode
201199
return impl_->find_facet( vertices );
202200
}
203201

202+
template < index_t dimension >
203+
bool SolidFacets< dimension >::is_opposite(
204+
index_t facet_id, const PolyhedronFacetVertices& vertices ) const
205+
{
206+
check_facet_id( *this, facet_id );
207+
return impl_->is_opposite( facet_id, vertices );
208+
}
209+
204210
template < index_t dimension >
205211
std::vector< index_t > SolidFacets< dimension >::update_facet_vertices(
206212
absl::Span< const index_t > old2new, SolidFacetsKey )

src/geode/mesh/core/surface_edges.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ namespace geode
9090
};
9191

9292
template < index_t dimension >
93-
SurfaceEdges< dimension >::SurfaceEdges()
94-
{
95-
}
93+
SurfaceEdges< dimension >::SurfaceEdges() = default;
9694

9795
template < index_t dimension >
9896
SurfaceEdges< dimension >::SurfaceEdges(
@@ -185,6 +183,14 @@ namespace geode
185183
return impl_->find_edge( vertices );
186184
}
187185

186+
template < index_t dimension >
187+
bool SurfaceEdges< dimension >::is_opposite(
188+
index_t edge_id, const std::array< index_t, 2 >& vertices ) const
189+
{
190+
check_edge_id( *this, edge_id );
191+
return impl_->is_opposite( edge_id, vertices );
192+
}
193+
188194
template < index_t dimension >
189195
AttributeManager& SurfaceEdges< dimension >::edge_attribute_manager() const
190196
{

0 commit comments

Comments
 (0)