19 #pragma warning( disable : 4786 )
22 #define MOAB_MPE_LOG "moab.mpe"
72 #ifdef MOAB_HAVE_HDF5_PARALLEL
75 #define DefaultWriterName "WriteHDF5Parallel"
79 #define DefaultWriterName "WriteHDF5"
81 #elif defined( MOAB_HAVE_NETCDF )
84 #define DefaultWriterName "WriteNCDF"
88 #define DefaultWriterName "WriteVtk"
114 #define ALLOW_NULL_FOR_MESH_TAG
119 #undef DISALLOW_EMPTY_HANDLE_LIST_FOR_TAGS
127 std::cerr <<
"WARNING: Accepting empty array to indicate mesh tag" << std::endl;
130 #ifdef ALLOW_NULL_FOR_MESH_TAG
131 #define CHECK_MESH_NULL \
132 EntityHandle root = 0; \
133 if( NULL == entity_handles && 0 == num_entities ) \
135 entity_handles = &root; \
137 warn_null_array_mesh_tag(); \
139 #elif defined( DISALLOW_EMPTY_HANDLE_LIST_FOR_TAGS )
140 #define CHECK_MESH_NULL \
141 if( NULL == entity_handles ) \
143 std::cerr << "ERROR: Deprecated NULL handle list at " __FILE__ ":" << __LINE__ << std::endl; \
147 #define CHECK_MESH_NULL
159 return reinterpret_cast< const MeshSetSequence*
>( seq )->get_set( h );
174 printf(
"Error initializing moab::Core\n" );
182 if( mMBWriteUtil )
delete mMBWriteUtil;
183 if( mMBReadUtil )
delete mMBReadUtil;
184 if( scdInterface )
delete scdInterface;
197 if( MPI_SUCCESS == MPI_Initialized( &flag ) )
207 initErrorHandlerInCore =
false;
211 initErrorHandlerInCore =
true;
214 geometricDimension = 3;
218 geomDimensionTag = 0;
227 mError =
new( std::nothrow )
Error;
244 geom_dimension_tag();
250 mesh_modified =
false;
265 std::vector< ParallelComm* > pc_list;
267 for( std::vector< ParallelComm* >::iterator vit = pc_list.begin(); vit != pc_list.end(); ++vit )
276 if( aEntityFactory )
delete aEntityFactory;
280 while( !tagList.empty() )
281 tag_delete( tagList.front() );
283 if( sequenceManager )
delete sequenceManager;
287 delete readerWriterSet;
290 if( mError )
delete mError;
297 const char* logfile = getenv(
"MPE_LOG_FILE" );
298 if( !logfile ) logfile = default_log;
310 if( !mMBReadUtil ) mMBReadUtil =
new ReadUtil(
this, mError );
315 if( !mMBWriteUtil ) mMBWriteUtil =
new WriteUtil(
this );
320 ptr = reader_writer_set();
322 else if( interface_type ==
typeid(
Error ) )
332 if( !scdInterface ) scdInterface =
new ScdInterface(
this );
396 ErrorCode error_code = sequence_manager()->find( handle, dummy_seq );
413 return load_file( file_name, 0, 0, name, block_id_list, num_blocks );
418 const char* setoptions,
419 const char* set_tag_name,
420 const int* set_tag_vals,
421 int num_set_tag_vals )
428 assert( !file_set || ( *file_set && is_valid( *file_set ) ) );
429 if( file_set && !*file_set )
431 MB_SET_GLB_ERR( MB_FAILURE,
"Non-NULL file set pointer should point to non-NULL set" );
435 std::string parallel_opt;
436 rval = opts.
get_option(
"PARALLEL", parallel_opt );
451 if( set_tag_name && num_set_tag_vals )
460 MB_SET_GLB_ERR( MB_FAILURE,
"PARALLEL option not valid, this instance compiled for serial execution" );
465 if( set_tag_name && num_set_tag_vals )
467 rval = serial_load_file( file_name, file_set, opts, &sl );
MB_CHK_ERR( rval );
471 rval = serial_load_file( file_name, file_set, opts );
MB_CHK_ERR( rval );
494 get_entities_by_handle( 0, new_ents );
495 new_ents =
subtract( new_ents, initial_ents );
496 delete_entities( new_ents );
498 std::vector< Tag > all_tags, new_tags;
499 tag_get_tags( all_tags );
500 std::sort( initial_tags.begin(), initial_tags.end() );
501 std::sort( all_tags.begin(), all_tags.end() );
502 std::set_difference( all_tags.begin(), all_tags.end(), initial_tags.begin(), initial_tags.end(),
503 std::back_inserter( new_tags ) );
504 while( !new_tags.empty() )
506 tag_delete( new_tags.back() );
518 #if defined( WIN32 ) || defined( WIN64 ) || defined( MSC_VER )
519 struct _stat stat_data;
520 status = _stat( file_name, &stat_data );
522 struct stat stat_data;
523 status = stat( file_name, &stat_data );
529 #if defined( WIN32 ) || defined( WIN64 ) || defined( MSC_VER )
530 else if( stat_data.st_mode & _S_IFDIR )
533 else if( S_ISDIR( stat_data.st_mode ) )
544 std::vector< Tag > initial_tags;
545 rval = tag_get_tags( initial_tags );
MB_CHK_ERR( rval );
553 bool tried_one =
false;
554 for( iter = set->
begin(); iter != set->
end(); ++iter )
556 if( !iter->reads_extension( ext.c_str() ) )
continue;
562 rval = reader->
load_file( file_name, file_set, opts, subsets, id_tag );
565 clean_up_failed_read( initial_ents, initial_tags );
572 for( iter = set->
begin(); iter != set->
end(); ++iter )
575 if( !reader )
continue;
576 rval = reader->
load_file( file_name, file_set, opts, subsets, id_tag );
581 clean_up_failed_read( initial_ents, initial_tags );
587 clean_up_failed_read( initial_ents, initial_tags );
588 MB_SET_ERR( rval,
"Failed to load file after trying all possible readers" );
593 get_entities_by_handle( 0, new_ents );
594 new_ents =
subtract( new_ents, initial_ents );
598 rval = mMBReadUtil->get_gather_set( gather_set );
602 new_ents.
erase( gather_set );
606 rval = get_entities_by_handle( gather_set, gather_ents );
610 rval = add_entities( *file_set, new_ents );
617 const char* tag_name,
619 std::vector< int >& vals,
629 rval = reader->
read_tag_values( file_name, tag_name, opts, vals, subsets );
636 for( iter = set->
begin(); iter != set->
end(); ++iter )
638 reader = iter->make_reader(
this );
641 rval = reader->
read_tag_values( file_name, tag_name, opts, vals, subsets );
653 return write_file( file_name, 0, 0, output_list, num_sets );
657 const char* file_type,
658 const char* options_string,
665 std::copy( output_sets, output_sets + num_output_sets,
range_inserter( range ) );
666 return write_file( file_name, file_type, options_string, range, tag_list, num_tags );
670 const char* file_type,
671 const char* options_string,
672 const Range& output_sets,
677 std::vector< EntityHandle > list( output_sets.
size() );
678 std::copy( output_sets.
begin(), output_sets.
end(), list.begin() );
687 MB_SET_GLB_ERR( MB_FAILURE,
"Unexpected value for CREATE option" );
693 std::vector< std::string > qa_records;
702 if( ( file_type && !i->name().compare( file_type ) ) || i->writes_extension( ext.c_str() ) )
709 writer->
write_file( file_name, overwrite, opts, list_ptr, list.
size(), qa_records, tag_list, num_tags );
712 printf(
"Writer with name %s for file %s using extension %s (file type \"%s\") was "
714 i->name().c_str(), file_name, ext.c_str(), file_type );
720 MB_SET_ERR( rval,
"Unrecognized file type \"" << file_type <<
"\"" );
726 printf(
"Using default writer %s for file %s \n",
DefaultWriterName, file_name );
727 rval = writer.
write_file( file_name, overwrite, opts, list_ptr, list.
size(), qa_records, tag_list, num_tags );
753 if( aEntityFactory )
delete aEntityFactory;
756 for( std::list< TagInfo* >::iterator i = tagList.begin(); i != tagList.end(); ++i )
758 result = ( *i )->release_all_data( sequenceManager, mError,
false );
MB_CHK_ERR( result );
761 sequenceManager->clear();
769 dim = geometricDimension;
780 if( geometricDimension <
dim )
784 get_number_entities_by_dimension( 0, geometricDimension, num );
794 geometricDimension =
dim;
809 int num_verts = vertices.
size();
812 coords.resize( geometricDimension * num_verts );
815 result = get_coords( &( *it ), 1, xyz );
MB_CHK_ERR( result );
817 coords[vec_pos] = xyz[0];
818 coords[num_verts + vec_pos] = xyz[1];
819 coords[2 * num_verts + vec_pos] = xyz[2];
829 double*& xcoords_ptr,
830 double*& ycoords_ptr,
831 double*& zcoords_ptr,
835 ErrorCode rval = sequence_manager()->find( *iter, seq );
838 xcoords_ptr = ycoords_ptr = zcoords_ptr = NULL;
839 MB_SET_ERR( rval,
"Couldn't find sequence for start handle" );
853 if( *end ) real_end = std::min( real_end, *end );
854 count = real_end - *iter + 1;
877 count = i->second -
first + 1;
887 double const *x, *y, *z;
892 for(
EntityID j = 0; j < count; ++j )
894 coords[3 * j] = x[j];
895 coords[3 * j + 1] = y[j];
896 coords[3 * j + 2] = z[j];
898 coords = &coords[3 * count];
905 rval = get_coords( &( *rit ), 1, coords );
MB_CHK_ERR( rval );
931 count = i->second -
first + 1;
941 double const *x, *y, *z;
945 memcpy( x_coords, x + offset, count *
sizeof(
double ) );
950 memcpy( y_coords, y + offset, count *
sizeof(
double ) );
955 memcpy( z_coords, z + offset, count *
sizeof(
double ) );
965 rval = get_coords( &( *rit ), 1, xyz );
MB_CHK_ERR( rval );
966 *x_coords++ = xyz[0];
967 *y_coords++ = xyz[1];
968 *z_coords++ = xyz[2];
988 seq = sequence_manager()->get_last_accessed_sequence(
MBVERTEX );
1005 static int num_conn;
1006 status = get_connectivity( *iter, conn, num_conn,
false, &dum_conn );
MB_CHK_ERR( status );
1007 status = get_coords( conn, num_conn, &dum_pos[0] );
MB_CHK_ERR( status );
1008 coords[0] = coords[1] = coords[2] = 0.0;
1009 for(
int i = 0; i < num_conn; i++ )
1011 coords[0] += dum_pos[3 * i];
1012 coords[1] += dum_pos[3 * i + 1];
1013 coords[2] += dum_pos[3 * i + 2];
1015 coords[0] /= num_conn;
1016 coords[1] /= num_conn;
1017 coords[2] /= num_conn;
1029 const double*& z )
const
1036 status = sequence_manager()->find( entity_handle, seq );
1040 status =
static_cast< const VertexSequence*
>( seq )->get_coordinates_ref( entity_handle, x, y, z );
1055 for( i = 0; i < num_entities; i++ )
1060 status = sequence_manager()->find( entity_handles[i], seq );
1064 status =
static_cast< VertexSequence*
>( seq )->set_coordinates( entity_handles[i], coords[j],
1065 coords[j + 1], coords[j + 2] );
1090 status = sequence_manager()->find( *rit, seq );
1094 status =
static_cast< VertexSequence*
>( seq )->set_coordinates( *rit, coords[j], coords[j + 1],
1108 return sequenceManager->get_sequence_multiplier();
1113 assert( factor >= 1.0 );
1114 sequenceManager->set_sequence_multiplier( factor );
1126 ErrorCode result = get_entities_by_type( 0, entity_type, this_range );
1128 int num_ents = this_range.
size();
1135 result = get_connectivity( *this_it, connect_vec, num_ents,
true );
MB_CHK_ERR( result );
1136 connect.insert( connect.end(), &connect_vec[0], &connect_vec[num_ents] );
1144 const int num_handles,
1145 Range& connectivity,
1146 bool corners_only )
const
1148 std::vector< EntityHandle > tmp_connect;
1149 ErrorCode result = get_connectivity( entity_handles, num_handles, tmp_connect, corners_only );
MB_CHK_ERR( result );
1151 std::sort( tmp_connect.begin(), tmp_connect.end() );
1152 std::copy( tmp_connect.rbegin(), tmp_connect.rend(),
range_inserter( connectivity ) );
1158 const int num_handles,
1159 std::vector< EntityHandle >& connectivity,
1161 std::vector< int >* offsets )
const
1163 connectivity.clear();
1168 std::vector< EntityHandle > tmp_storage;
1171 if( offsets ) offsets->push_back( 0 );
1172 for(
int i = 0; i < num_handles; ++i )
1174 rval = get_connectivity( entity_handles[i], conn, len, corners_only, &tmp_storage );
MB_CHK_ERR( rval );
1175 connectivity.insert( connectivity.end(), conn, conn + len );
1176 if( offsets ) offsets->push_back( connectivity.size() );
1186 std::vector< EntityHandle >* storage )
const
1194 if( entity_type < MBVERTEX || entity_type >=
MBENTITYSET )
1206 status = sequence_manager()->find( entity_handle, seq );
1209 return static_cast< const ElementSequence*
>( seq )->get_connectivity( entity_handle, connectivity, number_nodes,
1210 corners_only, storage );
1226 status = sequence_manager()->find( entity_handle, seq );
1233 aEntityFactory->notify_change_connectivity( entity_handle, old_conn, connect, num_connect );
1235 status =
static_cast< ElementSequence*
>( seq )->set_connectivity( entity_handle, connect, num_connect );
1237 aEntityFactory->notify_change_connectivity( entity_handle, connect, old_conn, num_connect );
1242 template <
typename ITER >
1247 bool create_if_missing,
1248 Range& adj_entities )
1250 const size_t DEFAULT_MAX_BLOCKS_SIZE = 4000;
1251 const size_t MAX_OUTER_ITERATIONS = 100;
1253 std::vector< EntityHandle > temp_vec, storage;
1254 std::vector< EntityHandle >::const_iterator ti;
1262 size_t remaining = end - begin;
1263 assert( begin + remaining == end );
1268 const size_t block_size = std::max( DEFAULT_MAX_BLOCKS_SIZE, remaining / MAX_OUTER_ITERATIONS );
1269 while( remaining > 0 )
1271 const size_t count = remaining > block_size ? block_size : remaining;
1274 for(
size_t j = 0; j < count; ++i, ++j )
1278 temp_vec.push_back( *i );
1282 tmp_result =
gMB->get_connectivity( *i, conn, conn_len,
false, &storage );
1285 result = tmp_result;
1288 temp_vec.insert( temp_vec.end(), conn, conn + conn_len );
1292 tmp_result =
gMB->a_entity_factory()->get_adjacencies( *i, to_dimension, create_if_missing, temp_vec );
1295 result = tmp_result;
1301 std::sort( temp_vec.begin(), temp_vec.end() );
1302 ins = adj_entities.
begin();
1303 ti = temp_vec.begin();
1304 while( ti != temp_vec.end() )
1308 for( ++ti; ti != temp_vec.end() && ( *ti - second <= 1 ); ++ti )
1316 template <
typename ITER >
1320 const int to_dimension,
1321 const bool create_if_missing,
1322 std::vector< EntityHandle >& adj_entities )
1324 const size_t SORT_THRESHOLD = 200;
1325 std::vector< EntityHandle > temp_vec;
1326 std::vector< EntityHandle >::iterator adj_it, w_it;
1331 adj_entities.clear();
1338 if( adj_entities.empty() )
1342 adj_entities.push_back( *begin );
1343 else if( to_dimension == 0 && entity_type !=
MBPOLYHEDRON )
1345 result =
mb->get_connectivity( &( *begin ), 1, adj_entities );
MB_CHK_ERR( result );
1349 result =
mb->a_entity_factory()->get_adjacencies( *begin, to_dimension, create_if_missing, adj_entities );
MB_CHK_ERR( result );
1354 for( ITER from_it = begin; from_it != end; ++from_it )
1362 temp_vec.push_back( *from_it );
1363 else if( to_dimension == 0 && entity_type !=
MBPOLYHEDRON )
1365 result =
mb->get_connectivity( &( *from_it ), 1, temp_vec );
MB_CHK_ERR( result );
1369 result =
mb->a_entity_factory()->get_adjacencies( *from_it, to_dimension, create_if_missing, temp_vec );
MB_CHK_ERR( result );
1373 w_it = adj_it = adj_entities.begin();
1374 if( temp_vec.size() * adj_entities.size() < SORT_THRESHOLD )
1376 for( ; adj_it != adj_entities.end(); ++adj_it )
1377 if( std::find( temp_vec.begin(), temp_vec.end(), *adj_it ) != temp_vec.end() )
1385 std::sort( temp_vec.begin(), temp_vec.end() );
1386 for( ; adj_it != adj_entities.end(); ++adj_it )
1387 if( std::binary_search( temp_vec.begin(), temp_vec.end(), *adj_it ) )
1393 adj_entities.erase( w_it, adj_entities.end() );
1396 if( adj_entities.empty() )
break;
1402 template <
typename ITER >
1406 const int to_dimension,
1407 const bool create_if_missing,
1408 Range& adj_entities )
1410 std::vector< EntityHandle > results;
1413 if( adj_entities.
empty() )
1415 std::copy( results.begin(), results.end(),
range_inserter( adj_entities ) );
1420 while( it != adj_entities.
end() )
1422 if( std::find( results.begin(), results.end(), *it ) == results.end() )
1423 it = adj_entities.
erase( it );
1432 #ifdef MOAB_HAVE_AHF
1434 template <
typename ITER >
1435 static inline ErrorCode get_adjacencies_intersection_ahf( Core*
mb,
1438 const int to_dimension,
1439 std::vector< EntityHandle >& adj_entities )
1441 const size_t SORT_THRESHOLD = 200;
1442 std::vector< EntityHandle > temp_vec;
1443 std::vector< EntityHandle >::iterator adj_it, w_it;
1448 adj_entities.clear();
1455 if( adj_entities.empty() )
1460 result =
mb->get_connectivity( &( *begin ), 1, adj_entities );
1462 result =
mb->a_half_facet_rep()->get_adjacencies( *begin, to_dimension, adj_entities );
1467 for( ITER from_it = begin; from_it != end; ++from_it )
1475 result =
mb->get_connectivity( &( *from_it ), 1, temp_vec );
1477 result =
mb->a_half_facet_rep()->get_adjacencies( *from_it, to_dimension, temp_vec );
1481 w_it = adj_it = adj_entities.begin();
1482 if( temp_vec.size() * adj_entities.size() < SORT_THRESHOLD )
1484 for( ; adj_it != adj_entities.end(); ++adj_it )
1485 if( std::find( temp_vec.begin(), temp_vec.end(), *adj_it ) != temp_vec.end() )
1493 std::sort( temp_vec.begin(), temp_vec.end() );
1494 for( ; adj_it != adj_entities.end(); ++adj_it )
1495 if( std::binary_search( temp_vec.begin(), temp_vec.end(), *adj_it ) )
1501 adj_entities.erase( w_it, adj_entities.end() );
1504 if( adj_entities.empty() )
break;
1514 const int num_entities,
1515 const int to_dimension,
1516 const bool create_if_missing,
1517 std::vector< EntityHandle >& adj_entities,
1518 const int operation_type )
1521 #ifdef MOAB_HAVE_AHF
1522 bool can_handle =
true;
1524 if( to_dimension == 4 )
1526 else if( create_if_missing )
1529 bool mixed = ahfRep->check_mixed_entity_type();
1531 if( mixed ) can_handle =
false;
1540 return get_adjacencies_intersection_ahf(
this, from_entities, from_entities + num_entities, to_dimension,
1547 std::vector< EntityHandle > tmp_storage;
1550 for(
int i = 0; i < num_entities; ++i )
1554 result = get_connectivity( from_entities[i], conn, len,
false, &tmp_storage );
1555 adj_entities.insert( adj_entities.end(), conn, conn + len );
1560 result = ahfRep->get_adjacencies( from_entities[i], to_dimension, adj_entities );
1564 std::sort( adj_entities.begin(), adj_entities.end() );
1565 adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
1574 create_if_missing, adj_entities );
1580 std::vector< EntityHandle > tmp_storage;
1583 for(
int i = 0; i < num_entities; ++i )
1587 result = get_connectivity( from_entities[i], conn, len,
false, &tmp_storage );
MB_CHK_ERR( result );
1588 adj_entities.insert( adj_entities.end(), conn, conn + len );
1593 aEntityFactory->get_adjacencies( from_entities[i], to_dimension, create_if_missing, adj_entities );
MB_CHK_ERR( result );
1596 std::sort( adj_entities.begin(), adj_entities.end() );
1597 adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
1601 #ifdef MOAB_HAVE_AHF
1609 const int num_entities,
1610 const int to_dimension,
1611 const bool create_if_missing,
1612 Range& adj_entities,
1613 const int operation_type )
1617 create_if_missing, adj_entities );
1620 create_if_missing, adj_entities );
1627 const size_t DEFAULT_MAX_BLOCKS_SIZE = 4000;
1628 const size_t MAX_OUTER_ITERATIONS = 100;
1630 std::vector< EntityHandle > temp_vec, storage;
1631 std::vector< EntityHandle >::const_iterator ti;
1639 size_t remaining = from_entities.
size();
1642 adj_entities.
merge( from_entities.
begin(), i );
1647 const size_t block_size = std::max( DEFAULT_MAX_BLOCKS_SIZE, remaining / MAX_OUTER_ITERATIONS );
1648 while( remaining > 0 )
1650 const size_t count = remaining > block_size ? block_size : remaining;
1653 for(
size_t j = 0; j < count; ++i, ++j )
1655 tmp_result = get_connectivity( *i, conn, conn_len, corners_only, &storage );
1658 result = tmp_result;
1662 const size_t oldsize = temp_vec.size();
1663 temp_vec.resize( oldsize + conn_len );
1664 memcpy( &temp_vec[oldsize], conn,
sizeof(
EntityHandle ) * conn_len );
1667 std::sort( temp_vec.begin(), temp_vec.end() );
1668 ins = adj_entities.
begin();
1669 ti = temp_vec.begin();
1670 while( ti != temp_vec.end() )
1674 for( ++ti; ti != temp_vec.end() && ( *ti - second <= 1 ); ++ti )
1685 int& verts_per_entity,
1698 ErrorCode rval = sequence_manager()->find( *iter, seq );
1702 assert( eseq != NULL );
1707 MB_SET_ERR( MB_FAILURE,
"Couldn't find connectivity array for start handle" );
1713 if( *end ) real_end = std::min( real_end, *end );
1714 count = real_end - *iter + 1;
1734 rval = get_connectivity( polygons, range );
MB_CHK_ERR( rval );
1737 if( vertices.
empty() )
1738 vertices.
swap( range );
1740 vertices.
merge( range );
1745 const int to_dimension,
1746 const bool create_if_missing,
1747 Range& adj_entities,
1748 const int operation_type )
1752 create_if_missing, adj_entities );
1755 else if( to_dimension == 0 )
1756 return get_vertices( from_entities, adj_entities );
1764 const int num_handles,
1769 for(
const EntityHandle* it = adjacencies; it != adjacencies + num_handles; it++ )
1771 result = aEntityFactory->add_adjacency( entity_handle, *it, both_ways );
MB_CHK_ERR( result );
1781 for(
Range::iterator rit = adjacencies.begin(); rit != adjacencies.end(); ++rit )
1783 result = aEntityFactory->add_adjacency( entity_handle, *rit, both_ways );
MB_CHK_ERR( result );
1791 const int num_handles )
1795 for(
const EntityHandle* it = adjacencies; it != adjacencies + num_handles; it++ )
1797 result = aEntityFactory->remove_adjacency( entity_handle, *it );
MB_CHK_ERR( result );
1798 result = aEntityFactory->remove_adjacency( *it, entity_handle );
MB_CHK_ERR( result );
1806 const std::vector< EntityHandle >**& adjs_ptr,
1819 ErrorCode rval = sequence_manager()->find( *iter, seq );
1823 if( !adjs_ptr )
return rval;
1828 if( *end ) real_end = std::min( real_end, *end );
1829 count = real_end - *iter + 1;
1835 const int dimension,
1837 const bool recursive )
const
1843 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
1847 else if( dimension > 3 )
1856 sequence_manager()->get_entities( this_type,
entities );
1864 const int dimension,
1865 std::vector< EntityHandle >&
entities,
1866 const bool recursive )
const
1872 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
1876 else if( dimension > 3 )
1885 sequence_manager()->get_entities( this_type,
entities );
1893 const EntityType entity_type,
1895 const bool recursive )
const
1901 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
1907 sequence_manager()->get_entities( entity_type,
entities );
1914 const EntityType entity_type,
1915 std::vector< EntityHandle >&
entities,
1916 const bool recursive )
const
1922 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
1928 sequence_manager()->get_entities( entity_type,
entities );
1935 const EntityType entity_type,
1937 const void*
const* values,
1940 const int condition,
1941 const bool recursive )
const
1946 result = get_entities_by_type( meshset, entity_type, range, recursive );
MB_CHK_ERR( result );
1952 for(
int it = 0; it < num_tags && !range.
empty(); it++ )
1961 if( NULL == values || NULL == values[it] )
1971 if( tags[it]->equals_default_value( values[it] ) )
1973 Range all_tagged, untagged;
1982 range.
swap( tmp_range );
1998 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
2006 sequence_manager()->get_entities( entity_type,
entities );
2013 std::vector< EntityHandle >&
entities,
2014 const bool recursive )
const
2017 if( recursive || !meshset )
2020 result = get_entities_by_handle( meshset, tmp_range, recursive );
2023 std::copy( tmp_range.
begin(), tmp_range.
end(),
entities.begin() + offset );
2028 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
2039 const bool recursive )
const
2049 number += sequence_manager()->get_number_entities( this_type );
2055 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
2065 const EntityType entity_type,
2067 const bool recursive )
const
2077 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
2079 result = mseq->
num_type( sequence_manager(), meshset, entity_type, num_ent, recursive );
MB_CHK_ERR( result );
2083 num_ent = sequence_manager()->get_number_entities( entity_type );
2090 const EntityType entity_type,
2091 const Tag* tag_handles,
2092 const void*
const* values,
2096 const bool recursive )
const
2099 ErrorCode result = get_entities_by_type_and_tag( meshset, entity_type, tag_handles, values, num_tags, dum_ents,
2100 condition, recursive );
2101 num_entities = dum_ents.
size();
2111 result = sequence_manager()->find( meshset, seq );
MB_CHK_ERR( result );
2113 return mseq->
num_entities( sequence_manager(), meshset, num_ent, recursive );
2120 result = get_number_entities_by_type( 0, this_type, dummy );
2136 void* tag_data )
const
2138 assert( valid_tag_handle( tag_handle ) );
2140 return tag_handle->
get_data( sequenceManager, mError, entity_handles, num_entities, tag_data );
2146 assert( valid_tag_handle( tag_handle ) );
2147 return tag_handle->
get_data( sequenceManager, mError, entity_handles, tag_data );
2154 const void* tag_data )
2156 assert( valid_tag_handle( tag_handle ) );
2158 return tag_handle->
set_data( sequenceManager, mError, entity_handles, num_entities, tag_data );
2164 assert( valid_tag_handle( tag_handle ) );
2165 return tag_handle->
set_data( sequenceManager, mError, entity_handles, tag_data );
2172 const void** tag_data,
2173 int* tag_sizes )
const
2175 assert( valid_tag_handle( tag_handle ) );
2178 tag_handle->
get_data( sequenceManager, mError, entity_handles, num_entities, tag_data, tag_sizes );
2180 if( tag_sizes && typesize != 1 )
2181 for(
int i = 0; i < num_entities; ++i )
2182 tag_sizes[i] /= typesize;
2188 const Range& entity_handles,
2189 const void** tag_data,
2190 int* tag_sizes )
const
2192 assert( valid_tag_handle( tag_handle ) );
2193 ErrorCode result = tag_handle->
get_data( sequenceManager, mError, entity_handles, tag_data, tag_sizes );
2195 if( tag_sizes && typesize != 1 )
2197 int num_entities = entity_handles.
size();
2198 for(
int i = 0; i < num_entities; ++i )
2199 tag_sizes[i] /= typesize;
2208 void const*
const* tag_data,
2209 const int* tag_sizes )
2211 assert( valid_tag_handle( tag_handle ) );
2213 std::vector< int > tmp_sizes;
2215 if( typesize != 1 && tag_sizes )
2217 tmp_sizes.resize( num_entities );
2218 for(
int i = 0; i < num_entities; ++i )
2219 tmp_sizes[i] = tag_sizes[i] * typesize;
2220 tag_sizes = &tmp_sizes[0];
2222 return tag_handle->
set_data( sequenceManager, mError, entity_handles, num_entities, tag_data, tag_sizes );
2227 const Range& entity_handles,
2228 void const*
const* tag_data,
2229 const int* tag_sizes )
2231 assert( valid_tag_handle( tag_handle ) );
2232 std::vector< int > tmp_sizes;
2234 if( typesize != 1 && tag_sizes )
2236 int num_entities = entity_handles.
size();
2237 tmp_sizes.resize( num_entities );
2238 for(
int i = 0; i < num_entities; ++i )
2239 tmp_sizes[i] = tag_sizes[i] * typesize;
2240 tag_sizes = &tmp_sizes[0];
2242 return tag_handle->
set_data( sequenceManager, mError, entity_handles, tag_data, tag_sizes );
2249 const void* tag_data,
2252 assert( valid_tag_handle( tag_handle ) );
2254 return tag_handle->
clear_data( sequenceManager, mError, entity_handles, num_entities, tag_data,
2261 assert( valid_tag_handle( tag_handle ) );
2262 return tag_handle->
clear_data( sequenceManager, mError, entity_handles, tag_data,
2268 const char* iter =
reinterpret_cast< const char*
>( mem );
2269 const char*
const end = iter +
size;
2270 for( ; iter != end; ++iter )
2271 if( *iter )
return false;
2280 const void* default_value,
2283 if( created ) *created =
false;
2304 for( std::list< Tag >::iterator i = tagList.begin(); i != tagList.end(); ++i )
2306 if( ( *i )->get_name() == name )
2323 if( extype != data_type )
2355 if( default_value && !( flags & MB_TAG_DFTOK ) &&
2391 tag_handle =
new SparseTag( name,
size, data_type, default_value );
2397 tag_handle =
new MeshTag( name,
size, data_type, default_value,
size );
2409 if( created ) *created =
true;
2410 tagList.push_back( tag_handle );
2419 const void* default_value )
const
2432 for( std::list< Tag >::const_iterator i = tagList.begin(); i != tagList.end(); ++i )
2434 if( ( *i )->get_name() == name )
2444 return const_cast< Core*
>( this )->tag_get_handle( name,
size, data_type, tag_handle,
2451 assert( valid_tag_handle( tag_handle ) );
2453 return tag_handle->
remove_data( sequenceManager, mError, entity_handles, num_entities );
2459 assert( valid_tag_handle( tag_handle ) );
2460 return tag_handle->
remove_data( sequenceManager, mError, entity_handles );
2466 std::list< TagInfo* >::iterator i = std::find( tagList.begin(), tagList.end(), tag_handle );
2484 assert( valid_tag_handle( tag_handle ) );
2485 ErrorCode result = tag_handle->
tag_iterate( sequenceManager, mError, iter, end, data_ptr, allocate );
2486 if(
MB_SUCCESS == result ) count = iter - init;
2577 assert( valid_tag_handle( tag_handle ) );
2585 std::copy( tagList.begin(), tagList.end(), std::back_inserter( tag_handles ) );
2592 for( std::list< TagInfo* >::const_iterator i = tagList.begin(); i != tagList.end(); ++i )
2593 if( ( *i )->is_tagged( sequenceManager, entity ) ) tag_handles.push_back( *i );
2599 const int negone = -1;
2600 if( 0 == materialTag )
2607 const int negone = -1;
2608 if( 0 == neumannBCTag )
2610 return neumannBCTag;
2615 const int negone = -1;
2616 if( 0 == dirichletBCTag )
2619 return dirichletBCTag;
2624 const int negone = -1;
2625 if( 0 == globalIdTag )
2632 const int negone = -1;
2633 if( 0 == geomDimensionTag )
2636 return geomDimensionTag;
2642 const int num_nodes,
2648 ErrorCode status = sequence_manager()->create_element( entity_type, connectivity, num_nodes, handle );
2649 if(
MB_SUCCESS == status ) status = aEntityFactory->notify_create_entity( handle, connectivity, num_nodes );
2651 #ifdef MOAB_HAVE_AHF
2652 mesh_modified =
true;
2662 return sequence_manager()->create_vertex( coords, handle );
2671 std::vector< double* > arrays;
2676 for(
int i = 0; i < nverts; i++ )
2678 arrays[0][i] = coordinates[3 * i];
2679 arrays[1][i] = coordinates[3 * i + 1];
2680 arrays[2][i] = coordinates[3 * i + 2];
2683 entity_handles.
clear();
2684 entity_handles.
insert( start_handle_out, start_handle_out + nverts - 1 );
2693 bool delete_removed_entity )
2695 if( auto_merge )
return MB_FAILURE;
2698 if( entity_to_keep == entity_to_remove )
return MB_FAILURE;
2708 status = sequence_manager()->find( entity_to_keep, seq );
2710 status = sequence_manager()->find( entity_to_remove, seq );
2718 std::vector< EntityHandle > conn, conn2;
2720 result = get_connectivity( &entity_to_keep, 1, conn );
MB_CHK_ERR( result );
2721 result = get_connectivity( &entity_to_remove, 1, conn2 );
MB_CHK_ERR( result );
2726 ( conn.size() != conn2.size() || !
CN::ConnectivityMatch( &conn[0], &conn2[0], conn.size(), dum1, dum2 ) ) )
2730 result = aEntityFactory->merge_adjust_adjacencies( entity_to_keep, entity_to_remove );
2732 if(
MB_SUCCESS == result && delete_removed_entity ) result = delete_entities( &entity_to_remove, 1 );
2743 for( std::list< TagInfo* >::iterator i = tagList.begin(); i != tagList.end(); ++i )
2745 temp_result = ( *i )->remove_data( sequenceManager, mError, range );
2754 temp_result = aEntityFactory->notify_delete_entity( *rit );
2757 result = temp_result;
2758 failed_ents.
insert( *rit );
2768 ptr->clear( *rit, a_entity_factory() );
2769 rel = ptr->get_parents( count );
2770 for( j = 0; j < count; ++j )
2771 remove_child_meshset( rel[j], *rit );
2772 rel = ptr->get_children( count );
2773 for( j = 0; j < count; ++j )
2774 remove_parent_meshset( rel[j], *rit );
2779 if( !failed_ents.
empty() )
2783 sequence_manager()->delete_entities( mError, dum_range );
2787 result = sequence_manager()->delete_entities( mError, range );
2798 for( std::list< TagInfo* >::iterator i = tagList.begin(); i != tagList.end(); ++i )
2800 temp_result = ( *i )->remove_data( sequenceManager, mError,
entities, num_entities );
2805 for(
int i = 0; i < num_entities; i++ )
2809 bool failed =
false;
2810 temp_result = aEntityFactory->notify_delete_entity(
entities[i] );
2813 result = temp_result;
2824 rel = ptr->get_parents( count );
2825 for( j = 0; j < count; ++j )
2826 remove_child_meshset( rel[j],
entities[i] );
2827 rel = ptr->get_children( count );
2828 for( j = 0; j < count; ++j )
2829 remove_parent_meshset( rel[j],
entities[i] );
2835 sequence_manager()->delete_entity( mError,
entities[i] );
2839 temp_result = sequence_manager()->delete_entity( mError,
entities[i] );
2840 if(
MB_SUCCESS != temp_result ) result = temp_result;
2851 if( NULL ==
entities && num_entities == 0 )
2855 std::cout << std::endl;
2856 std::cout <<
"Number of entities per type: " << std::endl;
2859 result = get_number_entities_by_type( 0, this_type, num_ents );
2862 std::cout << std::endl;
2866 else if( NULL ==
entities && num_entities < 0 )
2870 std::cout << std::endl;
2873 result = get_entities_by_type( 0, this_type, temp_range );
2876 return list_entities( temp_range );
2878 else if( NULL ==
entities && num_entities > 0 )
2882 std::cout << std::endl;
2883 result = get_entities_by_type( 0, (EntityType)num_entities, temp_range );
2885 return list_entities( temp_range );
2890 for(
int i = 0; i < num_entities; i++ )
2895 tmp_result = (
const_cast< Core*
>( this ) )->list_entity(
entities[i] );
2896 if(
MB_SUCCESS != tmp_result ) result = tmp_result;
2912 tmp_result = (
const_cast< Core*
>( this ) )->list_entity( *rit );
2913 if(
MB_SUCCESS != tmp_result ) result = tmp_result;
2924 if( !is_valid( entity ) )
2926 std::cout <<
"(invalid)" << std::endl;
2930 if( 0 != globalIdTag )
2933 result = tag_get_data( globalIdTag, &entity, 1, &
dum );
2934 if(
MB_SUCCESS == result ) std::cout <<
"Global id = " <<
dum << std::endl;
2942 result = get_coords( &( entity ), 1, coords );
MB_CHK_ERR( result );
2943 std::cout <<
"Coordinates: (" << coords[0] <<
", " << coords[1] <<
", " << coords[2] <<
")" << std::endl;
2946 this->print( entity,
"" );
2948 std::cout <<
" Adjacencies:" << std::endl;
2957 result = (
const_cast< Core*
>( this ) )->get_adjacencies( &( entity ), 1,
dim,
false, adj_vec );
2958 if( MB_FAILURE == result )
continue;
2959 for( HandleVec::iterator adj_it = adj_vec.begin(); adj_it != adj_vec.end(); ++adj_it )
2961 if( adj_it != adj_vec.begin() )
2967 if( !adj_vec.empty() )
2969 std::cout << std::endl;
2974 if( !some ) std::cout <<
"(none)" << std::endl;
2977 aEntityFactory->get_adjacencies( entity, explicit_adjs, num_exp );
2978 if( NULL != explicit_adjs && 0 != num_exp )
2980 std::cout <<
" Explicit adjacencies: ";
2981 for(
int i = 0; i < num_exp; i++ )
2983 if( i != 0 ) std::cout <<
", ";
2987 std::cout << std::endl;
2989 if( multiple != 0 ) std::cout <<
" (MULTIPLE = " << multiple <<
")" << std::endl;
2991 result = print_entity_tags( std::string(), entity,
MB_TAG_DENSE );
2993 std::cout << std::endl;
2999 const bool mid_side,
3000 const bool mid_face,
3001 const bool mid_volume,
3005 return fact.
convert( meshset, mid_side, mid_face, mid_volume );
3018 const EntityHandle *parent_conn = NULL, *child_conn = NULL;
3019 int num_parent_vertices = 0, num_child_vertices = 0;
3020 ErrorCode result = get_connectivity( parent, parent_conn, num_parent_vertices,
true );
3024 result = get_connectivity( parent, parent_conn, num_parent_vertices,
true, &tmp_connect );
3030 int child_index = std::find( parent_conn, parent_conn + num_parent_vertices,
child ) - parent_conn;
3031 if( child_index == num_parent_vertices )
3039 sd_number = child_index;
3049 for(
int i = 0; i < num_parent_vertices; i++ )
3050 if(
child == parent_conn[i] )
3059 result = get_connectivity(
child, child_conn, num_child_vertices,
true );
MB_CHK_ERR( result );
3066 int child_conn_indices[10];
3067 assert( (
unsigned)num_child_vertices <=
sizeof( child_conn_indices ) /
sizeof( child_conn_indices[0] ) );
3068 for(
int i = 0; i < num_child_vertices; ++i )
3070 child_conn_indices[i] =
3071 std::find( parent_conn, parent_conn + num_parent_vertices, child_conn[i] ) - parent_conn;
3072 if( child_conn_indices[i] >= num_parent_vertices )
3081 return ( 0 == temp_result ?
MB_SUCCESS : MB_FAILURE );
3086 const EntityHandle* first_v = std::find( parent_conn, parent_conn + num_parent_vertices, child_conn[0] );
3088 sd_number = first_v - parent_conn;
3109 int actual_num_parent_vertices = num_parent_vertices;
3110 while( actual_num_parent_vertices >= 3 &&
3111 ( parent_conn[actual_num_parent_vertices - 2] == parent_conn[actual_num_parent_vertices - 1] ) )
3112 actual_num_parent_vertices--;
3114 if( parent_conn[( sd_number + 1 ) % num_parent_vertices] == child_conn[1] )
3116 else if( parent_conn[( sd_number + num_parent_vertices - 1 ) % num_parent_vertices] ==
3121 else if( ( sd_number == actual_num_parent_vertices - 1 ) && ( child_conn[1] == parent_conn[0] ) )
3136 const EntityType subfacet_type,
3145 int num_parent_vertices = 0;
3146 ErrorCode result = get_connectivity( parent_handle, parent_conn, num_parent_vertices,
false );
MB_CHK_ERR( result );
3171 if( subfacet_type != parent_type )
3176 int subfacet_indices[10];
3177 assert( subfacet_size <=
sizeof( subfacet_indices ) /
sizeof( subfacet_indices[0] ) );
3178 for(
unsigned j = 0; j < subfacet_size; ++j )
3180 subfacet_indices[j] =
3181 std::find( parent_conn, parent_conn + num_parent_vertices, subfacet_conn[j] ) - parent_conn;
3182 if( subfacet_indices[j] >= num_parent_vertices )
3188 int dum, side_no, temp_offset;
3190 CN::SideNumber( parent_type, subfacet_indices, subfacet_size, subfacet_type, side_no,
dum, temp_offset );
3191 if( temp_result != 0 )
return MB_FAILURE;
3199 hon = parent_conn[offset];
3207 const int sd_number,
3213 ErrorCode result = get_connectivity( source_entity, verts, num_verts );
MB_CHK_ERR( result );
3218 if( sd_number < num_verts )
3220 target_entity = verts[sd_number];
3229 Range side_verts, target_ents;
3232 std::vector< int > vertex_indices;
3235 if( 0 != temp_result )
return MB_FAILURE;
3237 for(
unsigned int i = 0; i < vertex_indices.size(); i++ )
3238 side_verts.
insert( verts[vertex_indices[i]] );
3243 result = (
const_cast< Core*
>( this ) )->get_adjacencies( side_verts,
dim,
false, target_ents );
3251 if( !target_ents.
empty() ) target_entity = *( target_ents.
begin() );
3260 return sequence_manager()->create_mesh_set( setoptions, ms_handle );
3274 setoptions = set->
flags();
3283 return set->
set_flags( setoptions, ms_handle, a_entity_factory() );
3289 for(
int i = 0; i < num_meshsets; ++i )
3293 set->
clear( ms_handles[i], a_entity_factory() );
3308 set->
clear( *i, a_entity_factory() );
3322 return set1->
subtract( set2, meshset1, a_entity_factory() );
3331 return set1->
intersect( set2, meshset1, a_entity_factory() );
3340 return set1->
unite( set2, meshset1, a_entity_factory() );
3385 const int operation_type )
3390 return set->contains_entities(
entities, num_entities, operation_type );
3403 return set->
replace_entities( meshset, old_entities, new_entities, num_entities, a_entity_factory() );
3409 std::vector< EntityHandle >& parents,
3410 const int num_hops )
const
3415 ErrorCode rval = sequence_manager()->find( meshset, seq );
3419 return mseq->
get_parents( sequence_manager(), meshset, parents, num_hops );
3426 std::vector< EntityHandle > parent_vec;
3427 ErrorCode result = get_parent_meshsets( meshset, parent_vec, num_hops );
MB_CHK_ERR( result );
3428 std::sort( parent_vec.begin(), parent_vec.end() );
3429 std::copy( parent_vec.rbegin(), parent_vec.rend(),
range_inserter( parents ) );
3434 std::vector< EntityHandle >&
children,
3435 const int num_hops )
const
3440 ErrorCode rval = sequence_manager()->find( meshset, seq );
3451 std::vector< EntityHandle > child_vec;
3452 ErrorCode result = get_child_meshsets( meshset, child_vec, num_hops );
MB_CHK_ERR( result );
3453 std::sort( child_vec.begin(), child_vec.end() );
3459 std::vector< EntityHandle >&
children,
3460 const int num_hops )
const
3468 ErrorCode rval = sequence_manager()->find( meshset, seq );
3482 std::vector< EntityHandle > child_vec;
3483 ErrorCode result = get_contained_meshsets( meshset, child_vec, num_hops );
MB_CHK_ERR( result );
3484 std::sort( child_vec.begin(), child_vec.end() );
3494 ErrorCode rval = sequence_manager()->find( meshset, seq );
3498 return mseq->
num_parents( sequence_manager(), meshset, *number, num_hops );
3506 ErrorCode rval = sequence_manager()->find( meshset, seq );
3510 return mseq->
num_children( sequence_manager(), meshset, *number, num_hops );
3517 return get_number_entities_by_type( 0,
MBENTITYSET, *number );
3521 ErrorCode rval = sequence_manager()->find( meshset, seq );
3543 for(
int i = 0; i < count; ++i )
3546 for(
int i = 0; i < count; ++i )
3566 for(
int i = 0; i < count; ++i )
3569 for(
int i = 0; i < count; ++i )
3620 return (
unsigned)code <= (unsigned)MB_FAILURE ? ErrorCodeStr[code] :
"INVALID ERROR CODE";
3628 if( 0 != ms_handle )
3630 get_entities_by_handle( ms_handle,
entities );
3631 std::cout << prefix <<
"MBENTITYSET " <<
ID_FROM_HANDLE( ms_handle ) << std::endl;
3635 get_entities_by_dimension( 0, 3,
entities );
3638 get_entities_by_dimension( 0, 0,
entities );
3640 std::cout << prefix <<
"--: " << std::endl;
3643 std::string indent_prefix = prefix;
3644 indent_prefix +=
" ";
3645 entities.print( indent_prefix.c_str() );
3647 if( !first_call || !ms_handle )
return;
3651 this->get_parent_meshsets( ms_handle, temp );
3652 std::cout <<
" Parent sets: ";
3654 std::cout <<
"(none)" << std::endl;
3659 if( rit != temp.
begin() ) std::cout <<
", ";
3662 std::cout << std::endl;
3666 this->get_child_meshsets( ms_handle, temp );
3667 std::cout <<
" Child sets: ";
3669 std::cout <<
"(none)" << std::endl;
3674 if( rit != temp.
begin() ) std::cout <<
", ";
3677 std::cout << std::endl;
3681 print_entity_tags( indent_prefix, ms_handle,
MB_TAG_SPARSE );
3686 std::vector< Tag > set_tags;
3687 ErrorCode result = this->tag_get_tags_on_entity( handle, set_tags );
3688 std::cout << indent_prefix << ( tp ==
MB_TAG_SPARSE ?
"Sparse tags:" :
"Dense tags:" ) << std::endl;
3689 indent_prefix +=
" ";
3691 for( std::vector< Tag >::iterator vit = set_tags.begin(); vit != set_tags.end(); ++vit )
3694 result = this->tag_get_type( *vit, this_type );
3695 if(
MB_SUCCESS != result || tp != this_type )
continue;
3697 result = this->tag_get_data_type( *vit, this_data_type );
3700 result = this->tag_get_length( *vit, this_size );
3703 std::vector< double > dbl_vals( this_size );
3704 std::vector< int > int_vals( this_size );
3705 std::vector< EntityHandle > hdl_vals( this_size );
3706 std::string tag_name;
3707 result = this->tag_get_name( *vit, tag_name );
3709 switch( this_data_type )
3712 result = this->tag_get_data( *vit, &handle, 1, &int_vals[0] );
3714 std::cout << indent_prefix << tag_name <<
" = ";
3715 if( this_size < 10 )
3716 for(
int i = 0; i < this_size; i++ )
3717 std::cout << int_vals[i] <<
" ";
3719 std::cout << int_vals[0] <<
"... (mult values)";
3720 std::cout << std::endl;
3723 result = this->tag_get_data( *vit, &handle, 1, &dbl_vals[0] );
3725 std::cout << indent_prefix << tag_name <<
" = ";
3726 if( this_size < 10 )
3727 for(
int i = 0; i < this_size; i++ )
3728 std::cout << dbl_vals[i] <<
" ";
3730 std::cout << dbl_vals[0] <<
"... (mult values)";
3731 std::cout << std::endl;
3734 result = this->tag_get_data( *vit, &handle, 1, &hdl_vals[0] );
3736 std::cout << indent_prefix << tag_name <<
" = ";
3737 if( this_size < 10 )
3738 for(
int i = 0; i < this_size; i++ )
3739 std::cout << hdl_vals[i] <<
" ";
3741 std::cout << hdl_vals[0] <<
"... (mult values)";
3742 std::cout << std::endl;
3748 result = this->tag_get_data( *vit, &handle, 1, &dum_tag );
3752 std::cout << indent_prefix << tag_name <<
" = " << dum_tag << std::endl;
3771 result = check_adjacencies( &( *rit ), 1 );
MB_CHK_ERR( result );
3781 std::ostringstream oss;
3783 for(
int i = 0; i < num_ents; i++ )
3786 std::ostringstream ent_str;
3788 int this_dim = dimension_from_handle( this_ent );
3790 if( !is_valid( this_ent ) )
3792 std::cerr << ent_str.str() <<
"Not a valid entity." << std::endl;
3793 result = MB_FAILURE;
3804 if(
dim == this_dim )
continue;
3808 oss << ent_str.str() <<
"Failed to get adjacencies for dimension " <<
dim <<
"." << std::endl;
3809 result = tmp_result;
3812 if( !oss.str().empty() )
3814 std::cerr << oss.str();
3822 tmp_result = sequence_manager()->find( *rit, seq );
3827 result = tmp_result;
3832 tmp_result = get_adjacencies( &( *rit ), 1, this_dim,
false, rev_adjs );
3835 oss << ent_str.str() <<
"Failed to get reverse adjacency from "
3838 oss <<
" (MULTIPLE)" << std::endl;
3840 oss <<
" (" << tmp_result <<
")" << std::endl;
3841 result = tmp_result;
3843 else if( rev_adjs.
find( this_ent ) == rev_adjs.
end() )
3845 oss << ent_str.str() <<
"Failed to find adjacency to this entity from "
3848 result = tmp_result;
3851 if( !oss.str().empty() )
3853 std::cerr << oss.str();
3866 ErrorCode result = sequence_manager()->find( this_ent, seq );
3871 EntityType ent_type,
3878 unsigned int setoptions;
3882 rval = get_meshset_options( meshset, setoptions );
MB_CHK_ERR( rval );
3886 set_iter =
new( std::nothrow )
RangeSetIterator(
this, meshset, chunk_size, ent_type, ent_dim, check_valid );
3888 set_iter =
new( std::nothrow )
VectorSetIterator(
this, meshset, chunk_size, ent_type, ent_dim, check_valid );
3890 setIterators.push_back( set_iter );
3901 std::vector< SetIterator* >::iterator vit = std::find( setIterators.begin(), setIterators.end(), set_iter );
3902 if( vit == setIterators.end() )
3904 MB_SET_ERR( MB_FAILURE,
"Didn't find that iterator" );
3907 setIterators.erase( vit );
3918 for( std::vector< SetIterator* >::const_iterator vit = setIterators.begin(); vit != setIterators.end(); ++vit )
3919 if( ( *vit )->ent_set() == meshset ) set_iters.push_back( *vit );
3930 const Tag* tag_array,
3936 type_memstorage i_entity_storage, ia_entity_storage, i_adjacency_storage, ia_adjacency_storage, i_tag_storage,
3938 type_memstorage *total_tag_storage = 0, *amortized_total_tag_storage = 0;
3941 total_tag_storage = tag_storage;
3942 amortized_total_tag_storage = amortized_tag_storage;
3944 if( total_storage || total_amortized_storage )
3946 if( !entity_storage ) entity_storage = &i_entity_storage;
3947 if( !amortized_entity_storage ) amortized_entity_storage = &ia_entity_storage;
3948 if( !adjacency_storage ) adjacency_storage = &i_adjacency_storage;
3949 if( !amortized_adjacency_storage ) amortized_adjacency_storage = &ia_adjacency_storage;
3953 if( entity_storage || amortized_entity_storage )
3955 if( !amortized_entity_storage )
3956 amortized_entity_storage = &ia_entity_storage;
3957 else if( !entity_storage )
3958 entity_storage = &i_entity_storage;
3960 if( adjacency_storage || amortized_adjacency_storage )
3962 if( !amortized_adjacency_storage )
3963 amortized_adjacency_storage = &ia_adjacency_storage;
3964 else if( !adjacency_storage )
3965 adjacency_storage = &i_adjacency_storage;
3968 if( !total_tag_storage && total_storage ) total_tag_storage = &i_tag_storage;
3969 if( !amortized_total_tag_storage && total_amortized_storage ) amortized_total_tag_storage = &ia_tag_storage;
3972 if( amortized_entity_storage )
3975 sequenceManager->get_memory_use( *ents, *entity_storage, *amortized_entity_storage );
3977 sequenceManager->get_memory_use( *entity_storage, *amortized_entity_storage );
3981 if( amortized_adjacency_storage )
3984 aEntityFactory->get_memory_use( *ents, *adjacency_storage, *amortized_adjacency_storage );
3986 #ifdef MOAB_HAVE_AHF
3987 ahfRep->get_memory_use( *adjacency_storage, *amortized_adjacency_storage );
3989 aEntityFactory->get_memory_use( *adjacency_storage, *amortized_adjacency_storage );
3996 for(
unsigned i = 0; i < num_tags; ++i )
3998 if( !valid_tag_handle( tag_array[i] ) )
continue;
4000 unsigned long total = 0, per_ent = 0;
4005 size_t count = 0, count2 = 0;
4007 if( tag_storage ) tag_storage[i] = count * per_ent;
4008 if( amortized_tag_storage )
4012 amortized_tag_storage[i] =
static_cast< type_memstorage >( total * count * 1.0 / count2 );
4021 tag_storage[i] = count * per_ent;
4023 if( amortized_tag_storage ) amortized_tag_storage[i] = total;
4029 if( total_tag_storage || amortized_total_tag_storage )
4031 if( amortized_total_tag_storage ) *amortized_total_tag_storage = 0;
4032 if( total_tag_storage ) *total_tag_storage = 0;
4034 std::vector< Tag > tags;
4035 tag_get_tags( tags );
4036 for( std::list< TagInfo* >::const_iterator i = tagList.begin(); i != tagList.end(); ++i )
4038 unsigned long total = 0, per_ent = 0;
4039 ( *i )->get_memory_use( sequenceManager, total, per_ent );
4043 size_t count = 0, count2 = 0;
4044 ( *i )->num_tagged_entities( sequenceManager, count,
MBMAXTYPE, ents );
4045 if( total_tag_storage ) *total_tag_storage += count * per_ent;
4046 if( amortized_total_tag_storage )
4048 ( *i )->num_tagged_entities( sequenceManager, count2 );
4050 *amortized_total_tag_storage +=
static_cast< type_memstorage >( total * count * 1.0 / count2 );
4056 if( total_tag_storage )
4058 ( *i )->num_tagged_entities( sequenceManager, count );
4059 *total_tag_storage += count * per_ent;
4061 if( amortized_total_tag_storage ) *amortized_total_tag_storage += total;
4067 if( total_storage ) *total_storage = *entity_storage + *adjacency_storage + *total_tag_storage;
4069 if( total_amortized_storage )
4070 *total_amortized_storage =
4071 *amortized_entity_storage + *amortized_adjacency_storage + *amortized_total_tag_storage;
4075 unsigned long num_ents,
4082 const Tag* tag_array,
4094 std::vector< EntityHandle > list( num_ents );
4095 std::copy( ent_array, ent_array + num_ents, list.begin() );
4096 std::sort( list.begin(), list.end() );
4098 for( std::vector< EntityHandle >::reverse_iterator i = list.rbegin(); i != list.rend(); ++i )
4099 j = range.
insert( j, *i, *i );
4103 std::copy( ent_array, ent_array + num_ents,
range_inserter( range ) );
4107 estimated_memory_use_internal( ent_array ? &range : 0, total_storage, total_amortized_storage, entity_storage,
4108 amortized_entity_storage, adjacency_storage, amortized_adjacency_storage, tag_array,
4109 num_tags, tag_storage, amortized_tag_storage );
4119 const Tag* tag_array,
4124 estimated_memory_use_internal( &ents, total_storage, total_amortized_storage, entity_storage,
4125 amortized_entity_storage, adjacency_storage, amortized_adjacency_storage, tag_array,
4126 num_tags, tag_storage, amortized_tag_storage );
4134 if( !verts.
empty() )
4135 printf(
" Vertex ID X Y Z Adjacencies \n"
4136 " ---------- -------- -------- -------- -----------...\n" );
4139 for( i = verts.
begin(); i != verts.
end(); ++i )
4151 printf(
" %10d %8g %8g %8g", (
int)
ID_FROM_HANDLE( h ), c[0], c[1], c[2] );
4153 printf(
" %10d < ERROR %4d >", (
int)
ID_FROM_HANDLE( h ), (
int)rval );
4155 rval = a_entity_factory()->get_adjacencies( h, adj, nadj );
4158 printf(
" <ERROR %d>\n", (
int)rval );
4162 for(
int j = 0; j < nadj; ++j )
4178 if( elems.
empty() )
continue;
4181 for( i = elems.
begin(); i != elems.
end(); ++i )
4184 if( n > clen ) clen = n;
4188 if( clen < (
int)strlen(
"Connectivity" ) ) clen = strlen(
"Connectivity" );
4189 std::vector< char >
dashes( clen,
'-' );
4190 dashes.push_back(
'\0' );
4191 printf(
" %7s ID %-*s Adjacencies\n",
CN::EntityTypeName( t ), clen,
"Connectivity" );
4192 printf(
" ---------- %s -----------...\n", &
dashes[0] );
4194 std::vector< EntityHandle > storage;
4197 for( i = elems.
begin(); i != elems.
end(); ++i )
4207 rval = get_connectivity( h, conn, nconn,
false, &storage );
4209 printf(
" <ERROR %2d>%*s", (
int)rval, clen - 10,
"" );
4212 for(
int j = 0; j < nconn; ++j )
4214 printf(
"%*s", clen - 5 * nconn,
"" );
4217 rval = a_entity_factory()->get_adjacencies( h, adj, nadj );
4220 printf(
" <ERROR %d>\n", (
int)rval );
4224 for(
int j = 0; j < nadj; ++j )
4241 EntityType entity_type,
4250 if( !scdInterface ) scdInterface =
new ScdInterface(
this );
4252 ErrorCode rval = scdInterface->create_scd_sequence( coord_min, coord_max, entity_type,
4253 (
int)start_id_hint, newBox );
MB_CHK_ERR( rval );
4256 first_handle_out = newBox->
get_vertex( coord_min );
4258 first_handle_out = newBox->
get_element( coord_min );
4259 return sequence_manager()->find( first_handle_out, sequence_out );
4274 return sequence_manager()->add_vsequence( vert_seq, elem_seq, p1, q1, p2, q2, p3, q3, bb_input, bb_min, bb_max );