Skip to content

Commit a1f26e9

Browse files
committed
fix(Inspector): adding api functions to detect elements smaller than a given threshold
1 parent ebb64d3 commit a1f26e9

File tree

10 files changed

+93
-79
lines changed

10 files changed

+93
-79
lines changed

include/geode/inspector/criterion/degeneration/brep_meshes_degeneration.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,13 @@ namespace geode
7575
inspect_elements_degeneration() const;
7676

7777
[[nodiscard]] BRepMeshesDegenerationInspectionResult
78-
inspect_polygons_degeneration( double tolerance ) const;
78+
inspect_polygons_degeneration( double threshold ) const;
7979

8080
[[nodiscard]] BRepMeshesDegenerationInspectionResult
81-
inspect_edges_degeneration( double tolerance ) const;
81+
inspect_edges_degeneration( double threshold ) const;
8282

8383
[[nodiscard]] BRepMeshesDegenerationInspectionResult
84-
inspect_polyhedra_degeneration() const;
84+
inspect_polyhedra_degeneration( double threshold ) const;
8585

8686
private:
8787
IMPLEMENTATION_MEMBER( impl_ );

include/geode/inspector/criterion/degeneration/solid_degeneration.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,14 @@ namespace geode
5151

5252
[[nodiscard]] bool is_mesh_degenerated() const;
5353

54+
[[nodiscard]] InspectionIssues< index_t > small_edges(
55+
double threshold ) const;
56+
5457
[[nodiscard]] InspectionIssues< index_t > degenerated_edges() const;
5558

59+
[[nodiscard]] InspectionIssues< index_t > small_height_polyhedra(
60+
double threshold ) const;
61+
5662
[[nodiscard]] InspectionIssues< index_t > degenerated_polyhedra() const;
5763

5864
private:

include/geode/inspector/criterion/internal/component_meshes_degeneration.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,19 @@ namespace geode
4848
OPENGEODE_DISABLE_COPY( ComponentMeshesDegeneration );
4949

5050
public:
51-
void add_degenerated_edges(
52-
InspectionIssuesMap< index_t >& issues_map ) const;
53-
5451
void add_small_edges( InspectionIssuesMap< index_t >& issues_map,
55-
double tolerance ) const;
56-
57-
void add_degenerated_polygons(
58-
InspectionIssuesMap< index_t >& issues_map ) const;
52+
double threshold ) const;
5953

6054
void add_small_height_polygons(
6155
InspectionIssuesMap< index_t >& issues_map,
6256
double tolerance ) const;
6357

58+
void add_degenerated_edges(
59+
InspectionIssuesMap< index_t >& issues_map ) const;
60+
61+
void add_degenerated_polygons(
62+
InspectionIssuesMap< index_t >& issues_map ) const;
63+
6464
protected:
6565
explicit ComponentMeshesDegeneration( const Model& model );
6666

include/geode/inspector/criterion/internal/degeneration_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace geode
4747
[[nodiscard]] InspectionIssues< index_t > degenerated_edges() const;
4848

4949
private:
50-
[[nodiscard]] bool edge_is_smaller_than_threshold(
50+
[[nodiscard]] bool is_edge_smaller_than_threshold(
5151
index_t edge_index, double tolerance ) const;
5252

5353
[[nodiscard]] bool edge_is_degenerated( index_t edge_index ) const;

src/geode/inspector/criterion/degeneration/brep_meshes_degeneration.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,25 +76,35 @@ namespace geode
7676
{
7777
}
7878

79-
void add_degenerated_polyhedra(
79+
void add_solid_small_elements(
8080
InspectionIssuesMap< index_t >& degenerated_edges_map,
81-
InspectionIssuesMap< index_t >& degenerated_polyhedra_map ) const
81+
InspectionIssuesMap< index_t >& degenerated_polyhedra_map,
82+
double threshold ) const
8283
{
8384
for( const auto& block : model().blocks() )
8485
{
8586
const geode::SolidMeshDegeneration3D inspector{ block.mesh() };
86-
auto degenerated_edges = inspector.degenerated_edges();
87+
auto degenerated_edges = inspector.small_edges( threshold );
8788
degenerated_edges.set_description( absl::StrCat(
8889
"Block ", block.id().string(), " degenerated edges" ) );
8990
degenerated_edges_map.add_issues_to_map(
9091
block.id(), std::move( degenerated_edges ) );
91-
auto degenerated_polyhedra = inspector.degenerated_polyhedra();
92+
auto degenerated_polyhedra =
93+
inspector.small_height_polyhedra( threshold );
9294
degenerated_polyhedra.set_description( absl::StrCat(
9395
"Block ", block.id().string(), " degenerated polyhedra" ) );
9496
degenerated_polyhedra_map.add_issues_to_map(
9597
block.id(), std::move( degenerated_polyhedra ) );
9698
}
9799
}
100+
101+
void add_solid_degenerations(
102+
InspectionIssuesMap< index_t >& degenerated_edges_map,
103+
InspectionIssuesMap< index_t >& degenerated_polyhedra_map ) const
104+
{
105+
add_solid_small_elements( degenerated_edges_map,
106+
degenerated_polyhedra_map, GLOBAL_EPSILON );
107+
}
98108
};
99109

