Skip to content

Commit 773bd91

Browse files
committed
Merge branch 'next' into feat/add-inspection-before-remesh-to-ensure-model-validity
2 parents 1dae032 + babec87 commit 773bd91

21 files changed

+457
-222
lines changed

bindings/python/src/inspector/criterion/degeneration/solid_degeneration.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@ namespace geode
3939
.def( pybind11::init< const SolidMesh& >() )
4040
.def( "is_mesh_degenerated",
4141
&SolidMeshDegeneration::is_mesh_degenerated )
42-
.def( "degenerated_edges",
43-
&SolidMeshDegeneration::degenerated_edges );
42+
.def(
43+
"degenerated_edges", &SolidMeshDegeneration::degenerated_edges )
44+
.def( "degenerated_polyhedra",
45+
&SolidMeshDegeneration::degenerated_polyhedra );
4446
}
4547
void define_solid_degeneration( pybind11::module& module )
4648
{

bindings/python/src/inspector/criterion/degeneration/surface_degeneration.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@ namespace geode
4040
.def( "is_mesh_degenerated",
4141
&SurfaceMeshDegeneration::is_mesh_degenerated )
4242
.def( "degenerated_edges",
43-
&SurfaceMeshDegeneration::degenerated_edges );
43+
&SurfaceMeshDegeneration::degenerated_edges )
44+
.def( "degenerated_polygons",
45+
&SurfaceMeshDegeneration::degenerated_polygons );
4446
}
4547
void define_surface_degeneration( pybind11::module& module )
4648
{

bindings/python/tests/test-py-solid-degeneration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ def check_non_degeneration():
5050
if not degeneration_inspector.degenerated_edges().nb_issues() == 0:
5151
raise ValueError(
5252
"[Test] Solid has more degenerated edges than it should.")
53+
del degeneration_inspector
5354

5455
def check_degeneration_by_colocalisation():
5556
solid = geode.TetrahedralSolid3D.create()
@@ -73,6 +74,7 @@ def check_degeneration_by_colocalisation():
7374
raise ValueError("[Test] Solid has wrong number of degenerated edges.")
7475
if not degeneration_inspector.degenerated_edges().issues()[0] == solid.edges().edge_from_vertices([1, 4]):
7576
raise ValueError("[Test] Solid has wrong degenerated edges.")
77+
del degeneration_inspector
7678

7779

7880
def check_degeneration_by_point_multiple_presence():
@@ -97,6 +99,7 @@ def check_degeneration_by_point_multiple_presence():
9799
"[Test] Solid has the wrong number of degenerated edges.")
98100
if not degeneration_inspector.degenerated_edges().issues()[0] == solid.edges().edge_from_vertices([1, 1]):
99101
raise ValueError("[Test] Solid shows the wrong degenerated edges.")
102+
del degeneration_inspector
100103

101104

102105
if __name__ == '__main__':

bindings/python/tests/test-py-surface-degeneration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def check_non_degeneration2D():
4949
if not degeneration_inspector.degenerated_edges().nb_issues() == 0:
5050
raise ValueError(
5151
"[Test] Surface has more degenerated edges than it should.")
52+
del degeneration_inspector
5253

5354
def check_degeneration_by_colocalisation2D():
5455
surface = geode.TriangulatedSurface2D.create()
@@ -72,6 +73,7 @@ def check_degeneration_by_colocalisation2D():
7273
surface.enable_edges()
7374
if not degeneration_inspector.degenerated_edges().issues()[0] == surface.edges().edge_from_vertices([1, 3]):
7475
raise ValueError("[Test] Surface has wrong degenerated edges.")
76+
del degeneration_inspector
7577

7678

7779
def check_degeneration_by_point_multiple_presence2D():
@@ -95,6 +97,7 @@ def check_degeneration_by_point_multiple_presence2D():
9597
surface.enable_edges()
9698
if not degeneration_inspector.degenerated_edges().issues()[0] == surface.edges().edge_from_vertices([1, 1]):
9799
raise ValueError("[Test] Surface shows the wrong degenerated edges.")
100+
del degeneration_inspector
98101

99102

100103
def check_non_degeneration3D():
@@ -116,6 +119,7 @@ def check_non_degeneration3D():
116119
if not degeneration_inspector.degenerated_edges().nb_issues() == 0:
117120
raise ValueError(
118121
"[Test] (3D) Surface has more degenerated edges than it should.")
122+
del degeneration_inspector
119123

120124
def check_degeneration_by_colocalisation3D():
121125
surface = geode.TriangulatedSurface3D.create()
@@ -140,6 +144,7 @@ def check_degeneration_by_colocalisation3D():
140144
surface.enable_edges()
141145
if not degeneration_inspector.degenerated_edges().issues()[0] == surface.edges().edge_from_vertices([1, 3]):
142146
raise ValueError("[Test] (3D) Surface has wrong degenerated edges.")
147+
del degeneration_inspector
143148

144149

