29 if( MB_SUCCESS != rval ) return error( rval )
31 #define UNRECOVERABLE( ERRCODE ) \
34 if( MB_SUCCESS != ( ERRCODE ) ) \
36 error( ( ERRCODE ) ); \
37 std::cerr << "Unreconverable error during mesh reorder." << std::endl \
38 << "Error Code " << ( ERRCODE ) << " at " << __FILE__ << ":" << __LINE__ << std::endl; \
50 rval =
moab->tag_get_data_type( tag, act_type );
CHKERR;
52 rval =
moab->tag_get_bytes( tag, act_size );
CHKERR;
76 std::set< int > values;
77 for( i = seqs.
begin(); i != seqs.
end(); ++i )
86 std::set< int >::iterator j;
87 for( j = values.begin(); j != values.end(); ++j )
107 for( s = seqs.
begin(); s != seqs.
end(); ++s )
132 std::vector< int > sortvals(
entities.size() );
139 if( sortvals[r] == skip_value )
143 sortvals[w++] = sortvals[r];
147 sortvals.resize( w );
150 std::sort( sortvals.begin(), sortvals.end() );
156 std::vector< size_t > offsets;
157 offsets.push_back( 0 );
158 offsets.push_back( 1 );
159 for( w = 0, r = 1; r < sortvals.size(); ++r )
161 if( sortvals[r] == sortvals[w] )
168 sortvals[w] = sortvals[r];
169 offsets.push_back( offsets.back() + 1 );
173 assert( w + 1 == offsets.size() );
174 sortvals.resize( w );
181 w = std::lower_bound( sortvals.begin(), sortvals.end(), val ) - sortvals.begin();
182 assert( w < sortvals.size() );
183 size_t offset = offsets[w];
200 const int negone = -1;
206 return error( rval );
209 std::vector< std::vector< EntityHandle >* > data;
211 for(
size_t i = 0; i < data.size(); ++i )
216 return error( rval );
223 return error( rval );
235 bool operator()(
const std::vector< EntityHandle >* v1,
const std::vector< EntityHandle >* v2 )
const
237 std::vector< EntityHandle >::const_iterator i1, i2;
238 for( i1 = v1->begin(), i2 = v2->begin(); i1 != v1->end(); ++i1, ++i2 )
240 if( i2 == v2->end() || *i1 > *i2 )
245 return i2 != v2->end();
252 std::vector< std::vector< EntityHandle >* >& revMap )
263 std::map< std::vector< EntityHandle >*, int,
CompSortedVect > forMap;
264 std::map< std::vector< EntityHandle >*, int,
CompSortedVect >::iterator fiter, fiter2;
265 std::vector< EntityHandle > sharing;
272 Range tmp, ents, adj[4];
276 for(
int ldim = 0; ldim <
dim; ++ldim )
280 for(
int udim =
dim + 1; udim <= 3; ++udim )
305 if( val != skip_val )
307 sharing = *revMap[val];
308 assert( std::lower_bound( sharing.begin(), sharing.end(), *s ) == sharing.end() );
310 sharing.push_back( *s );
313 fiter = forMap.lower_bound( &sharing );
314 if( fiter == forMap.end() || lessthan( fiter->first, &sharing ) )
317 std::vector< EntityHandle >* newvec =
new std::vector< EntityHandle >;
318 newvec->swap( sharing );
319 if( (
int)revMap.size() == skip_val ) revMap.push_back( 0 );
321 forMap.insert( fiter, std::pair< std::vector< EntityHandle >*,
int >( newvec, revMap.size() ) );
322 assert( fiter2 != fiter );
324 revMap.push_back( newvec );
337 const Range& old_handles,
338 std::vector< EntityHandle >& new_handles )
340 new_handles.resize( old_handles.
size() );
344 std::vector< EntityHandle >::iterator it2 = new_handles.begin();
345 for( ; it1 != old_handles.
end(); ++it1, ++it2 )
346 if( 0 == *it2 ) *it2 = *it1;
352 const std::vector< EntityHandle >& old_handles,
353 std::vector< EntityHandle >& new_handles )
355 new_handles.resize( old_handles.size() );
366 for(
size_t i = 0; i < num_handles; ++i )
367 if( 0 == new_handles[i] ) new_handles[i] = old_handles[i];
375 newhandles.resize( old_handles.
size() );
381 for(
size_t r = 0; r < newhandles.size(); ++r )
383 if( 0 != newhandles[r] )
385 newhandles[w] = newhandles[r];
391 i = old_handles.
erase( i );
394 newhandles.resize( w );
395 assert( newhandles.size() == old_handles.
size() );
416 std::set< int > values;
417 for( i = seqs.
begin(); i != seqs.
end(); ++i )
426 std::set< int >::iterator j;
427 for( j = values.begin(); j != values.end(); ++j )
431 std::vector< EntityHandle > handles;
437 std::vector< double > coords(
entities.size() * 3 );
440 rval =
mMB->
set_coords( &handles[0], handles.size(), &coords[0] );
445 std::vector< EntityHandle > conn;
446 conn.reserve(
entities.size() * *j );
447 std::vector< EntityHandle > old_handles;
448 old_handles.resize(
entities.size() );
456 for(
unsigned int h = 0; h < handles.size(); ++h )
466 std::vector< Tag > tag_handles;
468 for(
size_t i = 0; i < tag_handles.size(); ++i )
470 Tag tag = tag_handles[i];
471 if( tag == new_handles )
503 return error( rval );
518 std::vector< EntityHandle > newhandles;
527 std::vector< unsigned char >
buffer;
528 std::vector< const void* > pointers;
529 std::vector< int >
sizes;
533 pointers.resize( old_tagged.
size() );
534 sizes.resize( pointers.size() );
536 int total = std::accumulate(
sizes.begin(),
sizes.end(), 0 );
543 type_size =
sizeof( int );
546 type_size =
sizeof( double );
560 buffer.resize( total * type_size );
562 for(
size_t j = 0; j < pointers.size(); ++j )
564 memcpy( &
buffer[off], pointers[j], type_size *
sizes[j] );
565 pointers[j] = &
buffer[off];
566 off +=
sizes[j] * type_size;
580 std::vector< unsigned char > buffer2(
buffer.size() );
610 std::sort( newhandles.begin(), newhandles.end() );
611 std::vector< EntityHandle >::iterator k = newhandles.begin();
613 while( i != old_tagged.
end() )
615 while( k != newhandles.end() && *k < *i )
617 if( k == newhandles.end() )
break;
620 i = old_tagged.
erase( i );
625 if( !old_tagged.
empty() )
638 std::vector< EntityHandle > old_handles, new_handles;
644 if( !( opts & MESHSET_ORDERED ) )
652 std::sort( new_handles.begin(), new_handles.end() );
654 for(
size_t j = 0; j < new_handles.size(); ++j )
655 hint = replace.
insert( hint, new_handles[j] );
659 assert( contents.
size() == replace.
size() );
660 if( !contents.
empty() )