Skip to content

Commit a840e37

Browse files
committed
feat(Binaries): Added a binary to inspect structural models.
1 parent df2faa3 commit a840e37

File tree

6 files changed

+436
-8
lines changed

6 files changed

+436
-8
lines changed

.github/workflows/CD.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
uses: Geode-solutions/actions/.github/workflows/cd-linux.yml@master
1010
with:
1111
name: OPENGEODE_INSPECTOR
12-
repos: OpenGeode;OpenGeode-IO
12+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
1313
secrets:
1414
TOKEN: ${{ secrets.TOKEN }}
1515
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -18,7 +18,7 @@ jobs:
1818
uses: Geode-solutions/actions/.github/workflows/cd-linux-python.yml@master
1919
with:
2020
name: OPENGEODE_INSPECTOR
21-
repos: OpenGeode;OpenGeode-IO
21+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
2222
secrets:
2323
TOKEN: ${{ secrets.TOKEN }}
2424
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -28,7 +28,7 @@ jobs:
2828
uses: Geode-solutions/actions/.github/workflows/cd-windows.yml@master
2929
with:
3030
name: OPENGEODE_INSPECTOR
31-
repos: OpenGeode;OpenGeode-IO
31+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
3232
secrets:
3333
TOKEN: ${{ secrets.TOKEN }}
3434
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -37,7 +37,7 @@ jobs:
3737
uses: Geode-solutions/actions/.github/workflows/cd-windows-python.yml@master
3838
with:
3939
name: OPENGEODE_INSPECTOR
40-
repos: OpenGeode;OpenGeode-IO
40+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
4141
secrets:
4242
TOKEN: ${{ secrets.TOKEN }}
4343
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

.github/workflows/CI.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
needs: format
1717
uses: Geode-solutions/actions/.github/workflows/ci-linux.yml@master
1818
with:
19-
repos: OpenGeode;OpenGeode-IO
19+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
2020
secrets:
2121
TOKEN: ${{ secrets.TOKEN }}
2222
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -26,7 +26,7 @@ jobs:
2626
uses: Geode-solutions/actions/.github/workflows/ci-linux-python.yml@master
2727
with:
2828
name: OPENGEODE_INSPECTOR
29-
repos: OpenGeode;OpenGeode-IO
29+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
3030
secrets:
3131
TOKEN: ${{ secrets.TOKEN }}
3232
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
@@ -35,7 +35,7 @@ jobs:
3535
needs: format
3636
uses: Geode-solutions/actions/.github/workflows/coverage.yml@master
3737
with:
38-
repos: OpenGeode;OpenGeode-IO
38+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
3939
secrets:
4040
TOKEN: ${{ secrets.TOKEN }}
4141

@@ -44,7 +44,7 @@ jobs:
4444
uses: Geode-solutions/actions/.github/workflows/ci-windows.yml@master
4545
with:
4646
name: OPENGEODE_INSPECTOR
47-
repos: OpenGeode;OpenGeode-IO
47+
repos: OpenGeode;OpenGeode-IO;OpenGeode-Geosciences;OpenGeode-GeosciencesIO
4848
secrets:
4949
TOKEN: ${{ secrets.TOKEN }}
5050
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ option(OPENGEODE_INSPECTOR_WITH_PYTHON "Compile Python bindings" OFF)
3030
find_package(OpenGeode REQUIRED)
3131
find_package(Async++ REQUIRED)
3232
find_package(OpenGeode-IO REQUIRED)
33+
find_package(OpenGeode-Geosciences REQUIRED)
34+
find_package(OpenGeode-GeosciencesIO REQUIRED)
3335

3436
#------------------------------------------------------------------------------------------------
3537
# Configure the OpenGeode-inspector libraries

