Mesh Oriented datABase  (version 5.5.0)
An array-based unstructured mesh library
moab::Tqdcfr Class Reference

#include <Tqdcfr.hpp>

+ Inheritance diagram for moab::Tqdcfr:
+ Collaboration diagram for moab::Tqdcfr:

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. More...
 
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. More...
 
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)
 
- Public Member Functions inherited from moab::ReaderIface
virtual ~ReaderIface ()
 

Static Public Member Functions

static ReaderIfacefactory (Interface *)
 

Public Attributes

ReadUtilIfacereadUtilIface
 
InterfacemdbImpl
 
FILE * cubFile
 
FileTOC fileTOC
 
std::vector< ModelEntrymodelEntries
 
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, EntityHandleuidSetMap
 
std::map< int, EntityHandlegidSetMap [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)
 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 More...
 
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 More...
 
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 More...
 
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 More...
 
ErrorCode process_sideset_10 (const int this_type, const int num_ents, const int sense_size, std::vector< EntityHandle > &ss_entities, Tqdcfr::SidesetHeader *sideseth)
 process entities in a sideset according to sense flags stored in uint_buf or char_buf (depending on sense_size) More...
 
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 More...
 

Detailed Description

Definition at line 45 of file Tqdcfr.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
aBODY 
LUMP 
SHELL 
FACE 
LOOP 
COEDGE 
aEDGE 
aVERTEX 
ATTRIB 
UNKNOWN 

Definition at line 247 of file Tqdcfr.hpp.

248  {
249  aBODY,
250  LUMP,
251  SHELL,
252  FACE,
253  LOOP,
254  COEDGE,
255  aEDGE,
256  aVERTEX,
257  ATTRIB,
258  UNKNOWN
259  };

◆ anonymous enum

anonymous enum
Enumerator
mesh 
acist 
acisb 
facet 
exodusmesh 

Definition at line 326 of file Tqdcfr.hpp.

327  {
328  mesh,
329  acist,
330  acisb,
331  facet,
332  exodusmesh
333  };

◆ anonymous enum

anonymous enum
private
Enumerator
GROUP 
BODY 
VOLUME 
SURFACE 
CURVE 
VERTEX 
HEX 
TET 
PYRAMID 
QUAD 
TRI 
EDGE 
NODE 

Definition at line 367 of file Tqdcfr.hpp.

368  {
369  GROUP = 0,
370  BODY,
371  VOLUME,
372  SURFACE,
373  CURVE,
374  VERTEX,
375  HEX,
376  TET,
377  PYRAMID,
378  QUAD,
379  TRI,
380  EDGE,
381  NODE
382  };

◆ anonymous enum

anonymous enum
private
Enumerator
SPHERE_EXO 
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 385 of file Tqdcfr.hpp.

386  {
387  SPHERE_EXO = 0,
388  BAR,
389  BAR2,
390  BAR3,
391  BEAM,
392  BEAM2,
393  BEAM3,
394  TRUSS,
395  TRUSS2,
396  TRUSS3,
397  SPRING,
398  TRIthree,
399  TRI3,
400  TRI6,
401  TRI7,
402  TRISHELL,
403  TRISHELL3,
404  TRISHELL6,
405  TRISHELL7,
406  SHEL,
407  SHELL4,
408  SHELL8,
409  SHELL9,
410  QUADfour,
411  QUAD4,
412  QUAD5,
413  QUAD8,
414  QUAD9,
415  TETRAfour,
416  TETRA4,
417  TETRA8,
418  TETRA10,
419  TETRA14,
420  PYRAMIDfive,
421  PYRAMID5,
422  PYRAMID8,
423  PYRAMID13,
424  PYRAMID18,
425  HEXeight,
426  HEX8,
427  HEX9,
428  HEX20,
429  HEX27,
430  HEXSHELL,
432  };

Constructor & Destructor Documentation

◆ ~Tqdcfr()

moab::Tqdcfr::~Tqdcfr ( )

Definition at line 261 of file Tqdcfr.cpp.

262 {
264 
265  if( NULL != cubMOABVertexMap ) delete cubMOABVertexMap;
266  if( attribVectorTag )
267  {
268  // get all sets, and release the string vectors
269  Range allSets; // although only geom sets should have these attributes
270  // can't error in a destructor
271  ErrorCode rval = mdbImpl->get_entities_by_type( 0, MBENTITYSET, allSets );
272  if( rval != MB_SUCCESS ) std::cerr << "WARNING: Could not get_entities_by_type" << std::endl;
273  for( Range::iterator sit = allSets.begin(); sit != allSets.end(); ++sit )
274  {
275  EntityHandle gset = *sit;
276  std::vector< std::string >* dum_vec;
277  // can't error in a destructor
278  rval = mdbImpl->tag_get_data( attribVectorTag, &gset, 1, &dum_vec );
279  if( rval != MB_SUCCESS ) std::cerr << "WARNING: Could not tag_get_data" << std::endl;
280  if( NULL != dum_vec ) delete dum_vec; //
281  }
283  attribVectorTag = NULL;
284  }
285 }

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().

◆ Tqdcfr()

moab::Tqdcfr::Tqdcfr ( Interface impl)

Definition at line 232 of file Tqdcfr.cpp.

233  : cubFile( NULL ), globalIdTag( 0 ), cubIdTag( 0 ), geomTag( 0 ), uniqueIdTag( 0 ), blockTag( 0 ), nsTag( 0 ),
234  ssTag( 0 ), attribVectorTag( 0 ), entityNameTag( 0 ), categoryTag( 0 ), hasMidNodesTag( 0 ),
235  swapForEndianness( false ), int_buf( NULL ), mFileSet( 0 ), printedSeqWarning( false ),
236  printedElemWarning( false ), acisDumpFile( NULL )
237 {
238  assert( NULL != impl );
239  mdbImpl = impl;
241  assert( NULL != readUtilIface );
242 
243  currVHandleOffset = -1;
244  for( EntityType this_type = MBVERTEX; this_type < MBMAXTYPE; this_type++ )
245  currElementIdOffset[this_type] = -1;
246 
247  ErrorCode rval;
248  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." );
249  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." );
250  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." );
251 
252  if( 0 == entityNameTag )
253  {
255  MB_TAG_SPARSE | MB_TAG_CREAT );MB_CHK_SET_ERR_RET( rval, "Failed to tag_get_handle." );
256  }
257 
258  cubMOABVertexMap = NULL;
259 }

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().

Member Function Documentation

◆ check_contiguous()

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.

1661 {
1662  unsigned int *id_it, curr_id, i;
1663 
1664  // Check in forward-contiguous direction
1665  id_it = &uint_buf[0];
1666  curr_id = *id_it++ + 1;
1667  contig = 1;
1668  min_id = uint_buf[0];
1669  max_id = uint_buf[0];
1670  for( i = 1; i < num_ents; id_it++, i++, curr_id++ )
1671  {
1672  if( *id_it != curr_id )
1673  {
1674  contig = 0;
1675  }
1676  min_id = MIN( min_id, uint_buf[i] );
1677  max_id = MAX( max_id, uint_buf[i] );
1678  }
1679 
1680  // If we got here and we're at the end of the loop, it's forward-contiguous
1681  if( 1 == contig ) return;
1682 
1683  // Check in reverse-contiguous direction
1684  contig = -1;
1685  id_it = &uint_buf[0];
1686  curr_id = *id_it++ - 1;
1687  for( i = 1; i < num_ents; id_it++, i++, curr_id-- )
1688  {
1689  if( *id_it != curr_id )
1690  {
1691  contig = 0;
1692  break;
1693  }
1694  }
1695 
1696  // If we got here and we're at the end of the loop, it's reverse-contiguous
1697  if( -1 == contig ) return;
1698 
1699  // One final check, for contiguous but out of order
1700  if( max_id - min_id + 1 == num_ents ) contig = -2;
1701 
1702  // Else it's not contiguous at all
1703  contig = 0;
1704 }

References moab::MAX(), moab::MIN(), and uint_buf.

Referenced by read_elements(), and read_nodes().

◆ convert_nodesets_sidesets()

ErrorCode moab::Tqdcfr::convert_nodesets_sidesets ( )
private

Definition at line 489 of file Tqdcfr.cpp.

490 {
491  // Look first for the nodeset and sideset offset flags; if they're not
492  // set, we don't need to convert
493  const EntityHandle msh = 0;
494  unsigned int nodeset_offset, sideset_offset;
495  Tag tmp_tag;
497  if( MB_SUCCESS != result )
498  nodeset_offset = 0;
499  else
500  {
501  result = mdbImpl->tag_get_data( tmp_tag, &msh, 1, &nodeset_offset );
502  if( MB_SUCCESS != result ) return result;
503  }
504 
506  if( MB_SUCCESS != result )
507  sideset_offset = 0;
508  else
509  {
510  result = mdbImpl->tag_get_data( tmp_tag, &msh, 1, &sideset_offset );
511  if( MB_SUCCESS != result ) return result;
512  }
513 
514  if( 0 == nodeset_offset && 0 == sideset_offset ) return MB_SUCCESS;
515 
516  // Look for all blocks
517  Range blocks;
518  result = mdbImpl->get_entities_by_type_and_tag( 0, MBENTITYSET, &blockTag, NULL, 1, blocks );
519  if( MB_SUCCESS != result || blocks.empty() ) return result;
520 
521  // Get the id tag for them
522  std::vector< int > block_ids( blocks.size() );
523  result = mdbImpl->tag_get_data( globalIdTag, blocks, &block_ids[0] );
524  if( MB_SUCCESS != result ) return result;
525 
526  unsigned int i = 0;
527  Range::iterator rit = blocks.begin();
528  Range new_nodesets, new_sidesets;
529  std::vector< int > new_nodeset_ids, new_sideset_ids;
530  for( ; rit != blocks.end(); i++, ++rit )
531  {
532  if( 0 != nodeset_offset && block_ids[i] >= (int)nodeset_offset &&
533  ( nodeset_offset > sideset_offset || block_ids[i] < (int)sideset_offset ) )
534  {
535  // This is a nodeset
536  new_nodesets.insert( *rit );
537  new_nodeset_ids.push_back( block_ids[i] );
538  }
539  else if( 0 != sideset_offset && block_ids[i] >= (int)sideset_offset &&
540  ( sideset_offset > nodeset_offset || block_ids[i] < (int)nodeset_offset ) )
541  {
542  // This is a sideset
543  new_sidesets.insert( *rit );
544  new_sideset_ids.push_back( block_ids[i] );
545  }
546  }
547 
548  // OK, have the new nodesets and sidesets; now remove the block tags, and
549  // add nodeset and sideset tags
550  ErrorCode tmp_result = MB_SUCCESS;
551  if( 0 != nodeset_offset )
552  {
553  if( 0 == nsTag )
554  {
555  int default_val = 0;
557  MB_TAG_SPARSE | MB_TAG_CREAT, &default_val );
558  if( MB_SUCCESS != tmp_result ) result = tmp_result;
559  }
560  if( MB_SUCCESS == tmp_result ) tmp_result = mdbImpl->tag_set_data( nsTag, new_nodesets, &new_nodeset_ids[0] );
561  if( MB_SUCCESS != tmp_result ) result = tmp_result;
562  tmp_result = mdbImpl->tag_delete_data( blockTag, new_nodesets );
563  if( MB_SUCCESS != tmp_result ) result = tmp_result;
564  }
565  if( 0 != sideset_offset )
566  {
567  if( 0 == ssTag )
568  {
569  int default_val = 0;
571  MB_TAG_SPARSE | MB_TAG_CREAT, &default_val );
572  if( MB_SUCCESS != tmp_result ) result = tmp_result;
573  }
574  if( MB_SUCCESS == tmp_result ) tmp_result = mdbImpl->tag_set_data( ssTag, new_sidesets, &new_sideset_ids[0] );
575  if( MB_SUCCESS != tmp_result ) result = tmp_result;
576  tmp_result = mdbImpl->tag_delete_data( blockTag, new_sidesets );
577  if( MB_SUCCESS != tmp_result ) result = tmp_result;
578  }
579 
580  return result;
581 }

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().

◆ CONVERT_TO_INTS()

void moab::Tqdcfr::CONVERT_TO_INTS ( unsigned int  num_ents)

Definition at line 221 of file Tqdcfr.cpp.

222 {
223  for( unsigned int i = 0; i < num_ents; i++ )
224  int_buf[i] = uint_buf[i];
225 }

References int_buf, and uint_buf.

Referenced by read_block(), read_elements(), read_group(), read_nodes(), read_nodeset(), and read_sideset().

◆ create_set()

◆ factory()

ReaderIface * moab::Tqdcfr::factory ( Interface iface)
static

Definition at line 227 of file Tqdcfr.cpp.

228 {
229  return new Tqdcfr( iface );
230 }

References iface, and Tqdcfr().

Referenced by moab::ReaderWriterSet::ReaderWriterSet().

