Skip to content

Commit 2cfbe37

Browse files
committed
fix(BRepTopology): Fixed the inspection of the topology of a BRep in several specific cases
1 parent 50decb6 commit 2cfbe37

File tree

8 files changed

+151
-75
lines changed

8 files changed

+151
-75
lines changed

bindings/python/src/inspector/topology/brep_topology.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,20 @@
3131
.def( pybind11::init< const BRep& >() ) \
3232
.def( "brep_topology_is_valid", \
3333
&BRepTopologyInspector::brep_topology_is_valid ) \
34-
.def( "brep_components_are_linked_to_a_unique_vertex", \
34+
.def( "brep_meshed_components_are_linked_to_a_unique_vertex", \
3535
&BRepTopologyInspector:: \
36-
brep_components_are_linked_to_a_unique_vertex ) \
36+
brep_meshed_components_are_linked_to_a_unique_vertex ) \
3737
.def( "nb_corners_not_linked_to_a_unique_vertex", \
3838
&BRepTopologyInspector::nb_corners_not_linked_to_a_unique_vertex ) \
39-
.def( "nb_lines_not_linked_to_a_unique_vertex", \
40-
&BRepTopologyInspector::nb_lines_not_linked_to_a_unique_vertex ) \
41-
.def( "nb_surfaces_not_linked_to_a_unique_vertex", \
39+
.def( "nb_lines_meshed_but_not_linked_to_a_unique_vertex", \
4240
&BRepTopologyInspector:: \
43-
nb_surfaces_not_linked_to_a_unique_vertex ) \
44-
.def( "nb_blocks_not_linked_to_a_unique_vertex", \
45-
&BRepTopologyInspector::nb_blocks_not_linked_to_a_unique_vertex ) \
41+
nb_lines_meshed_but_not_linked_to_a_unique_vertex ) \
42+
.def( "nb_surfaces_meshed_but_not_linked_to_a_unique_vertex", \
43+
&BRepTopologyInspector:: \
44+
nb_surfaces_meshed_but_not_linked_to_a_unique_vertex ) \
45+
.def( "nb_blocks_meshed_but_not_linked_to_a_unique_vertex", \
46+
&BRepTopologyInspector:: \
47+
nb_blocks_meshed_but_not_linked_to_a_unique_vertex ) \
4648
.def( "invalid_components_topology_unique_vertices", \
4749
&BRepTopologyInspector:: \
4850
invalid_components_topology_unique_vertices ) \

bindings/python/tests/test-py-brep-topology.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@
3030
def check_components_linking( brep_inspector ):
3131
nb_unlinked_corners = brep_inspector.nb_corners_not_linked_to_a_unique_vertex()
3232
print( "There are ", nb_unlinked_corners, " corners not linked to a unique vertex." )
33-
nb_unlinked_lines = brep_inspector.nb_lines_not_linked_to_a_unique_vertex()
34-
print( "There are ", nb_unlinked_lines, " lines not linked to a unique vertex." )
35-
nb_unlinked_surfaces = brep_inspector.nb_surfaces_not_linked_to_a_unique_vertex()
36-
print( "There are ", nb_unlinked_surfaces, " surfaces not linked to a unique vertex." )
37-
nb_unlinked_blocks = brep_inspector.nb_blocks_not_linked_to_a_unique_vertex()
38-
print( "There are ", nb_unlinked_blocks, " blocks not linked to a unique vertex." )
33+
nb_unlinked_lines = brep_inspector.nb_lines_meshed_but_not_linked_to_a_unique_vertex()
34+
print( "There are ", nb_unlinked_lines, " lines meshed but not linked to a unique vertex." )
35+
nb_unlinked_surfaces = brep_inspector.nb_surfaces_meshed_but_not_linked_to_a_unique_vertex()
36+
print( "There are ", nb_unlinked_surfaces, " surfaces meshed but not linked to a unique vertex." )
37+
nb_unlinked_blocks = brep_inspector.nb_blocks_meshed_but_not_linked_to_a_unique_vertex()
38+
print( "There are ", nb_unlinked_blocks, " blocks meshed but not linked to a unique vertex." )
3939

