Skip to content

Commit 75bc023

Browse files
fix(Inspector): Added executables for the inspection of Pointsets, EdgedCurves and Solids. (#13)
1 parent 79ef9d0 commit 75bc023

File tree

6 files changed

+293
-3
lines changed

6 files changed

+293
-3
lines changed

src/bin/CMakeLists.txt

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2019 - 2021 Geode-solutions
1+
# Copyright (c) 2019 - 2022 Geode-solutions
22
#
33
# Permission is hereby granted, free of charge, to any person obtaining a copy
44
# of this software and associated documentation files (the "Software"), to deal
@@ -18,6 +18,32 @@
1818
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1919
# SOFTWARE.
2020

21+
add_geode_binary(
22+
SOURCE "geode-inspector-pointset.cpp"
23+
DEPENDENCIES
24+
Async++
25+
absl::flags
26+
absl::flags_parse
27+
absl::flags_usage
28+
OpenGeode::basic
29+
OpenGeode::mesh
30+
OpenGeode-IO::mesh
31+
${PROJECT_NAME}::inspector
32+
)
33+
34+
add_geode_binary(
35+
SOURCE "geode-inspector-edgedcurve.cpp"
36+
DEPENDENCIES
37+
Async++
38+
absl::flags
39+
absl::flags_parse
40+
absl::flags_usage
41+
OpenGeode::basic
42+
OpenGeode::mesh
43+
OpenGeode-IO::mesh
44+
${PROJECT_NAME}::inspector
45+
)
46+
2147
add_geode_binary(
2248
SOURCE "geode-inspector-surface.cpp"
2349
DEPENDENCIES
@@ -31,6 +57,19 @@ add_geode_binary(
3157
${PROJECT_NAME}::inspector
3258
)
3359

60+
add_geode_binary(
61+
SOURCE "geode-inspector-solid.cpp"
62+
DEPENDENCIES
63+
Async++
64+
absl::flags
65+
absl::flags_parse
66+
absl::flags_usage
67+
OpenGeode::basic
68+
OpenGeode::mesh
69+
OpenGeode-IO::mesh
70+
${PROJECT_NAME}::inspector
71+
)
72+
3473
add_geode_binary(
3574
SOURCE "geode-inspector-brep-topology.cpp"
3675
DEPENDENCIES

src/bin/geode-inspector-brep-topology.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019 - 2021 Geode-solutions. All rights reserved.
2+
* Copyright (c) 2019 - 2022 Geode-solutions. All rights reserved.
33
*/
44

55
#include <absl/flags/flag.h>
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
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/mesh/core/edged_curve.h>
16+
#include <geode/mesh/core/mesh_factory.h>
17+
#include <geode/mesh/io/edged_curve_input.h>
18+
19+
#include <geode/io/mesh/detail/common.h>
20+
21+
#include <geode/inspector/criterion/colocation/edgedcurve_colocation.h>
22+
#include <geode/inspector/criterion/degeneration/edgedcurve_degeneration.h>
23+
24+
ABSL_FLAG( std::string, input, "/path/my/curve.og_edc3d", "Input edged curve" );
25+
ABSL_FLAG( bool, colocation, true, "Toggle colocation criterion" );
26+
ABSL_FLAG( bool, degeneration, true, "Toggle degeneration criterion" );
27+
28+
template < geode::index_t dimension >
29+
void inspect_edgedcurve( const geode::EdgedCurve< dimension >& edgedcurve )
30+
{
31+
absl::InlinedVector< async::task< void >, 2 > tasks;
32+
if( absl::GetFlag( FLAGS_colocation ) )
33+
{
34+
tasks.emplace_back( async::spawn( [&edgedcurve] {
35+
const geode::EdgedCurveColocation< dimension > colocation{
36+
edgedcurve
37+
};
38+
const auto nb = colocation.nb_colocated_points();
39+
geode::Logger::info( nb, " colocated points" );
40+
} ) );
41+
}
42+
if( absl::GetFlag( FLAGS_degeneration ) )
43+
{
44+
tasks.emplace_back( async::spawn( [&edgedcurve] {
45+
const geode::EdgedCurveDegeneration< dimension > degeneration{
46+
edgedcurve
47+
};
48+
const auto nb = degeneration.nb_degenerated_edges();
49+
geode::Logger::info( nb, " degenerated edges" );
50+
} ) );
51+
}
52+
async::when_all( tasks.begin(), tasks.end() ).wait();
53+
}
54+
55+
int main( int argc, char* argv[] )
56+
{
57+
try
58+
{
59+
absl::SetProgramUsageMessage(
60+
absl::StrCat( "EdgedCurve inspector from Geode-solutions.\n",
61+
"Sample usage:\n", argv[0], " --input my_edgedcurve.og_edc3d\n",
62+
"Default behavior test all available criteria, to disable one "
63+
"use --noXXX, e.g. --nocolocation" ) );
64+
absl::ParseCommandLine( argc, argv );
65+
66+
geode::detail::initialize_mesh_io();
67+
const auto filename = absl::GetFlag( FLAGS_input );
68+
const auto ext =
69+
geode::to_string( geode::extension_from_filename( filename ) );
70+
71+
if( geode::EdgedCurveInputFactory3D::has_creator( ext ) )
72+
{
73+
inspect_edgedcurve( *geode::load_edged_curve< 3 >( filename ) );
74+
}
75+
else if( geode::EdgedCurveInputFactory2D::has_creator( ext ) )
76+
{
77+
inspect_edgedcurve( *geode::load_edged_curve< 2 >( filename ) );
78+
}
79+
else
80+
{
81+
throw geode::OpenGeodeException( "Unable to load file ", filename );
82+
}
83+
84+
return 0;
85+
}
86+
catch( ... )
87+
{
88+
return geode::geode_lippincott();
89+
}
90+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
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/mesh/core/mesh_factory.h>
16+
#include <geode/mesh/core/point_set.h>
17+
#include <geode/mesh/io/point_set_input.h>
18+
19+
#include <geode/io/mesh/detail/common.h>
20+
21+
#include <geode/inspector/criterion/colocation/pointset_colocation.h>
22+
23+
ABSL_FLAG( std::string, input, "/path/my/pointset.og_pts3d", "Input pointset" );
24+
25+
template < geode::index_t dimension >
26+
void inspect_pointset( const geode::PointSet< dimension >& pointset )
27+
{
28+
const geode::PointSetColocation< dimension > colocation{ pointset };
29+
const auto nb = colocation.nb_colocated_points();
30+
geode::Logger::info( nb, " colocated points" );
31+
}
32+
33+
int main( int argc, char* argv[] )
34+
{
35+
try
36+
{
37+
absl::SetProgramUsageMessage( absl::StrCat(
38+
"PointSet inspector from Geode-solutions.\n", "Sample usage:\n",
39+
argv[0], " --input my_pointset.og_pts3d\n" ) );
40+
41+
geode::detail::initialize_mesh_io();
42+
const auto filename = absl::GetFlag( FLAGS_input );
43+
const auto ext =
44+
geode::to_string( geode::extension_from_filename( filename ) );
45+
46+
if( geode::PointSetInputFactory3D::has_creator( ext ) )
47+
{
48+
inspect_pointset( *geode::load_point_set< 3 >( filename ) );
49+
}
50+
else if( geode::PointSetInputFactory2D::has_creator( ext ) )
51+
{
52+
inspect_pointset( *geode::load_point_set< 2 >( filename ) );
53+
}
54+
else
55+
{
56+
throw geode::OpenGeodeException( "Unable to load file ", filename );
57+
}
58+
59+
return 0;
60+
}
61+
catch( ... )
62+
{
63+
return geode::geode_lippincott();
64+
}
65+
}

src/bin/geode-inspector-solid.cpp

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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/mesh/core/hybrid_solid.h>
16+
#include <geode/mesh/core/mesh_factory.h>
17+
#include <geode/mesh/core/polyhedral_solid.h>
18+
#include <geode/mesh/core/tetrahedral_solid.h>
19+
#include <geode/mesh/io/hybrid_solid_input.h>
20+
#include <geode/mesh/io/polyhedral_solid_input.h>
21+
#include <geode/mesh/io/tetrahedral_solid_input.h>
22+
23+
#include <geode/io/mesh/detail/common.h>
24+
25+
#include <geode/inspector/criterion/colocation/solid_colocation.h>
26+
#include <geode/inspector/criterion/degeneration/solid_degeneration.h>
27+
28+
ABSL_FLAG( std::string, input, "/path/my/solid.og_tso3d", "Input solid" );
29+
ABSL_FLAG( bool, colocation, true, "Toggle colocation criterion" );
30+
ABSL_FLAG( bool, degeneration, true, "Toggle degeneration criterion" );
31+
32+
template < geode::index_t dimension >
33+
void inspect_solid( const geode::SolidMesh< dimension >& solid )
34+
{
35+
absl::InlinedVector< async::task< void >, 2 > tasks;
36+
if( absl::GetFlag( FLAGS_colocation ) )
37+
{
38+
tasks.emplace_back( async::spawn( [&solid] {
39+
const geode::SolidMeshColocation< dimension > colocation{ solid };
40+
const auto nb = colocation.nb_colocated_points();
41+
geode::Logger::info( nb, " colocated points" );
42+
} ) );
43+
}
44+
if( absl::GetFlag( FLAGS_degeneration ) )
45+
{
46+
tasks.emplace_back( async::spawn( [&solid] {
47+
const geode::SolidMeshDegeneration< dimension > degeneration{
48+
solid
49+
};
50+
const auto nb = degeneration.nb_degenerated_edges();
51+
geode::Logger::info( nb, " degenerated edges" );
52+
} ) );
53+
}
54+
async::when_all( tasks.begin(), tasks.end() ).wait();
55+
}
56+
57+
int main( int argc, char* argv[] )
58+
{
59+
try
60+
{
61+
absl::SetProgramUsageMessage(
62+
absl::StrCat( "Solid inspector from Geode-solutions.\n",
63+
"Sample usage:\n", argv[0], " --input my_solid.og_tsf3d\n",
64+
"Default behavior test all available criteria, to disable one "
65+
"use --noXXX, e.g. --noadjacency" ) );
66+
absl::ParseCommandLine( argc, argv );
67+
68+
geode::detail::initialize_mesh_io();
69+
const auto filename = absl::GetFlag( FLAGS_input );
70+
const auto ext =
71+
geode::to_string( geode::extension_from_filename( filename ) );
72+
73+
if( geode::TetrahedralSolidInputFactory3D::has_creator( ext ) )
74+
{
75+
inspect_solid( *geode::load_tetrahedral_solid< 3 >( filename ) );
76+
}
77+
else if( geode::PolyhedralSolidInputFactory3D::has_creator( ext ) )
78+
{
79+
inspect_solid( *geode::load_polyhedral_solid< 3 >( filename ) );
80+
}
81+
else if( geode::HybridSolidInputFactory3D::has_creator( ext ) )
82+
{
83+
inspect_solid( *geode::load_hybrid_solid< 3 >( filename ) );
84+
}
85+
else
86+
{
87+
throw geode::OpenGeodeException( "Unable to load file ", filename );
88+
}
89+
90+
return 0;
91+
}
92+
catch( ... )
93+
{
94+
return geode::geode_lippincott();
95+
}
96+
}

src/bin/geode-inspector-surface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019 - 2021 Geode-solutions. All rights reserved.
2+
* Copyright (c) 2019 - 2022 Geode-solutions. All rights reserved.
33
*/
44

55
#include <absl/flags/flag.h>

0 commit comments

Comments
 (0)