moab
moab::Tqdcfr Class Reference

#include <Tqdcfr.hpp>

Inheritance diagram for moab::Tqdcfr:
moab::ReaderIface

List of all members.

Classes

struct  AcisRecord
class  BlockHeader
class  FEModelHeader
class  FileTOC
class  GeomHeader
class  GroupHeader
class  MetaDataContainer
class  ModelEntry
class  NodesetHeader
class  SidesetHeader

Public Types

enum  {
  aBODY, LUMP, SHELL, FACE,
  LOOP, COEDGE, aEDGE, aVERTEX,
  ATTRIB, UNKNOWN
}
enum  {
  mesh, acist, acisb, facet,
  exodusmesh
}

Public Member Functions

void FSEEK (unsigned offset)
void FREADI (unsigned num_ents)
void FREADD (unsigned num_ents)
void FREADC (unsigned num_ents)
void FREADIA (unsigned num_ents, unsigned int *array)
void FREADDA (unsigned num_ents, double *array)
void FREADCA (unsigned num_ents, char *arrat)
void CONVERT_TO_INTS (unsigned int num_ents)
 ~Tqdcfr ()
ErrorCode load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const SubsetList *subset_list=0, const Tag *file_id_tag=0)
 Load mesh from a file.
ErrorCode read_tag_values (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_values_out, const SubsetList *subset_list=0)
 Read tag values from a file.
ErrorCode read_nodeset (const unsigned int nsindex, ModelEntry *model, NodesetHeader *nodeseth)
ErrorCode read_sideset (const unsigned int ssindex, const double data_version, ModelEntry *model, SidesetHeader *sideseth)
ErrorCode read_block (const unsigned int blindex, const double data_version, ModelEntry *model, BlockHeader *blockh)
ErrorCode read_group (const unsigned int gr_index, ModelEntry *model, GroupHeader *grouph)
ErrorCode read_nodes (const unsigned int gindex, ModelEntry *model, GeomHeader *entity)
ErrorCode read_elements (ModelEntry *model, GeomHeader *entity)
ErrorCode read_file_header ()
ErrorCode read_model_entries ()
int find_model (const unsigned int model_type)
ErrorCode read_meta_data (const unsigned int metadata_offset, MetaDataContainer &mc)
ErrorCode read_md_string (std::string &name)
EntityType type_from_cub_type (const unsigned int cub_type, const unsigned int nodes_per_elem)
void check_contiguous (const unsigned int num_ents, int &contig, unsigned int &min_id, unsigned int &max_id)
 Tqdcfr (Interface *impl)
ErrorCode create_set (EntityHandle &h, unsigned int flags=MESHSET_SET)

Static Public Member Functions

static ReaderIfacefactory (Interface *)

Public Attributes

const unsigned int * ACIS_DIMS
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)
ErrorCode get_entities (const unsigned int this_type, int *id_buf, const unsigned int id_buf_size, std::vector< EntityHandle > &entities, std::vector< EntityHandle > &excl_entities)
 get entities specified by type and ids, append to entities
ErrorCode get_ref_entities (const unsigned int this_type, int *id_buf, const unsigned id_buf_size, std::vector< EntityHandle > &entities)
 get ref entity sets with specified type and ids
ErrorCode get_mesh_entities (const unsigned int this_type, int *id_buf, const unsigned id_buf_size, std::vector< EntityHandle > &entities, std::vector< EntityHandle > &excl_entities)
 get mesh entities with specified type and ids
ErrorCode process_sideset_10 (const int this_type, const int num_ents, const int sense_size, std::vector< EntityHandle > &ss_entities, Tqdcfr::SidesetHeader *sideseth)
ErrorCode process_sideset_11 (std::vector< EntityHandle > &ss_entities, int num_wrts, Tqdcfr::SidesetHeader *sideseth)
ErrorCode put_into_set (EntityHandle set_handle, std::vector< EntityHandle > &entities, std::vector< EntityHandle > &excl_entities)
ErrorCode get_names (MetaDataContainer &md, unsigned int set_index, EntityHandle seth)

Private Attributes

EntityHandle mFileSet
bool printedSeqWarning
bool printedElemWarning
FILE * acisDumpFile
std::vector< EntityHandle > * cubMOABVertexMap

Static Private Attributes

static const char geom_categories [][CATEGORY_TAG_SIZE]
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
static const EntityType mp_type_to_mb_type []
 mapping from mesh packet type to moab type

Detailed Description

Definition at line 45 of file Tqdcfr.hpp.


Member Enumeration Documentation

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

Definition at line 261 of file Tqdcfr.hpp.

anonymous enum
Enumerator:
mesh 
acist 
acisb 
facet 
exodusmesh 

Definition at line 338 of file Tqdcfr.hpp.

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

Definition at line 375 of file Tqdcfr.hpp.

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 378 of file Tqdcfr.hpp.


Constructor & Destructor Documentation

Definition at line 246 of file Tqdcfr.cpp.


Member Function Documentation

void moab::Tqdcfr::check_contiguous ( const unsigned int  num_ents,
int &  contig,
unsigned int &  min_id,
unsigned int &  max_id 
)

Definition at line 1554 of file Tqdcfr.cpp.

{
  unsigned int *id_it, curr_id, i;
  max_id = min_id = 0;

    // check in forward-contiguous direction
  id_it = &uint_buf[0];
  curr_id = *id_it++ + 1;
  contig = 1;
  min_id = uint_buf[0];
  max_id = uint_buf[0];
  for (i = 1; i < num_ents; id_it++, i++, curr_id++) {
    if (*id_it != curr_id) {
      contig = 0;
    }
    min_id = MIN(min_id, uint_buf[i]);
    max_id = MAX(max_id, uint_buf[i]);
  }

    // if we got here and we're at the end of the loop, it's forward-contiguous
  if (1 == contig) return;

// check in reverse-contiguous direction
  contig = -1;
  id_it = &uint_buf[0];
  curr_id = *id_it++ - 1;
  for (i = 1; i < num_ents; id_it++, i++, curr_id--) {
    if (*id_it != curr_id) {
      contig = 0;
      break;
    }
  }

    // if we got here and we're at the end of the loop, it's reverse-contiguous
  if (-1 == contig) return;

    // one final check, for contiguous but out of order
  if (max_id - min_id + 1 == num_ents) contig = -2;

    // else it's not contiguous at all
  contig = 0;
}

Definition at line 474 of file Tqdcfr.cpp.

{

    // look first for the nodeset and sideset offset flags; if they're not
    // set, we don't need to convert
  const EntityHandle msh = 0;
  unsigned int nodeset_offset, sideset_offset;
  Tag tmp_tag;
  ErrorCode result = mdbImpl->tag_get_handle(BLOCK_NODESET_OFFSET_TAG_NAME,
                                              1, MB_TYPE_INTEGER, tmp_tag);
  if (MB_SUCCESS != result) nodeset_offset = 0;
  else {
    result = mdbImpl->tag_get_data(tmp_tag, &msh, 1, &nodeset_offset);
    if (MB_SUCCESS != result) return result;
  }

  result = mdbImpl->tag_get_handle(BLOCK_SIDESET_OFFSET_TAG_NAME,
                                   1, MB_TYPE_INTEGER, tmp_tag);
  if (MB_SUCCESS != result) sideset_offset = 0;
  else {
    result = mdbImpl->tag_get_data(tmp_tag, &msh, 1, &sideset_offset);
    if (MB_SUCCESS != result) return result;
  }

  if (0 == nodeset_offset && 0 == sideset_offset) return MB_SUCCESS;

    // look for all blocks
  Range blocks;
  result = mdbImpl->get_entities_by_type_and_tag(0, MBENTITYSET,
                                                 &blockTag, NULL, 1,
                                                 blocks);
  if (MB_SUCCESS != result || blocks.empty()) return result;
  
    // get the id tag for them
  std::vector<int> block_ids(blocks.size());
  result = mdbImpl->tag_get_data(globalIdTag, blocks, &block_ids[0]);
  if (MB_SUCCESS != result) return result;

  unsigned int i = 0;
  Range::iterator rit = blocks.begin();
  Range new_nodesets, new_sidesets;
  std::vector<int> new_nodeset_ids, new_sideset_ids;
  for (; rit != blocks.end(); i++, rit++) {
    if (0 != nodeset_offset && block_ids[i] >= (int) nodeset_offset && 
        (nodeset_offset > sideset_offset || block_ids[i] < (int) sideset_offset)) {
        // this is a nodeset
      new_nodesets.insert(*rit);
      new_nodeset_ids.push_back(block_ids[i]);
    }
    else if (0 != sideset_offset && block_ids[i] >= (int) sideset_offset && 
             (sideset_offset > nodeset_offset || block_ids[i] < (int) nodeset_offset)) {
        // this is a sideset
      new_sidesets.insert(*rit);
      new_sideset_ids.push_back(block_ids[i]);
    }
  }

    // ok, have the new nodesets and sidesets; now remove the block tags, and
    // add nodeset and sideset tags
  ErrorCode tmp_result = MB_SUCCESS;
  if (0 != nodeset_offset) {
    if (0 == nsTag) {
      int default_val = 0;
      tmp_result = mdbImpl->tag_get_handle(DIRICHLET_SET_TAG_NAME,1, MB_TYPE_INTEGER, 
                                       nsTag, MB_TAG_SPARSE|MB_TAG_CREAT, &default_val);
      if (MB_SUCCESS != tmp_result) result = tmp_result;
    }
    if (MB_SUCCESS == tmp_result)
      tmp_result = mdbImpl->tag_set_data(nsTag, new_nodesets, 
                                         &new_nodeset_ids[0]);
    if (MB_SUCCESS != tmp_result) result = tmp_result;
    tmp_result = mdbImpl->tag_delete_data(blockTag, new_nodesets);
    if (MB_SUCCESS != tmp_result) result = tmp_result;
  }
  if (0 != sideset_offset) {
    if (0 == ssTag) {
      int default_val = 0;
      tmp_result = mdbImpl->tag_get_handle(NEUMANN_SET_TAG_NAME,1, MB_TYPE_INTEGER, 
                                       ssTag, MB_TAG_SPARSE|MB_TAG_CREAT, &default_val);
      if (MB_SUCCESS != tmp_result) result = tmp_result;
    }
    if (MB_SUCCESS == tmp_result) 
      tmp_result = mdbImpl->tag_set_data(ssTag, new_sidesets, 
                                         &new_sideset_ids[0]);
    if (MB_SUCCESS != tmp_result) result = tmp_result;
    tmp_result = mdbImpl->tag_delete_data(blockTag, new_sidesets);
    if (MB_SUCCESS != tmp_result) result = tmp_result;
  }

  return result;
}
void moab::Tqdcfr::CONVERT_TO_INTS ( unsigned int  num_ents)

Definition at line 210 of file Tqdcfr.cpp.

{
  for (unsigned int i = 0; i < num_ents; i++)
    int_buf[i] = uint_buf[i];
}
ErrorCode moab::Tqdcfr::create_set ( EntityHandle h,
unsigned int  flags = MESHSET_SET 
)