4040
def check_invalid_components_topology_unique_vertices( brep_inspector ):
4141
invalid_components_unique_vertices = brep_inspector.invalid_components_topology_unique_vertices()

include/geode/inspector/topology/brep_topology.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ namespace geode
5151
*/
5252
bool brep_topology_is_valid() const;
5353

54-
bool brep_components_are_linked_to_a_unique_vertex() const;
54+
bool brep_meshed_components_are_linked_to_a_unique_vertex() const;
5555

5656
index_t nb_corners_not_linked_to_a_unique_vertex() const;
5757

58-
index_t nb_lines_not_linked_to_a_unique_vertex() const;
58+
index_t nb_lines_meshed_but_not_linked_to_a_unique_vertex() const;
5959

60-
index_t nb_surfaces_not_linked_to_a_unique_vertex() const;
60+
index_t nb_surfaces_meshed_but_not_linked_to_a_unique_vertex() const;
6161

62-
index_t nb_blocks_not_linked_to_a_unique_vertex() const;
62+
index_t nb_blocks_meshed_but_not_linked_to_a_unique_vertex() const;
6363

6464
std::vector< index_t >
6565
invalid_components_topology_unique_vertices() const;

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,24 @@ void inspect_brep( const geode::BRep& brep )
5555
} ) );
5656
tasks.emplace_back( async::spawn( [&brep_inspector] {
5757
const auto nb_lines =
58-
brep_inspector.nb_lines_not_linked_to_a_unique_vertex();
58+
brep_inspector
59+
.nb_lines_meshed_but_not_linked_to_a_unique_vertex();
5960
geode::Logger::info(
60-
nb_lines, " corners not linked to a unique vertex" );
61+
nb_lines, " lines meshed but not linked to a unique vertex" );
6162
} ) );
6263
tasks.emplace_back( async::spawn( [&brep_inspector] {
6364
const auto nb_surfaces =
64-
brep_inspector.nb_surfaces_not_linked_to_a_unique_vertex();
65-
geode::Logger::info(
66-
nb_surfaces, " surfaces not linked to a unique vertex" );
65+
brep_inspector
66+
.nb_surfaces_meshed_but_not_linked_to_a_unique_vertex();
67+
geode::Logger::info( nb_surfaces,
68+
" surfaces meshed but not linked to a unique vertex" );
6769
} ) );
6870
tasks.emplace_back( async::spawn( [&brep_inspector] {
6971
const auto nb_blocks =
70-
brep_inspector.nb_blocks_not_linked_to_a_unique_vertex();
72+
brep_inspector
73+
.nb_blocks_meshed_but_not_linked_to_a_unique_vertex();
7174
geode::Logger::info(
72-
nb_blocks, " blocks not linked to a unique vertex" );
75+
nb_blocks, " blocks meshed but not linked to a unique vertex" );
7376
} ) );
7477
}
7578
if( absl::GetFlag( FLAGS_corners ) )

src/geode/inspector/topology/brep_topology.cpp

Lines changed: 61 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
#include <geode/basic/pimpl_impl.h>
2727

28+
#include <geode/mesh/core/edged_curve.h>
29+
#include <geode/mesh/core/solid_mesh.h>
30+
#include <geode/mesh/core/surface_mesh.h>
31+
2832
#include <geode/model/mixin/core/block.h>
2933
#include <geode/model/mixin/core/corner.h>
3034
#include <geode/model/mixin/core/line.h>
@@ -38,7 +42,25 @@
3842