100110
BRepComponentMeshesDegeneration::BRepComponentMeshesDegeneration(
@@ -112,36 +122,37 @@ namespace geode
112122
BRepMeshesDegenerationInspectionResult result;
113123
impl_->add_degenerated_edges( result.degenerated_edges );
114124
impl_->add_degenerated_polygons( result.degenerated_polygons );
115-
impl_->add_degenerated_polyhedra(
125+
impl_->add_solid_degenerations(
116126
result.degenerated_edges, result.degenerated_polyhedra );
117127
return result;
118128
}
119129

120130
BRepMeshesDegenerationInspectionResult
121131
BRepComponentMeshesDegeneration::inspect_edges_degeneration(
122-
double tolerance ) const
132+
double threshold ) const
123133
{
124134
BRepMeshesDegenerationInspectionResult result;
125-
impl_->add_degenerated_edges( result.degenerated_edges, tolerance );
135+
impl_->add_small_edges( result.degenerated_edges, threshold );
126136
return result;
127137
}
128138

129139
BRepMeshesDegenerationInspectionResult
130140
BRepComponentMeshesDegeneration::inspect_polygons_degeneration(
131-
double tolerance ) const
141+
double threshold ) const
132142
{
133143
BRepMeshesDegenerationInspectionResult result;
134-
impl_->add_degenerated_polygons(
135-
result.degenerated_polygons, tolerance );
144+
impl_->add_small_height_polygons(
145+
result.degenerated_polygons, threshold );
136146
return result;
137147
}
138148

139149
BRepMeshesDegenerationInspectionResult
140-
BRepComponentMeshesDegeneration::inspect_polyhedra_degeneration() const
150+
BRepComponentMeshesDegeneration::inspect_polyhedra_degeneration(
151+
double threshold ) const
141152
{
142153
BRepMeshesDegenerationInspectionResult result;
143-
impl_->add_degenerated_polyhedra(
144-
result.degenerated_edges, result.degenerated_polyhedra );
154+
impl_->add_solid_small_elements(
155+
result.degenerated_edges, result.degenerated_polyhedra, threshold );
145156
return result;
146157
}
147158

src/geode/inspector/criterion/degeneration/edgedcurve_degeneration.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ namespace geode
5151
return false;
5252
}
5353

