Skip to content

Commit 547d487

Browse files
committed
fix(SegFault): avoid segfault and trigger warning if there are problems due to unique_vertices
1 parent 9c25544 commit 547d487

File tree

5 files changed

+35
-3
lines changed

5 files changed

+35
-3
lines changed

src/geode/inspector/criterion/internal/component_meshes_adjacency.cpp

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ namespace
4343
{
4444
const auto edge_unique_vertices =
4545
geode::edge_unique_vertices( model, surface, polygon_edge );
46+
OPENGEODE_EXCEPTION( edge_unique_vertices[0] != geode::NO_ID
47+
&& edge_unique_vertices[1] != geode::NO_ID,
48+
"[ComponentMeshesAdjacency] Missing unique_vertices" );
4649
return !geode::detail::line_component_mesh_edges(
4750
model, edge_unique_vertices )
4851
.empty();
@@ -79,10 +82,22 @@ namespace geode
7982
LRange{ mesh.nb_polygon_edges( polygon_id ) } )
8083
{
8184
const PolygonEdge polygon_edge{ polygon_id, edge_id };
82-
if( mesh.is_edge_on_border( polygon_edge )
83-
&& !polygon_edge_is_on_a_line(
84-
model_, surface, polygon_edge ) )
85+
try
8586
{
87+
if( mesh.is_edge_on_border( polygon_edge )
88+
&& !polygon_edge_is_on_a_line(
89+
model_, surface, polygon_edge ) )
90+
{
91+
issues.add_issue( polygon_edge,
92+
absl::StrCat( "Local edge ", edge_id,
93+
" of polygon ", polygon_id,
94+
" has no adjacencies but is not part of a "
95+
"model Line." ) );
96+
}
97+
}
98+
catch( const OpenGeodeException& e )
99+
{
100+
Logger::warn( e.what() );
86101
issues.add_issue( polygon_edge,
87102
absl::StrCat( "Local edge ", edge_id,
88103
" of polygon ", polygon_id,

tests/data/test.shp

1.11 MB
Binary file not shown.

tests/data/test.shx

10.4 KB
Binary file not shown.

tests/inspector/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,6 @@ add_geode_test(
170170
OpenGeode::geometry
171171
OpenGeode::mesh
172172
OpenGeode::model
173+
OpenGeode-GeosciencesIO::model
173174
${PROJECT_NAME}::inspector
174175
)

tests/inspector/test-section.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
#include <geode/model/representation/core/section.hpp>
3131
#include <geode/model/representation/io/section_input.hpp>
3232

33+
#include <geode/geosciences_io/model/common.hpp>
34+
3335
#include <geode/inspector/section_inspector.hpp>
3436

3537
geode::index_t corners_topological_validity(
@@ -276,12 +278,26 @@ void check_section( bool string )
276278
nb_component_meshes_issues, " meshes problems instead of 0." );
277279
}
278280

281+
void check_section_test()
282+
{
283+
const auto model_section =
284+
geode::load_section( absl::StrCat( geode::DATA_PATH, "test.shp" ) );
285+
geode::SectionInspector section_inspector{ model_section };
286+
auto result = section_inspector.inspect_section();
287+
288+
geode::Logger::info( "vertical_lines section topology is ",
289+
section_inspector.section_topology_is_valid() ? "valid." : "invalid." );
290+
}
291+
279292
int main()
280293
{
281294
try
282295
{
283296
geode::InspectorInspectorLibrary::initialize();
297+
geode::GeosciencesIOModelLibrary::initialize();
298+
geode::Logger::set_level( geode::Logger::LEVEL::trace );
284299
check_section( false );
300+
check_section_test();
285301

286302
geode::Logger::info( "TEST SUCCESS" );
287303
return 0;

0 commit comments

Comments
 (0)