3943
namespace
4044
{
41-
bool brep_has_unique_vertex_associated_to_component_id(
45+
bool brep_line_is_meshed(
46+
const geode::BRep& brep, const geode::uuid& line_id )
47+
{
48+
return brep.line( line_id ).mesh().nb_vertices() != 0;
49+
}
50+
51+
bool brep_surface_is_meshed(
52+
const geode::BRep& brep, const geode::uuid& surface_id )
53+
{
54+
return brep.surface( surface_id ).mesh().nb_vertices() != 0;
55+
}
56+
57+
bool brep_block_is_meshed(
58+
const geode::BRep& brep, const geode::uuid& block_id )
59+
{
60+
return brep.block( block_id ).mesh().nb_vertices() != 0;
61+
}
62+
63+
bool brep_has_unique_vertex_associated_to_component(
4264
const geode::BRep& brep, const geode::uuid& component_id )
4365
{
4466
for( const auto unique_vertex_id :
@@ -77,7 +99,7 @@ namespace geode
7799
{
78100
return false;
79101
}
80-
if( !brep_components_are_linked_to_a_unique_vertex() )
102+
if( !brep_meshed_components_are_linked_to_a_unique_vertex() )
81103
{
82104
return false;
83105
}
@@ -97,27 +119,38 @@ namespace geode
97119
return true;
98120
}
99121

100-
bool brep_components_are_linked_to_a_unique_vertex() const
122+
bool brep_meshed_components_are_linked_to_a_unique_vertex() const
101123
{
102124
for( const auto& corner : brep_.corners() )
103125
{
104-
if( !brep_has_unique_vertex_associated_to_component_id(
126+
if( !brep_has_unique_vertex_associated_to_component(
105127
brep_, corner.id() ) )
106128
{
107129
return false;
108130
}
109131
}
132+
for( const auto& line : brep_.lines() )
133+
{
134+
if( brep_line_is_meshed( brep_, line.id() )
135+
&& !brep_has_unique_vertex_associated_to_component(
136+
brep_, line.id() ) )
137+
{
138+
return false;
139+
}
140+
}
110141
for( const auto& surface : brep_.surfaces() )
111142
{
112-
if( !brep_has_unique_vertex_associated_to_component_id(
143+
if( brep_surface_is_meshed( brep_, surface.id() )
144+
&& !brep_has_unique_vertex_associated_to_component(
113145
brep_, surface.id() ) )
114146
{
115147
return false;
116148
}
117149
}
118150
for( const auto& block : brep_.blocks() )
119151
{
120-
if( !brep_has_unique_vertex_associated_to_component_id(
152+
if( brep_block_is_meshed( brep_, block.id() )
153+
&& !brep_has_unique_vertex_associated_to_component(
121154
brep_, block.id() ) )
122155
{
123156
return false;
@@ -131,7 +164,7 @@ namespace geode
131164
index_t counter{ 0 };
132165
for( const auto& corner : brep_.corners() )
133166
{
134-
if( !brep_has_unique_vertex_associated_to_component_id(
167+
if( !brep_has_unique_vertex_associated_to_component(
135168
brep_, corner.id() ) )
136169
{
137170
counter++;
@@ -140,12 +173,13 @@ namespace geode
140173
return counter;
141174
}
142175

143-
index_t nb_lines_not_linked_to_a_unique_vertex() const
176+
index_t nb_lines_meshed_but_not_linked_to_a_unique_vertex() const
144177
{
145178
index_t counter{ 0 };
146179
for( const auto& line : brep_.lines() )
147180
{
148-
if( !brep_has_unique_vertex_associated_to_component_id(
181+
if( brep_line_is_meshed( brep_, line.id() )
182+
&& !brep_has_unique_vertex_associated_to_component(
149183
brep_, line.id() ) )
150184
{
151185
counter++;
@@ -154,12 +188,13 @@ namespace geode
154188
return counter;
155189
}
156190

157-
index_t nb_surfaces_not_linked_to_a_unique_vertex() const
191+
index_t nb_surfaces_meshed_but_not_linked_to_a_unique_vertex() const
158192
{
159193
index_t counter{ 0 };
160194
for( const auto& surface : brep_.surfaces() )
161195
{
162-
if( !brep_has_unique_vertex_associated_to_component_id(
196+
if( brep_surface_is_meshed( brep_, surface.id() )
197+
&& !brep_has_unique_vertex_associated_to_component(
163198
brep_, surface.id() ) )
164199
{
165200
counter++;
@@ -168,12 +203,13 @@ namespace geode
168203
return counter;
169204
}
170205

171-
index_t nb_blocks_not_linked_to_a_unique_vertex() const
206+
index_t nb_blocks_meshed_but_not_linked_to_a_unique_vertex() const
172207
{
173208
index_t counter{ 0 };
174209
for( const auto& block : brep_.blocks() )
175210
{
176-
if( !brep_has_unique_vertex_associated_to_component_id(
211+
if( brep_block_is_meshed( brep_, block.id() )
212+
&& !brep_has_unique_vertex_associated_to_component(
177213
brep_, block.id() ) )
178214
{
179215
counter++;
@@ -416,10 +452,10 @@ namespace geode
416452
return impl_->brep_topology_is_valid();
417453
}
418454

419-
bool BRepTopologyInspector::brep_components_are_linked_to_a_unique_vertex()
420-
const
455+
bool BRepTopologyInspector::
456+
brep_meshed_components_are_linked_to_a_unique_vertex() const
421457
{
422-
return impl_->brep_components_are_linked_to_a_unique_vertex();
458+
return impl_->brep_meshed_components_are_linked_to_a_unique_vertex();
423459
}
424460

425461
index_t
@@ -428,22 +464,22 @@ namespace geode
428464
return impl_->nb_corners_not_linked_to_a_unique_vertex();
429465
}
430466

431-
index_t
432-
BRepTopologyInspector::nb_lines_not_linked_to_a_unique_vertex() const
467+
index_t BRepTopologyInspector::
468+
nb_lines_meshed_but_not_linked_to_a_unique_vertex() const
433469
{
434-
return impl_->nb_lines_not_linked_to_a_unique_vertex();
470+
return impl_->nb_lines_meshed_but_not_linked_to_a_unique_vertex();
435471
}
436472

437-
index_t
438-
BRepTopologyInspector::nb_surfaces_not_linked_to_a_unique_vertex() const
473+
index_t BRepTopologyInspector::
474+
nb_surfaces_meshed_but_not_linked_to_a_unique_vertex() const
439475
{
440-
return impl_->nb_surfaces_not_linked_to_a_unique_vertex();
476+
return impl_->nb_surfaces_meshed_but_not_linked_to_a_unique_vertex();
441477
}
442478

443-
index_t
444-
BRepTopologyInspector::nb_blocks_not_linked_to_a_unique_vertex() const
479+
index_t BRepTopologyInspector::
480+
nb_blocks_meshed_but_not_linked_to_a_unique_vertex() const
445481
{
446-
return impl_->nb_blocks_not_linked_to_a_unique_vertex();
482+
return impl_->nb_blocks_meshed_but_not_linked_to_a_unique_vertex();
447483
}
448484

449485
std::vector< index_t >

src/geode/inspector/topology/private/brep_lines_topology_impl.cpp

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,16 @@ namespace geode
8383
for( const auto line : brep_.mesh_component_vertices(
8484
unique_vertex_index, Line3D::component_type_static() ) )
8585
{
86-
if( brep_.nb_embeddings( line.component_id.id() ) < 1 )
87-
{
88-
return false;
89-
}
90-
else if( brep_.nb_embeddings( line.component_id.id() ) > 1
91-
|| brep_.nb_incidences( line.component_id.id() ) > 0 )
86+
const auto embeddings =
87+
brep_.embeddings( line.component_id.id() );
88+
89+
for( const auto embedding : embeddings )
9290
{
93-
return true;
91+
if( brep_.Relationships::is_boundary(
92+
line.component_id.id(), embedding.id() ) )
93+
{
94+
return true;
95+
}
9496
}
9597
}
9698
return false;
@@ -113,7 +115,12 @@ namespace geode
113115
{
114116
if( !brep_.Relationships::is_internal(
115117
lines[0].component_id.id(),
116-
surfaces[0].component_id.id() ) )
118+
surfaces[0].component_id.id() )
119+
&& !( brep_.Relationships::nb_embeddings(
120+
surfaces[0].component_id.id() )
121+
&& brep_.Relationships::is_boundary(
122+
lines[0].component_id.id(),
123+
surfaces[0].component_id.id() ) ) )
117124
{
118125
return true;
119126
}
@@ -133,6 +140,9 @@ namespace geode
133140
for( const auto& surface : surfaces )
134141
{
135142
if( !brep_.Relationships::is_boundary(
143+
lines[0].component_id.id(),
144+
surface.component_id.id() )
145+
&& !brep_.Relationships::is_internal(
136146
lines[0].component_id.id(),
137147
surface.component_id.id() ) )
138148
{

0 commit comments

Comments
 (0)