54-
InspectionIssues< index_t > degenerated_edges( double tolerance ) const
54+
InspectionIssues< index_t > small_edges( double threshold ) const
5555
{
5656
InspectionIssues< index_t > degenerated_edges_index{
5757
"Degenerated Edges of EdgeCurve " + mesh_.id().string() + "."
5858
};
5959
for( const auto edge_id : Range{ mesh_.nb_edges() } )
6060
{
61-
if( mesh_.is_edge_degenerated( edge_id, tolerance ) )
61+
if( mesh_.edge_length( edge_id ) <= threshold )
6262
{
6363
degenerated_edges_index.add_issue(
6464
edge_id, absl::StrCat( "Edge with index ", edge_id,
@@ -72,7 +72,7 @@ namespace geode
7272

7373
InspectionIssues< index_t > degenerated_edges() const
7474
{
75-
return degenerated_edges( GLOBAL_EPSILON );
75+
return small_edges( GLOBAL_EPSILON );
7676
}
7777

7878
private:
@@ -97,10 +97,10 @@ namespace geode
9797

9898
template < index_t dimension >
9999
InspectionIssues< index_t >
100-
EdgedCurveDegeneration< dimension >::degenerated_edges(
101-
double tolerance ) const
100+
EdgedCurveDegeneration< dimension >::small_edges(
101+
double threshold ) const
102102
{
103-
return impl_->degenerated_edges( tolerance );
103+
return impl_->small_edges( threshold );
104104
}
105105

106106
template < index_t dimension >

src/geode/inspector/criterion/degeneration/solid_degeneration.cpp

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,17 @@ namespace geode
6464
return false;
6565
}
6666

67-
InspectionIssues< index_t > degenerated_polyhedra() const
67+
InspectionIssues< index_t > small_height_polyhedra(
68+
double threshold ) const
6869
{
6970
InspectionIssues< index_t > wrong_polyhedra{
7071
"Degenerated Polyhedra."
7172
};
7273
for( const auto polyhedron_id :
7374
Range{ this->mesh().nb_polyhedra() } )
7475
{
75-
if( this->mesh().is_polyhedron_degenerated( polyhedron_id ) )
76+
if( this->mesh().polyhedron_minimum_height( polyhedron_id )
77+
<= threshold )
7678
{
7779
wrong_polyhedra.add_issue( polyhedron_id,
7880
absl::StrCat( "Polyhedron ", polyhedron_id,
@@ -82,6 +84,11 @@ namespace geode
8284
}
8385
return wrong_polyhedra;
8486
}
87+
88+
InspectionIssues< index_t > degenerated_polyhedra() const
89+
{
90+
return small_height_polyhedra( GLOBAL_EPSILON );
91+
}
8592
};
8693

8794
template < index_t dimension >
@@ -100,13 +107,28 @@ namespace geode
100107
return impl_->is_mesh_degenerated();
101108
}
102109

110+
template < index_t dimension >
111+
InspectionIssues< index_t > SolidMeshDegeneration< dimension >::small_edges(
112+
double threshold ) const
113+
{
114+
return impl_->small_edges( threshold );
115+
}
116+
103117
template < index_t dimension >
104118
InspectionIssues< index_t >
105119
SolidMeshDegeneration< dimension >::degenerated_edges() const
106120
{
107121
return impl_->degenerated_edges();
108122
}
109123

124+
template < index_t dimension >
125+
InspectionIssues< index_t >
126+
SolidMeshDegeneration< dimension >::small_height_polyhedra(
127+
double threshold ) const
128+
{
129+
return impl_->small_height_polyhedra( threshold );
130+
}
131+
110132
template < index_t dimension >
111133
InspectionIssues< index_t >
112134
SolidMeshDegeneration< dimension >::degenerated_polyhedra() const

src/geode/inspector/criterion/degeneration/surface_degeneration.cpp

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
#include <geode/geometry/mensuration.hpp>
3232

3333
#include <geode/mesh/core/surface_mesh.hpp>
34-
#include <geode/mesh/helpers/mesh_quality.hpp>
3534

3635
#include <geode/inspector/criterion/internal/degeneration_impl.hpp>
3736

@@ -72,8 +71,8 @@ namespace geode
7271
};
7372
for( const auto polygon_id : Range{ this->mesh().nb_polygons() } )
7473
{
75-
if( is_polygon_minimum_height_too_small(
76-
this->mesh(), polygon_id, tolerance ) )
74+
if( this->mesh().polygon_minimum_height( polygon_id )
75+
<= tolerance )
7776
{
7877
wrong_polygons.add_issue( polygon_id,
7978
absl::StrCat( "Polygon ", polygon_id, " of Surface ",
@@ -85,20 +84,7 @@ namespace geode
8584

8685
InspectionIssues< index_t > degenerated_polygons() const
8786
{
88-
InspectionIssues< index_t > wrong_polygons{
89-
"Degenerated Polygons."
90-
};
91-
for( const auto polygon_id : Range{ this->mesh().nb_polygons() } )
92-
{
93-
if( this->mesh().is_polygon_degenerated(
94-
polygon_id, GLOBAL_EPSILON ) )
95-
{
96-
wrong_polygons.add_issue( polygon_id,
97-
absl::StrCat( "Polygon ", polygon_id, " of Surface ",
98-
this->mesh().id().string(), " is degenerated." ) );
99-
}
100-
}
101-
return wrong_polygons;
87+
return small_height_polygons( GLOBAL_EPSILON );
10288
}
10389
};
10490

src/geode/inspector/criterion/internal/component_meshes_degeneration.cpp

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,16 @@ namespace geode
4747
}
4848

4949
template < typename Model >
50-
void ComponentMeshesDegeneration< Model >::add_degenerated_edges(
50+
void ComponentMeshesDegeneration< Model >::add_small_edges(
5151
InspectionIssuesMap< index_t >& components_degenerated_edges,
52-
double tolerance ) const
52+
double threshold ) const
5353
{
5454
for( const auto& line : model_.lines() )
5555
{
5656
const EdgedCurveDegeneration< Model::dim > inspector{
5757
line.mesh()
5858
};
59-
auto issues = inspector.degenerated_edges( tolerance );
59+
auto issues = inspector.small_edges( threshold );
6060
issues.set_description( absl::StrCat(
6161
"Line ", line.id().string(), " degenerated edges" ) );
6262
components_degenerated_edges.add_issues_to_map(
@@ -67,7 +67,7 @@ namespace geode
6767
const geode::SurfaceMeshDegeneration< Model::dim > inspector{
6868
surface.mesh()
6969
};
70-
auto issues = inspector.degenerated_edges( tolerance );
70+
auto issues = inspector.small_edges( threshold );
7171
issues.set_description( absl::StrCat(
7272
"Surface ", surface.id().string(), " degenerated edges" ) );
7373
components_degenerated_edges.add_issues_to_map(
@@ -79,21 +79,20 @@ namespace geode
7979
void ComponentMeshesDegeneration< Model >::add_degenerated_edges(
8080
InspectionIssuesMap< index_t >& components_degenerated_edges ) const
8181
{
82-
add_degenerated_edges(
83-
components_degenerated_edges, GLOBAL_EPSILON );
82+
add_small_edges( components_degenerated_edges, GLOBAL_EPSILON );
8483
}
8584

8685
template < typename Model >
87-
void ComponentMeshesDegeneration< Model >::add_degenerated_polygons(
88-
InspectionIssuesMap< index_t >& components_degenerated_polygons )
89-
const
86+
void ComponentMeshesDegeneration< Model >::add_small_height_polygons(
87+
InspectionIssuesMap< index_t >& components_degenerated_polygons,
88+
double threshold ) const
9089
{
9190
for( const auto& surface : model_.surfaces() )
9291
{
9392
const geode::SurfaceMeshDegeneration< Model::dim > inspector{
9493
surface.mesh()
9594
};
96-
auto issues = inspector.degenerated_polygons();
95+
auto issues = inspector.small_height_polygons( threshold );
9796
issues.set_description( absl::StrCat( "Surface ",
9897
surface.id().string(), " degenerated polygons" ) );
9998
components_degenerated_polygons.add_issues_to_map(
@@ -103,20 +102,11 @@ namespace geode
103102

104103
template < typename Model >
105104
void ComponentMeshesDegeneration< Model >::add_degenerated_polygons(
106-
InspectionIssuesMap< index_t >& components_degenerated_polygons,
107-
double tolerance ) const
105+
InspectionIssuesMap< index_t >& components_degenerated_polygons )
106+
const
108107
{
109-
for( const auto& surface : model_.surfaces() )
110-
{
111-
const geode::SurfaceMeshDegeneration< Model::dim > inspector{
112-
surface.mesh()
113-
};
114-
auto issues = inspector.degenerated_polygons( tolerance );
115-
issues.set_description( absl::StrCat( "Surface ",
116-
surface.id().string(), " degenerated polygons" ) );
117-
components_degenerated_polygons.add_issues_to_map(
118-
surface.id(), std::move( issues ) );
119-
}
108+
add_small_height_polygons(
109+
components_degenerated_polygons, GLOBAL_EPSILON );
120110
}
121111

122112
template < typename Model >

0 commit comments

Comments
 (0)