src/bin/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,22 @@ add_geode_binary(
100100
OpenGeode-IO::mesh
101101
OpenGeode-IO::model
102102
${PROJECT_NAME}::inspector
103+
)
104+
105+
add_geode_binary(
106+
SOURCE "geode-inspector-structural-model.cpp"
107+
DEPENDENCIES
108+
Async++
109+
absl::flags
110+
absl::flags_parse
111+
absl::flags_usage
112+
OpenGeode::basic
113+
OpenGeode::geometry
114+
OpenGeode::mesh
115+
OpenGeode::model
116+
OpenGeode-IO::mesh
117+
OpenGeode-IO::model
118+
OpenGeode-Geosciences::geosciences
119+
OpenGeode-GeosciencesIO::geosciences
120+
${PROJECT_NAME}::inspector
103121
)
Lines changed: 184 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,184 @@
1+
/*
2+
* Copyright (c) 2019 - 2022 Geode-solutions. All rights reserved.
3+
*/
4+
5+
#include <absl/flags/flag.h>
6+
#include <absl/flags/parse.h>
7+
#include <absl/flags/usage.h>
8+
9+
#include <async++.h>
10+
11+
#include <geode/basic/assert.h>
12+
#include <geode/basic/filename.h>
13+
#include <geode/basic/logger.h>
14+
15+
#include <geode/geosciences/representation/core/cross_section.h>
16+
#include <geode/geosciences/representation/io/cross_section_input.h>
17+
18+
#include <geode/geosciences/detail/common.h>
19+
20+
#include <geode/inspector/section_inspector.h>
21+
22+
ABSL_FLAG( std::string, input, "/path/my/model.og_xsctn", "Input model" );
23+
ABSL_FLAG( bool,
24+
component_linking,
25+
true,
26+
"Toggle components linking to unique vertices criterion" );
27+
ABSL_FLAG( bool,
28+
corners,
29+
true,
30+
"Toggle inspection of corner topology through unique vertices" );
31+
ABSL_FLAG( bool,
32+
lines,
33+
true,
34+
"Toggle inspection of lines topology through unique vertices" );
35+
ABSL_FLAG( bool,
36+
surfaces,
37+
true,
38+
"Toggle inspection of surfaces topology through unique vertices" );
39+
ABSL_FLAG( bool,
40+
verbose,
41+
false,
42+
"Toggle verbose mode for the inspection of topology through unique "
43+
"vertices" );
44+
45+
void inspect_cross_section( const geode::CrossSection& cross_section )
46+
{
47+
const auto verbose = absl::GetFlag( FLAGS_verbose );
48+
const geode::SectionInspector cross_section_inspector{ cross_section,
49+
verbose };
50+
absl::InlinedVector< async::task< void >, 13 > tasks;
51+
if( absl::GetFlag( FLAGS_component_linking ) )
52+
{
53+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
54+
const auto nb_corners =
55+
cross_section_inspector
56+
.nb_corners_not_linked_to_a_unique_vertex();
57+
geode::Logger::info(
58+
nb_corners, " corners not linked to a unique vertex" );
59+
} ) );
60+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
61+
const auto nb_lines =
62+
cross_section_inspector
63+
.nb_lines_meshed_but_not_linked_to_a_unique_vertex();
64+
geode::Logger::info(
65+
nb_lines, " lines meshed but not linked to a unique vertex" );
66+
} ) );
67+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
68+
const auto nb_surfaces =
69+
cross_section_inspector
70+
.nb_surfaces_meshed_but_not_linked_to_a_unique_vertex();
71+
geode::Logger::info( nb_surfaces,
72+
" surfaces meshed but not linked to a unique vertex" );
73+
} ) );
74+
}
75+
if( absl::GetFlag( FLAGS_corners ) )
76+
{
77+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
78+
const auto nb =
79+
cross_section_inspector.multiple_corners_unique_vertices()
80+
.size();
81+
geode::Logger::info(
82+
nb, " unique vertices associated to multiple corners." );
83+
} ) );
84+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
85+
const auto nb =
86+
cross_section_inspector.multiple_internals_corner_vertices()
87+
.size();
88+
geode::Logger::info( nb, " unique vertices associated to a corner "
89+
"with multiple internals." );
90+
} ) );
91+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
92+
const auto nb = cross_section_inspector
93+
.not_internal_nor_boundary_corner_vertices()
94+
.size();
95+
geode::Logger::info( nb,
96+
" unique vertices associated to a corner which is neither "
97+
"internal nor boundary." );
98+
} ) );
99+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
100+
const auto nb =
101+
cross_section_inspector
102+
.internal_with_multiple_incidences_corner_vertices()
103+
.size();
104+
geode::Logger::info( nb,
105+
" unique vertices associated to a corner which is internal "
106+
"but has multiple incidences." );
107+
} ) );
108+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
109+
const auto nb =
110+
cross_section_inspector.line_corners_without_boundary_status()
111+
.size();
112+
geode::Logger::info( nb, " unique vertices associated to a corner "
113+
"part of a line but not boundary of it." );
114+
} ) );
115+
}
116+
if( absl::GetFlag( FLAGS_lines ) )
117+
{
118+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
119+
const auto nb =
120+
cross_section_inspector
121+
.part_of_not_boundary_nor_internal_line_unique_vertices()
122+
.size();
123+
geode::Logger::info( nb, " unique vertices part of a line which is "
124+
"neither internal nor boundary." );
125+
} ) );
126+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
127+
const auto nb =
128+
cross_section_inspector
129+
.part_of_line_with_invalid_internal_topology_unique_vertices()
130+
.size();
131+
geode::Logger::info( nb, " unique vertices part of a line with "
132+
"invalid internal topology." );
133+
} ) );
134+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
135+
const auto nb = cross_section_inspector
136+
.part_of_invalid_unique_line_unique_vertices()
137+
.size();
138+
geode::Logger::info( nb, " unique vertices part of a unique line "
139+
"with invalid topology." );
140+
} ) );
141+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
142+
const auto nb = cross_section_inspector
143+
.part_of_lines_but_not_corner_unique_vertices()
144+
.size();
145+
geode::Logger::info( nb,
146+
" unique vertices part of multiple lines but not a corner." );
147+
} ) );
148+
}
149+
if( absl::GetFlag( FLAGS_surfaces ) )
150+
{
151+
tasks.emplace_back( async::spawn( [&cross_section_inspector] {
152+
const auto nb = cross_section_inspector
153+
.part_of_invalid_surfaces_unique_vertices()
154+
.size();
155+
geode::Logger::info( nb,
156+
" unique vertices part of surfaces with invalid topology." );
157+
} ) );
158+
}
159+
async::when_all( tasks.begin(), tasks.end() ).wait();
160+
}
161+
162+
int main( int argc, char* argv[] )
163+
{
164+
try
165+
{
166+
absl::SetProgramUsageMessage( absl::StrCat(
167+
"CrossSection inspector from Geode-solutions.\n", "Sample usage:\n",
168+
argv[0], " --input my_cross_section.og_xsctn\n",
169+
"Default behavior tests all available criteria, to disable one "
170+
"use --noXXX, e.g. --nocomponent_linking" ) );
171+
absl::ParseCommandLine( argc, argv );
172+
173+
geode::detail::initialize_geosciences_io();
174+
const auto filename = absl::GetFlag( FLAGS_input );
175+
176+
inspect_cross_section( geode::load_cross_section( filename ) );
177+
178+
return 0;
179+
}
180+
catch( ... )
181+
{
182+
return geode::geode_lippincott();
183+
}
184+
}

0 commit comments

Comments
 (0)