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
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
class VertexSet;
} // namespace geode

namespace geode

Check warning on line 44 in include/geode/inspector/inspection/topology/internal/topology_helpers.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/inspector/inspection/topology/internal/topology_helpers.hpp:44:1 [modernize-concat-nested-namespaces]

nested namespaces can be concatenated
{
namespace internal
{
Expand Down Expand Up @@ -96,7 +96,7 @@
InspectionIssues< index_t > result;
for( const auto vertex_id : Range{ component_mesh.nb_vertices() } )
{
ComponentMeshVertex component_mesh_vertex{ component_id,

Check failure on line 99 in include/geode/inspector/inspection/topology/internal/topology_helpers.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/inspector/inspection/topology/internal/topology_helpers.hpp:99:37 [clang-diagnostic-error]

variable has incomplete type 'ComponentMeshVertex'
vertex_id };
if( model.unique_vertex( component_mesh_vertex ) == NO_ID )
{
Expand All @@ -107,5 +107,29 @@
}
return result;
}

// Adds the issue found by the check on the unique vertex, if any.
// Each check is protected on its own: if it throws because of wrong
// links between the unique vertex and the components (reported by the
// unique vertices inspection), the other checks still fill the result.
template < typename Check >
void add_unique_vertex_issue( InspectionIssues< index_t >& issues,
index_t unique_vertex_id,
const Check& check )
{
try
{
if( const auto problem_message = check() )
{
issues.add_issue(
unique_vertex_id, problem_message.value() );
}
}
catch( const std::exception& )

Check warning on line 128 in include/geode/inspector/inspection/topology/internal/topology_helpers.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/inspector/inspection/topology/internal/topology_helpers.hpp:128:13 [bugprone-empty-catch]

empty catch statements hide issues; to handle exceptions appropriately, consider re-throwing, handling, or avoiding catch altogether
{
// Wrong links to components are reported by the unique
// vertices inspection
}
}
} // namespace internal
} // namespace geode
116 changes: 72 additions & 44 deletions src/geode/inspector/inspection/topology/brep_blocks_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
return false;
}

void create_graph( const geode::BRep& brep,

Check warning on line 119 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:119:10 [readability-function-size]

function 'create_graph' exceeds recommended size/complexity thresholds

Check warning on line 119 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:119:10 [readability-function-cognitive-complexity]

function 'create_graph' has cognitive complexity of 16 (threshold 10)
geode::GenericMapping< geode::uuid, geode::index_t >&
surface_uuids_to_graph_edges,
geode::BijectiveMapping< geode::uuid, geode::index_t >&
Expand Down Expand Up @@ -160,7 +160,7 @@
}
}

std::vector< geode::uuid > find_not_boundary_surfaces(

Check warning on line 163 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:163:32 [readability-function-cognitive-complexity]

function 'find_not_boundary_surfaces' has cognitive complexity of 33 (threshold 10)
const geode::BRep& brep )
{
std::vector< geode::uuid > not_boundaries_surfaces;
Expand Down Expand Up @@ -243,7 +243,7 @@
return not_boundaries_surfaces;
}

std::vector< geode::uuid > find_dangling_surfaces( const geode::BRep& brep,

Check warning on line 246 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:246:32 [readability-function-cognitive-complexity]

function 'find_dangling_surfaces' has cognitive complexity of 17 (threshold 10)
absl::Span< const geode::uuid > not_boundary_surfaces )
{
std::vector< geode::uuid > dangling_surfaces;
Expand All @@ -255,19 +255,35 @@
{
continue;
}
const auto polygon_barycenter =
surface_mesh.polygon_barycenter( 0 );
bool is_dangling{ true };
for( const auto& block : brep.blocks() )
// Ray tracing may fail on ambiguous rays: try a few polygons, a
// surface which cannot be located is not reported as dangling
constexpr geode::index_t MAX_TRIALS{ 5 };
std::optional< bool > is_dangling;
for( const auto polygon_id : geode::Range{
std::min( surface_mesh.nb_polygons(), MAX_TRIALS ) } )
{
if( ray_tracing.is_point_inside_block(
polygon_barycenter, block ) )
try
{
is_dangling = false;
const auto polygon_barycenter =
surface_mesh.polygon_barycenter( polygon_id );
is_dangling = true;
for( const auto& block : brep.active_blocks() )
{
if( ray_tracing.is_point_inside_block(
polygon_barycenter, block ) )
{
is_dangling = false;
break;
}
}
break;
}
catch( const geode::OpenGeodeException& )
{
is_dangling.reset();
}
}
if( is_dangling )
if( is_dangling.value_or( false ) )
{
dangling_surfaces.push_back( surface_id );
}
Expand Down Expand Up @@ -297,6 +313,10 @@
const geode::BRep& brep, std::queue< geode::uuid >& to_process )
{
std::vector< geode::uuid > processed;
if( to_process.empty() )
{
return processed;
}
const auto first_surface_uuid = to_process.front();
to_process.pop();
processed.emplace_back( first_surface_uuid );
Expand Down Expand Up @@ -371,7 +391,7 @@
std::vector< geode::BoundingBox3D > bounding_boxes;
for( const auto& surface_list : linked_surfaces_list )
{
bounding_boxes.emplace_back(

Check warning on line 394 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:394:13 [performance-inefficient-vector-operation]

'emplace_back' is called inside a loop; consider pre-allocating the container capacity before the loop
surface_list_box( brep, surface_list ) );
}
for( const auto first_surface_list_id :
Expand All @@ -397,7 +417,7 @@
return std::nullopt;
}

std::unique_ptr< geode::PolygonalSurface3D > fuse_brep_surfaces_from_list(

Check warning on line 420 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:420:50 [readability-function-cognitive-complexity]

function 'fuse_brep_surfaces_from_list' has cognitive complexity of 15 (threshold 10)
const geode::BRep& brep,
const std::vector< geode::uuid >& surface_list )
{
Expand All @@ -419,6 +439,14 @@
{
const auto unique_vertex = brep.unique_vertex(
{ surface.component_id(), polygon_vertex } );
if( unique_vertex == geode::NO_ID )
{
// Unlinked vertices cannot be merged with others
polygon_vertex =
polygonal_surface_builder->create_point(
surface_mesh.point( polygon_vertex ) );
continue;
}
if( !unique_vertices_to_polygonal_surface_vertices
.has_mapping_input( unique_vertex ) )
{
Expand All @@ -443,7 +471,7 @@
return polygonal_surface;
}

bool block_boundaries_are_closed(

Check warning on line 474 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:474:10 [readability-function-cognitive-complexity]

function 'block_boundaries_are_closed' has cognitive complexity of 19 (threshold 10)
const geode::BRep& brep, const geode::Block3D& block )
{
auto to_process = queue_with_block_boundaries( brep, block );
Expand Down Expand Up @@ -504,6 +532,11 @@
bool brep_boundaries_are_closed( const geode::BRep& brep )
{
auto to_process = queue_with_model_boundaries( brep );
if( to_process.empty() )
{
// No boundary surface to check
return true;
}
auto compute_closed_linked_surfaces =
closed_linked_surfaces( brep, to_process );
return to_process.empty();
Expand All @@ -529,7 +562,7 @@
+ unique_vertex_linked_to_multiple_invalid_surfaces.nb_issues();
}

std::string BRepBlocksTopologyInspectionResult::string() const

Check warning on line 565 in src/geode/inspector/inspection/topology/brep_blocks_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_blocks_topology.cpp:565:53 [readability-function-cognitive-complexity]

function 'string' has cognitive complexity of 11 (threshold 10)
{
std::string message;
if( some_blocks_not_meshed.nb_issues() != 0 )
Expand Down Expand Up @@ -961,44 +994,39 @@
}
for( const auto unique_vertex_id : Range{ brep_.nb_unique_vertices() } )
{
if( const auto problem_message =
unique_vertex_is_part_of_two_blocks_and_no_boundary_surface(
unique_vertex_id ) )
{
internal::add_unique_vertex_issue(
result
.unique_vertices_part_of_two_blocks_and_no_boundary_surface
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
unique_vertex_block_cmvs_count_is_incorrect(
unique_vertex_id ) )
{
result.unique_vertices_with_incorrect_block_cmvs_count
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
vertex_is_part_of_invalid_single_surface(
unique_vertex_id, not_boundary_surfaces ) )
{
result.unique_vertices_linked_to_a_single_and_invalid_surface
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
vertex_is_part_of_surface_with_wrong_relationships_to_block(
unique_vertex_id, not_boundary_surfaces,
dangling_surfaces ) )
{
.unique_vertices_part_of_two_blocks_and_no_boundary_surface,
unique_vertex_id, [&] {
return unique_vertex_is_part_of_two_blocks_and_no_boundary_surface(
unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result.unique_vertices_with_incorrect_block_cmvs_count,
unique_vertex_id, [&] {
return unique_vertex_block_cmvs_count_is_incorrect(
unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result.unique_vertices_linked_to_a_single_and_invalid_surface,
unique_vertex_id, [&] {
return vertex_is_part_of_invalid_single_surface(
unique_vertex_id, not_boundary_surfaces );
} );
internal::add_unique_vertex_issue(
result
.unique_vertices_linked_to_surface_with_wrong_relationship_to_blocks
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
vertex_is_part_of_invalid_multiple_surfaces(
unique_vertex_id ) )
{
result.unique_vertex_linked_to_multiple_invalid_surfaces
.add_issue( unique_vertex_id, problem_message.value() );
}
.unique_vertices_linked_to_surface_with_wrong_relationship_to_blocks,
unique_vertex_id, [&] {
return vertex_is_part_of_surface_with_wrong_relationships_to_block(
unique_vertex_id, not_boundary_surfaces,
dangling_surfaces );
} );
internal::add_unique_vertex_issue(
result.unique_vertex_linked_to_multiple_invalid_surfaces,
unique_vertex_id, [&] {
return vertex_is_part_of_invalid_multiple_surfaces(
unique_vertex_id );
} );
}
for( const auto& block : brep_.active_blocks() )
{
Expand Down
48 changes: 23 additions & 25 deletions src/geode/inspector/inspection/topology/brep_corners_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,32 +335,30 @@ namespace geode
}
for( const auto unique_vertex_id : Range{ brep_.nb_unique_vertices() } )
{
if( const auto problem_message =
unique_vertex_has_multiple_corners( unique_vertex_id ) )
{
result.unique_vertices_linked_to_multiple_corners.add_issue(
unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
corner_is_multiply_embedded( unique_vertex_id ) )
{
result.unique_vertices_linked_to_multiply_embedded_corner
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
corner_is_not_internal_nor_boundary( unique_vertex_id ) )
{
internal::add_unique_vertex_issue(
result.unique_vertices_linked_to_multiple_corners,
unique_vertex_id, [&] {
return unique_vertex_has_multiple_corners(
unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result.unique_vertices_linked_to_multiply_embedded_corner,
unique_vertex_id, [&] {
return corner_is_multiply_embedded( unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result
.unique_vertices_linked_to_not_internal_nor_boundary_corner
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
corner_is_part_of_line_but_not_boundary(
unique_vertex_id ) )
{
result.unique_vertices_linked_to_not_boundary_line_corner
.add_issue( unique_vertex_id, problem_message.value() );
}
.unique_vertices_linked_to_not_internal_nor_boundary_corner,
unique_vertex_id, [&] {
return corner_is_not_internal_nor_boundary(
unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result.unique_vertices_linked_to_not_boundary_line_corner,
unique_vertex_id, [&] {
return corner_is_part_of_line_but_not_boundary(
unique_vertex_id );
} );
}
return result;
}
Expand Down
83 changes: 42 additions & 41 deletions src/geode/inspector/inspection/topology/brep_lines_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,18 @@

#include <geode/inspector/inspection/topology/internal/topology_helpers.hpp>

namespace
{
std::string embedding_label(
const geode::BRep& brep, const geode::ComponentID& embedding )
{
const auto name = brep.component( embedding.id ).name();
const auto id = embedding.id.string();
return absl::StrCat( embedding.type.get(), " ",
name ? name.value() : id, " (", id, ")" );
}
} // namespace

namespace geode
{
index_t BRepLinesTopologyInspectionResult::nb_issues() const
Expand Down Expand Up @@ -185,12 +197,8 @@ namespace geode
" is part of line ",
line.name().value_or( line_id.string() ), " (",
line_id.string(),
"), which is both boundary and embedded in "
"Surface ",
brep_.surface( embedding.id )
.name()
.value_or( embedding.id.string() ),
" (", embedding.id.string() + ")." );
"), which is both boundary and embedded in ",
embedding_label( brep_, embedding ), "." );
}
if( embedding.type == Block3D::component_type_static()
&& !internal::brep_blocks_are_meshed( brep_ ) )
Expand All @@ -206,13 +214,10 @@ namespace geode
return absl::StrCat( "unique vertex ", unique_vertex_index,
" is part of Line ",
line.name().value_or( line_id.string() ), " (",
line_id.string(), "), which is embedded in Surface ",
brep_.surface( embedding.id )
.name()
.value_or( embedding.id.string() ),
" (", embedding.id.string(),
"), but the unique vertex is not linked to the "
"Surface mesh vertices." );
line_id.string(), "), which is embedded in ",
embedding_label( brep_, embedding ),
", but the unique vertex is not linked to the ",
embedding.type.get(), " mesh vertices." );
}
}
}
Expand Down Expand Up @@ -610,36 +615,32 @@ namespace geode
}
for( const auto unique_vertex_id : Range{ brep_.nb_unique_vertices() } )
{
if( const auto invalid_internal_topology =
vertex_is_part_of_invalid_embedded_line(
unique_vertex_id ) )
{
result.unique_vertices_linked_to_a_line_with_invalid_embeddings
.add_issue(
unique_vertex_id, invalid_internal_topology.value() );
}
if( const auto problem_message =
vertex_is_part_of_line_with_wrong_relationships_to_surface(
unique_vertex_id ) )
{
internal::add_unique_vertex_issue(
result.unique_vertices_linked_to_a_line_with_invalid_embeddings,
unique_vertex_id, [&] {
return vertex_is_part_of_invalid_embedded_line(
unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result
.unique_vertices_linked_to_line_with_wrong_relationship_to_surface
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto problem_message =
vertex_is_part_of_invalid_single_line( unique_vertex_id ) )
{
result.unique_vertices_linked_to_a_single_and_invalid_line
.add_issue( unique_vertex_id, problem_message.value() );
}
if( const auto lines_but_is_not_corner =
vertex_has_lines_but_is_not_a_corner( unique_vertex_id ) )
{
.unique_vertices_linked_to_line_with_wrong_relationship_to_surface,
unique_vertex_id, [&] {
return vertex_is_part_of_line_with_wrong_relationships_to_surface(
unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result.unique_vertices_linked_to_a_single_and_invalid_line,
unique_vertex_id, [&] {
return vertex_is_part_of_invalid_single_line(
unique_vertex_id );
} );
internal::add_unique_vertex_issue(
result
.unique_vertices_linked_to_several_lines_but_not_linked_to_a_corner
.add_issue(
unique_vertex_id, lines_but_is_not_corner.value() );
}
.unique_vertices_linked_to_several_lines_but_not_linked_to_a_corner,
unique_vertex_id, [&] {
return vertex_has_lines_but_is_not_a_corner(
unique_vertex_id );
} );
}
return result;
}
Expand Down
Loading
Loading