145150
def check_degeneration_by_point_multiple_presence3D():
@@ -164,6 +169,7 @@ def check_degeneration_by_point_multiple_presence3D():
164169
if not degeneration_inspector.degenerated_edges().issues()[0] == surface.edges().edge_from_vertices([1, 1]):
165170
raise ValueError(
166171
"[Test] (3D) Surface shows the wrong degenerated edges.")
172+
del degeneration_inspector
167173

168174

169175
if __name__ == '__main__':

include/geode/inspector/criterion/internal/component_meshes_adjacency.hpp

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -36,25 +36,28 @@ namespace geode
3636

3737
namespace geode
3838
{
39-
/*!
40-
* Class for inspecting the adjacency of edges in the Component Meshes of
41-
* a Model (BRep or Section).
42-
*/
43-
template < typename Model >
44-
class ComponentMeshesAdjacency
39+
namespace internal
4540
{
46-
OPENGEODE_DISABLE_COPY( ComponentMeshesAdjacency );
47-
48-
public:
49-
void add_surfaces_edges_with_wrong_adjacencies(
50-
InspectionIssuesMap< PolygonEdge >& issues_map ) const;
51-
52-
protected:
53-
explicit ComponentMeshesAdjacency( const Model& model );
54-
55-
[[nodiscard]] const Model& model() const;
56-
57-
private:
58-
const Model& model_;
59-
};
41+
/*!
42+
* Class for inspecting the adjacency of edges in the Component Meshes
43+
* of a Model (BRep or Section).
44+
*/
45+
template < typename Model >
46+
class ComponentMeshesAdjacency
47+
{
48+
OPENGEODE_DISABLE_COPY( ComponentMeshesAdjacency );
49+
50+
public:
51+
void add_surfaces_edges_with_wrong_adjacencies(
52+
InspectionIssuesMap< PolygonEdge >& issues_map ) const;
53+
54+
protected:
55+
explicit ComponentMeshesAdjacency( const Model& model );
56+
57+
[[nodiscard]] const Model& model() const;
58+
59+
private:
60+
const Model& model_;
61+
};
62+
} // namespace internal
6063
} // namespace geode

include/geode/inspector/criterion/internal/component_meshes_degeneration.hpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,31 @@ namespace geode
3636

3737
namespace geode
3838
{
39-
/*!
40-
* Class for inspecting the degeneration of elements in the Component Meshes
41-
* of a Model (BRep or Section).
42-
*/
43-
template < typename Model >
44-
class ComponentMeshesDegeneration
39+
namespace internal
4540
{
46-
OPENGEODE_DISABLE_COPY( ComponentMeshesDegeneration );
41+
/*!
42+
* Class for inspecting the degeneration of elements in the Component
43+
* Meshes of a Model (BRep or Section).
44+
*/
45+
template < typename Model >
46+
class ComponentMeshesDegeneration
47+
{
48+
OPENGEODE_DISABLE_COPY( ComponentMeshesDegeneration );
4749

48-
public:
49-
void add_degenerated_edges(
50-
InspectionIssuesMap< index_t >& issues_map ) const;
50+
public:
51+
void add_degenerated_edges(
52+
InspectionIssuesMap< index_t >& issues_map ) const;
5153

52-
void add_degenerated_polygons(
53-
InspectionIssuesMap< index_t >& issues_map ) const;
54+
void add_degenerated_polygons(
55+
InspectionIssuesMap< index_t >& issues_map ) const;
5456

55-
protected:
56-
explicit ComponentMeshesDegeneration( const Model& model );
57+
protected:
58+
explicit ComponentMeshesDegeneration( const Model& model );
5759

58-
[[nodiscard]] const Model& model() const;
60+
[[nodiscard]] const Model& model() const;
5961

60-
private:
61-
const Model& model_;
62-
};
62+
private:
63+
const Model& model_;
64+
};
65+
} // namespace internal
6366
} // namespace geode

include/geode/inspector/criterion/internal/component_meshes_manifold.hpp

Lines changed: 27 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,28 +32,32 @@
3232

3333
namespace geode
3434
{
35-
/*!
36-
* Class for inspecting the manifold property in the Component Meshes of
37-
* a Model (BRep or Section).
38-
*/
39-
template < typename Model >
40-
class ComponentMeshesManifold
35+
namespace internal
4136
{
42-
OPENGEODE_DISABLE_COPY( ComponentMeshesManifold );
43-
44-
public:
45-
void add_surfaces_meshes_non_manifold_vertices(
46-
InspectionIssuesMap< index_t >& issues_map ) const;
47-
48-
void add_surfaces_meshes_non_manifold_edges(
49-
InspectionIssuesMap< std::array< index_t, 2 > >& issues_map ) const;
50-
51-
protected:
52-
explicit ComponentMeshesManifold( const Model& model );
53-
54-
[[nodiscard]] const Model& model() const;
55-
56-
private:
57-
const Model& model_;
58-
};
37+
/*!
38+
* Class for inspecting the manifold property in the Component Meshes of
39+
* a Model (BRep or Section).
40+
*/
41+
template < typename Model >
42+
class ComponentMeshesManifold
43+
{
44+
OPENGEODE_DISABLE_COPY( ComponentMeshesManifold );
45+
46+
public:
47+
void add_surfaces_meshes_non_manifold_vertices(
48+
InspectionIssuesMap< index_t >& issues_map ) const;
49+
50+
void add_surfaces_meshes_non_manifold_edges(
51+
InspectionIssuesMap< std::array< index_t, 2 > >& issues_map )
52+
const;
53+
54+
protected:
55+
explicit ComponentMeshesManifold( const Model& model );
56+
57+
[[nodiscard]] const Model& model() const;
58+
59+
private:
60+
const Model& model_;
61+
};
62+
} // namespace internal
5963
} // namespace geode

