Skip to content

Commit 92b74dc

Browse files
committed
add test for meshes
1 parent a09d55b commit 92b74dc

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

src/geode/inspector/criterion/manifold/surface_edge_manifold.cpp

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,11 @@ namespace
3636
using Edge = geode::detail::VertexCycle< std::array< geode::index_t, 2 > >;
3737

3838
template < geode::index_t dimension >
39-
absl::flat_hash_map< Edge, geode::local_index_t > edge_to_polygons_around(
40-
const geode::SurfaceMesh< dimension >& mesh )
39+
absl::flat_hash_map< Edge, std::pair< geode::local_index_t, bool > >
40+
edge_to_polygons_around( const geode::SurfaceMesh< dimension >& mesh )
4141
{
42-
absl::flat_hash_map< Edge, geode::local_index_t > polygons_around_edges;
42+
absl::flat_hash_map< Edge, std::pair< geode::local_index_t, bool > >
43+
polygons_around_edges;
4344
for( const auto polygon_id : geode::Range{ mesh.nb_polygons() } )
4445
{
4546
for( const auto polygon_edge_id :
@@ -50,10 +51,19 @@ namespace
5051
{ polygon_id, polygon_edge_id } )
5152
};
5253
if( !polygons_around_edges
53-
.try_emplace( polygon_edge_vertex_cycle, 1 )
54+
.try_emplace( polygon_edge_vertex_cycle,
55+
std::pair< geode::local_index_t, bool >{
56+
1, false } )
5457
.second )
5558
{
56-
polygons_around_edges[polygon_edge_vertex_cycle] += 1;
59+
polygons_around_edges[polygon_edge_vertex_cycle].first += 1;
60+
}
61+
const auto adj =
62+
mesh.polygon_adjacent( { polygon_id, polygon_edge_id } );
63+
if( !adj )
64+
{
65+
polygons_around_edges[polygon_edge_vertex_cycle].second =
66+
true;
5767
}
5868
}
5969
}
@@ -73,7 +83,11 @@ namespace geode
7383
{
7484
for( const auto& edge : edge_to_polygons_around( mesh_ ) )
7585
{
76-
if( edge.second > 2 )
86+
if( edge.second.second && edge.second.first != 1 )
87+
{
88+
return false;
89+
}
90+
if( !edge.second.second && edge.second.first != 2 )
7791
{
7892
return false;
7993
}
@@ -88,7 +102,14 @@ namespace geode
88102
};
89103
for( const auto& edge : edge_to_polygons_around( mesh_ ) )
90104
{
91-
if( edge.second > 2 )
105+
if( edge.second.second && edge.second.first != 1 )
106+
{
107+
non_manifold_edges.add_issue( edge.first.vertices(),
108+
absl::StrCat( "Edge between vertices with index ",
109+
edge.first.vertices()[0], " and index ",
110+
edge.first.vertices()[1], " is not manifold." ) );
111+
}
112+
if( !edge.second.second && edge.second.first != 2 )
92113
{
93114
non_manifold_edges.add_issue( edge.first.vertices(),
94115
absl::StrCat( "Edge between vertices with index ",

0 commit comments

Comments
 (0)