◆ find_model()

int moab::Tqdcfr::find_model ( const unsigned int  model_type)

Definition at line 1779 of file Tqdcfr.cpp.

1780 {
1781  for( unsigned int i = 0; i < fileTOC.numModels; i++ )
1782  {
1783  if( modelEntries[i].modelType == model_type ) return i;
1784  }
1785 
1786  return -1;
1787 }

References fileTOC, modelEntries, and moab::Tqdcfr::FileTOC::numModels.

Referenced by load_file().

◆ FREADC()

void moab::Tqdcfr::FREADC ( unsigned  num_ents)

Definition at line 148 of file Tqdcfr.cpp.

149 {
150  char_buf.resize( num_ents );
151  FREADCA( num_ents, &char_buf[0] );
152 }

References char_buf, and FREADCA().

Referenced by load_file(), read_acis_records(), read_block(), read_md_string(), read_nodeset(), and read_sideset().

◆ FREADCA()

void moab::Tqdcfr::FREADCA ( unsigned  num_ents,
char *  arrat 
)

Definition at line 215 of file Tqdcfr.cpp.

216 {
217  unsigned rval = fread( array, sizeof( char ), num_ents, cubFile );
218  IO_ASSERT( rval == num_ents );
219 }

References cubFile, and IO_ASSERT.

Referenced by FREADC(), read_nodeset(), and read_sideset().

◆ FREADD()

void moab::Tqdcfr::FREADD ( unsigned  num_ents)

Definition at line 142 of file Tqdcfr.cpp.

143 {
144  dbl_buf.resize( num_ents );
145  FREADDA( num_ents, &dbl_buf[0] );
146 }

References dbl_buf, and FREADDA().

Referenced by read_block(), read_meta_data(), and read_sideset().

◆ FREADDA()

void moab::Tqdcfr::FREADDA ( unsigned  num_ents,
double *  array 
)

Definition at line 200 of file Tqdcfr.cpp.

201 {
202  unsigned rval = fread( array, sizeof( double ), num_ents, cubFile );
203  IO_ASSERT( rval == num_ents );
204  if( swapForEndianness )
205  {
206  double* pt = array;
207  for( unsigned int i = 0; i < num_ents; i++ )
208  {
209  swap8_voff( (long*)pt );
210  pt++;
211  }
212  }
213 }

References cubFile, IO_ASSERT, moab::swap8_voff(), and swapForEndianness.

Referenced by FREADD(), and read_nodes().

◆ FREADI()

◆ FREADIA()

void moab::Tqdcfr::FREADIA ( unsigned  num_ents,
unsigned int *  array 
)

Definition at line 185 of file Tqdcfr.cpp.

186 {
187  unsigned rval = fread( array, sizeof( unsigned int ), num_ents, cubFile );
188  IO_ASSERT( rval == num_ents );
189  if( swapForEndianness )
190  {
191  unsigned int* pt = array;
192  for( unsigned int i = 0; i < num_ents; i++ )
193  {
194  swap4_uint( (unsigned int*)pt );
195  pt++;
196  }
197  }
198 }

References cubFile, IO_ASSERT, moab::swap4_uint(), and swapForEndianness.

Referenced by FREADI(), and read_sideset().

◆ FSEEK()

◆ get_entities() [1/2]

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.

1247 {
1248  ErrorCode tmp_result, result = MB_SUCCESS;
1249 
1250  for( unsigned int i = 0; i < id_buf_size; i++ )
1251  {
1252  if( is_group )
1253  tmp_result = get_entities( mem_types[i], id_buf + i, 1, entities, entities );
1254  else
1255  // For blocks/nodesets/sidesets, use CSOEntityType, which is 2 greater than
1256  // group entity types
1257  tmp_result = get_entities( mem_types[i] + 2, id_buf + i, 1, entities, entities );
1258  if( MB_SUCCESS != tmp_result ) result = tmp_result;
1259  }
1260 
1261  return result;
1262 }

References entities, ErrorCode, and MB_SUCCESS.

Referenced by read_block(), read_group(), read_nodeset(), and read_sideset().

◆ get_entities() [2/2]

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.

1269 {
1270  ErrorCode result = MB_FAILURE;
1271 
1272  if( this_type <= VERTEX )
1273  result = get_ref_entities( this_type, id_buf, id_buf_size, entities );
1274  else if( this_type >= HEX && this_type <= NODE )
1275  result = get_mesh_entities( this_type, id_buf, id_buf_size, entities, excl_entities );
1276 
1277  return result;
1278 }

References entities, ErrorCode, get_mesh_entities(), get_ref_entities(), HEX, NODE, and VERTEX.

◆ get_mesh_entities()

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.

1296 {
1297  ErrorCode result = MB_SUCCESS;
1298  std::vector< EntityHandle >* ent_list = NULL;
1299  EntityType this_ent_type = MBVERTEX;
1300  const unsigned int arr_len = sizeof( group_type_to_mb_type ) / sizeof( group_type_to_mb_type[0] );
1301  if( this_type > 1000 )
1302  {
1303  if( this_type - 1000 < arr_len )
1304  {
1305  this_ent_type = group_type_to_mb_type[this_type - 1000];
1306  ent_list = &excl_entities;
1307  }
1308  }
1309  else
1310  {
1311  if( this_type < arr_len )
1312  {
1313  this_ent_type = group_type_to_mb_type[this_type];
1314  ent_list = &entities;
1315  }
1316  }
1317  if( NULL == ent_list )
1318  {
1319  MB_SET_ERR( MB_FAILURE, "Entities list is NULL" );
1320  }
1321 
1322  // Get entities with this type, and get their cub id tags
1323  if( MBVERTEX == this_ent_type )
1324  {
1325  // Use either vertex offset or cubMOABVertexMap
1326  if( NULL == cubMOABVertexMap )
1327  {
1328  for( unsigned int i = 0; i < id_buf_size; i++ )
1329  ent_list->push_back( (EntityHandle)( id_buf[i] + currVHandleOffset ) );
1330  }
1331  else
1332  {
1333  for( unsigned int i = 0; i < id_buf_size; i++ )
1334  {
1335  assert( 0 != ( *cubMOABVertexMap )[id_buf[i]] );
1336  ent_list->push_back( ( *cubMOABVertexMap )[id_buf[i]] );
1337  }
1338  }
1339  }
1340  else
1341  {
1342  Range tmp_ents;
1343  result = mdbImpl->get_entities_by_type( 0, this_ent_type, tmp_ents );
1344  if( MB_SUCCESS != result ) return result;
1345  if( tmp_ents.empty() && 0 != id_buf_size ) return MB_FAILURE;
1346 
1347  std::vector< int > cub_ids( tmp_ents.size() );
1348  result = mdbImpl->tag_get_data( globalIdTag, tmp_ents, &cub_ids[0] );
1349  if( MB_SUCCESS != result && MB_TAG_NOT_FOUND != result ) return result;
1350 
1351  // Now go through id list, finding each entity by id
1352  for( unsigned int i = 0; i < id_buf_size; i++ )
1353  {
1354  std::vector< int >::iterator vit = std::find( cub_ids.begin(), cub_ids.end(), id_buf[i] );
1355  if( vit != cub_ids.end() )
1356  {
1357  EntityHandle this_ent = tmp_ents[vit - cub_ids.begin()];
1358  if( mdbImpl->type_from_handle( this_ent ) != MBMAXTYPE ) ent_list->push_back( this_ent );
1359  }
1360  else
1361  {
1362  std::cout << "Warning: didn't find " << CN::EntityTypeName( this_ent_type ) << " " << id_buf[i]
1363  << std::endl;
1364  }
1365  }
1366  }
1367 
1368  return result;
1369 }

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().

◆ get_names()

ErrorCode moab::Tqdcfr::get_names ( MetaDataContainer md,
unsigned int  set_index,
EntityHandle  seth 
)
private

Definition at line 1093 of file Tqdcfr.cpp.

1094 {
1095  ErrorCode result = MB_SUCCESS;
1096 
1097  // Now get block names, if any
1098  int md_index = md.get_md_entry( set_index, "Name" );
1099  if( -1 == md_index ) return result;
1100  MetaDataContainer::MetaDataEntry* md_entry = &( md.metadataEntries[md_index] );
1101  // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE);
1102  char name_tag_data[NAME_TAG_SIZE];
1103  memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed
1104  strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
1105  result = mdbImpl->tag_set_data( entityNameTag, &seth, 1, name_tag_data );
1106  if( MB_SUCCESS != result ) return result;
1107 
1108  // Look for extra names
1109  md_index = md.get_md_entry( set_index, "NumExtraNames" );
1110  if( -1 == md_index ) return result;
1111  int num_names = md.metadataEntries[md_index].mdIntValue;
1112  for( int i = 0; i < num_names; i++ )
1113  {
1114  std::ostringstream extra_name_label( "ExtraName" );
1115  extra_name_label << i;
1116  std::ostringstream moab_extra_name( "EXTRA_" );
1117  moab_extra_name << NAME_TAG_NAME << i;
1118  md_index = md.get_md_entry( set_index, extra_name_label.str().c_str() );
1119  if( -1 != md_index )
1120  {
1121  md_entry = &( md.metadataEntries[md_index] );
1122  Tag extra_name_tag;
1123  ErrorCode rval;
1124  rval = mdbImpl->tag_get_handle( moab_extra_name.str().c_str(), NAME_TAG_SIZE, MB_TYPE_OPAQUE,
1125  extra_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT );MB_CHK_ERR( rval );
1126  memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed
1127  strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
1128  result = mdbImpl->tag_set_data( extra_name_tag, &seth, 1, name_tag_data );
1129  }
1130  }
1131 
1132  return result;
1133 }

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().

◆ get_ref_entities()

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.

1284 {
1285  for( unsigned int i = 0; i < id_buf_size; i++ )
1286  entities.push_back( ( gidSetMap[5 - this_type] )[id_buf[i]] );
1287 
1288  return MB_SUCCESS;
1289 }

References entities, gidSetMap, and MB_SUCCESS.

Referenced by get_entities().

◆ interpret_acis_records()

ErrorCode moab::Tqdcfr::interpret_acis_records ( std::vector< AcisRecord > &  records)
private

Definition at line 2479 of file Tqdcfr.cpp.

2480 {
2481  // Make a tag for the vector holding unrecognized attributes
2482  void* default_val = NULL;
2483  ErrorCode result = mdbImpl->tag_get_handle( "ATTRIB_VECTOR", sizeof( void* ), MB_TYPE_OPAQUE, attribVectorTag,
2484  MB_TAG_CREAT | MB_TAG_SPARSE, &default_val );
2485  if( MB_SUCCESS != result ) return result;
2486 
2487  unsigned int current_record = 0;
2488 
2489 #define REC records[current_record]
2490 
2491  while( current_record != records.size() )
2492  {
2493  // If this record's been processed, or if it's an attribute, continue
2494  if( REC.processed || REC.rec_type == Tqdcfr::ATTRIB )
2495  {
2496  current_record++;
2497  continue;
2498  }
2499 
2500  if( REC.rec_type == Tqdcfr::UNKNOWN )
2501  {
2502  REC.processed = true;
2503  current_record++;
2504  continue;
2505  }
2506 
2507  // It's a known, non-attrib rec type; parse for any attribs
2508  parse_acis_attribs( current_record, records );
2509 
2510  REC.processed = true;
2511 
2512  current_record++;
2513  }
2514 
2515  return MB_SUCCESS;
2516 }

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().

◆ load_file()

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.

Parameters
file_nameThe file to read.
file_setOptional 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_listAn optional struct pointer specifying the tags identifying entity sets to be read.
file_id_tagIf specified, reader should store for each entity it reads, a unique integer ID for this tag.
Author
Jason Kraftcheck

Implements moab::ReaderIface.

Definition at line 296 of file Tqdcfr.cpp.

