23 : mbImpl( impl ), mbMergeTag( 0 ), mergeTol( 0.001 ), mergeTolSq( 0.000001 ), printError( printErrorIn )
35 const double merge_tol,
37 const int update_sets,
44 tmp_elems.
insert( elems, elems + elems_size );
61 const double merge_tol,
65 bool merge_higher_dim )
68 if( merge_higher_dim && !do_merge )
95 result = kd.
build_tree( skin_range, &tree_root );
109 if( merge_higher_dim &&
deadEnts.size() != 0 )
165 if(
printError ) std::cout <<
"\nWarning: Geometries don't have a common face; Nothing to merge" << std::endl;
169 std::vector< EntityHandle > merge_tag_val(
deadEnts.size() );
175 std::set< EntityHandle >::iterator rit;
179 assert( merge_tag_val[i] );
207 return ( ia->
eh < ib->
eh ) ? -1 : 1;
211 return ( ia->
val - ib->
val );
222 std::vector< int > vals( verts.
size() );
236 std::vector< handle_id > handles( verts.
size() );
240 handles[i].eh = *vit;
241 handles[i].val = vals[i];
247 while( i < (
int)verts.
size() - 1 )
251 while( j < (
int)verts.
size() && handles[j].val ==
first.val )
270 Range leaf_range, leaf_range2;
271 std::vector< EntityHandle > sorted_leaves;
272 std::vector< double > coords;
273 std::vector< EntityHandle > merge_tag_val, leaves_out;
279 sorted_leaves.push_back( iter.
handle() );
280 result = iter.
step();
283 std::sort( sorted_leaves.begin(), sorted_leaves.end() );
285 std::vector< EntityHandle >::iterator it;
286 for( it = sorted_leaves.begin(); it != sorted_leaves.end(); ++it )
292 coords.resize( 3 * leaf_range.
size() );
293 merge_tag_val.resize( leaf_range.
size() );
300 bool inleaf_merged, outleaf_merged =
false;
301 unsigned int lr_size = leaf_range.
size();
303 for( i = 0, rit = leaf_range.
begin(); i != lr_size; ++rit, i++ )
305 if( 0 != merge_tag_val[i] )
continue;
307 inleaf_merged =
false;
314 for( std::vector< EntityHandle >::iterator vit = leaves_out.begin(); vit != leaves_out.end(); ++vit )
322 if( !leaf_range2.
empty() )
324 coords.resize( 3 * ( lr_size + leaf_range2.
size() ) );
325 merge_tag_val.resize( lr_size + leaf_range2.
size() );
330 outleaf_merged =
false;
334 for(
unsigned int j = i + 1; j < merge_tag_val.size(); j++ )
336 EntityHandle to_ent = j >= lr_size ? leaf_range2[j - lr_size] : leaf_range[j];
338 if( *rit == to_ent )
continue;
342 merge_tag_val[j] = *rit;
345 inleaf_merged =
true;
349 outleaf_merged =
true;
358 outleaf_merged =
false;
383 Range mergedToVertsRange;
387 Range possibleEntsToMerge, conn, matches, moreDeadEnts;
391 moreDeadEnts.
clear();
392 possibleEntsToMerge.
clear();
409 if( matches.
size() > 1 )
414 if( to_remove != eh )
416 moreDeadEnts.
insert( to_remove );
419 possibleEntsToMerge.
erase( to_remove );
430 Range skinEnts, adj, matches, moreDeadEnts;
437 moreDeadEnts.
clear();
438 result = skinner.
find_skin(0, elems,
dim, skinEnts,
false,
false);
441 skinIt != skinEnts.
end(); ++skinIt)
455 if (matches.
size() > 1)
458 matchIt != matches.
end(); ++matchIt)
460 if (*matchIt != *skinIt)
462 moreDeadEnts.
insert(*matchIt);
466 skinEnts.
erase(*matchIt);