MOAB: Mesh Oriented datABase
(version 5.4.1)
|
00001 #include "moab/Core.hpp" 00002 #include "moab/ReorderTool.hpp" 00003 #include "TestUtil.hpp" 00004 00005 using namespace moab; 00006 00007 // some tag names 00008 const char GLOBAL_ID_NAME[] = "GLOBAL_ID"; /* global ID assigned to each vtx and quad */ 00009 const char SET_IDS_NAME[] = "SET_IDS"; /* global IDs of entities in each set */ 00010 const char SET_HANDLES_NAME[] = "SET_HANDLES"; /* handles of entities in each set */ 00011 const char CONN_IDS_NAME[] = "CONN_IDS"; /* global IDs of vertices in each quad */ 00012 const char CONN_NAME[] = "CONN_HANDLES"; /* handles of vertices in each quad */ 00013 const char VAR_INTS_NAME[] = "VAR_LEN_INTS"; /* variable length tag on nodes */ 00014 const char BIT_NAME[] = "TEST_BIT_TAG"; 00015 const int ENTS_PER_SET = 6; 00016 const int BITS_PER_TAG = 2; 00017 00018 Core* mbcore = 0; 00019 Interface* mb = 0; 00020 Tag order_tag = 0; 00021 00022 const size_t INTERVALS = 6; 00023 00024 /* values for variable-length tag data */ 00025 void tag_vals_from_gid( int global_id, std::vector< int >& values ) 00026 { 00027 int i = global_id / ( INTERVALS + 1 ); 00028 int j = global_id % ( INTERVALS + 1 ); 00029 int n = global_id % 5 + 1; 00030 int vals[] = { i, j, n, i + j, j - 2 * i }; 00031 values.resize( n ); 00032 std::copy( vals, vals + n, values.begin() ); 00033 } 00034 00035 unsigned char bits_from_gid( int global_id ) 00036 { 00037 return global_id % ( 1 << BITS_PER_TAG ); 00038 } 00039 00040 unsigned char order_from_gid( int global_id ) 00041 { 00042 return global_id % 3; 00043 } 00044 00045 void coords_from_gid( int global_id, double coords[3] ) 00046 { 00047 int i = global_id / ( INTERVALS + 1 ); 00048 int j = global_id % ( INTERVALS + 1 ); 00049 coords[0] = i; 00050 coords[1] = j; 00051 coords[2] = 0.1 * ( i + j ); 00052 } 00053 00054 void build_mesh(); 00055 void check_order_by_sets_and_adj(); 00056 void call_reorder(); 00057 void check_order(); 00058 void check_node_coords(); 00059 void check_quad_conn(); 00060 void check_set_meshset(); 00061 void check_list_meshset(); 00062 void check_big_meshset(); 00063 void check_handle_tag(); 00064 void check_varlen_tag(); 00065 void check_bit_tag(); 00066 00067 int main() 00068 { 00069 // Define global MOAB instance for use by all tests 00070 Core mcore; 00071 mbcore = &mcore; 00072 mb = &mcore; 00073 00074 // if this fails, don't bother with anything else 00075 if( RUN_TEST( build_mesh ) ) return 1; 00076 00077 // this test needs be be run before reordering the mesh 00078 int errors = 0; 00079 errors += RUN_TEST( check_order_by_sets_and_adj ); 00080 00081 // if reorder returned failure, don't bother doing anything else 00082 int tmp = RUN_TEST( call_reorder ); 00083 if( tmp ) return tmp + errors; 00084 00085 // test the core stuff 00086 errors += RUN_TEST( check_order ); 00087 errors += RUN_TEST( check_node_coords ); 00088 errors += RUN_TEST( check_quad_conn ); 00089 errors += RUN_TEST( check_set_meshset ); 00090 errors += RUN_TEST( check_list_meshset ); 00091 errors += RUN_TEST( check_big_meshset ); 00092 errors += RUN_TEST( check_handle_tag ); 00093 errors += RUN_TEST( check_varlen_tag ); 00094 errors += RUN_TEST( check_bit_tag ); 00095 return errors; 00096 } 00097 00098 void build_mesh() 00099 { 00100 const unsigned dense = MB_TAG_CREAT | MB_TAG_DENSE; 00101 const unsigned sparse = MB_TAG_CREAT | MB_TAG_SPARSE; 00102 00103 ErrorCode rval; 00104 00105 // get/create various tags 00106 Tag gid; 00107 rval = mb->tag_get_handle( GLOBAL_ID_NAME, 1, MB_TYPE_INTEGER, gid, dense );CHECK_ERR( rval ); 00108 00109 Tag conn_ids; 00110 rval = mb->tag_get_handle( CONN_IDS_NAME, 4, MB_TYPE_INTEGER, conn_ids, dense );CHECK_ERR( rval ); 00111 00112 Tag conn_handles; 00113 rval = mb->tag_get_handle( CONN_NAME, 4, MB_TYPE_HANDLE, conn_handles, dense );CHECK_ERR( rval ); 00114 00115 Tag set_ids; 00116 rval = mb->tag_get_handle( SET_IDS_NAME, ENTS_PER_SET, MB_TYPE_INTEGER, set_ids, sparse );CHECK_ERR( rval ); 00117 00118 Tag set_handles; 00119 rval = mb->tag_get_handle( SET_HANDLES_NAME, ENTS_PER_SET, MB_TYPE_HANDLE, set_handles, sparse );CHECK_ERR( rval ); 00120 00121 Tag var_data; 00122 rval = mb->tag_get_handle( VAR_INTS_NAME, 0, MB_TYPE_INTEGER, var_data, dense | MB_TAG_VARLEN );CHECK_ERR( rval ); 00123 00124 Tag bit_data; 00125 rval = mb->tag_get_handle( BIT_NAME, BITS_PER_TAG, MB_TYPE_BIT, bit_data, MB_TAG_CREAT );CHECK_ERR( rval ); 00126 00127 rval = mb->tag_get_handle( "ORDER", 1, MB_TYPE_INTEGER, order_tag, dense );CHECK_ERR( rval ); 00128 00129 // create and tag vertices 00130 std::vector< int > values; 00131 EntityHandle nodes[( INTERVALS + 1 ) * ( INTERVALS + 1 )]; 00132 for( size_t i = 0; i <= INTERVALS; ++i ) 00133 { 00134 for( size_t j = 0; j <= INTERVALS; ++j ) 00135 { 00136 size_t idx = i * ( INTERVALS + 1 ) + j; 00137 double coords[3]; 00138 coords_from_gid( idx, coords ); 00139 rval = mb->create_vertex( coords, nodes[idx] );CHECK_ERR( rval ); 00140 00141 int tagval = idx; 00142 rval = mb->tag_set_data( gid, nodes + idx, 1, &tagval );CHECK_ERR( rval ); 00143 00144 tag_vals_from_gid( idx, values ); 00145 const void* ptr = &values[0]; 00146 const int size = values.size(); 00147 rval = mb->tag_set_by_ptr( var_data, nodes + idx, 1, &ptr, &size );CHECK_ERR( rval ); 00148 00149 unsigned char bits = bits_from_gid( idx ); 00150 rval = mb->tag_set_data( bit_data, nodes + idx, 1, &bits );CHECK_ERR( rval ); 00151 00152 int group = order_from_gid( idx ); 00153 rval = mb->tag_set_data( order_tag, nodes + idx, 1, &group );CHECK_ERR( rval ); 00154 } 00155 } 00156 00157 // create and tag elements 00158 EntityHandle quads[INTERVALS * INTERVALS]; 00159 for( size_t i = 0; i < INTERVALS; ++i ) 00160 { 00161 for( size_t j = 0; j < INTERVALS; ++j ) 00162 { 00163 size_t idx = i * INTERVALS + j; 00164 size_t n0 = i * ( INTERVALS + 1 ) + j; 00165 size_t n1 = ( i + 1 ) * ( INTERVALS + 1 ) + j; 00166 size_t n2 = ( i + 1 ) * ( INTERVALS + 1 ) + j + 1; 00167 size_t n3 = i * ( INTERVALS + 1 ) + j + 1; 00168 EntityHandle conn[4] = { nodes[n0], nodes[n1], nodes[n2], nodes[n3] }; 00169 EntityHandle h; 00170 rval = mb->create_element( MBQUAD, conn, 4, h );CHECK_ERR( rval ); 00171 00172 int tagval = idx; 00173 rval = mb->tag_set_data( gid, &h, 1, &tagval );CHECK_ERR( rval ); 00174 00175 int ids[4] = { static_cast< int >( n0 ), static_cast< int >( n1 ), static_cast< int >( n2 ), 00176 static_cast< int >( n3 ) }; 00177 rval = mb->tag_set_data( conn_ids, &h, 1, ids );CHECK_ERR( rval ); 00178 00179 rval = mb->tag_set_data( conn_handles, &h, 1, conn );CHECK_ERR( rval ); 00180 00181 int group = order_from_gid( idx ); 00182 rval = mb->tag_set_data( order_tag, &h, 1, &group );CHECK_ERR( rval ); 00183 00184 quads[idx] = h; 00185 } 00186 } 00187 00188 // create a few sets 00189 for( int i = 0; i < 2; ++i ) 00190 { 00191 EntityHandle* from = 0; 00192 size_t count; 00193 unsigned flag; 00194 if( i ) 00195 { 00196 from = nodes; 00197 count = ( INTERVALS + 1 ) * ( INTERVALS + 1 ); 00198 flag = MESHSET_SET; 00199 } 00200 else 00201 { 00202 from = quads; 00203 count = INTERVALS * INTERVALS; 00204 flag = MESHSET_ORDERED; 00205 } 00206 00207 EntityHandle h; 00208 rval = mb->create_meshset( flag | MESHSET_TRACK_OWNER, h );CHECK_ERR( rval ); 00209 00210 EntityHandle ents[ENTS_PER_SET]; 00211 int gids[ENTS_PER_SET]; 00212 for( int j = 0; j < ENTS_PER_SET; ++j ) 00213 { 00214 int idx = j + 2; 00215 idx = ( idx * idx ) % count; 00216 ents[j] = from[idx]; 00217 gids[j] = idx; 00218 } 00219 00220 rval = mb->add_entities( h, ents, ENTS_PER_SET );CHECK_ERR( rval ); 00221 00222 rval = mb->tag_set_data( set_ids, &h, 1, gids );CHECK_ERR( rval ); 00223 00224 rval = mb->tag_set_data( set_handles, &h, 1, ents );CHECK_ERR( rval ); 00225 } 00226 00227 // create a set containing all vertices 00228 EntityHandle allverts; 00229 rval = mb->create_meshset( MESHSET_SET, allverts );CHECK_ERR( rval ); 00230 rval = mb->add_entities( allverts, nodes, ( INTERVALS + 1 ) * ( INTERVALS + 1 ) );CHECK_ERR( rval ); 00231 } 00232 00233 void call_reorder() 00234 { 00235 // do reorder 00236 ReorderTool tool( mbcore ); 00237 Tag mapping; 00238 ErrorCode rval = tool.handle_order_from_int_tag( order_tag, -1, mapping );CHECK_ERR( rval ); 00239 rval = tool.reorder_entities( mapping );CHECK_ERR( rval ); 00240 } 00241 00242 void check_order( EntityType type ) 00243 { 00244 ErrorCode rval; 00245 00246 Tag gid; 00247 rval = mb->tag_get_handle( GLOBAL_ID_NAME, 1, MB_TYPE_INTEGER, gid );CHECK_ERR( rval ); 00248 00249 Range ents; 00250 rval = mb->get_entities_by_type( 0, type, ents );CHECK_ERR( rval ); 00251 00252 std::vector< int > ids( ents.size() ); 00253 rval = mb->tag_get_data( gid, ents, &ids[0] );CHECK_ERR( rval ); 00254 00255 for( size_t i = 1; i < ids.size(); ++i ) 00256 { 00257 CHECK( order_from_gid( ids[i - 1] ) <= order_from_gid( ids[i] ) ); 00258 } 00259 } 00260 00261 void check_order_by_sets_and_adj() 00262 { 00263 ErrorCode rval; 00264 00265 std::vector< EntityHandle > quads; 00266 rval = mb->get_entities_by_dimension( 0, 2, quads );CHECK_ERR( rval ); 00267 CHECK( !quads.empty() ); 00268 00269 // group quads by the ordering assigned in build_mesh() 00270 std::map< int, Range > groups; 00271 std::vector< int > group_ids( quads.size() ); 00272 rval = mb->tag_get_data( order_tag, &quads[0], quads.size(), &group_ids[0] );CHECK_ERR( rval ); 00273 for( size_t i = 0; i < quads.size(); ++i ) 00274 groups[group_ids[i]].insert( quads[i] ); 00275 00276 // create sets from groups 00277 Range sets; 00278 for( std::map< int, Range >::iterator i = groups.begin(); i != groups.end(); ++i ) 00279 { 00280 EntityHandle h; 00281 rval = mb->create_meshset( MESHSET_SET, h );CHECK_ERR( rval ); 00282 rval = mb->add_entities( h, i->second );CHECK_ERR( rval ); 00283 sets.insert( h ); 00284 } 00285 00286 // Get ordering assigned by set containment 00287 Tag neworder = 0; 00288 ReorderTool tool( mbcore ); 00289 rval = tool.handle_order_from_sets_and_adj( sets, neworder );CHECK_ERR( rval ); 00290 00291 // check that new quad handles are clustered as expected 00292 std::vector< std::pair< EntityHandle, EntityHandle > > ranges; 00293 for( std::map< int, Range >::iterator i = groups.begin(); i != groups.end(); ++i ) 00294 { 00295 std::vector< EntityHandle > newh( i->second.size() ); 00296 rval = mb->tag_get_data( neworder, i->second, &newh[0] );CHECK_ERR( rval ); 00297 std::sort( newh.begin(), newh.end() ); 00298 CHECK( newh[0] > 0 ); // zero implies some quad got left out of the reordering 00299 std::pair< EntityHandle, EntityHandle > p( newh[0], newh[newh.size() - 1] ); 00300 ranges.push_back( p ); 00301 } 00302 std::sort( ranges.begin(), ranges.end() ); 00303 for( size_t i = 1; i < ranges.size(); ++i ) 00304 { 00305 CHECK( ranges[i - 1].second < ranges[i].first ); 00306 } 00307 00308 // group vertices as we expect handles to be grouped 00309 std::map< std::vector< int >, Range > vtxgroups; 00310 Range verts; 00311 rval = mb->get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval ); 00312 for( Range::iterator i = verts.begin(); i != verts.end(); ++i ) 00313 { 00314 Range adj; 00315 rval = mb->get_adjacencies( &*i, 1, 2, false, adj );CHECK_ERR( rval ); 00316 std::vector< int > ids( adj.size() ); 00317 rval = mb->tag_get_data( order_tag, adj, &ids[0] );CHECK_ERR( rval ); 00318 std::sort( ids.begin(), ids.end() ); 00319 ids.erase( std::unique( ids.begin(), ids.end() ), ids.end() ); 00320 vtxgroups[ids].insert( *i ); 00321 } 00322 00323 // check that new vertex handles are clustered as expected 00324 ranges.clear(); 00325 std::map< std::vector< int >, Range >::iterator j; 00326 for( j = vtxgroups.begin(); j != vtxgroups.end(); ++j ) 00327 { 00328 std::vector< EntityHandle > newh( j->second.size() ); 00329 rval = mb->tag_get_data( neworder, j->second, &newh[0] );CHECK_ERR( rval ); 00330 std::sort( newh.begin(), newh.end() ); 00331 CHECK( newh[0] > 0 ); // zero implies some quad got left out of the reordering 00332 std::pair< EntityHandle, EntityHandle > p( newh[0], newh[newh.size() - 1] ); 00333 ranges.push_back( p ); 00334 } 00335 std::sort( ranges.begin(), ranges.end() ); 00336 for( size_t i = 1; i < ranges.size(); ++i ) 00337 { 00338 CHECK( ranges[i - 1].second < ranges[i].first ); 00339 } 00340 } 00341 00342 void check_order() 00343 { 00344 check_order( MBVERTEX ); 00345 check_order( MBQUAD ); 00346 } 00347 00348 void check_node_coords() 00349 { 00350 ErrorCode rval; 00351 00352 Tag gid; 00353 rval = mb->tag_get_handle( GLOBAL_ID_NAME, 1, MB_TYPE_INTEGER, gid );CHECK_ERR( rval ); 00354 00355 Range verts; 00356 rval = mb->get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval ); 00357 00358 std::vector< int > ids( verts.size() ); 00359 rval = mb->tag_get_data( gid, verts, &ids[0] );CHECK_ERR( rval ); 00360 00361 std::vector< double > coords( 3 * verts.size() ); 00362 rval = mb->get_coords( verts, &coords[0] );CHECK_ERR( rval ); 00363 00364 std::vector< double > expected( 3 * verts.size() ); 00365 for( size_t i = 0; i < ids.size(); ++i ) 00366 coords_from_gid( ids[i], &expected[3 * i] ); 00367 00368 CHECK_EQUAL( expected, coords ); 00369 } 00370 00371 void check_quad_conn() 00372 { 00373 ErrorCode rval; 00374 00375 Tag gid; 00376 rval = mb->tag_get_handle( GLOBAL_ID_NAME, 1, MB_TYPE_INTEGER, gid );CHECK_ERR( rval ); 00377 00378 Tag conn_ids; 00379 rval = mb->tag_get_handle( CONN_IDS_NAME, 4, MB_TYPE_INTEGER, conn_ids );CHECK_ERR( rval ); 00380 00381 std::vector< EntityHandle > quads; 00382 rval = mb->get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval ); 00383 00384 std::vector< EntityHandle > conn; 00385 rval = mb->get_connectivity( &quads[0], quads.size(), conn, true );CHECK_ERR( rval ); 00386 00387 CHECK_EQUAL( 4 * quads.size(), conn.size() ); 00388 std::vector< int > exp_ids( 4 * quads.size() ), act_ids( 4 * quads.size() ); 00389 rval = mb->tag_get_data( conn_ids, &quads[0], quads.size(), &exp_ids[0] );CHECK_ERR( rval ); 00390 rval = mb->tag_get_data( gid, &conn[0], conn.size(), &act_ids[0] );CHECK_ERR( rval ); 00391 00392 CHECK_EQUAL( exp_ids, act_ids ); 00393 } 00394 00395 void check_meshset_common( bool ordered ) 00396 { 00397 ErrorCode rval; 00398 00399 Tag set_ids; 00400 rval = mb->tag_get_handle( SET_IDS_NAME, ENTS_PER_SET, MB_TYPE_INTEGER, set_ids );CHECK_ERR( rval ); 00401 00402 Tag gid; 00403 rval = mb->tag_get_handle( GLOBAL_ID_NAME, 1, MB_TYPE_INTEGER, gid );CHECK_ERR( rval ); 00404 00405 Range sets; 00406 rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &set_ids, 0, 1, sets );CHECK_ERR( rval ); 00407 CHECK( !sets.empty() ); 00408 00409 EntityHandle set = 0; 00410 unsigned flags; 00411 for( Range::iterator it = sets.begin(); it != sets.end(); ++it ) 00412 { 00413 rval = mb->get_meshset_options( *it, flags );CHECK_ERR( rval ); 00414 if( ( ordered && ( flags & MESHSET_ORDERED ) ) || ( !ordered && !( flags & MESHSET_ORDERED ) ) ) 00415 { 00416 set = *it; 00417 break; 00418 } 00419 } 00420 CHECK( 0 != set ); 00421 00422 std::vector< EntityHandle > ents; 00423 rval = mb->get_entities_by_handle( set, ents );CHECK_ERR( rval ); 00424 CHECK_EQUAL( ENTS_PER_SET, (int)ents.size() ); 00425 00426 int exp[ENTS_PER_SET], act[ENTS_PER_SET]; 00427 rval = mb->tag_get_data( set_ids, &set, 1, exp );CHECK_ERR( rval ); 00428 rval = mb->tag_get_data( gid, &ents[0], ENTS_PER_SET, act );CHECK_ERR( rval ); 00429 00430 if( !ordered ) 00431 { 00432 std::sort( exp, exp + ENTS_PER_SET ); 00433 std::sort( act, act + ENTS_PER_SET ); 00434 } 00435 00436 CHECK_ARRAYS_EQUAL( exp, ENTS_PER_SET, act, ENTS_PER_SET ); 00437 00438 if( !( flags & MESHSET_TRACK_OWNER ) ) return; 00439 00440 for( int i = 0; i < ENTS_PER_SET; ++i ) 00441 { 00442 std::vector< EntityHandle > adj; 00443 rval = mb->get_adjacencies( &ents[i], 1, 4, false, adj );CHECK_ERR( rval ); 00444 CHECK( std::find( adj.begin(), adj.end(), set ) != adj.end() ); 00445 } 00446 } 00447 00448 void check_set_meshset() 00449 { 00450 check_meshset_common( false ); 00451 } 00452 00453 void check_list_meshset() 00454 { 00455 check_meshset_common( true ); 00456 } 00457 00458 void check_big_meshset() 00459 { 00460 // Mesh should have a single set that contains all the vertices. 00461 // Find it. 00462 Range sets; 00463 ErrorCode rval = mb->get_entities_by_type( 0, MBENTITYSET, sets );CHECK_ERR( rval ); 00464 00465 Range verts; 00466 rval = mb->get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval ); 00467 00468 bool found = false; 00469 for( Range::iterator it = sets.begin(); it != sets.end(); ++it ) 00470 { 00471 Range ents; 00472 rval = mb->get_entities_by_handle( *it, ents );CHECK_ERR( rval ); 00473 if( ents == verts ) 00474 { 00475 found = true; 00476 break; 00477 } 00478 } 00479 CHECK( found ); 00480 } 00481 00482 void check_handle_tag() 00483 { 00484 Range::iterator it; 00485 ErrorCode rval; 00486 00487 // first check tag on sets, for which the values should have been 00488 // updated according to the reordering 00489 00490 Tag set_handles; 00491 rval = mb->tag_get_handle( SET_HANDLES_NAME, ENTS_PER_SET, MB_TYPE_HANDLE, set_handles );CHECK_ERR( rval ); 00492 00493 Range sets; 00494 rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &set_handles, 0, 1, sets );CHECK_ERR( rval ); 00495 CHECK( !sets.empty() ); 00496 00497 for( it = sets.begin(); it != sets.end(); ++it ) 00498 { 00499 std::vector< EntityHandle > ents; 00500 rval = mb->get_entities_by_handle( *it, ents );CHECK_ERR( rval ); 00501 00502 std::vector< EntityHandle > handles( ENTS_PER_SET ); 00503 rval = mb->tag_get_data( set_handles, &*it, 1, &handles[0] );CHECK_ERR( rval ); 00504 00505 unsigned flags; 00506 rval = mb->get_meshset_options( *it, flags );CHECK_ERR( rval ); 00507 if( !( flags & MESHSET_ORDERED ) ) std::sort( handles.begin(), handles.end() ); 00508 00509 CHECK_EQUAL( ents, handles ); 00510 } 00511 00512 // Now check handle tag on quads. This tag need to both be re-ordered 00513 // and have the contained handles updated. 00514 00515 Tag conn_handles; 00516 rval = mb->tag_get_handle( CONN_NAME, 4, MB_TYPE_HANDLE, conn_handles );CHECK_ERR( rval ); 00517 00518 std::vector< EntityHandle > quads; 00519 rval = mb->get_entities_by_type( 0, MBQUAD, quads );CHECK_ERR( rval ); 00520 00521 std::vector< EntityHandle > conn; 00522 rval = mb->get_connectivity( &quads[0], quads.size(), conn, true );CHECK_ERR( rval ); 00523 00524 std::vector< EntityHandle > tagvals( 4 * quads.size() ); 00525 rval = mb->tag_get_data( conn_handles, &quads[0], quads.size(), &tagvals[0] );CHECK_ERR( rval ); 00526 00527 CHECK_EQUAL( conn, tagvals ); 00528 } 00529 00530 void check_varlen_tag() 00531 { 00532 ErrorCode rval; 00533 00534 Tag gid; 00535 rval = mb->tag_get_handle( GLOBAL_ID_NAME, 1, MB_TYPE_INTEGER, gid );CHECK_ERR( rval ); 00536 00537 Tag var_data; 00538 rval = mb->tag_get_handle( VAR_INTS_NAME, 0, MB_TYPE_INTEGER, var_data );CHECK_ERR( rval ); 00539 00540 Range verts; 00541 rval = mb->get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval ); 00542 00543 std::vector< int > gids( verts.size() ); 00544 rval = mb->tag_get_data( gid, verts, &gids[0] );CHECK_ERR( rval ); 00545 00546 std::vector< const void* > ptrs( verts.size() ); 00547 std::vector< int > sizes( verts.size() ); 00548 rval = mb->tag_get_by_ptr( var_data, verts, &ptrs[0], &sizes[0] );CHECK_ERR( rval ); 00549 00550 for( size_t i = 0; i < gids.size(); ++i ) 00551 { 00552 std::vector< int > exp; 00553 tag_vals_from_gid( gids[i], exp ); 00554 CHECK_ARRAYS_EQUAL( &exp[0], exp.size(), (const int*)ptrs[i], sizes[i] ); 00555 } 00556 } 00557 00558 void check_bit_tag() 00559 { 00560 ErrorCode rval; 00561 00562 Tag gid; 00563 rval = mb->tag_get_handle( GLOBAL_ID_NAME, 1, MB_TYPE_INTEGER, gid );CHECK_ERR( rval ); 00564 00565 Tag bit_data; 00566 rval = mb->tag_get_handle( BIT_NAME, BITS_PER_TAG, MB_TYPE_BIT, bit_data );CHECK_ERR( rval ); 00567 00568 Range verts; 00569 rval = mb->get_entities_by_type( 0, MBVERTEX, verts );CHECK_ERR( rval ); 00570 00571 std::vector< int > gids( verts.size() ); 00572 rval = mb->tag_get_data( gid, verts, &gids[0] );CHECK_ERR( rval ); 00573 00574 std::vector< unsigned char > exp( gids.size() ), act( gids.size() ); 00575 for( size_t i = 0; i < exp.size(); ++i ) 00576 exp[i] = bits_from_gid( gids[i] ); 00577 00578 rval = mb->tag_get_data( bit_data, verts, &act[0] );CHECK_ERR( rval ); 00579 00580 CHECK_EQUAL( exp, act ); 00581 }