Definition at line 2908 of file Tqdcfr.cpp.

{
  return mdbImpl->create_meshset( flags, h );
}
ReaderIface * moab::Tqdcfr::factory ( Interface iface) [static]

Definition at line 216 of file Tqdcfr.cpp.

{ return new Tqdcfr( iface ); }
int moab::Tqdcfr::find_model ( const unsigned int  model_type)

Definition at line 1669 of file Tqdcfr.cpp.

{
  for (unsigned int i = 0; i < fileTOC.numModels; i++) 
    if (modelEntries[i].modelType == model_type) return i;
  
  return -1;
}
void moab::Tqdcfr::FREADC ( unsigned  num_ents)

Definition at line 150 of file Tqdcfr.cpp.

                                       {
  char_buf.resize( num_ents );
  FREADCA( num_ents, &char_buf[0] );
}
void moab::Tqdcfr::FREADCA ( unsigned  num_ents,
char *  arrat 
)

Definition at line 205 of file Tqdcfr.cpp.

                                                     {
  unsigned rval = fread( array, sizeof(char), num_ents, cubFile );
  IO_ASSERT( rval == num_ents );
}
void moab::Tqdcfr::FREADD ( unsigned  num_ents)

Definition at line 145 of file Tqdcfr.cpp.

                                       {
  dbl_buf.resize( num_ents );
  FREADDA( num_ents, &dbl_buf[0] );
}
void moab::Tqdcfr::FREADDA ( unsigned  num_ents,
double *  array 
)

Definition at line 191 of file Tqdcfr.cpp.

                                                       {
  unsigned rval = fread( array, sizeof(double), num_ents, cubFile );
  IO_ASSERT( rval == num_ents );
  if (swapForEndianness)
  {
    double  * pt=array;
    for (unsigned int i=0; i<num_ents; i++ )
    {
      swap8_voff((long *)pt);
      pt++;
    }
  }
}
void moab::Tqdcfr::FREADI ( unsigned  num_ents)

Definition at line 137 of file Tqdcfr.cpp.

                                       {
  if (uint_buf.size() < num_ents) {
    uint_buf.resize( num_ents );
    int_buf = (int*)&uint_buf[0];
  }
  FREADIA( num_ents, &uint_buf[0] );
}
void moab::Tqdcfr::FREADIA ( unsigned  num_ents,
unsigned int *  array 
)

Definition at line 176 of file Tqdcfr.cpp.

                                                             {
  unsigned rval = fread( array, sizeof(unsigned int), num_ents, cubFile );
  IO_ASSERT( rval == num_ents );
  if (swapForEndianness)
  {
    unsigned int  * pt=array;
    for (unsigned int i=0; i<num_ents; i++ )
    {
      swap4_uint((unsigned int *)pt);
      pt++;
    }
  }

}
void moab::Tqdcfr::FSEEK ( unsigned  offset)

Definition at line 132 of file Tqdcfr.cpp.

                                        {
  int rval = fseek( cubFile, offset, SEEK_SET );
  IO_ASSERT( !rval );
}
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 1158 of file Tqdcfr.cpp.

{
  ErrorCode tmp_result, result = MB_SUCCESS;
  
  for (unsigned int i = 0; i < id_buf_size; i++) {
    if (is_group)
      tmp_result = get_entities(mem_types[i], id_buf+i, 1, entities, entities);
    else
        // for blocks/nodesets/sidesets, use CSOEntityType, which is 2 greater than
        // group entity types
      tmp_result = get_entities(mem_types[i]+2, id_buf+i, 1, entities, entities);
    if (MB_SUCCESS != tmp_result) result = tmp_result;
  }
  return result;
}
ErrorCode moab::Tqdcfr::get_entities ( const unsigned int  this_type,
int *  id_buf,
const unsigned int  id_buf_size,
std::vector< EntityHandle > &  entities,
std::vector< EntityHandle > &  excl_entities 
) [private]

get entities specified by type and ids, append to entities

Definition at line 1177 of file Tqdcfr.cpp.

{
  ErrorCode result = MB_FAILURE;
  
  if (this_type <= VERTEX)
    result = get_ref_entities(this_type, id_buf, id_buf_size, entities);
  else if (this_type >= HEX && this_type <= NODE)
    result = get_mesh_entities(this_type, id_buf, id_buf_size, entities, excl_entities);

  return result;
}
ErrorCode moab::Tqdcfr::get_mesh_entities ( const unsigned int  this_type,
int *  id_buf,
const unsigned  id_buf_size,
std::vector< EntityHandle > &  entities,
std::vector< EntityHandle > &  excl_entities 
) [private]

get mesh entities with specified type and ids

Definition at line 1202 of file Tqdcfr.cpp.

{
  ErrorCode result = MB_SUCCESS;
  std::vector<EntityHandle> *ent_list = NULL;
  EntityType this_ent_type;
  if (this_type > 1000) {
    this_ent_type = group_type_to_mb_type[this_type-1000];
    ent_list = &excl_entities;
  }
  else {
    this_ent_type = group_type_to_mb_type[this_type];
    ent_list = &entities;
  }
  
    // get entities with this type, and get their cub id tags
  if (MBVERTEX == this_ent_type) {
      // use either vertex offset or cubMOABVertexMap
    if (NULL == cubMOABVertexMap) {
      for (unsigned int i = 0; i < id_buf_size; i++)
        ent_list->push_back((EntityHandle)(id_buf[i]+currVHandleOffset));
    }
    else {
      for (unsigned int i = 0; i < id_buf_size; i++) {
        assert(0 != (*cubMOABVertexMap)[id_buf[i]]);
        ent_list->push_back((*cubMOABVertexMap)[id_buf[i]]);
      }
    }
  }
  else {
    Range tmp_ents;
    result = mdbImpl->get_entities_by_type(0, this_ent_type, tmp_ents);
    if (MB_SUCCESS != result) return result;
    if (tmp_ents.empty() && 0 != id_buf_size) return MB_FAILURE;
  
    std::vector<int> cub_ids(tmp_ents.size());
    result = mdbImpl->tag_get_data(globalIdTag, tmp_ents, &cub_ids[0]);
    if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) return result;
  
      // now go through id list, finding each entity by id
    for (unsigned int i = 0; i < id_buf_size; i++) {
      std::vector<int>::iterator vit = 
        std::find(cub_ids.begin(), cub_ids.end(), id_buf[i]);
      if (vit != cub_ids.end()) {
        EntityHandle this_ent = tmp_ents[vit-cub_ids.begin()];
        if (mdbImpl->type_from_handle(this_ent) != MBMAXTYPE) ent_list->push_back(this_ent);
      }
      else {
        std::cout << "Warning: didn't find " << CN::EntityTypeName(this_ent_type) 
                  << " " << *vit << std::endl;
      }
    }
  }

  return result;
}
ErrorCode moab::Tqdcfr::get_names ( MetaDataContainer md,
unsigned int  set_index,
EntityHandle  seth 
) [private]

Definition at line 1013 of file Tqdcfr.cpp.

{
  ErrorCode result = MB_SUCCESS;
  
    // now get block names, if any
  int md_index = md.get_md_entry(set_index, "Name");
  if (-1 == md_index) return result;
  MetaDataContainer::MetaDataEntry *md_entry = &(md.metadataEntries[md_index]);
  //assert(md_entry->mdStringValue.length()+1 <= NAME_TAG_SIZE);
  char name_tag_data[NAME_TAG_SIZE];
  memset( name_tag_data, 0, NAME_TAG_SIZE ); // make sure any extra bytes zeroed
  strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE );
  result = mdbImpl->tag_set_data(entityNameTag, &seth, 1, name_tag_data);
  if (MB_SUCCESS != result) return result;
    
    // look for extra names
  md_index = md.get_md_entry(set_index, "NumExtraNames");
  if (-1 == md_index) return result;
  int num_names = md.metadataEntries[md_index].mdIntValue;
  for (int i = 0; i < num_names; i++) {
    std::ostringstream extra_name_label( "ExtraName" );
    extra_name_label << i;
    std::ostringstream moab_extra_name( "EXTRA_" );
    moab_extra_name << NAME_TAG_NAME << i;
    md_index = md.get_md_entry(set_index, extra_name_label.str().c_str());
    if (-1 != md_index) {
      md_entry = &(md.metadataEntries[md_index]);
      Tag extra_name_tag;
      mdbImpl->tag_get_handle( moab_extra_name.str().c_str(), NAME_TAG_SIZE, 
                               MB_TYPE_OPAQUE, extra_name_tag, MB_TAG_SPARSE|MB_TAG_CREAT );
      memset( name_tag_data, 0, NAME_TAG_SIZE ); // make sure any extra bytes zeroed
      strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE );
      result = mdbImpl->tag_set_data(extra_name_tag, &seth, 1, name_tag_data);
    }
  }

  return result;
}
ErrorCode moab::Tqdcfr::get_ref_entities ( const unsigned int  this_type,
int *  id_buf,
const unsigned  id_buf_size,
std::vector< EntityHandle > &  entities 
) [private]

get ref entity sets with specified type and ids

Definition at line 1192 of file Tqdcfr.cpp.

{
  for (unsigned int i = 0; i < id_buf_size; i++)
    entities.push_back((gidSetMap[5-this_type])[id_buf[i]]);
  
  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::interpret_acis_records ( std::vector< AcisRecord > &  records) [private]

Definition at line 2370 of file Tqdcfr.cpp.

{
    // make a tag for the vector holding unrecognized attributes
  void *default_val = NULL;
  ErrorCode result = 
    mdbImpl->tag_get_handle("ATTRIB_VECTOR", sizeof(void*), MB_TYPE_OPAQUE, 
                        attribVectorTag, MB_TAG_CREAT|MB_TAG_SPARSE, &default_val);
  if (MB_SUCCESS != result) return result;

  unsigned int current_record = 0;

#define REC records[current_record]

  while (current_record != records.size()) {

      // if this record's been processed, or if it's an attribute, continue
    if (REC.processed || REC.rec_type == Tqdcfr::ATTRIB) {
      current_record++;
      continue;
    }

    if (REC.rec_type == Tqdcfr::UNKNOWN) {
      REC.processed = true;
      current_record++;
      continue;
    }
    
      // it's a known, non-attrib rec type; parse for any attribs
    parse_acis_attribs(current_record, records);

    REC.processed = true;
    
    current_record++;
  }

  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::load_file ( const char *  file_name,
const EntityHandle file_set,
const FileOptions opts,
const SubsetList subset_list = 0,
const Tag file_id_tag = 0 
) [virtual]

Load mesh from a file.

Method all readers must provide to import a mesh.

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 264 of file Tqdcfr.cpp.

{
  ErrorCode result;

  int tmpval;
  if (MB_SUCCESS == opts.get_int_option("DEBUG_IO", 1, tmpval)) {
    if (0 < tmpval) debug = true;
  }

  if (subset_list) {
    readUtilIface->report_error( "Reading subset of files not supported for CUB files." );
    return MB_UNSUPPORTED_OPERATION;
  }
  
    // open file
  cubFile = fopen(file_name, "rb");
  if (NULL == cubFile) {
    readUtilIface->report_error("File not found.");
    return MB_FAILURE;
  }
  
    // verify magic string
  FREADC(4);
  if (!(char_buf[0] == 'C' && char_buf[1] == 'U' && 
        char_buf[2] == 'B' && char_buf[3] == 'E')) {
    readUtilIface->report_error("This doesn't appear to be a .cub file.");
    return MB_FAILURE;
  }

    // get "before" entities
  result = mdbImpl->get_entities_by_handle(0, beforeEnts);
  if (MB_SUCCESS != result) {
    readUtilIface->report_error("Couldn't get \"before\" entities.");
    return result;
  }

    // ***********************
    // read model header type information...
    // ***********************
  if (debug) std::cout << "Reading file header." << std::endl;
  result = read_file_header(); RR;

  if (debug) std::cout << "Reading model entries." << std::endl;
  result = read_model_entries(); RR;
  
    // read model metadata
  if (debug) std::cout << "Reading model metadata." << std::endl;
  result = read_meta_data(fileTOC.modelMetaDataOffset, modelMetaData); RR;

  double data_version;
  int md_index = modelMetaData.get_md_entry(2, "DataVersion");
  if (-1 == md_index) data_version = 1.0;
  else data_version = modelMetaData.metadataEntries[md_index].mdDblValue;
  
    // get the major/minor cubit version that wrote this file
//  int major = -1, minor = -1;
  md_index = modelMetaData.get_md_entry(2, "CubitVersion");
  if (md_index >= 0 && !modelMetaData.metadataEntries[md_index].mdStringValue.empty())
    sscanf( modelMetaData.metadataEntries[md_index].mdStringValue.c_str(), "%d.%d",
            &major, &minor);
  
    // ***********************
    // read mesh...
    // ***********************
  int index = find_model(mesh); 
  if (-1 == index) return MB_FAILURE;
  ModelEntry *mesh_model = &modelEntries[index];
  
    // first the header & metadata info
  if (debug) std::cout << "Reading mesh model header and metadata." << std::endl;
  result = mesh_model->read_header_info(this, data_version);
  if (MB_SUCCESS != result)
    return result;
  result = mesh_model->read_metadata_info(this);
  if (MB_SUCCESS != result)
    return result;

    // now read in mesh for each geometry entity; read in order of increasing dimension
    // so we have all the mesh we need
  for (int dim = 0; dim < 4; dim++) {
    for (unsigned int gindex = 0; 
         gindex < mesh_model->feModelHeader.geomArray.numEntities;
         gindex++) {
      Tqdcfr::GeomHeader *geom_header = &mesh_model->feGeomH[gindex];

      if (geom_header->maxDim != dim) continue;

        // read nodes
      if (debug) std::cout << "Reading geom index " << gindex << " mesh: nodes... ";
      result = read_nodes(gindex, mesh_model, geom_header); 
      if (MB_SUCCESS != result)
        return result;
    
        // read elements
      if (debug) std::cout << "elements... ";
      result = read_elements(mesh_model, geom_header); 
      if (MB_SUCCESS != result)
        return result;
      if (debug) std::cout << std::endl;
    }
  }
  
    // ***********************
    // read acis records...
    // ***********************
  std::string sat_file_name;
  if (MB_SUCCESS != opts.get_str_option( "SAT_FILE", sat_file_name))
    sat_file_name.clear();
  result = read_acis_records( sat_file_name.empty() ? NULL : sat_file_name.c_str() ); RR;

    // ***********************
    // read groups...
    // ***********************
  if (debug) std::cout << "Reading groups... ";
  for (unsigned int grindex = 0; 
       grindex < mesh_model->feModelHeader.groupArray.numEntities;
       grindex++) {
    GroupHeader *group_header = &mesh_model->feGroupH[grindex];
    result = read_group(grindex, mesh_model, group_header); 
    if (MB_SUCCESS != result)
      return result;
  }
  if (debug) std::cout << mesh_model->feModelHeader.groupArray.numEntities 
                       << " read successfully." << std::endl;;
  
    // ***********************
    // read blocks...
    // ***********************
  if (debug) std::cout << "Reading blocks... ";
  Range ho_entities;
  for (unsigned int blindex = 0; 
       blindex < mesh_model->feModelHeader.blockArray.numEntities;
       blindex++) {
    BlockHeader *block_header = &mesh_model->feBlockH[blindex];
    result = read_block(blindex, data_version, mesh_model, block_header); 
    if (MB_SUCCESS != result)
      return result;
  }
  
  
  if (debug) std::cout << mesh_model->feModelHeader.blockArray.numEntities 
                       << " read successfully." << std::endl;;
  

    // ***********************
    // read nodesets...
    // ***********************
  if (debug) std::cout << "Reading nodesets... ";
  for (unsigned int nsindex = 0; 
       nsindex < mesh_model->feModelHeader.nodesetArray.numEntities;
       nsindex++) {
    NodesetHeader *nodeset_header = &mesh_model->feNodeSetH[nsindex];
    result = read_nodeset(nsindex, mesh_model, nodeset_header); 
    if (MB_SUCCESS != result)
      return result;
  }
  if (debug) std::cout << mesh_model->feModelHeader.nodesetArray.numEntities 
                       << " read successfully." << std::endl;;

    // ***********************
    // read sidesets...
    // ***********************
  if (debug) std::cout << "Reading sidesets...";
  for (unsigned int ssindex = 0; 
       ssindex < mesh_model->feModelHeader.sidesetArray.numEntities;
       ssindex++) {
    SidesetHeader *sideset_header = &mesh_model->feSideSetH[ssindex];
    result = read_sideset(ssindex, data_version, mesh_model, sideset_header); 
    if (MB_SUCCESS != result)
      return result;
  }
  if (debug) std::cout << mesh_model->feModelHeader.sidesetArray.numEntities 
                       << " read successfully." << std::endl;;

  if (debug) {
    std::cout << "Read the following mesh:" << std::endl;
    std::string dum;
    mdbImpl->list_entities(0, 0);
  }

    // **************************
    // restore geometric topology
    // **************************
  GeomTopoTool gtt(mdbImpl, true);
  result = gtt.restore_topology();
  if (MB_SUCCESS != result)
  {
    std::cout << "Failed to restore topology " << std::endl;
  }

    // convert blocks to nodesets/sidesets if tag is set
  result = convert_nodesets_sidesets();
  
  Range after_ents;
  result = mdbImpl->get_entities_by_handle(0, after_ents);
  if (MB_SUCCESS != result) 
    return result;

  after_ents = subtract( after_ents, beforeEnts);
  
  if (file_id_tag)
    readUtilIface->assign_ids( *file_id_tag, after_ents );

  return result;
}
ErrorCode moab::Tqdcfr::parse_acis_attribs ( const unsigned int  entity_rec_num,
std::vector< AcisRecord > &  records 
) [private]

Definition at line 2408 of file Tqdcfr.cpp.

{
  unsigned int num_read;
  std::vector<std::string> attrib_vec;
  char temp_name[1024];
  char name_tag_val[NAME_TAG_SIZE];
  std::string name_tag;
  int id = -1;
  int uid = -1;
  int next_attrib = -1;
  ErrorCode result;
  
  int current_attrib = records[entity_rec_num].first_attrib;
  if (-1 == current_attrib) return MB_SUCCESS;

  if (NULL != acisDumpFile) {
    fwrite("-----------------------------------------------------------------------\n", 1, 72, acisDumpFile);
    fwrite(records[entity_rec_num].att_string.c_str(), sizeof(char), 
           records[entity_rec_num].att_string.length(), acisDumpFile);
  }

  while (-1 != current_attrib) {
    if (records[current_attrib].rec_type != Tqdcfr::UNKNOWN &&
           (records[current_attrib].att_next != next_attrib ||
            records[current_attrib].att_ent_num != (int)entity_rec_num)) return MB_FAILURE;
    
    if (NULL != acisDumpFile)
      fwrite(records[current_attrib].att_string.c_str(), sizeof(char), 
             records[current_attrib].att_string.length(), acisDumpFile);

      // is the attrib one we already recognize?
    if (strncmp(records[current_attrib].att_string.c_str(), "ENTITY_NAME", 11) == 0) {
        // parse name
      int num_chars;
      num_read = sscanf(records[current_attrib].att_string.c_str(), "ENTITY_NAME @%d %s", &num_chars, temp_name);
      if (num_read != 2)
        num_read = sscanf(records[current_attrib].att_string.c_str(), "ENTITY_NAME %d %s", &num_chars, temp_name);
      if (num_read != 2) return MB_FAILURE;

        // put the name on the entity
      name_tag = std::string( temp_name, num_chars );
    }
    else if (strncmp(records[current_attrib].att_string.c_str(), "ENTITY_ID", 9) == 0) {
        // parse id
      int bounding_uid, bounding_sense;
      num_read = sscanf(records[current_attrib].att_string.c_str(), "ENTITY_ID 0 3 %d %d %d", 
                        &id, &bounding_uid, &bounding_sense);
      if (3 != num_read) {
          // try reading updated entity_id format, which has coordinate triple embedded in it too
        float dumx, dumy, dumz;
        num_read = sscanf(records[current_attrib].att_string.c_str(), 
                          "ENTITY_ID 3 %f %f %f 3 %d %d %d", 
                          &dumx, &dumy, &dumz, &id, &bounding_uid, &bounding_sense);
        num_read -= 3;
      }
      
      if (3 != num_read)  
        std::cout << "Warning: bad ENTITY_ID attribute in .sat file, record number " << entity_rec_num
                  << ", record follows:" << std::endl
                  << records[current_attrib].att_string.c_str() << std::endl;
      ;
    }
    else if (strncmp(records[current_attrib].att_string.c_str(), "UNIQUE_ID", 9) == 0) {
        // parse uid
      if (major >=14) // change of format for cubit 14:
        num_read =sscanf(records[current_attrib].att_string.c_str(), "UNIQUE_ID 0 1 %d", &uid);
      else
        num_read = sscanf(records[current_attrib].att_string.c_str(), "UNIQUE_ID 1 0 1 %d", &uid);
      if (1 != num_read) return MB_FAILURE;
    }
    else if (strncmp(records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 UNIQUE_ID", 29) == 0) {
        // parse uid
      int dum1, dum2, dum3, dum4;
      num_read = sscanf(records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 UNIQUE_ID %d %d %d %d %d",
          &dum1, &dum2, &dum3, &dum4, &uid);
      if (5 != num_read) return MB_FAILURE;
    }
    else if (strncmp(records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID", 29) == 0) {
        // parse id
      int dum1, dum2, dum3;
      num_read = sscanf(records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID %d %d %d %d",
          &dum1, &dum2, &dum3, &id);
      if (4 != num_read) return MB_FAILURE;
    }

    else {
      attrib_vec.push_back(records[current_attrib].att_string);
    }

    records[current_attrib].processed = true;
    next_attrib = current_attrib;
    current_attrib = records[current_attrib].att_prev;
  }

    // at this point, there aren't entity sets for entity types which don't contain mesh
    // in this case, just return
  if (records[entity_rec_num].rec_type == aBODY ||
      (records[entity_rec_num].entity == 0 && uid == -1)) {
    return MB_SUCCESS;
      // Warning: couldn't resolve entity of type 1 because no uid was found.
      // ddriv: GeomTopoTool.cpp:172: ErrorCode GeomTopoTool::separate_by_dimension(const Range&, Range*, void**): Assertion `false' failed.
      // xxx
  }
  
    // parsed the data; now put on mdb entities; first we need to find the entity
  if (records[entity_rec_num].entity == 0) {
    records[entity_rec_num].entity = uidSetMap[uid];
  }

  if (0==records[entity_rec_num].entity)
    return MB_SUCCESS; // we do not have a MOAB entity for this, skip

  //assert(records[entity_rec_num].entity);
  
    // set the id
  if (id != -1) {
    result = mdbImpl->tag_set_data(globalIdTag, &(records[entity_rec_num].entity), 1, &id);
    if (MB_SUCCESS != result) return result;

    int ent_dim = -1;
    if (records[entity_rec_num].rec_type == aBODY) ent_dim = 4;
    else if (records[entity_rec_num].rec_type == LUMP) ent_dim = 3;
    else if (records[entity_rec_num].rec_type == FACE) ent_dim = 2;
    else if (records[entity_rec_num].rec_type == aEDGE) ent_dim = 1;
    else if (records[entity_rec_num].rec_type == aVERTEX) ent_dim = 0;
    if (-1 != ent_dim) gidSetMap[ent_dim][id] = records[entity_rec_num].entity;
  }
  
    // set the name
  if (!name_tag.empty()) {
    if (0 == entityNameTag) {
      char dum_val[NAME_TAG_SIZE] = {0};
      result = mdbImpl->tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE,
                                       entityNameTag, MB_TAG_SPARSE|MB_TAG_CREAT, dum_val);
      if (MB_SUCCESS != result) return result;
    }
    
    size_t len = name_tag.size();
    if (len>=NAME_TAG_SIZE)
       len = NAME_TAG_SIZE-1;// truncate a name that is too big
    memcpy( name_tag_val, name_tag.c_str(), len );
    memset( name_tag_val+len, '\0', NAME_TAG_SIZE-len );
    result = mdbImpl->tag_set_data(entityNameTag, &(records[entity_rec_num].entity), 1, name_tag_val);
    if (MB_SUCCESS != result) return result;
  }

  if (!attrib_vec.empty()) {
      // put the attrib vector in a tag on the entity
    std::vector<std::string> *dum_vec;
    result = mdbImpl->tag_get_data(attribVectorTag, &(records[entity_rec_num].entity), 1, &dum_vec);
    if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result) return result;
    if (MB_TAG_NOT_FOUND == result || dum_vec == NULL) {
        // put this list directly on the entity
      dum_vec = new std::vector<std::string>;
      dum_vec->swap(attrib_vec);
      result = mdbImpl->tag_set_data(attribVectorTag, &(records[entity_rec_num].entity), 1, &dum_vec);
      if (MB_SUCCESS != result) {
        delete dum_vec;
        return result;
      }
    }
    else {
        // copy this list over, and delete this list
      std::copy(attrib_vec.begin(), attrib_vec.end(), 
                std::back_inserter(*dum_vec));
    }
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::process_record ( AcisRecord this_record) [private]

Definition at line 2592 of file Tqdcfr.cpp.

{
    // get the entity type
  const char *type_substr;

    // try attribs first, since the others have some common processing between them
  if ((type_substr = strstr(this_record.att_string.c_str(), "attrib")) != NULL && 
      type_substr-this_record.att_string.c_str() < 20) {
    this_record.rec_type = Tqdcfr::ATTRIB;
    bool simple_attrib = false;
    bool generic_attrib = false;
    if ((type_substr = strstr(this_record.att_string.c_str(), "simple-snl-attrib")) != NULL)
      simple_attrib = true;
    else if ((type_substr = strstr(this_record.att_string.c_str(), "integer_attrib-name_attrib-gen-attrib")) != NULL)
      generic_attrib = true;
    else {
      this_record.rec_type = Tqdcfr::UNKNOWN;
      return MB_SUCCESS;
    }

      // find next space
    type_substr = strchr(type_substr, ' ');
    if (NULL == type_substr) return MB_FAILURE;
    
      // read the numbers from there
    int num_converted = sscanf(type_substr, " $-1 -1 $%d $%d $%d -1", &(this_record.att_prev), 
                               &(this_record.att_next), &(this_record.att_ent_num));
    if (num_converted != 3) return MB_FAILURE;
    
      // trim the string to the attribute, if it's a simple attrib
    if (simple_attrib) {
      type_substr = strstr(this_record.att_string.c_str(), "NEW_SIMPLE_ATTRIB");
      if (NULL == type_substr) return MB_FAILURE;
      type_substr = strstr(type_substr, "@");
      if (NULL == type_substr) return MB_FAILURE;
      type_substr = strstr(type_substr, " ") + 1;
      if (NULL == type_substr) return MB_FAILURE;
        // copy the rest of the string to a dummy string
      std::string dum_str(type_substr);
      this_record.att_string = dum_str;
    }
    else if (generic_attrib) {
      type_substr = strstr(this_record.att_string.c_str(), "CUBIT_ID");
      if (NULL == type_substr) return MB_FAILURE;
        // copy the rest of the string to a dummy string
      std::string dum_str(type_substr);
      this_record.att_string = dum_str;
    }
  }
  else {
      // else it's a topological entity, I think
    if ((type_substr = strstr(this_record.att_string.c_str(), "body")) != NULL 
        && type_substr-this_record.att_string.c_str() < 20) {
      this_record.rec_type = Tqdcfr::aBODY;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "lump")) != NULL  && 
             type_substr-this_record.att_string.c_str() < 20) {
      this_record.rec_type = Tqdcfr::LUMP;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "shell")) != NULL && 
             type_substr-this_record.att_string.c_str() < 20) {
        // don't care about shells
      this_record.rec_type = Tqdcfr::UNKNOWN;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "surface")) != NULL && 
             type_substr-this_record.att_string.c_str() < 20) {
        // don't care about surfaces
      this_record.rec_type = Tqdcfr::UNKNOWN;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "face")) != NULL && 
             type_substr-this_record.att_string.c_str() < 20) {
      this_record.rec_type = Tqdcfr::FACE;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "loop")) != NULL && 
             type_substr-this_record.att_string.c_str() < 20) {
        // don't care about loops
      this_record.rec_type = Tqdcfr::UNKNOWN;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "coedge")) != NULL && 
             type_substr-this_record.att_string.c_str() < 20) {
        // don't care about coedges
      this_record.rec_type = Tqdcfr::UNKNOWN;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "edge")) != NULL && 
             type_substr-this_record.att_string.c_str() < 20) {
      this_record.rec_type = Tqdcfr::aEDGE;
    }
    else if ((type_substr = strstr(this_record.att_string.c_str(), "vertex")) != NULL && 
             type_substr-this_record.att_string.c_str() < 20) {
      this_record.rec_type = Tqdcfr::aVERTEX;
    }
    else 
      this_record.rec_type = Tqdcfr::UNKNOWN;
    
    if (this_record.rec_type != Tqdcfr::UNKNOWN) {

        // print a warning if it looks like there are sequence numbers
      if (type_substr != this_record.att_string.c_str() && !printedSeqWarning) {
        std::cout << "Warning: acis file has sequence numbers!" << std::endl;
        printedSeqWarning = true;
      }

        // scan ahead to the next white space
      type_substr = strchr(type_substr, ' ');
      if (NULL == type_substr) return MB_FAILURE;
      
        // get the id of the first attrib
      int num_converted = sscanf(type_substr, " $%d", &(this_record.first_attrib));
      if (num_converted != 1) return MB_FAILURE;
    }
  }

  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::process_sideset_10 ( const int  this_type,
const int  num_ents,
const int  sense_size,
std::vector< EntityHandle > &  ss_entities,
Tqdcfr::SidesetHeader sideseth 
) [private]

