Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions bindings/python/src/inspection/information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
{
template < typename ProblemType >
inline void do_define_information(
pybind11::module& module, const std::string& typestr )

Check failure on line 34 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:34:9 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
{
using InspectionIssues = geode::InspectionIssues< ProblemType >;
const auto name = absl::StrCat( "InspectionIssues", typestr );
pybind11::class_< InspectionIssues >( module, name.c_str() )

Check failure on line 38 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:38:27 [clang-diagnostic-error]

unexpected type name 'InspectionIssues': expected expression

Check failure on line 38 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:38:9 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
.def( "set_description", &InspectionIssues::set_description )
.def( "description", &InspectionIssues::description )
.def( "nb_issues", &InspectionIssues::nb_issues )
Expand All @@ -44,29 +44,31 @@

using InspectionIssuesMap = geode::InspectionIssuesMap< ProblemType >;
const auto map_name = absl::StrCat( "InspectionIssuesMap", typestr );
pybind11::class_< InspectionIssuesMap >( module, map_name.c_str() )

Check failure on line 47 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:47:27 [clang-diagnostic-error]

unexpected type name 'InspectionIssuesMap': expected expression

Check failure on line 47 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:47:9 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
.def( "set_description", &InspectionIssuesMap::set_description )
.def( "description", &InspectionIssuesMap::description )
.def( "nb_issues", &InspectionIssuesMap::nb_issues )
.def( "nb_components_with_issues",
&InspectionIssuesMap::nb_components_with_issues )
.def( "issues_map", &InspectionIssuesMap::issues_map )
.def( "string", &InspectionIssuesMap::string );
}

inline void define_information( pybind11::module& module )

Check failure on line 57 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:57:37 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
{
do_define_information< index_t >( module, "Index" );
do_define_information< std::vector< index_t > >(
module, "VectorIndex" );
do_define_information< PolyhedronFacet >( module, "PolyhedronFacet" );

Check failure on line 62 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:62:32 [clang-diagnostic-error]

use of undeclared identifier 'PolyhedronFacet'
do_define_information< std::array< index_t, 2 > >(
module, "ArrayIndex2" );
do_define_information< PolyhedronFacetVertices >(

Check failure on line 65 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:65:32 [clang-diagnostic-error]

use of undeclared identifier 'PolyhedronFacetVertices'
module, "PolyhedronFacetVertices" );
do_define_information< PolygonEdge >( module, "PolygonEdge" );

Check failure on line 67 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:67:32 [clang-diagnostic-error]

use of undeclared identifier 'PolygonEdge'
do_define_information< std::pair< index_t, index_t > >(
module, "PairIndex" );
do_define_information< uuid >( module, "UUID" );
do_define_information< std::pair< geode::ComponentMeshElement,

Check failure on line 71 in bindings/python/src/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/information.hpp:71:50 [clang-diagnostic-error]

no member named 'ComponentMeshElement' in namespace 'geode'
geode::ComponentMeshElement > >(
module, "PairComponentMeshElement" );
}
Expand Down
10 changes: 5 additions & 5 deletions bindings/python/tests/inspection/test-py-brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,9 @@ def check_a1(verbose):
else:
print("model_A1 topology is invalid.")
nb_model_issues = launch_topological_validity_checks(result.topology, verbose)
if nb_model_issues != 5191:
if nb_model_issues != 6182:
raise ValueError(
"[Test] model model_A1 should have 5191 unique vertices with topological problems."
"[Test] model model_A1 should have 6182 unique vertices with topological problems."
)
nb_component_meshes_issues = launch_component_meshes_validity_checks(
result.meshes, verbose
Expand All @@ -242,9 +242,9 @@ def inspect_model_A1(model_brep, verbose):
else:
print("model_A1_valid topology is invalid.")
nb_model_issues = launch_topological_validity_checks(result.topology, verbose)
if nb_model_issues != 5191:
if nb_model_issues != 6182:
raise ValueError(
"[Test] model model_A1_valid should have 5191 topological problems."
"[Test] model model_A1_valid should have 6182 topological problems."
)
nb_component_meshes_issues = launch_component_meshes_validity_checks(
result.meshes, verbose
Expand All @@ -268,7 +268,7 @@ def inspect_model_mss(model_brep, verbose):
else:
print("model mss topology is invalid.")
nb_model_issues = launch_topological_validity_checks(result.topology, verbose)
if nb_model_issues != 50:
if nb_model_issues != 65:
raise ValueError(
"[Test] model mss.og_strm should have 50 topological problems, not "
+ str(nb_model_issues)
Expand Down
47 changes: 39 additions & 8 deletions include/geode/inspector/inspection/information.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,19 +69,33 @@
}

[[nodiscard]] std::string string() const
{
std::string message;
append_string( message );
return message;
}

void append_string( std::string& message ) const
{
if( issues_.empty() )
{
return absl::StrCat( "no issues with ", description_, "\n" );
absl::StrAppend(
&message, "no issues with ", description_, "\n" );
return;
}
auto message =
absl::StrCat( issues_.size(), " issues with ", description_ );
auto size = message.size() + description_.size() + 32;

Check warning on line 86 in include/geode/inspector/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/inspector/inspection/information.hpp:86:64 [cppcoreguidelines-avoid-magic-numbers]

32 is a magic number; consider replacing it with a named constant
for( const auto& issue : messages_ )
{
size += issue.size() + 2;
}
message.reserve( size );
absl::StrAppend(
&message, issues_.size(), " issues with ", description_ );
for( const auto& issue : messages_ )
{
absl::StrAppend( &message, "\n\t", issue );
}
absl::StrAppend( &message, "\n" );
return message;
message.append( "\n" );
}

[[nodiscard]] const std::vector< IssueType >& issues() const
Expand Down Expand Up @@ -119,7 +133,23 @@
return description_;
}

/*!
* Total number of issues, summed over every component of the map
*/
[[nodiscard]] index_t nb_issues() const
{
index_t nb{ 0 };

Check warning on line 141 in include/geode/inspector/inspection/information.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/inspector/inspection/information.hpp:141:21 [readability-identifier-length]

variable name 'nb' is too short, expected at least 3 characters
for( const auto& issues : issues_map_ )
{
nb += issues.second.nb_issues();
}
return nb;
}

/*!
* Number of components having at least one issue
*/
[[nodiscard]] index_t nb_components_with_issues() const
{
return issues_map_.size();
}
Expand All @@ -140,11 +170,12 @@
{
return absl::StrCat( "no issues with ", description_, "\n" );
}
auto message = absl::StrCat(
issues_map_.size(), " issues with ", description_ );
auto message =
absl::StrCat( nb_issues(), " issues with ", description_ );
for( const auto& issues : issues_map_ )
{
absl::StrAppend( &message, "\n\t", issues.second.string() );
message.append( "\n\t" );
issues.second.append_string( message );
}
absl::StrAppend( &message, "\n" );
return message;
Expand Down
4 changes: 1 addition & 3 deletions src/bin/geode-inspector-brep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

ABSL_FLAG( std::string, input, "/path/my/model.og_brep", "Input model" );

void inspect_brep( const geode::BRep& brep )

Check warning on line 44 in src/bin/geode-inspector-brep.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-brep.cpp:44:6 [misc-use-internal-linkage]

function 'inspect_brep' can be made static or moved into an anonymous namespace to enforce internal linkage
{
const geode::BRepInspector brep_inspector{ brep };
auto result = brep_inspector.inspect_brep();
Expand All @@ -54,9 +54,7 @@
{
absl::SetProgramUsageMessage(
absl::StrCat( "BRep inspector from Geode-solutions.\n",
"Sample usage:\n", argv[0], " --input my_brep.og_brep\n",
"Default behavior tests all available criteria, to disable one "
"use --noXXX, e.g. --nocomponent_linking" ) );
"Sample usage:\n", argv[0], " --input my_brep.og_brep\n" ) );

Check warning on line 57 in src/bin/geode-inspector-brep.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-brep.cpp:57:36 [cppcoreguidelines-pro-bounds-pointer-arithmetic]

do not use pointer arithmetic
absl::ParseCommandLine( argc, argv );

geode::OpenGeodeIOModelLibrary::initialize();
Expand Down
8 changes: 3 additions & 5 deletions src/bin/geode-inspector-edgedcurve.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
ABSL_FLAG( std::string, input, "/path/my/curve.og_edc3d", "Input edged curve" );

template < geode::index_t dimension >
void inspect_edged_curve( const geode::EdgedCurve< dimension >& edged_curve )

Check warning on line 47 in src/bin/geode-inspector-edgedcurve.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-edgedcurve.cpp:47:6 [misc-use-internal-linkage]

function 'inspect_edged_curve' can be made static or moved into an anonymous namespace to enforce internal linkage
{
const geode::EdgedCurveInspector< dimension > inspector{ edged_curve };
const auto result = inspector.inspect_edged_curve();
Expand All @@ -56,11 +56,9 @@
{
try
{
absl::SetProgramUsageMessage(
absl::StrCat( "EdgedCurve inspector from Geode-solutions.\n",
"Sample usage:\n", argv[0], " --input my_edgedcurve.og_edc3d\n",
"Default behavior test all available criteria, to disable one "
"use --noXXX, e.g. --nocolocation" ) );
absl::SetProgramUsageMessage( absl::StrCat(
"EdgedCurve inspector from Geode-solutions.\n", "Sample usage:\n",
argv[0], " --input my_edgedcurve.og_edc3d\n" ) );

Check warning on line 61 in src/bin/geode-inspector-edgedcurve.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-edgedcurve.cpp:61:13 [cppcoreguidelines-pro-bounds-pointer-arithmetic]

do not use pointer arithmetic
absl::ParseCommandLine( argc, argv );

geode::OpenGeodeIOMeshLibrary::initialize();
Expand Down
4 changes: 1 addition & 3 deletions src/bin/geode-inspector-section.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

ABSL_FLAG( std::string, input, "/path/my/model.og_sctn", "Input model" );

void inspect_section( const geode::Section& section )

Check warning on line 43 in src/bin/geode-inspector-section.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-section.cpp:43:6 [misc-use-internal-linkage]

function 'inspect_section' can be made static or moved into an anonymous namespace to enforce internal linkage
{
const geode::SectionInspector section_inspector{ section };

Expand All @@ -54,9 +54,7 @@
{
absl::SetProgramUsageMessage(
absl::StrCat( "Section inspector from Geode-solutions.\n",
"Sample usage:\n", argv[0], " --input my_section.og_sctn\n",
"Default behavior tests all available criteria, to disable one "
"use --noXXX, e.g. --nocomponent_linking" ) );
"Sample usage:\n", argv[0], " --input my_section.og_sctn\n" ) );

Check warning on line 57 in src/bin/geode-inspector-section.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-section.cpp:57:36 [cppcoreguidelines-pro-bounds-pointer-arithmetic]

do not use pointer arithmetic
absl::ParseCommandLine( argc, argv );

geode::OpenGeodeIOModelLibrary::initialize();
Expand Down
4 changes: 1 addition & 3 deletions src/bin/geode-inspector-solid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
ABSL_FLAG( std::string, input, "/path/my/solid.og_tso3d", "Input solid" );

template < geode::index_t dimension >
void inspect_solid( const geode::SolidMesh< dimension >& solid )

Check warning on line 53 in src/bin/geode-inspector-solid.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-solid.cpp:53:6 [misc-use-internal-linkage]

function 'inspect_solid' can be made static or moved into an anonymous namespace to enforce internal linkage
{
const geode::SolidMeshInspector< dimension > inspector{ solid };
const auto result = inspector.inspect_solid();
Expand All @@ -63,9 +63,7 @@
{
absl::SetProgramUsageMessage(
absl::StrCat( "Solid inspector from Geode-solutions.\n",
"Sample usage:\n", argv[0], " --input my_solid.og_tsf3d\n",
"Default behavior test all available criteria, to disable one "
"use --noXXX, e.g. --noadjacency" ) );
"Sample usage:\n", argv[0], " --input my_solid.og_tsf3d\n" ) );

Check warning on line 66 in src/bin/geode-inspector-solid.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/bin/geode-inspector-solid.cpp:66:36 [cppcoreguidelines-pro-bounds-pointer-arithmetic]

do not use pointer arithmetic
absl::ParseCommandLine( argc, argv );

geode::OpenGeodeIOMeshLibrary::initialize();
Expand Down
8 changes: 3 additions & 5 deletions src/bin/geode-inspector-surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@ int main( int argc, char* argv[] )
{
try
{
absl::SetProgramUsageMessage(
absl::StrCat( "Surface inspector from Geode-solutions.\n",
"Sample usage:\n", argv[0], " --input my_surface.og_tsf3d\n",
"Default behavior test all available criteria, to disable one "
"use --noXXX, e.g. --noadjacency" ) );
absl::SetProgramUsageMessage( absl::StrCat(
"Surface inspector from Geode-solutions.\n", "Sample usage:\n",
argv[0], " --input my_surface.og_tsf3d\n" ) );
absl::ParseCommandLine( argc, argv );

geode::OpenGeodeIOMeshLibrary::initialize();
Expand Down
8 changes: 8 additions & 0 deletions tests/inspection/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ add_geode_test(
OpenGeode::mesh
${PROJECT_NAME}::inspection
)

add_geode_test(
SOURCE "test-information.cpp"
DEPENDENCIES
OpenGeode::basic
${PROJECT_NAME}::inspection
)

add_geode_test(
SOURCE "test-edgedcurve-colocation.cpp"
DEPENDENCIES
Expand Down
26 changes: 16 additions & 10 deletions tests/inspection/test-brep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,11 @@ geode::index_t lines_topological_validity(
result
.unique_vertices_linked_to_several_lines_but_not_linked_to_a_corner
.nb_issues();
nb_issues +=
result.line_edges_with_wrong_component_edges_around.nb_issues();
for( const auto& issue :
result.line_edges_with_wrong_component_edges_around.issues_map() )
{
nb_issues += issue.second.nb_issues();
}
geode::Logger::info( "BRep Lines Topology check: ", nb_issues, " issues." );
if( string )
{
Expand All @@ -108,8 +111,11 @@ geode::index_t surfaces_topological_validity(
nb_issues +=
result.unique_vertices_linked_to_a_surface_with_invalid_embbedings
.nb_issues();
nb_issues +=
result.surface_polygons_with_wrong_component_facets_around.nb_issues();
for( const auto& issue : result
.surface_polygons_with_wrong_component_facets_around.issues_map() )
{
nb_issues += issue.second.nb_issues();
}
geode::Logger::info(
"BRep Surfaces Topology check: ", nb_issues, " issues." );
if( string )
Expand Down Expand Up @@ -326,8 +332,8 @@ void check_model_a1( bool string )
const auto nb_topological_issues =
launch_topological_validity_checks( result.topology, string );
geode::OpenGeodeInspectorInspectionException::test(
nb_topological_issues == 5191, "model_A1 has ", nb_topological_issues,
" topological problems instead of 5191." );
nb_topological_issues == 6182, "model_A1 has ", nb_topological_issues,
" topological problems instead of 6182." );

const auto nb_component_meshes_issues =
launch_component_meshes_validity_checks( result.meshes, string );
Expand All @@ -349,8 +355,8 @@ void check_model_a1_valid( bool string )
const auto nb_topological_issues =
launch_topological_validity_checks( result.topology, string );
geode::OpenGeodeInspectorInspectionException::test(
nb_topological_issues == 5191, "model_A1_valid has ",
nb_topological_issues, " topological problems instead of 5191." );
nb_topological_issues == 6182, "model_A1_valid has ",
nb_topological_issues, " topological problems instead of 6182." );

const auto nb_component_meshes_issues =
launch_component_meshes_validity_checks( result.meshes, string );
Expand All @@ -372,8 +378,8 @@ void check_model_mss( bool string )
const auto nb_topological_issues =
launch_topological_validity_checks( result.topology, string );
geode::OpenGeodeInspectorInspectionException::test(
nb_topological_issues == 50, "mss has ", nb_topological_issues,
" topological problems instead of 50." );
nb_topological_issues == 65, "mss has ", nb_topological_issues,
" topological problems instead of 65." );

const auto nb_component_meshes_issues =
launch_component_meshes_validity_checks( result.meshes, string );
Expand Down
122 changes: 122 additions & 0 deletions tests/inspection/test-information.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
/*
* Copyright (c) 2019 - 2026 Geode-solutions
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/

#include <geode/basic/assert.hpp>
#include <geode/basic/logger.hpp>
#include <geode/basic/range.hpp>
#include <geode/basic/uuid.hpp>

#include <geode/inspector/inspection/information.hpp>

namespace
{
geode::InspectionIssues< geode::index_t > make_issues(
geode::index_t nb_issues )
{
geode::InspectionIssues< geode::index_t > issues{ "component issues" };
for( const auto issue : geode::Range{ nb_issues } )
{
issues.add_issue( issue, absl::StrCat( "issue ", issue ) );
}
return issues;
}
} // namespace

void check_issues()
{
geode::InspectionIssues< geode::index_t > empty{ "nothing" };
geode::OpenGeodeInspectorInspectionException::test(
empty.string() == "no issues with nothing\n",
"[Test] Wrong empty InspectionIssues string: ", empty.string() );

const auto issues = make_issues( 2 );
geode::OpenGeodeInspectorInspectionException::test(
issues.nb_issues() == 2, "[Test] Wrong InspectionIssues count" );
const std::string expected{
"2 issues with component issues\n\tissue 0\n\tissue 1\n"
};
geode::OpenGeodeInspectorInspectionException::test(
issues.string() == expected,
"[Test] Wrong InspectionIssues string: ", issues.string() );
}

void check_issues_map()
{
geode::InspectionIssuesMap< geode::index_t > map{ "map issues" };
geode::OpenGeodeInspectorInspectionException::test(
map.nb_issues() == 0 && map.nb_components_with_issues() == 0,
"[Test] Empty InspectionIssuesMap should have no issues" );
geode::OpenGeodeInspectorInspectionException::test(
map.string() == "no issues with map issues\n",
"[Test] Wrong empty InspectionIssuesMap string: ", map.string() );

const geode::uuid first;
const geode::uuid second;
const geode::uuid third;
map.add_issues_to_map( first, make_issues( 3 ) );
map.add_issues_to_map( second, make_issues( 0 ) );
map.add_issues_to_map( third, make_issues( 1 ) );
geode::OpenGeodeInspectorInspectionException::test(
map.nb_components_with_issues() == 2,
"[Test] InspectionIssuesMap should have 2 components with issues, "
"not ",
map.nb_components_with_issues() );
geode::OpenGeodeInspectorInspectionException::test( map.nb_issues() == 4,
"[Test] InspectionIssuesMap should have 4 issues, not ",
map.nb_issues() );
geode::index_t nb_issues_from_map{ 0 };
for( const auto& issues : map.issues_map() )
{
nb_issues_from_map += issues.second.nb_issues();
}
geode::OpenGeodeInspectorInspectionException::test(
map.nb_issues() == nb_issues_from_map,
"[Test] InspectionIssuesMap count differs from its content" );

const std::string expected{ "4 issues with map issues"
"\n\t3 issues with component issues"
"\n\tissue 0\n\tissue 1\n\tissue 2\n"
"\n\t1 issues with component issues"
"\n\tissue 0\n"
"\n" };
geode::OpenGeodeInspectorInspectionException::test(
map.string() == expected,
"[Test] Wrong InspectionIssuesMap string: ", map.string() );
}

int main()
{
try
{
geode::OpenGeodeInspectorInspectionLibrary::initialize();
check_issues();
check_issues_map();

geode::Logger::info( "TEST SUCCESS" );
return 0;
}
catch( ... )
{
return geode::geode_lippincott();
}
}
Loading