include/geode/inspector/criterion/internal/degeneration_impl.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ namespace geode
5353

5454
private:
5555
const Mesh& mesh_;
56+
bool enabled_edges_;
5657
};
5758
} // namespace internal
5859
} // namespace geode

src/bin/CMakeLists.txt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,38 @@ add_geode_binary(
6262
${PROJECT_NAME}::inspector
6363
)
6464

65+
add_geode_binary(
66+
SOURCE "geode-inspector-implicit-cross-section.cpp"
67+
DEPENDENCIES
68+
Async++
69+
absl::flags
70+
absl::flags_parse
71+
absl::flags_usage
72+
OpenGeode::basic
73+
OpenGeode::geometry
74+
OpenGeode::mesh
75+
OpenGeode::model
76+
OpenGeode-Geosciences::implicit
77+
OpenGeode-GeosciencesIO::model
78+
${PROJECT_NAME}::inspector
79+
)
80+
81+
add_geode_binary(
82+
SOURCE "geode-inspector-implicit-structural-model.cpp"
83+
DEPENDENCIES
84+
Async++
85+
absl::flags
86+
absl::flags_parse
87+
absl::flags_usage
88+
OpenGeode::basic
89+
OpenGeode::geometry
90+
OpenGeode::mesh
91+
OpenGeode::model
92+
OpenGeode-Geosciences::implicit
93+
OpenGeode-GeosciencesIO::model
94+
${PROJECT_NAME}::inspector
95+
)
96+
6597
add_geode_binary(
6698
SOURCE "geode-inspector-pointset.cpp"
6799
DEPENDENCIES
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
* Copyright (c) 2019 - 2025 Geode-solutions
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining a copy
5+
* of this software and associated documentation files (the "Software"), to deal
6+
* in the Software without restriction, including without limitation the rights
7+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8+
* copies of the Software, and to permit persons to whom the Software is
9+
* furnished to do so, subject to the following conditions:
10+
*
11+
* The above copyright notice and this permission notice shall be included in
12+
* all copies or substantial portions of the Software.
13+
*
14+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20+
* SOFTWARE.
21+
*
22+
*/
23+
24+
#include <absl/flags/flag.h>
25+
#include <absl/flags/parse.h>
26+
#include <absl/flags/usage.h>
27+
28+
#include <async++.h>
29+
30+
#include <geode/basic/assert.hpp>
31+
#include <geode/basic/filename.hpp>
32+
#include <geode/basic/logger.hpp>
33+
34+
#include <geode/geosciences/implicit/representation/core/implicit_cross_section.hpp>
35+
#include <geode/geosciences/implicit/representation/io/implicit_cross_section_input.hpp>
36+
37+
#include <geode/geosciences_io/model/common.hpp>
38+
39+
#include <geode/inspector/section_inspector.hpp>
40+
41+
ABSL_FLAG( std::string, input, "/path/my/model.og_ixsctn", "Input model" );
42+
43+
void inspect_implicit_cross_section(
44+
const geode::ImplicitCrossSection& cross_section )
45+
{
46+
const geode::SectionInspector cross_section_inspector{ cross_section };
47+
auto result = cross_section_inspector.inspect_section();
48+
49+
geode::Logger::info( result.string() );
50+
}
51+
52+
int main( int argc, char* argv[] )
53+
{
54+
try
55+
{
56+
absl::SetProgramUsageMessage( absl::StrCat(
57+
"ImplicitCrossSection inspector from Geode-solutions.\n",
58+
"Sample usage:\n", argv[0], " --input my_cross_section.og_ixsctn\n",
59+
"Default behavior tests all available criteria, to disable one "
60+
"use --noXXX, e.g. --nocomponent_linking" ) );
61+
absl::ParseCommandLine( argc, argv );
62+
63+
geode::GeosciencesIOModelLibrary::initialize();
64+
const auto filename = absl::GetFlag( FLAGS_input );
65+
66+
inspect_implicit_cross_section(
67+
geode::load_implicit_cross_section( filename ) );
68+
69+
return 0;
70+
}
71+
catch( ... )
72+
{
73+
return geode::geode_lippincott();
74+
}
75+
}

0 commit comments

Comments
 (0)