301 {
302  ErrorCode result;
303 
304  int tmpval;
305  if( MB_SUCCESS == opts.get_int_option( "DEBUG_IO", 1, tmpval ) )
306  {
307  if( 0 < tmpval ) debug = true;
308  }
309 
310  if( subset_list )
311  {
312  MB_SET_ERR( MB_UNSUPPORTED_OPERATION, "Reading subset of files not supported for CUB files" );
313  }
314 
315  // Open file
316  cubFile = fopen( file_name, "rb" );
317  if( NULL == cubFile )
318  {
319  MB_SET_ERR( MB_FAILURE, "File not found" );
320  }
321 
322  // Verify magic string
323  FREADC( 4 );
324  if( !( char_buf[0] == 'C' && char_buf[1] == 'U' && char_buf[2] == 'B' && char_buf[3] == 'E' ) )
325  {
326  fclose( cubFile );
327  MB_SET_ERR( MB_FAILURE, "This doesn't appear to be a .cub file" );
328  }
329 
330  // Get "before" entities
331  result = mdbImpl->get_entities_by_handle( 0, beforeEnts );MB_CHK_SET_ERR( result, "Couldn't get \"before\" entities" );
332 
333  // ***********************
334  // Read model header type information...
335  // ***********************
336  if( debug ) std::cout << "Reading file header." << std::endl;
337  result = read_file_header();RR;
338 
339  if( debug ) std::cout << "Reading model entries." << std::endl;
340  result = read_model_entries();RR;
341 
342  // Read model metadata
343  if( debug ) std::cout << "Reading model metadata." << std::endl;
345 
346  double data_version;
347  int md_index = modelMetaData.get_md_entry( 2, "DataVersion" );
348  if( -1 == md_index )
349  data_version = 1.0;
350  else
351  data_version = modelMetaData.metadataEntries[md_index].mdDblValue;
352 
353  // Get the major/minor cubit version that wrote this file
354  // int major = -1, minor = -1;
355  md_index = modelMetaData.get_md_entry( 2, "CubitVersion" );
356  if( md_index >= 0 && !modelMetaData.metadataEntries[md_index].mdStringValue.empty() )
357  sscanf( modelMetaData.metadataEntries[md_index].mdStringValue.c_str(), "%d.%d", &major, &minor );
358 
359  // ***********************
360  // Read mesh...
361  // ***********************
362  int index = find_model( mesh );
363  if( -1 == index ) return MB_FAILURE;
364  ModelEntry* mesh_model = &modelEntries[index];
365 
366  // First the header & metadata info
367  if( debug ) std::cout << "Reading mesh model header and metadata." << std::endl;
368  result = mesh_model->read_header_info( this, data_version );
369  if( MB_SUCCESS != result ) return result;
370  result = mesh_model->read_metadata_info( this );
371  if( MB_SUCCESS != result ) return result;
372 
373  // Now read in mesh for each geometry entity; read in order of increasing dimension
374  // so we have all the mesh we need
375  for( int dim = 0; dim < 4; dim++ )
376  {
377  for( unsigned int gindex = 0; gindex < mesh_model->feModelHeader.geomArray.numEntities; gindex++ )
378  {
379  Tqdcfr::GeomHeader* geom_header = &mesh_model->feGeomH[gindex];
380 
381  if( geom_header->maxDim != dim ) continue;
382 
383  // Read nodes
384  if( debug ) std::cout << "Reading geom index " << gindex << " mesh: nodes... ";
385  result = read_nodes( gindex, mesh_model, geom_header );
386  if( MB_SUCCESS != result ) return result;
387 
388  // Read elements
389  if( debug ) std::cout << "elements... ";
390  result = read_elements( mesh_model, geom_header );
391  if( MB_SUCCESS != result ) return result;
392  if( debug ) std::cout << std::endl;
393  }
394  }
395 
396  // ***********************
397  // Read acis records...
398  // ***********************
399  std::string sat_file_name;
400  if( MB_SUCCESS != opts.get_str_option( "SAT_FILE", sat_file_name ) ) sat_file_name.clear();
401  result = read_acis_records( sat_file_name.empty() ? NULL : sat_file_name.c_str() );RR;
402 
403  // ***********************
404  // Read groups...
405  // ***********************
406  if( debug ) std::cout << "Reading groups... ";
407  for( unsigned int grindex = 0; grindex < mesh_model->feModelHeader.groupArray.numEntities; grindex++ )
408  {
409  GroupHeader* group_header = &mesh_model->feGroupH[grindex];
410  result = read_group( grindex, mesh_model, group_header );
411  if( MB_SUCCESS != result ) return result;
412  }
413  if( debug ) std::cout << mesh_model->feModelHeader.groupArray.numEntities << " read successfully." << std::endl;
414 
415  // ***********************
416  // Read blocks...
417  // ***********************
418  if( debug ) std::cout << "Reading blocks... ";
419  Range ho_entities;
420  for( unsigned int blindex = 0; blindex < mesh_model->feModelHeader.blockArray.numEntities; blindex++ )
421  {
422  BlockHeader* block_header = &mesh_model->feBlockH[blindex];
423  result = read_block( blindex, data_version, mesh_model, block_header );
424  if( MB_SUCCESS != result ) return result;
425  }
426 
427  if( debug ) std::cout << mesh_model->feModelHeader.blockArray.numEntities << " read successfully." << std::endl;
428 
429  // ***********************
430  // Read nodesets...
431  // ***********************
432  if( debug ) std::cout << "Reading nodesets... ";
433  for( unsigned int nsindex = 0; nsindex < mesh_model->feModelHeader.nodesetArray.numEntities; nsindex++ )
434  {
435  NodesetHeader* nodeset_header = &mesh_model->feNodeSetH[nsindex];
436  result = read_nodeset( nsindex, mesh_model, nodeset_header );
437  if( MB_SUCCESS != result ) return result;
438  }
439  if( debug ) std::cout << mesh_model->feModelHeader.nodesetArray.numEntities << " read successfully." << std::endl;
440 
441  // ***********************
442  // Read sidesets...
443  // ***********************
444  if( debug ) std::cout << "Reading sidesets...";
445  for( unsigned int ssindex = 0; ssindex < mesh_model->feModelHeader.sidesetArray.numEntities; ssindex++ )
446  {
447  SidesetHeader* sideset_header = &mesh_model->feSideSetH[ssindex];
448  result = read_sideset( ssindex, data_version, mesh_model, sideset_header );
449  if( MB_SUCCESS != result ) return result;
450  }
451  if( debug ) std::cout << mesh_model->feModelHeader.sidesetArray.numEntities << " read successfully." << std::endl;
452 
453  if( debug )
454  {
455  std::cout << "Read the following mesh:" << std::endl;
456  mdbImpl->list_entities( 0, 0 );
457  }
458 
459  // Convert blocks to nodesets/sidesets if tag is set
460  result = convert_nodesets_sidesets();
461  if( MB_SUCCESS != result ) return result;
462 
463  Range after_ents;
464  result = mdbImpl->get_entities_by_handle( 0, after_ents );
465  if( MB_SUCCESS != result ) return result;
466 
467  after_ents = subtract( after_ents, beforeEnts );
468 
469  if( file_id_tag ) readUtilIface->assign_ids( *file_id_tag, after_ents );
470 
471  if( MB_SUCCESS != opts.get_null_option( "SKIP_TOPOLOGY" ) )
472  {
473  // **************************
474  // Restore geometric topology
475  // **************************
476  GeomTopoTool gtt( mdbImpl, true, 0, true, false );
477  result = gtt.restore_topology_from_adjacency();
478  if( MB_SUCCESS != result )
479  {
480  std::cout << "Failed to restore topology " << std::endl;
481  }
482  }
483 
484  // done with the cubit file
485  fclose( cubFile );
486  return result;
487 }

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().

◆ parse_acis_attribs()

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.

