MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <Tqdcfr.hpp>
Classes | |
struct | AcisRecord |
class | BlockHeader |
class | FEModelHeader |
class | FileTOC |
class | GeomHeader |
class | GroupHeader |
class | MetaDataContainer |
class | ModelEntry |
class | NodesetHeader |
class | SidesetHeader |
Public Types | |
enum | { aBODY, LUMP, SHELL, FACE, LOOP, COEDGE, aEDGE, aVERTEX, ATTRIB, UNKNOWN } |
enum | { mesh, acist, acisb, facet, exodusmesh } |
Public Member Functions | |
void | FSEEK (unsigned offset) |
void | FREADI (unsigned num_ents) |
void | FREADD (unsigned num_ents) |
void | FREADC (unsigned num_ents) |
void | FREADIA (unsigned num_ents, unsigned int *array) |
void | FREADDA (unsigned num_ents, double *array) |
void | FREADCA (unsigned num_ents, char *arrat) |
void | CONVERT_TO_INTS (unsigned int num_ents) |
~Tqdcfr () | |
ErrorCode | load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const SubsetList *subset_list=0, const Tag *file_id_tag=0) |
Load mesh from a file. | |
ErrorCode | read_tag_values (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_values_out, const SubsetList *subset_list=0) |
Read tag values from a file. | |
ErrorCode | read_nodeset (const unsigned int nsindex, ModelEntry *model, NodesetHeader *nodeseth) |
ErrorCode | read_sideset (const unsigned int ssindex, const double data_version, ModelEntry *model, SidesetHeader *sideseth) |
ErrorCode | read_block (const unsigned int blindex, const double data_version, ModelEntry *model, BlockHeader *blockh) |
ErrorCode | read_group (const unsigned int gr_index, ModelEntry *model, GroupHeader *grouph) |
ErrorCode | read_nodes (const unsigned int gindex, ModelEntry *model, GeomHeader *entity) |
ErrorCode | read_elements (ModelEntry *model, GeomHeader *entity) |
ErrorCode | read_file_header () |
ErrorCode | read_model_entries () |
int | find_model (const unsigned int model_type) |
ErrorCode | read_meta_data (const unsigned int metadata_offset, MetaDataContainer &mc) |
ErrorCode | read_md_string (std::string &name) |
EntityType | type_from_cub_type (const unsigned int cub_type, const unsigned int nodes_per_elem) |
void | check_contiguous (const unsigned int num_ents, int &contig, unsigned int &min_id, unsigned int &max_id) |
Tqdcfr (Interface *impl) | |
ErrorCode | create_set (EntityHandle &h, unsigned int flags=MESHSET_SET) |
Static Public Member Functions | |
static ReaderIface * | factory (Interface *) |
Public Attributes | |
ReadUtilIface * | readUtilIface |
Interface * | mdbImpl |
FILE * | cubFile |
FileTOC | fileTOC |
std::vector< ModelEntry > | modelEntries |
MetaDataContainer | modelMetaData |
long | currVHandleOffset |
Range | beforeEnts |
long | currElementIdOffset [MBMAXTYPE] |
Tag | globalIdTag |
Tag | cubIdTag |
Tag | geomTag |
Tag | uniqueIdTag |
Tag | blockTag |
Tag | nsTag |
Tag | ssTag |
Tag | attribVectorTag |
Tag | entityNameTag |
Tag | categoryTag |
Tag | hasMidNodesTag |
std::map< int, EntityHandle > | uidSetMap |
std::map< int, EntityHandle > | gidSetMap [6] |
bool | swapForEndianness |
std::vector< unsigned int > | uint_buf |
int * | int_buf |
std::vector< double > | dbl_buf |
std::vector< char > | char_buf |
Private Types | |
enum | { GROUP = 0, BODY, VOLUME, SURFACE, CURVE, VERTEX, HEX, TET, PYRAMID, QUAD, TRI, EDGE, NODE } |
enum | { SPHERE_EXO = 0, BAR, BAR2, BAR3, BEAM, BEAM2, BEAM3, TRUSS, TRUSS2, TRUSS3, SPRING, TRIthree, TRI3, TRI6, TRI7, TRISHELL, TRISHELL3, TRISHELL6, TRISHELL7, SHEL, SHELL4, SHELL8, SHELL9, QUADfour, QUAD4, QUAD5, QUAD8, QUAD9, TETRAfour, TETRA4, TETRA8, TETRA10, TETRA14, PYRAMIDfive, PYRAMID5, PYRAMID8, PYRAMID13, PYRAMID18, HEXeight, HEX8, HEX9, HEX20, HEX27, HEXSHELL, INVALID_ELEMENT_TYPE } |
Private Member Functions | |
ErrorCode | convert_nodesets_sidesets () |
ErrorCode | read_acis_records (const char *sat_file_name=0) |
ErrorCode | parse_acis_attribs (const unsigned int entity_rec_num, std::vector< AcisRecord > &records) |
ErrorCode | interpret_acis_records (std::vector< AcisRecord > &records) |
ErrorCode | reset_record (AcisRecord &this_record) |
ErrorCode | process_record (AcisRecord &this_record) |
ErrorCode | get_entities (const unsigned int *mem_types, int *id_buf, const unsigned int id_buf_size, const bool is_group, std::vector< EntityHandle > &entities) |
ErrorCode | get_entities (const unsigned int this_type, int *id_buf, const unsigned int id_buf_size, std::vector< EntityHandle > &entities, std::vector< EntityHandle > &excl_entities) |
get entities specified by type and ids, append to entities | |
ErrorCode | get_ref_entities (const unsigned int this_type, int *id_buf, const unsigned id_buf_size, std::vector< EntityHandle > &entities) |
get ref entity sets with specified type and ids | |
ErrorCode | get_mesh_entities (const unsigned int this_type, int *id_buf, const unsigned id_buf_size, std::vector< EntityHandle > &entities, std::vector< EntityHandle > &excl_entities) |
get mesh entities with specified type and ids | |
ErrorCode | process_sideset_10 (const int this_type, const int num_ents, const int sense_size, std::vector< EntityHandle > &ss_entities, Tqdcfr::SidesetHeader *sideseth) |
ErrorCode | process_sideset_11 (std::vector< EntityHandle > &ss_entities, int num_wrts, Tqdcfr::SidesetHeader *sideseth) |
ErrorCode | put_into_set (EntityHandle set_handle, std::vector< EntityHandle > &entities, std::vector< EntityHandle > &excl_entities) |
ErrorCode | get_names (MetaDataContainer &md, unsigned int set_index, EntityHandle seth) |
Private Attributes | |
EntityHandle | mFileSet |
bool | printedSeqWarning |
bool | printedElemWarning |
FILE * | acisDumpFile |
std::vector< EntityHandle > * | cubMOABVertexMap |
Static Private Attributes | |
static const char | geom_categories [][CATEGORY_TAG_SIZE] = { "Vertex\0", "Curve\0", "Surface\0", "Volume\0" } |
static const EntityType | group_type_to_mb_type [] |
static const EntityType | block_type_to_mb_type [] |
static const int | cub_elem_num_verts [] |
static const int | cub_elem_num_verts_len = sizeof( cub_elem_num_verts ) / sizeof( cub_elem_num_verts[0] ) |
static const EntityType | mp_type_to_mb_type [] |
mapping from mesh packet type to moab type |
Definition at line 45 of file Tqdcfr.hpp.
anonymous enum |
anonymous enum |
Definition at line 326 of file Tqdcfr.hpp.
{ mesh, acist, acisb, facet, exodusmesh };
anonymous enum [private] |
anonymous enum [private] |
Definition at line 385 of file Tqdcfr.hpp.
{ SPHERE_EXO = 0, BAR, BAR2, BAR3, BEAM, BEAM2, BEAM3, TRUSS, TRUSS2, TRUSS3, SPRING, TRIthree, TRI3, TRI6, TRI7, TRISHELL, TRISHELL3, TRISHELL6, TRISHELL7, SHEL, SHELL4, SHELL8, SHELL9, QUADfour, QUAD4, QUAD5, QUAD8, QUAD9, TETRAfour, TETRA4, TETRA8, TETRA10, TETRA14, PYRAMIDfive, PYRAMID5, PYRAMID8, PYRAMID13, PYRAMID18, HEXeight, HEX8, HEX9, HEX20, HEX27, HEXSHELL, INVALID_ELEMENT_TYPE };
Definition at line 261 of file Tqdcfr.cpp.
References attribVectorTag, moab::Range::begin(), cubMOABVertexMap, moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_type(), MB_SUCCESS, MBENTITYSET, mdbImpl, readUtilIface, moab::Interface::release_interface(), moab::Interface::tag_delete(), and moab::Interface::tag_get_data().
{ mdbImpl->release_interface( readUtilIface ); if( NULL != cubMOABVertexMap ) delete cubMOABVertexMap; if( attribVectorTag ) { // get all sets, and release the string vectors Range allSets; // although only geom sets should have these attributes // can't error in a destructor ErrorCode rval = mdbImpl->get_entities_by_type( 0, MBENTITYSET, allSets ); if( rval != MB_SUCCESS ) std::cerr << "WARNING: Could not get_entities_by_type" << std::endl; for( Range::iterator sit = allSets.begin(); sit != allSets.end(); ++sit ) { EntityHandle gset = *sit; std::vector< std::string >* dum_vec; // can't error in a destructor rval = mdbImpl->tag_get_data( attribVectorTag, &gset, 1, &dum_vec ); if( rval != MB_SUCCESS ) std::cerr << "WARNING: Could not tag_get_data" << std::endl; if( NULL != dum_vec ) delete dum_vec; // } mdbImpl->tag_delete( attribVectorTag ); attribVectorTag = NULL; } }
moab::Tqdcfr::Tqdcfr | ( | Interface * | impl | ) |
Definition at line 232 of file Tqdcfr.cpp.
References blockTag, cubMOABVertexMap, currElementIdOffset, currVHandleOffset, DIRICHLET_SET_TAG_NAME, entityNameTag, ErrorCode, MATERIAL_SET_TAG_NAME, MB_CHK_SET_ERR_RET, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_INTEGER, MB_TYPE_OPAQUE, MBMAXTYPE, MBVERTEX, mdbImpl, NAME_TAG_NAME, NAME_TAG_SIZE, NEUMANN_SET_TAG_NAME, nsTag, moab::Interface::query_interface(), readUtilIface, ssTag, and moab::Interface::tag_get_handle().
Referenced by factory().
: cubFile( NULL ), globalIdTag( 0 ), cubIdTag( 0 ), geomTag( 0 ), uniqueIdTag( 0 ), blockTag( 0 ), nsTag( 0 ), ssTag( 0 ), attribVectorTag( 0 ), entityNameTag( 0 ), categoryTag( 0 ), hasMidNodesTag( 0 ), swapForEndianness( false ), int_buf( NULL ), mFileSet( 0 ), printedSeqWarning( false ), printedElemWarning( false ), acisDumpFile( NULL ) { assert( NULL != impl ); mdbImpl = impl; impl->query_interface( readUtilIface ); assert( NULL != readUtilIface ); currVHandleOffset = -1; for( EntityType this_type = MBVERTEX; this_type < MBMAXTYPE; this_type++ ) currElementIdOffset[this_type] = -1; ErrorCode rval; rval = mdbImpl->tag_get_handle( MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, blockTag );MB_CHK_SET_ERR_RET( rval, "Failed to tag_get_handle." ); rval = mdbImpl->tag_get_handle( DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag );MB_CHK_SET_ERR_RET( rval, "Failed to tag_get_handle." ); rval = mdbImpl->tag_get_handle( NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag );MB_CHK_SET_ERR_RET( rval, "Failed to tag_get_handle." ); if( 0 == entityNameTag ) { rval = mdbImpl->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, entityNameTag, MB_TAG_SPARSE | MB_TAG_CREAT );MB_CHK_SET_ERR_RET( rval, "Failed to tag_get_handle." ); } cubMOABVertexMap = NULL; }
void moab::Tqdcfr::check_contiguous | ( | const unsigned int | num_ents, |
int & | contig, | ||
unsigned int & | min_id, | ||
unsigned int & | max_id | ||
) |
Definition at line 1660 of file Tqdcfr.cpp.
References moab::MAX(), moab::MIN(), and uint_buf.
Referenced by read_elements(), and read_nodes().
{ unsigned int *id_it, curr_id, i; // Check in forward-contiguous direction id_it = &uint_buf[0]; curr_id = *id_it++ + 1; contig = 1; min_id = uint_buf[0]; max_id = uint_buf[0]; for( i = 1; i < num_ents; id_it++, i++, curr_id++ ) { if( *id_it != curr_id ) { contig = 0; } min_id = MIN( min_id, uint_buf[i] ); max_id = MAX( max_id, uint_buf[i] ); } // If we got here and we're at the end of the loop, it's forward-contiguous if( 1 == contig ) return; // Check in reverse-contiguous direction contig = -1; id_it = &uint_buf[0]; curr_id = *id_it++ - 1; for( i = 1; i < num_ents; id_it++, i++, curr_id-- ) { if( *id_it != curr_id ) { contig = 0; break; } } // If we got here and we're at the end of the loop, it's reverse-contiguous if( -1 == contig ) return; // One final check, for contiguous but out of order if( max_id - min_id + 1 == num_ents ) contig = -2; // Else it's not contiguous at all contig = 0; }
ErrorCode moab::Tqdcfr::convert_nodesets_sidesets | ( | ) | [private] |
Definition at line 489 of file Tqdcfr.cpp.
References moab::Range::begin(), moab::BLOCK_NODESET_OFFSET_TAG_NAME, moab::BLOCK_SIDESET_OFFSET_TAG_NAME, blockTag, DIRICHLET_SET_TAG_NAME, moab::Range::empty(), moab::Range::end(), ErrorCode, moab::Interface::get_entities_by_type_and_tag(), globalIdTag, moab::Range::insert(), MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_INTEGER, MBENTITYSET, mdbImpl, NEUMANN_SET_TAG_NAME, nsTag, moab::Range::size(), ssTag, moab::Interface::tag_delete_data(), moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), and moab::Interface::tag_set_data().
Referenced by load_file().
{ // Look first for the nodeset and sideset offset flags; if they're not // set, we don't need to convert const EntityHandle msh = 0; unsigned int nodeset_offset, sideset_offset; Tag tmp_tag; ErrorCode result = mdbImpl->tag_get_handle( BLOCK_NODESET_OFFSET_TAG_NAME, 1, MB_TYPE_INTEGER, tmp_tag ); if( MB_SUCCESS != result ) nodeset_offset = 0; else { result = mdbImpl->tag_get_data( tmp_tag, &msh, 1, &nodeset_offset ); if( MB_SUCCESS != result ) return result; } result = mdbImpl->tag_get_handle( BLOCK_SIDESET_OFFSET_TAG_NAME, 1, MB_TYPE_INTEGER, tmp_tag ); if( MB_SUCCESS != result ) sideset_offset = 0; else { result = mdbImpl->tag_get_data( tmp_tag, &msh, 1, &sideset_offset ); if( MB_SUCCESS != result ) return result; } if( 0 == nodeset_offset && 0 == sideset_offset ) return MB_SUCCESS; // Look for all blocks Range blocks; result = mdbImpl->get_entities_by_type_and_tag( 0, MBENTITYSET, &blockTag, NULL, 1, blocks ); if( MB_SUCCESS != result || blocks.empty() ) return result; // Get the id tag for them std::vector< int > block_ids( blocks.size() ); result = mdbImpl->tag_get_data( globalIdTag, blocks, &block_ids[0] ); if( MB_SUCCESS != result ) return result; unsigned int i = 0; Range::iterator rit = blocks.begin(); Range new_nodesets, new_sidesets; std::vector< int > new_nodeset_ids, new_sideset_ids; for( ; rit != blocks.end(); i++, ++rit ) { if( 0 != nodeset_offset && block_ids[i] >= (int)nodeset_offset && ( nodeset_offset > sideset_offset || block_ids[i] < (int)sideset_offset ) ) { // This is a nodeset new_nodesets.insert( *rit ); new_nodeset_ids.push_back( block_ids[i] ); } else if( 0 != sideset_offset && block_ids[i] >= (int)sideset_offset && ( sideset_offset > nodeset_offset || block_ids[i] < (int)nodeset_offset ) ) { // This is a sideset new_sidesets.insert( *rit ); new_sideset_ids.push_back( block_ids[i] ); } } // OK, have the new nodesets and sidesets; now remove the block tags, and // add nodeset and sideset tags ErrorCode tmp_result = MB_SUCCESS; if( 0 != nodeset_offset ) { if( 0 == nsTag ) { int default_val = 0; tmp_result = mdbImpl->tag_get_handle( DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag, MB_TAG_SPARSE | MB_TAG_CREAT, &default_val ); if( MB_SUCCESS != tmp_result ) result = tmp_result; } if( MB_SUCCESS == tmp_result ) tmp_result = mdbImpl->tag_set_data( nsTag, new_nodesets, &new_nodeset_ids[0] ); if( MB_SUCCESS != tmp_result ) result = tmp_result; tmp_result = mdbImpl->tag_delete_data( blockTag, new_nodesets ); if( MB_SUCCESS != tmp_result ) result = tmp_result; } if( 0 != sideset_offset ) { if( 0 == ssTag ) { int default_val = 0; tmp_result = mdbImpl->tag_get_handle( NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag, MB_TAG_SPARSE | MB_TAG_CREAT, &default_val ); if( MB_SUCCESS != tmp_result ) result = tmp_result; } if( MB_SUCCESS == tmp_result ) tmp_result = mdbImpl->tag_set_data( ssTag, new_sidesets, &new_sideset_ids[0] ); if( MB_SUCCESS != tmp_result ) result = tmp_result; tmp_result = mdbImpl->tag_delete_data( blockTag, new_sidesets ); if( MB_SUCCESS != tmp_result ) result = tmp_result; } return result; }
void moab::Tqdcfr::CONVERT_TO_INTS | ( | unsigned int | num_ents | ) |
Definition at line 221 of file Tqdcfr.cpp.
References int_buf, and uint_buf.
Referenced by read_block(), read_elements(), read_group(), read_nodes(), read_nodeset(), and read_sideset().
ErrorCode moab::Tqdcfr::create_set | ( | EntityHandle & | h, |
unsigned int | flags = MESHSET_SET |
||
) |
Definition at line 3061 of file Tqdcfr.cpp.
References moab::Interface::create_meshset(), and mdbImpl.
Referenced by process_sideset_10(), process_sideset_11(), moab::Tqdcfr::GeomHeader::read_info_header(), moab::Tqdcfr::GroupHeader::read_info_header(), moab::Tqdcfr::BlockHeader::read_info_header(), moab::Tqdcfr::NodesetHeader::read_info_header(), and moab::Tqdcfr::SidesetHeader::read_info_header().
{ return mdbImpl->create_meshset( flags, h ); }
ReaderIface * moab::Tqdcfr::factory | ( | Interface * | iface | ) | [static] |
Definition at line 227 of file Tqdcfr.cpp.
References Tqdcfr().
Referenced by moab::ReaderWriterSet::ReaderWriterSet().
int moab::Tqdcfr::find_model | ( | const unsigned int | model_type | ) |
Definition at line 1779 of file Tqdcfr.cpp.
References fileTOC, modelEntries, and moab::Tqdcfr::FileTOC::numModels.
Referenced by load_file().
{ for( unsigned int i = 0; i < fileTOC.numModels; i++ ) { if( modelEntries[i].modelType == model_type ) return i; } return -1; }
void moab::Tqdcfr::FREADC | ( | unsigned | num_ents | ) |
Definition at line 148 of file Tqdcfr.cpp.
References char_buf, and FREADCA().
Referenced by load_file(), read_acis_records(), read_block(), read_md_string(), read_nodeset(), and read_sideset().
void moab::Tqdcfr::FREADCA | ( | unsigned | num_ents, |
char * | arrat | ||
) |
Definition at line 215 of file Tqdcfr.cpp.
References cubFile, and IO_ASSERT.
Referenced by FREADC(), read_nodeset(), and read_sideset().
void moab::Tqdcfr::FREADD | ( | unsigned | num_ents | ) |
Definition at line 142 of file Tqdcfr.cpp.
References dbl_buf, and FREADDA().
Referenced by read_block(), read_meta_data(), and read_sideset().
void moab::Tqdcfr::FREADDA | ( | unsigned | num_ents, |
double * | array | ||
) |
Definition at line 200 of file Tqdcfr.cpp.
References cubFile, IO_ASSERT, moab::swap8_voff(), and swapForEndianness.
Referenced by FREADD(), and read_nodes().
{ unsigned rval = fread( array, sizeof( double ), num_ents, cubFile ); IO_ASSERT( rval == num_ents ); if( swapForEndianness ) { double* pt = array; for( unsigned int i = 0; i < num_ents; i++ ) { swap8_voff( (long*)pt ); pt++; } } }
void moab::Tqdcfr::FREADI | ( | unsigned | num_ents | ) |
Definition at line 132 of file Tqdcfr.cpp.
References FREADIA(), int_buf, and uint_buf.
Referenced by moab::Tqdcfr::FEModelHeader::init(), read_block(), read_elements(), read_file_header(), read_group(), moab::Tqdcfr::GeomHeader::read_info_header(), moab::Tqdcfr::GroupHeader::read_info_header(), moab::Tqdcfr::BlockHeader::read_info_header(), moab::Tqdcfr::NodesetHeader::read_info_header(), moab::Tqdcfr::SidesetHeader::read_info_header(), read_md_string(), read_meta_data(), read_model_entries(), read_nodes(), read_nodeset(), and read_sideset().
void moab::Tqdcfr::FREADIA | ( | unsigned | num_ents, |
unsigned int * | array | ||
) |
Definition at line 185 of file Tqdcfr.cpp.
References cubFile, IO_ASSERT, moab::swap4_uint(), and swapForEndianness.
Referenced by FREADI(), and read_sideset().
{ unsigned rval = fread( array, sizeof( unsigned int ), num_ents, cubFile ); IO_ASSERT( rval == num_ents ); if( swapForEndianness ) { unsigned int* pt = array; for( unsigned int i = 0; i < num_ents; i++ ) { swap4_uint( (unsigned int*)pt ); pt++; } } }
void moab::Tqdcfr::FSEEK | ( | unsigned | offset | ) |
Definition at line 126 of file Tqdcfr.cpp.
References cubFile, and IO_ASSERT.
Referenced by moab::Tqdcfr::FEModelHeader::init(), read_acis_records(), read_block(), read_elements(), read_file_header(), read_group(), moab::Tqdcfr::GeomHeader::read_info_header(), moab::Tqdcfr::GroupHeader::read_info_header(), moab::Tqdcfr::BlockHeader::read_info_header(), moab::Tqdcfr::NodesetHeader::read_info_header(), moab::Tqdcfr::SidesetHeader::read_info_header(), read_meta_data(), read_model_entries(), read_nodes(), read_nodeset(), and read_sideset().
ErrorCode moab::Tqdcfr::get_entities | ( | const unsigned int * | mem_types, |
int * | id_buf, | ||
const unsigned int | id_buf_size, | ||
const bool | is_group, | ||
std::vector< EntityHandle > & | entities | ||
) | [private] |
get entities with individually-specified types; if is_group is false, increment each mem_type by 2 since they're CSOEntityType's and not group types
Definition at line 1242 of file Tqdcfr.cpp.
References ErrorCode, and MB_SUCCESS.
Referenced by read_block(), read_group(), read_nodeset(), and read_sideset().
{ ErrorCode tmp_result, result = MB_SUCCESS; for( unsigned int i = 0; i < id_buf_size; i++ ) { if( is_group ) tmp_result = get_entities( mem_types[i], id_buf + i, 1, entities, entities ); else // For blocks/nodesets/sidesets, use CSOEntityType, which is 2 greater than // group entity types tmp_result = get_entities( mem_types[i] + 2, id_buf + i, 1, entities, entities ); if( MB_SUCCESS != tmp_result ) result = tmp_result; } return result; }
ErrorCode moab::Tqdcfr::get_entities | ( | const unsigned int | this_type, |
int * | id_buf, | ||
const unsigned int | id_buf_size, | ||
std::vector< EntityHandle > & | entities, | ||
std::vector< EntityHandle > & | excl_entities | ||
) | [private] |
get entities specified by type and ids, append to entities
Definition at line 1264 of file Tqdcfr.cpp.
References ErrorCode, get_mesh_entities(), get_ref_entities(), HEX, NODE, and VERTEX.
{ ErrorCode result = MB_FAILURE; if( this_type <= VERTEX ) result = get_ref_entities( this_type, id_buf, id_buf_size, entities ); else if( this_type >= HEX && this_type <= NODE ) result = get_mesh_entities( this_type, id_buf, id_buf_size, entities, excl_entities ); return result; }
ErrorCode moab::Tqdcfr::get_mesh_entities | ( | const unsigned int | this_type, |
int * | id_buf, | ||
const unsigned | id_buf_size, | ||
std::vector< EntityHandle > & | entities, | ||
std::vector< EntityHandle > & | excl_entities | ||
) | [private] |
get mesh entities with specified type and ids
Definition at line 1291 of file Tqdcfr.cpp.
References cubMOABVertexMap, currVHandleOffset, moab::Range::empty(), entities, moab::CN::EntityTypeName(), ErrorCode, moab::Interface::get_entities_by_type(), globalIdTag, group_type_to_mb_type, MB_SET_ERR, MB_SUCCESS, MB_TAG_NOT_FOUND, MBMAXTYPE, MBVERTEX, mdbImpl, moab::Range::size(), moab::Interface::tag_get_data(), and moab::Interface::type_from_handle().
Referenced by get_entities().
{ ErrorCode result = MB_SUCCESS; std::vector< EntityHandle >* ent_list = NULL; EntityType this_ent_type = MBVERTEX; const unsigned int arr_len = sizeof( group_type_to_mb_type ) / sizeof( group_type_to_mb_type[0] ); if( this_type > 1000 ) { if( this_type - 1000 < arr_len ) { this_ent_type = group_type_to_mb_type[this_type - 1000]; ent_list = &excl_entities; } } else { if( this_type < arr_len ) { this_ent_type = group_type_to_mb_type[this_type]; ent_list = &entities; } } if( NULL == ent_list ) { MB_SET_ERR( MB_FAILURE, "Entities list is NULL" ); } // Get entities with this type, and get their cub id tags if( MBVERTEX == this_ent_type ) { // Use either vertex offset or cubMOABVertexMap if( NULL == cubMOABVertexMap ) { for( unsigned int i = 0; i < id_buf_size; i++ ) ent_list->push_back( (EntityHandle)( id_buf[i] + currVHandleOffset ) ); } else { for( unsigned int i = 0; i < id_buf_size; i++ ) { assert( 0 != ( *cubMOABVertexMap )[id_buf[i]] ); ent_list->push_back( ( *cubMOABVertexMap )[id_buf[i]] ); } } } else { Range tmp_ents; result = mdbImpl->get_entities_by_type( 0, this_ent_type, tmp_ents ); if( MB_SUCCESS != result ) return result; if( tmp_ents.empty() && 0 != id_buf_size ) return MB_FAILURE; std::vector< int > cub_ids( tmp_ents.size() ); result = mdbImpl->tag_get_data( globalIdTag, tmp_ents, &cub_ids[0] ); if( MB_SUCCESS != result && MB_TAG_NOT_FOUND != result ) return result; // Now go through id list, finding each entity by id for( unsigned int i = 0; i < id_buf_size; i++ ) { std::vector< int >::iterator vit = std::find( cub_ids.begin(), cub_ids.end(), id_buf[i] ); if( vit != cub_ids.end() ) { EntityHandle this_ent = tmp_ents[vit - cub_ids.begin()]; if( mdbImpl->type_from_handle( this_ent ) != MBMAXTYPE ) ent_list->push_back( this_ent ); } else { std::cout << "Warning: didn't find " << CN::EntityTypeName( this_ent_type ) << " " << id_buf[i] << std::endl; } } } return result; }
ErrorCode moab::Tqdcfr::get_names | ( | MetaDataContainer & | md, |
unsigned int | set_index, | ||
EntityHandle | seth | ||
) | [private] |
Definition at line 1093 of file Tqdcfr.cpp.
References entityNameTag, ErrorCode, moab::Tqdcfr::MetaDataContainer::get_md_entry(), MB_CHK_ERR, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_OPAQUE, mdbImpl, moab::Tqdcfr::MetaDataContainer::MetaDataEntry::mdStringValue, moab::Tqdcfr::MetaDataContainer::metadataEntries, NAME_TAG_NAME, NAME_TAG_SIZE, moab::Interface::tag_get_handle(), and moab::Interface::tag_set_data().
Referenced by read_block(), read_nodeset(), and read_sideset().
{ ErrorCode result = MB_SUCCESS; // Now get block names, if any int md_index = md.get_md_entry( set_index, "Name" ); if( -1 == md_index ) return result; MetaDataContainer::MetaDataEntry* md_entry = &( md.metadataEntries[md_index] ); // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE); char name_tag_data[NAME_TAG_SIZE]; memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 ); result = mdbImpl->tag_set_data( entityNameTag, &seth, 1, name_tag_data ); if( MB_SUCCESS != result ) return result; // Look for extra names md_index = md.get_md_entry( set_index, "NumExtraNames" ); if( -1 == md_index ) return result; int num_names = md.metadataEntries[md_index].mdIntValue; for( int i = 0; i < num_names; i++ ) { std::ostringstream extra_name_label( "ExtraName" ); extra_name_label << i; std::ostringstream moab_extra_name( "EXTRA_" ); moab_extra_name << NAME_TAG_NAME << i; md_index = md.get_md_entry( set_index, extra_name_label.str().c_str() ); if( -1 != md_index ) { md_entry = &( md.metadataEntries[md_index] ); Tag extra_name_tag; ErrorCode rval; rval = mdbImpl->tag_get_handle( moab_extra_name.str().c_str(), NAME_TAG_SIZE, MB_TYPE_OPAQUE, extra_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT );MB_CHK_ERR( rval ); memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 ); result = mdbImpl->tag_set_data( extra_name_tag, &seth, 1, name_tag_data ); } } return result; }
ErrorCode moab::Tqdcfr::get_ref_entities | ( | const unsigned int | this_type, |
int * | id_buf, | ||
const unsigned | id_buf_size, | ||
std::vector< EntityHandle > & | entities | ||
) | [private] |
get ref entity sets with specified type and ids
Definition at line 1280 of file Tqdcfr.cpp.
References gidSetMap, and MB_SUCCESS.
Referenced by get_entities().
{ for( unsigned int i = 0; i < id_buf_size; i++ ) entities.push_back( ( gidSetMap[5 - this_type] )[id_buf[i]] ); return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::interpret_acis_records | ( | std::vector< AcisRecord > & | records | ) | [private] |
Definition at line 2479 of file Tqdcfr.cpp.
References ATTRIB, attribVectorTag, ErrorCode, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_OPAQUE, mdbImpl, parse_acis_attribs(), REC, moab::Interface::tag_get_handle(), and UNKNOWN.
Referenced by read_acis_records().
{ // Make a tag for the vector holding unrecognized attributes void* default_val = NULL; ErrorCode result = mdbImpl->tag_get_handle( "ATTRIB_VECTOR", sizeof( void* ), MB_TYPE_OPAQUE, attribVectorTag, MB_TAG_CREAT | MB_TAG_SPARSE, &default_val ); if( MB_SUCCESS != result ) return result; unsigned int current_record = 0; #define REC records[current_record] while( current_record != records.size() ) { // If this record's been processed, or if it's an attribute, continue if( REC.processed || REC.rec_type == Tqdcfr::ATTRIB ) { current_record++; continue; } if( REC.rec_type == Tqdcfr::UNKNOWN ) { REC.processed = true; current_record++; continue; } // It's a known, non-attrib rec type; parse for any attribs parse_acis_attribs( current_record, records ); REC.processed = true; current_record++; } return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::load_file | ( | const char * | file_name, |
const EntityHandle * | file_set, | ||
const FileOptions & | opts, | ||
const SubsetList * | subset_list = 0 , |
||
const Tag * | file_id_tag = 0 |
||
) | [virtual] |
Load mesh from a file.
Method all readers must provide to import a mesh.
file_name | The file to read. |
file_set | Optional pointer to entity set representing file. If this is not NULL, reader may optionally tag the pointed-to set with format-specific meta-data. |
subset_list | An optional struct pointer specifying the tags identifying entity sets to be read. |
file_id_tag | If specified, reader should store for each entity it reads, a unique integer ID for this tag. |
Implements moab::ReaderIface.
Definition at line 296 of file Tqdcfr.cpp.
References moab::ReadUtilIface::assign_ids(), beforeEnts, moab::Tqdcfr::FEModelHeader::blockArray, char_buf, convert_nodesets_sidesets(), cubFile, moab::debug, dim, ErrorCode, moab::Tqdcfr::ModelEntry::feBlockH, moab::Tqdcfr::ModelEntry::feGeomH, moab::Tqdcfr::ModelEntry::feGroupH, moab::Tqdcfr::ModelEntry::feModelHeader, moab::Tqdcfr::ModelEntry::feNodeSetH, moab::Tqdcfr::ModelEntry::feSideSetH, fileTOC, find_model(), FREADC(), moab::Tqdcfr::FEModelHeader::geomArray, moab::Interface::get_entities_by_handle(), moab::FileOptions::get_int_option(), moab::Tqdcfr::MetaDataContainer::get_md_entry(), moab::FileOptions::get_null_option(), moab::FileOptions::get_str_option(), moab::Tqdcfr::FEModelHeader::groupArray, moab::Interface::list_entities(), moab::major, moab::Tqdcfr::GeomHeader::maxDim, MB_CHK_SET_ERR, MB_SET_ERR, MB_SUCCESS, MB_UNSUPPORTED_OPERATION, mdbImpl, mesh, moab::Tqdcfr::MetaDataContainer::metadataEntries, moab::minor, modelEntries, modelMetaData, moab::Tqdcfr::FileTOC::modelMetaDataOffset, moab::Tqdcfr::FEModelHeader::nodesetArray, moab::Tqdcfr::FEModelHeader::ArrayInfo::numEntities, read_acis_records(), read_block(), read_elements(), read_file_header(), read_group(), moab::Tqdcfr::ModelEntry::read_header_info(), read_meta_data(), moab::Tqdcfr::ModelEntry::read_metadata_info(), read_model_entries(), read_nodes(), read_nodeset(), read_sideset(), readUtilIface, moab::GeomTopoTool::restore_topology_from_adjacency(), RR, moab::Tqdcfr::FEModelHeader::sidesetArray, and moab::subtract().
Referenced by main().
{ ErrorCode result; int tmpval; if( MB_SUCCESS == opts.get_int_option( "DEBUG_IO", 1, tmpval ) ) { if( 0 < tmpval ) debug = true; } if( subset_list ) { MB_SET_ERR( MB_UNSUPPORTED_OPERATION, "Reading subset of files not supported for CUB files" ); } // Open file cubFile = fopen( file_name, "rb" ); if( NULL == cubFile ) { MB_SET_ERR( MB_FAILURE, "File not found" ); } // Verify magic string FREADC( 4 ); if( !( char_buf[0] == 'C' && char_buf[1] == 'U' && char_buf[2] == 'B' && char_buf[3] == 'E' ) ) { fclose( cubFile ); MB_SET_ERR( MB_FAILURE, "This doesn't appear to be a .cub file" ); } // Get "before" entities result = mdbImpl->get_entities_by_handle( 0, beforeEnts );MB_CHK_SET_ERR( result, "Couldn't get \"before\" entities" ); // *********************** // Read model header type information... // *********************** if( debug ) std::cout << "Reading file header." << std::endl; result = read_file_header();RR; if( debug ) std::cout << "Reading model entries." << std::endl; result = read_model_entries();RR; // Read model metadata if( debug ) std::cout << "Reading model metadata." << std::endl; result = read_meta_data( fileTOC.modelMetaDataOffset, modelMetaData );RR; double data_version; int md_index = modelMetaData.get_md_entry( 2, "DataVersion" ); if( -1 == md_index ) data_version = 1.0; else data_version = modelMetaData.metadataEntries[md_index].mdDblValue; // Get the major/minor cubit version that wrote this file // int major = -1, minor = -1; md_index = modelMetaData.get_md_entry( 2, "CubitVersion" ); if( md_index >= 0 && !modelMetaData.metadataEntries[md_index].mdStringValue.empty() ) sscanf( modelMetaData.metadataEntries[md_index].mdStringValue.c_str(), "%d.%d", &major, &minor ); // *********************** // Read mesh... // *********************** int index = find_model( mesh ); if( -1 == index ) return MB_FAILURE; ModelEntry* mesh_model = &modelEntries[index]; // First the header & metadata info if( debug ) std::cout << "Reading mesh model header and metadata." << std::endl; result = mesh_model->read_header_info( this, data_version ); if( MB_SUCCESS != result ) return result; result = mesh_model->read_metadata_info( this ); if( MB_SUCCESS != result ) return result; // Now read in mesh for each geometry entity; read in order of increasing dimension // so we have all the mesh we need for( int dim = 0; dim < 4; dim++ ) { for( unsigned int gindex = 0; gindex < mesh_model->feModelHeader.geomArray.numEntities; gindex++ ) { Tqdcfr::GeomHeader* geom_header = &mesh_model->feGeomH[gindex]; if( geom_header->maxDim != dim ) continue; // Read nodes if( debug ) std::cout << "Reading geom index " << gindex << " mesh: nodes... "; result = read_nodes( gindex, mesh_model, geom_header ); if( MB_SUCCESS != result ) return result; // Read elements if( debug ) std::cout << "elements... "; result = read_elements( mesh_model, geom_header ); if( MB_SUCCESS != result ) return result; if( debug ) std::cout << std::endl; } } // *********************** // Read acis records... // *********************** std::string sat_file_name; if( MB_SUCCESS != opts.get_str_option( "SAT_FILE", sat_file_name ) ) sat_file_name.clear(); result = read_acis_records( sat_file_name.empty() ? NULL : sat_file_name.c_str() );RR; // *********************** // Read groups... // *********************** if( debug ) std::cout << "Reading groups... "; for( unsigned int grindex = 0; grindex < mesh_model->feModelHeader.groupArray.numEntities; grindex++ ) { GroupHeader* group_header = &mesh_model->feGroupH[grindex]; result = read_group( grindex, mesh_model, group_header ); if( MB_SUCCESS != result ) return result; } if( debug ) std::cout << mesh_model->feModelHeader.groupArray.numEntities << " read successfully." << std::endl; // *********************** // Read blocks... // *********************** if( debug ) std::cout << "Reading blocks... "; Range ho_entities; for( unsigned int blindex = 0; blindex < mesh_model->feModelHeader.blockArray.numEntities; blindex++ ) { BlockHeader* block_header = &mesh_model->feBlockH[blindex]; result = read_block( blindex, data_version, mesh_model, block_header ); if( MB_SUCCESS != result ) return result; } if( debug ) std::cout << mesh_model->feModelHeader.blockArray.numEntities << " read successfully." << std::endl; // *********************** // Read nodesets... // *********************** if( debug ) std::cout << "Reading nodesets... "; for( unsigned int nsindex = 0; nsindex < mesh_model->feModelHeader.nodesetArray.numEntities; nsindex++ ) { NodesetHeader* nodeset_header = &mesh_model->feNodeSetH[nsindex]; result = read_nodeset( nsindex, mesh_model, nodeset_header ); if( MB_SUCCESS != result ) return result; } if( debug ) std::cout << mesh_model->feModelHeader.nodesetArray.numEntities << " read successfully." << std::endl; // *********************** // Read sidesets... // *********************** if( debug ) std::cout << "Reading sidesets..."; for( unsigned int ssindex = 0; ssindex < mesh_model->feModelHeader.sidesetArray.numEntities; ssindex++ ) { SidesetHeader* sideset_header = &mesh_model->feSideSetH[ssindex]; result = read_sideset( ssindex, data_version, mesh_model, sideset_header ); if( MB_SUCCESS != result ) return result; } if( debug ) std::cout << mesh_model->feModelHeader.sidesetArray.numEntities << " read successfully." << std::endl; if( debug ) { std::cout << "Read the following mesh:" << std::endl; mdbImpl->list_entities( 0, 0 ); } // Convert blocks to nodesets/sidesets if tag is set result = convert_nodesets_sidesets(); if( MB_SUCCESS != result ) return result; Range after_ents; result = mdbImpl->get_entities_by_handle( 0, after_ents ); if( MB_SUCCESS != result ) return result; after_ents = subtract( after_ents, beforeEnts ); if( file_id_tag ) readUtilIface->assign_ids( *file_id_tag, after_ents ); if( MB_SUCCESS != opts.get_null_option( "SKIP_TOPOLOGY" ) ) { // ************************** // Restore geometric topology // ************************** GeomTopoTool gtt( mdbImpl, true, 0, true, false ); result = gtt.restore_topology_from_adjacency(); if( MB_SUCCESS != result ) { std::cout << "Failed to restore topology " << std::endl; } } // done with the cubit file fclose( cubFile ); return result; }
ErrorCode moab::Tqdcfr::parse_acis_attribs | ( | const unsigned int | entity_rec_num, |
std::vector< AcisRecord > & | records | ||
) | [private] |
Definition at line 2518 of file Tqdcfr.cpp.
References aBODY, acisDumpFile, aEDGE, attribVectorTag, aVERTEX, entityNameTag, ErrorCode, FACE, gidSetMap, globalIdTag, LUMP, moab::major, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_NOT_FOUND, MB_TAG_SPARSE, MB_TYPE_OPAQUE, mdbImpl, name_tag, NAME_TAG_NAME, NAME_TAG_SIZE, moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), uidSetMap, and UNKNOWN.
Referenced by interpret_acis_records().
{ unsigned int num_read; std::vector< std::string > attrib_vec; char temp_name[1024]; char name_tag_val[NAME_TAG_SIZE]; std::string name_tag; int id = -1; int uid = -1; int next_attrib = -1; ErrorCode result; int current_attrib = records[entity_rec_num].first_attrib; if( -1 == current_attrib ) return MB_SUCCESS; if( NULL != acisDumpFile ) { fwrite( "-----------------------------------------------------------------------\n", 1, 72, acisDumpFile ); fwrite( records[entity_rec_num].att_string.c_str(), sizeof( char ), records[entity_rec_num].att_string.length(), acisDumpFile ); } while( -1 != current_attrib ) { if( records[current_attrib].rec_type != Tqdcfr::UNKNOWN && ( records[current_attrib].att_next != next_attrib || records[current_attrib].att_ent_num != (int)entity_rec_num ) ) return MB_FAILURE; if( NULL != acisDumpFile ) fwrite( records[current_attrib].att_string.c_str(), sizeof( char ), records[current_attrib].att_string.length(), acisDumpFile ); // Is the attrib one we already recognize? if( strncmp( records[current_attrib].att_string.c_str(), "ENTITY_NAME", 11 ) == 0 ) { // Parse name int num_chars; num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_NAME @%d %s", &num_chars, temp_name ); if( num_read != 2 ) num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_NAME %d %s", &num_chars, temp_name ); if( num_read != 2 ) return MB_FAILURE; // Put the name on the entity name_tag = std::string( temp_name, num_chars ); } else if( strncmp( records[current_attrib].att_string.c_str(), "ENTITY_ID", 9 ) == 0 ) { // Parse id int bounding_uid, bounding_sense; num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_ID 0 3 %d %d %d", &id, &bounding_uid, &bounding_sense ); if( 3 != num_read ) { // Try reading updated entity_id format, which has coordinate triple embedded in it // too float dumx, dumy, dumz; num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_ID 3 %f %f %f 3 %d %d %d", &dumx, &dumy, &dumz, &id, &bounding_uid, &bounding_sense ); num_read -= 3; } if( 3 != num_read ) std::cout << "Warning: bad ENTITY_ID attribute in .sat file, record number " << entity_rec_num << ", record follows:" << std::endl << records[current_attrib].att_string.c_str() << std::endl; } else if( strncmp( records[current_attrib].att_string.c_str(), "UNIQUE_ID", 9 ) == 0 ) { // Parse uid if( major >= 14 ) // Change of format for cubit 14: num_read = sscanf( records[current_attrib].att_string.c_str(), "UNIQUE_ID 0 1 %d", &uid ); else num_read = sscanf( records[current_attrib].att_string.c_str(), "UNIQUE_ID 1 0 1 %d", &uid ); if( 1 != num_read ) return MB_FAILURE; } else if( strncmp( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 UNIQUE_ID", 29 ) == 0 ) { // Parse uid int dum1, dum2, dum3, dum4; num_read = sscanf( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 UNIQUE_ID %d %d %d %d %d", &dum1, &dum2, &dum3, &dum4, &uid ); if( 5 != num_read ) return MB_FAILURE; } else if( strncmp( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID", 29 ) == 0 ) { // Parse id int dum1, dum2, dum3; num_read = sscanf( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID %d %d %d %d", &dum1, &dum2, &dum3, &id ); if( 4 != num_read ) return MB_FAILURE; } else { attrib_vec.push_back( records[current_attrib].att_string ); } records[current_attrib].processed = true; next_attrib = current_attrib; current_attrib = records[current_attrib].att_prev; } // At this point, there aren't entity sets for entity types which don't contain mesh // in this case, just return if( records[entity_rec_num].rec_type == aBODY || ( records[entity_rec_num].entity == 0 && uid == -1 ) ) { return MB_SUCCESS; // Warning: couldn't resolve entity of type 1 because no uid was found. // ddriv: GeomTopoTool.cpp:172: ErrorCode GeomTopoTool::separate_by_dimension(const Range&, // Range*, void**): Assertion `false' failed. xxx } // Parsed the data; now put on mdb entities; first we need to find the entity if( records[entity_rec_num].entity == 0 ) { records[entity_rec_num].entity = uidSetMap[uid]; } if( 0 == records[entity_rec_num].entity ) return MB_SUCCESS; // We do not have a MOAB entity for this, skip // assert(records[entity_rec_num].entity); // Set the id if( id != -1 ) { result = mdbImpl->tag_set_data( globalIdTag, &( records[entity_rec_num].entity ), 1, &id ); if( MB_SUCCESS != result ) return result; int ent_dim = -1; if( records[entity_rec_num].rec_type == aBODY ) ent_dim = 4; else if( records[entity_rec_num].rec_type == LUMP ) ent_dim = 3; else if( records[entity_rec_num].rec_type == FACE ) ent_dim = 2; else if( records[entity_rec_num].rec_type == aEDGE ) ent_dim = 1; else if( records[entity_rec_num].rec_type == aVERTEX ) ent_dim = 0; if( -1 != ent_dim ) gidSetMap[ent_dim][id] = records[entity_rec_num].entity; } // Set the name if( !name_tag.empty() ) { if( 0 == entityNameTag ) { char dum_val[NAME_TAG_SIZE] = { 0 }; result = mdbImpl->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, entityNameTag, MB_TAG_SPARSE | MB_TAG_CREAT, dum_val ); if( MB_SUCCESS != result ) return result; } size_t len = name_tag.size(); if( len >= NAME_TAG_SIZE ) len = NAME_TAG_SIZE - 1; // Truncate a name that is too big memcpy( name_tag_val, name_tag.c_str(), len ); memset( name_tag_val + len, '\0', NAME_TAG_SIZE - len ); result = mdbImpl->tag_set_data( entityNameTag, &( records[entity_rec_num].entity ), 1, name_tag_val ); if( MB_SUCCESS != result ) return result; } if( !attrib_vec.empty() ) { // Put the attrib vector in a tag on the entity std::vector< std::string >* dum_vec; result = mdbImpl->tag_get_data( attribVectorTag, &( records[entity_rec_num].entity ), 1, &dum_vec ); if( MB_SUCCESS != result && MB_TAG_NOT_FOUND != result ) return result; if( MB_TAG_NOT_FOUND == result || dum_vec == NULL ) { // Put this list directly on the entity dum_vec = new std::vector< std::string >; dum_vec->swap( attrib_vec ); result = mdbImpl->tag_set_data( attribVectorTag, &( records[entity_rec_num].entity ), 1, &dum_vec ); if( MB_SUCCESS != result ) { delete dum_vec; return result; } } else { // Copy this list over, and delete this list std::copy( attrib_vec.begin(), attrib_vec.end(), std::back_inserter( *dum_vec ) ); } } return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::process_record | ( | AcisRecord & | this_record | ) | [private] |
Definition at line 2720 of file Tqdcfr.cpp.
References aBODY, aEDGE, moab::Tqdcfr::AcisRecord::att_ent_num, moab::Tqdcfr::AcisRecord::att_next, moab::Tqdcfr::AcisRecord::att_prev, moab::Tqdcfr::AcisRecord::att_string, ATTRIB, aVERTEX, FACE, moab::Tqdcfr::AcisRecord::first_attrib, LUMP, MB_SUCCESS, printedSeqWarning, moab::Tqdcfr::AcisRecord::rec_type, and UNKNOWN.
Referenced by read_acis_records().
{ // Get the entity type const char* type_substr; // Try attribs first, since the others have some common processing between them if( ( type_substr = strstr( this_record.att_string.c_str(), "attrib" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { this_record.rec_type = Tqdcfr::ATTRIB; bool simple_attrib = false; bool generic_attrib = false; if( ( type_substr = strstr( this_record.att_string.c_str(), "simple-snl-attrib" ) ) != NULL ) simple_attrib = true; else if( ( type_substr = strstr( this_record.att_string.c_str(), "integer_attrib-name_attrib-gen-attrib" ) ) != NULL ) generic_attrib = true; else { this_record.rec_type = Tqdcfr::UNKNOWN; return MB_SUCCESS; } // Find next space type_substr = strchr( type_substr, ' ' ); if( NULL == type_substr ) return MB_FAILURE; // Read the numbers from there int num_converted = sscanf( type_substr, " $-1 -1 $%d $%d $%d -1", &( this_record.att_prev ), &( this_record.att_next ), &( this_record.att_ent_num ) ); if( num_converted != 3 ) return MB_FAILURE; // Trim the string to the attribute, if it's a simple attrib if( simple_attrib ) { type_substr = strstr( this_record.att_string.c_str(), "NEW_SIMPLE_ATTRIB" ); if( NULL == type_substr ) return MB_FAILURE; type_substr = strstr( type_substr, "@" ); if( NULL == type_substr ) return MB_FAILURE; type_substr = strstr( type_substr, " " ) + 1; // Copy the rest of the string to a dummy string std::string dum_str( type_substr ); this_record.att_string = dum_str; } else if( generic_attrib ) { type_substr = strstr( this_record.att_string.c_str(), "CUBIT_ID" ); if( NULL == type_substr ) return MB_FAILURE; // Copy the rest of the string to a dummy string std::string dum_str( type_substr ); this_record.att_string = dum_str; } } else { // Else it's a topological entity, I think if( ( type_substr = strstr( this_record.att_string.c_str(), "body" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { this_record.rec_type = Tqdcfr::aBODY; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "lump" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { this_record.rec_type = Tqdcfr::LUMP; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "shell" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { // Don't care about shells this_record.rec_type = Tqdcfr::UNKNOWN; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "surface" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { // Don't care about surfaces this_record.rec_type = Tqdcfr::UNKNOWN; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "face" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { this_record.rec_type = Tqdcfr::FACE; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "loop" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { // Don't care about loops this_record.rec_type = Tqdcfr::UNKNOWN; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "coedge" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { // Don't care about coedges this_record.rec_type = Tqdcfr::UNKNOWN; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "edge" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { this_record.rec_type = Tqdcfr::aEDGE; } else if( ( type_substr = strstr( this_record.att_string.c_str(), "vertex" ) ) != NULL && type_substr - this_record.att_string.c_str() < 20 ) { this_record.rec_type = Tqdcfr::aVERTEX; } else this_record.rec_type = Tqdcfr::UNKNOWN; if( this_record.rec_type != Tqdcfr::UNKNOWN ) { // Print a warning if it looks like there are sequence numbers if( type_substr != this_record.att_string.c_str() && !printedSeqWarning ) { std::cout << "Warning: acis file has sequence numbers!" << std::endl; printedSeqWarning = true; } // Scan ahead to the next white space type_substr = strchr( type_substr, ' ' ); if( NULL == type_substr ) return MB_FAILURE; // Get the id of the first attrib int num_converted = sscanf( type_substr, " $%d", &( this_record.first_attrib ) ); if( num_converted != 1 ) return MB_FAILURE; } } return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::process_sideset_10 | ( | const int | this_type, |
const int | num_ents, | ||
const int | sense_size, | ||
std::vector< EntityHandle > & | ss_entities, | ||
Tqdcfr::SidesetHeader * | sideseth | ||
) | [private] |
process entities in a sideset according to sense flags stored in uint_buf or char_buf (depending on sense_size)
Definition at line 843 of file Tqdcfr.cpp.
References moab::Interface::add_entities(), char_buf, create_set(), ErrorCode, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_INTEGER, mdbImpl, moab::Tqdcfr::SidesetHeader::setHandle, moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), and uint_buf.
Referenced by read_sideset().
{ std::vector< EntityHandle > forward, reverse; if( this_type == 3 // Surface && sense_size == 1 // Byte size ) { // Interpret sense flags w/o reference to anything for( int i = 0; i < num_ents; i++ ) { if( (int)char_buf[i] == 0 ) forward.push_back( ss_entities[i] ); else if( (int)char_buf[i] == 1 ) reverse.push_back( ss_entities[i] ); else if( (int)char_buf[i] == -1 ) { // -1 means "unknown", which means both forward.push_back( ss_entities[i] ); reverse.push_back( ss_entities[i] ); } } } else if( this_type == 4 // Curve && sense_size == 2 // int32 size ) { for( int i = 0; i < num_ents; i++ ) { if( uint_buf[i] == 0 ) forward.push_back( ss_entities[i] ); else if( uint_buf[i] == 1 ) reverse.push_back( ss_entities[i] ); else if( *( (int*)&uint_buf[i] ) == -1 ) { // -1 means "unknown", which means both forward.push_back( ss_entities[i] ); reverse.push_back( ss_entities[i] ); } } } // Now actually put them in the set ErrorCode result = MB_SUCCESS; if( !forward.empty() ) { ErrorCode tmp_result = mdbImpl->add_entities( sideseth->setHandle, &forward[0], forward.size() ); if( tmp_result != MB_SUCCESS ) result = tmp_result; } if( !reverse.empty() ) { // Need to make a new set, add a reverse sense tag, then add to the sideset EntityHandle reverse_set; ErrorCode tmp_result = create_set( reverse_set ); if( MB_SUCCESS != tmp_result ) result = tmp_result; tmp_result = mdbImpl->add_entities( reverse_set, &reverse[0], reverse.size() ); if( tmp_result != MB_SUCCESS ) result = tmp_result; int def_val = 1; Tag sense_tag; tmp_result = mdbImpl->tag_get_handle( "NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag, MB_TAG_SPARSE | MB_TAG_CREAT, &def_val ); if( tmp_result != MB_SUCCESS ) result = tmp_result; def_val = -1; tmp_result = mdbImpl->tag_set_data( sense_tag, &reverse_set, 1, &def_val ); if( tmp_result != MB_SUCCESS ) result = tmp_result; tmp_result = mdbImpl->add_entities( sideseth->setHandle, &reverse_set, 1 ); if( tmp_result != MB_SUCCESS ) result = tmp_result; } return result; }
ErrorCode moab::Tqdcfr::process_sideset_11 | ( | std::vector< EntityHandle > & | ss_entities, |
int | num_wrts, | ||
Tqdcfr::SidesetHeader * | sideseth | ||
) | [private] |
Definition at line 916 of file Tqdcfr.cpp.
References moab::Interface::add_entities(), char_buf, create_set(), ErrorCode, MB_ALREADY_ALLOCATED, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_INTEGER, mdbImpl, moab::Tqdcfr::SidesetHeader::setHandle, moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), and uint_buf.
Referenced by read_sideset().
{ std::vector< EntityHandle > forward, reverse; unsigned int num_ents = ss_entities.size(); unsigned int* wrt_it = &uint_buf[0]; for( unsigned int i = 0; i < num_ents; i++ ) { unsigned int num_wrt = 0; if( 0 != num_wrts ) num_wrt = *wrt_it++; for( unsigned int j = 0; j < num_wrt; j++ ) wrt_it += 2; // Assume here that if it's in the list twice, we get both senses if( num_wrt > 1 ) { forward.push_back( ss_entities[i] ); reverse.push_back( ss_entities[i] ); } else { // Else interpret the sense flag if( (int)char_buf[i] == 0 ) forward.push_back( ss_entities[i] ); else if( (int)char_buf[i] == 1 ) reverse.push_back( ss_entities[i] ); else if( (int)char_buf[i] == -1 ) { // -1 means "unknown", which means both forward.push_back( ss_entities[i] ); reverse.push_back( ss_entities[i] ); } } } // Now actually put them in the set ErrorCode result = MB_SUCCESS; if( !forward.empty() ) { ErrorCode tmp_result = mdbImpl->add_entities( sideseth->setHandle, &forward[0], forward.size() ); if( tmp_result != MB_SUCCESS ) result = tmp_result; } if( !reverse.empty() ) { // Need to make a new set, add a reverse sense tag, then add to the sideset EntityHandle reverse_set; ErrorCode tmp_result = create_set( reverse_set ); if( MB_SUCCESS != tmp_result ) result = tmp_result; tmp_result = mdbImpl->add_entities( reverse_set, &reverse[0], reverse.size() ); if( tmp_result != MB_SUCCESS ) result = tmp_result; int def_val = 1; Tag sense_tag; tmp_result = mdbImpl->tag_get_handle( "NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag, MB_TAG_SPARSE | MB_TAG_CREAT, &def_val ); if( tmp_result != MB_SUCCESS && tmp_result != MB_ALREADY_ALLOCATED ) result = tmp_result; def_val = -1; tmp_result = mdbImpl->tag_set_data( sense_tag, &reverse_set, 1, &def_val ); if( tmp_result != MB_SUCCESS ) result = tmp_result; tmp_result = mdbImpl->add_entities( sideseth->setHandle, &reverse_set, 1 ); if( tmp_result != MB_SUCCESS ) result = tmp_result; } return result; }
ErrorCode moab::Tqdcfr::put_into_set | ( | EntityHandle | set_handle, |
std::vector< EntityHandle > & | entities, | ||
std::vector< EntityHandle > & | excl_entities | ||
) | [private] |
Definition at line 1214 of file Tqdcfr.cpp.
References moab::Interface::add_entities(), ErrorCode, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_OPAQUE, mdbImpl, moab::Interface::tag_get_handle(), and moab::Interface::tag_set_data().
Referenced by read_block(), read_group(), and read_nodeset().
{ // And put entities into this block's set ErrorCode result = mdbImpl->add_entities( set_handle, &entities[0], entities.size() ); if( MB_SUCCESS != result ) return result; // Check for excluded entities, and add them to a vector hung off the block if there Tag excl_tag; if( !excl_entities.empty() ) { result = mdbImpl->tag_get_handle( "Exclude_Entities", sizeof( std::vector< EntityHandle >* ), MB_TYPE_OPAQUE, excl_tag, MB_TAG_SPARSE | MB_TAG_CREAT ); if( MB_SUCCESS != result ) return result; std::vector< EntityHandle >* new_vector = new std::vector< EntityHandle >; new_vector->swap( excl_entities ); result = mdbImpl->tag_set_data( excl_tag, &set_handle, 1, &new_vector ); if( MB_SUCCESS != result ) { delete new_vector; return MB_FAILURE; } } return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::read_acis_records | ( | const char * | sat_file_name = 0 | ) | [private] |
Definition at line 2368 of file Tqdcfr.cpp.
References acisDumpFile, moab::Tqdcfr::AcisRecord::att_string, char_buf, fileTOC, FREADC(), FSEEK(), interpret_acis_records(), MB_SUCCESS, modelEntries, moab::Tqdcfr::FileTOC::numModels, process_record(), and reset_record().
Referenced by load_file().
{ // Get the acis model location unsigned int acis_model_offset = 0, acis_model_length = 0, acis_model_handle = 1, acis_sat_type = 1; for( unsigned int i = 0; i < fileTOC.numModels; i++ ) { if( modelEntries[i].modelHandle == acis_model_handle && modelEntries[i].modelType == acis_sat_type ) { acis_model_offset = modelEntries[i].modelOffset; acis_model_length = modelEntries[i].modelLength; break; } } if( acis_model_length == 0 ) return MB_SUCCESS; std::vector< AcisRecord > records; acisDumpFile = NULL; if( sat_filename ) { acisDumpFile = fopen( sat_filename, "w+" ); if( NULL == acisDumpFile ) return MB_FAILURE; } // Position the file at the start of the acis model FSEEK( acis_model_offset ); unsigned int bytes_left = acis_model_length; struct AcisRecord this_record; reset_record( this_record ); char* ret; // Make the char buffer at least buf_size + 1 long, to fit null char const unsigned int buf_size = 1023; // CHECK_SIZE(char_buf, buf_size + 1); char_buf.resize( buf_size + 1 ); while( 0 != bytes_left ) { // Read the next buff characters, or bytes_left if smaller unsigned int next_buf = ( bytes_left > buf_size ? buf_size : bytes_left ); FREADC( next_buf ); if( NULL != acisDumpFile ) fwrite( &char_buf[0], sizeof( char ), next_buf, acisDumpFile ); // Put null at end of string to stop searches char_buf.resize( next_buf + 1 ); char_buf[next_buf] = '\0'; unsigned int buf_pos = 0; // Check for first read, and if so, get rid of the header if( bytes_left == acis_model_length ) { // Look for 3 newlines ret = strchr( &( char_buf[0] ), '\n' ); ret = strchr( ret + 1, '\n' ); ret = strchr( ret + 1, '\n' ); if( NULL == ret ) return MB_FAILURE; buf_pos += ret - &( char_buf[0] ) + 1; } bytes_left -= next_buf; // Now start grabbing records do { // Get next occurrence of '#' (record terminator) ret = strchr( &( char_buf[buf_pos] ), '#' ); while( ret && (unsigned int)( ret + 1 - &char_buf[0] ) < bytes_left && *( ret + 1 ) != '\n' && *( ret + 1 ) != '\r' && *( ret + 1 ) != 0 ) // CR added for windows ret = strchr( ret + 1, '#' ); if( NULL != ret ) { // Grab the string (inclusive of the record terminator and the line feed) and // complete the record int num_chars = ret - &( char_buf[buf_pos] ) + 2; if( *( ret + 1 ) == '\r' ) num_chars++; // add more one character for Windows CR this_record.att_string.append( &( char_buf[buf_pos] ), num_chars ); buf_pos += num_chars; process_record( this_record ); // Put the record in the list... records.push_back( this_record ); // And reset the record reset_record( this_record ); } else { // Reached end of buffer; cache string then go get another; discard last character, // which will be the null character this_record.att_string.append( &( char_buf[buf_pos] ), next_buf - buf_pos ); buf_pos = next_buf; } } while( buf_pos < next_buf ); } if( NULL != acisDumpFile ) fwrite( "\n======================\nSorted acis records:\n======================\n", 1, 68, acisDumpFile ); // Now interpret the records interpret_acis_records( records ); if( NULL != acisDumpFile ) fclose( acisDumpFile ); return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::read_block | ( | const unsigned int | blindex, |
const double | data_version, | ||
Tqdcfr::ModelEntry * | model, | ||
Tqdcfr::BlockHeader * | blockh | ||
) |
Definition at line 982 of file Tqdcfr.cpp.
References moab::Tqdcfr::BlockHeader::attribOrder, BLOCK_ATTRIBUTES, moab::Tqdcfr::BlockHeader::blockElemType, moab::Tqdcfr::BlockHeader::blockEntityType, moab::Tqdcfr::ModelEntry::blockMD, char_buf, moab::HigherOrderFactory::convert(), CONVERT_TO_INTS(), cub_elem_num_verts, dbl_buf, moab::CN::Dimension(), entities, ErrorCode, FREADC(), FREADD(), FREADI(), FSEEK(), moab::Interface::get_adjacencies(), get_entities(), moab::Interface::get_entities_by_type(), get_names(), moab::Tqdcfr::BlockHeader::hasMidNodes, int_buf, moab::major, MB_ALREADY_ALLOCATED, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TAG_VARLEN, MB_TYPE_DOUBLE, mbcore, MBMAXTYPE, mdbImpl, moab::Tqdcfr::BlockHeader::memCt, moab::Tqdcfr::BlockHeader::memOffset, moab::Tqdcfr::BlockHeader::memTypeCt, moab::Range::merge(), moab::minor, moab::Tqdcfr::ModelEntry::modelOffset, put_into_set(), moab::Tqdcfr::BlockHeader::setHandle, moab::Interface::tag_get_handle(), moab::Interface::tag_set_by_ptr(), uint_buf, moab::Interface::UNION, and moab::CN::VerticesPerEntity().
Referenced by load_file().
{ if( blockh->memCt == 0 ) return MB_SUCCESS; // Position file FSEEK( model->modelOffset + blockh->memOffset ); // Read ids for each entity type unsigned int num_read = 0; int this_type, num_ents; //, uid; std::vector< EntityHandle > block_entities, excl_entities; for( unsigned int i = 0; i < blockh->memTypeCt; i++ ) { // Get how many and what type FREADI( 2 ); num_read += 2 * sizeof( int ); this_type = uint_buf[0]; num_ents = uint_buf[1]; // Now get the ids FREADI( num_ents ); num_read += num_ents * sizeof( int ); CONVERT_TO_INTS( num_ents ); ErrorCode result = get_entities( this_type + 2, &int_buf[0], num_ents, block_entities, excl_entities ); if( MB_SUCCESS != result ) return result; } // And put entities into this block's set ErrorCode result = put_into_set( blockh->setHandle, block_entities, excl_entities ); if( MB_SUCCESS != result ) return result; // Read attribs if there are any Tag block_attribs; { int def_block_attributes_length = 0; result = mdbImpl->tag_get_handle( BLOCK_ATTRIBUTES, def_block_attributes_length, MB_TYPE_DOUBLE, block_attribs, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL ); if( MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result ) return result; } if( blockh->attribOrder > 0 ) { FREADD( blockh->attribOrder ); num_read += sizeof( double ); void const* tag_data[] = { &dbl_buf[0] }; int tag_sizes[] = { static_cast< int >( blockh->attribOrder ) }; result = mdbImpl->tag_set_by_ptr( block_attribs, &( blockh->setHandle ), 1, tag_data, tag_sizes ); if( MB_SUCCESS != result ) return result; } // Check for more data if( num_read < blockh->blockLength ) { FREADC( 2 ); // num_read += 2; if( char_buf[0] == 'i' && char_buf[1] == 'd' ) { FREADI( 1 ); // num_read += sizeof(int); // uid = int_buf[0]; } } result = get_names( model->blockMD, blindex, blockh->setHandle ); if( MB_SUCCESS != result ) return result; // Put additional higher-order nodes into element connectivity list. // Cubit saves full connectivity list only for NodeHex and NodeTet // elements. Other element types will only have the corners and // the mid-element node if there is one. Need to reconstruct additional // connectivity entries from mid-nodes of adjacent lower-order entities. int node_per_elem = cub_elem_num_verts[blockh->blockElemType]; if( blockh->blockEntityType == MBMAXTYPE ) return MB_SUCCESS; if( ( 14 == major && 2 < minor ) || 15 <= major ) { if( 55 == blockh->blockElemType || CN::VerticesPerEntity( blockh->blockEntityType ) == node_per_elem ) return MB_SUCCESS; } else { if( 52 == blockh->blockElemType || CN::VerticesPerEntity( blockh->blockEntityType ) == node_per_elem ) return MB_SUCCESS; } // Can't use Interface::convert_entities because block could contain // both entity sets and entities. convert_entities will fail if block // contains an entity set, but we still need to call it on any elements // directly in the block (rather than a geometry subset). So bypass // Interface and call HOFactory directly with an Range of entities. Range ho_entities, entities; mdbImpl->get_entities_by_type( blockh->setHandle, blockh->blockEntityType, entities, true ); if( CN::Dimension( blockh->blockEntityType ) > 2 ) { result = mdbImpl->get_adjacencies( entities, 2, false, ho_entities, Interface::UNION ); if( MB_SUCCESS != result ) return result; } if( CN::Dimension( blockh->blockEntityType ) > 1 ) { result = mdbImpl->get_adjacencies( entities, 1, false, ho_entities, Interface::UNION ); if( MB_SUCCESS != result ) return result; } entities.merge( ho_entities ); Core* mbcore = dynamic_cast< Core* >( mdbImpl ); assert( mbcore != NULL ); HigherOrderFactory ho_fact( mbcore, 0 ); return ho_fact.convert( entities, !!blockh->hasMidNodes[1], !!blockh->hasMidNodes[2], !!blockh->hasMidNodes[3] ); }
ErrorCode moab::Tqdcfr::read_elements | ( | Tqdcfr::ModelEntry * | model, |
Tqdcfr::GeomHeader * | entity | ||
) |
Definition at line 1545 of file Tqdcfr.cpp.
References moab::Interface::add_entities(), categoryTag, check_contiguous(), CONVERT_TO_INTS(), moab::cub_elem_order_map, cubMOABVertexMap, currElementIdOffset, currVHandleOffset, moab::debug, moab::SequenceManager::DEFAULT_ELEMENT_SEQUENCE_SIZE, moab::CN::Dimension(), moab::Tqdcfr::GeomHeader::elemOffset, moab::Tqdcfr::GeomHeader::elemTypeCt, moab::CN::EntityTypeName(), ErrorCode, FREADI(), FSEEK(), geom_categories, geomTag, moab::ReadUtilIface::get_element_connect(), globalIdTag, moab::Interface::handle_from_id(), moab::Interface::id_from_handle(), int_buf, moab::major, MB_SUCCESS, MBVERTEX, mdbImpl, moab::Tqdcfr::ModelEntry::modelOffset, mp_type_to_mb_type, printedElemWarning, readUtilIface, moab::Tqdcfr::GeomHeader::setHandle, moab::Interface::tag_set_data(), uint_buf, and moab::ReadUtilIface::update_adjacencies().
Referenced by load_file().
{ if( entity->elemTypeCt == 0 ) return MB_SUCCESS; const int in_order_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 }; // Get data in separate calls to minimize memory usage // Position the file FSEEK( model->modelOffset + entity->elemOffset ); int int_type, nodes_per_elem, num_elem; int max_dim = -1; ErrorCode result; for( unsigned int i = 0; i < entity->elemTypeCt; i++ ) { // For this elem type, get the type, nodes per elem, num elems FREADI( 3 ); int_type = uint_buf[0]; nodes_per_elem = uint_buf[1]; num_elem = uint_buf[2]; // Get MB element type from cub file's EntityType elem_type = mp_type_to_mb_type[int_type]; max_dim = ( max_dim < CN::Dimension( elem_type ) ? CN::Dimension( elem_type ) : max_dim ); if( debug ) std::cout << "type " << CN::EntityTypeName( elem_type ) << ":"; const int* node_order = cub_elem_order_map[elem_type][nodes_per_elem]; if( !node_order ) node_order = in_order_map; // Get element ids FREADI( num_elem ); // Check to see if ids are contiguous... int contig; unsigned int max_id, min_id; check_contiguous( num_elem, contig, min_id, max_id ); if( 0 == contig && !printedElemWarning ) { std::cout << "Element ids are not contiguous!" << std::endl; printedElemWarning = true; } // Get a space for reading connectivity data directly into MB EntityHandle *conn, start_handle; result = readUtilIface->get_element_connect( num_elem, nodes_per_elem, elem_type, int_buf[0], start_handle, conn, SequenceManager::DEFAULT_ELEMENT_SEQUENCE_SIZE ); if( MB_SUCCESS != result ) return result; Range dum_range( start_handle, start_handle + num_elem - 1 ); long elem_offset; elem_offset = ( 1 == contig ? start_handle - int_buf[0] : int_buf[num_elem - 1] ); if( -1 == currElementIdOffset[elem_type] ) currElementIdOffset[elem_type] = elem_offset; // Set the gids on elements CONVERT_TO_INTS( num_elem ); result = mdbImpl->tag_set_data( globalIdTag, dum_range, &int_buf[0] ); if( MB_SUCCESS != result ) return result; // Get the connectivity array unsigned int total_conn = num_elem * nodes_per_elem; if( major >= 14 ) FREADI( num_elem ); // We need to skip num_elem in advance, it looks like FREADI( total_conn ); // Post-process connectivity into handles EntityHandle new_handle; int j = 0; for( int e = 0; e < num_elem; ++e ) { for( int k = 0; k < nodes_per_elem; ++k, ++j ) { if( debug ) { if( 0 == j ) std::cout << "Conn="; std::cout << ", " << uint_buf[j]; } if( NULL == cubMOABVertexMap ) new_handle = (EntityHandle)currVHandleOffset + uint_buf[j]; else { assert( uint_buf[j] < cubMOABVertexMap->size() && 0 != ( *cubMOABVertexMap )[uint_buf[j]] ); new_handle = ( *cubMOABVertexMap )[uint_buf[j]]; } #ifndef NDEBUG EntityHandle dum_handle; assert( MB_SUCCESS == mdbImpl->handle_from_id( MBVERTEX, mdbImpl->id_from_handle( new_handle ), dum_handle ) ); #endif conn[e * nodes_per_elem + node_order[k]] = new_handle; } } // Add these elements into the entity's set result = mdbImpl->add_entities( entity->setHandle, dum_range ); if( MB_SUCCESS != result ) return result; // Notify MOAB of the new elements result = readUtilIface->update_adjacencies( start_handle, num_elem, nodes_per_elem, conn ); if( MB_SUCCESS != result ) return result; } // Set the dimension on the geom tag result = mdbImpl->tag_set_data( geomTag, &entity->setHandle, 1, &max_dim ); if( MB_SUCCESS != result ) return result; if( max_dim != -1 ) { result = mdbImpl->tag_set_data( categoryTag, &entity->setHandle, 1, &geom_categories[max_dim] ); if( MB_SUCCESS != result ) return result; } return MB_SUCCESS; }
Definition at line 1730 of file Tqdcfr.cpp.
References moab::Tqdcfr::FileTOC::activeFEModel, cubFile, moab::debug, moab::Tqdcfr::FileTOC::fileEndian, moab::Tqdcfr::FileTOC::fileSchema, fileTOC, FREADI(), FSEEK(), IO_ASSERT, MB_SUCCESS, moab::Tqdcfr::FileTOC::modelMetaDataOffset, moab::Tqdcfr::FileTOC::modelTableOffset, moab::Tqdcfr::FileTOC::numModels, moab::Tqdcfr::FileTOC::print(), swapForEndianness, and uint_buf.
Referenced by load_file().
{ // Read file header FSEEK( 4 ); // Read the first int from the file // If it is 0, it is littleEndian unsigned rval = fread( &fileTOC.fileEndian, sizeof( unsigned int ), 1, cubFile ); IO_ASSERT( rval == 1 ); #ifdef WORDS_BIGENDIAN if( fileTOC.fileEndian == 0 ) swapForEndianness = true; #else if( fileTOC.fileEndian != 0 ) swapForEndianness = true; #endif if( debug ) std::cout << " swapping ? " << swapForEndianness << "\n"; FREADI( 5 ); // fileTOC.fileEndian = uint_buf[0]; fileTOC.fileSchema = uint_buf[0]; fileTOC.numModels = uint_buf[1]; fileTOC.modelTableOffset = uint_buf[2]; fileTOC.modelMetaDataOffset = uint_buf[3]; fileTOC.activeFEModel = uint_buf[4]; if( debug ) fileTOC.print(); return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::read_group | ( | const unsigned int | gr_index, |
Tqdcfr::ModelEntry * | model, | ||
Tqdcfr::GroupHeader * | grouph | ||
) |
Definition at line 1135 of file Tqdcfr.cpp.
References CONVERT_TO_INTS(), entityNameTag, ErrorCode, FREADI(), FSEEK(), get_entities(), moab::Tqdcfr::MetaDataContainer::get_md_entry(), moab::Tqdcfr::ModelEntry::groupMD, moab::Tqdcfr::GroupHeader::grpID, int_buf, MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_OPAQUE, mdbImpl, moab::Tqdcfr::MetaDataContainer::MetaDataEntry::mdStringValue, moab::Tqdcfr::GroupHeader::memOffset, moab::Tqdcfr::GroupHeader::memTypeCt, moab::Tqdcfr::MetaDataContainer::metadataEntries, moab::Tqdcfr::ModelEntry::modelOffset, NAME_TAG_NAME, NAME_TAG_SIZE, put_into_set(), moab::Tqdcfr::GroupHeader::setHandle, moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), and uint_buf.
Referenced by load_file().
{ // Position file FSEEK( model->modelOffset + grouph->memOffset ); char name_tag_data[NAME_TAG_SIZE]; // Read ids for each entity type int this_type, num_ents; std::vector< EntityHandle > grp_entities, excl_entities; for( unsigned int i = 0; i < grouph->memTypeCt; i++ ) { // Get how many and what type FREADI( 2 ); this_type = uint_buf[0]; num_ents = uint_buf[1]; // Now get the ids FREADI( num_ents ); CONVERT_TO_INTS( num_ents ); // Get the entities in this group ErrorCode result = get_entities( this_type, &int_buf[0], num_ents, grp_entities, excl_entities ); if( MB_SUCCESS != result ) return result; } // Now add the entities ErrorCode result = put_into_set( grouph->setHandle, grp_entities, excl_entities ); if( MB_SUCCESS != result ) return result; // Now get group names, if any int md_index = model->groupMD.get_md_entry( grouph->grpID, "NAME" ); if( -1 != md_index ) { MetaDataContainer::MetaDataEntry* md_entry = &( model->groupMD.metadataEntries[md_index] ); if( 0 == entityNameTag ) { memset( name_tag_data, 0, NAME_TAG_SIZE ); result = mdbImpl->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, entityNameTag, MB_TAG_SPARSE | MB_TAG_CREAT, name_tag_data ); if( MB_SUCCESS != result ) return result; } // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE); memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 ); result = mdbImpl->tag_set_data( entityNameTag, &grouph->setHandle, 1, name_tag_data ); if( MB_SUCCESS != result ) return result; // Look for extra names md_index = model->groupMD.get_md_entry( group_index, "NumExtraNames" ); if( -1 != md_index ) { int num_names = model->groupMD.metadataEntries[md_index].mdIntValue; for( int i = 0; i < num_names; i++ ) { std::ostringstream extra_name_label( "ExtraName" ); extra_name_label << i; std::ostringstream moab_extra_name( "EXTRA_" ); moab_extra_name << NAME_TAG_NAME << i; md_index = model->groupMD.get_md_entry( group_index, extra_name_label.str().c_str() ); if( -1 != md_index ) { md_entry = &( model->groupMD.metadataEntries[md_index] ); Tag extra_name_tag; memset( name_tag_data, 0, NAME_TAG_SIZE ); result = mdbImpl->tag_get_handle( moab_extra_name.str().c_str(), NAME_TAG_SIZE, MB_TYPE_OPAQUE, extra_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT, name_tag_data ); if( MB_SUCCESS != result ) return result; // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE); memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 ); result = mdbImpl->tag_set_data( extra_name_tag, &grouph->setHandle, 1, name_tag_data ); } } } } return result; }
ErrorCode moab::Tqdcfr::read_md_string | ( | std::string & | name | ) |
Definition at line 1853 of file Tqdcfr.cpp.
References char_buf, FREADC(), FREADI(), MB_SUCCESS, and uint_buf.
Referenced by read_meta_data().
{ FREADI( 1 ); int str_size = uint_buf[0]; if( str_size > 0 ) { FREADC( str_size ); if( char_buf.size() <= (unsigned int)str_size ) char_buf.resize( str_size + 1 ); char_buf[str_size] = '\0'; name = (char*)&char_buf[0]; // Read pad if any int extra = str_size % sizeof( int ); if( extra ) { // Read extra chars to end of pad str_size = sizeof( int ) - extra; FREADC( str_size ); } } return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::read_meta_data | ( | const unsigned int | metadata_offset, |
Tqdcfr::MetaDataContainer & | mc | ||
) |
Definition at line 1789 of file Tqdcfr.cpp.
References moab::Tqdcfr::MetaDataContainer::compressFlag, dbl_buf, moab::debug, FREADD(), FREADI(), FSEEK(), MB_SUCCESS, moab::Tqdcfr::MetaDataContainer::mdSchema, moab::Tqdcfr::MetaDataContainer::metadataEntries, moab::Tqdcfr::MetaDataContainer::print(), read_md_string(), and uint_buf.
Referenced by load_file(), and moab::Tqdcfr::ModelEntry::read_metadata_info().
{ // Read the metadata header FSEEK( metadata_offset ); FREADI( 3 ); mc.mdSchema = uint_buf[0]; mc.compressFlag = uint_buf[1]; // Allocate space for the entries mc.metadataEntries.resize( uint_buf[2] ); // Now read the metadata values for( unsigned int i = 0; i < mc.metadataEntries.size(); i++ ) { FREADI( 2 ); mc.metadataEntries[i].mdOwner = uint_buf[0]; mc.metadataEntries[i].mdDataType = uint_buf[1]; // Read the name string read_md_string( mc.metadataEntries[i].mdName ); if( mc.metadataEntries[i].mdDataType == 0 ) { // integer FREADI( 1 ); mc.metadataEntries[i].mdIntValue = uint_buf[0]; } else if( mc.metadataEntries[i].mdDataType == 1 ) { // string read_md_string( mc.metadataEntries[i].mdStringValue ); } else if( mc.metadataEntries[i].mdDataType == 2 ) { // double FREADD( 1 ); mc.metadataEntries[i].mdDblValue = dbl_buf[0]; } else if( mc.metadataEntries[i].mdDataType == 3 ) { // int array FREADI( 1 ); mc.metadataEntries[i].mdIntArrayValue.resize( uint_buf[0] ); FREADI( mc.metadataEntries[i].mdIntArrayValue.size() ); std::copy( uint_buf.begin(), uint_buf.begin() + mc.metadataEntries[i].mdIntArrayValue.size(), mc.metadataEntries[i].mdIntArrayValue.begin() ); } else if( mc.metadataEntries[i].mdDataType == 4 ) { // double array FREADI( 1 ); mc.metadataEntries[i].mdDblArrayValue.resize( uint_buf[0] ); FREADD( mc.metadataEntries[i].mdDblArrayValue.size() ); std::copy( dbl_buf.begin(), dbl_buf.begin() + mc.metadataEntries[i].mdDblArrayValue.size(), mc.metadataEntries[i].mdDblArrayValue.begin() ); } else return MB_FAILURE; } if( debug ) mc.print(); return MB_SUCCESS; }
Definition at line 1756 of file Tqdcfr.cpp.
References moab::debug, fileTOC, FREADI(), FSEEK(), MB_SUCCESS, modelEntries, moab::Tqdcfr::FileTOC::modelTableOffset, moab::Tqdcfr::FileTOC::numModels, and uint_buf.
Referenced by load_file().
{ // Read model entries FSEEK( fileTOC.modelTableOffset ); FREADI( fileTOC.numModels * 6 ); modelEntries.resize( fileTOC.numModels ); if( modelEntries.empty() ) return MB_FAILURE; std::vector< unsigned int >::iterator int_it = uint_buf.begin(); for( unsigned int i = 0; i < fileTOC.numModels; i++ ) { modelEntries[i].modelHandle = *int_it++; modelEntries[i].modelOffset = *int_it++; modelEntries[i].modelLength = *int_it++; modelEntries[i].modelType = *int_it++; modelEntries[i].modelOwner = *int_it++; modelEntries[i].modelPad = *int_it++; if( int_it == uint_buf.end() && i != fileTOC.numModels - 1 ) return MB_FAILURE; if( debug ) modelEntries[i].print(); } return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::read_nodes | ( | const unsigned int | gindex, |
Tqdcfr::ModelEntry * | model, | ||
Tqdcfr::GeomHeader * | entity | ||
) |
Definition at line 1371 of file Tqdcfr.cpp.
References moab::Interface::add_entities(), beforeEnts, moab::Range::begin(), categoryTag, check_contiguous(), CONVERT_TO_INTS(), cubMOABVertexMap, currVHandleOffset, moab::debug, moab::SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE, moab::Range::empty(), moab::Range::end(), ErrorCode, FREADDA(), FREADI(), FSEEK(), geom_categories, geomTag, moab::Interface::get_entities_by_type(), moab::Tqdcfr::MetaDataContainer::get_md_entry(), moab::ReadUtilIface::get_node_coords(), globalIdTag, int_buf, moab::MAX(), MB_SUCCESS, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_INTEGER, MBVERTEX, mdbImpl, moab::Tqdcfr::MetaDataContainer::MetaDataEntry::mdDataType, moab::Tqdcfr::MetaDataContainer::MetaDataEntry::mdIntArrayValue, moab::Range::merge(), moab::Tqdcfr::MetaDataContainer::metadataEntries, moab::Tqdcfr::ModelEntry::modelOffset, moab::Tqdcfr::GeomHeader::nodeCt, moab::Tqdcfr::ModelEntry::nodeMD, moab::Tqdcfr::GeomHeader::nodeOffset, moab::Range::rbegin(), readUtilIface, RR, moab::Tqdcfr::GeomHeader::setHandle, size, moab::Range::subset_by_type(), moab::subtract(), moab::Interface::tag_get_handle(), moab::Interface::tag_set_data(), and uint_buf.
Referenced by load_file().
{ if( entity->nodeCt == 0 ) { if( debug ) std::cout << "(no nodes) "; return MB_SUCCESS; } // Get the ids & coords in separate calls to minimize memory usage // Position the file FSEEK( model->modelOffset + entity->nodeOffset ); // Get node ids in uint_buf FREADI( entity->nodeCt ); if( debug ) { std::cout << "("; for( unsigned int i = 0; i < entity->nodeCt; i++ ) { std::cout << uint_buf[i]; if( i != entity->nodeCt - 1 ) std::cout << ", "; } std::cout << ")..."; } // Get a space for reading nodal data directly into MB, and read that data EntityHandle vhandle = 0; std::vector< double* > arrays; readUtilIface->get_node_coords( 3, entity->nodeCt, uint_buf[0], vhandle, arrays, SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE ); // Get node x's in arrays[0] FREADDA( entity->nodeCt, arrays[0] ); // Get node y's in arrays[1] FREADDA( entity->nodeCt, arrays[1] ); // Get node z's in arrays[2] FREADDA( entity->nodeCt, arrays[2] ); // Add these nodes into the entity's set Range dum_range( vhandle, vhandle + entity->nodeCt - 1 ); ErrorCode result = mdbImpl->add_entities( entity->setHandle, dum_range ); if( MB_SUCCESS != result ) return result; // Check for id contiguity; know that cid's will never be > 32bit, so // ids can be unsigned int unsigned int max_cid, min_cid; int contig; check_contiguous( entity->nodeCt, contig, min_cid, max_cid ); // Compute the offset we get in this batch and compare to any previous one long vhandle_offset = vhandle - min_cid; if( -1 == currVHandleOffset ) currVHandleOffset = vhandle_offset; // In 2 situations we'll need to add/modify a cubit_id -> vhandle map: // case A: no map yet, and either this offset different from // previous or not contiguous if( !cubMOABVertexMap && ( currVHandleOffset != vhandle_offset || !contig ) ) { // Get all vertices, removing ones in this batch Range vrange, tmp_range( dum_range ); result = mdbImpl->get_entities_by_type( 0, MBVERTEX, vrange );RR; if( !beforeEnts.empty() ) tmp_range.merge( beforeEnts.subset_by_type( MBVERTEX ) ); vrange = subtract( vrange, tmp_range ); // Compute the max cid; map is indexed by cid, so size is max_cid + 1 #define MAX( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) ) #define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) ) // Sanity check that max vhandle is larger than offset long new_max = *vrange.rbegin() - currVHandleOffset; assert( new_max >= 0 && ( (long)*vrange.begin() ) - currVHandleOffset >= 0 ); max_cid = MAX( max_cid, ( (unsigned int)new_max ) ); cubMOABVertexMap = new std::vector< EntityHandle >( max_cid + 1 ); // Initialize to zero then put previous vertices into the map std::fill( cubMOABVertexMap->begin(), cubMOABVertexMap->end(), 0 ); Range::iterator rit; for( rit = vrange.begin(); rit != vrange.end(); ++rit ) { assert( ( (long)*rit ) - currVHandleOffset >= 0 && ( (long)*rit ) - currVHandleOffset <= max_cid ); ( *cubMOABVertexMap )[*rit - currVHandleOffset] = *rit; } } // case B: there is a map and we need to resize it else if( cubMOABVertexMap && max_cid + 1 > cubMOABVertexMap->size() ) { unsigned int old_size = cubMOABVertexMap->size(); cubMOABVertexMap->resize( max_cid + 1 ); std::fill( &( *cubMOABVertexMap )[old_size], &( *cubMOABVertexMap )[0] + cubMOABVertexMap->size(), 0 ); } // OK, we have a map or don't need one if( NULL == cubMOABVertexMap ) { // If we're not forward-contiguous (i.e. we're reverse or // out-of-order contiguous), re-order coordinates for handles // so that they are if( -1 == contig || -2 == contig ) { // In case the arrays are large, do each coord separately std::vector< double > tmp_coords( entity->nodeCt ); for( unsigned int j = 0; j < 3; j++ ) { // Permute the coords into new order for( unsigned int i = 0; i < entity->nodeCt; i++ ) { assert( uint_buf[i] >= min_cid && max_cid - uint_buf[i] < entity->nodeCt ); tmp_coords[uint_buf[i] - min_cid] = arrays[j][i]; } // Copy the permuted to storage std::copy( &tmp_coords[0], &tmp_coords[0] + entity->nodeCt, arrays[j] ); } // Now re-order the ids; either way just go off min, max cid for( unsigned int i = 0; i < entity->nodeCt; i++ ) uint_buf[i] = min_cid + i; } else if( !contig ) // Shouldn't get here, since in non-contiguous case map should be there assert( false ); } else { // Put new vertices into the map // Now set the new values unsigned int* vit = &uint_buf[0]; Range::iterator rit = dum_range.begin(); for( ; rit != dum_range.end(); vit++, ++rit ) { assert( *vit < cubMOABVertexMap->size() ); ( *cubMOABVertexMap )[*vit] = *rit; } } // No longer need to use uint_buf; convert in-place to ints, so we // can assign gid tag CONVERT_TO_INTS( entity->nodeCt ); result = mdbImpl->tag_set_data( globalIdTag, dum_range, &int_buf[0] ); if( MB_SUCCESS != result ) return result; // Set the dimension to at least zero (entity has at least nodes) on the geom tag int max_dim = 0; result = mdbImpl->tag_set_data( geomTag, &( entity->setHandle ), 1, &max_dim ); if( MB_SUCCESS != result ) return result; // Set the category tag just in case there're only vertices in this set result = mdbImpl->tag_set_data( categoryTag, &entity->setHandle, 1, &geom_categories[0] ); if( MB_SUCCESS != result ) return result; // Get fixed node data and assign int md_index = model->nodeMD.get_md_entry( gindex, "FixedNodes" ); if( -1 == md_index ) return MB_SUCCESS; MetaDataContainer::MetaDataEntry* md_entry = &( model->nodeMD.metadataEntries[md_index] ); std::vector< int > fixed_flags( entity->nodeCt ); std::fill( fixed_flags.begin(), fixed_flags.end(), 0 ); if( md_entry->mdDataType != 3 ) return MB_FAILURE; for( std::vector< unsigned int >::iterator vit = md_entry->mdIntArrayValue.begin(); vit != md_entry->mdIntArrayValue.end(); ++vit ) { #ifndef NDEBUG EntityHandle fixed_v = ( cubMOABVertexMap ? ( *cubMOABVertexMap )[*vit] : (EntityHandle)currVHandleOffset + *vit ); assert( fixed_v >= *dum_range.begin() && fixed_v <= *dum_range.rbegin() ); #endif fixed_flags[*vit - *dum_range.begin()] = 1; } Tag fixedFlagTag; int dum_val = 0; result = mdbImpl->tag_get_handle( "NodeFixed", 1, MB_TYPE_INTEGER, fixedFlagTag, MB_TAG_SPARSE | MB_TAG_CREAT, &dum_val ); if( MB_SUCCESS != result ) return result; result = mdbImpl->tag_set_data( fixedFlagTag, dum_range, &fixed_flags[0] ); return result; }
ErrorCode moab::Tqdcfr::read_nodeset | ( | const unsigned int | nsindex, |
Tqdcfr::ModelEntry * | model, | ||
Tqdcfr::NodesetHeader * | nodeseth | ||
) |
Definition at line 583 of file Tqdcfr.cpp.
References char_buf, CONVERT_TO_INTS(), moab::debug, DIRICHLET_SET_TAG_NAME, ErrorCode, FREADC(), FREADCA(), FREADI(), FSEEK(), get_entities(), get_names(), int_buf, MB_SUCCESS, MB_TAG_BYTES, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TAG_VARLEN, MB_TYPE_OPAQUE, mdbImpl, moab::Tqdcfr::NodesetHeader::memOffset, moab::Tqdcfr::NodesetHeader::memTypeCt, moab::Tqdcfr::ModelEntry::modelOffset, moab::Tqdcfr::ModelEntry::nodesetMD, moab::Tqdcfr::NodesetHeader::print(), put_into_set(), moab::Tqdcfr::NodesetHeader::setHandle, moab::Interface::tag_get_handle(), moab::Interface::tag_set_by_ptr(), and uint_buf.
Referenced by load_file().
{ if( nodeseth->memTypeCt == 0 ) return MB_SUCCESS; // Position file FSEEK( model->modelOffset + nodeseth->memOffset ); // Read ids for each entity type unsigned int this_type, num_ents; //, uid; std::vector< char > bc_data; unsigned int num_read = 0; std::vector< EntityHandle > ns_entities, excl_entities; for( unsigned int i = 0; i < nodeseth->memTypeCt; i++ ) { // Get how many and what type FREADI( 2 ); num_read += 2 * sizeof( int ); this_type = uint_buf[0]; num_ents = uint_buf[1]; // Now get the ids FREADI( num_ents ); num_read += sizeof( int ); CONVERT_TO_INTS( num_ents ); ErrorCode result = get_entities( this_type + 2, &int_buf[0], num_ents, ns_entities, excl_entities ); if( MB_SUCCESS != result ) return result; } // Check for more data if( num_read < nodeseth->nsLength ) { FREADC( 2 ); // num_read += 2; if( char_buf[0] == 'i' && char_buf[1] == 'd' ) { FREADI( 1 ); // num_read += sizeof(int); // uid = int_buf[0]; } else { if( char_buf[0] == 'b' && char_buf[1] == 'c' ) { FREADI( 1 ); // num_read += sizeof(int); int num_bcs = uint_buf[0]; bc_data.resize( num_bcs ); FREADCA( num_bcs, &bc_data[0] ); // num_read += num_bcs; } } } if( debug ) { nodeseth->print(); if( !bc_data.empty() ) { std::cout << "bc_data = "; std::vector< char >::iterator vit = bc_data.begin(); for( ; vit != bc_data.end(); ++vit ) { std::cout << std::hex << (int)( (unsigned char)*vit ) << " "; } std::cout << ": "; vit = bc_data.begin(); for( ; vit != bc_data.end(); ++vit ) { std::cout << *vit; } std::cout << std::endl; } } // And put entities into this nodeset's set ErrorCode result = put_into_set( nodeseth->setHandle, ns_entities, excl_entities ); if( MB_SUCCESS != result ) return result; result = get_names( model->nodesetMD, nsindex, nodeseth->setHandle ); if( MB_SUCCESS != result ) return result; const int def_bc_data_len = 0; std::string tag_name = std::string( DIRICHLET_SET_TAG_NAME ) + "__BC_DATA"; Tag nbc_data; result = mdbImpl->tag_get_handle( tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nbc_data, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL ); if( MB_SUCCESS != result ) return result; void const* tag_data[] = { ( bc_data.empty() ) ? NULL : &( bc_data[0] ) }; int tag_size = bc_data.size(); result = mdbImpl->tag_set_by_ptr( nbc_data, &nodeseth->setHandle, 1, tag_data, &tag_size ); if( MB_SUCCESS != result ) return result; return result; }
ErrorCode moab::Tqdcfr::read_sideset | ( | const unsigned int | ssindex, |
const double | data_version, | ||
Tqdcfr::ModelEntry * | model, | ||
Tqdcfr::SidesetHeader * | sideseth | ||
) |
Definition at line 674 of file Tqdcfr.cpp.
References char_buf, CONVERT_TO_INTS(), dbl_buf, moab::debug, ErrorCode, FREADC(), FREADCA(), FREADD(), FREADI(), FREADIA(), FSEEK(), get_entities(), get_names(), int_buf, MB_SUCCESS, MB_TAG_BYTES, MB_TAG_CREAT, MB_TAG_SPARSE, MB_TAG_VARLEN, MB_TYPE_DOUBLE, MB_TYPE_OPAQUE, mdbImpl, moab::Tqdcfr::SidesetHeader::memCt, moab::Tqdcfr::SidesetHeader::memOffset, moab::Tqdcfr::SidesetHeader::memTypeCt, moab::Tqdcfr::ModelEntry::modelOffset, NEUMANN_SET_TAG_NAME, moab::Tqdcfr::SidesetHeader::numDF, moab::Tqdcfr::SidesetHeader::print(), process_sideset_10(), process_sideset_11(), moab::Tqdcfr::SidesetHeader::setHandle, moab::Tqdcfr::ModelEntry::sidesetMD, moab::Interface::tag_get_handle(), moab::Interface::tag_set_by_ptr(), and uint_buf.
Referenced by load_file().
{ if( sideseth->memCt == 0 ) return MB_SUCCESS; ErrorCode result; // Position file FSEEK( model->modelOffset + sideseth->memOffset ); // Read ids for each entity type unsigned int this_type, num_ents, sense_size; std::vector< char > bc_data; unsigned int num_read = 0; //, uid; std::vector< EntityHandle > ss_entities, excl_entities; if( data_version <= 1.0 ) { for( unsigned int i = 0; i < sideseth->memTypeCt; i++ ) { // Get how many and what type FREADI( 3 ); num_read += 3 * sizeof( int ); this_type = uint_buf[0]; num_ents = uint_buf[1]; sense_size = uint_buf[2]; // Now get the ids FREADI( num_ents ); num_read += sizeof( int ); CONVERT_TO_INTS( num_ents ); result = get_entities( this_type + 2, &int_buf[0], num_ents, ss_entities, excl_entities ); if( MB_SUCCESS != result ) return result; if( sense_size == 1 ) { // Byte-size sense flags; make sure read ends aligned... unsigned int read_length = ( num_ents / 8 ) * 8; if( read_length < num_ents ) read_length += 8; FREADC( read_length ); num_read += read_length; } else if( sense_size == 2 ) { // Int-size sense flags FREADI( num_ents ); num_read += sizeof( int ); } // Now do something with them... process_sideset_10( this_type, num_ents, sense_size, ss_entities, sideseth ); } } else { for( unsigned int i = 0; i < sideseth->memTypeCt; i++ ) { // Get how many and what type FREADI( 1 ); num_read += sizeof( int ); num_ents = uint_buf[0]; // Get the types, and ids std::vector< unsigned int > mem_types( num_ents ), mem_ids( num_ents ); FREADIA( num_ents, &mem_types[0] ); num_read += num_ents * sizeof( int ); FREADI( num_ents ); num_read += sizeof( int ); result = get_entities( &mem_types[0], &int_buf[0], num_ents, false, ss_entities ); if( MB_SUCCESS != result ) return result; // Byte-size sense flags; make sure read ends aligned... unsigned int read_length = ( num_ents / 8 ) * 8; if( read_length < num_ents ) read_length += 8; FREADC( read_length ); num_read += read_length; // wrt entities FREADI( 1 ); num_read += sizeof( int ); int num_wrts = uint_buf[0]; FREADI( num_wrts ); num_read += num_wrts * sizeof( int ); result = process_sideset_11( ss_entities, num_wrts, sideseth ); if( MB_SUCCESS != result ) return result; } } // Now set the dist factors if( sideseth->numDF > 0 ) { // Have to read dist factors FREADD( sideseth->numDF ); num_read += sideseth->numDF * sizeof( double ); Tag distFactorTag; result = mdbImpl->tag_get_handle( "distFactor", 0, MB_TYPE_DOUBLE, distFactorTag, MB_TAG_SPARSE | MB_TAG_VARLEN | MB_TAG_CREAT ); if( MB_SUCCESS != result ) return result; const void* dist_data = &dbl_buf[0]; const int dist_size = sideseth->numDF; result = mdbImpl->tag_set_by_ptr( distFactorTag, &sideseth->setHandle, 1, &dist_data, &dist_size ); if( MB_SUCCESS != result ) return result; } // Check for more data if( data_version > 1.0 && num_read < sideseth->ssLength ) { FREADC( 2 ); // num_read += 2; if( char_buf[0] == 'i' && char_buf[1] == 'd' ) { FREADI( 1 ); // num_read += sizeof(int); // uid = int_buf[0]; } else { // Check for bc_data if( char_buf[0] == 'b' && char_buf[1] == 'c' ) { FREADI( 1 ); // num_read += sizeof(int); int num_bcs = uint_buf[0]; bc_data.resize( num_bcs ); FREADCA( num_bcs, &bc_data[0] ); // num_read += num_bcs; } } } if( debug ) { sideseth->print(); if( !bc_data.empty() ) { std::cout << "bc_data = "; std::vector< char >::iterator vit = bc_data.begin(); for( ; vit != bc_data.end(); ++vit ) { std::cout << std::hex << (int)( (unsigned char)*vit ) << " "; } std::cout << ": "; vit = bc_data.begin(); for( ; vit != bc_data.end(); ++vit ) { std::cout << *vit; } std::cout << std::endl; } } result = get_names( model->sidesetMD, ssindex, sideseth->setHandle ); if( MB_SUCCESS != result ) return result; const int def_bc_data_len = 0; std::string tag_name = std::string( NEUMANN_SET_TAG_NAME ) + "__BC_DATA"; Tag nbc_data; result = mdbImpl->tag_get_handle( tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nbc_data, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL ); if( MB_SUCCESS != result ) return result; void const* tag_data[] = { ( bc_data.empty() ) ? NULL : &( bc_data[0] ) }; int tag_size = bc_data.size(); result = mdbImpl->tag_set_by_ptr( nbc_data, &sideseth->setHandle, 1, tag_data, &tag_size ); if( MB_SUCCESS != result ) return result; return MB_SUCCESS; }
ErrorCode moab::Tqdcfr::read_tag_values | ( | const char * | file_name, |
const char * | tag_name, | ||
const FileOptions & | opts, | ||
std::vector< int > & | tag_values_out, | ||
const SubsetList * | subset_list = 0 |
||
) | [virtual] |
Read tag values from a file.
Read the list if all integer tag values from the file for a tag that is a single integer value per entity.
file_name | The file to read. |
tag_name | The tag for which to read values |
tag_values_out | Output: The list of tag values. |
subset_list | An array of tag name and value sets specifying the subset of the file to read. If multiple tags are specified, the sets that match all tags (intersection) should be read. |
subset_list_length | The length of the 'subset_list' array. |
Implements moab::ReaderIface.
Definition at line 287 of file Tqdcfr.cpp.
References MB_NOT_IMPLEMENTED.
{ return MB_NOT_IMPLEMENTED; }
ErrorCode moab::Tqdcfr::reset_record | ( | AcisRecord & | this_record | ) | [private] |
Definition at line 2709 of file Tqdcfr.cpp.
References moab::Tqdcfr::AcisRecord::att_ent_num, moab::Tqdcfr::AcisRecord::att_next, moab::Tqdcfr::AcisRecord::att_prev, moab::Tqdcfr::AcisRecord::att_string, moab::Tqdcfr::AcisRecord::entity, moab::Tqdcfr::AcisRecord::first_attrib, MB_SUCCESS, moab::Tqdcfr::AcisRecord::processed, moab::Tqdcfr::AcisRecord::rec_type, and UNKNOWN.
Referenced by read_acis_records().
{ this_record.rec_type = Tqdcfr::UNKNOWN; this_record.att_string.clear(); this_record.first_attrib = this_record.att_prev = this_record.att_next = this_record.att_ent_num = -1; this_record.processed = false; this_record.entity = 0; return MB_SUCCESS; }
EntityType moab::Tqdcfr::type_from_cub_type | ( | const unsigned int | cub_type, |
const unsigned int | nodes_per_elem | ||
) |
FILE* moab::Tqdcfr::acisDumpFile [private] |
Definition at line 361 of file Tqdcfr.hpp.
Referenced by parse_acis_attribs(), and read_acis_records().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by interpret_acis_records(), parse_acis_attribs(), and ~Tqdcfr().
Definition at line 280 of file Tqdcfr.hpp.
Referenced by load_file(), and read_nodes().
const EntityType moab::Tqdcfr::block_type_to_mb_type [static, private] |
{ MBVERTEX, MBEDGE, MBEDGE, MBEDGE, MBEDGE, MBEDGE, MBEDGE, MBEDGE, MBEDGE, MBEDGE, MBEDGE, MBTRI, MBTRI, MBTRI, MBTRI, MBTRI, MBTRI, MBTRI, MBTRI, MBQUAD, MBQUAD, MBQUAD, MBQUAD, MBQUAD, MBQUAD, MBQUAD, MBQUAD, MBQUAD, MBTET, MBTET, MBTET, MBTET, MBTET, MBPYRAMID, MBPYRAMID, MBPYRAMID, MBPYRAMID, MBPYRAMID, MBHEX, MBHEX, MBHEX, MBHEX, MBHEX, MBHEX, MBMAXTYPE }
Definition at line 433 of file Tqdcfr.hpp.
Referenced by moab::Tqdcfr::BlockHeader::read_info_header().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by convert_nodesets_sidesets(), moab::Tqdcfr::ModelEntry::read_header_info(), moab::Tqdcfr::BlockHeader::read_info_header(), and Tqdcfr().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by read_elements(), moab::Tqdcfr::GeomHeader::read_info_header(), moab::Tqdcfr::GroupHeader::read_info_header(), moab::Tqdcfr::BlockHeader::read_info_header(), moab::Tqdcfr::NodesetHeader::read_info_header(), moab::Tqdcfr::SidesetHeader::read_info_header(), and read_nodes().
std::vector< char > moab::Tqdcfr::char_buf |
Definition at line 291 of file Tqdcfr.hpp.
Referenced by FREADC(), load_file(), process_sideset_10(), process_sideset_11(), read_acis_records(), read_block(), read_md_string(), read_nodeset(), and read_sideset().
const int moab::Tqdcfr::cub_elem_num_verts [static, private] |
{ 1, 2, 2, 3, 2, 2, 3, 2, 2, 3, 2, 3, 3, 6, 7, 3, 3, 6, 7, 4, 4, 8, 9, 4, 4, 5, 8, 9, 4, 4, 8, 10, 14, 5, 5, 8, 13, 18, 8, 8, 9, 20, 27, 12, 0 }
Definition at line 434 of file Tqdcfr.hpp.
Referenced by read_block(), and moab::Tqdcfr::BlockHeader::read_info_header().
const int moab::Tqdcfr::cub_elem_num_verts_len = sizeof( cub_elem_num_verts ) / sizeof( cub_elem_num_verts[0] ) [static, private] |
Definition at line 435 of file Tqdcfr.hpp.
Referenced by moab::Tqdcfr::BlockHeader::read_info_header().
FILE* moab::Tqdcfr::cubFile |
Definition at line 275 of file Tqdcfr.hpp.
Referenced by FREADCA(), FREADDA(), FREADIA(), FSEEK(), load_file(), and read_file_header().
Definition at line 282 of file Tqdcfr.hpp.
std::vector< EntityHandle >* moab::Tqdcfr::cubMOABVertexMap [private] |
Definition at line 364 of file Tqdcfr.hpp.
Referenced by get_mesh_entities(), read_elements(), read_nodes(), Tqdcfr(), and ~Tqdcfr().
Definition at line 281 of file Tqdcfr.hpp.
Referenced by read_elements(), and Tqdcfr().
Definition at line 279 of file Tqdcfr.hpp.
Referenced by get_mesh_entities(), read_elements(), read_nodes(), and Tqdcfr().
std::vector< double > moab::Tqdcfr::dbl_buf |
Definition at line 290 of file Tqdcfr.hpp.
Referenced by FREADD(), read_block(), read_meta_data(), and read_sideset().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by get_names(), parse_acis_attribs(), read_group(), and Tqdcfr().
Definition at line 276 of file Tqdcfr.hpp.
Referenced by find_model(), load_file(), read_acis_records(), read_file_header(), and read_model_entries().
const char moab::Tqdcfr::geom_categories = { "Vertex\0", "Curve\0", "Surface\0", "Volume\0" } [static, private] |
Definition at line 359 of file Tqdcfr.hpp.
Referenced by read_elements(), and read_nodes().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by read_elements(), moab::Tqdcfr::ModelEntry::read_header_info(), moab::Tqdcfr::GeomHeader::read_info_header(), and read_nodes().
std::map< int, EntityHandle > moab::Tqdcfr::gidSetMap[6] |
Definition at line 285 of file Tqdcfr.hpp.
Referenced by get_ref_entities(), parse_acis_attribs(), and moab::Tqdcfr::GroupHeader::read_info_header().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by convert_nodesets_sidesets(), get_mesh_entities(), parse_acis_attribs(), read_elements(), moab::Tqdcfr::ModelEntry::read_header_info(), moab::Tqdcfr::GroupHeader::read_info_header(), moab::Tqdcfr::BlockHeader::read_info_header(), moab::Tqdcfr::NodesetHeader::read_info_header(), moab::Tqdcfr::SidesetHeader::read_info_header(), and read_nodes().
const EntityType moab::Tqdcfr::group_type_to_mb_type [static, private] |
{ MBENTITYSET, MBENTITYSET, MBENTITYSET, MBENTITYSET, MBENTITYSET, MBENTITYSET, MBHEX, MBTET, MBPYRAMID, MBQUAD, MBTRI, MBEDGE, MBVERTEX }
Definition at line 383 of file Tqdcfr.hpp.
Referenced by get_mesh_entities().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by moab::Tqdcfr::BlockHeader::read_info_header().
Definition at line 289 of file Tqdcfr.hpp.
Referenced by CONVERT_TO_INTS(), FREADI(), read_block(), read_elements(), read_group(), read_nodes(), read_nodeset(), and read_sideset().
Definition at line 274 of file Tqdcfr.hpp.
Referenced by convert_nodesets_sidesets(), create_set(), get_mesh_entities(), get_names(), interpret_acis_records(), load_file(), parse_acis_attribs(), process_sideset_10(), process_sideset_11(), put_into_set(), read_block(), read_elements(), read_group(), moab::Tqdcfr::ModelEntry::read_header_info(), moab::Tqdcfr::GeomHeader::read_info_header(), moab::Tqdcfr::GroupHeader::read_info_header(), moab::Tqdcfr::BlockHeader::read_info_header(), moab::Tqdcfr::NodesetHeader::read_info_header(), moab::Tqdcfr::SidesetHeader::read_info_header(), read_nodes(), read_nodeset(), read_sideset(), Tqdcfr(), and ~Tqdcfr().
EntityHandle moab::Tqdcfr::mFileSet [private] |
Definition at line 342 of file Tqdcfr.hpp.
std::vector< ModelEntry > moab::Tqdcfr::modelEntries |
Definition at line 277 of file Tqdcfr.hpp.
Referenced by find_model(), load_file(), read_acis_records(), and read_model_entries().
Definition at line 278 of file Tqdcfr.hpp.
Referenced by load_file().
const EntityType moab::Tqdcfr::mp_type_to_mb_type [static, private] |
{ MBHEX, MBHEX, MBHEX, MBHEX, MBHEX, MBHEX, MBHEX, MBHEX, MBTET, MBTET, MBTET, MBTET, MBTET, MBTET, MBTET, MBTET, MBPYRAMID, MBPYRAMID, MBPYRAMID, MBPYRAMID, MBQUAD, MBQUAD, MBQUAD, MBQUAD, MBTRI, MBTRI, MBTRI, MBTRI, MBEDGE, MBEDGE, MBVERTEX }
mapping from mesh packet type to moab type
Definition at line 438 of file Tqdcfr.hpp.
Referenced by read_elements(), and moab::Tqdcfr::GeomHeader::read_info_header().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by convert_nodesets_sidesets(), moab::Tqdcfr::ModelEntry::read_header_info(), moab::Tqdcfr::NodesetHeader::read_info_header(), and Tqdcfr().
bool moab::Tqdcfr::printedElemWarning [private] |
Definition at line 346 of file Tqdcfr.hpp.
Referenced by read_elements().
bool moab::Tqdcfr::printedSeqWarning [private] |
Definition at line 344 of file Tqdcfr.hpp.
Referenced by process_record().
Definition at line 273 of file Tqdcfr.hpp.
Referenced by load_file(), read_elements(), read_nodes(), Tqdcfr(), and ~Tqdcfr().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by convert_nodesets_sidesets(), moab::Tqdcfr::ModelEntry::read_header_info(), moab::Tqdcfr::SidesetHeader::read_info_header(), and Tqdcfr().
Definition at line 286 of file Tqdcfr.hpp.
Referenced by FREADDA(), FREADIA(), and read_file_header().
std::map< int, EntityHandle > moab::Tqdcfr::uidSetMap |
Definition at line 284 of file Tqdcfr.hpp.
Referenced by parse_acis_attribs(), and moab::Tqdcfr::GeomHeader::read_info_header().
std::vector< unsigned int > moab::Tqdcfr::uint_buf |
Definition at line 288 of file Tqdcfr.hpp.
Referenced by check_contiguous(), CONVERT_TO_INTS(), FREADI(), moab::Tqdcfr::FEModelHeader::init(), process_sideset_10(), process_sideset_11(), read_block(), read_elements(), read_file_header(), read_group(), moab::Tqdcfr::GeomHeader::read_info_header(), moab::Tqdcfr::GroupHeader::read_info_header(), moab::Tqdcfr::BlockHeader::read_info_header(), moab::Tqdcfr::NodesetHeader::read_info_header(), moab::Tqdcfr::SidesetHeader::read_info_header(), read_md_string(), read_meta_data(), read_model_entries(), read_nodes(), read_nodeset(), and read_sideset().
Definition at line 282 of file Tqdcfr.hpp.
Referenced by moab::Tqdcfr::ModelEntry::read_header_info(), and moab::Tqdcfr::GeomHeader::read_info_header().