31 : mbImpl( impl ), readMeshIface( NULL ), nativeParallel( false ), myPcomm( NULL ), mGlobalIdTag( 0 ), dU()
58 if( use_mpio && !parallel )
74 const Tag* file_id_tag )
86 DMSLmodel_create(
sizeof(
EntityHandle ) == 8 ? DAMSEL_HANDLE_TYPE_HANDLE64 : DAMSEL_HANDLE_TYPE_HANDLE32 );
90 MPI_Comm comm = MPI_COMM_WORLD;
98 err = DMSLmodel_attach(
dU.
dmslModel, filename, comm, NULL );
104 int num_containers = 0, num_tag_infos = 0, num_ent_infos = 0;
105 DMSLmodel_get_tuple_count(
dU.
dmslModel, &num_containers, &num_tag_infos );
106 num_ent_infos = DMSLmodel_get_entity_count(
dU.
dmslModel );
107 int num_coll_infos = DMSLmodel_get_collection_count(
dU.
dmslModel );
108 CHK_DMSL_ERR( err,
"DMSLmodel_get_collection_count failed" );
109 if( -1 == num_containers || -1 == num_tag_infos || -1 == num_ent_infos )
110 MB_SET_ERR( MB_FAILURE,
"Bad count for containers/tags/ents" );
112 std::vector< damsel_entity_buf_type > ent_infos( num_ent_infos );
113 std::vector< damsel_collection_buf_type > coll_infos( num_coll_infos );
114 std::vector< damsel_tag_buf_type > tag_infos( num_tag_infos );
115 std::vector< damsel_container_buf_type > cont_infos( num_containers );
116 err = DMSLmodel_get_entity_infos(
dU.
dmslModel, &ent_infos[0] );
118 err = DMSLmodel_get_collection_infos(
dU.
dmslModel, &coll_infos[0] );
119 CHK_DMSL_ERR( err,
"Failure getting collection infos" );
120 err = DMSLmodel_get_tag_infos(
dU.
dmslModel, &tag_infos[0] );
122 err = DMSLmodel_get_container_infos(
dU.
dmslModel, &cont_infos[0] );
188 std::vector< damsel_entity_buf_type >::iterator eiit;
191 for( eiit = ent_infos.begin(); eiit != ent_infos.end(); ++eiit )
193 if( ( *eiit ).entity_type == DAMSEL_ENTITY_TYPE_VERTEX )
199 for( eiit = ent_infos.begin(); eiit != ent_infos.end(); ++eiit )
201 if( ( *eiit ).entity_type != DAMSEL_ENTITY_TYPE_VERTEX )
252 const char* tag_name,
254 std::vector< int >& tag_values_out,
264 for( std::vector< damsel_tag_buf_type >::iterator tit = tag_infos.begin(); tit != tag_infos.end(); ++tit )
268 std::cout <<
"Damsel reader encountered opaque tag." << std::endl;
280 if( !strncmp( ( *tit ).name,
"mbdmsl_", 7 ) )
283 if( !strcmp( ( *tit ).name,
"mbdmsl_XCOORDS" ) )
285 else if( !strcmp( ( *tit ).name,
"mbdmsl_YCOORDS" ) )
289 else if( !strcmp( ( *tit ).name,
"mbdmsl_ZCOORDS" ) )
293 else if( !strcmp( ( *tit ).name,
"mbdmsl_COLL_FLAGS" ) )
297 else if( !strcmp( ( *tit ).name,
"mbdmsl_PARENTS" ) )
301 else if( !strcmp( ( *tit ).name,
"mbdmsl_CHILDREN" ) )
323 damsel_container app_cont;
331 if(
MB_SUCCESS != rval || fside_handles.
size() != einfo.count || fside_handles.
psize() != 1 )
return MB_FAILURE;
334 if( einfo.entity_type != DAMSEL_ENTITY_TYPE_VERTEX )
340 these_ents.
insert( start_handle, start_handle + einfo.count - 1 );
343 app_cont = DMSLcontainer_create_sequence(
dU.
dmslModel, einfo.count, start_handle, 1 );
344 err = DMSLmodel_map_handles( app_cont, einfo.entity_container );
345 CHK_DMSL_ERR( err,
"Error returned mapping entity handles" );
348 assert( DMSLcontainer_count( einfo.vertex_container ) == (
int)( einfo.vertices_per_entity * einfo.count ) );
355 damsel_handle xcoord_dtag = DMSLselect_tag_by_name(
dU.
dmslModel,
"mbdmsl_XCOORDS" );
356 if( xcoord_dtag ) num_ctags++;
357 damsel_handle ycoord_dtag = DMSLselect_tag_by_name(
dU.
dmslModel,
"mbdmsl_YCOORDS" );
358 if( ycoord_dtag ) num_ctags++;
359 damsel_handle zcoord_dtag = DMSLselect_tag_by_name(
dU.
dmslModel,
"mbdmsl_ZCOORDS" );
360 if( zcoord_dtag ) num_ctags++;
363 assert( einfo.vertices_per_entity == 1 );
364 std::vector< double* > coord_arrays;
367 these_ents.
insert( start_handle, start_handle + einfo.count - 1 );
370 app_cont = DMSLcontainer_create_sequence(
dU.
dmslModel, start_handle, einfo.count, 1 );
371 err = DMSLmodel_map_handles( app_cont, einfo.entity_container );
375 if( xcoord_dtag != 0 )
377 err = DMSLmodel_map_tag( coord_arrays[0], app_cont, (damsel_handle_ptr)&
dU.
xcoordsTag.
mTagh );
378 CHK_DMSL_ERR( err,
"Trouble mapping x coordinate tag" );
380 if( ycoord_dtag != 0 )
382 err = DMSLmodel_map_tag( coord_arrays[1], app_cont, (damsel_handle_ptr)&
dU.
ycoordsTag.
mTagh );
383 CHK_DMSL_ERR( err,
"Trouble mapping y coordinate tag" );
385 if( zcoord_dtag != 0 )
387 err = DMSLmodel_map_tag( coord_arrays[2], app_cont, (damsel_handle_ptr)&
dU.
zcoordsTag.
mTagh );
388 CHK_DMSL_ERR( err,
"Trouble mapping z coordinate tag" );
393 dmHandleRMap.
insert( DMSLcontainer_handle_at_position( einfo.entity_container, 0 ), start_handle, einfo.count );
395 rval =
process_entity_tags( einfo.tag_count, einfo.tag_handle_container, app_cont, these_ents );
401 damsel_container tag_container,
402 damsel_container app_cont,
407 for(
int i = 0; i < count; i++ )
409 damsel_handle dtagh = DMSLcontainer_handle_at_position( tag_container, i );
412 std::vector< DamselUtil::tinfo >::iterator vit =
418 MB_SET_ERR( MB_FAILURE,
"Failed to find tag" );
420 Tag tagh = ( *vit ).mTagh;
423 int ecount = these_ents.
size();
425 assert( ecount == (
int)these_ents.
size() );
426 damsel_err_t err = DMSLmodel_map_tag( tag_data, app_cont, (damsel_handle_ptr)&tagh );
427 CHK_DMSL_ERR( err,
"Problem calling DMSLmodel_map_tag" );
436 if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE )
439 size_t count, stride;
440 damsel_err_t err = DMSLcontainer_sequence_get_contents( m, c, &start, &count, &stride );
441 CHK_DMSL_ERR( err,
"DMSLcontainer_sequence_get_contents" );
449 unsigned long diff = std::max( ( *beg ).begin - start, (damsel_handle)0 );
450 unsigned long num = std::min( count - diff, (
size_t)( *beg ).count );
451 ents.
insert( ( *beg ).begin + diff, ( *beg ).begin + diff + num - 1 );
452 count -= ( diff + num );
458 for(
int i = count - 1; i >= 0; i-- )
464 else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR )
466 damsel_handle* handle_ptr;
468 damsel_err_t err = DMSLcontainer_vector_get_contents( m, c, &handle_ptr, &count );
470 for(
int i = count - 1; i >= 0; i-- )
475 else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE )
477 damsel_handle_ptr node_ptr = NULL;
478 damsel_container cont = NULL;
479 while( DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ) == DMSL_OK && cont )
494 if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_SEQUENCE )
497 size_t count, stride;
498 damsel_err_t err = DMSLcontainer_sequence_get_contents( m, c, &start, &count, &stride );
499 CHK_DMSL_ERR( err,
"Problem calling DMSLcontainer_sequence_get_contents" );
507 unsigned int diff = std::max( ( *beg ).begin - start, (damsel_handle)0 );
508 unsigned int num = std::min( count - diff, (
size_t)( *beg ).count );
509 for(
EntityHandle hdl = ( *beg ).begin + diff; hdl <= (
int)( *beg ).begin + diff + num - 1; hdl++ )
511 count -= ( diff + num );
517 for(
int i = count - 1; i >= 0; i-- )
523 else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_VECTOR )
525 damsel_handle_ptr handle_ptr;
527 damsel_err_t err = DMSLcontainer_vector_get_contents( m, c, &handle_ptr, &count );
529 for(
int i = count - 1; i >= 0; i-- )
534 else if( DMSLcontainer_get_type( c ) == DAMSEL_HANDLE_CONTAINER_TYPE_TREE )
536 damsel_handle_ptr node_ptr = NULL;
537 damsel_container cont = NULL;
538 while( DMSLcontainer_tree_get_contents( m, c, &node_ptr, &cont ) == DMSL_OK && cont )
542 unsigned int num = DMSLcontainer_count( cont );