@@ -169,72 +169,57 @@ namespace
169169 nb_block_cmvs, " Block mesh vertices (should be " ,
170170 predicted_nb_block_cmvs, " )." ) ) );
171171 }
172- // const auto nb_free_line_cmvs = count_cmvs(
173- // unique_vertex_cmvs.line_cmvs, [&brep]( const auto& cmv ) {
174- // return brep.nb_incidences( cmv.component_id.id() ) == 1
175- // && brep.nb_embedding_surfaces(
176- // brep.line( cmv.component_id.id() ) )
177- // == 0 ;
172+ // const auto nb_internal_surface_cmvs = count_cmvs(
173+ // unique_vertex_cmvs.surface_cmvs,
174+ // [&block_uuid, & brep]( const auto& cmv ) {
175+ // return brep.is_internal( brep.surface( cmv.component_id.id()
176+ // ),
177+ // brep.block( block_uuid ) ) ;
178178 // } );
179- // auto predicted_nb_block_cmvs =
180- // nb_internal_surface_cmvs < nb_free_line_cmvs + 1
181- // ? static_cast< geode::index_t >( 1 )
182- // : nb_internal_surface_cmvs - nb_free_line_cmvs;
183- // if( nb_internal_surface_cmvs - nb_free_line_cmvs == 1 )
184- // {
185- // predicted_nb_block_cmvs++;
186- // }
187- // if( nb_boundary_surface_cmvs > 1
188- // && unique_vertex_cmvs.corner_cmvs.empty() )
189- // {
190- // predicted_nb_block_cmvs += ( nb_boundary_surface_cmvs - 2 ) / 2;
191- // }
192- // / predicted_nb_block_cmvs = 1 + nb_internal_surfaces - nb_free_lines -
193- // / nb_lines_boundary_to_strictly_2_internal_surfaces
194- absl::flat_hash_set< geode::uuid > uuids_used;
195- const auto nb_internal_surfaces = count_cmvs (
196- unique_vertex_cmvs.surface_cmvs ,
197- [&block_uuid, &brep, &uuids_used]( const auto & cmv ) {
198- if ( !uuids_used.emplace ( cmv.component_id .id () ).second )
199- {
200- return false ;
201- }
202- return brep.is_internal ( brep.surface ( cmv.component_id .id () ),
203- brep.block ( block_uuid ) );
204- } );
205- uuids_used.clear ();
179+ const auto nb_line_internal_to_internal_surface_cmvs =
180+ count_cmvs ( unique_vertex_cmvs.line_cmvs ,
181+ [&block_uuid, &brep]( const auto & cmv ) {
182+ const auto & cmv_line = brep.line ( cmv.component_id .id () );
183+ if ( brep.nb_embedding_surfaces ( cmv_line ) != 1 )
184+ {
185+ return false ;
186+ }
187+ for ( const auto & incident_surface :
188+ brep.embedding_surfaces ( cmv_line ) )
189+ {
190+ if ( !brep.is_internal (
191+ incident_surface, brep.block ( block_uuid ) ) )
192+ {
193+ return false ;
194+ }
195+ }
196+ return true ;
197+ } );
198+ // absl::flat_hash_set< geode::uuid > uuids_used;
206199 // / Lines that are free but incident to the same surface are counted
207200 // / only once
208- const auto nb_free_lines = count_cmvs ( unique_vertex_cmvs.line_cmvs ,
209- [&brep, &uuids_used]( const auto & cmv ) {
210- if ( !uuids_used.emplace ( cmv.component_id .id () ).second )
211- {
212- return false ;
213- }
201+ const auto nb_free_line_cmvs = count_cmvs (
202+ unique_vertex_cmvs.line_cmvs , [&brep]( const auto & cmv ) {
214203 if ( brep.nb_incidences ( cmv.component_id .id () ) != 1 )
215204 {
216205 return false ;
217206 }
218- for ( const auto & incident_surface :
219- brep.incidences ( brep.line ( cmv.component_id .id () ) ) )
220- {
221- if ( !uuids_used.emplace ( incident_surface.id () ).second )
222- {
223- return false ;
224- }
225- }
207+ // for( const auto& incident_surface :
208+ // brep.incidences( brep.line( cmv.component_id.id() ) ) )
209+ // {
210+ // if( !uuids_used.emplace( incident_surface.id() ).second )
211+ // {
212+ // return false;
213+ // }
214+ // }
226215 return brep.nb_embedding_surfaces (
227216 brep.line ( cmv.component_id .id () ) )
228217 == 0 ;
229218 } );
230- uuids_used.clear ();
231- const auto nb_lines_boundary_to_two_internal_lines =
219+ // uuids_used.clear();
220+ const auto nb_lines_boundary_to_two_internal_surfaces_cmvs =
232221 count_cmvs ( unique_vertex_cmvs.line_cmvs ,
233- [&block_uuid, &brep, &uuids_used]( const auto & cmv ) {
234- if ( !uuids_used.emplace ( cmv.component_id .id () ).second )
235- {
236- return false ;
237- }
222+ [&block_uuid, &brep]( const auto & cmv ) {
238223 if ( brep.nb_incidences ( cmv.component_id .id () ) != 2 )
239224 {
240225 return false ;
@@ -250,10 +235,19 @@ namespace
250235 }
251236 return true ;
252237 } );
253- geode::index_t predicted_nb_block_cmvs{
254- 1 + nb_internal_surfaces - nb_free_lines
255- - nb_lines_boundary_to_two_internal_lines
238+ geode::index_t predicted_nb_block_cmvs{ 1 + nb_internal_surface_cmvs };
239+ const geode::index_t nb_line_cmvs_to_remove{
240+ nb_line_internal_to_internal_surface_cmvs + nb_free_line_cmvs
241+ + nb_lines_boundary_to_two_internal_surfaces_cmvs
256242 };
243+ if ( predicted_nb_block_cmvs > nb_line_cmvs_to_remove )
244+ {
245+ predicted_nb_block_cmvs -= nb_line_cmvs_to_remove;
246+ }
247+ else
248+ {
249+ predicted_nb_block_cmvs = 1 ;
250+ }
257251 return std::make_pair ( predicted_nb_block_cmvs,
258252 nb_block_cmvs == predicted_nb_block_cmvs
259253 ? std::nullopt
@@ -265,12 +259,16 @@ namespace
265259 .point ( unique_vertex_cmvs.block_cmvs [0 ].vertex )
266260 .string (),
267261 " ] is part of Block " , brep.block ( block_uuid ).name (),
268- " (" , block_uuid.string (), " ), and part of " ,
269- nb_internal_surfaces,
270- " surfaces internal to that block, " , nb_free_lines,
271- " free lines on different surfaces, and " ,
272- nb_lines_boundary_to_two_internal_lines,
273- " lines boundary to strictly two internal lines, with " ,
262+ " (" , block_uuid.string (), " ), and has " ,
263+ nb_internal_surface_cmvs,
264+ " cmvs of surfaces internal to that block, " ,
265+ nb_line_internal_to_internal_surface_cmvs,
266+ " cmvs of lines internal to one surface internal to that "
267+ " block, " ,
268+ nb_free_line_cmvs, " cmvs of free lines, and " ,
269+ nb_lines_boundary_to_two_internal_surfaces_cmvs,
270+ " cmvs of lines boundary to strictly two internal lines, "
271+ " with " ,
274272 nb_block_cmvs, " Block CMVs (should be " ,
275273 predicted_nb_block_cmvs, " )." ) ) );
276274 }
0 commit comments