process entities in a sideset according to sense flags stored in uint_buf or char_buf (depending on sense_size)

Definition at line 797 of file Tqdcfr.cpp.

{
  std::vector<EntityHandle> forward, reverse;
  if (this_type == 3 // surface
      && sense_size == 1 // byte size 
      ) {
      // interpret sense flags w/o reference to anything
    for (int i = 0; i < num_ents; i++) {
      if ((int) char_buf[i] == 0) forward.push_back(ss_entities[i]);
      else if ((int) char_buf[i] == 1) reverse.push_back(ss_entities[i]);
      if ((int) char_buf[i] == -1) { // -1 means "unknown", which means both
        forward.push_back(ss_entities[i]);
        reverse.push_back(ss_entities[i]);
      }
    }
  }
  else if (this_type == 4 // curve
           && sense_size == 2 // int32 size
           ) {
    for (int i = 0; i < num_ents; i++) {
      if (uint_buf[i] == 0) forward.push_back(ss_entities[i]);
      else if (uint_buf[i] == 1) reverse.push_back(ss_entities[i]);
      if (*((int*)&uint_buf[i]) == -1) { // -1 means "unknown", which means both
        forward.push_back(ss_entities[i]);
        reverse.push_back(ss_entities[i]);
      }
    }
  }
  
    // now actually put them in the set
  ErrorCode result = MB_SUCCESS;
  if (!forward.empty()) {
    ErrorCode tmp_result = mdbImpl->add_entities(sideseth->setHandle, &forward[0], forward.size());
    if (tmp_result != MB_SUCCESS) result = tmp_result;
  }
  if (!reverse.empty()) {
      // need to make a new set, add a reverse sense tag, then add to the sideset
    EntityHandle reverse_set;
    ErrorCode tmp_result = create_set(reverse_set);
    if (MB_SUCCESS != tmp_result) result = tmp_result;
    tmp_result = mdbImpl->add_entities(reverse_set, &reverse[0], reverse.size());
    if (tmp_result != MB_SUCCESS) result = tmp_result;
    int def_val = 1;
    Tag sense_tag;
    tmp_result = mdbImpl->tag_get_handle("NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag, 
                                     MB_TAG_SPARSE|MB_TAG_CREAT, &def_val);
    if (tmp_result != MB_SUCCESS) result = tmp_result;
    def_val = -1;
    tmp_result = mdbImpl->tag_set_data(sense_tag, &reverse_set, 1, &def_val);
    if (tmp_result != MB_SUCCESS) result = tmp_result;
    tmp_result = mdbImpl->add_entities(sideseth->setHandle, &reverse_set, 1);
    if (tmp_result != MB_SUCCESS) result = tmp_result;
  }

  return result;
}
ErrorCode moab::Tqdcfr::process_sideset_11 ( std::vector< EntityHandle > &  ss_entities,
int  num_wrts,
Tqdcfr::SidesetHeader sideseth 
) [private]

Definition at line 857 of file Tqdcfr.cpp.

{
  std::vector<EntityHandle> forward, reverse;

  unsigned int num_ents = ss_entities.size();
  unsigned int *wrt_it = &uint_buf[0];
  
  for (unsigned int i = 0; i < num_ents; i++) {
    
    unsigned int num_wrt = 0;
    if (0 != num_wrts) num_wrt = *wrt_it++;
    for (unsigned int j = 0; j < num_wrt; j++) wrt_it += 2;
      // assume here that if it's in the list twice, we get both senses
    if (num_wrt > 1) {
      forward.push_back(ss_entities[i]);
      reverse.push_back(ss_entities[i]);
    }
    else {
        // else interpret the sense flag
      if ((int) char_buf[i] == 0) forward.push_back(ss_entities[i]);
      else if ((int) char_buf[i] == 1) reverse.push_back(ss_entities[i]);
      if ((int) char_buf[i] == -1) { // -1 means "unknown", which means both
        forward.push_back(ss_entities[i]);
        reverse.push_back(ss_entities[i]);
      }
    }
  }
  
    // now actually put them in the set
  ErrorCode result = MB_SUCCESS;
  if (!forward.empty()) {
    ErrorCode tmp_result = mdbImpl->add_entities(sideseth->setHandle, &forward[0], forward.size());
    if (tmp_result != MB_SUCCESS) result = tmp_result;
  }
  if (!reverse.empty()) {
      // need to make a new set, add a reverse sense tag, then add to the sideset
    EntityHandle reverse_set;
    ErrorCode tmp_result = create_set(reverse_set);
    if (MB_SUCCESS != tmp_result) result = tmp_result;
    tmp_result = mdbImpl->add_entities(reverse_set, &reverse[0], reverse.size());
    if (tmp_result != MB_SUCCESS) result = tmp_result;
    int def_val = 1;
    Tag sense_tag;
    tmp_result = mdbImpl->tag_get_handle("NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag, 
                                      MB_TAG_SPARSE|MB_TAG_CREAT, &def_val);
    if (tmp_result != MB_SUCCESS && tmp_result != MB_ALREADY_ALLOCATED) result = tmp_result;
    def_val = -1;
    tmp_result = mdbImpl->tag_set_data(sense_tag, &reverse_set, 1, &def_val);
    if (tmp_result != MB_SUCCESS) result = tmp_result;
    tmp_result = mdbImpl->add_entities(sideseth->setHandle, &reverse_set, 1);
    if (tmp_result != MB_SUCCESS) result = tmp_result;
  }

  return result;
}
ErrorCode moab::Tqdcfr::put_into_set ( EntityHandle  set_handle,
std::vector< EntityHandle > &  entities,
std::vector< EntityHandle > &  excl_entities 
) [private]

Definition at line 1130 of file Tqdcfr.cpp.

{
    // and put entities into this block's set
  ErrorCode result = mdbImpl->add_entities(set_handle, &entities[0], entities.size());
  if (MB_SUCCESS != result) return result;

    // check for excluded entities, and add them to a vector hung off the block if there
  Tag excl_tag;
  if (!excl_entities.empty()) {
    result = mdbImpl->tag_get_handle("Exclude_Entities", 
                                   sizeof(std::vector<EntityHandle>*), 
                                   MB_TYPE_OPAQUE, excl_tag,
                                   MB_TAG_SPARSE|MB_TAG_CREAT);
    if (MB_SUCCESS != result) return result;
    std::vector<EntityHandle> *new_vector = new std::vector<EntityHandle>;
    new_vector->swap(excl_entities);
    result = mdbImpl->tag_set_data(excl_tag, &set_handle, 1, &new_vector);
    if (MB_SUCCESS != result) {
      delete new_vector;
      return MB_FAILURE;
    }
  }
  
  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::read_acis_records ( const char *  sat_file_name = 0) [private]

Definition at line 2263 of file Tqdcfr.cpp.

{

    // get the acis model location
  unsigned int acis_model_offset = 0, acis_model_length = 0, acis_model_handle = 1,
    acis_sat_type = 1;
  for (unsigned int i = 0; i < fileTOC.numModels; i++) {
    if (modelEntries[i].modelHandle == acis_model_handle &&
        modelEntries[i].modelType == acis_sat_type) {
      acis_model_offset = modelEntries[i].modelOffset;
      acis_model_length = modelEntries[i].modelLength;
      break;
    }
  }
  
  if (acis_model_length == 0) return MB_SUCCESS;
  
  std::vector<AcisRecord> records;

  acisDumpFile = NULL;
  if (sat_filename)
  {
    acisDumpFile = fopen( sat_filename, "w+" );
    if (NULL == acisDumpFile)
      return MB_FAILURE;
  }

    // position the file at the start of the acis model
  FSEEK(acis_model_offset);

  unsigned int bytes_left = acis_model_length;
  
  struct AcisRecord this_record;
  reset_record(this_record);
  char *ret;

    // make the char buffer at least buf_size+1 long, to fit null char
  const unsigned int buf_size = 1023;
  
  //CHECK_SIZE(char_buf, buf_size+1);
  char_buf.resize(buf_size+1);
  
  while (0 != bytes_left) {
      // read the next buff characters, or bytes_left if smaller
    unsigned int next_buf = (bytes_left > buf_size ? buf_size : bytes_left);
    FREADC(next_buf);

    if (NULL != acisDumpFile)
      fwrite(&char_buf[0], sizeof(char), next_buf, acisDumpFile);
    
      // put null at end of string to stop searches 
    char_buf[next_buf] = '\0';
    unsigned int buf_pos = 0;

      // check for first read, and if so, get rid of the header
    if (bytes_left == acis_model_length) {
        // look for 3 newlines
      ret = strchr(&(char_buf[0]), '\n'); ret = strchr(ret+1, '\n'); ret = strchr(ret+1, '\n');
      if (NULL == ret) return MB_FAILURE;
      buf_pos += ret - &(char_buf[0]) + 1;
    }
      
    bytes_left -= next_buf;

      // now start grabbing records
    do {
      
        // get next occurrence of '#' (record terminator)
      ret = strchr(&(char_buf[buf_pos]), '#');
      while (ret && ret+1-&char_buf[0] < bytes_left && *(ret+1) != '\n')
        ret = strchr(ret+1, '#');
      if (NULL != ret) {
          // grab the string (inclusive of the record terminator and the line feed) and complete the record
        int num_chars = ret-&(char_buf[buf_pos])+2;
        this_record.att_string.append(&(char_buf[buf_pos]), num_chars);
        buf_pos += num_chars;
        process_record(this_record);

          // put the record in the list...
        records.push_back(this_record);

          // and reset the record
        reset_record(this_record);
      }
      else {
          // reached end of buffer; cache string then go get another; discard last character,
          // which will be the null character
        this_record.att_string.append(&(char_buf[buf_pos]), next_buf-buf_pos);
        buf_pos = next_buf;
      }
      
    }
    while (buf_pos < next_buf);
  }

  if (NULL != acisDumpFile)
    fwrite("\n======================\nSorted acis records:\n======================\n", 1, 68, acisDumpFile);
    
    // now interpret the records
  interpret_acis_records(records);
  
  if (NULL != acisDumpFile)
    fclose(acisDumpFile);

  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::read_block ( const unsigned int  blindex,
const double  data_version,
Tqdcfr::ModelEntry model,
Tqdcfr::BlockHeader blockh 
)

Definition at line 915 of file Tqdcfr.cpp.

{

  if (blockh->memCt == 0) return MB_SUCCESS;
  
    // position file
  FSEEK(model->modelOffset+blockh->memOffset);
  
    // read ids for each entity type
  unsigned int num_read = 0;
  int this_type, num_ents; //, uid;
  std::vector<char> bc_data;
  std::vector<EntityHandle> block_entities, excl_entities;
  for (unsigned int i = 0; i < blockh->memTypeCt; i++) {
      // get how many and what type
    FREADI(2); num_read += 2*sizeof(int);
    this_type = uint_buf[0];
    num_ents = uint_buf[1];

      // now get the ids
    FREADI(num_ents); num_read += num_ents*sizeof(int);
    CONVERT_TO_INTS(num_ents);

    ErrorCode result = get_entities(this_type+2, &int_buf[0], num_ents, 
                                      block_entities, excl_entities);
    if (MB_SUCCESS != result) return result;
  }
  
    // and put entities into this block's set
  ErrorCode result = put_into_set(blockh->setHandle, block_entities, excl_entities);
  if (MB_SUCCESS != result) return result;
  
  // read attribs if there are any
  Tag block_attribs;
  {
    int def_block_attributes_length = 0;
    result = mdbImpl->tag_get_handle(BLOCK_ATTRIBUTES,def_block_attributes_length,MB_TYPE_DOUBLE,
      block_attribs,MB_TAG_CREAT|MB_TAG_SPARSE|MB_TAG_VARLEN,NULL); 
    if (MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result) return result;
  }
  if (blockh->attribOrder > 0) {
     
    FREADD(blockh->attribOrder); num_read += sizeof(double);
    void const* tag_data[] = { &dbl_buf[0] };
    int tag_sizes[] = { static_cast<int>(blockh->attribOrder) };
    result = mdbImpl->tag_set_by_ptr(block_attribs,&(blockh->setHandle),1,tag_data,tag_sizes);
    if (MB_SUCCESS != result) return result;
  }

    // check for more data
  if (num_read < blockh->blockLength) {
    FREADC(2); num_read += 2;
    if (char_buf[0] == 'i' && char_buf[1] == 'd') {
      FREADI(1); num_read += sizeof(int);
      //uid = int_buf[0];
    }
  }
  
  result = get_names(model->blockMD, blindex, blockh->setHandle);
  if (MB_SUCCESS != result) return result;
  
    // Put additional higher-order nodes into element connectivity list.
    // Cubit saves full connectivity list only for NodeHex and NodeTet
    // elements.  Other element types will only have the corners and
    // the mid-element node if there is one.  Need to reconsturct additional
    // connectivity entries from mid-nodes of adjacent lower-order entities.
  int node_per_elem = cub_elem_num_verts[blockh->blockElemType];
  if (blockh->blockEntityType==MBMAXTYPE)
    return MB_SUCCESS;
  if (52 == blockh->blockElemType ||
      CN::VerticesPerEntity(blockh->blockEntityType) == node_per_elem)
    return MB_SUCCESS;
  
    // Can't use Interface::convert_entities because block could contain
    // both entity sets and entities.  convert_entities will fail if block
    // contains an entity set, but we still need to call it on any elements
    // directly in the block (rather than a geometry subset).  So bypass
    // Interface and call HOFactory directly with an Range of entities.
  Range ho_entities, entities;
  mdbImpl->get_entities_by_type( blockh->setHandle, blockh->blockEntityType, entities, true );
  if (CN::Dimension(blockh->blockEntityType) > 2) {
    result = mdbImpl->get_adjacencies(entities, 2, false, ho_entities, Interface::UNION);
    if (MB_SUCCESS != result) return result;
  }
  if (CN::Dimension(blockh->blockEntityType) > 1) {
    result = mdbImpl->get_adjacencies(entities, 1, false, ho_entities, Interface::UNION);
    if (MB_SUCCESS != result) return result;
  }
  entities.merge(ho_entities);
  
  HigherOrderFactory ho_fact( dynamic_cast<Core*>(mdbImpl), 0 );
  return ho_fact.convert( entities, !!blockh->hasMidNodes[1], !!blockh->hasMidNodes[2], 
                          !!blockh->hasMidNodes[3] );
}

Definition at line 1433 of file Tqdcfr.cpp.

{
  if (entity->elemTypeCt == 0) return MB_SUCCESS;
  const int in_order_map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
                               11, 12, 13, 14, 15, 16, 17, 18, 19,
                               20, 21, 22, 23, 24, 25, 26, 27 };
  
    // get data in separate calls to minimize memory usage
    // position the file
  FSEEK(model->modelOffset+entity->elemOffset);

  int int_type, nodes_per_elem, num_elem;
  int max_dim = -1;
  ErrorCode result;
  for (unsigned int i = 0; i < entity->elemTypeCt; i++) {
      // for this elem type, get the type, nodes per elem, num elems
    FREADI(3);
    int_type = uint_buf[0];
    nodes_per_elem = uint_buf[1];
    num_elem = uint_buf[2];

      // get MB element type from cub file's 
    EntityType elem_type = mp_type_to_mb_type[int_type];
    max_dim = (max_dim < CN::Dimension(elem_type) ? CN::Dimension(elem_type) : max_dim);

    if (debug)
      std::cout << "type " << CN::EntityTypeName(elem_type) << ":";

    const int* node_order = cub_elem_order_map[elem_type][nodes_per_elem];
    if (!node_order)
      node_order = in_order_map;
    
      // get element ids
    FREADI(num_elem);
    
      // check to see if ids are contiguous...
    int contig;
    unsigned int max_id, min_id;
    check_contiguous(num_elem, contig, min_id, max_id);
    if (0 == contig && !printedElemWarning) {
      std::cout << "Element ids are not contiguous!" << std::endl;
      printedElemWarning = true;
    }
    
      // get a space for reading connectivity data directly into MB
    EntityHandle *conn, start_handle;
    
    result = readUtilIface->get_element_connect(num_elem, nodes_per_elem,
                                     elem_type, int_buf[0], 
                                     start_handle, conn, 
                                 SequenceManager::DEFAULT_ELEMENT_SEQUENCE_SIZE);
    if (MB_SUCCESS != result)
      return result;
    
    Range dum_range(start_handle, start_handle+num_elem-1);
        
    long elem_offset;
    elem_offset = (1 == contig ? start_handle - int_buf[0] : int_buf[num_elem-1]);
    if (-1 == currElementIdOffset[elem_type])
      currElementIdOffset[elem_type] = elem_offset;

      // set the gids on elements
    CONVERT_TO_INTS(num_elem);
    result = mdbImpl->tag_set_data(globalIdTag, dum_range, &int_buf[0]);
    if (MB_SUCCESS != result) return result;

      // get the connectivity array
    unsigned int total_conn = num_elem * nodes_per_elem;
    if(major >=14)
      FREADI(num_elem);// we need to skip num_elem in advance, it looks like
    FREADI(total_conn);

      // post-process connectivity into handles
    EntityHandle new_handle;
    int j = 0;
    for (int e = 0; e < num_elem; ++e) {
      for (int k = 0; k < nodes_per_elem; ++k, ++j) {
        if (debug) {
          if (0 == j) std::cout << "Conn=";
          std::cout << ", " << uint_buf[j];
        }
        if (NULL == cubMOABVertexMap)
          new_handle = (EntityHandle) currVHandleOffset+uint_buf[j];
        else {
          assert(uint_buf[j] < cubMOABVertexMap->size() &&
                 0 != (*cubMOABVertexMap)[uint_buf[j]]);
          new_handle = (*cubMOABVertexMap)[uint_buf[j]];
        }
  #ifndef NDEBUG
        EntityHandle dum_handle;
        assert(MB_SUCCESS == 
               mdbImpl->handle_from_id(MBVERTEX, mdbImpl->id_from_handle(new_handle), 
                                       dum_handle));
  #endif
        conn[e*nodes_per_elem + node_order[k]] = new_handle;
      }
    }

      // add these elements into the entity's set
    result = mdbImpl->add_entities(entity->setHandle, dum_range);
    if (MB_SUCCESS != result) return result;

      // notify MOAB of the new elements
    result = readUtilIface->update_adjacencies(start_handle, num_elem,
                                               nodes_per_elem, conn);
    if (MB_SUCCESS != result) return result;
  }

    // set the dimension on the geom tag
  result = mdbImpl->tag_set_data(geomTag, &entity->setHandle, 1, &max_dim);
  if (MB_SUCCESS != result) return result;
  if (max_dim != -1) {
    result = mdbImpl->tag_set_data(categoryTag, &entity->setHandle, 1, 
                                   &geom_categories[max_dim]);
    if (MB_SUCCESS != result) return result;
  }

  return MB_SUCCESS;
}

Definition at line 1617 of file Tqdcfr.cpp.

{
    // read file header
  FSEEK(4);
  // read tthe first int from the file
  // if it is 0, it is littleEndian
  unsigned rval = fread( &fileTOC.fileEndian, sizeof(unsigned int), 1, cubFile );
  IO_ASSERT( rval == 1 );
#ifdef WORDS_BIGENDIAN
  if (fileTOC.fileEndian==0)
    swapForEndianness=true;
#else
  if (fileTOC.fileEndian!=0)
    swapForEndianness=true;
#endif
  if (debug)
    std::cout << " swapping ? " << swapForEndianness << "\n";
  FREADI(5);
  //fileTOC.fileEndian = uint_buf[0];
  fileTOC.fileSchema = uint_buf[0];
  fileTOC.numModels = uint_buf[1];
  fileTOC.modelTableOffset = uint_buf[2];
  fileTOC.modelMetaDataOffset = uint_buf[3];
  fileTOC.activeFEModel = uint_buf[4];
  if (debug) fileTOC.print();

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

Definition at line 1052 of file Tqdcfr.cpp.

{
    // position file
  FSEEK(model->modelOffset+grouph->memOffset);
  char name_tag_data[NAME_TAG_SIZE];
  
    // read ids for each entity type
  int this_type, num_ents;
  std::vector<EntityHandle> grp_entities, excl_entities;
  for (unsigned int i = 0; i < grouph->memTypeCt; i++) {
      // get how many and what type
    FREADI(2);
    this_type = uint_buf[0];
    num_ents = uint_buf[1];

      // now get the ids
    FREADI(num_ents);
    CONVERT_TO_INTS(num_ents);
    
      // get the entities in this group
    ErrorCode result = get_entities(this_type, &int_buf[0], num_ents, grp_entities, excl_entities);
    if (MB_SUCCESS != result) return result;
  }

    // now add the entities
  ErrorCode result = put_into_set(grouph->setHandle, grp_entities, excl_entities);
  if (MB_SUCCESS != result) return result;
  
    // now get group names, if any
  int md_index = model->groupMD.get_md_entry(grouph->grpID, "NAME");
  if (-1 != md_index) {
    MetaDataContainer::MetaDataEntry *md_entry = &(model->groupMD.metadataEntries[md_index]);
    if (0 == entityNameTag) {
       memset( name_tag_data, 0, NAME_TAG_SIZE );
       result = mdbImpl->tag_get_handle(NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE,
                                      entityNameTag, MB_TAG_SPARSE|MB_TAG_CREAT,
                                      name_tag_data);
      if (MB_SUCCESS != result) return result;
    }
    //assert(md_entry->mdStringValue.length()+1 <= NAME_TAG_SIZE);
    memset( name_tag_data, 0, NAME_TAG_SIZE ); // make sure any extra bytes zeroed
    strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE );
    result = mdbImpl->tag_set_data(entityNameTag, &grouph->setHandle, 1, 
                                   name_tag_data);
    
      // look for extra names
    md_index = model->groupMD.get_md_entry(group_index, "NumExtraNames");
    if (-1 != md_index) {
      int num_names = model->groupMD.metadataEntries[md_index].mdIntValue;
      for (int i = 0; i < num_names; i++) {
        std::ostringstream extra_name_label( "ExtraName" );
        extra_name_label << i;
        std::ostringstream moab_extra_name( "EXTRA_" );
        moab_extra_name << NAME_TAG_NAME << i;
        md_index = model->groupMD.get_md_entry(group_index, extra_name_label.str().c_str());
        if (-1 != md_index) {
          md_entry = &(model->groupMD.metadataEntries[md_index]);
          Tag extra_name_tag;
          memset( name_tag_data, 0, NAME_TAG_SIZE );
          result = mdbImpl->tag_get_handle(moab_extra_name.str().c_str(), 
                                           NAME_TAG_SIZE, MB_TYPE_OPAQUE,
                                           extra_name_tag, MB_TAG_SPARSE|MB_TAG_CREAT,
                                           name_tag_data);
          //assert(md_entry->mdStringValue.length()+1 <= NAME_TAG_SIZE);
          memset( name_tag_data, 0, NAME_TAG_SIZE ); // make sure any extra bytes zeroed
          strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE );
          result = mdbImpl->tag_set_data(extra_name_tag, &grouph->setHandle, 1, 
                                         name_tag_data);
        }
      }
    }
  }
  
  return result;
}
ErrorCode moab::Tqdcfr::read_md_string ( std::string &  name)

Definition at line 1738 of file Tqdcfr.cpp.

