@@ -144,22 +144,24 @@ namespace geode
144144 for ( const auto & surface : model ().surfaces () )
145145 {
146146 const auto & mesh = surface.mesh ();
147- for ( const auto p : Range{ mesh.nb_polygons () } )
147+ for ( const auto polygon_id : Range{ mesh.nb_polygons () } )
148148 {
149- const auto vertices = mesh.polygon_vertices ( p );
150- for ( const auto e : LIndices{ vertices } )
149+ const auto vertices = mesh.polygon_vertices ( polygon_id );
150+ for ( const auto edge_id : LIndices{ vertices } )
151151 {
152- const auto adj = mesh.polygon_adjacent ( { p, e } );
153- if ( !adj || adj.value () < p )
152+ const auto adj =
153+ mesh.polygon_adjacent ( { polygon_id, edge_id } );
154+ if ( !adj || adj.value () < polygon_id )
154155 {
155156 continue ;
156157 }
157158 const auto v0 = model ().unique_vertex (
158- { surface.component_id (), vertices[e ] } );
159+ { surface.component_id (), vertices[edge_id ] } );
159160 const auto v1 =
160161 model ().unique_vertex ( { surface.component_id (),
161- vertices[e == vertices.size () - 1 ? 0
162- : e + 1 ] } );
162+ vertices[edge_id == vertices.size () - 1
163+ ? 0
164+ : edge_id + 1 ] } );
163165 const auto info = edges.try_emplace (
164166 Edge{ std::array< index_t , 2 >{ v0, v1 } },
165167 std::vector< uuid >{ surface.id () } );
@@ -173,49 +175,50 @@ namespace geode
173175 for ( auto & edge : edges )
174176 {
175177 sort_unique ( edge.second );
176- if ( edge.second .size () > 1 )
178+ if ( edge.second .size () <= 1 )
177179 {
178- std::string message =
179- absl::StrCat ( " Model edge between unique vertices " ,
180- edge.first .vertices ()[0 ], " and " ,
181- edge.first .vertices ()[1 ],
182- " is not manifold: it does not belong to a line "
183- " but is on surfaces " );
184- for ( const auto surface_uuid : edge.second )
185- {
186- absl::StrAppend (
187- &message, surface_uuid.string (), " , " );
188- }
189- issues.add_issue (
190- BRepNonManifoldEdge{
191- edge.first .vertices (), edge.second },
192- message );
193180 continue ;
194181 }
182+ std::string message = absl::StrCat (
183+ " Model edge between unique vertices " ,
184+ edge.first .vertices ()[0 ], " and " , edge.first .vertices ()[1 ],
185+ " is not manifold: it does not belong to a line "
186+ " but is on surfaces " );
187+ for ( const auto surface_uuid : edge.second )
188+ {
189+ absl::StrAppend ( &message, surface_uuid.string (), " , " );
190+ }
191+ issues.add_issue (
192+ BRepNonManifoldEdge{ edge.first .vertices (), edge.second },
193+ message );
195194 }
196195 for ( const auto & line : model ().lines () )
197196 {
198197 const auto & mesh = line.mesh ();
199- if ( mesh.nb_edges () = = 1
200- && model ().nb_embedding_surfaces ( line ) > 0 )
198+ if ( mesh.nb_edges () ! = 1
199+ || model ().nb_embedding_surfaces ( line ) == 0 )
201200 {
202- std::array< index_t , 2 > edge_unique_vertices;
203- for ( const auto edge_vertex : LRange{ 2 } )
204- {
205- edge_unique_vertices[edge_vertex] =
206- model ().unique_vertex ( { line.component_id (),
207- mesh.edge_vertex ( { 0 , edge_vertex } ) } );
208- }
209- std::string message =
210- absl::StrCat ( " Model edge between unique vertices " ,
211- edge_unique_vertices[0 ], " and " ,
212- edge_unique_vertices[1 ],
213- " is not manifold: it belongs to internal line " ,
214- line.id ().string (), " with only one edge" );
215- issues.add_issue ( BRepNonManifoldEdge{ edge_unique_vertices,
216- { line.id () } },
217- message );
201+ continue ;
218202 }
203+ std::array< index_t , 2 > edge_unique_vertices;
204+ for ( const auto edge_vertex : LRange{ 2 } )
205+ {
206+ edge_unique_vertices[edge_vertex] =
207+ model ().unique_vertex ( { line.component_id (),
208+ mesh.edge_vertex ( { 0 , edge_vertex } ) } );
209+ }
210+ if ( several_cmvs_on_one_vertex ( edge_unique_vertices ) )
211+ {
212+ continue ;
213+ }
214+ std::string message = absl::StrCat (
215+ " Model edge between unique vertices " ,
216+ edge_unique_vertices[0 ], " and " , edge_unique_vertices[1 ],
217+ " is not manifold: it belongs to internal line " ,
218+ line.id ().string (), " with only one edge" );
219+ issues.add_issue (
220+ BRepNonManifoldEdge{ edge_unique_vertices, { line.id () } },
221+ message );
219222 }
220223 }
221224
@@ -225,25 +228,50 @@ namespace geode
225228 for ( const auto & surface : model ().surfaces () )
226229 {
227230 const auto & mesh = surface.mesh ();
228- if ( mesh.nb_polygons () == 1
229- && model ().nb_embedding_blocks ( surface ) > 0 )
231+ if ( mesh.nb_polygons () != 1
232+ || model ().nb_embedding_blocks ( surface ) == 0 )
233+ {
234+ continue ;
235+ }
236+ auto facet_vertices =
237+ polygon_unique_vertices ( model (), surface, 0 );
238+ if ( several_cmvs_on_one_vertex ( facet_vertices ) )
239+ {
240+ continue ;
241+ }
242+ std::string message = " Model facet between unique vertices " ;
243+ for ( const auto polygon_vertex : facet_vertices )
244+ {
245+ absl::StrAppend ( &message, polygon_vertex, " " );
246+ }
247+ absl::StrAppend ( &message,
248+ " is not manifold: it belongs to an internal "
249+ " surface with only one facet" );
250+ issues.add_issue (
251+ BRepNonManifoldFacet{ facet_vertices, { surface.id () } },
252+ message );
253+ }
254+ }
255+
256+ private:
257+ bool several_cmvs_on_one_vertex (
258+ absl::Span< const index_t > unique_vertices ) const
259+ {
260+ for ( const auto unique_vertex : unique_vertices )
261+ {
262+ std::vector< uuid > components;
263+ for ( const auto & cmv :
264+ model ().component_mesh_vertices ( unique_vertex ) )
230265 {
231- auto facet_vertices =
232- polygon_unique_vertices ( model (), surface, 0 );
233- std::string message =
234- " Model facet between unique vertices " ;
235- for ( const auto polygon_vertex : facet_vertices )
266+ if ( absl::c_find ( components, cmv.component_id .id () )
267+ != components.end () )
236268 {
237- absl::StrAppend ( &message, polygon_vertex, " " ) ;
269+ return true ;
238270 }
239- absl::StrAppend ( &message,
240- " is not manifold: it belongs to an internal "
241- " surface with only one facet" );
242- issues.add_issue ( BRepNonManifoldFacet{ facet_vertices,
243- { surface.id () } },
244- message );
271+ components.push_back ( cmv.component_id .id () );
245272 }
246273 }
274+ return false ;
247275 }
248276 };
249277
0 commit comments