2519 {
2520  unsigned int num_read;
2521  std::vector< std::string > attrib_vec;
2522  char temp_name[1024];
2523  char name_tag_val[NAME_TAG_SIZE];
2524  std::string name_tag;
2525  int id = -1;
2526  int uid = -1;
2527  int next_attrib = -1;
2528  ErrorCode result;
2529 
2530  int current_attrib = records[entity_rec_num].first_attrib;
2531  if( -1 == current_attrib ) return MB_SUCCESS;
2532 
2533  if( NULL != acisDumpFile )
2534  {
2535  fwrite( "-----------------------------------------------------------------------\n", 1, 72, acisDumpFile );
2536  fwrite( records[entity_rec_num].att_string.c_str(), sizeof( char ), records[entity_rec_num].att_string.length(),
2537  acisDumpFile );
2538  }
2539 
2540  while( -1 != current_attrib )
2541  {
2542  if( records[current_attrib].rec_type != Tqdcfr::UNKNOWN &&
2543  ( records[current_attrib].att_next != next_attrib ||
2544  records[current_attrib].att_ent_num != (int)entity_rec_num ) )
2545  return MB_FAILURE;
2546 
2547  if( NULL != acisDumpFile )
2548  fwrite( records[current_attrib].att_string.c_str(), sizeof( char ),
2549  records[current_attrib].att_string.length(), acisDumpFile );
2550 
2551  // Is the attrib one we already recognize?
2552  if( strncmp( records[current_attrib].att_string.c_str(), "ENTITY_NAME", 11 ) == 0 )
2553  {
2554  // Parse name
2555  int num_chars;
2556  num_read =
2557  sscanf( records[current_attrib].att_string.c_str(), "ENTITY_NAME @%d %s", &num_chars, temp_name );
2558  if( num_read != 2 )
2559  num_read =
2560  sscanf( records[current_attrib].att_string.c_str(), "ENTITY_NAME %d %s", &num_chars, temp_name );
2561  if( num_read != 2 ) return MB_FAILURE;
2562 
2563  // Put the name on the entity
2564  name_tag = std::string( temp_name, num_chars );
2565  }
2566  else if( strncmp( records[current_attrib].att_string.c_str(), "ENTITY_ID", 9 ) == 0 )
2567  {
2568  // Parse id
2569  int bounding_uid, bounding_sense;
2570  num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_ID 0 3 %d %d %d", &id, &bounding_uid,
2571  &bounding_sense );
2572  if( 3 != num_read )
2573  {
2574  // Try reading updated entity_id format, which has coordinate triple embedded in it
2575  // too
2576  float dumx, dumy, dumz;
2577  num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_ID 3 %f %f %f 3 %d %d %d", &dumx,
2578  &dumy, &dumz, &id, &bounding_uid, &bounding_sense );
2579  num_read -= 3;
2580  }
2581 
2582  if( 3 != num_read )
2583  std::cout << "Warning: bad ENTITY_ID attribute in .sat file, record number " << entity_rec_num
2584  << ", record follows:" << std::endl
2585  << records[current_attrib].att_string.c_str() << std::endl;
2586  }
2587  else if( strncmp( records[current_attrib].att_string.c_str(), "UNIQUE_ID", 9 ) == 0 )
2588  {
2589  // Parse uid
2590  if( major >= 14 ) // Change of format for cubit 14:
2591  num_read = sscanf( records[current_attrib].att_string.c_str(), "UNIQUE_ID 0 1 %d", &uid );
2592  else
2593  num_read = sscanf( records[current_attrib].att_string.c_str(), "UNIQUE_ID 1 0 1 %d", &uid );
2594  if( 1 != num_read ) return MB_FAILURE;
2595  }
2596  else if( strncmp( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 UNIQUE_ID", 29 ) == 0 )
2597  {
2598  // Parse uid
2599  int dum1, dum2, dum3, dum4;
2600  num_read = sscanf( records[current_attrib].att_string.c_str(),
2601  "COMPOSITE_ATTRIB @9 UNIQUE_ID %d %d %d %d %d", &dum1, &dum2, &dum3, &dum4, &uid );
2602  if( 5 != num_read ) return MB_FAILURE;
2603  }
2604  else if( strncmp( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID", 29 ) == 0 )
2605  {
2606  // Parse id
2607  int dum1, dum2, dum3;
2608  num_read = sscanf( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID %d %d %d %d",
2609  &dum1, &dum2, &dum3, &id );
2610  if( 4 != num_read ) return MB_FAILURE;
2611  }
2612  else
2613  {
2614  attrib_vec.push_back( records[current_attrib].att_string );
2615  }
2616 
2617  records[current_attrib].processed = true;
2618  next_attrib = current_attrib;
2619  current_attrib = records[current_attrib].att_prev;
2620  }
2621 
2622  // At this point, there aren't entity sets for entity types which don't contain mesh
2623  // in this case, just return
2624  if( records[entity_rec_num].rec_type == aBODY || ( records[entity_rec_num].entity == 0 && uid == -1 ) )
2625  {
2626  return MB_SUCCESS;
2627  // Warning: couldn't resolve entity of type 1 because no uid was found.
2628  // ddriv: GeomTopoTool.cpp:172: ErrorCode GeomTopoTool::separate_by_dimension(const Range&,
2629  // Range*, void**): Assertion `false' failed. xxx
2630  }
2631 
2632  // Parsed the data; now put on mdb entities; first we need to find the entity
2633  if( records[entity_rec_num].entity == 0 )
2634  {
2635  records[entity_rec_num].entity = uidSetMap[uid];
2636  }
2637 
2638  if( 0 == records[entity_rec_num].entity ) return MB_SUCCESS; // We do not have a MOAB entity for this, skip
2639 
2640  // assert(records[entity_rec_num].entity);
2641 
2642  // Set the id
2643  if( id != -1 )
2644  {
2645  result = mdbImpl->tag_set_data( globalIdTag, &( records[entity_rec_num].entity ), 1, &id );
2646  if( MB_SUCCESS != result ) return result;
2647 
2648  int ent_dim = -1;
2649  if( records[entity_rec_num].rec_type == aBODY )
2650  ent_dim = 4;
2651  else if( records[entity_rec_num].rec_type == LUMP )
2652  ent_dim = 3;
2653  else if( records[entity_rec_num].rec_type == FACE )
2654  ent_dim = 2;
2655  else if( records[entity_rec_num].rec_type == aEDGE )
2656  ent_dim = 1;
2657  else if( records[entity_rec_num].rec_type == aVERTEX )
2658  ent_dim = 0;
2659  if( -1 != ent_dim ) gidSetMap[ent_dim][id] = records[entity_rec_num].entity;
2660  }
2661 
2662  // Set the name
2663  if( !name_tag.empty() )
2664  {
2665  if( 0 == entityNameTag )
2666  {
2667  char dum_val[NAME_TAG_SIZE] = { 0 };
2669  MB_TAG_SPARSE | MB_TAG_CREAT, dum_val );
2670  if( MB_SUCCESS != result ) return result;
2671  }
2672 
2673  size_t len = name_tag.size();
2674  if( len >= NAME_TAG_SIZE ) len = NAME_TAG_SIZE - 1; // Truncate a name that is too big
2675  memcpy( name_tag_val, name_tag.c_str(), len );
2676  memset( name_tag_val + len, '\0', NAME_TAG_SIZE - len );
2677  result = mdbImpl->tag_set_data( entityNameTag, &( records[entity_rec_num].entity ), 1, name_tag_val );
2678  if( MB_SUCCESS != result ) return result;
2679  }
2680 
2681  if( !attrib_vec.empty() )
2682  {
2683  // Put the attrib vector in a tag on the entity
2684  std::vector< std::string >* dum_vec;
2685  result = mdbImpl->tag_get_data( attribVectorTag, &( records[entity_rec_num].entity ), 1, &dum_vec );
2686  if( MB_SUCCESS != result && MB_TAG_NOT_FOUND != result ) return result;
2687  if( MB_TAG_NOT_FOUND == result || dum_vec == NULL )
2688  {
2689  // Put this list directly on the entity
2690  dum_vec = new std::vector< std::string >;
2691  dum_vec->swap( attrib_vec );
2692  result = mdbImpl->tag_set_data( attribVectorTag, &( records[entity_rec_num].entity ), 1, &dum_vec );
2693  if( MB_SUCCESS != result )
2694  {
2695  delete dum_vec;
2696  return result;
2697  }
2698  }
2699  else
2700  {
2701  // Copy this list over, and delete this list
2702  std::copy( attrib_vec.begin(), attrib_vec.end(), std::back_inserter( *dum_vec ) );
2703  }
2704  }
2705 
2706  return MB_SUCCESS;
2707 }

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, 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().

◆ process_record()

ErrorCode moab::Tqdcfr::process_record ( AcisRecord this_record)
private

Definition at line 2720 of file Tqdcfr.cpp.

2721 {
2722  // Get the entity type
2723  const char* type_substr;
2724 
2725  // Try attribs first, since the others have some common processing between them
2726  if( ( type_substr = strstr( this_record.att_string.c_str(), "attrib" ) ) != NULL &&
2727  type_substr - this_record.att_string.c_str() < 20 )
2728  {
2729  this_record.rec_type = Tqdcfr::ATTRIB;
2730  bool simple_attrib = false;
2731  bool generic_attrib = false;
2732  if( ( type_substr = strstr( this_record.att_string.c_str(), "simple-snl-attrib" ) ) != NULL )
2733  simple_attrib = true;
2734  else if( ( type_substr = strstr( this_record.att_string.c_str(), "integer_attrib-name_attrib-gen-attrib" ) ) !=
2735  NULL )
2736  generic_attrib = true;
2737  else
2738  {
2739  this_record.rec_type = Tqdcfr::UNKNOWN;
2740  return MB_SUCCESS;
2741  }
2742 
2743  // Find next space
2744  type_substr = strchr( type_substr, ' ' );
2745  if( NULL == type_substr ) return MB_FAILURE;
2746 
2747  // Read the numbers from there
2748  int num_converted = sscanf( type_substr, " $-1 -1 $%d $%d $%d -1", &( this_record.att_prev ),
2749  &( this_record.att_next ), &( this_record.att_ent_num ) );
2750  if( num_converted != 3 ) return MB_FAILURE;
2751 
2752  // Trim the string to the attribute, if it's a simple attrib
2753  if( simple_attrib )
2754  {
2755  type_substr = strstr( this_record.att_string.c_str(), "NEW_SIMPLE_ATTRIB" );
2756  if( NULL == type_substr ) return MB_FAILURE;
2757  type_substr = strstr( type_substr, "@" );
2758  if( NULL == type_substr ) return MB_FAILURE;
2759  type_substr = strstr( type_substr, " " ) + 1;
2760  // Copy the rest of the string to a dummy string
2761  std::string dum_str( type_substr );
2762  this_record.att_string = dum_str;
2763  }
2764  else if( generic_attrib )
2765  {
2766  type_substr = strstr( this_record.att_string.c_str(), "CUBIT_ID" );
2767  if( NULL == type_substr ) return MB_FAILURE;
2768  // Copy the rest of the string to a dummy string
2769  std::string dum_str( type_substr );
2770  this_record.att_string = dum_str;
2771  }
2772  }
2773  else
2774  {
2775  // Else it's a topological entity, I think
2776  if( ( type_substr = strstr( this_record.att_string.c_str(), "body" ) ) != NULL &&
2777  type_substr - this_record.att_string.c_str() < 20 )
2778  {
2779  this_record.rec_type = Tqdcfr::aBODY;
2780  }
2781  else if( ( type_substr = strstr( this_record.att_string.c_str(), "lump" ) ) != NULL &&
2782  type_substr - this_record.att_string.c_str() < 20 )
2783  {
2784  this_record.rec_type = Tqdcfr::LUMP;
2785  }
2786  else if( ( type_substr = strstr( this_record.att_string.c_str(), "shell" ) ) != NULL &&
2787  type_substr - this_record.att_string.c_str() < 20 )
2788  {
2789  // Don't care about shells
2790  this_record.rec_type = Tqdcfr::UNKNOWN;
2791  }
2792  else if( ( type_substr = strstr( this_record.att_string.c_str(), "surface" ) ) != NULL &&
2793  type_substr - this_record.att_string.c_str() < 20 )
2794  {
2795  // Don't care about surfaces
2796  this_record.rec_type = Tqdcfr::UNKNOWN;
2797  }
2798  else if( ( type_substr = strstr( this_record.att_string.c_str(), "face" ) ) != NULL &&
2799  type_substr - this_record.att_string.c_str() < 20 )
2800  {
2801  this_record.rec_type = Tqdcfr::FACE;
2802  }
2803  else if( ( type_substr = strstr( this_record.att_string.c_str(), "loop" ) ) != NULL &&
2804  type_substr - this_record.att_string.c_str() < 20 )
2805  {
2806  // Don't care about loops
2807  this_record.rec_type = Tqdcfr::UNKNOWN;
2808  }
2809  else if( ( type_substr = strstr( this_record.att_string.c_str(), "coedge" ) ) != NULL &&
2810  type_substr - this_record.att_string.c_str() < 20 )
2811  {
2812  // Don't care about coedges
2813  this_record.rec_type = Tqdcfr::UNKNOWN;
2814  }
2815  else if( ( type_substr = strstr( this_record.att_string.c_str(), "edge" ) ) != NULL &&
2816  type_substr - this_record.att_string.c_str() < 20 )
2817  {
2818  this_record.rec_type = Tqdcfr::aEDGE;
2819  }
2820  else if( ( type_substr = strstr( this_record.att_string.c_str(), "vertex" ) ) != NULL &&
2821  type_substr - this_record.att_string.c_str() < 20 )
2822  {
2823  this_record.rec_type = Tqdcfr::aVERTEX;
2824  }
2825  else
2826  this_record.rec_type = Tqdcfr::UNKNOWN;
2827 
2828  if( this_record.rec_type != Tqdcfr::UNKNOWN )
2829  {
2830  // Print a warning if it looks like there are sequence numbers
2831  if( type_substr != this_record.att_string.c_str() && !printedSeqWarning )
2832  {
2833  std::cout << "Warning: acis file has sequence numbers!" << std::endl;
2834  printedSeqWarning = true;
2835  }
2836 
2837  // Scan ahead to the next white space
2838  type_substr = strchr( type_substr, ' ' );
2839  if( NULL == type_substr ) return MB_FAILURE;
2840 
2841  // Get the id of the first attrib
2842  int num_converted = sscanf( type_substr, " $%d", &( this_record.first_attrib ) );
2843  if( num_converted != 1 ) return MB_FAILURE;
2844  }
2845  }
2846 
2847  return MB_SUCCESS;
2848 }

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().

◆ process_sideset_10()

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.

848 {
849  std::vector< EntityHandle > forward, reverse;
850  if( this_type == 3 // Surface
851  && sense_size == 1 // Byte size
852  )
853  {
854  // Interpret sense flags w/o reference to anything
855  for( int i = 0; i < num_ents; i++ )
856  {
857  if( (int)char_buf[i] == 0 )
858  forward.push_back( ss_entities[i] );
859  else if( (int)char_buf[i] == 1 )
860  reverse.push_back( ss_entities[i] );
861  else if( (int)char_buf[i] == -1 )
862  { // -1 means "unknown", which means both
863  forward.push_back( ss_entities[i] );
864  reverse.push_back( ss_entities[i] );
865  }
866  }
867  }
868  else if( this_type == 4 // Curve
869  && sense_size == 2 // int32 size
870  )
871  {
872  for( int i = 0; i < num_ents; i++ )
873  {
874  if( uint_buf[i] == 0 )
875  forward.push_back( ss_entities[i] );
876  else if( uint_buf[i] == 1 )
877  reverse.push_back( ss_entities[i] );
878  else if( *( (int*)&uint_buf[i] ) == -1 )
879  { // -1 means "unknown", which means both
880  forward.push_back( ss_entities[i] );
881  reverse.push_back( ss_entities[i] );
882  }
883  }
884  }
885 
886  // Now actually put them in the set
887  ErrorCode result = MB_SUCCESS;
888  if( !forward.empty() )
889  {
890  ErrorCode tmp_result = mdbImpl->add_entities( sideseth->setHandle, &forward[0], forward.size() );
891  if( tmp_result != MB_SUCCESS ) result = tmp_result;
892  }
893  if( !reverse.empty() )
894  {
895  // Need to make a new set, add a reverse sense tag, then add to the sideset
896  EntityHandle reverse_set;
897  ErrorCode tmp_result = create_set( reverse_set );
898  if( MB_SUCCESS != tmp_result ) result = tmp_result;
899  tmp_result = mdbImpl->add_entities( reverse_set, &reverse[0], reverse.size() );
900  if( tmp_result != MB_SUCCESS ) result = tmp_result;
901  int def_val = 1;
902  Tag sense_tag;
903  tmp_result = mdbImpl->tag_get_handle( "NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag,
904  MB_TAG_SPARSE | MB_TAG_CREAT, &def_val );
905  if( tmp_result != MB_SUCCESS ) result = tmp_result;
906  def_val = -1;
907  tmp_result = mdbImpl->tag_set_data( sense_tag, &reverse_set, 1, &def_val );
908  if( tmp_result != MB_SUCCESS ) result = tmp_result;
909  tmp_result = mdbImpl->add_entities( sideseth->setHandle, &reverse_set, 1 );
910  if( tmp_result != MB_SUCCESS ) result = tmp_result;
911  }
912 
913  return result;
914 }

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().

◆ process_sideset_11()

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.

919 {
920  std::vector< EntityHandle > forward, reverse;
921 
922  unsigned int num_ents = ss_entities.size();
923  unsigned int* wrt_it = &uint_buf[0];
924 
925  for( unsigned int i = 0; i < num_ents; i++ )
926  {
927  unsigned int num_wrt = 0;
928  if( 0 != num_wrts ) num_wrt = *wrt_it++;
929  for( unsigned int j = 0; j < num_wrt; j++ )
930  wrt_it += 2;
931  // Assume here that if it's in the list twice, we get both senses
932  if( num_wrt > 1 )
933  {
934  forward.push_back( ss_entities[i] );
935  reverse.push_back( ss_entities[i] );
936  }
937  else
938  {
939  // Else interpret the sense flag
940  if( (int)char_buf[i] == 0 )
941  forward.push_back( ss_entities[i] );
942  else if( (int)char_buf[i] == 1 )
943  reverse.push_back( ss_entities[i] );
944  else if( (int)char_buf[i] == -1 )
945  { // -1 means "unknown", which means both
946  forward.push_back( ss_entities[i] );
947  reverse.push_back( ss_entities[i] );
948  }
949  }
950  }
951 
952  // Now actually put them in the set
953  ErrorCode result = MB_SUCCESS;
954  if( !forward.empty() )
955  {
956  ErrorCode tmp_result = mdbImpl->add_entities( sideseth->setHandle, &forward[0], forward.size() );
957  if( tmp_result != MB_SUCCESS ) result = tmp_result;
958  }
959  if( !reverse.empty() )
960  {
961  // Need to make a new set, add a reverse sense tag, then add to the sideset
962  EntityHandle reverse_set;
963  ErrorCode tmp_result = create_set( reverse_set );
964  if( MB_SUCCESS != tmp_result ) result = tmp_result;
965  tmp_result = mdbImpl->add_entities( reverse_set, &reverse[0], reverse.size() );
966  if( tmp_result != MB_SUCCESS ) result = tmp_result;
967  int def_val = 1;
968  Tag sense_tag;
969  tmp_result = mdbImpl->tag_get_handle( "NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag,
970  MB_TAG_SPARSE | MB_TAG_CREAT, &def_val );
971  if( tmp_result != MB_SUCCESS && tmp_result != MB_ALREADY_ALLOCATED ) result = tmp_result;
972  def_val = -1;
973  tmp_result = mdbImpl->tag_set_data( sense_tag, &reverse_set, 1, &def_val );
974  if( tmp_result != MB_SUCCESS ) result = tmp_result;
975  tmp_result = mdbImpl->add_entities( sideseth->setHandle, &reverse_set, 1 );
976  if( tmp_result != MB_SUCCESS ) result = tmp_result;
977  }
978 
979  return result;
980 }

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().

◆ put_into_set()

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.

1217 {
1218  // And put entities into this block's set
1219  ErrorCode result = mdbImpl->add_entities( set_handle, &entities[0], entities.size() );
1220  if( MB_SUCCESS != result ) return result;
1221 
1222  // Check for excluded entities, and add them to a vector hung off the block if there
1223  Tag excl_tag;
1224  if( !excl_entities.empty() )
1225  {
1226  result = mdbImpl->tag_get_handle( "Exclude_Entities", sizeof( std::vector< EntityHandle >* ), MB_TYPE_OPAQUE,
1227  excl_tag, MB_TAG_SPARSE | MB_TAG_CREAT );
1228  if( MB_SUCCESS != result ) return result;
1229  std::vector< EntityHandle >* new_vector = new std::vector< EntityHandle >;
1230  new_vector->swap( excl_entities );
1231  result = mdbImpl->tag_set_data( excl_tag, &set_handle, 1, &new_vector );
1232  if( MB_SUCCESS != result )
1233  {
1234  delete new_vector;
1235  return MB_FAILURE;
1236  }
1237  }
1238 
1239  return MB_SUCCESS;
1240 }

References moab::Interface::add_entities(), 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().

◆ read_acis_records()

ErrorCode moab::Tqdcfr::read_acis_records ( const char *  sat_file_name = 0)
private

Definition at line 2368 of file Tqdcfr.cpp.

2369 {
2370  // Get the acis model location
2371  unsigned int acis_model_offset = 0, acis_model_length = 0, acis_model_handle = 1, acis_sat_type = 1;
2372  for( unsigned int i = 0; i < fileTOC.numModels; i++ )
2373  {
2374  if( modelEntries[i].modelHandle == acis_model_handle && modelEntries[i].modelType == acis_sat_type )
2375  {
2376  acis_model_offset = modelEntries[i].modelOffset;
2377  acis_model_length = modelEntries[i].modelLength;
2378  break;
2379  }
2380  }
2381 
2382  if( acis_model_length == 0 ) return MB_SUCCESS;
2383 
2384  std::vector< AcisRecord > records;
2385 
2386  acisDumpFile = NULL;
2387  if( sat_filename )
2388  {
2389  acisDumpFile = fopen( sat_filename, "w+" );
2390  if( NULL == acisDumpFile ) return MB_FAILURE;
2391  }
2392 
2393  // Position the file at the start of the acis model
2394  FSEEK( acis_model_offset );
2395 
2396  unsigned int bytes_left = acis_model_length;
2397 
2398  struct AcisRecord this_record;
2399  reset_record( this_record );
2400  char* ret;
2401 
2402  // Make the char buffer at least buf_size + 1 long, to fit null char
2403  const unsigned int buf_size = 1023;
2404 
2405  // CHECK_SIZE(char_buf, buf_size + 1);
2406  char_buf.resize( buf_size + 1 );
2407 
2408  while( 0 != bytes_left )
2409  {
2410  // Read the next buff characters, or bytes_left if smaller
2411  unsigned int next_buf = ( bytes_left > buf_size ? buf_size : bytes_left );
2412  FREADC( next_buf );
2413 
2414  if( NULL != acisDumpFile ) fwrite( &char_buf[0], sizeof( char ), next_buf, acisDumpFile );
2415 
2416  // Put null at end of string to stop searches
2417  char_buf.resize( next_buf + 1 );
2418  char_buf[next_buf] = '\0';
2419  unsigned int buf_pos = 0;
2420 
2421  // Check for first read, and if so, get rid of the header
2422  if( bytes_left == acis_model_length )
2423  {
2424  // Look for 3 newlines
2425  ret = strchr( &( char_buf[0] ), '\n' );
2426  ret = strchr( ret + 1, '\n' );
2427  ret = strchr( ret + 1, '\n' );
2428  if( NULL == ret ) return MB_FAILURE;
2429  buf_pos += ret - &( char_buf[0] ) + 1;
2430  }
2431 
2432  bytes_left -= next_buf;
2433 
2434  // Now start grabbing records
2435  do
2436  {
2437  // Get next occurrence of '#' (record terminator)
2438  ret = strchr( &( char_buf[buf_pos] ), '#' );
2439  while( ret && (unsigned int)( ret + 1 - &char_buf[0] ) < bytes_left && *( ret + 1 ) != '\n' &&
2440  *( ret + 1 ) != '\r' && *( ret + 1 ) != 0 ) // CR added for windows
2441  ret = strchr( ret + 1, '#' );
2442  if( NULL != ret )
2443  {
2444  // Grab the string (inclusive of the record terminator and the line feed) and
2445  // complete the record
2446  int num_chars = ret - &( char_buf[buf_pos] ) + 2;
2447  if( *( ret + 1 ) == '\r' ) num_chars++; // add more one character for Windows CR
2448  this_record.att_string.append( &( char_buf[buf_pos] ), num_chars );
2449  buf_pos += num_chars;
2450  process_record( this_record );
2451 
2452  // Put the record in the list...
2453  records.push_back( this_record );
2454 
2455  // And reset the record
2456  reset_record( this_record );
2457  }
2458  else
2459  {
2460  // Reached end of buffer; cache string then go get another; discard last character,
2461  // which will be the null character
2462  this_record.att_string.append( &( char_buf[buf_pos] ), next_buf - buf_pos );
2463  buf_pos = next_buf;
2464  }
2465  } while( buf_pos < next_buf );
2466  }
2467 
2468  if( NULL != acisDumpFile )
2469  fwrite( "\n======================\nSorted acis records:\n======================\n", 1, 68, acisDumpFile );
2470 
2471  // Now interpret the records
2472  interpret_acis_records( records );
2473 
2474  if( NULL != acisDumpFile ) fclose( acisDumpFile );
2475 
2476  return MB_SUCCESS;
2477 }

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().

◆ read_block()

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.

986 {
987  if( blockh->memCt == 0 ) return MB_SUCCESS;
988 
989  // Position file
990  FSEEK( model->modelOffset + blockh->memOffset );
991 
992  // Read ids for each entity type
993  unsigned int num_read = 0;
994  int this_type, num_ents; //, uid;
995  std::vector< EntityHandle > block_entities, excl_entities;
996  for( unsigned int i = 0; i < blockh->memTypeCt; i++ )
997  {
998  // Get how many and what type
999  FREADI( 2 );
1000  num_read += 2 * sizeof( int );
1001  this_type = uint_buf[0];
1002  num_ents = uint_buf[1];
1003 
1004  // Now get the ids
1005  FREADI( num_ents );
1006  num_read += num_ents * sizeof( int );
1007  CONVERT_TO_INTS( num_ents );
1008 
1009  ErrorCode result = get_entities( this_type + 2, &int_buf[0], num_ents, block_entities, excl_entities );
1010  if( MB_SUCCESS != result ) return result;
1011  }
1012 
1013  // And put entities into this block's set
1014  ErrorCode result = put_into_set( blockh->setHandle, block_entities, excl_entities );
1015  if( MB_SUCCESS != result ) return result;
1016 
1017  // Read attribs if there are any
1018  Tag block_attribs;
1019  {
1020  int def_block_attributes_length = 0;
1021  result = mdbImpl->tag_get_handle( BLOCK_ATTRIBUTES, def_block_attributes_length, MB_TYPE_DOUBLE, block_attribs,
1023  if( MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result ) return result;
1024  }
1025 
1026  if( blockh->attribOrder > 0 )
1027  {
1028  FREADD( blockh->attribOrder );
1029  num_read += sizeof( double );
1030  void const* tag_data[] = { &dbl_buf[0] };
1031  int tag_sizes[] = { static_cast< int >( blockh->attribOrder ) };
1032  result = mdbImpl->tag_set_by_ptr( block_attribs, &( blockh->setHandle ), 1, tag_data, tag_sizes );
1033  if( MB_SUCCESS != result ) return result;
1034  }
1035 
1036  // Check for more data
1037  if( num_read < blockh->blockLength )
1038  {
1039  FREADC( 2 ); // num_read += 2;
1040  if( char_buf[0] == 'i' && char_buf[1] == 'd' )
1041  {
1042  FREADI( 1 ); // num_read += sizeof(int);
1043  // uid = int_buf[0];
1044  }
1045  }
1046 
1047  result = get_names( model->blockMD, blindex, blockh->setHandle );
1048  if( MB_SUCCESS != result ) return result;
1049 
1050  // Put additional higher-order nodes into element connectivity list.
1051  // Cubit saves full connectivity list only for NodeHex and NodeTet
1052  // elements. Other element types will only have the corners and
1053  // the mid-element node if there is one. Need to reconstruct additional
1054  // connectivity entries from mid-nodes of adjacent lower-order entities.
1055  int node_per_elem = cub_elem_num_verts[blockh->blockElemType];
1056  if( blockh->blockEntityType == MBMAXTYPE ) return MB_SUCCESS;
1057  if( ( 14 == major && 2 < minor ) || 15 <= major )
1058  {
1059  if( 55 == blockh->blockElemType || CN::VerticesPerEntity( blockh->blockEntityType ) == node_per_elem )
1060  return MB_SUCCESS;
1061  }
1062  else
1063  {
1064  if( 52 == blockh->blockElemType || CN::VerticesPerEntity( blockh->blockEntityType ) == node_per_elem )
1065  return MB_SUCCESS;
1066  }
1067 
1068  // Can't use Interface::convert_entities because block could contain
1069  // both entity sets and entities. convert_entities will fail if block
1070  // contains an entity set, but we still need to call it on any elements
1071  // directly in the block (rather than a geometry subset). So bypass
1072  // Interface and call HOFactory directly with an Range of entities.
1073  Range ho_entities, entities;
1074  mdbImpl->get_entities_by_type( blockh->setHandle, blockh->blockEntityType, entities, true );
1075  if( CN::Dimension( blockh->blockEntityType ) > 2 )
1076  {
1077  result = mdbImpl->get_adjacencies( entities, 2, false, ho_entities, Interface::UNION );
1078  if( MB_SUCCESS != result ) return result;
1079  }
1080  if( CN::Dimension( blockh->blockEntityType ) > 1 )
1081  {
1082  result = mdbImpl->get_adjacencies( entities, 1, false, ho_entities, Interface::UNION );
1083  if( MB_SUCCESS != result ) return result;
1084  }
1085  entities.merge( ho_entities );
1086 
1087  Core* mbcore = dynamic_cast< Core* >( mdbImpl );
1088  assert( mbcore != NULL );
1089  HigherOrderFactory ho_fact( mbcore, 0 );
1090  return ho_fact.convert( entities, !!blockh->hasMidNodes[1], !!blockh->hasMidNodes[2], !!blockh->hasMidNodes[3] );
1091 }

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, MBMAXTYPE, mdbImpl, moab::Tqdcfr::BlockHeader::memCt, moab::Tqdcfr::BlockHeader::memOffset, moab::Tqdcfr::BlockHeader::memTypeCt, 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().

◆ read_elements()

ErrorCode moab::Tqdcfr::read_elements ( Tqdcfr::ModelEntry model,
Tqdcfr::GeomHeader entity 
)

Definition at line 1545 of file Tqdcfr.cpp.

1546 {
1547  if( entity->elemTypeCt == 0 ) return MB_SUCCESS;
1548  const int in_order_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
1549  14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 };
1550 
1551  // Get data in separate calls to minimize memory usage
1552  // Position the file
1553  FSEEK( model->modelOffset + entity->elemOffset );
1554 
1555  int int_type, nodes_per_elem, num_elem;
1556  int max_dim = -1;
1557  ErrorCode result;
1558  for( unsigned int i = 0; i < entity->elemTypeCt; i++ )
1559  {
1560  // For this elem type, get the type, nodes per elem, num elems
1561  FREADI( 3 );
1562  int_type = uint_buf[0];
1563  nodes_per_elem = uint_buf[1];
1564  num_elem = uint_buf[2];
1565 
1566  // Get MB element type from cub file's
1567  EntityType elem_type = mp_type_to_mb_type[int_type];
1568  max_dim = ( max_dim < CN::Dimension( elem_type ) ? CN::Dimension( elem_type ) : max_dim );
1569 
1570  if( debug ) std::cout << "type " << CN::EntityTypeName( elem_type ) << ":";
1571 
1572  const int* node_order = cub_elem_order_map[elem_type][nodes_per_elem];
1573  if( !node_order ) node_order = in_order_map;
1574 
1575  // Get element ids
1576  FREADI( num_elem );
1577 
1578  // Check to see if ids are contiguous...
1579  int contig;
1580  unsigned int max_id, min_id;
1581  check_contiguous( num_elem, contig, min_id, max_id );
1582  if( 0 == contig && !printedElemWarning )
1583  {
1584  std::cout << "Element ids are not contiguous!" << std::endl;
1585  printedElemWarning = true;
1586  }
1587 
1588  // Get a space for reading connectivity data directly into MB
1589  EntityHandle *conn, start_handle;
1590 
1591  result = readUtilIface->get_element_connect( num_elem, nodes_per_elem, elem_type, int_buf[0], start_handle,
1593  if( MB_SUCCESS != result ) return result;
1594 
1595  Range dum_range( start_handle, start_handle + num_elem - 1 );
1596 
1597  long elem_offset;
1598  elem_offset = ( 1 == contig ? start_handle - int_buf[0] : int_buf[num_elem - 1] );
1599  if( -1 == currElementIdOffset[elem_type] ) currElementIdOffset[elem_type] = elem_offset;
1600 
1601  // Set the gids on elements
1602  CONVERT_TO_INTS( num_elem );
1603  result = mdbImpl->tag_set_data( globalIdTag, dum_range, &int_buf[0] );
1604  if( MB_SUCCESS != result ) return result;
1605 
1606  // Get the connectivity array
1607  unsigned int total_conn = num_elem * nodes_per_elem;
1608  if( major >= 14 ) FREADI( num_elem ); // We need to skip num_elem in advance, it looks like
1609  FREADI( total_conn );
1610 
1611  // Post-process connectivity into handles
1612  EntityHandle new_handle;
1613  int j = 0;
1614  for( int e = 0; e < num_elem; ++e )
1615  {
1616  for( int k = 0; k < nodes_per_elem; ++k, ++j )
1617  {
1618  if( debug )
1619  {
1620  if( 0 == j ) std::cout << "Conn=";
1621  std::cout << ", " << uint_buf[j];
1622  }
1623  if( NULL == cubMOABVertexMap )
1624  new_handle = (EntityHandle)currVHandleOffset + uint_buf[j];
1625  else
1626  {
1627  assert( uint_buf[j] < cubMOABVertexMap->size() && 0 != ( *cubMOABVertexMap )[uint_buf[j]] );
1628  new_handle = ( *cubMOABVertexMap )[uint_buf[j]];
1629  }
1630 #ifndef NDEBUG
1631  EntityHandle dum_handle;
1632  assert( MB_SUCCESS ==
1633  mdbImpl->handle_from_id( MBVERTEX, mdbImpl->id_from_handle( new_handle ), dum_handle ) );
1634 #endif
1635  conn[e * nodes_per_elem + node_order[k]] = new_handle;
1636  }
1637  }
1638 
1639  // Add these elements into the entity's set
1640  result = mdbImpl->add_entities( entity->setHandle, dum_range );
1641  if( MB_SUCCESS != result ) return result;
1642 
1643  // Notify MOAB of the new elements
1644  result = readUtilIface->update_adjacencies( start_handle, num_elem, nodes_per_elem, conn );
1645  if( MB_SUCCESS != result ) return result;
1646  }
1647 
1648  // Set the dimension on the geom tag
1649  result = mdbImpl->tag_set_data( geomTag, &entity->setHandle, 1, &max_dim );
1650  if( MB_SUCCESS != result ) return result;
1651  if( max_dim != -1 )
1652  {
1653  result = mdbImpl->tag_set_data( categoryTag, &entity->setHandle, 1, &geom_categories[max_dim] );
1654  if( MB_SUCCESS != result ) return result;
1655  }
1656 
1657  return MB_SUCCESS;
1658 }

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().

◆ read_file_header()

ErrorCode moab::Tqdcfr::read_file_header ( )

Definition at line 1730 of file Tqdcfr.cpp.

1731 {
1732  // Read file header
1733  FSEEK( 4 );
1734  // Read the first int from the file
1735  // If it is 0, it is littleEndian
1736  unsigned rval = fread( &fileTOC.fileEndian, sizeof( unsigned int ), 1, cubFile );
1737  IO_ASSERT( rval == 1 );
1738 #ifdef WORDS_BIGENDIAN
1739  if( fileTOC.fileEndian == 0 ) swapForEndianness = true;
1740 #else
1741  if( fileTOC.fileEndian != 0 ) swapForEndianness = true;
1742 #endif
1743  if( debug ) std::cout << " swapping ? " << swapForEndianness << "\n";
1744  FREADI( 5 );
1745  // fileTOC.fileEndian = uint_buf[0];
1747  fileTOC.numModels = uint_buf[1];
1751  if( debug ) fileTOC.print();
1752 
1753  return MB_SUCCESS;
1754 }

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_group()

ErrorCode moab::Tqdcfr::read_group ( const unsigned int  gr_index,
Tqdcfr::ModelEntry model,
Tqdcfr::GroupHeader grouph 
)

Definition at line 1135 of file Tqdcfr.cpp.

1136 {
1137  // Position file
1138  FSEEK( model->modelOffset + grouph->memOffset );
1139  char name_tag_data[NAME_TAG_SIZE];
1140 
1141  // Read ids for each entity type
1142  int this_type, num_ents;
1143  std::vector< EntityHandle > grp_entities, excl_entities;
1144  for( unsigned int i = 0; i < grouph->memTypeCt; i++ )
1145  {
1146  // Get how many and what type
1147  FREADI( 2 );
1148  this_type = uint_buf[0];
1149  num_ents = uint_buf[1];
1150 
1151  // Now get the ids
1152  FREADI( num_ents );
1153  CONVERT_TO_INTS( num_ents );
1154 
1155  // Get the entities in this group
1156  ErrorCode result = get_entities( this_type, &int_buf[0], num_ents, grp_entities, excl_entities );
1157  if( MB_SUCCESS != result ) return result;
1158  }
1159 
1160  // Now add the entities
1161  ErrorCode result = put_into_set( grouph->setHandle, grp_entities, excl_entities );
1162  if( MB_SUCCESS != result ) return result;
1163 
1164  // Now get group names, if any
1165  int md_index = model->groupMD.get_md_entry( grouph->grpID, "NAME" );
1166  if( -1 != md_index )
1167  {
1168  MetaDataContainer::MetaDataEntry* md_entry = &( model->groupMD.metadataEntries[md_index] );
1169  if( 0 == entityNameTag )
1170  {
1171  memset( name_tag_data, 0, NAME_TAG_SIZE );
1173  MB_TAG_SPARSE | MB_TAG_CREAT, name_tag_data );
1174  if( MB_SUCCESS != result ) return result;
1175  }
1176  // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE);
1177  memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed
1178  strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
1179  result = mdbImpl->tag_set_data( entityNameTag, &grouph->setHandle, 1, name_tag_data );
1180  if( MB_SUCCESS != result ) return result;
1181 
1182  // Look for extra names
1183  md_index = model->groupMD.get_md_entry( group_index, "NumExtraNames" );
1184  if( -1 != md_index )
1185  {
1186  int num_names = model->groupMD.metadataEntries[md_index].mdIntValue;
1187  for( int i = 0; i < num_names; i++ )
1188  {
1189  std::ostringstream extra_name_label( "ExtraName" );
1190  extra_name_label << i;
1191  std::ostringstream moab_extra_name( "EXTRA_" );
1192  moab_extra_name << NAME_TAG_NAME << i;
1193  md_index = model->groupMD.get_md_entry( group_index, extra_name_label.str().c_str() );
1194  if( -1 != md_index )
1195  {
1196  md_entry = &( model->groupMD.metadataEntries[md_index] );
1197  Tag extra_name_tag;
1198  memset( name_tag_data, 0, NAME_TAG_SIZE );
1199  result = mdbImpl->tag_get_handle( moab_extra_name.str().c_str(), NAME_TAG_SIZE, MB_TYPE_OPAQUE,
1200  extra_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT, name_tag_data );
1201  if( MB_SUCCESS != result ) return result;
1202  // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE);
1203  memset( name_tag_data, 0, NAME_TAG_SIZE ); // Make sure any extra bytes zeroed
1204  strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
1205  result = mdbImpl->tag_set_data( extra_name_tag, &grouph->setHandle, 1, name_tag_data );
1206  }
1207  }
1208  }
1209  }
1210 
1211  return result;
1212 }

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().

◆ read_md_string()

ErrorCode moab::Tqdcfr::read_md_string ( std::string &  name)

Definition at line 1853 of file Tqdcfr.cpp.

1854 {
1855  FREADI( 1 );
1856  int str_size = uint_buf[0];
1857  if( str_size > 0 )
1858  {
1859  FREADC( str_size );
1860  if( char_buf.size() <= (unsigned int)str_size ) char_buf.resize( str_size + 1 );
1861  char_buf[str_size] = '\0';
1862  name = (char*)&char_buf[0];
1863  // Read pad if any
1864  int extra = str_size % sizeof( int );
1865  if( extra )
1866  {
1867  // Read extra chars to end of pad
1868  str_size = sizeof( int ) - extra;
1869  FREADC( str_size );
1870  }
1871  }
1872 
1873  return MB_SUCCESS;
1874 }

References char_buf, FREADC(), FREADI(), MB_SUCCESS, and uint_buf.

Referenced by read_meta_data().

◆ read_meta_data()

ErrorCode moab::Tqdcfr::read_meta_data ( const unsigned int  metadata_offset,
Tqdcfr::MetaDataContainer mc 
)

Definition at line 1789 of file Tqdcfr.cpp.

1790 {
1791  // Read the metadata header
1792  FSEEK( metadata_offset );
1793  FREADI( 3 );
1794  mc.mdSchema = uint_buf[0];
1795  mc.compressFlag = uint_buf[1];
1796 
1797  // Allocate space for the entries
1798  mc.metadataEntries.resize( uint_buf[2] );
1799 
1800  // Now read the metadata values
1801  for( unsigned int i = 0; i < mc.metadataEntries.size(); i++ )
1802  {
1803  FREADI( 2 );
1804  mc.metadataEntries[i].mdOwner = uint_buf[0];
1805  mc.metadataEntries[i].mdDataType = uint_buf[1];
1806 
1807  // Read the name string
1808  read_md_string( mc.metadataEntries[i].mdName );
1809 
1810  if( mc.metadataEntries[i].mdDataType == 0 )
1811  {
1812  // integer
1813  FREADI( 1 );
1814  mc.metadataEntries[i].mdIntValue = uint_buf[0];
1815  }
1816  else if( mc.metadataEntries[i].mdDataType == 1 )
1817  {
1818  // string
1819  read_md_string( mc.metadataEntries[i].mdStringValue );
1820  }
1821  else if( mc.metadataEntries[i].mdDataType == 2 )
1822  {
1823  // double
1824  FREADD( 1 );
1825  mc.metadataEntries[i].mdDblValue = dbl_buf[0];
1826  }
1827  else if( mc.metadataEntries[i].mdDataType == 3 )
1828  {
1829  // int array
1830  FREADI( 1 );
1831  mc.metadataEntries[i].mdIntArrayValue.resize( uint_buf[0] );
1832  FREADI( mc.metadataEntries[i].mdIntArrayValue.size() );
1833  std::copy( uint_buf.begin(), uint_buf.begin() + mc.metadataEntries[i].mdIntArrayValue.size(),
1834  mc.metadataEntries[i].mdIntArrayValue.begin() );
1835  }
1836  else if( mc.metadataEntries[i].mdDataType == 4 )
1837  {
1838  // double array
1839  FREADI( 1 );
1840  mc.metadataEntries[i].mdDblArrayValue.resize( uint_buf[0] );
1841  FREADD( mc.metadataEntries[i].mdDblArrayValue.size() );
1842  std::copy( dbl_buf.begin(), dbl_buf.begin() + mc.metadataEntries[i].mdDblArrayValue.size(),
1843  mc.metadataEntries[i].mdDblArrayValue.begin() );
1844  }
1845  else
1846  return MB_FAILURE;
1847  }
1848  if( debug ) mc.print();
1849 
1850  return MB_SUCCESS;
1851 }

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_model_entries()

ErrorCode moab::Tqdcfr::read_model_entries ( )

Definition at line 1756 of file Tqdcfr.cpp.

1757 {
1758  // Read model entries
1760  FREADI( fileTOC.numModels * 6 );
1761  modelEntries.resize( fileTOC.numModels );
1762  if( modelEntries.empty() ) return MB_FAILURE;
1763  std::vector< unsigned int >::iterator int_it = uint_buf.begin();
1764  for( unsigned int i = 0; i < fileTOC.numModels; i++ )
1765  {
1766  modelEntries[i].modelHandle = *int_it++;
1767  modelEntries[i].modelOffset = *int_it++;
1768  modelEntries[i].modelLength = *int_it++;
1769  modelEntries[i].modelType = *int_it++;
1770  modelEntries[i].modelOwner = *int_it++;
1771  modelEntries[i].modelPad = *int_it++;
1772  if( int_it == uint_buf.end() && i != fileTOC.numModels - 1 ) return MB_FAILURE;
1773  if( debug ) modelEntries[i].print();
1774  }
1775 
1776  return MB_SUCCESS;
1777 }

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_nodes()

ErrorCode moab::Tqdcfr::read_nodes ( const unsigned int  gindex,
Tqdcfr::ModelEntry model,
Tqdcfr::GeomHeader entity 
)

Definition at line 1371 of file Tqdcfr.cpp.

1372 {
1373  if( entity->nodeCt == 0 )
1374  {
1375  if( debug ) std::cout << "(no nodes) ";
1376  return MB_SUCCESS;
1377  }
1378 
1379  // Get the ids & coords in separate calls to minimize memory usage
1380  // Position the file
1381  FSEEK( model->modelOffset + entity->nodeOffset );
1382  // Get node ids in uint_buf
1383  FREADI( entity->nodeCt );
1384 
1385  if( debug )
1386  {
1387  std::cout << "(";
1388  for( unsigned int i = 0; i < entity->nodeCt; i++ )
1389  {
1390  std::cout << uint_buf[i];
1391  if( i != entity->nodeCt - 1 ) std::cout << ", ";
1392  }
1393  std::cout << ")...";
1394  }
1395 
1396  // Get a space for reading nodal data directly into MB, and read that data
1397  EntityHandle vhandle = 0;
1398  std::vector< double* > arrays;
1399  readUtilIface->get_node_coords( 3, entity->nodeCt, uint_buf[0], vhandle, arrays,
1401 
1402  // Get node x's in arrays[0]
1403  FREADDA( entity->nodeCt, arrays[0] );
1404  // Get node y's in arrays[1]
1405  FREADDA( entity->nodeCt, arrays[1] );
1406  // Get node z's in arrays[2]
1407  FREADDA( entity->nodeCt, arrays[2] );
1408 
1409  // Add these nodes into the entity's set
1410  Range dum_range( vhandle, vhandle + entity->nodeCt - 1 );
1411  ErrorCode result = mdbImpl->add_entities( entity->setHandle, dum_range );
1412  if( MB_SUCCESS != result ) return result;
1413 
1414  // Check for id contiguity; know that cid's will never be > 32bit, so
1415  // ids can be unsigned int
1416  unsigned int max_cid, min_cid;
1417  int contig;
1418  check_contiguous( entity->nodeCt, contig, min_cid, max_cid );
1419 
1420  // Compute the offset we get in this batch and compare to any previous one
1421  long vhandle_offset = vhandle - min_cid;
1422  if( -1 == currVHandleOffset ) currVHandleOffset = vhandle_offset;
1423 
1424  // In 2 situations we'll need to add/modify a cubit_id -> vhandle map:
1425  // case A: no map yet, and either this offset different from
1426  // previous or not contiguous
1427  if( !cubMOABVertexMap && ( currVHandleOffset != vhandle_offset || !contig ) )
1428  {
1429  // Get all vertices, removing ones in this batch
1430  Range vrange, tmp_range( dum_range );
1431  result = mdbImpl->get_entities_by_type( 0, MBVERTEX, vrange );RR;
1432  if( !beforeEnts.empty() ) tmp_range.merge( beforeEnts.subset_by_type( MBVERTEX ) );
1433  vrange = subtract( vrange, tmp_range );
1434  // Compute the max cid; map is indexed by cid, so size is max_cid + 1
1435 #define MAX( a, b ) ( ( a ) > ( b ) ? ( a ) : ( b ) )
1436 #define MIN( a, b ) ( ( a ) < ( b ) ? ( a ) : ( b ) )
1437  // Sanity check that max vhandle is larger than offset
1438  long new_max = *vrange.rbegin() - currVHandleOffset;
1439  assert( new_max >= 0 && ( (long)*vrange.begin() ) - currVHandleOffset >= 0 );
1440  max_cid = MAX( max_cid, ( (unsigned int)new_max ) );
1441  cubMOABVertexMap = new std::vector< EntityHandle >( max_cid + 1 );
1442  // Initialize to zero then put previous vertices into the map
1443  std::fill( cubMOABVertexMap->begin(), cubMOABVertexMap->end(), 0 );
1444  Range::iterator rit;
1445  for( rit = vrange.begin(); rit != vrange.end(); ++rit )
1446  {
1447  assert( ( (long)*rit ) - currVHandleOffset >= 0 && ( (long)*rit ) - currVHandleOffset <= max_cid );
1448  ( *cubMOABVertexMap )[*rit - currVHandleOffset] = *rit;
1449  }
1450  }
1451  // case B: there is a map and we need to resize it
1452  else if( cubMOABVertexMap && max_cid + 1 > cubMOABVertexMap->size() )
1453  {
1454  unsigned int old_size = cubMOABVertexMap->size();
1455  cubMOABVertexMap->resize( max_cid + 1 );
1456  std::fill( &( *cubMOABVertexMap )[old_size], &( *cubMOABVertexMap )[0] + cubMOABVertexMap->size(), 0 );
1457  }
1458 
1459  // OK, we have a map or don't need one
1460  if( NULL == cubMOABVertexMap )
1461  {
1462  // If we're not forward-contiguous (i.e. we're reverse or
1463  // out-of-order contiguous), re-order coordinates for handles
1464  // so that they are
1465  if( -1 == contig || -2 == contig )
1466  {
1467  // In case the arrays are large, do each coord separately
1468  std::vector< double > tmp_coords( entity->nodeCt );
1469  for( unsigned int j = 0; j < 3; j++ )
1470  {
1471  // Permute the coords into new order
1472  for( unsigned int i = 0; i < entity->nodeCt; i++ )
1473  {
1474  assert( uint_buf[i] >= min_cid && max_cid - uint_buf[i] < entity->nodeCt );
1475  tmp_coords[uint_buf[i] - min_cid] = arrays[j][i];
1476  }
1477  // Copy the permuted to storage
1478  std::copy( &tmp_coords[0], &tmp_coords[0] + entity->nodeCt, arrays[j] );
1479  }
1480  // Now re-order the ids; either way just go off min, max cid
1481  for( unsigned int i = 0; i < entity->nodeCt; i++ )
1482  uint_buf[i] = min_cid + i;
1483  }
1484  else if( !contig )
1485  // Shouldn't get here, since in non-contiguous case map should be there
1486  assert( false );
1487  }
1488  else
1489  {
1490  // Put new vertices into the map
1491  // Now set the new values
1492  unsigned int* vit = &uint_buf[0];
1493  Range::iterator rit = dum_range.begin();
1494  for( ; rit != dum_range.end(); vit++, ++rit )
1495  {
1496  assert( *vit < cubMOABVertexMap->size() );
1497  ( *cubMOABVertexMap )[*vit] = *rit;
1498  }
1499  }
1500 
1501  // No longer need to use uint_buf; convert in-place to ints, so we
1502  // can assign gid tag
1503  CONVERT_TO_INTS( entity->nodeCt );
1504  result = mdbImpl->tag_set_data( globalIdTag, dum_range, &int_buf[0] );
1505  if( MB_SUCCESS != result ) return result;
1506 
1507  // Set the dimension to at least zero (entity has at least nodes) on the geom tag
1508  int max_dim = 0;
1509  result = mdbImpl->tag_set_data( geomTag, &( entity->setHandle ), 1, &max_dim );
1510  if( MB_SUCCESS != result ) return result;
1511  // Set the category tag just in case there're only vertices in this set
1512  result = mdbImpl->tag_set_data( categoryTag, &entity->setHandle, 1, &geom_categories[0] );
1513  if( MB_SUCCESS != result ) return result;
1514 
1515  // Get fixed node data and assign
1516  int md_index = model->nodeMD.get_md_entry( gindex, "FixedNodes" );
1517  if( -1 == md_index ) return MB_SUCCESS;
1518  MetaDataContainer::MetaDataEntry* md_entry = &( model->nodeMD.metadataEntries[md_index] );
1519 
1520  std::vector< int > fixed_flags( entity->nodeCt );
1521  std::fill( fixed_flags.begin(), fixed_flags.end(), 0 );
1522  if( md_entry->mdDataType != 3 ) return MB_FAILURE;
1523 
1524  for( std::vector< unsigned int >::iterator vit = md_entry->mdIntArrayValue.begin();
1525  vit != md_entry->mdIntArrayValue.end(); ++vit )
1526  {
1527 #ifndef NDEBUG
1528  EntityHandle fixed_v =
1529  ( cubMOABVertexMap ? ( *cubMOABVertexMap )[*vit] : (EntityHandle)currVHandleOffset + *vit );
1530  assert( fixed_v >= *dum_range.begin() && fixed_v <= *dum_range.rbegin() );
1531 #endif
1532  fixed_flags[*vit - *dum_range.begin()] = 1;
1533  }
1534 
1535  Tag fixedFlagTag;
1536  int dum_val = 0;
1537  result = mdbImpl->tag_get_handle( "NodeFixed", 1, MB_TYPE_INTEGER, fixedFlagTag, MB_TAG_SPARSE | MB_TAG_CREAT,
1538  &dum_val );
1539  if( MB_SUCCESS != result ) return result;
1540  result = mdbImpl->tag_set_data( fixedFlagTag, dum_range, &fixed_flags[0] );
1541 
1542  return result;
1543 }

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().

◆ read_nodeset()

ErrorCode moab::Tqdcfr::read_nodeset ( const unsigned int  nsindex,
Tqdcfr::ModelEntry model,
Tqdcfr::NodesetHeader nodeseth 
)

Definition at line 583 of file Tqdcfr.cpp.

584 {
585  if( nodeseth->memTypeCt == 0 ) return MB_SUCCESS;
586 
587  // Position file
588  FSEEK( model->modelOffset + nodeseth->memOffset );
589 
590  // Read ids for each entity type
591  unsigned int this_type, num_ents; //, uid;
592  std::vector< char > bc_data;
593  unsigned int num_read = 0;
594  std::vector< EntityHandle > ns_entities, excl_entities;
595  for( unsigned int i = 0; i < nodeseth->memTypeCt; i++ )
596  {
597  // Get how many and what type
598  FREADI( 2 );
599  num_read += 2 * sizeof( int );
600  this_type = uint_buf[0];
601  num_ents = uint_buf[1];
602 
603  // Now get the ids
604  FREADI( num_ents );
605  num_read += sizeof( int );
606  CONVERT_TO_INTS( num_ents );
607 
608  ErrorCode result = get_entities( this_type + 2, &int_buf[0], num_ents, ns_entities, excl_entities );
609  if( MB_SUCCESS != result ) return result;
610  }
611  // Check for more data
612  if( num_read < nodeseth->nsLength )
613  {
614  FREADC( 2 ); // num_read += 2;
615  if( char_buf[0] == 'i' && char_buf[1] == 'd' )
616  {
617  FREADI( 1 ); // num_read += sizeof(int);
618  // uid = int_buf[0];
619  }
620  else
621  {
622  if( char_buf[0] == 'b' && char_buf[1] == 'c' )
623  {
624  FREADI( 1 ); // num_read += sizeof(int);
625  int num_bcs = uint_buf[0];
626  bc_data.resize( num_bcs );
627  FREADCA( num_bcs, &bc_data[0] ); // num_read += num_bcs;
628  }
629  }
630  }
631 
632  if( debug )
633  {
634  nodeseth->print();
635  if( !bc_data.empty() )
636  {
637  std::cout << "bc_data = ";
638  std::vector< char >::iterator vit = bc_data.begin();
639  for( ; vit != bc_data.end(); ++vit )
640  {
641  std::cout << std::hex << (int)( (unsigned char)*vit ) << " ";
642  }
643  std::cout << ": ";
644  vit = bc_data.begin();
645  for( ; vit != bc_data.end(); ++vit )
646  {
647  std::cout << *vit;
648  }
649  std::cout << std::endl;
650  }
651  }
652 
653  // And put entities into this nodeset's set
654  ErrorCode result = put_into_set( nodeseth->setHandle, ns_entities, excl_entities );
655  if( MB_SUCCESS != result ) return result;
656 
657  result = get_names( model->nodesetMD, nsindex, nodeseth->setHandle );
658  if( MB_SUCCESS != result ) return result;
659 
660  const int def_bc_data_len = 0;
661  std::string tag_name = std::string( DIRICHLET_SET_TAG_NAME ) + "__BC_DATA";
662  Tag nbc_data;
663  result = mdbImpl->tag_get_handle( tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nbc_data,
665  if( MB_SUCCESS != result ) return result;
666  void const* tag_data[] = { ( bc_data.empty() ) ? NULL : &( bc_data[0] ) };
667  int tag_size = bc_data.size();
668  result = mdbImpl->tag_set_by_ptr( nbc_data, &nodeseth->setHandle, 1, tag_data, &tag_size );
669  if( MB_SUCCESS != result ) return result;
670 
671  return result;
672 }

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().

◆ read_sideset()

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.

678 {
679  if( sideseth->memCt == 0 ) return MB_SUCCESS;
680 
681  ErrorCode result;
682 
683  // Position file
684  FSEEK( model->modelOffset + sideseth->memOffset );
685 
686  // Read ids for each entity type
687  unsigned int this_type, num_ents, sense_size;
688 
689  std::vector< char > bc_data;
690  unsigned int num_read = 0; //, uid;
691  std::vector< EntityHandle > ss_entities, excl_entities;
692  if( data_version <= 1.0 )
693  {
694  for( unsigned int i = 0; i < sideseth->memTypeCt; i++ )
695  {
696  // Get how many and what type
697  FREADI( 3 );
698  num_read += 3 * sizeof( int );
699  this_type = uint_buf[0];
700  num_ents = uint_buf[1];
701  sense_size = uint_buf[2];
702 
703  // Now get the ids
704  FREADI( num_ents );
705  num_read += sizeof( int );
706  CONVERT_TO_INTS( num_ents );
707 
708  result = get_entities( this_type + 2, &int_buf[0], num_ents, ss_entities, excl_entities );
709  if( MB_SUCCESS != result ) return result;
710 
711  if( sense_size == 1 )
712  {
713  // Byte-size sense flags; make sure read ends aligned...
714  unsigned int read_length = ( num_ents / 8 ) * 8;
715  if( read_length < num_ents ) read_length += 8;
716  FREADC( read_length );
717  num_read += read_length;
718  }
719  else if( sense_size == 2 )
720  {
721  // Int-size sense flags
722  FREADI( num_ents );
723  num_read += sizeof( int );
724  }
725 
726  // Now do something with them...
727  process_sideset_10( this_type, num_ents, sense_size, ss_entities, sideseth );
728  }
729  }
730  else
731  {
732  for( unsigned int i = 0; i < sideseth->memTypeCt; i++ )
733  {
734  // Get how many and what type
735  FREADI( 1 );
736  num_read += sizeof( int );
737  num_ents = uint_buf[0];
738 
739  // Get the types, and ids
740  std::vector< unsigned int > mem_types( num_ents ), mem_ids( num_ents );
741  FREADIA( num_ents, &mem_types[0] );
742  num_read += num_ents * sizeof( int );
743  FREADI( num_ents );
744  num_read += sizeof( int );
745 
746  result = get_entities( &mem_types[0], &int_buf[0], num_ents, false, ss_entities );
747  if( MB_SUCCESS != result ) return result;
748 
749  // Byte-size sense flags; make sure read ends aligned...
750  unsigned int read_length = ( num_ents / 8 ) * 8;
751  if( read_length < num_ents ) read_length += 8;
752  FREADC( read_length );
753  num_read += read_length;
754 
755  // wrt entities
756  FREADI( 1 );
757  num_read += sizeof( int );
758  int num_wrts = uint_buf[0];
759  FREADI( num_wrts );
760  num_read += num_wrts * sizeof( int );
761 
762  result = process_sideset_11( ss_entities, num_wrts, sideseth );
763  if( MB_SUCCESS != result ) return result;
764  }
765  }
766 
767  // Now set the dist factors
768  if( sideseth->numDF > 0 )
769  {
770  // Have to read dist factors
771  FREADD( sideseth->numDF );
772  num_read += sideseth->numDF * sizeof( double );
773  Tag distFactorTag;
774  result = mdbImpl->tag_get_handle( "distFactor", 0, MB_TYPE_DOUBLE, distFactorTag,
776  if( MB_SUCCESS != result ) return result;
777  const void* dist_data = &dbl_buf[0];
778  const int dist_size = sideseth->numDF;
779  result = mdbImpl->tag_set_by_ptr( distFactorTag, &sideseth->setHandle, 1, &dist_data, &dist_size );
780  if( MB_SUCCESS != result ) return result;
781  }
782 
783  // Check for more data
784  if( data_version > 1.0 && num_read < sideseth->ssLength )
785  {
786  FREADC( 2 ); // num_read += 2;
787  if( char_buf[0] == 'i' && char_buf[1] == 'd' )
788  {
789  FREADI( 1 ); // num_read += sizeof(int);
790  // uid = int_buf[0];
791  }
792  else
793  {
794  // Check for bc_data
795  if( char_buf[0] == 'b' && char_buf[1] == 'c' )
796  {
797  FREADI( 1 ); // num_read += sizeof(int);
798  int num_bcs = uint_buf[0];
799  bc_data.resize( num_bcs );
800  FREADCA( num_bcs, &bc_data[0] ); // num_read += num_bcs;
801  }
802  }
803  }
804 
805  if( debug )
806  {
807  sideseth->print();
808  if( !bc_data.empty() )
809  {
810  std::cout << "bc_data = ";
811  std::vector< char >::iterator vit = bc_data.begin();
812  for( ; vit != bc_data.end(); ++vit )
813  {
814  std::cout << std::hex << (int)( (unsigned char)*vit ) << " ";
815  }
816  std::cout << ": ";
817  vit = bc_data.begin();
818  for( ; vit != bc_data.end(); ++vit )
819  {
820  std::cout << *vit;
821  }
822  std::cout << std::endl;
823  }
824  }
825 
826  result = get_names( model->sidesetMD, ssindex, sideseth->setHandle );
827  if( MB_SUCCESS != result ) return result;
828 
829  const int def_bc_data_len = 0;
830  std::string tag_name = std::string( NEUMANN_SET_TAG_NAME ) + "__BC_DATA";
831  Tag nbc_data;
832  result = mdbImpl->tag_get_handle( tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nbc_data,
834  if( MB_SUCCESS != result ) return result;
835  void const* tag_data[] = { ( bc_data.empty() ) ? NULL : &( bc_data[0] ) };
836  int tag_size = bc_data.size();
837  result = mdbImpl->tag_set_by_ptr( nbc_data, &sideseth->setHandle, 1, tag_data, &tag_size );
838  if( MB_SUCCESS != result ) return result;
839 
840  return MB_SUCCESS;
841 }

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().

◆ read_tag_values()

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.

Parameters
file_nameThe file to read.
tag_nameThe tag for which to read values
tag_values_outOutput: The list of tag values.
subset_listAn 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_lengthThe length of the 'subset_list' array.

Implements moab::ReaderIface.

Definition at line 287 of file Tqdcfr.cpp.

292 {
293  return MB_NOT_IMPLEMENTED;
294 }

References MB_NOT_IMPLEMENTED.

◆ reset_record()

ErrorCode moab::Tqdcfr::reset_record ( AcisRecord this_record)
private

Definition at line 2709 of file Tqdcfr.cpp.

2710 {
2711  this_record.rec_type = Tqdcfr::UNKNOWN;
2712  this_record.att_string.clear();
2713  this_record.first_attrib = this_record.att_prev = this_record.att_next = this_record.att_ent_num = -1;
2714  this_record.processed = false;
2715  this_record.entity = 0;
2716 
2717  return MB_SUCCESS;
2718 }

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().

◆ type_from_cub_type()

EntityType moab::Tqdcfr::type_from_cub_type ( const unsigned int  cub_type,
const unsigned int  nodes_per_elem 
)

Member Data Documentation

◆ acisDumpFile

FILE* moab::Tqdcfr::acisDumpFile
private

Definition at line 361 of file Tqdcfr.hpp.

Referenced by parse_acis_attribs(), and read_acis_records().

◆ attribVectorTag

Tag moab::Tqdcfr::attribVectorTag

Definition at line 282 of file Tqdcfr.hpp.

Referenced by interpret_acis_records(), parse_acis_attribs(), and ~Tqdcfr().

◆ beforeEnts

Range moab::Tqdcfr::beforeEnts

Definition at line 280 of file Tqdcfr.hpp.

Referenced by load_file(), and read_nodes().

◆ block_type_to_mb_type

const EntityType moab::Tqdcfr::block_type_to_mb_type
staticprivate

◆ blockTag

◆ categoryTag

◆ char_buf

std::vector< char > moab::Tqdcfr::char_buf

◆ cub_elem_num_verts

const int moab::Tqdcfr::cub_elem_num_verts
staticprivate
Initial value:
= { 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().

◆ cub_elem_num_verts_len

const int moab::Tqdcfr::cub_elem_num_verts_len = sizeof( cub_elem_num_verts ) / sizeof( cub_elem_num_verts[0] )
staticprivate

Definition at line 435 of file Tqdcfr.hpp.

Referenced by moab::Tqdcfr::BlockHeader::read_info_header().

◆ cubFile

FILE* moab::Tqdcfr::cubFile

Definition at line 275 of file Tqdcfr.hpp.

Referenced by FREADCA(), FREADDA(), FREADIA(), FSEEK(), load_file(), and read_file_header().

◆ cubIdTag

Tag moab::Tqdcfr::cubIdTag

Definition at line 282 of file Tqdcfr.hpp.

◆ cubMOABVertexMap

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().

◆ currElementIdOffset

long moab::Tqdcfr::currElementIdOffset[MBMAXTYPE]

Definition at line 281 of file Tqdcfr.hpp.

Referenced by read_elements(), and Tqdcfr().

◆ currVHandleOffset

long moab::Tqdcfr::currVHandleOffset

Definition at line 279 of file Tqdcfr.hpp.

Referenced by get_mesh_entities(), read_elements(), read_nodes(), and Tqdcfr().

◆ dbl_buf

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().

◆ entityNameTag

Tag moab::Tqdcfr::entityNameTag

Definition at line 282 of file Tqdcfr.hpp.

Referenced by get_names(), parse_acis_attribs(), read_group(), and Tqdcfr().

◆ fileTOC

FileTOC moab::Tqdcfr::fileTOC

◆ geom_categories

const char moab::Tqdcfr::geom_categories = { "Vertex\0", "Curve\0", "Surface\0", "Volume\0" }
staticprivate

Definition at line 359 of file Tqdcfr.hpp.

Referenced by read_elements(), and read_nodes().

◆ geomTag

◆ gidSetMap

std::map< int, EntityHandle > moab::Tqdcfr::gidSetMap[6]

◆ globalIdTag

◆ group_type_to_mb_type

const EntityType moab::Tqdcfr::group_type_to_mb_type
staticprivate

◆ hasMidNodesTag

Tag moab::Tqdcfr::hasMidNodesTag

Definition at line 283 of file Tqdcfr.hpp.

Referenced by moab::Tqdcfr::BlockHeader::read_info_header().

◆ int_buf

int* moab::Tqdcfr::int_buf

◆ mdbImpl

◆ mFileSet

EntityHandle moab::Tqdcfr::mFileSet
private

Definition at line 342 of file Tqdcfr.hpp.

◆ modelEntries

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().

◆ modelMetaData

MetaDataContainer moab::Tqdcfr::modelMetaData

Definition at line 278 of file Tqdcfr.hpp.

Referenced by load_file().

◆ mp_type_to_mb_type

const EntityType moab::Tqdcfr::mp_type_to_mb_type
staticprivate
Initial value:

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().

◆ nsTag

◆ printedElemWarning

bool moab::Tqdcfr::printedElemWarning
private

Definition at line 346 of file Tqdcfr.hpp.

Referenced by read_elements().

◆ printedSeqWarning

bool moab::Tqdcfr::printedSeqWarning
private

Definition at line 344 of file Tqdcfr.hpp.

Referenced by process_record().

◆ readUtilIface

ReadUtilIface* moab::Tqdcfr::readUtilIface

Definition at line 273 of file Tqdcfr.hpp.

Referenced by load_file(), read_elements(), read_nodes(), Tqdcfr(), and ~Tqdcfr().

◆ ssTag

◆ swapForEndianness

bool moab::Tqdcfr::swapForEndianness

Definition at line 286 of file Tqdcfr.hpp.

Referenced by FREADDA(), FREADIA(), and read_file_header().

◆ uidSetMap

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().

◆ uint_buf

◆ uniqueIdTag

Tag moab::Tqdcfr::uniqueIdTag

The documentation for this class was generated from the following files: