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
5 changes: 5 additions & 0 deletions bindings/python/src/inspection/topology/brep_topology.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
namespace geode
{

void define_brep_topology_inspector( pybind11::module& module )

Check failure on line 31 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:31:42 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
{
pybind11::class_< BRepCornersTopologyInspectionResult >(

Check failure on line 33 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:33:27 [clang-diagnostic-error]

'BRepCornersTopologyInspectionResult' does not refer to a value

Check failure on line 33 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:33:9 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
module, "BRepCornersTopologyInspectionResult" )
.def( pybind11::init<>() )

Check failure on line 35 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:35:36 [clang-diagnostic-error]

expected expression

Check failure on line 35 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:35:34 [clang-diagnostic-error]

expected expression

Check failure on line 35 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:35:19 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
.def_readwrite( "corners_not_meshed",
&BRepCornersTopologyInspectionResult::corners_not_meshed )
.def_readwrite( "corners_not_linked_to_a_unique_vertex",
Expand All @@ -56,18 +56,20 @@
.def( "string", &BRepCornersTopologyInspectionResult::string )
.def( "__str__", &BRepCornersTopologyInspectionResult::string )
.def( "__repr__",
&issues_repr< BRepCornersTopologyInspectionResult > )

Check failure on line 59 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:59:18 [clang-diagnostic-error]

use of undeclared identifier 'issues_repr'
.def( "inspection_type",
&BRepCornersTopologyInspectionResult::inspection_type );

pybind11::class_< BRepLinesTopologyInspectionResult >(

Check failure on line 63 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:63:27 [clang-diagnostic-error]

'BRepLinesTopologyInspectionResult' does not refer to a value

Check failure on line 63 in bindings/python/src/inspection/topology/brep_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:63:9 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
module, "BRepLinesTopologyInspectionResult" )
.def( pybind11::init<>() )

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

View workflow job for this annotation

GitHub Actions / test / tidy

bindings/python/src/inspection/topology/brep_topology.hpp:65:19 [clang-diagnostic-error]

use of undeclared identifier 'pybind11'
.def_readwrite( "lines_not_meshed",
&BRepLinesTopologyInspectionResult::lines_not_meshed )
.def_readwrite( "lines_not_embedded_nor_incident",
&BRepLinesTopologyInspectionResult::
lines_not_embedded_nor_incident )
.def_readwrite( "lines_multiply_embedded",
&BRepLinesTopologyInspectionResult::lines_multiply_embedded )
.def_readwrite( "lines_not_linked_to_a_unique_vertex",
&BRepLinesTopologyInspectionResult::
lines_not_linked_to_a_unique_vertex )
Expand Down Expand Up @@ -102,6 +104,9 @@
.def( pybind11::init<>() )
.def_readwrite( "surfaces_not_meshed",
&BRepSurfacesTopologyInspectionResult::surfaces_not_meshed )
.def_readwrite( "surfaces_multiply_embedded",
&BRepSurfacesTopologyInspectionResult::
surfaces_multiply_embedded )
.def_readwrite( "surfaces_not_linked_to_a_unique_vertex",
&BRepSurfacesTopologyInspectionResult::
surfaces_not_linked_to_a_unique_vertex )
Expand Down
2 changes: 2 additions & 0 deletions bindings/python/tests/inspection/test-py-brep.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ def lines_topological_validity(result, verbose):
nb_issues += issue[1].nb_issues()
nb_issues += result.lines_not_meshed.nb_issues()
nb_issues += result.lines_not_embedded_nor_incident.nb_issues()
nb_issues += result.lines_multiply_embedded.nb_issues()
nb_issues += (
result.unique_vertices_linked_to_a_line_with_invalid_embeddings.nb_issues()
)
Expand All @@ -75,6 +76,7 @@ def surfaces_topological_validity(result, verbose):
for issue in result.surfaces_not_linked_to_a_unique_vertex.issues_map():
nb_issues += issue[1].nb_issues()
nb_issues += result.surfaces_not_meshed.nb_issues()
nb_issues += result.surfaces_multiply_embedded.nb_issues()
nb_issues += (
result.unique_vertices_linked_to_a_line_but_is_not_on_a_surface_border.nb_issues()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
InspectionIssues< uuid > lines_not_embedded_nor_incident{
"Lines neither embedded nor incident (uuids listed)"
};
InspectionIssues< uuid > lines_multiply_embedded{
"Lines embedded in several components including a Block (uuids "
"listed)"
};
InspectionIssues< index_t >
unique_vertices_linked_to_line_with_wrong_relationship_to_surface{
"unique vertices linked to a Line with an incorrect "
Expand Down Expand Up @@ -125,7 +129,7 @@

[[nodiscard]] std::optional< std::string >
line_edge_has_wrong_component_edges_around(
const Line3D& line, const index_t edge_index ) const;

Check warning on line 132 in include/geode/inspector/inspection/topology/brep_lines_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/inspector/inspection/topology/brep_lines_topology.hpp:132:37 [readability-avoid-const-params-in-decls]

parameter 'edge_index' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions

[[nodiscard]] BRepLinesTopologyInspectionResult
inspect_lines_topology() const;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
InspectionIssues< uuid > surfaces_not_meshed{
"Surface without mesh (uuids listed)"
};
InspectionIssues< uuid > surfaces_multiply_embedded{
"Surfaces embedded in several Blocks (uuids listed)"
};
InspectionIssuesMap< index_t > surfaces_not_linked_to_a_unique_vertex{
"Surfaces containing mesh vertices not linked to unique vertices"
};
Expand Down Expand Up @@ -118,7 +121,7 @@

[[nodiscard]] std::optional< std::string >
surface_facet_has_wrong_component_facets_around(
const Surface3D& line, const index_t facet_index ) const;

Check warning on line 124 in include/geode/inspector/inspection/topology/brep_surfaces_topology.hpp

View workflow job for this annotation

GitHub Actions / test / tidy

include/geode/inspector/inspection/topology/brep_surfaces_topology.hpp:124:40 [readability-avoid-const-params-in-decls]

parameter 'facet_index' is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions

[[nodiscard]] BRepSurfacesTopologyInspectionResult
inspect_surfaces_topology() const;
Expand Down
40 changes: 40 additions & 0 deletions src/geode/inspector/inspection/topology/brep_lines_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <optional>

#include <absl/algorithm/container.h>
#include <absl/strings/str_join.h>

#include <geode/mesh/core/edged_curve.hpp>
#include <geode/mesh/core/solid_mesh.hpp>
Expand All @@ -45,10 +46,38 @@
const geode::BRep& brep, const geode::ComponentID& embedding )
{
const auto name = brep.component( embedding.id ).name();
const auto id = embedding.id.string();

Check warning on line 49 in src/geode/inspector/inspection/topology/brep_lines_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_lines_topology.cpp:49:20 [readability-identifier-length]

variable name 'id' is too short, expected at least 3 characters
return absl::StrCat( embedding.type.get(), " ",
name ? name.value() : id, " (", id, ")" );
}

std::optional< std::string > line_multiply_embedded_message(
const geode::BRep& brep, const geode::Line3D& line )
{
std::vector< std::string > embedding_labels;
bool embedded_in_block{ false };
for( const auto& embedding : brep.embeddings( line.id() ) )
{
if( !brep.component( embedding.id ).is_active() )
{
continue;
}
if( embedding.type == geode::Block3D::component_type_static() )
{
embedded_in_block = true;
}
embedding_labels.push_back( embedding_label( brep, embedding ) );
}
if( embedding_labels.size() < 2 || !embedded_in_block )
{
return std::nullopt;
}
return absl::StrCat( "Line ",
line.name().value_or( line.id().string() ), " (",
line.id().string(),
") is embedded in several components including a Block: ",
absl::StrJoin( embedding_labels, ", " ) );
}
} // namespace

namespace geode
Expand All @@ -57,6 +86,7 @@
{
return lines_not_meshed.nb_issues()
+ lines_not_embedded_nor_incident.nb_issues()
+ lines_multiply_embedded.nb_issues()
+ unique_vertices_linked_to_line_with_wrong_relationship_to_surface
.nb_issues()
+ lines_not_linked_to_a_unique_vertex.nb_issues()
Expand All @@ -80,6 +110,10 @@
absl::StrAppend(
&message, lines_not_embedded_nor_incident.string() );
}
if( lines_multiply_embedded.nb_issues() != 0 )
{
absl::StrAppend( &message, lines_multiply_embedded.string() );
}
if( unique_vertices_linked_to_line_with_wrong_relationship_to_surface
.nb_issues()
!= 0 )
Expand Down Expand Up @@ -179,7 +213,7 @@
}

std::optional< std::string >
BRepLinesTopology::vertex_is_part_of_invalid_embedded_line(

Check warning on line 216 in src/geode/inspector/inspection/topology/brep_lines_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_lines_topology.cpp:216:28 [readability-function-cognitive-complexity]

function 'vertex_is_part_of_invalid_embedded_line' has cognitive complexity of 17 (threshold 10)
index_t unique_vertex_index ) const
{
for( const auto& line_cmv :
Expand Down Expand Up @@ -231,7 +265,7 @@
}

std::optional< std::string >
BRepLinesTopology::vertex_is_part_of_invalid_single_line(

Check warning on line 268 in src/geode/inspector/inspection/topology/brep_lines_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_lines_topology.cpp:268:28 [readability-function-cognitive-complexity]

function 'vertex_is_part_of_invalid_single_line' has cognitive complexity of 23 (threshold 10)
index_t unique_vertex_index ) const
{
const auto line_uuids = internal::components_uuids(
Expand All @@ -258,7 +292,7 @@
if( surface_uuids.size() == 1 )
{
if( !brep_.Relationships::is_internal( line_id, surface_uuids[0] )
&& !( brep_.Relationships::nb_embeddings( surface_uuids[0] ) > 0

Check warning on line 295 in src/geode/inspector/inspection/topology/brep_lines_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_lines_topology.cpp:295:20 [readability-simplify-boolean-expr]

boolean expression can be simplified by DeMorgan's theorem
|| brep_.Relationships::is_boundary(
line_id, surface_uuids[0] ) ) )
{
Expand Down Expand Up @@ -322,7 +356,7 @@
}

std::optional< std::string > BRepLinesTopology::
vertex_is_part_of_line_with_wrong_relationships_to_surface(

Check warning on line 359 in src/geode/inspector/inspection/topology/brep_lines_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_lines_topology.cpp:359:9 [readability-function-cognitive-complexity]

function 'vertex_is_part_of_line_with_wrong_relationships_to_surface' has cognitive complexity of 38 (threshold 10)
index_t unique_vertex_index ) const
{
for( const auto& cmv :
Expand Down Expand Up @@ -454,7 +488,7 @@
}

std::optional< std::string >
BRepLinesTopology::line_edge_has_wrong_component_edges_around(

Check warning on line 491 in src/geode/inspector/inspection/topology/brep_lines_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_lines_topology.cpp:491:28 [readability-function-cognitive-complexity]

function 'line_edge_has_wrong_component_edges_around' has cognitive complexity of 36 (threshold 10)
const Line3D& line, const index_t edge_index ) const
{
const auto cme = component_mesh_edges( brep_, line, edge_index );
Expand Down Expand Up @@ -573,7 +607,7 @@
}

BRepLinesTopologyInspectionResult
BRepLinesTopology::inspect_lines_topology() const

Check warning on line 610 in src/geode/inspector/inspection/topology/brep_lines_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_lines_topology.cpp:610:28 [readability-function-cognitive-complexity]

function 'inspect_lines_topology' has cognitive complexity of 18 (threshold 10)
{
BRepLinesTopologyInspectionResult result;
for( const auto& line : brep_.active_lines() )
Expand All @@ -594,6 +628,12 @@
" (", line.id().string(),
") is neither embedded nor incident" ) );
}
if( const auto message =
line_multiply_embedded_message( brep_, line ) )
{
result.lines_multiply_embedded.add_issue(
line.id(), message.value() );
}
auto line_result = internal::
model_component_vertices_not_associated_to_unique_vertices(
brep_, line.component_id(), line.mesh() );
Expand Down
36 changes: 36 additions & 0 deletions src/geode/inspector/inspection/topology/brep_surfaces_topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

#include <absl/algorithm/container.h>
#include <absl/container/flat_hash_map.h>
#include <absl/strings/str_join.h>

#include <geode/basic/algorithm.hpp>

Expand Down Expand Up @@ -61,7 +62,7 @@
const geode::Block3D& block,
SurfaceBlocksRelations& relations )
{
const auto [it, inserted] =

Check warning on line 65 in src/geode/inspector/inspection/topology/brep_surfaces_topology.cpp

View workflow job for this annotation

GitHub Actions / test / tidy

src/geode/inspector/inspection/topology/brep_surfaces_topology.cpp:65:21 [readability-identifier-length]

variable name 'it' is too short, expected at least 3 characters
relations.try_emplace( block.id(), SURFACE_BLOCK_RELATION::none );
if( inserted )
{
Expand Down Expand Up @@ -137,13 +138,38 @@
}
return std::nullopt;
}

std::optional< std::string > surface_multiply_embedded_message(
const geode::BRep& brep, const geode::Surface3D& surface )
{
std::vector< std::string > block_labels;
for( const auto& block : brep.embedding_blocks( surface ) )
{
if( !block.is_active() )
{
continue;
}
block_labels.push_back( absl::StrCat( "Block ",
block.name().value_or( block.id().string() ), " (",
block.id().string(), ")" ) );
}
if( block_labels.size() < 2 )
{
return std::nullopt;
}
return absl::StrCat( "Surface ",
surface.name().value_or( surface.id().string() ), " (",
surface.id().string(), ") is embedded in several Blocks: ",
absl::StrJoin( block_labels, ", " ) );
}
} // namespace

namespace geode
{
index_t BRepSurfacesTopologyInspectionResult::nb_issues() const
{
return surfaces_not_meshed.nb_issues()
+ surfaces_multiply_embedded.nb_issues()
+ surfaces_not_linked_to_a_unique_vertex.nb_issues()
+ unique_vertices_linked_to_a_surface_with_invalid_embbedings
.nb_issues()
Expand All @@ -160,6 +186,10 @@
{
absl::StrAppend( &message, surfaces_not_meshed.string() );
}
if( surfaces_multiply_embedded.nb_issues() != 0 )
{
absl::StrAppend( &message, surfaces_multiply_embedded.string() );
}
if( surfaces_not_linked_to_a_unique_vertex.nb_issues() != 0 )
{
absl::StrAppend(
Expand Down Expand Up @@ -480,6 +510,12 @@
surface.name().value_or( surface.id().string() ), " (",
surface.id().string(), ") is not meshed" ) );
}
if( const auto message =
surface_multiply_embedded_message( brep_, surface ) )
{
result.surfaces_multiply_embedded.add_issue(
surface.id(), message.value() );
}

auto surface_result = internal::
model_component_vertices_not_associated_to_unique_vertices(
Expand Down
10 changes: 10 additions & 0 deletions src/geode/inspector/validity/brep_validity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ namespace
invalidities.invalidities.push_back(
lines_topo.lines_not_embedded_nor_incident.string() );
}
if( lines_topo.lines_multiply_embedded.nb_issues() != 0 )
{
invalidities.invalidities.push_back(
lines_topo.lines_multiply_embedded.string() );
}
if( lines_topo
.unique_vertices_linked_to_line_with_wrong_relationship_to_surface
.nb_issues()
Expand Down Expand Up @@ -267,6 +272,11 @@ namespace
invalidities.invalidities.push_back(
surfaces_topo.surfaces_not_meshed.string() );
}
if( surfaces_topo.surfaces_multiply_embedded.nb_issues() != 0 )
{
invalidities.invalidities.push_back(
surfaces_topo.surfaces_multiply_embedded.string() );
}
if( surfaces_topo.surfaces_not_linked_to_a_unique_vertex.nb_issues()
!= 0 )
{
Expand Down
65 changes: 65 additions & 0 deletions tests/inspection/test-brep-topology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include <tuple>

#include <absl/algorithm/container.h>
#include <absl/strings/match.h>

#include <geode/basic/assert.hpp>
Expand All @@ -40,6 +41,7 @@
#include <geode/model/mixin/core/block.hpp>
#include <geode/model/mixin/core/corner.hpp>
#include <geode/model/mixin/core/line.hpp>
#include <geode/model/mixin/core/surface.hpp>
#include <geode/model/representation/builder/brep_builder.hpp>
#include <geode/model/representation/core/brep.hpp>

Expand Down Expand Up @@ -159,6 +161,67 @@ namespace
"[free line] Wrong reported Line: ", issues.string() );
}

void test_multiply_embedded_line()
{
geode::BRep brep;
geode::BRepBuilder builder{ brep };
const auto& block0 = brep.block( builder.add_block() );
const auto& block1 = brep.block( builder.add_block() );
const auto& surface = brep.surface( builder.add_surface() );
const auto& line_in_blocks = brep.line( builder.add_line() );
const auto& line_in_block_and_surface = brep.line( builder.add_line() );
const auto& line_in_block = brep.line( builder.add_line() );
builder.add_line_block_internal_relationship( line_in_blocks, block0 );
builder.add_line_block_internal_relationship( line_in_blocks, block1 );
builder.add_line_block_internal_relationship(
line_in_block_and_surface, block0 );
builder.add_line_surface_internal_relationship(
line_in_block_and_surface, surface );
builder.add_line_block_internal_relationship( line_in_block, block1 );
const geode::BRepTopologyInspector inspector{ brep };
const auto result = inspector.inspect_brep_topology();
const auto& issues = result.lines.lines_multiply_embedded;
geode::OpenGeodeInspectorInspectionException::test(
issues.nb_issues() == 2,
"[multiply embedded line] Wrong number of issues: ",
issues.string() );
geode::OpenGeodeInspectorInspectionException::test(
absl::c_find( issues.issues(), line_in_blocks.id() )
!= issues.issues().end()
&& absl::c_find(
issues.issues(), line_in_block_and_surface.id() )
!= issues.issues().end(),
"[multiply embedded line] Wrong reported Lines: ",
issues.string() );
}

void test_multiply_embedded_surface()
{
geode::BRep brep;
geode::BRepBuilder builder{ brep };
const auto& block0 = brep.block( builder.add_block() );
const auto& block1 = brep.block( builder.add_block() );
const auto& surface_in_blocks = brep.surface( builder.add_surface() );
const auto& surface_in_block = brep.surface( builder.add_surface() );
builder.add_surface_block_internal_relationship(
surface_in_blocks, block0 );
builder.add_surface_block_internal_relationship(
surface_in_blocks, block1 );
builder.add_surface_block_internal_relationship(
surface_in_block, block0 );
const geode::BRepTopologyInspector inspector{ brep };
const auto result = inspector.inspect_brep_topology();
const auto& issues = result.surfaces.surfaces_multiply_embedded;
geode::OpenGeodeInspectorInspectionException::test(
issues.nb_issues() == 1,
"[multiply embedded surface] Wrong number of issues: ",
issues.string() );
geode::OpenGeodeInspectorInspectionException::test(
issues.issues().front() == surface_in_blocks.id(),
"[multiply embedded surface] Wrong reported Surface: ",
issues.string() );
}

void test_checks_independent_of_failing_check()
{
geode::BRep brep;
Expand Down Expand Up @@ -226,6 +289,8 @@ int main()
test_non_bijective_link_message();
test_line_embedded_in_block_message();
test_free_line_message();
test_multiply_embedded_line();
test_multiply_embedded_surface();
test_empty_model_boundary();
test_checks_independent_of_failing_check();
geode::Logger::info( "TEST SUCCESS" );
Expand Down
Loading