{
  FREADI(1);
  int str_size = uint_buf[0];
  if (str_size > 0) {
    FREADC(str_size);
    if (char_buf.size() <= (unsigned int) str_size)
      char_buf.resize(str_size+1);
    char_buf[str_size] = '\0';
    name = (char *) &char_buf[0];
      // read pad if any
    int extra = str_size % sizeof(int);
    if (extra) {
        // read extra chars to end of pad
      str_size = sizeof(int) - extra;
      FREADC(str_size);
    }
  }

  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::read_meta_data ( const unsigned int  metadata_offset,
Tqdcfr::MetaDataContainer mc 
)

Definition at line 1677 of file Tqdcfr.cpp.

{
    // read the metadata header
  FSEEK(metadata_offset);
  FREADI(3);
  mc.mdSchema = uint_buf[0];
  mc.compressFlag = uint_buf[1];
 
    // allocate space for the entries
  mc.metadataEntries.resize( uint_buf[2] );
  
    // now read the metadata values
  for (unsigned int i = 0; i < mc.metadataEntries.size(); i++) {
    FREADI(2);
    mc.metadataEntries[i].mdOwner = uint_buf[0];
    mc.metadataEntries[i].mdDataType = uint_buf[1];
    
      // read the name string
    read_md_string(mc.metadataEntries[i].mdName);

    if (mc.metadataEntries[i].mdDataType == 0) {
        // integer
      FREADI(1);
      mc.metadataEntries[i].mdIntValue = uint_buf[0];
    }
    else if (mc.metadataEntries[i].mdDataType == 1) {
        // string
      read_md_string(mc.metadataEntries[i].mdStringValue);
    }
    else if (mc.metadataEntries[i].mdDataType == 2) {
        // double
      FREADD(1);
      mc.metadataEntries[i].mdDblValue = dbl_buf[0];
    }
    else if (mc.metadataEntries[i].mdDataType == 3) {
        // int array
      FREADI(1);
      mc.metadataEntries[i].mdIntArrayValue.resize(uint_buf[0]);
      FREADI(mc.metadataEntries[i].mdIntArrayValue.size());
      std::copy(uint_buf.begin(), 
                uint_buf.begin() + mc.metadataEntries[i].mdIntArrayValue.size(),
                mc.metadataEntries[i].mdIntArrayValue.begin());
    }
    else if (mc.metadataEntries[i].mdDataType == 4) {
        // double array
      FREADI(1);
      mc.metadataEntries[i].mdDblArrayValue.resize(uint_buf[0]);
      FREADD(mc.metadataEntries[i].mdDblArrayValue.size());
      std::copy(dbl_buf.begin(), 
                dbl_buf.begin() + mc.metadataEntries[i].mdDblArrayValue.size(),
                mc.metadataEntries[i].mdDblArrayValue.begin());
    }
    else
      return MB_FAILURE;
  }
  if (debug) mc.print();

  return MB_SUCCESS;
}

Definition at line 1646 of file Tqdcfr.cpp.

{
  
    // read model entries
  FSEEK(fileTOC.modelTableOffset);
  FREADI(fileTOC.numModels*6);
  modelEntries.resize(fileTOC.numModels);
  if (modelEntries.empty()) return MB_FAILURE;
  std::vector<unsigned int>::iterator int_it = uint_buf.begin();
  for (unsigned int i = 0; i < fileTOC.numModels; i++) {
    modelEntries[i].modelHandle = *int_it++;
    modelEntries[i].modelOffset = *int_it++;
    modelEntries[i].modelLength = *int_it++;
    modelEntries[i].modelType = *int_it++;
    modelEntries[i].modelOwner = *int_it++;
    modelEntries[i].modelPad = *int_it++;
    if (int_it == uint_buf.end() && i != fileTOC.numModels-1) return MB_FAILURE;
    if (debug) modelEntries[i].print();
  }

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

Definition at line 1261 of file Tqdcfr.cpp.

{
  if (entity->nodeCt == 0) {
    if (debug) std::cout << "(no nodes) ";
    return MB_SUCCESS;
  }
  
    // get the ids & coords in separate calls to minimize memory usage
    // position the file
  FSEEK(model->modelOffset+entity->nodeOffset);
    // get node ids in uint_buf
  FREADI(entity->nodeCt);

  if (debug) {
    std::cout << "(";
    for (unsigned int i = 0; i < entity->nodeCt; i++) {
      std::cout << uint_buf[i];
      if (i != entity->nodeCt-1) std::cout << ", ";
    }
    std::cout << ")...";
  }

    // get a space for reading nodal data directly into MB, and read that data
  EntityHandle vhandle = 0;
  std::vector<double*> arrays;
  readUtilIface->get_node_coords(3, entity->nodeCt,
                                 uint_buf[0], 
                                 vhandle, arrays, 
                                 SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE);

    // get node x's in arrays[0]
  FREADDA(entity->nodeCt, arrays[0]);
    // get node y's in arrays[1]
  FREADDA(entity->nodeCt, arrays[1]);
    // get node z's in arrays[2]
  FREADDA(entity->nodeCt, arrays[2]);

    // add these nodes into the entity's set
  Range dum_range(vhandle, 
                    vhandle+entity->nodeCt-1);
  ErrorCode result = mdbImpl->add_entities(entity->setHandle, dum_range);
  if (MB_SUCCESS != result) return result;

    // check for id contiguity; know that cid's will never be > 32bit, so
    // ids can be unsigned int
  unsigned int max_cid, min_cid;
  int contig;
  check_contiguous(entity->nodeCt, contig, min_cid, max_cid);

    // compute the offset we get in this batch and compare to any previous one
  long vhandle_offset = vhandle - min_cid;
  if (-1 == currVHandleOffset) currVHandleOffset = vhandle_offset;

    // In 2 situations we'll need to add/modify a cubit_id -> vhandle map:
    // case A: no map yet, and either this offset different from 
    // previous or not contiguous
  if (!cubMOABVertexMap &&
      (currVHandleOffset != vhandle_offset || !contig)) {
      // get all vertices, removing ones in this batch
    Range vrange, tmp_range(dum_range);
    result = mdbImpl->get_entities_by_type(0, MBVERTEX, vrange); RR;
    if (!beforeEnts.empty()) tmp_range.merge(beforeEnts.subset_by_type(MBVERTEX));
    vrange = subtract( vrange, tmp_range);
      // compute the max cid; map is indexed by cid, so size is max_cid+1
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
      // sanity check that max vhandle is larger than offset
    long new_max = *vrange.rbegin()-currVHandleOffset;
    assert(new_max >= 0 && ((long)*vrange.begin()) - currVHandleOffset >= 0);
    max_cid = MAX(max_cid, ((unsigned int) new_max));
    cubMOABVertexMap = new std::vector<EntityHandle>(max_cid+1);
      // initialize to zero then put previous vertices into the map
    std::fill(cubMOABVertexMap->begin(), cubMOABVertexMap->end(), 0);
    Range::iterator rit;
    for (rit = vrange.begin(); rit != vrange.end(); rit++) {
      assert(((long)*rit)-currVHandleOffset >= 0 &&
             ((long)*rit)-currVHandleOffset <= max_cid);
      (*cubMOABVertexMap)[*rit - currVHandleOffset] = *rit;
    }
  }
    // case B: there is a map and we need to resize it
  else if (cubMOABVertexMap && max_cid+1 > cubMOABVertexMap->size()) {
      unsigned int old_size = cubMOABVertexMap->size();
      cubMOABVertexMap->resize(max_cid+1);
      std::fill(&(*cubMOABVertexMap)[old_size], 
                &(*cubMOABVertexMap)[0]+cubMOABVertexMap->size(), 0);
  }
    
    // ok, we have a map or don't need one
  if (NULL == cubMOABVertexMap) {
      // if we're not forward-contiguous (i.e. we're reverse or
      // out-of-order contiguous), re-order coordinates for handles 
      // so that they are
    if (-1 == contig || -2 == contig) {
        // in case the arrays are large, do each coord separately
      std::vector<double> tmp_coords(entity->nodeCt);
      for (unsigned int j = 0; j < 3; j++) {
          // permute the coords into new order
        for (unsigned int i = 0; i < entity->nodeCt; i++) {
          assert(uint_buf[i] >= min_cid && 
                 max_cid-uint_buf[i] < entity->nodeCt);
          tmp_coords[uint_buf[i]-min_cid] = arrays[j][i];
        }
          // copy the permuted to storage
        std::copy(&tmp_coords[0], &tmp_coords[0]+entity->nodeCt, arrays[j]);
      }
        // now re-order the ids; either way just go off min, max cid
      for (unsigned int i = 0; i < entity->nodeCt; i++)
        uint_buf[i] = min_cid+i;
    }
    else if (!contig)
        // shouldn't get here, since in non-contig case map should be there
      assert(false);
  }
  else {
      // put new vertices into the map
      // now set the new values
    unsigned int *vit = &uint_buf[0];
    Range::iterator rit = dum_range.begin();
    for (; rit != dum_range.end(); vit++, rit++) {
      assert(*vit < cubMOABVertexMap->size());
      (*cubMOABVertexMap)[*vit] = *rit;
    }
  }

    // no longer need to use uint_buf; convert in-place to ints, so we
    // can assign gid tag
  CONVERT_TO_INTS(entity->nodeCt);
  result = mdbImpl->tag_set_data(globalIdTag, dum_range, &int_buf[0]);
  if (MB_SUCCESS != result) return result;

    // set the dimension to at least zero (entity has at least nodes) on the geom tag
  int max_dim = 0;
  result = mdbImpl->tag_set_data(geomTag, &(entity->setHandle), 1, &max_dim);
  if (MB_SUCCESS != result) return result;
    // set the category tag just in case there're only vertices in this set
  result = mdbImpl->tag_set_data(categoryTag, &entity->setHandle, 1, 
                                 &geom_categories[0]);
  if (MB_SUCCESS != result) return result;

    // get fixed node data and assign
  int md_index = model->nodeMD.get_md_entry(gindex, "FixedNodes");
  if (-1 == md_index) return MB_SUCCESS;
  MetaDataContainer::MetaDataEntry *md_entry = &(model->nodeMD.metadataEntries[md_index]);
  
  std::vector<int> fixed_flags(entity->nodeCt);
  std::fill(fixed_flags.begin(), fixed_flags.end(), 0);
  if (md_entry->mdDataType != 3) return MB_FAILURE;

  for (std::vector<unsigned int>::iterator vit = md_entry->mdIntArrayValue.begin();
       vit != md_entry->mdIntArrayValue.end(); vit++) {
#ifndef NDEBUG
    EntityHandle fixed_v = (cubMOABVertexMap ? 
                              (*cubMOABVertexMap)[*vit] : 
                              (EntityHandle) currVHandleOffset+*vit);
    assert(fixed_v >= *dum_range.begin() && fixed_v <= *dum_range.rbegin());
#endif
    fixed_flags[*vit - *dum_range.begin()] = 1;
  }

  Tag fixedFlagTag;
  int dum_val = 0;
  result = mdbImpl->tag_get_handle("NodeFixed", 1, MB_TYPE_INTEGER, fixedFlagTag,
                                   MB_TAG_SPARSE|MB_TAG_CREAT, &dum_val);
  if (MB_SUCCESS != result) return result;
  result = mdbImpl->tag_set_data(fixedFlagTag, dum_range, &fixed_flags[0]);

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

Definition at line 566 of file Tqdcfr.cpp.

{
  if (nodeseth->memTypeCt == 0) return MB_SUCCESS;

    // position file
  FSEEK(model->modelOffset+nodeseth->memOffset);
  
    // read ids for each entity type
  unsigned int this_type, num_ents; //, uid;
  std::vector<char> bc_data;
  unsigned int num_read = 0;
  std::vector<EntityHandle> ns_entities, excl_entities;
  for (unsigned int i = 0; i < nodeseth->memTypeCt; i++) {
      // get how many and what type
    FREADI(2); num_read += 2*sizeof(int);
    this_type = uint_buf[0];
    num_ents = uint_buf[1];

      // now get the ids
    FREADI(num_ents); num_read += sizeof(int);
    CONVERT_TO_INTS(num_ents);
    
    ErrorCode result = get_entities(this_type+2, &int_buf[0], num_ents, 
                                      ns_entities, excl_entities);
    if (MB_SUCCESS != result) return result;
  }
    // check for more data
  if (num_read < nodeseth->nsLength) {
    FREADC(2); num_read += 2;
    if (char_buf[0] == 'i' && char_buf[1] == 'd') {
      FREADI(1); num_read += sizeof(int);
      //uid = int_buf[0];
    } else {
      if (char_buf[0] == 'b' && char_buf[1] == 'c') {
        FREADI(1); num_read += sizeof(int); 
        int num_bcs = uint_buf[0]; 
        bc_data.resize(num_bcs);
        FREADCA(num_bcs, &bc_data[0]); num_read += num_bcs;
      }
    }
  }

  if(debug) { 
    nodeseth->print(); 
    if(!bc_data.empty()) {
      std::cout << "bc_data = ";
      std::vector<char>::iterator vit = bc_data.begin();
      for(;vit!=bc_data.end();vit++) {
    std::cout << std::hex << (int)((unsigned char)*vit) << " ";
      }
      std::cout << ": ";
      vit = bc_data.begin();
      for(;vit!=bc_data.end();vit++) {
    std::cout << *vit;
      }
      std::cout << std::endl;
    }
  } 

    // and put entities into this nodeset's set
  ErrorCode result = put_into_set(nodeseth->setHandle, ns_entities, excl_entities);
  if (MB_SUCCESS != result) return result;

  result = get_names(model->nodesetMD, nsindex, nodeseth->setHandle);
  if (MB_SUCCESS != result) return result;

  const int def_bc_data_len = 0;
  std::string tag_name = std::string(DIRICHLET_SET_TAG_NAME)+"__BC_DATA";
  Tag nbc_data;
  result = mdbImpl->tag_get_handle(tag_name.c_str(),def_bc_data_len,MB_TYPE_OPAQUE,
    nbc_data,MB_TAG_CREAT|MB_TAG_SPARSE|MB_TAG_BYTES|MB_TAG_VARLEN,NULL); 
  if (MB_SUCCESS != result) return result;
  void const* tag_data[] = { &(bc_data[0]) };
  int tag_size = bc_data.size();
  result = mdbImpl->tag_set_by_ptr(nbc_data,&nodeseth->setHandle,1,tag_data,&tag_size);
  if (MB_SUCCESS != result) return result;
  
  return result;
}
ErrorCode moab::Tqdcfr::read_sideset ( const unsigned int  ssindex,
const double  data_version,
Tqdcfr::ModelEntry model,
Tqdcfr::SidesetHeader sideseth 
)

Definition at line 648 of file Tqdcfr.cpp.

{
  if (sideseth->memCt == 0) return MB_SUCCESS;

  ErrorCode result;
  
    // position file
  FSEEK(model->modelOffset+sideseth->memOffset);
  
    // read ids for each entity type
  unsigned int this_type, num_ents, sense_size;

  std::vector<char> bc_data;
  unsigned int num_read = 0; //, uid;
  std::vector<EntityHandle> ss_entities, excl_entities;
  std::vector<double> ss_dfs;
  if (data_version <= 1.0) {
    for (unsigned int i = 0; i < sideseth->memTypeCt; i++) {
        // get how many and what type
      FREADI(3); num_read += 3*sizeof(int);
      this_type = uint_buf[0];
      num_ents = uint_buf[1];
      sense_size = uint_buf[2];

        // now get the ids
      FREADI(num_ents); num_read += sizeof(int);
      CONVERT_TO_INTS(num_ents);
    
      result = get_entities(this_type+2, &int_buf[0], num_ents, 
                            ss_entities, excl_entities);
      if (MB_SUCCESS != result) return result;

      if (sense_size == 1) {
          // byte-size sense flags; make sure read ends aligned...
        unsigned int read_length = (num_ents / 8) * 8;
        if (read_length < num_ents) read_length += 8;
        FREADC(read_length); num_read += read_length;
      
      }
      else if (sense_size == 2) {
          // int-size sense flags
        FREADI(num_ents); num_read += sizeof(int);
      }

        // now do something with them...
      process_sideset_10(this_type, num_ents, sense_size, ss_entities, sideseth);
    }

  }
  else {
    for (unsigned int i = 0; i < sideseth->memTypeCt; i++) {
        // get how many and what type
      FREADI(1); num_read += sizeof(int);
      num_ents = uint_buf[0];

        // get the types, and ids
      std::vector<unsigned int> mem_types(num_ents), mem_ids(num_ents);
      FREADIA(num_ents, &mem_types[0]); num_read += num_ents*sizeof(int);
      FREADI(num_ents); num_read += sizeof(int);

      result = get_entities(&mem_types[0], &int_buf[0], num_ents, false,
                            ss_entities);
      if (MB_SUCCESS != result) return result;

        // byte-size sense flags; make sure read ends aligned...
      unsigned int read_length = (num_ents / 8) * 8;
      if (read_length < num_ents) read_length += 8;
      FREADC(read_length); num_read += read_length;

        // wrt entities
      FREADI(1); num_read += sizeof(int);
      int num_wrts = uint_buf[0];
      FREADI(num_wrts); num_read += num_wrts*sizeof(int);
      
      result = process_sideset_11(ss_entities, num_wrts, sideseth);
      if (MB_SUCCESS != result) return result;
    }
  }

    // now set the dist factors
  if (sideseth->numDF > 0) {
      // have to read dist factors
    FREADD(sideseth->numDF); num_read += sideseth->numDF*sizeof(double);
    Tag distFactorTag;
    result = mdbImpl->tag_get_handle( "distFactor", 0, MB_TYPE_DOUBLE,
                                      distFactorTag, 
                                      MB_TAG_SPARSE|MB_TAG_VARLEN|MB_TAG_CREAT);
    if (MB_SUCCESS != result) return result;
    const void* dist_data = &dbl_buf[0];
    const int dist_size = sideseth->numDF;
    result = mdbImpl->tag_set_by_ptr( distFactorTag, &sideseth->setHandle, 1, &dist_data, &dist_size);
    if (MB_SUCCESS != result) return result;
  }
  
    // check for more data
  if (data_version > 1.0 && num_read < sideseth->ssLength) {
    FREADC(2); num_read += 2;
    if (char_buf[0] == 'i' && char_buf[1] == 'd') {
      FREADI(1); num_read += sizeof(int);
      //uid = int_buf[0];
    } else {
        // check for bc_data
      if (char_buf[0] == 'b' && char_buf[1] == 'c') {
        FREADI(1); num_read += sizeof(int);
        int num_bcs = uint_buf[0];
        bc_data.resize(num_bcs);
        FREADCA(num_bcs, &bc_data[0]); num_read += num_bcs;
      }
    }
  }

  if(debug) { 
    sideseth->print(); 
    if(!bc_data.empty()) {
      std::cout << "bc_data = ";
      std::vector<char>::iterator vit = bc_data.begin();
      for(;vit!=bc_data.end();vit++) {
    std::cout << std::hex << (int)((unsigned char)*vit) << " ";
      }
      std::cout << ": ";
      vit = bc_data.begin();
      for(;vit!=bc_data.end();vit++) {
    std::cout << *vit;
      }
      std::cout << std::endl;
    }
  } 

  result = get_names(model->sidesetMD, ssindex, sideseth->setHandle);
  if (MB_SUCCESS != result) return result;

  const int def_bc_data_len = 0;
  std::string tag_name = std::string(NEUMANN_SET_TAG_NAME)+"__BC_DATA";
  Tag nbc_data;
  result = mdbImpl->tag_get_handle(tag_name.c_str(),def_bc_data_len,MB_TYPE_OPAQUE,
    nbc_data,MB_TAG_CREAT|MB_TAG_SPARSE|MB_TAG_BYTES|MB_TAG_VARLEN,NULL); 
  if (MB_SUCCESS != result) return result;
  void const* tag_data[] = { &(bc_data[0]) };
  int tag_size = bc_data.size();
  result = mdbImpl->tag_set_by_ptr(nbc_data,&sideseth->setHandle,1,tag_data,&tag_size);
  if (MB_SUCCESS != result) return result;

  
  return MB_SUCCESS;
}
ErrorCode moab::Tqdcfr::read_tag_values ( const char *  file_name,
const char *  tag_name,
const FileOptions opts,
std::vector< int > &  tag_values_out,
const SubsetList subset_list = 0 
) [virtual]

Read tag values from a file.

Read the list if all integer tag values from the file for a tag that is a single integer value per entity.

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 255 of file Tqdcfr.cpp.

{
  return MB_NOT_IMPLEMENTED;
}
ErrorCode moab::Tqdcfr::reset_record ( AcisRecord this_record) [private]

Definition at line 2580 of file Tqdcfr.cpp.

{
  this_record.rec_type = Tqdcfr::UNKNOWN;
  this_record.att_string.clear();
  this_record.first_attrib = this_record.att_prev = 
    this_record.att_next = this_record.att_ent_num = -1;
  this_record.processed = false;
  this_record.entity = 0;

  return MB_SUCCESS;
}
EntityType moab::Tqdcfr::type_from_cub_type ( const unsigned int  cub_type,
const unsigned int  nodes_per_elem 
)

Member Data Documentation

const unsigned int* moab::Tqdcfr::ACIS_DIMS

Definition at line 263 of file Tqdcfr.hpp.

FILE* moab::Tqdcfr::acisDumpFile [private]

Definition at line 369 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 284 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

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

Definition at line 295 of file Tqdcfr.hpp.

const int moab::Tqdcfr::cub_elem_num_verts [static, private]
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 392 of file Tqdcfr.hpp.

const int moab::Tqdcfr::cub_elem_num_verts_len [static, private]
Initial value:

Definition at line 393 of file Tqdcfr.hpp.

Definition at line 279 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 372 of file Tqdcfr.hpp.

Definition at line 285 of file Tqdcfr.hpp.

Definition at line 283 of file Tqdcfr.hpp.

std::vector<double> moab::Tqdcfr::dbl_buf

Definition at line 294 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 280 of file Tqdcfr.hpp.

const char moab::Tqdcfr::geom_categories [static, private]
Initial value:
 
{"Vertex\0", "Curve\0", "Surface\0", "Volume\0"}

Definition at line 367 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 289 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

const EntityType moab::Tqdcfr::group_type_to_mb_type [static, private]

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 293 of file Tqdcfr.hpp.

Definition at line 278 of file Tqdcfr.hpp.

Definition at line 349 of file Tqdcfr.hpp.

Definition at line 281 of file Tqdcfr.hpp.

const EntityType moab::Tqdcfr::mp_type_to_mb_type [static, private]
Initial value:

mapping from mesh packet type to moab type

Definition at line 396 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 353 of file Tqdcfr.hpp.

Definition at line 351 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.

Definition at line 290 of file Tqdcfr.hpp.

Definition at line 288 of file Tqdcfr.hpp.

std::vector<unsigned int> moab::Tqdcfr::uint_buf

Definition at line 292 of file Tqdcfr.hpp.

Definition at line 286 of file Tqdcfr.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines