LCOV - code coverage report
Current view: top level - src/io - Tqdcfr.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 48 1569 3.1 %
Date: 2020-12-16 07:07:30 Functions: 11 82 13.4 %
Branches: 51 2898 1.8 %

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
       3                 :            :  * storing and accessing finite element mesh data.
       4                 :            :  *
       5                 :            :  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
       6                 :            :  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
       7                 :            :  * retains certain rights in this software.
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  */
      15                 :            : 
      16                 :            : #include "Tqdcfr.hpp"
      17                 :            : #include "moab/Core.hpp"
      18                 :            : #include "moab/Range.hpp"
      19                 :            : #include "moab/FileOptions.hpp"
      20                 :            : #include <iostream>
      21                 :            : #include <string>
      22                 :            : 
      23                 :            : #ifdef MOAB_HAVE_MPI
      24                 :            : #include "moab_mpi.h"
      25                 :            : #endif
      26                 :            : 
      27                 :            : #include "moab/ReadUtilIface.hpp"
      28                 :            : #include "SequenceManager.hpp"
      29                 :            : #include "moab/GeomTopoTool.hpp"
      30                 :            : #include "MBTagConventions.hpp"
      31                 :            : #include "moab/CN.hpp"
      32                 :            : #include "Internals.hpp"
      33                 :            : #include "moab/HigherOrderFactory.hpp"
      34                 :            : #include "exodus_order.h"
      35                 :            : 
      36                 :            : #include <sstream>
      37                 :            : #include <assert.h>
      38                 :            : #include <string.h>
      39                 :            : 
      40                 :            : namespace moab
      41                 :            : {
      42                 :            : 
      43                 :            : static bool debug = false;
      44                 :            : 
      45                 :            : const char Tqdcfr::geom_categories[][CATEGORY_TAG_SIZE] = { "Vertex\0", "Curve\0", "Surface\0", "Volume\0" };
      46                 :            : 
      47                 :            : // Will be used in a static function, so declared outside class members :(
      48                 :            : // major/minor cubit version that wrote this file
      49                 :            : static int major = -1, minor = -1;
      50                 :            : const EntityType Tqdcfr::group_type_to_mb_type[] = { MBENTITYSET, MBENTITYSET, MBENTITYSET,  // group, body, volume
      51                 :            :                                                      MBENTITYSET, MBENTITYSET, MBENTITYSET,  // surface, curve, vertex
      52                 :            :                                                      MBHEX,       MBTET,       MBPYRAMID,   MBQUAD,
      53                 :            :                                                      MBTRI,       MBEDGE,      MBVERTEX };
      54                 :            : 
      55                 :            : const EntityType Tqdcfr::block_type_to_mb_type[] = {
      56                 :            :     MBVERTEX,                                               // sphere
      57                 :            :     MBEDGE,    MBEDGE,    MBEDGE,                           // bars
      58                 :            :     MBEDGE,    MBEDGE,    MBEDGE,                           // beams
      59                 :            :     MBEDGE,    MBEDGE,    MBEDGE,                           // truss
      60                 :            :     MBEDGE,                                                 // spring
      61                 :            :     MBTRI,     MBTRI,     MBTRI,     MBTRI,                 // tri
      62                 :            :     MBTRI,     MBTRI,     MBTRI,     MBTRI,                 // trishell
      63                 :            :     MBQUAD,    MBQUAD,    MBQUAD,    MBQUAD,                // shell
      64                 :            :     MBQUAD,    MBQUAD,    MBQUAD,    MBQUAD,    MBQUAD,     // quad
      65                 :            :     MBTET,     MBTET,     MBTET,     MBTET,     MBTET,      // tet
      66                 :            :     MBPYRAMID, MBPYRAMID, MBPYRAMID, MBPYRAMID, MBPYRAMID,  // pyramid
      67                 :            :     MBHEX,     MBHEX,     MBHEX,     MBHEX,     MBHEX,      // hex
      68                 :            :     MBHEX,                                                  // hexshell
      69                 :            :     MBMAXTYPE                                               // last
      70                 :            : };
      71                 :            : 
      72                 :            : // Mapping from mesh packet type to moab type
      73                 :            : const EntityType Tqdcfr::mp_type_to_mb_type[] = { MBHEX,  MBHEX,  MBHEX,     MBHEX,     MBHEX,     MBHEX,     MBHEX,
      74                 :            :                                                   MBHEX,  MBTET,  MBTET,     MBTET,     MBTET,     MBTET,     MBTET,
      75                 :            :                                                   MBTET,  MBTET,  MBPYRAMID, MBPYRAMID, MBPYRAMID, MBPYRAMID, MBQUAD,
      76                 :            :                                                   MBQUAD, MBQUAD, MBQUAD,    MBTRI,     MBTRI,     MBTRI,     MBTRI,
      77                 :            :                                                   MBEDGE, MBEDGE, MBVERTEX };
      78                 :            : 
      79                 :            : const int Tqdcfr::cub_elem_num_verts[] = { 1,                    // sphere
      80                 :            :                                            2, 2, 3,              // bars
      81                 :            :                                            2, 2, 3,              // beams
      82                 :            :                                            2, 2, 3,              // truss
      83                 :            :                                            2,                    // spring
      84                 :            :                                            3, 3, 6, 7,           // tris
      85                 :            :                                            3, 3, 6, 7,           // trishells
      86                 :            :                                            4, 4, 8, 9,           // shells
      87                 :            :                                            4, 4, 5, 8,  9,       // quads
      88                 :            :                                            4, 4, 8, 10, 14,      // tets
      89                 :            :                                            5, 5, 8, 13, 18,      // pyramids
      90                 :            :                                            8, 8, 9, 20, 27, 12,  // hexes (incl. hexshell at end)
      91                 :            :                                            0 };
      92                 :            : 
      93                 :            : const int Tqdcfr::cub_elem_num_verts_len = sizeof( cub_elem_num_verts ) / sizeof( cub_elem_num_verts[0] );
      94                 :            : 
      95                 :            : // Define node-order map from Cubit to CN. Table is indexed
      96                 :            : // by EntityType and number of nodes. Entries are NULL if Cubit order
      97                 :            : // is the same as CN ordering. Non-null entries contain the
      98                 :            : // index into the MOAB node order for the corresponding vertex
      99                 :            : // in the Cubit connectivity list. Thus for a 27-node hex:
     100                 :            : // moab_conn[ cub_hex27_order[i] ] = cubit_conn[ i ];
     101                 :            : const int* const* const* const cub_elem_order_map = exodus_elem_order_map;
     102                 :            : 
     103                 :            : const char* const BLOCK_NODESET_OFFSET_TAG_NAME = "BLOCK_NODESET_OFFSET";
     104                 :            : const char* const BLOCK_SIDESET_OFFSET_TAG_NAME = "BLOCK_SIDESET_OFFSET";
     105                 :            : 
     106                 :            : #define RR \
     107                 :            :     if( MB_SUCCESS != result ) return result
     108                 :            : 
     109                 :            : // acis dimensions for each entity type, to match
     110                 :            : // enum {BODY, LUMP, SHELL, FACE, LOOP, COEDGE, EDGE, VERTEX, ATTRIB, UNKNOWN}
     111                 :            : 
     112                 :            : #define IO_ASSERT( C ) INT_IO_ERROR( C, __LINE__ )
     113                 :            : 
     114                 :          1 : static inline void INT_IO_ERROR( bool condition, unsigned line )
     115                 :            : {
     116         [ -  + ]:          1 :     if( !condition )
     117                 :            :     {
     118                 :          0 :         char buffer[] = __FILE__ "             ";
     119                 :          0 :         sprintf( buffer, "%s:%u", __FILE__, line );
     120         [ #  # ]:          0 :         fflush( stderr );
     121         [ #  # ]:          0 :         perror( buffer );
     122                 :          0 :         abort();
     123                 :            :     }
     124                 :          1 : }
     125                 :            : 
     126                 :          0 : void Tqdcfr::FSEEK( unsigned int offset )
     127                 :            : {
     128                 :          0 :     int rval = fseek( cubFile, offset, SEEK_SET );
     129                 :          0 :     IO_ASSERT( !rval );
     130                 :          0 : }
     131                 :            : 
     132                 :          0 : void Tqdcfr::FREADI( unsigned num_ents )
     133                 :            : {
     134         [ #  # ]:          0 :     if( uint_buf.size() < num_ents )
     135                 :            :     {
     136                 :          0 :         uint_buf.resize( num_ents );
     137                 :          0 :         int_buf = (int*)&uint_buf[0];
     138                 :            :     }
     139                 :          0 :     FREADIA( num_ents, &uint_buf[0] );
     140                 :          0 : }
     141                 :            : 
     142                 :          0 : void Tqdcfr::FREADD( unsigned num_ents )
     143                 :            : {
     144                 :          0 :     dbl_buf.resize( num_ents );
     145                 :          0 :     FREADDA( num_ents, &dbl_buf[0] );
     146                 :          0 : }
     147                 :            : 
     148                 :          1 : void Tqdcfr::FREADC( unsigned num_ents )
     149                 :            : {
     150                 :          1 :     char_buf.resize( num_ents );
     151                 :          1 :     FREADCA( num_ents, &char_buf[0] );
     152                 :          1 : }
     153                 :            : 
     154                 :            : // Used for swapping
     155                 :          0 : static void swap8_voff( long* data )
     156                 :            : {
     157                 :          0 :     unsigned char tmp, *cdat = (unsigned char*)data;
     158                 :          0 :     tmp     = cdat[0];
     159                 :          0 :     cdat[0] = cdat[7], cdat[7] = tmp;
     160                 :          0 :     tmp     = cdat[1];
     161                 :          0 :     cdat[1] = cdat[6], cdat[6] = tmp;
     162                 :          0 :     tmp     = cdat[2];
     163                 :          0 :     cdat[2] = cdat[5], cdat[5] = tmp;
     164                 :          0 :     tmp     = cdat[3];
     165                 :          0 :     cdat[3] = cdat[4], cdat[4] = tmp;
     166                 :          0 : }
     167                 :            : 
     168                 :          0 : static void swap4_uint( unsigned int* data )
     169                 :            : {
     170                 :          0 :     unsigned char tmp, *cdat = (unsigned char*)data;
     171                 :          0 :     tmp     = cdat[0];
     172                 :          0 :     cdat[0] = cdat[3], cdat[3] = tmp;
     173                 :          0 :     tmp     = cdat[1];
     174                 :          0 :     cdat[1] = cdat[2], cdat[2] = tmp;
     175                 :          0 : }
     176                 :            : 
     177                 :            : /*
     178                 :            : static void swap2_ushort(unsigned short *data)
     179                 :            : {
     180                 :            :   unsigned char tmp, *cdat = (unsigned char *) data;
     181                 :            :   tmp = cdat[0]; cdat[0] = cdat[1], cdat[1] = tmp;
     182                 :            : }
     183                 :            : */
     184                 :            : 
     185                 :          0 : void Tqdcfr::FREADIA( unsigned num_ents, unsigned int* array )
     186                 :            : {
     187                 :          0 :     unsigned rval = fread( array, sizeof( unsigned int ), num_ents, cubFile );
     188                 :          0 :     IO_ASSERT( rval == num_ents );
     189         [ #  # ]:          0 :     if( swapForEndianness )
     190                 :            :     {
     191                 :          0 :         unsigned int* pt = array;
     192         [ #  # ]:          0 :         for( unsigned int i = 0; i < num_ents; i++ )
     193                 :            :         {
     194                 :          0 :             swap4_uint( (unsigned int*)pt );
     195                 :          0 :             pt++;
     196                 :            :         }
     197                 :            :     }
     198                 :          0 : }
     199                 :            : 
     200                 :          0 : void Tqdcfr::FREADDA( unsigned num_ents, double* array )
     201                 :            : {
     202                 :          0 :     unsigned rval = fread( array, sizeof( double ), num_ents, cubFile );
     203                 :          0 :     IO_ASSERT( rval == num_ents );
     204         [ #  # ]:          0 :     if( swapForEndianness )
     205                 :            :     {
     206                 :          0 :         double* pt = array;
     207         [ #  # ]:          0 :         for( unsigned int i = 0; i < num_ents; i++ )
     208                 :            :         {
     209                 :          0 :             swap8_voff( (long*)pt );
     210                 :          0 :             pt++;
     211                 :            :         }
     212                 :            :     }
     213                 :          0 : }
     214                 :            : 
     215                 :          1 : void Tqdcfr::FREADCA( unsigned num_ents, char* array )
     216                 :            : {
     217                 :          1 :     unsigned rval = fread( array, sizeof( char ), num_ents, cubFile );
     218                 :          1 :     IO_ASSERT( rval == num_ents );
     219                 :          1 : }
     220                 :            : 
     221                 :          0 : void Tqdcfr::CONVERT_TO_INTS( unsigned int num_ents )
     222                 :            : {
     223         [ #  # ]:          0 :     for( unsigned int i = 0; i < num_ents; i++ )
     224                 :          0 :         int_buf[i] = uint_buf[i];
     225                 :          0 : }
     226                 :            : 
     227                 :          1 : ReaderIface* Tqdcfr::factory( Interface* iface )
     228                 :            : {
     229         [ +  - ]:          1 :     return new Tqdcfr( iface );
     230                 :            : }
     231                 :            : 
     232                 :          1 : Tqdcfr::Tqdcfr( Interface* impl )
     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 [ +  - ][ +  - ]:          7 :       printedElemWarning( false ), acisDumpFile( NULL )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  - ]
         [ +  - ][ +  -  
          #  #  #  #  #  
                      # ]
     237                 :            : {
     238         [ -  + ]:          1 :     assert( NULL != impl );
     239                 :          1 :     mdbImpl = impl;
     240         [ +  - ]:          1 :     impl->query_interface( readUtilIface );
     241         [ -  + ]:          1 :     assert( NULL != readUtilIface );
     242                 :            : 
     243                 :          1 :     currVHandleOffset = -1;
     244 [ +  - ][ +  + ]:         13 :     for( EntityType this_type = MBVERTEX; this_type < MBMAXTYPE; this_type++ )
     245                 :         12 :         currElementIdOffset[this_type] = -1;
     246                 :            : 
     247                 :            :     ErrorCode rval;
     248 [ +  - ][ -  + ]:          1 :     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 [ +  - ][ -  + ]:          1 :     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 [ +  - ][ -  + ]:          1 :     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         [ +  - ]:          1 :     if( 0 == entityNameTag )
     253                 :            :     {
     254                 :            :         rval = mdbImpl->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, entityNameTag,
     255 [ +  - ][ -  + ]:          1 :                                         MB_TAG_SPARSE | MB_TAG_CREAT );MB_CHK_SET_ERR_RET( rval, "Failed to tag_get_handle." );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     256                 :            :     }
     257                 :            : 
     258         [ #  # ]:          1 :     cubMOABVertexMap = NULL;
     259                 :            : }
     260                 :            : 
     261 [ +  - ][ +  + ]:          9 : Tqdcfr::~Tqdcfr()
     262                 :            : {
     263                 :          1 :     mdbImpl->release_interface( readUtilIface );
     264                 :            : 
     265 [ -  + ][ #  # ]:          1 :     if( NULL != cubMOABVertexMap ) delete cubMOABVertexMap;
     266         [ -  + ]:          1 :     if( attribVectorTag )
     267                 :            :     {
     268                 :            :         // get all sets, and release the string vectors
     269                 :          0 :         Range allSets;  // although only geom sets should have these attributes
     270                 :            :         // can't error in a destructor
     271                 :          0 :         ErrorCode rval = mdbImpl->get_entities_by_type( 0, MBENTITYSET, allSets );
     272         [ #  # ]:          0 :         if( rval != MB_SUCCESS ) std::cerr << "WARNING: Could not get_entities_by_type" << std::endl;
     273         [ #  # ]:          0 :         for( Range::iterator sit = allSets.begin(); sit != allSets.end(); ++sit )
     274                 :            :         {
     275                 :          0 :             EntityHandle gset = *sit;
     276                 :            :             std::vector< std::string >* dum_vec;
     277                 :            :             // can't error in a destructor
     278                 :          0 :             rval = mdbImpl->tag_get_data( attribVectorTag, &gset, 1, &dum_vec );
     279         [ #  # ]:          0 :             if( rval != MB_SUCCESS ) std::cerr << "WARNING: Could not tag_get_data" << std::endl;
     280 [ #  # ][ #  # ]:          0 :             if( NULL != dum_vec ) delete dum_vec;  //
     281                 :            :         }
     282                 :          0 :         mdbImpl->tag_delete( attribVectorTag );
     283                 :          0 :         attribVectorTag = NULL;
     284                 :            :     }
     285         [ -  + ]:          2 : }
     286                 :            : 
     287                 :          0 : ErrorCode Tqdcfr::read_tag_values( const char* /* file_name */, const char* /* tag_name */,
     288                 :            :                                    const FileOptions& /* opts */, std::vector< int >& /* tag_values_out */,
     289                 :            :                                    const SubsetList* /* subset_list */ )
     290                 :            : {
     291                 :          0 :     return MB_NOT_IMPLEMENTED;
     292                 :            : }
     293                 :            : 
     294                 :          1 : ErrorCode Tqdcfr::load_file( const char* file_name, const EntityHandle*, const FileOptions& opts,
     295                 :            :                              const ReaderIface::SubsetList* subset_list, const Tag* file_id_tag )
     296                 :            : {
     297                 :            :     ErrorCode result;
     298                 :            : 
     299                 :            :     int tmpval;
     300 [ +  - ][ -  + ]:          1 :     if( MB_SUCCESS == opts.get_int_option( "DEBUG_IO", 1, tmpval ) )
     301                 :            :     {
     302         [ #  # ]:          0 :         if( 0 < tmpval ) debug = true;
     303                 :            :     }
     304                 :            : 
     305 [ -  + ][ #  # ]:          1 :     if( subset_list ) { MB_SET_ERR( MB_UNSUPPORTED_OPERATION, "Reading subset of files not supported for CUB files" ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     306                 :            : 
     307                 :            :     // Open file
     308         [ +  - ]:          1 :     cubFile = fopen( file_name, "rb" );
     309 [ -  + ][ #  # ]:          1 :     if( NULL == cubFile ) { MB_SET_ERR( MB_FAILURE, "File not found" ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     310                 :            : 
     311                 :            :     // Verify magic string
     312         [ +  - ]:          1 :     FREADC( 4 );
     313 [ +  - ][ -  + ]:          1 :     if( !( char_buf[0] == 'C' && char_buf[1] == 'U' && char_buf[2] == 'B' && char_buf[3] == 'E' ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ +  - ]
     314                 :            :     {
     315         [ +  - ]:          1 :         fclose( cubFile );
     316 [ +  - ][ +  - ]:          1 :         MB_SET_ERR( MB_FAILURE, "This doesn't appear to be a .cub file" );
         [ +  - ][ -  + ]
                 [ +  - ]
     317                 :            :     }
     318                 :            : 
     319                 :            :     // Get "before" entities
     320 [ #  # ][ #  # ]:          0 :     result = mdbImpl->get_entities_by_handle( 0, beforeEnts );MB_CHK_SET_ERR( result, "Couldn't get \"before\" entities" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     321                 :            : 
     322                 :            :     // ***********************
     323                 :            :     // Read model header type information...
     324                 :            :     // ***********************
     325 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading file header." << std::endl;
                 [ #  # ]
     326 [ #  # ][ #  # ]:          0 :     result = read_file_header();RR;
     327                 :            : 
     328 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading model entries." << std::endl;
                 [ #  # ]
     329 [ #  # ][ #  # ]:          0 :     result = read_model_entries();RR;
     330                 :            : 
     331                 :            :     // Read model metadata
     332 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading model metadata." << std::endl;
                 [ #  # ]
     333 [ #  # ][ #  # ]:          0 :     result = read_meta_data( fileTOC.modelMetaDataOffset, modelMetaData );RR;
     334                 :            : 
     335                 :            :     double data_version;
     336 [ #  # ][ #  # ]:          0 :     int md_index = modelMetaData.get_md_entry( 2, "DataVersion" );
     337         [ #  # ]:          0 :     if( -1 == md_index )
     338                 :          0 :         data_version = 1.0;
     339                 :            :     else
     340         [ #  # ]:          0 :         data_version = modelMetaData.metadataEntries[md_index].mdDblValue;
     341                 :            : 
     342                 :            :     // Get the major/minor cubit version that wrote this file
     343                 :            :     // int major = -1, minor = -1;
     344 [ #  # ][ #  # ]:          0 :     md_index = modelMetaData.get_md_entry( 2, "CubitVersion" );
     345 [ #  # ][ #  # ]:          0 :     if( md_index >= 0 && !modelMetaData.metadataEntries[md_index].mdStringValue.empty() )
         [ #  # ][ #  # ]
     346         [ #  # ]:          0 :         sscanf( modelMetaData.metadataEntries[md_index].mdStringValue.c_str(), "%d.%d", &major, &minor );
     347                 :            : 
     348                 :            :     // ***********************
     349                 :            :     // Read mesh...
     350                 :            :     // ***********************
     351         [ #  # ]:          0 :     int index = find_model( mesh );
     352         [ #  # ]:          0 :     if( -1 == index ) return MB_FAILURE;
     353         [ #  # ]:          0 :     ModelEntry* mesh_model = &modelEntries[index];
     354                 :            : 
     355                 :            :     // First the header & metadata info
     356 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading mesh model header and metadata." << std::endl;
                 [ #  # ]
     357         [ #  # ]:          0 :     result = mesh_model->read_header_info( this, data_version );
     358         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     359         [ #  # ]:          0 :     result = mesh_model->read_metadata_info( this );
     360         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     361                 :            : 
     362                 :            :     // Now read in mesh for each geometry entity; read in order of increasing dimension
     363                 :            :     // so we have all the mesh we need
     364         [ #  # ]:          0 :     for( int dim = 0; dim < 4; dim++ )
     365                 :            :     {
     366         [ #  # ]:          0 :         for( unsigned int gindex = 0; gindex < mesh_model->feModelHeader.geomArray.numEntities; gindex++ )
     367                 :            :         {
     368                 :          0 :             Tqdcfr::GeomHeader* geom_header = &mesh_model->feGeomH[gindex];
     369                 :            : 
     370         [ #  # ]:          0 :             if( geom_header->maxDim != dim ) continue;
     371                 :            : 
     372                 :            :             // Read nodes
     373 [ #  # ][ #  # ]:          0 :             if( debug ) std::cout << "Reading geom index " << gindex << " mesh: nodes... ";
         [ #  # ][ #  # ]
     374         [ #  # ]:          0 :             result = read_nodes( gindex, mesh_model, geom_header );
     375         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     376                 :            : 
     377                 :            :             // Read elements
     378 [ #  # ][ #  # ]:          0 :             if( debug ) std::cout << "elements... ";
     379         [ #  # ]:          0 :             result = read_elements( mesh_model, geom_header );
     380         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     381 [ #  # ][ #  # ]:          0 :             if( debug ) std::cout << std::endl;
     382                 :            :         }
     383                 :            :     }
     384                 :            : 
     385                 :            :     // ***********************
     386                 :            :     // Read acis records...
     387                 :            :     // ***********************
     388         [ #  # ]:          0 :     std::string sat_file_name;
     389 [ #  # ][ #  # ]:          0 :     if( MB_SUCCESS != opts.get_str_option( "SAT_FILE", sat_file_name ) ) sat_file_name.clear();
     390 [ #  # ][ #  # ]:          0 :     result = read_acis_records( sat_file_name.empty() ? NULL : sat_file_name.c_str() );RR;
                 [ #  # ]
     391                 :            : 
     392                 :            :     // ***********************
     393                 :            :     // Read groups...
     394                 :            :     // ***********************
     395 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading groups... ";
     396         [ #  # ]:          0 :     for( unsigned int grindex = 0; grindex < mesh_model->feModelHeader.groupArray.numEntities; grindex++ )
     397                 :            :     {
     398                 :          0 :         GroupHeader* group_header = &mesh_model->feGroupH[grindex];
     399         [ #  # ]:          0 :         result                    = read_group( grindex, mesh_model, group_header );
     400         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     401                 :            :     }
     402 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << mesh_model->feModelHeader.groupArray.numEntities << " read successfully." << std::endl;
         [ #  # ][ #  # ]
     403                 :            : 
     404                 :            :     // ***********************
     405                 :            :     // Read blocks...
     406                 :            :     // ***********************
     407 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading blocks... ";
     408         [ #  # ]:          0 :     Range ho_entities;
     409         [ #  # ]:          0 :     for( unsigned int blindex = 0; blindex < mesh_model->feModelHeader.blockArray.numEntities; blindex++ )
     410                 :            :     {
     411                 :          0 :         BlockHeader* block_header = &mesh_model->feBlockH[blindex];
     412         [ #  # ]:          0 :         result                    = read_block( blindex, data_version, mesh_model, block_header );
     413         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     414                 :            :     }
     415                 :            : 
     416 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << mesh_model->feModelHeader.blockArray.numEntities << " read successfully." << std::endl;
         [ #  # ][ #  # ]
     417                 :            : 
     418                 :            :     // ***********************
     419                 :            :     // Read nodesets...
     420                 :            :     // ***********************
     421 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading nodesets... ";
     422         [ #  # ]:          0 :     for( unsigned int nsindex = 0; nsindex < mesh_model->feModelHeader.nodesetArray.numEntities; nsindex++ )
     423                 :            :     {
     424                 :          0 :         NodesetHeader* nodeset_header = &mesh_model->feNodeSetH[nsindex];
     425         [ #  # ]:          0 :         result                        = read_nodeset( nsindex, mesh_model, nodeset_header );
     426         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     427                 :            :     }
     428 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << mesh_model->feModelHeader.nodesetArray.numEntities << " read successfully." << std::endl;
         [ #  # ][ #  # ]
     429                 :            : 
     430                 :            :     // ***********************
     431                 :            :     // Read sidesets...
     432                 :            :     // ***********************
     433 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << "Reading sidesets...";
     434         [ #  # ]:          0 :     for( unsigned int ssindex = 0; ssindex < mesh_model->feModelHeader.sidesetArray.numEntities; ssindex++ )
     435                 :            :     {
     436                 :          0 :         SidesetHeader* sideset_header = &mesh_model->feSideSetH[ssindex];
     437         [ #  # ]:          0 :         result                        = read_sideset( ssindex, data_version, mesh_model, sideset_header );
     438         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     439                 :            :     }
     440 [ #  # ][ #  # ]:          0 :     if( debug ) std::cout << mesh_model->feModelHeader.sidesetArray.numEntities << " read successfully." << std::endl;
         [ #  # ][ #  # ]
     441                 :            : 
     442         [ #  # ]:          0 :     if( debug )
     443                 :            :     {
     444 [ #  # ][ #  # ]:          0 :         std::cout << "Read the following mesh:" << std::endl;
     445         [ #  # ]:          0 :         mdbImpl->list_entities( 0, 0 );
     446                 :            :     }
     447                 :            : 
     448                 :            :     // **************************
     449                 :            :     // Restore geometric topology
     450                 :            :     // **************************
     451         [ #  # ]:          0 :     GeomTopoTool gtt( mdbImpl, true, 0, true, false );
     452         [ #  # ]:          0 :     result = gtt.restore_topology_from_adjacency();
     453 [ #  # ][ #  # ]:          0 :     if( MB_SUCCESS != result ) { std::cout << "Failed to restore topology " << std::endl; }
                 [ #  # ]
     454                 :            : 
     455                 :            :     // Convert blocks to nodesets/sidesets if tag is set
     456         [ #  # ]:          0 :     result = convert_nodesets_sidesets();
     457         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     458                 :            : 
     459         [ #  # ]:          0 :     Range after_ents;
     460         [ #  # ]:          0 :     result = mdbImpl->get_entities_by_handle( 0, after_ents );
     461         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     462                 :            : 
     463 [ #  # ][ #  # ]:          0 :     after_ents = subtract( after_ents, beforeEnts );
     464                 :            : 
     465 [ #  # ][ #  # ]:          0 :     if( file_id_tag ) readUtilIface->assign_ids( *file_id_tag, after_ents );
     466                 :            : 
     467                 :            :     // done with the cubit file
     468         [ #  # ]:          0 :     fclose( cubFile );
     469                 :          1 :     return result;
     470                 :            : }
     471                 :            : 
     472                 :          0 : ErrorCode Tqdcfr::convert_nodesets_sidesets()
     473                 :            : {
     474                 :            :     // Look first for the nodeset and sideset offset flags; if they're not
     475                 :            :     // set, we don't need to convert
     476                 :          0 :     const EntityHandle msh = 0;
     477                 :            :     unsigned int nodeset_offset, sideset_offset;
     478                 :            :     Tag tmp_tag;
     479         [ #  # ]:          0 :     ErrorCode result = mdbImpl->tag_get_handle( BLOCK_NODESET_OFFSET_TAG_NAME, 1, MB_TYPE_INTEGER, tmp_tag );
     480         [ #  # ]:          0 :     if( MB_SUCCESS != result )
     481                 :          0 :         nodeset_offset = 0;
     482                 :            :     else
     483                 :            :     {
     484         [ #  # ]:          0 :         result = mdbImpl->tag_get_data( tmp_tag, &msh, 1, &nodeset_offset );
     485         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     486                 :            :     }
     487                 :            : 
     488         [ #  # ]:          0 :     result = mdbImpl->tag_get_handle( BLOCK_SIDESET_OFFSET_TAG_NAME, 1, MB_TYPE_INTEGER, tmp_tag );
     489         [ #  # ]:          0 :     if( MB_SUCCESS != result )
     490                 :          0 :         sideset_offset = 0;
     491                 :            :     else
     492                 :            :     {
     493         [ #  # ]:          0 :         result = mdbImpl->tag_get_data( tmp_tag, &msh, 1, &sideset_offset );
     494         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     495                 :            :     }
     496                 :            : 
     497 [ #  # ][ #  # ]:          0 :     if( 0 == nodeset_offset && 0 == sideset_offset ) return MB_SUCCESS;
     498                 :            : 
     499                 :            :     // Look for all blocks
     500         [ #  # ]:          0 :     Range blocks;
     501         [ #  # ]:          0 :     result = mdbImpl->get_entities_by_type_and_tag( 0, MBENTITYSET, &blockTag, NULL, 1, blocks );
     502 [ #  # ][ #  # ]:          0 :     if( MB_SUCCESS != result || blocks.empty() ) return result;
         [ #  # ][ #  # ]
     503                 :            : 
     504                 :            :     // Get the id tag for them
     505 [ #  # ][ #  # ]:          0 :     std::vector< int > block_ids( blocks.size() );
     506 [ #  # ][ #  # ]:          0 :     result = mdbImpl->tag_get_data( globalIdTag, blocks, &block_ids[0] );
     507         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     508                 :            : 
     509                 :          0 :     unsigned int i      = 0;
     510         [ #  # ]:          0 :     Range::iterator rit = blocks.begin();
     511 [ #  # ][ #  # ]:          0 :     Range new_nodesets, new_sidesets;
     512 [ #  # ][ #  # ]:          0 :     std::vector< int > new_nodeset_ids, new_sideset_ids;
     513 [ #  # ][ #  # ]:          0 :     for( ; rit != blocks.end(); i++, ++rit )
         [ #  # ][ #  # ]
     514                 :            :     {
     515 [ #  # ][ #  # ]:          0 :         if( 0 != nodeset_offset && block_ids[i] >= (int)nodeset_offset &&
         [ #  # ][ #  # ]
                 [ #  # ]
     516 [ #  # ][ #  # ]:          0 :             ( nodeset_offset > sideset_offset || block_ids[i] < (int)sideset_offset ) )
     517                 :            :         {
     518                 :            :             // This is a nodeset
     519 [ #  # ][ #  # ]:          0 :             new_nodesets.insert( *rit );
     520 [ #  # ][ #  # ]:          0 :             new_nodeset_ids.push_back( block_ids[i] );
     521                 :            :         }
     522 [ #  # ][ #  # ]:          0 :         else if( 0 != sideset_offset && block_ids[i] >= (int)sideset_offset &&
         [ #  # ][ #  # ]
                 [ #  # ]
     523 [ #  # ][ #  # ]:          0 :                  ( sideset_offset > nodeset_offset || block_ids[i] < (int)nodeset_offset ) )
     524                 :            :         {
     525                 :            :             // This is a sideset
     526 [ #  # ][ #  # ]:          0 :             new_sidesets.insert( *rit );
     527 [ #  # ][ #  # ]:          0 :             new_sideset_ids.push_back( block_ids[i] );
     528                 :            :         }
     529                 :            :     }
     530                 :            : 
     531                 :            :     // OK, have the new nodesets and sidesets; now remove the block tags, and
     532                 :            :     // add nodeset and sideset tags
     533                 :          0 :     ErrorCode tmp_result = MB_SUCCESS;
     534         [ #  # ]:          0 :     if( 0 != nodeset_offset )
     535                 :            :     {
     536         [ #  # ]:          0 :         if( 0 == nsTag )
     537                 :            :         {
     538                 :          0 :             int default_val = 0;
     539                 :            :             tmp_result      = mdbImpl->tag_get_handle( DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, nsTag,
     540         [ #  # ]:          0 :                                                   MB_TAG_SPARSE | MB_TAG_CREAT, &default_val );
     541         [ #  # ]:          0 :             if( MB_SUCCESS != tmp_result ) result = tmp_result;
     542                 :            :         }
     543 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS == tmp_result ) tmp_result = mdbImpl->tag_set_data( nsTag, new_nodesets, &new_nodeset_ids[0] );
                 [ #  # ]
     544         [ #  # ]:          0 :         if( MB_SUCCESS != tmp_result ) result = tmp_result;
     545         [ #  # ]:          0 :         tmp_result = mdbImpl->tag_delete_data( blockTag, new_nodesets );
     546         [ #  # ]:          0 :         if( MB_SUCCESS != tmp_result ) result = tmp_result;
     547                 :            :     }
     548         [ #  # ]:          0 :     if( 0 != sideset_offset )
     549                 :            :     {
     550         [ #  # ]:          0 :         if( 0 == ssTag )
     551                 :            :         {
     552                 :          0 :             int default_val = 0;
     553                 :            :             tmp_result      = mdbImpl->tag_get_handle( NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, ssTag,
     554         [ #  # ]:          0 :                                                   MB_TAG_SPARSE | MB_TAG_CREAT, &default_val );
     555         [ #  # ]:          0 :             if( MB_SUCCESS != tmp_result ) result = tmp_result;
     556                 :            :         }
     557 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS == tmp_result ) tmp_result = mdbImpl->tag_set_data( ssTag, new_sidesets, &new_sideset_ids[0] );
                 [ #  # ]
     558         [ #  # ]:          0 :         if( MB_SUCCESS != tmp_result ) result = tmp_result;
     559         [ #  # ]:          0 :         tmp_result = mdbImpl->tag_delete_data( blockTag, new_sidesets );
     560         [ #  # ]:          0 :         if( MB_SUCCESS != tmp_result ) result = tmp_result;
     561                 :            :     }
     562                 :            : 
     563                 :          0 :     return result;
     564                 :            : }
     565                 :            : 
     566                 :          0 : ErrorCode Tqdcfr::read_nodeset( const unsigned int nsindex, Tqdcfr::ModelEntry* model, Tqdcfr::NodesetHeader* nodeseth )
     567                 :            : {
     568         [ #  # ]:          0 :     if( nodeseth->memTypeCt == 0 ) return MB_SUCCESS;
     569                 :            : 
     570                 :            :     // Position file
     571         [ #  # ]:          0 :     FSEEK( model->modelOffset + nodeseth->memOffset );
     572                 :            : 
     573                 :            :     // Read ids for each entity type
     574                 :            :     unsigned int this_type, num_ents;  //, uid;
     575         [ #  # ]:          0 :     std::vector< char > bc_data;
     576                 :          0 :     unsigned int num_read = 0;
     577 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > ns_entities, excl_entities;
     578         [ #  # ]:          0 :     for( unsigned int i = 0; i < nodeseth->memTypeCt; i++ )
     579                 :            :     {
     580                 :            :         // Get how many and what type
     581         [ #  # ]:          0 :         FREADI( 2 );
     582                 :          0 :         num_read += 2 * sizeof( int );
     583         [ #  # ]:          0 :         this_type = uint_buf[0];
     584         [ #  # ]:          0 :         num_ents  = uint_buf[1];
     585                 :            : 
     586                 :            :         // Now get the ids
     587         [ #  # ]:          0 :         FREADI( num_ents );
     588                 :          0 :         num_read += sizeof( int );
     589         [ #  # ]:          0 :         CONVERT_TO_INTS( num_ents );
     590                 :            : 
     591         [ #  # ]:          0 :         ErrorCode result = get_entities( this_type + 2, &int_buf[0], num_ents, ns_entities, excl_entities );
     592         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     593                 :            :     }
     594                 :            :     // Check for more data
     595         [ #  # ]:          0 :     if( num_read < nodeseth->nsLength )
     596                 :            :     {
     597         [ #  # ]:          0 :         FREADC( 2 );  // num_read += 2;
     598 [ #  # ][ #  # ]:          0 :         if( char_buf[0] == 'i' && char_buf[1] == 'd' )
         [ #  # ][ #  # ]
                 [ #  # ]
     599                 :            :         {
     600         [ #  # ]:          0 :             FREADI( 1 );  // num_read += sizeof(int);
     601                 :            :             // uid = int_buf[0];
     602                 :            :         }
     603                 :            :         else
     604                 :            :         {
     605 [ #  # ][ #  # ]:          0 :             if( char_buf[0] == 'b' && char_buf[1] == 'c' )
         [ #  # ][ #  # ]
                 [ #  # ]
     606                 :            :             {
     607         [ #  # ]:          0 :                 FREADI( 1 );  // num_read += sizeof(int);
     608         [ #  # ]:          0 :                 int num_bcs = uint_buf[0];
     609         [ #  # ]:          0 :                 bc_data.resize( num_bcs );
     610 [ #  # ][ #  # ]:          0 :                 FREADCA( num_bcs, &bc_data[0] );  // num_read += num_bcs;
     611                 :            :             }
     612                 :            :         }
     613                 :            :     }
     614                 :            : 
     615         [ #  # ]:          0 :     if( debug )
     616                 :            :     {
     617         [ #  # ]:          0 :         nodeseth->print();
     618         [ #  # ]:          0 :         if( !bc_data.empty() )
     619                 :            :         {
     620         [ #  # ]:          0 :             std::cout << "bc_data = ";
     621                 :          0 :             std::vector< char >::iterator vit = bc_data.begin();
     622 [ #  # ][ #  # ]:          0 :             for( ; vit != bc_data.end(); ++vit )
                 [ #  # ]
     623                 :            :             {
     624 [ #  # ][ #  # ]:          0 :                 std::cout << std::hex << (int)( (unsigned char)*vit ) << " ";
         [ #  # ][ #  # ]
     625                 :            :             }
     626         [ #  # ]:          0 :             std::cout << ": ";
     627                 :          0 :             vit = bc_data.begin();
     628 [ #  # ][ #  # ]:          0 :             for( ; vit != bc_data.end(); ++vit )
                 [ #  # ]
     629                 :            :             {
     630 [ #  # ][ #  # ]:          0 :                 std::cout << *vit;
     631                 :            :             }
     632         [ #  # ]:          0 :             std::cout << std::endl;
     633                 :            :         }
     634                 :            :     }
     635                 :            : 
     636                 :            :     // And put entities into this nodeset's set
     637         [ #  # ]:          0 :     ErrorCode result = put_into_set( nodeseth->setHandle, ns_entities, excl_entities );
     638         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     639                 :            : 
     640         [ #  # ]:          0 :     result = get_names( model->nodesetMD, nsindex, nodeseth->setHandle );
     641         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     642                 :            : 
     643                 :          0 :     const int def_bc_data_len = 0;
     644 [ #  # ][ #  # ]:          0 :     std::string tag_name      = std::string( DIRICHLET_SET_TAG_NAME ) + "__BC_DATA";
     645                 :            :     Tag nbc_data;
     646                 :            :     result = mdbImpl->tag_get_handle( tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nbc_data,
     647         [ #  # ]:          0 :                                       MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL );
     648         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     649 [ #  # ][ #  # ]:          0 :     void const* tag_data[] = { ( bc_data.empty() ) ? NULL : &( bc_data[0] ) };
     650                 :          0 :     int tag_size           = bc_data.size();
     651         [ #  # ]:          0 :     result                 = mdbImpl->tag_set_by_ptr( nbc_data, &nodeseth->setHandle, 1, tag_data, &tag_size );
     652         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     653                 :            : 
     654                 :          0 :     return result;
     655                 :            : }
     656                 :            : 
     657                 :          0 : ErrorCode Tqdcfr::read_sideset( const unsigned int ssindex, const double data_version, Tqdcfr::ModelEntry* model,
     658                 :            :                                 Tqdcfr::SidesetHeader* sideseth )
     659                 :            : {
     660         [ #  # ]:          0 :     if( sideseth->memCt == 0 ) return MB_SUCCESS;
     661                 :            : 
     662                 :            :     ErrorCode result;
     663                 :            : 
     664                 :            :     // Position file
     665         [ #  # ]:          0 :     FSEEK( model->modelOffset + sideseth->memOffset );
     666                 :            : 
     667                 :            :     // Read ids for each entity type
     668                 :            :     unsigned int this_type, num_ents, sense_size;
     669                 :            : 
     670         [ #  # ]:          0 :     std::vector< char > bc_data;
     671                 :          0 :     unsigned int num_read = 0;  //, uid;
     672 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > ss_entities, excl_entities;
     673         [ #  # ]:          0 :     if( data_version <= 1.0 )
     674                 :            :     {
     675         [ #  # ]:          0 :         for( unsigned int i = 0; i < sideseth->memTypeCt; i++ )
     676                 :            :         {
     677                 :            :             // Get how many and what type
     678         [ #  # ]:          0 :             FREADI( 3 );
     679                 :          0 :             num_read += 3 * sizeof( int );
     680         [ #  # ]:          0 :             this_type  = uint_buf[0];
     681         [ #  # ]:          0 :             num_ents   = uint_buf[1];
     682         [ #  # ]:          0 :             sense_size = uint_buf[2];
     683                 :            : 
     684                 :            :             // Now get the ids
     685         [ #  # ]:          0 :             FREADI( num_ents );
     686                 :          0 :             num_read += sizeof( int );
     687         [ #  # ]:          0 :             CONVERT_TO_INTS( num_ents );
     688                 :            : 
     689         [ #  # ]:          0 :             result = get_entities( this_type + 2, &int_buf[0], num_ents, ss_entities, excl_entities );
     690         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     691                 :            : 
     692         [ #  # ]:          0 :             if( sense_size == 1 )
     693                 :            :             {
     694                 :            :                 // Byte-size sense flags; make sure read ends aligned...
     695                 :          0 :                 unsigned int read_length = ( num_ents / 8 ) * 8;
     696         [ #  # ]:          0 :                 if( read_length < num_ents ) read_length += 8;
     697         [ #  # ]:          0 :                 FREADC( read_length );
     698                 :          0 :                 num_read += read_length;
     699                 :            :             }
     700         [ #  # ]:          0 :             else if( sense_size == 2 )
     701                 :            :             {
     702                 :            :                 // Int-size sense flags
     703         [ #  # ]:          0 :                 FREADI( num_ents );
     704                 :          0 :                 num_read += sizeof( int );
     705                 :            :             }
     706                 :            : 
     707                 :            :             // Now do something with them...
     708         [ #  # ]:          0 :             process_sideset_10( this_type, num_ents, sense_size, ss_entities, sideseth );
     709                 :            :         }
     710                 :            :     }
     711                 :            :     else
     712                 :            :     {
     713         [ #  # ]:          0 :         for( unsigned int i = 0; i < sideseth->memTypeCt; i++ )
     714                 :            :         {
     715                 :            :             // Get how many and what type
     716         [ #  # ]:          0 :             FREADI( 1 );
     717                 :          0 :             num_read += sizeof( int );
     718         [ #  # ]:          0 :             num_ents = uint_buf[0];
     719                 :            : 
     720                 :            :             // Get the types, and ids
     721 [ #  # ][ #  # ]:          0 :             std::vector< unsigned int > mem_types( num_ents ), mem_ids( num_ents );
                 [ #  # ]
     722 [ #  # ][ #  # ]:          0 :             FREADIA( num_ents, &mem_types[0] );
     723                 :          0 :             num_read += num_ents * sizeof( int );
     724         [ #  # ]:          0 :             FREADI( num_ents );
     725                 :          0 :             num_read += sizeof( int );
     726                 :            : 
     727 [ #  # ][ #  # ]:          0 :             result = get_entities( &mem_types[0], &int_buf[0], num_ents, false, ss_entities );
     728         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     729                 :            : 
     730                 :            :             // Byte-size sense flags; make sure read ends aligned...
     731                 :          0 :             unsigned int read_length = ( num_ents / 8 ) * 8;
     732         [ #  # ]:          0 :             if( read_length < num_ents ) read_length += 8;
     733         [ #  # ]:          0 :             FREADC( read_length );
     734                 :          0 :             num_read += read_length;
     735                 :            : 
     736                 :            :             // wrt entities
     737         [ #  # ]:          0 :             FREADI( 1 );
     738                 :          0 :             num_read += sizeof( int );
     739         [ #  # ]:          0 :             int num_wrts = uint_buf[0];
     740         [ #  # ]:          0 :             FREADI( num_wrts );
     741                 :          0 :             num_read += num_wrts * sizeof( int );
     742                 :            : 
     743         [ #  # ]:          0 :             result = process_sideset_11( ss_entities, num_wrts, sideseth );
     744 [ #  # ][ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     745                 :          0 :         }
     746                 :            :     }
     747                 :            : 
     748                 :            :     // Now set the dist factors
     749         [ #  # ]:          0 :     if( sideseth->numDF > 0 )
     750                 :            :     {
     751                 :            :         // Have to read dist factors
     752         [ #  # ]:          0 :         FREADD( sideseth->numDF );
     753                 :          0 :         num_read += sideseth->numDF * sizeof( double );
     754                 :            :         Tag distFactorTag;
     755                 :            :         result = mdbImpl->tag_get_handle( "distFactor", 0, MB_TYPE_DOUBLE, distFactorTag,
     756         [ #  # ]:          0 :                                           MB_TAG_SPARSE | MB_TAG_VARLEN | MB_TAG_CREAT );
     757         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     758         [ #  # ]:          0 :         const void* dist_data = &dbl_buf[0];
     759                 :          0 :         const int dist_size   = sideseth->numDF;
     760         [ #  # ]:          0 :         result = mdbImpl->tag_set_by_ptr( distFactorTag, &sideseth->setHandle, 1, &dist_data, &dist_size );
     761         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     762                 :            :     }
     763                 :            : 
     764                 :            :     // Check for more data
     765 [ #  # ][ #  # ]:          0 :     if( data_version > 1.0 && num_read < sideseth->ssLength )
     766                 :            :     {
     767         [ #  # ]:          0 :         FREADC( 2 );  // num_read += 2;
     768 [ #  # ][ #  # ]:          0 :         if( char_buf[0] == 'i' && char_buf[1] == 'd' )
         [ #  # ][ #  # ]
                 [ #  # ]
     769                 :            :         {
     770         [ #  # ]:          0 :             FREADI( 1 );  // num_read += sizeof(int);
     771                 :            :             // uid = int_buf[0];
     772                 :            :         }
     773                 :            :         else
     774                 :            :         {
     775                 :            :             // Check for bc_data
     776 [ #  # ][ #  # ]:          0 :             if( char_buf[0] == 'b' && char_buf[1] == 'c' )
         [ #  # ][ #  # ]
                 [ #  # ]
     777                 :            :             {
     778         [ #  # ]:          0 :                 FREADI( 1 );  // num_read += sizeof(int);
     779         [ #  # ]:          0 :                 int num_bcs = uint_buf[0];
     780         [ #  # ]:          0 :                 bc_data.resize( num_bcs );
     781 [ #  # ][ #  # ]:          0 :                 FREADCA( num_bcs, &bc_data[0] );  // num_read += num_bcs;
     782                 :            :             }
     783                 :            :         }
     784                 :            :     }
     785                 :            : 
     786         [ #  # ]:          0 :     if( debug )
     787                 :            :     {
     788         [ #  # ]:          0 :         sideseth->print();
     789         [ #  # ]:          0 :         if( !bc_data.empty() )
     790                 :            :         {
     791         [ #  # ]:          0 :             std::cout << "bc_data = ";
     792                 :          0 :             std::vector< char >::iterator vit = bc_data.begin();
     793 [ #  # ][ #  # ]:          0 :             for( ; vit != bc_data.end(); ++vit )
                 [ #  # ]
     794                 :            :             {
     795 [ #  # ][ #  # ]:          0 :                 std::cout << std::hex << (int)( (unsigned char)*vit ) << " ";
         [ #  # ][ #  # ]
     796                 :            :             }
     797         [ #  # ]:          0 :             std::cout << ": ";
     798                 :          0 :             vit = bc_data.begin();
     799 [ #  # ][ #  # ]:          0 :             for( ; vit != bc_data.end(); ++vit )
                 [ #  # ]
     800                 :            :             {
     801 [ #  # ][ #  # ]:          0 :                 std::cout << *vit;
     802                 :            :             }
     803         [ #  # ]:          0 :             std::cout << std::endl;
     804                 :            :         }
     805                 :            :     }
     806                 :            : 
     807         [ #  # ]:          0 :     result = get_names( model->sidesetMD, ssindex, sideseth->setHandle );
     808         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     809                 :            : 
     810                 :          0 :     const int def_bc_data_len = 0;
     811 [ #  # ][ #  # ]:          0 :     std::string tag_name      = std::string( NEUMANN_SET_TAG_NAME ) + "__BC_DATA";
     812                 :            :     Tag nbc_data;
     813                 :            :     result = mdbImpl->tag_get_handle( tag_name.c_str(), def_bc_data_len, MB_TYPE_OPAQUE, nbc_data,
     814         [ #  # ]:          0 :                                       MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES | MB_TAG_VARLEN, NULL );
     815         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     816 [ #  # ][ #  # ]:          0 :     void const* tag_data[] = { ( bc_data.empty() ) ? NULL : &( bc_data[0] ) };
     817                 :          0 :     int tag_size           = bc_data.size();
     818         [ #  # ]:          0 :     result                 = mdbImpl->tag_set_by_ptr( nbc_data, &sideseth->setHandle, 1, tag_data, &tag_size );
     819         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     820                 :            : 
     821                 :          0 :     return MB_SUCCESS;
     822                 :            : }
     823                 :            : 
     824                 :          0 : ErrorCode Tqdcfr::process_sideset_10( const int this_type, const int num_ents, const int sense_size,
     825                 :            :                                       std::vector< EntityHandle >& ss_entities, Tqdcfr::SidesetHeader* sideseth )
     826                 :            : {
     827 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > forward, reverse;
     828         [ #  # ]:          0 :     if( this_type == 3      // Surface
     829         [ #  # ]:          0 :         && sense_size == 1  // Byte size
     830                 :            :     )
     831                 :            :     {
     832                 :            :         // Interpret sense flags w/o reference to anything
     833         [ #  # ]:          0 :         for( int i = 0; i < num_ents; i++ )
     834                 :            :         {
     835 [ #  # ][ #  # ]:          0 :             if( (int)char_buf[i] == 0 )
     836 [ #  # ][ #  # ]:          0 :                 forward.push_back( ss_entities[i] );
     837 [ #  # ][ #  # ]:          0 :             else if( (int)char_buf[i] == 1 )
     838 [ #  # ][ #  # ]:          0 :                 reverse.push_back( ss_entities[i] );
     839 [ #  # ][ #  # ]:          0 :             else if( (int)char_buf[i] == -1 )
     840                 :            :             {  // -1 means "unknown", which means both
     841 [ #  # ][ #  # ]:          0 :                 forward.push_back( ss_entities[i] );
     842 [ #  # ][ #  # ]:          0 :                 reverse.push_back( ss_entities[i] );
     843                 :            :             }
     844                 :          0 :         }
     845                 :            :     }
     846         [ #  # ]:          0 :     else if( this_type == 4      // Curve
     847         [ #  # ]:          0 :              && sense_size == 2  // int32 size
     848                 :            :     )
     849                 :            :     {
     850         [ #  # ]:          0 :         for( int i = 0; i < num_ents; i++ )
     851                 :            :         {
     852 [ #  # ][ #  # ]:          0 :             if( uint_buf[i] == 0 )
     853 [ #  # ][ #  # ]:          0 :                 forward.push_back( ss_entities[i] );
     854 [ #  # ][ #  # ]:          0 :             else if( uint_buf[i] == 1 )
     855 [ #  # ][ #  # ]:          0 :                 reverse.push_back( ss_entities[i] );
     856 [ #  # ][ #  # ]:          0 :             else if( *( (int*)&uint_buf[i] ) == -1 )
     857                 :            :             {  // -1 means "unknown", which means both
     858 [ #  # ][ #  # ]:          0 :                 forward.push_back( ss_entities[i] );
     859 [ #  # ][ #  # ]:          0 :                 reverse.push_back( ss_entities[i] );
     860                 :            :             }
     861                 :            :         }
     862                 :            :     }
     863                 :            : 
     864                 :            :     // Now actually put them in the set
     865                 :          0 :     ErrorCode result = MB_SUCCESS;
     866         [ #  # ]:          0 :     if( !forward.empty() )
     867                 :            :     {
     868 [ #  # ][ #  # ]:          0 :         ErrorCode tmp_result = mdbImpl->add_entities( sideseth->setHandle, &forward[0], forward.size() );
     869         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     870                 :            :     }
     871         [ #  # ]:          0 :     if( !reverse.empty() )
     872                 :            :     {
     873                 :            :         // Need to make a new set, add a reverse sense tag, then add to the sideset
     874                 :            :         EntityHandle reverse_set;
     875         [ #  # ]:          0 :         ErrorCode tmp_result = create_set( reverse_set );
     876         [ #  # ]:          0 :         if( MB_SUCCESS != tmp_result ) result = tmp_result;
     877 [ #  # ][ #  # ]:          0 :         tmp_result = mdbImpl->add_entities( reverse_set, &reverse[0], reverse.size() );
     878         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     879                 :          0 :         int def_val = 1;
     880                 :            :         Tag sense_tag;
     881                 :            :         tmp_result = mdbImpl->tag_get_handle( "NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag,
     882         [ #  # ]:          0 :                                               MB_TAG_SPARSE | MB_TAG_CREAT, &def_val );
     883         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     884                 :          0 :         def_val    = -1;
     885         [ #  # ]:          0 :         tmp_result = mdbImpl->tag_set_data( sense_tag, &reverse_set, 1, &def_val );
     886         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     887         [ #  # ]:          0 :         tmp_result = mdbImpl->add_entities( sideseth->setHandle, &reverse_set, 1 );
     888         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     889                 :            :     }
     890                 :            : 
     891                 :          0 :     return result;
     892                 :            : }
     893                 :            : 
     894                 :          0 : ErrorCode Tqdcfr::process_sideset_11( std::vector< EntityHandle >& ss_entities, int num_wrts,
     895                 :            :                                       Tqdcfr::SidesetHeader* sideseth )
     896                 :            : {
     897 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > forward, reverse;
     898                 :            : 
     899                 :          0 :     unsigned int num_ents = ss_entities.size();
     900         [ #  # ]:          0 :     unsigned int* wrt_it  = &uint_buf[0];
     901                 :            : 
     902         [ #  # ]:          0 :     for( unsigned int i = 0; i < num_ents; i++ )
     903                 :            :     {
     904                 :          0 :         unsigned int num_wrt = 0;
     905         [ #  # ]:          0 :         if( 0 != num_wrts ) num_wrt = *wrt_it++;
     906         [ #  # ]:          0 :         for( unsigned int j = 0; j < num_wrt; j++ )
     907                 :          0 :             wrt_it += 2;
     908                 :            :         // Assume here that if it's in the list twice, we get both senses
     909         [ #  # ]:          0 :         if( num_wrt > 1 )
     910                 :            :         {
     911 [ #  # ][ #  # ]:          0 :             forward.push_back( ss_entities[i] );
     912 [ #  # ][ #  # ]:          0 :             reverse.push_back( ss_entities[i] );
     913                 :            :         }
     914                 :            :         else
     915                 :            :         {
     916                 :            :             // Else interpret the sense flag
     917 [ #  # ][ #  # ]:          0 :             if( (int)char_buf[i] == 0 )
     918 [ #  # ][ #  # ]:          0 :                 forward.push_back( ss_entities[i] );
     919 [ #  # ][ #  # ]:          0 :             else if( (int)char_buf[i] == 1 )
     920 [ #  # ][ #  # ]:          0 :                 reverse.push_back( ss_entities[i] );
     921 [ #  # ][ #  # ]:          0 :             else if( (int)char_buf[i] == -1 )
     922                 :            :             {  // -1 means "unknown", which means both
     923 [ #  # ][ #  # ]:          0 :                 forward.push_back( ss_entities[i] );
     924 [ #  # ][ #  # ]:          0 :                 reverse.push_back( ss_entities[i] );
     925                 :            :             }
     926                 :            :         }
     927                 :            :     }
     928                 :            : 
     929                 :            :     // Now actually put them in the set
     930                 :          0 :     ErrorCode result = MB_SUCCESS;
     931         [ #  # ]:          0 :     if( !forward.empty() )
     932                 :            :     {
     933 [ #  # ][ #  # ]:          0 :         ErrorCode tmp_result = mdbImpl->add_entities( sideseth->setHandle, &forward[0], forward.size() );
     934         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     935                 :            :     }
     936         [ #  # ]:          0 :     if( !reverse.empty() )
     937                 :            :     {
     938                 :            :         // Need to make a new set, add a reverse sense tag, then add to the sideset
     939                 :            :         EntityHandle reverse_set;
     940         [ #  # ]:          0 :         ErrorCode tmp_result = create_set( reverse_set );
     941         [ #  # ]:          0 :         if( MB_SUCCESS != tmp_result ) result = tmp_result;
     942 [ #  # ][ #  # ]:          0 :         tmp_result = mdbImpl->add_entities( reverse_set, &reverse[0], reverse.size() );
     943         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     944                 :          0 :         int def_val = 1;
     945                 :            :         Tag sense_tag;
     946                 :            :         tmp_result = mdbImpl->tag_get_handle( "NEUSET_SENSE", 1, MB_TYPE_INTEGER, sense_tag,
     947         [ #  # ]:          0 :                                               MB_TAG_SPARSE | MB_TAG_CREAT, &def_val );
     948 [ #  # ][ #  # ]:          0 :         if( tmp_result != MB_SUCCESS && tmp_result != MB_ALREADY_ALLOCATED ) result = tmp_result;
     949                 :          0 :         def_val    = -1;
     950         [ #  # ]:          0 :         tmp_result = mdbImpl->tag_set_data( sense_tag, &reverse_set, 1, &def_val );
     951         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     952         [ #  # ]:          0 :         tmp_result = mdbImpl->add_entities( sideseth->setHandle, &reverse_set, 1 );
     953         [ #  # ]:          0 :         if( tmp_result != MB_SUCCESS ) result = tmp_result;
     954                 :            :     }
     955                 :            : 
     956                 :          0 :     return result;
     957                 :            : }
     958                 :            : 
     959                 :          0 : ErrorCode Tqdcfr::read_block( const unsigned int blindex, const double /*data_version*/, Tqdcfr::ModelEntry* model,
     960                 :            :                               Tqdcfr::BlockHeader* blockh )
     961                 :            : {
     962         [ #  # ]:          0 :     if( blockh->memCt == 0 ) return MB_SUCCESS;
     963                 :            : 
     964                 :            :     // Position file
     965         [ #  # ]:          0 :     FSEEK( model->modelOffset + blockh->memOffset );
     966                 :            : 
     967                 :            :     // Read ids for each entity type
     968                 :          0 :     unsigned int num_read = 0;
     969                 :            :     int this_type, num_ents;  //, uid;
     970 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > block_entities, excl_entities;
     971         [ #  # ]:          0 :     for( unsigned int i = 0; i < blockh->memTypeCt; i++ )
     972                 :            :     {
     973                 :            :         // Get how many and what type
     974         [ #  # ]:          0 :         FREADI( 2 );
     975                 :          0 :         num_read += 2 * sizeof( int );
     976         [ #  # ]:          0 :         this_type = uint_buf[0];
     977         [ #  # ]:          0 :         num_ents  = uint_buf[1];
     978                 :            : 
     979                 :            :         // Now get the ids
     980         [ #  # ]:          0 :         FREADI( num_ents );
     981                 :          0 :         num_read += num_ents * sizeof( int );
     982         [ #  # ]:          0 :         CONVERT_TO_INTS( num_ents );
     983                 :            : 
     984         [ #  # ]:          0 :         ErrorCode result = get_entities( this_type + 2, &int_buf[0], num_ents, block_entities, excl_entities );
     985         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     986                 :            :     }
     987                 :            : 
     988                 :            :     // And put entities into this block's set
     989         [ #  # ]:          0 :     ErrorCode result = put_into_set( blockh->setHandle, block_entities, excl_entities );
     990         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
     991                 :            : 
     992                 :            :     // Read attribs if there are any
     993                 :            :     Tag block_attribs;
     994                 :            :     {
     995                 :          0 :         int def_block_attributes_length = 0;
     996                 :            :         result = mdbImpl->tag_get_handle( BLOCK_ATTRIBUTES, def_block_attributes_length, MB_TYPE_DOUBLE, block_attribs,
     997         [ #  # ]:          0 :                                           MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_VARLEN, NULL );
     998 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result ) return result;
     999                 :            :     }
    1000                 :            : 
    1001         [ #  # ]:          0 :     if( blockh->attribOrder > 0 )
    1002                 :            :     {
    1003         [ #  # ]:          0 :         FREADD( blockh->attribOrder );
    1004                 :          0 :         num_read += sizeof( double );
    1005         [ #  # ]:          0 :         void const* tag_data[] = { &dbl_buf[0] };
    1006                 :          0 :         int tag_sizes[]        = { static_cast< int >( blockh->attribOrder ) };
    1007         [ #  # ]:          0 :         result = mdbImpl->tag_set_by_ptr( block_attribs, &( blockh->setHandle ), 1, tag_data, tag_sizes );
    1008         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1009                 :            :     }
    1010                 :            : 
    1011                 :            :     // Check for more data
    1012         [ #  # ]:          0 :     if( num_read < blockh->blockLength )
    1013                 :            :     {
    1014         [ #  # ]:          0 :         FREADC( 2 );  // num_read += 2;
    1015 [ #  # ][ #  # ]:          0 :         if( char_buf[0] == 'i' && char_buf[1] == 'd' )
         [ #  # ][ #  # ]
                 [ #  # ]
    1016                 :            :         {
    1017         [ #  # ]:          0 :             FREADI( 1 );  // num_read += sizeof(int);
    1018                 :            :             // uid = int_buf[0];
    1019                 :            :         }
    1020                 :            :     }
    1021                 :            : 
    1022         [ #  # ]:          0 :     result = get_names( model->blockMD, blindex, blockh->setHandle );
    1023         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1024                 :            : 
    1025                 :            :     // Put additional higher-order nodes into element connectivity list.
    1026                 :            :     // Cubit saves full connectivity list only for NodeHex and NodeTet
    1027                 :            :     // elements. Other element types will only have the corners and
    1028                 :            :     // the mid-element node if there is one. Need to reconstruct additional
    1029                 :            :     // connectivity entries from mid-nodes of adjacent lower-order entities.
    1030                 :          0 :     int node_per_elem = cub_elem_num_verts[blockh->blockElemType];
    1031         [ #  # ]:          0 :     if( blockh->blockEntityType == MBMAXTYPE ) return MB_SUCCESS;
    1032 [ #  # ][ #  # ]:          0 :     if( ( 14 == major && 2 < minor ) || 15 <= major )
                 [ #  # ]
    1033                 :            :     {
    1034 [ #  # ][ #  # ]:          0 :         if( 55 == blockh->blockElemType || CN::VerticesPerEntity( blockh->blockEntityType ) == node_per_elem )
         [ #  # ][ #  # ]
    1035                 :          0 :             return MB_SUCCESS;
    1036                 :            :     }
    1037                 :            :     else
    1038                 :            :     {
    1039 [ #  # ][ #  # ]:          0 :         if( 52 == blockh->blockElemType || CN::VerticesPerEntity( blockh->blockEntityType ) == node_per_elem )
         [ #  # ][ #  # ]
    1040                 :          0 :             return MB_SUCCESS;
    1041                 :            :     }
    1042                 :            : 
    1043                 :            :     // Can't use Interface::convert_entities because block could contain
    1044                 :            :     // both entity sets and entities. convert_entities will fail if block
    1045                 :            :     // contains an entity set, but we still need to call it on any elements
    1046                 :            :     // directly in the block (rather than a geometry subset). So bypass
    1047                 :            :     // Interface and call HOFactory directly with an Range of entities.
    1048 [ #  # ][ #  # ]:          0 :     Range ho_entities, entities;
    1049         [ #  # ]:          0 :     mdbImpl->get_entities_by_type( blockh->setHandle, blockh->blockEntityType, entities, true );
    1050 [ #  # ][ #  # ]:          0 :     if( CN::Dimension( blockh->blockEntityType ) > 2 )
    1051                 :            :     {
    1052         [ #  # ]:          0 :         result = mdbImpl->get_adjacencies( entities, 2, false, ho_entities, Interface::UNION );
    1053         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1054                 :            :     }
    1055 [ #  # ][ #  # ]:          0 :     if( CN::Dimension( blockh->blockEntityType ) > 1 )
    1056                 :            :     {
    1057         [ #  # ]:          0 :         result = mdbImpl->get_adjacencies( entities, 1, false, ho_entities, Interface::UNION );
    1058         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1059                 :            :     }
    1060         [ #  # ]:          0 :     entities.merge( ho_entities );
    1061                 :            : 
    1062         [ #  # ]:          0 :     Core* mbcore = dynamic_cast< Core* >( mdbImpl );
    1063         [ #  # ]:          0 :     assert( mbcore != NULL );
    1064         [ #  # ]:          0 :     HigherOrderFactory ho_fact( mbcore, 0 );
    1065         [ #  # ]:          0 :     return ho_fact.convert( entities, !!blockh->hasMidNodes[1], !!blockh->hasMidNodes[2], !!blockh->hasMidNodes[3] );
    1066                 :            : }
    1067                 :            : 
    1068                 :          0 : ErrorCode Tqdcfr::get_names( MetaDataContainer& md, unsigned int set_index, EntityHandle seth )
    1069                 :            : {
    1070                 :          0 :     ErrorCode result = MB_SUCCESS;
    1071                 :            : 
    1072                 :            :     // Now get block names, if any
    1073 [ #  # ][ #  # ]:          0 :     int md_index = md.get_md_entry( set_index, "Name" );
    1074         [ #  # ]:          0 :     if( -1 == md_index ) return result;
    1075         [ #  # ]:          0 :     MetaDataContainer::MetaDataEntry* md_entry = &( md.metadataEntries[md_index] );
    1076                 :            :     // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE);
    1077                 :            :     char name_tag_data[NAME_TAG_SIZE];
    1078                 :          0 :     memset( name_tag_data, 0, NAME_TAG_SIZE );  // Make sure any extra bytes zeroed
    1079                 :          0 :     strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
    1080         [ #  # ]:          0 :     result = mdbImpl->tag_set_data( entityNameTag, &seth, 1, name_tag_data );
    1081         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1082                 :            : 
    1083                 :            :     // Look for extra names
    1084 [ #  # ][ #  # ]:          0 :     md_index = md.get_md_entry( set_index, "NumExtraNames" );
    1085         [ #  # ]:          0 :     if( -1 == md_index ) return result;
    1086         [ #  # ]:          0 :     int num_names = md.metadataEntries[md_index].mdIntValue;
    1087         [ #  # ]:          0 :     for( int i = 0; i < num_names; i++ )
    1088                 :            :     {
    1089 [ #  # ][ #  # ]:          0 :         std::ostringstream extra_name_label( "ExtraName" );
    1090         [ #  # ]:          0 :         extra_name_label << i;
    1091 [ #  # ][ #  # ]:          0 :         std::ostringstream moab_extra_name( "EXTRA_" );
                 [ #  # ]
    1092 [ #  # ][ #  # ]:          0 :         moab_extra_name << NAME_TAG_NAME << i;
    1093 [ #  # ][ #  # ]:          0 :         md_index = md.get_md_entry( set_index, extra_name_label.str().c_str() );
                 [ #  # ]
    1094         [ #  # ]:          0 :         if( -1 != md_index )
    1095                 :            :         {
    1096         [ #  # ]:          0 :             md_entry = &( md.metadataEntries[md_index] );
    1097                 :            :             Tag extra_name_tag;
    1098                 :            :             ErrorCode rval;
    1099                 :            :             rval = mdbImpl->tag_get_handle( moab_extra_name.str().c_str(), NAME_TAG_SIZE, MB_TYPE_OPAQUE,
    1100 [ #  # ][ #  # ]:          0 :                                             extra_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT );MB_CHK_ERR( rval );
         [ #  # ][ #  # ]
                 [ #  # ]
    1101                 :          0 :             memset( name_tag_data, 0, NAME_TAG_SIZE );  // Make sure any extra bytes zeroed
    1102                 :          0 :             strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
    1103 [ #  # ][ #  # ]:          0 :             result = mdbImpl->tag_set_data( extra_name_tag, &seth, 1, name_tag_data );
    1104                 :            :         }
    1105                 :          0 :     }
    1106                 :            : 
    1107                 :          0 :     return result;
    1108                 :            : }
    1109                 :            : 
    1110                 :          0 : ErrorCode Tqdcfr::read_group( const unsigned int group_index, Tqdcfr::ModelEntry* model, Tqdcfr::GroupHeader* grouph )
    1111                 :            : {
    1112                 :            :     // Position file
    1113         [ #  # ]:          0 :     FSEEK( model->modelOffset + grouph->memOffset );
    1114                 :            :     char name_tag_data[NAME_TAG_SIZE];
    1115                 :            : 
    1116                 :            :     // Read ids for each entity type
    1117                 :            :     int this_type, num_ents;
    1118 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > grp_entities, excl_entities;
    1119         [ #  # ]:          0 :     for( unsigned int i = 0; i < grouph->memTypeCt; i++ )
    1120                 :            :     {
    1121                 :            :         // Get how many and what type
    1122         [ #  # ]:          0 :         FREADI( 2 );
    1123         [ #  # ]:          0 :         this_type = uint_buf[0];
    1124         [ #  # ]:          0 :         num_ents  = uint_buf[1];
    1125                 :            : 
    1126                 :            :         // Now get the ids
    1127         [ #  # ]:          0 :         FREADI( num_ents );
    1128         [ #  # ]:          0 :         CONVERT_TO_INTS( num_ents );
    1129                 :            : 
    1130                 :            :         // Get the entities in this group
    1131         [ #  # ]:          0 :         ErrorCode result = get_entities( this_type, &int_buf[0], num_ents, grp_entities, excl_entities );
    1132         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1133                 :            :     }
    1134                 :            : 
    1135                 :            :     // Now add the entities
    1136         [ #  # ]:          0 :     ErrorCode result = put_into_set( grouph->setHandle, grp_entities, excl_entities );
    1137         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1138                 :            : 
    1139                 :            :     // Now get group names, if any
    1140 [ #  # ][ #  # ]:          0 :     int md_index = model->groupMD.get_md_entry( grouph->grpID, "NAME" );
    1141         [ #  # ]:          0 :     if( -1 != md_index )
    1142                 :            :     {
    1143         [ #  # ]:          0 :         MetaDataContainer::MetaDataEntry* md_entry = &( model->groupMD.metadataEntries[md_index] );
    1144         [ #  # ]:          0 :         if( 0 == entityNameTag )
    1145                 :            :         {
    1146                 :          0 :             memset( name_tag_data, 0, NAME_TAG_SIZE );
    1147                 :            :             result = mdbImpl->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, entityNameTag,
    1148         [ #  # ]:          0 :                                               MB_TAG_SPARSE | MB_TAG_CREAT, name_tag_data );
    1149         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
    1150                 :            :         }
    1151                 :            :         // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE);
    1152                 :          0 :         memset( name_tag_data, 0, NAME_TAG_SIZE );  // Make sure any extra bytes zeroed
    1153                 :          0 :         strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
    1154         [ #  # ]:          0 :         result = mdbImpl->tag_set_data( entityNameTag, &grouph->setHandle, 1, name_tag_data );
    1155         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1156                 :            : 
    1157                 :            :         // Look for extra names
    1158 [ #  # ][ #  # ]:          0 :         md_index = model->groupMD.get_md_entry( group_index, "NumExtraNames" );
    1159         [ #  # ]:          0 :         if( -1 != md_index )
    1160                 :            :         {
    1161         [ #  # ]:          0 :             int num_names = model->groupMD.metadataEntries[md_index].mdIntValue;
    1162         [ #  # ]:          0 :             for( int i = 0; i < num_names; i++ )
    1163                 :            :             {
    1164 [ #  # ][ #  # ]:          0 :                 std::ostringstream extra_name_label( "ExtraName" );
    1165         [ #  # ]:          0 :                 extra_name_label << i;
    1166 [ #  # ][ #  # ]:          0 :                 std::ostringstream moab_extra_name( "EXTRA_" );
                 [ #  # ]
    1167 [ #  # ][ #  # ]:          0 :                 moab_extra_name << NAME_TAG_NAME << i;
    1168 [ #  # ][ #  # ]:          0 :                 md_index = model->groupMD.get_md_entry( group_index, extra_name_label.str().c_str() );
                 [ #  # ]
    1169         [ #  # ]:          0 :                 if( -1 != md_index )
    1170                 :            :                 {
    1171         [ #  # ]:          0 :                     md_entry = &( model->groupMD.metadataEntries[md_index] );
    1172                 :            :                     Tag extra_name_tag;
    1173                 :          0 :                     memset( name_tag_data, 0, NAME_TAG_SIZE );
    1174                 :            :                     result = mdbImpl->tag_get_handle( moab_extra_name.str().c_str(), NAME_TAG_SIZE, MB_TYPE_OPAQUE,
    1175 [ #  # ][ #  # ]:          0 :                                                       extra_name_tag, MB_TAG_SPARSE | MB_TAG_CREAT, name_tag_data );
    1176         [ #  # ]:          0 :                     if( MB_SUCCESS != result ) return result;
    1177                 :            :                     // assert(md_entry->mdStringValue.length() + 1 <= NAME_TAG_SIZE);
    1178                 :          0 :                     memset( name_tag_data, 0, NAME_TAG_SIZE );  // Make sure any extra bytes zeroed
    1179                 :          0 :                     strncpy( name_tag_data, md_entry->mdStringValue.c_str(), NAME_TAG_SIZE - 1 );
    1180 [ #  # ][ #  # ]:          0 :                     result = mdbImpl->tag_set_data( extra_name_tag, &grouph->setHandle, 1, name_tag_data );
    1181                 :            :                 }
    1182                 :          0 :             }
    1183                 :            :         }
    1184                 :            :     }
    1185                 :            : 
    1186                 :          0 :     return result;
    1187                 :            : }
    1188                 :            : 
    1189                 :          0 : ErrorCode Tqdcfr::put_into_set( EntityHandle set_handle, std::vector< EntityHandle >& entities,
    1190                 :            :                                 std::vector< EntityHandle >& excl_entities )
    1191                 :            : {
    1192                 :            :     // And put entities into this block's set
    1193 [ #  # ][ #  # ]:          0 :     ErrorCode result = mdbImpl->add_entities( set_handle, &entities[0], entities.size() );
    1194         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1195                 :            : 
    1196                 :            :     // Check for excluded entities, and add them to a vector hung off the block if there
    1197                 :            :     Tag excl_tag;
    1198         [ #  # ]:          0 :     if( !excl_entities.empty() )
    1199                 :            :     {
    1200                 :            :         result = mdbImpl->tag_get_handle( "Exclude_Entities", sizeof( std::vector< EntityHandle >* ), MB_TYPE_OPAQUE,
    1201         [ #  # ]:          0 :                                           excl_tag, MB_TAG_SPARSE | MB_TAG_CREAT );
    1202         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1203 [ #  # ][ #  # ]:          0 :         std::vector< EntityHandle >* new_vector = new std::vector< EntityHandle >;
    1204                 :          0 :         new_vector->swap( excl_entities );
    1205         [ #  # ]:          0 :         result = mdbImpl->tag_set_data( excl_tag, &set_handle, 1, &new_vector );
    1206         [ #  # ]:          0 :         if( MB_SUCCESS != result )
    1207                 :            :         {
    1208         [ #  # ]:          0 :             delete new_vector;
    1209                 :          0 :             return MB_FAILURE;
    1210                 :            :         }
    1211                 :            :     }
    1212                 :            : 
    1213                 :          0 :     return MB_SUCCESS;
    1214                 :            : }
    1215                 :            : 
    1216                 :          0 : ErrorCode Tqdcfr::get_entities( const unsigned int* mem_types, int* id_buf, const unsigned int id_buf_size,
    1217                 :            :                                 const bool is_group, std::vector< EntityHandle >& entities )
    1218                 :            : {
    1219                 :          0 :     ErrorCode tmp_result, result = MB_SUCCESS;
    1220                 :            : 
    1221         [ #  # ]:          0 :     for( unsigned int i = 0; i < id_buf_size; i++ )
    1222                 :            :     {
    1223         [ #  # ]:          0 :         if( is_group )
    1224                 :          0 :             tmp_result = get_entities( mem_types[i], id_buf + i, 1, entities, entities );
    1225                 :            :         else
    1226                 :            :             // For blocks/nodesets/sidesets, use CSOEntityType, which is 2 greater than
    1227                 :            :             // group entity types
    1228                 :          0 :             tmp_result = get_entities( mem_types[i] + 2, id_buf + i, 1, entities, entities );
    1229         [ #  # ]:          0 :         if( MB_SUCCESS != tmp_result ) result = tmp_result;
    1230                 :            :     }
    1231                 :            : 
    1232                 :          0 :     return result;
    1233                 :            : }
    1234                 :            : 
    1235                 :          0 : ErrorCode Tqdcfr::get_entities( const unsigned int this_type, int* id_buf, const unsigned int id_buf_size,
    1236                 :            :                                 std::vector< EntityHandle >& entities, std::vector< EntityHandle >& excl_entities )
    1237                 :            : {
    1238                 :          0 :     ErrorCode result = MB_FAILURE;
    1239                 :            : 
    1240         [ #  # ]:          0 :     if( this_type <= VERTEX )
    1241                 :          0 :         result = get_ref_entities( this_type, id_buf, id_buf_size, entities );
    1242 [ #  # ][ #  # ]:          0 :     else if( this_type >= HEX && this_type <= NODE )
    1243                 :          0 :         result = get_mesh_entities( this_type, id_buf, id_buf_size, entities, excl_entities );
    1244                 :            : 
    1245                 :          0 :     return result;
    1246                 :            : }
    1247                 :            : 
    1248                 :          0 : ErrorCode Tqdcfr::get_ref_entities( const unsigned int this_type, int* id_buf, const unsigned int id_buf_size,
    1249                 :            :                                     std::vector< EntityHandle >& entities )
    1250                 :            : {
    1251         [ #  # ]:          0 :     for( unsigned int i = 0; i < id_buf_size; i++ )
    1252                 :          0 :         entities.push_back( ( gidSetMap[5 - this_type] )[id_buf[i]] );
    1253                 :            : 
    1254                 :          0 :     return MB_SUCCESS;
    1255                 :            : }
    1256                 :            : 
    1257                 :          0 : ErrorCode Tqdcfr::get_mesh_entities( const unsigned int this_type, int* id_buf, const unsigned int id_buf_size,
    1258                 :            :                                      std::vector< EntityHandle >& entities, std::vector< EntityHandle >& excl_entities )
    1259                 :            : {
    1260                 :          0 :     ErrorCode result                      = MB_SUCCESS;
    1261                 :          0 :     std::vector< EntityHandle >* ent_list = NULL;
    1262                 :          0 :     EntityType this_ent_type              = MBVERTEX;
    1263                 :          0 :     const unsigned int arr_len            = sizeof( group_type_to_mb_type ) / sizeof( group_type_to_mb_type[0] );
    1264         [ #  # ]:          0 :     if( this_type > 1000 )
    1265                 :            :     {
    1266         [ #  # ]:          0 :         if( this_type - 1000 < arr_len )
    1267                 :            :         {
    1268                 :          0 :             this_ent_type = group_type_to_mb_type[this_type - 1000];
    1269                 :          0 :             ent_list      = &excl_entities;
    1270                 :            :         }
    1271                 :            :     }
    1272                 :            :     else
    1273                 :            :     {
    1274         [ #  # ]:          0 :         if( this_type < arr_len )
    1275                 :            :         {
    1276                 :          0 :             this_ent_type = group_type_to_mb_type[this_type];
    1277                 :          0 :             ent_list      = &entities;
    1278                 :            :         }
    1279                 :            :     }
    1280 [ #  # ][ #  # ]:          0 :     if( NULL == ent_list ) { MB_SET_ERR( MB_FAILURE, "Entities list is NULL" ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1281                 :            : 
    1282                 :            :     // Get entities with this type, and get their cub id tags
    1283         [ #  # ]:          0 :     if( MBVERTEX == this_ent_type )
    1284                 :            :     {
    1285                 :            :         // Use either vertex offset or cubMOABVertexMap
    1286         [ #  # ]:          0 :         if( NULL == cubMOABVertexMap )
    1287                 :            :         {
    1288         [ #  # ]:          0 :             for( unsigned int i = 0; i < id_buf_size; i++ )
    1289         [ #  # ]:          0 :                 ent_list->push_back( ( EntityHandle )( id_buf[i] + currVHandleOffset ) );
    1290                 :            :         }
    1291                 :            :         else
    1292                 :            :         {
    1293         [ #  # ]:          0 :             for( unsigned int i = 0; i < id_buf_size; i++ )
    1294                 :            :             {
    1295         [ #  # ]:          0 :                 assert( 0 != ( *cubMOABVertexMap )[id_buf[i]] );
    1296                 :          0 :                 ent_list->push_back( ( *cubMOABVertexMap )[id_buf[i]] );
    1297                 :            :             }
    1298                 :            :         }
    1299                 :            :     }
    1300                 :            :     else
    1301                 :            :     {
    1302         [ #  # ]:          0 :         Range tmp_ents;
    1303         [ #  # ]:          0 :         result = mdbImpl->get_entities_by_type( 0, this_ent_type, tmp_ents );
    1304         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1305 [ #  # ][ #  # ]:          0 :         if( tmp_ents.empty() && 0 != id_buf_size ) return MB_FAILURE;
         [ #  # ][ #  # ]
    1306                 :            : 
    1307 [ #  # ][ #  # ]:          0 :         std::vector< int > cub_ids( tmp_ents.size() );
                 [ #  # ]
    1308 [ #  # ][ #  # ]:          0 :         result = mdbImpl->tag_get_data( globalIdTag, tmp_ents, &cub_ids[0] );
    1309 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != result && MB_TAG_NOT_FOUND != result ) return result;
    1310                 :            : 
    1311                 :            :         // Now go through id list, finding each entity by id
    1312 [ #  # ][ #  # ]:          0 :         for( unsigned int i = 0; i < id_buf_size; i++ )
    1313                 :            :         {
    1314         [ #  # ]:          0 :             std::vector< int >::iterator vit = std::find( cub_ids.begin(), cub_ids.end(), id_buf[i] );
    1315 [ #  # ][ #  # ]:          0 :             if( vit != cub_ids.end() )
    1316                 :            :             {
    1317 [ #  # ][ #  # ]:          0 :                 EntityHandle this_ent = tmp_ents[vit - cub_ids.begin()];
    1318 [ #  # ][ #  # ]:          0 :                 if( mdbImpl->type_from_handle( this_ent ) != MBMAXTYPE ) ent_list->push_back( this_ent );
                 [ #  # ]
    1319                 :            :             }
    1320                 :            :             else
    1321                 :            :             {
    1322 [ #  # ][ #  # ]:          0 :                 std::cout << "Warning: didn't find " << CN::EntityTypeName( this_ent_type ) << " " << id_buf[i]
         [ #  # ][ #  # ]
                 [ #  # ]
    1323         [ #  # ]:          0 :                           << std::endl;
    1324                 :            :             }
    1325                 :          0 :         }
    1326                 :            :     }
    1327                 :            : 
    1328                 :          0 :     return result;
    1329                 :            : }
    1330                 :            : 
    1331                 :          0 : ErrorCode Tqdcfr::read_nodes( const unsigned int gindex, Tqdcfr::ModelEntry* model, Tqdcfr::GeomHeader* entity )
    1332                 :            : {
    1333         [ #  # ]:          0 :     if( entity->nodeCt == 0 )
    1334                 :            :     {
    1335 [ #  # ][ #  # ]:          0 :         if( debug ) std::cout << "(no nodes) ";
    1336                 :          0 :         return MB_SUCCESS;
    1337                 :            :     }
    1338                 :            : 
    1339                 :            :     // Get the ids & coords in separate calls to minimize memory usage
    1340                 :            :     // Position the file
    1341         [ #  # ]:          0 :     FSEEK( model->modelOffset + entity->nodeOffset );
    1342                 :            :     // Get node ids in uint_buf
    1343         [ #  # ]:          0 :     FREADI( entity->nodeCt );
    1344                 :            : 
    1345         [ #  # ]:          0 :     if( debug )
    1346                 :            :     {
    1347         [ #  # ]:          0 :         std::cout << "(";
    1348         [ #  # ]:          0 :         for( unsigned int i = 0; i < entity->nodeCt; i++ )
    1349                 :            :         {
    1350 [ #  # ][ #  # ]:          0 :             std::cout << uint_buf[i];
    1351 [ #  # ][ #  # ]:          0 :             if( i != entity->nodeCt - 1 ) std::cout << ", ";
    1352                 :            :         }
    1353         [ #  # ]:          0 :         std::cout << ")...";
    1354                 :            :     }
    1355                 :            : 
    1356                 :            :     // Get a space for reading nodal data directly into MB, and read that data
    1357                 :          0 :     EntityHandle vhandle = 0;
    1358         [ #  # ]:          0 :     std::vector< double* > arrays;
    1359         [ #  # ]:          0 :     readUtilIface->get_node_coords( 3, entity->nodeCt, uint_buf[0], vhandle, arrays,
    1360         [ #  # ]:          0 :                                     SequenceManager::DEFAULT_VERTEX_SEQUENCE_SIZE );
    1361                 :            : 
    1362                 :            :     // Get node x's in arrays[0]
    1363 [ #  # ][ #  # ]:          0 :     FREADDA( entity->nodeCt, arrays[0] );
    1364                 :            :     // Get node y's in arrays[1]
    1365 [ #  # ][ #  # ]:          0 :     FREADDA( entity->nodeCt, arrays[1] );
    1366                 :            :     // Get node z's in arrays[2]
    1367 [ #  # ][ #  # ]:          0 :     FREADDA( entity->nodeCt, arrays[2] );
    1368                 :            : 
    1369                 :            :     // Add these nodes into the entity's set
    1370         [ #  # ]:          0 :     Range dum_range( vhandle, vhandle + entity->nodeCt - 1 );
    1371         [ #  # ]:          0 :     ErrorCode result = mdbImpl->add_entities( entity->setHandle, dum_range );
    1372         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1373                 :            : 
    1374                 :            :     // Check for id contiguity; know that cid's will never be > 32bit, so
    1375                 :            :     // ids can be unsigned int
    1376                 :            :     unsigned int max_cid, min_cid;
    1377                 :            :     int contig;
    1378         [ #  # ]:          0 :     check_contiguous( entity->nodeCt, contig, min_cid, max_cid );
    1379                 :            : 
    1380                 :            :     // Compute the offset we get in this batch and compare to any previous one
    1381                 :          0 :     long vhandle_offset = vhandle - min_cid;
    1382         [ #  # ]:          0 :     if( -1 == currVHandleOffset ) currVHandleOffset = vhandle_offset;
    1383                 :            : 
    1384                 :            :     // In 2 situations we'll need to add/modify a cubit_id -> vhandle map:
    1385                 :            :     // case A: no map yet, and either this offset different from
    1386                 :            :     // previous or not contiguous
    1387 [ #  # ][ #  # ]:          0 :     if( !cubMOABVertexMap && ( currVHandleOffset != vhandle_offset || !contig ) )
                 [ #  # ]
    1388                 :            :     {
    1389                 :            :         // Get all vertices, removing ones in this batch
    1390 [ #  # ][ #  # ]:          0 :         Range vrange, tmp_range( dum_range );
                 [ #  # ]
    1391 [ #  # ][ #  # ]:          0 :         result = mdbImpl->get_entities_by_type( 0, MBVERTEX, vrange );RR;
    1392 [ #  # ][ #  # ]:          0 :         if( !beforeEnts.empty() ) tmp_range.merge( beforeEnts.subset_by_type( MBVERTEX ) );
         [ #  # ][ #  # ]
    1393 [ #  # ][ #  # ]:          0 :         vrange = subtract( vrange, tmp_range );
    1394                 :            :         // Compute the max cid; map is indexed by cid, so size is max_cid + 1
    1395                 :            : #define MAX( a, b ) ( a > b ? a : b )
    1396                 :            : #define MIN( a, b ) ( a < b ? a : b )
    1397                 :            :         // Sanity check that max vhandle is larger than offset
    1398 [ #  # ][ #  # ]:          0 :         long new_max = *vrange.rbegin() - currVHandleOffset;
    1399 [ #  # ][ #  # ]:          0 :         assert( new_max >= 0 && ( (long)*vrange.begin() ) - currVHandleOffset >= 0 );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1400                 :          0 :         max_cid          = MAX( max_cid, ( (unsigned int)new_max ) );
    1401 [ #  # ][ #  # ]:          0 :         cubMOABVertexMap = new std::vector< EntityHandle >( max_cid + 1 );
    1402                 :            :         // Initialize to zero then put previous vertices into the map
    1403         [ #  # ]:          0 :         std::fill( cubMOABVertexMap->begin(), cubMOABVertexMap->end(), 0 );
    1404         [ #  # ]:          0 :         Range::iterator rit;
    1405 [ #  # ][ #  # ]:          0 :         for( rit = vrange.begin(); rit != vrange.end(); ++rit )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1406                 :            :         {
    1407 [ #  # ][ #  # ]:          0 :             assert( ( (long)*rit ) - currVHandleOffset >= 0 && ( (long)*rit ) - currVHandleOffset <= max_cid );
         [ #  # ][ #  # ]
    1408 [ #  # ][ #  # ]:          0 :             ( *cubMOABVertexMap )[*rit - currVHandleOffset] = *rit;
                 [ #  # ]
    1409                 :          0 :         }
    1410                 :            :     }
    1411                 :            :     // case B: there is a map and we need to resize it
    1412 [ #  # ][ #  # ]:          0 :     else if( cubMOABVertexMap && max_cid + 1 > cubMOABVertexMap->size() )
                 [ #  # ]
    1413                 :            :     {
    1414                 :          0 :         unsigned int old_size = cubMOABVertexMap->size();
    1415         [ #  # ]:          0 :         cubMOABVertexMap->resize( max_cid + 1 );
    1416 [ #  # ][ #  # ]:          0 :         std::fill( &( *cubMOABVertexMap )[old_size], &( *cubMOABVertexMap )[0] + cubMOABVertexMap->size(), 0 );
                 [ #  # ]
    1417                 :            :     }
    1418                 :            : 
    1419                 :            :     // OK, we have a map or don't need one
    1420         [ #  # ]:          0 :     if( NULL == cubMOABVertexMap )
    1421                 :            :     {
    1422                 :            :         // If we're not forward-contiguous (i.e. we're reverse or
    1423                 :            :         // out-of-order contiguous), re-order coordinates for handles
    1424                 :            :         // so that they are
    1425 [ #  # ][ #  # ]:          0 :         if( -1 == contig || -2 == contig )
    1426                 :            :         {
    1427                 :            :             // In case the arrays are large, do each coord separately
    1428         [ #  # ]:          0 :             std::vector< double > tmp_coords( entity->nodeCt );
    1429         [ #  # ]:          0 :             for( unsigned int j = 0; j < 3; j++ )
    1430                 :            :             {
    1431                 :            :                 // Permute the coords into new order
    1432         [ #  # ]:          0 :                 for( unsigned int i = 0; i < entity->nodeCt; i++ )
    1433                 :            :                 {
    1434 [ #  # ][ #  # ]:          0 :                     assert( uint_buf[i] >= min_cid && max_cid - uint_buf[i] < entity->nodeCt );
         [ #  # ][ #  # ]
    1435 [ #  # ][ #  # ]:          0 :                     tmp_coords[uint_buf[i] - min_cid] = arrays[j][i];
                 [ #  # ]
    1436                 :            :                 }
    1437                 :            :                 // Copy the permuted to storage
    1438 [ #  # ][ #  # ]:          0 :                 std::copy( &tmp_coords[0], &tmp_coords[0] + entity->nodeCt, arrays[j] );
         [ #  # ][ #  # ]
    1439                 :            :             }
    1440                 :            :             // Now re-order the ids; either way just go off min, max cid
    1441         [ #  # ]:          0 :             for( unsigned int i = 0; i < entity->nodeCt; i++ )
    1442         [ #  # ]:          0 :                 uint_buf[i] = min_cid + i;
    1443                 :            :         }
    1444         [ #  # ]:          0 :         else if( !contig )
    1445                 :            :             // Shouldn't get here, since in non-contiguous case map should be there
    1446                 :          0 :             assert( false );
    1447                 :            :     }
    1448                 :            :     else
    1449                 :            :     {
    1450                 :            :         // Put new vertices into the map
    1451                 :            :         // Now set the new values
    1452         [ #  # ]:          0 :         unsigned int* vit   = &uint_buf[0];
    1453         [ #  # ]:          0 :         Range::iterator rit = dum_range.begin();
    1454 [ #  # ][ #  # ]:          0 :         for( ; rit != dum_range.end(); vit++, ++rit )
         [ #  # ][ #  # ]
    1455                 :            :         {
    1456         [ #  # ]:          0 :             assert( *vit < cubMOABVertexMap->size() );
    1457 [ #  # ][ #  # ]:          0 :             ( *cubMOABVertexMap )[*vit] = *rit;
    1458                 :            :         }
    1459                 :            :     }
    1460                 :            : 
    1461                 :            :     // No longer need to use uint_buf; convert in-place to ints, so we
    1462                 :            :     // can assign gid tag
    1463         [ #  # ]:          0 :     CONVERT_TO_INTS( entity->nodeCt );
    1464         [ #  # ]:          0 :     result = mdbImpl->tag_set_data( globalIdTag, dum_range, &int_buf[0] );
    1465         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1466                 :            : 
    1467                 :            :     // Set the dimension to at least zero (entity has at least nodes) on the geom tag
    1468                 :          0 :     int max_dim = 0;
    1469         [ #  # ]:          0 :     result      = mdbImpl->tag_set_data( geomTag, &( entity->setHandle ), 1, &max_dim );
    1470         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1471                 :            :     // Set the category tag just in case there're only vertices in this set
    1472         [ #  # ]:          0 :     result = mdbImpl->tag_set_data( categoryTag, &entity->setHandle, 1, &geom_categories[0] );
    1473         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1474                 :            : 
    1475                 :            :     // Get fixed node data and assign
    1476 [ #  # ][ #  # ]:          0 :     int md_index = model->nodeMD.get_md_entry( gindex, "FixedNodes" );
    1477         [ #  # ]:          0 :     if( -1 == md_index ) return MB_SUCCESS;
    1478         [ #  # ]:          0 :     MetaDataContainer::MetaDataEntry* md_entry = &( model->nodeMD.metadataEntries[md_index] );
    1479                 :            : 
    1480         [ #  # ]:          0 :     std::vector< int > fixed_flags( entity->nodeCt );
    1481         [ #  # ]:          0 :     std::fill( fixed_flags.begin(), fixed_flags.end(), 0 );
    1482         [ #  # ]:          0 :     if( md_entry->mdDataType != 3 ) return MB_FAILURE;
    1483                 :            : 
    1484   [ #  #  #  # ]:          0 :     for( std::vector< unsigned int >::iterator vit = md_entry->mdIntArrayValue.begin();
                 [ #  # ]
    1485                 :          0 :          vit != md_entry->mdIntArrayValue.end(); ++vit )
    1486                 :            :     {
    1487                 :            : #ifndef NDEBUG
    1488                 :            :         EntityHandle fixed_v =
    1489 [ #  # ][ #  # ]:          0 :             ( cubMOABVertexMap ? ( *cubMOABVertexMap )[*vit] : (EntityHandle)currVHandleOffset + *vit );
         [ #  # ][ #  # ]
    1490 [ #  # ][ #  # ]:          0 :         assert( fixed_v >= *dum_range.begin() && fixed_v <= *dum_range.rbegin() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1491                 :            : #endif
    1492 [ #  # ][ #  # ]:          0 :         fixed_flags[*vit - *dum_range.begin()] = 1;
         [ #  # ][ #  # ]
    1493                 :            :     }
    1494                 :            : 
    1495                 :            :     Tag fixedFlagTag;
    1496                 :          0 :     int dum_val = 0;
    1497                 :            :     result      = mdbImpl->tag_get_handle( "NodeFixed", 1, MB_TYPE_INTEGER, fixedFlagTag, MB_TAG_SPARSE | MB_TAG_CREAT,
    1498         [ #  # ]:          0 :                                       &dum_val );
    1499         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1500 [ #  # ][ #  # ]:          0 :     result = mdbImpl->tag_set_data( fixedFlagTag, dum_range, &fixed_flags[0] );
    1501                 :            : 
    1502                 :          0 :     return result;
    1503                 :            : }
    1504                 :            : 
    1505                 :          0 : ErrorCode Tqdcfr::read_elements( Tqdcfr::ModelEntry* model, Tqdcfr::GeomHeader* entity )
    1506                 :            : {
    1507         [ #  # ]:          0 :     if( entity->elemTypeCt == 0 ) return MB_SUCCESS;
    1508                 :            :     const int in_order_map[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10, 11, 12, 13,
    1509                 :          0 :                                  14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27 };
    1510                 :            : 
    1511                 :            :     // Get data in separate calls to minimize memory usage
    1512                 :            :     // Position the file
    1513         [ #  # ]:          0 :     FSEEK( model->modelOffset + entity->elemOffset );
    1514                 :            : 
    1515                 :            :     int int_type, nodes_per_elem, num_elem;
    1516                 :          0 :     int max_dim = -1;
    1517                 :            :     ErrorCode result;
    1518         [ #  # ]:          0 :     for( unsigned int i = 0; i < entity->elemTypeCt; i++ )
    1519                 :            :     {
    1520                 :            :         // For this elem type, get the type, nodes per elem, num elems
    1521         [ #  # ]:          0 :         FREADI( 3 );
    1522         [ #  # ]:          0 :         int_type       = uint_buf[0];
    1523         [ #  # ]:          0 :         nodes_per_elem = uint_buf[1];
    1524         [ #  # ]:          0 :         num_elem       = uint_buf[2];
    1525                 :            : 
    1526                 :            :         // Get MB element type from cub file's
    1527                 :          0 :         EntityType elem_type = mp_type_to_mb_type[int_type];
    1528 [ #  # ][ #  # ]:          0 :         max_dim              = ( max_dim < CN::Dimension( elem_type ) ? CN::Dimension( elem_type ) : max_dim );
                 [ #  # ]
    1529                 :            : 
    1530 [ #  # ][ #  # ]:          0 :         if( debug ) std::cout << "type " << CN::EntityTypeName( elem_type ) << ":";
         [ #  # ][ #  # ]
                 [ #  # ]
    1531                 :            : 
    1532                 :          0 :         const int* node_order = cub_elem_order_map[elem_type][nodes_per_elem];
    1533         [ #  # ]:          0 :         if( !node_order ) node_order = in_order_map;
    1534                 :            : 
    1535                 :            :         // Get element ids
    1536         [ #  # ]:          0 :         FREADI( num_elem );
    1537                 :            : 
    1538                 :            :         // Check to see if ids are contiguous...
    1539                 :            :         int contig;
    1540                 :            :         unsigned int max_id, min_id;
    1541         [ #  # ]:          0 :         check_contiguous( num_elem, contig, min_id, max_id );
    1542 [ #  # ][ #  # ]:          0 :         if( 0 == contig && !printedElemWarning )
    1543                 :            :         {
    1544 [ #  # ][ #  # ]:          0 :             std::cout << "Element ids are not contiguous!" << std::endl;
    1545                 :          0 :             printedElemWarning = true;
    1546                 :            :         }
    1547                 :            : 
    1548                 :            :         // Get a space for reading connectivity data directly into MB
    1549                 :            :         EntityHandle *conn, start_handle;
    1550                 :            : 
    1551                 :          0 :         result = readUtilIface->get_element_connect( num_elem, nodes_per_elem, elem_type, int_buf[0], start_handle,
    1552         [ #  # ]:          0 :                                                      conn, SequenceManager::DEFAULT_ELEMENT_SEQUENCE_SIZE );
    1553         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1554                 :            : 
    1555         [ #  # ]:          0 :         Range dum_range( start_handle, start_handle + num_elem - 1 );
    1556                 :            : 
    1557                 :            :         long elem_offset;
    1558         [ #  # ]:          0 :         elem_offset = ( 1 == contig ? start_handle - int_buf[0] : int_buf[num_elem - 1] );
    1559         [ #  # ]:          0 :         if( -1 == currElementIdOffset[elem_type] ) currElementIdOffset[elem_type] = elem_offset;
    1560                 :            : 
    1561                 :            :         // Set the gids on elements
    1562         [ #  # ]:          0 :         CONVERT_TO_INTS( num_elem );
    1563         [ #  # ]:          0 :         result = mdbImpl->tag_set_data( globalIdTag, dum_range, &int_buf[0] );
    1564         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1565                 :            : 
    1566                 :            :         // Get the connectivity array
    1567                 :          0 :         unsigned int total_conn = num_elem * nodes_per_elem;
    1568 [ #  # ][ #  # ]:          0 :         if( major >= 14 ) FREADI( num_elem );  // We need to skip num_elem in advance, it looks like
    1569         [ #  # ]:          0 :         FREADI( total_conn );
    1570                 :            : 
    1571                 :            :         // Post-process connectivity into handles
    1572                 :            :         EntityHandle new_handle;
    1573                 :          0 :         int j = 0;
    1574         [ #  # ]:          0 :         for( int e = 0; e < num_elem; ++e )
    1575                 :            :         {
    1576         [ #  # ]:          0 :             for( int k = 0; k < nodes_per_elem; ++k, ++j )
    1577                 :            :             {
    1578         [ #  # ]:          0 :                 if( debug )
    1579                 :            :                 {
    1580 [ #  # ][ #  # ]:          0 :                     if( 0 == j ) std::cout << "Conn=";
    1581 [ #  # ][ #  # ]:          0 :                     std::cout << ", " << uint_buf[j];
                 [ #  # ]
    1582                 :            :                 }
    1583         [ #  # ]:          0 :                 if( NULL == cubMOABVertexMap )
    1584         [ #  # ]:          0 :                     new_handle = (EntityHandle)currVHandleOffset + uint_buf[j];
    1585                 :            :                 else
    1586                 :            :                 {
    1587 [ #  # ][ #  # ]:          0 :                     assert( uint_buf[j] < cubMOABVertexMap->size() && 0 != ( *cubMOABVertexMap )[uint_buf[j]] );
         [ #  # ][ #  # ]
                 [ #  # ]
    1588 [ #  # ][ #  # ]:          0 :                     new_handle = ( *cubMOABVertexMap )[uint_buf[j]];
    1589                 :            :                 }
    1590                 :            : #ifndef NDEBUG
    1591                 :            :                 EntityHandle dum_handle;
    1592 [ #  # ][ #  # ]:          0 :                 assert( MB_SUCCESS ==
    1593         [ #  # ]:          0 :                         mdbImpl->handle_from_id( MBVERTEX, mdbImpl->id_from_handle( new_handle ), dum_handle ) );
    1594                 :            : #endif
    1595                 :          0 :                 conn[e * nodes_per_elem + node_order[k]] = new_handle;
    1596                 :            :             }
    1597                 :            :         }
    1598                 :            : 
    1599                 :            :         // Add these elements into the entity's set
    1600         [ #  # ]:          0 :         result = mdbImpl->add_entities( entity->setHandle, dum_range );
    1601         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1602                 :            : 
    1603                 :            :         // Notify MOAB of the new elements
    1604         [ #  # ]:          0 :         result = readUtilIface->update_adjacencies( start_handle, num_elem, nodes_per_elem, conn );
    1605 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1606                 :          0 :     }
    1607                 :            : 
    1608                 :            :     // Set the dimension on the geom tag
    1609         [ #  # ]:          0 :     result = mdbImpl->tag_set_data( geomTag, &entity->setHandle, 1, &max_dim );
    1610         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    1611         [ #  # ]:          0 :     if( max_dim != -1 )
    1612                 :            :     {
    1613         [ #  # ]:          0 :         result = mdbImpl->tag_set_data( categoryTag, &entity->setHandle, 1, &geom_categories[max_dim] );
    1614         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1615                 :            :     }
    1616                 :            : 
    1617                 :          0 :     return MB_SUCCESS;
    1618                 :            : }
    1619                 :            : 
    1620                 :          0 : void Tqdcfr::check_contiguous( const unsigned int num_ents, int& contig, unsigned int& min_id, unsigned int& max_id )
    1621                 :            : {
    1622                 :            :     unsigned int *id_it, curr_id, i;
    1623                 :            : 
    1624                 :            :     // Check in forward-contiguous direction
    1625                 :          0 :     id_it   = &uint_buf[0];
    1626                 :          0 :     curr_id = *id_it++ + 1;
    1627                 :          0 :     contig  = 1;
    1628                 :          0 :     min_id  = uint_buf[0];
    1629                 :          0 :     max_id  = uint_buf[0];
    1630         [ #  # ]:          0 :     for( i = 1; i < num_ents; id_it++, i++, curr_id++ )
    1631                 :            :     {
    1632         [ #  # ]:          0 :         if( *id_it != curr_id ) { contig = 0; }
    1633         [ #  # ]:          0 :         min_id = MIN( min_id, uint_buf[i] );
    1634         [ #  # ]:          0 :         max_id = MAX( max_id, uint_buf[i] );
    1635                 :            :     }
    1636                 :            : 
    1637                 :            :     // If we got here and we're at the end of the loop, it's forward-contiguous
    1638         [ #  # ]:          0 :     if( 1 == contig ) return;
    1639                 :            : 
    1640                 :            :     // Check in reverse-contiguous direction
    1641                 :          0 :     contig  = -1;
    1642                 :          0 :     id_it   = &uint_buf[0];
    1643                 :          0 :     curr_id = *id_it++ - 1;
    1644         [ #  # ]:          0 :     for( i = 1; i < num_ents; id_it++, i++, curr_id-- )
    1645                 :            :     {
    1646         [ #  # ]:          0 :         if( *id_it != curr_id )
    1647                 :            :         {
    1648                 :          0 :             contig = 0;
    1649                 :          0 :             break;
    1650                 :            :         }
    1651                 :            :     }
    1652                 :            : 
    1653                 :            :     // If we got here and we're at the end of the loop, it's reverse-contiguous
    1654         [ #  # ]:          0 :     if( -1 == contig ) return;
    1655                 :            : 
    1656                 :            :     // One final check, for contiguous but out of order
    1657         [ #  # ]:          0 :     if( max_id - min_id + 1 == num_ents ) contig = -2;
    1658                 :            : 
    1659                 :            :     // Else it's not contiguous at all
    1660                 :          0 :     contig = 0;
    1661                 :            : }
    1662                 :            : 
    1663                 :          0 : void Tqdcfr::FEModelHeader::init( const unsigned int offset, Tqdcfr* instance )
    1664                 :            : {
    1665                 :          0 :     instance->FSEEK( offset );
    1666                 :          0 :     instance->FREADI( 4 );
    1667                 :          0 :     feEndian       = instance->uint_buf[0];
    1668                 :          0 :     feSchema       = instance->uint_buf[1];
    1669                 :          0 :     feCompressFlag = instance->uint_buf[2];
    1670                 :          0 :     feLength       = instance->uint_buf[3];
    1671                 :          0 :     instance->FREADI( 3 );
    1672                 :          0 :     geomArray.init( instance->uint_buf );
    1673                 :          0 :     instance->FREADI( 2 );
    1674                 :          0 :     nodeArray.metaDataOffset    = instance->uint_buf[0];
    1675                 :          0 :     elementArray.metaDataOffset = instance->uint_buf[1];
    1676                 :          0 :     instance->FREADI( 3 );
    1677                 :          0 :     groupArray.init( instance->uint_buf );
    1678                 :          0 :     instance->FREADI( 3 );
    1679                 :          0 :     blockArray.init( instance->uint_buf );
    1680                 :          0 :     instance->FREADI( 3 );
    1681                 :          0 :     nodesetArray.init( instance->uint_buf );
    1682                 :          0 :     instance->FREADI( 3 );
    1683                 :          0 :     sidesetArray.init( instance->uint_buf );
    1684                 :          0 :     instance->FREADI( 1 );
    1685                 :          0 : }
    1686                 :            : 
    1687                 :          0 : ErrorCode Tqdcfr::read_file_header()
    1688                 :            : {
    1689                 :            :     // Read file header
    1690                 :          0 :     FSEEK( 4 );
    1691                 :            :     // Read the first int from the file
    1692                 :            :     // If it is 0, it is littleEndian
    1693                 :          0 :     unsigned rval = fread( &fileTOC.fileEndian, sizeof( unsigned int ), 1, cubFile );
    1694                 :          0 :     IO_ASSERT( rval == 1 );
    1695                 :            : #ifdef WORDS_BIGENDIAN
    1696                 :            :     if( fileTOC.fileEndian == 0 ) swapForEndianness = true;
    1697                 :            : #else
    1698         [ #  # ]:          0 :     if( fileTOC.fileEndian != 0 ) swapForEndianness = true;
    1699                 :            : #endif
    1700         [ #  # ]:          0 :     if( debug ) std::cout << " swapping ? " << swapForEndianness << "\n";
    1701                 :          0 :     FREADI( 5 );
    1702                 :            :     // fileTOC.fileEndian = uint_buf[0];
    1703                 :          0 :     fileTOC.fileSchema          = uint_buf[0];
    1704                 :          0 :     fileTOC.numModels           = uint_buf[1];
    1705                 :          0 :     fileTOC.modelTableOffset    = uint_buf[2];
    1706                 :          0 :     fileTOC.modelMetaDataOffset = uint_buf[3];
    1707                 :          0 :     fileTOC.activeFEModel       = uint_buf[4];
    1708         [ #  # ]:          0 :     if( debug ) fileTOC.print();
    1709                 :            : 
    1710                 :          0 :     return MB_SUCCESS;
    1711                 :            : }
    1712                 :            : 
    1713                 :          0 : ErrorCode Tqdcfr::read_model_entries()
    1714                 :            : {
    1715                 :            :     // Read model entries
    1716         [ #  # ]:          0 :     FSEEK( fileTOC.modelTableOffset );
    1717         [ #  # ]:          0 :     FREADI( fileTOC.numModels * 6 );
    1718         [ #  # ]:          0 :     modelEntries.resize( fileTOC.numModels );
    1719         [ #  # ]:          0 :     if( modelEntries.empty() ) return MB_FAILURE;
    1720                 :          0 :     std::vector< unsigned int >::iterator int_it = uint_buf.begin();
    1721         [ #  # ]:          0 :     for( unsigned int i = 0; i < fileTOC.numModels; i++ )
    1722                 :            :     {
    1723 [ #  # ][ #  # ]:          0 :         modelEntries[i].modelHandle = *int_it++;
                 [ #  # ]
    1724 [ #  # ][ #  # ]:          0 :         modelEntries[i].modelOffset = *int_it++;
                 [ #  # ]
    1725 [ #  # ][ #  # ]:          0 :         modelEntries[i].modelLength = *int_it++;
                 [ #  # ]
    1726 [ #  # ][ #  # ]:          0 :         modelEntries[i].modelType   = *int_it++;
                 [ #  # ]
    1727 [ #  # ][ #  # ]:          0 :         modelEntries[i].modelOwner  = *int_it++;
                 [ #  # ]
    1728 [ #  # ][ #  # ]:          0 :         modelEntries[i].modelPad    = *int_it++;
                 [ #  # ]
    1729 [ #  # ][ #  # ]:          0 :         if( int_it == uint_buf.end() && i != fileTOC.numModels - 1 ) return MB_FAILURE;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1730 [ #  # ][ #  # ]:          0 :         if( debug ) modelEntries[i].print();
                 [ #  # ]
    1731                 :            :     }
    1732                 :            : 
    1733                 :          0 :     return MB_SUCCESS;
    1734                 :            : }
    1735                 :            : 
    1736                 :          0 : int Tqdcfr::find_model( const unsigned int model_type )
    1737                 :            : {
    1738         [ #  # ]:          0 :     for( unsigned int i = 0; i < fileTOC.numModels; i++ )
    1739                 :            :     {
    1740         [ #  # ]:          0 :         if( modelEntries[i].modelType == model_type ) return i;
    1741                 :            :     }
    1742                 :            : 
    1743                 :          0 :     return -1;
    1744                 :            : }
    1745                 :            : 
    1746                 :          0 : ErrorCode Tqdcfr::read_meta_data( const unsigned int metadata_offset, Tqdcfr::MetaDataContainer& mc )
    1747                 :            : {
    1748                 :            :     // Read the metadata header
    1749                 :          0 :     FSEEK( metadata_offset );
    1750                 :          0 :     FREADI( 3 );
    1751                 :          0 :     mc.mdSchema     = uint_buf[0];
    1752                 :          0 :     mc.compressFlag = uint_buf[1];
    1753                 :            : 
    1754                 :            :     // Allocate space for the entries
    1755                 :          0 :     mc.metadataEntries.resize( uint_buf[2] );
    1756                 :            : 
    1757                 :            :     // Now read the metadata values
    1758         [ #  # ]:          0 :     for( unsigned int i = 0; i < mc.metadataEntries.size(); i++ )
    1759                 :            :     {
    1760                 :          0 :         FREADI( 2 );
    1761                 :          0 :         mc.metadataEntries[i].mdOwner    = uint_buf[0];
    1762                 :          0 :         mc.metadataEntries[i].mdDataType = uint_buf[1];
    1763                 :            : 
    1764                 :            :         // Read the name string
    1765                 :          0 :         read_md_string( mc.metadataEntries[i].mdName );
    1766                 :            : 
    1767         [ #  # ]:          0 :         if( mc.metadataEntries[i].mdDataType == 0 )
    1768                 :            :         {
    1769                 :            :             // integer
    1770                 :          0 :             FREADI( 1 );
    1771                 :          0 :             mc.metadataEntries[i].mdIntValue = uint_buf[0];
    1772                 :            :         }
    1773         [ #  # ]:          0 :         else if( mc.metadataEntries[i].mdDataType == 1 )
    1774                 :            :         {
    1775                 :            :             // string
    1776                 :          0 :             read_md_string( mc.metadataEntries[i].mdStringValue );
    1777                 :            :         }
    1778         [ #  # ]:          0 :         else if( mc.metadataEntries[i].mdDataType == 2 )
    1779                 :            :         {
    1780                 :            :             // double
    1781                 :          0 :             FREADD( 1 );
    1782                 :          0 :             mc.metadataEntries[i].mdDblValue = dbl_buf[0];
    1783                 :            :         }
    1784         [ #  # ]:          0 :         else if( mc.metadataEntries[i].mdDataType == 3 )
    1785                 :            :         {
    1786                 :            :             // int array
    1787                 :          0 :             FREADI( 1 );
    1788                 :          0 :             mc.metadataEntries[i].mdIntArrayValue.resize( uint_buf[0] );
    1789                 :          0 :             FREADI( mc.metadataEntries[i].mdIntArrayValue.size() );
    1790                 :          0 :             std::copy( uint_buf.begin(), uint_buf.begin() + mc.metadataEntries[i].mdIntArrayValue.size(),
    1791 [ #  # ][ #  # ]:          0 :                        mc.metadataEntries[i].mdIntArrayValue.begin() );
    1792                 :            :         }
    1793         [ #  # ]:          0 :         else if( mc.metadataEntries[i].mdDataType == 4 )
    1794                 :            :         {
    1795                 :            :             // double array
    1796                 :          0 :             FREADI( 1 );
    1797                 :          0 :             mc.metadataEntries[i].mdDblArrayValue.resize( uint_buf[0] );
    1798                 :          0 :             FREADD( mc.metadataEntries[i].mdDblArrayValue.size() );
    1799                 :          0 :             std::copy( dbl_buf.begin(), dbl_buf.begin() + mc.metadataEntries[i].mdDblArrayValue.size(),
    1800 [ #  # ][ #  # ]:          0 :                        mc.metadataEntries[i].mdDblArrayValue.begin() );
    1801                 :            :         }
    1802                 :            :         else
    1803                 :          0 :             return MB_FAILURE;
    1804                 :            :     }
    1805         [ #  # ]:          0 :     if( debug ) mc.print();
    1806                 :            : 
    1807                 :          0 :     return MB_SUCCESS;
    1808                 :            : }
    1809                 :            : 
    1810                 :          0 : ErrorCode Tqdcfr::read_md_string( std::string& name )
    1811                 :            : {
    1812                 :          0 :     FREADI( 1 );
    1813                 :          0 :     int str_size = uint_buf[0];
    1814         [ #  # ]:          0 :     if( str_size > 0 )
    1815                 :            :     {
    1816                 :          0 :         FREADC( str_size );
    1817         [ #  # ]:          0 :         if( char_buf.size() <= (unsigned int)str_size ) char_buf.resize( str_size + 1 );
    1818                 :          0 :         char_buf[str_size] = '\0';
    1819                 :          0 :         name               = (char*)&char_buf[0];
    1820                 :            :         // Read pad if any
    1821                 :          0 :         int extra = str_size % sizeof( int );
    1822         [ #  # ]:          0 :         if( extra )
    1823                 :            :         {
    1824                 :            :             // Read extra chars to end of pad
    1825                 :          0 :             str_size = sizeof( int ) - extra;
    1826                 :          0 :             FREADC( str_size );
    1827                 :            :         }
    1828                 :            :     }
    1829                 :            : 
    1830                 :          0 :     return MB_SUCCESS;
    1831                 :            : }
    1832                 :            : 
    1833                 :          0 : ErrorCode Tqdcfr::GeomHeader::read_info_header( const unsigned int model_offset,
    1834                 :            :                                                 const Tqdcfr::FEModelHeader::ArrayInfo& info, Tqdcfr* instance,
    1835                 :            :                                                 Tqdcfr::GeomHeader*& geom_headers )
    1836                 :            : {
    1837 [ #  # ][ #  # ]:          0 :     geom_headers = new GeomHeader[info.numEntities];
         [ #  # ][ #  # ]
    1838         [ #  # ]:          0 :     instance->FSEEK( model_offset + info.tableOffset );
    1839                 :            :     int dum_int;
    1840                 :            :     ErrorCode result;
    1841                 :            : 
    1842         [ #  # ]:          0 :     if( 0 == instance->categoryTag )
    1843                 :            :     {
    1844                 :            :         static const char val[CATEGORY_TAG_SIZE] = { 0 };
    1845                 :            :         result = instance->mdbImpl->tag_get_handle( CATEGORY_TAG_NAME, CATEGORY_TAG_SIZE, MB_TYPE_OPAQUE,
    1846         [ #  # ]:          0 :                                                     instance->categoryTag, MB_TAG_SPARSE | MB_TAG_CREAT, val );
    1847         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1848                 :            :     }
    1849                 :            : 
    1850         [ #  # ]:          0 :     for( unsigned int i = 0; i < info.numEntities; i++ )
    1851                 :            :     {
    1852         [ #  # ]:          0 :         instance->FREADI( 8 );
    1853         [ #  # ]:          0 :         geom_headers[i].nodeCt     = instance->uint_buf[0];
    1854         [ #  # ]:          0 :         geom_headers[i].nodeOffset = instance->uint_buf[1];
    1855         [ #  # ]:          0 :         geom_headers[i].elemCt     = instance->uint_buf[2];
    1856         [ #  # ]:          0 :         geom_headers[i].elemOffset = instance->uint_buf[3];
    1857         [ #  # ]:          0 :         geom_headers[i].elemTypeCt = instance->uint_buf[4];
    1858         [ #  # ]:          0 :         geom_headers[i].elemLength = instance->uint_buf[5];
    1859         [ #  # ]:          0 :         geom_headers[i].geomID     = instance->uint_buf[6];
    1860                 :            : 
    1861                 :            :         // Don't represent in MOAB if no mesh
    1862 [ #  # ][ #  # ]:          0 :         if( geom_headers[i].nodeCt == 0 && geom_headers[i].elemCt == 0 ) continue;
    1863                 :            : 
    1864                 :            :         // Create an entity set for this entity
    1865         [ #  # ]:          0 :         result = instance->create_set( geom_headers[i].setHandle );
    1866         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1867                 :            : 
    1868                 :            :         // Set the dimension to -1; will have to reset later, after elements are read
    1869                 :          0 :         dum_int = -1;
    1870         [ #  # ]:          0 :         result  = instance->mdbImpl->tag_set_data( instance->geomTag, &( geom_headers[i].setHandle ), 1, &dum_int );
    1871         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1872                 :            : 
    1873                 :            :         // Set a unique id tag
    1874                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->uniqueIdTag, &( geom_headers[i].setHandle ), 1,
    1875         [ #  # ]:          0 :                                                   &( geom_headers[i].geomID ) );
    1876         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1877                 :            : 
    1878                 :            :         // Put the set and uid into a map for later
    1879         [ #  # ]:          0 :         instance->uidSetMap[geom_headers[i].geomID] = geom_headers[i].setHandle;
    1880                 :            :     }
    1881                 :            : 
    1882                 :            :     // Now get the dimensions of elements for each geom entity
    1883         [ #  # ]:          0 :     for( unsigned int i = 0; i < info.numEntities; i++ )
    1884                 :            :     {
    1885         [ #  # ]:          0 :         if( geom_headers[i].elemTypeCt == 0 ) continue;
    1886         [ #  # ]:          0 :         instance->FSEEK( model_offset + geom_headers[i].elemOffset );
    1887         [ #  # ]:          0 :         for( unsigned int j = 0; j < geom_headers[i].elemTypeCt; j++ )
    1888                 :            :         {
    1889                 :            :             // For this elem type, get the type, nodes per elem, num elems
    1890         [ #  # ]:          0 :             instance->FREADI( 3 );
    1891         [ #  # ]:          0 :             int int_type           = instance->uint_buf[0];
    1892         [ #  # ]:          0 :             int nodes_per_elem     = instance->uint_buf[1];
    1893         [ #  # ]:          0 :             int num_elem           = instance->uint_buf[2];
    1894                 :          0 :             EntityType elem_type   = mp_type_to_mb_type[int_type];
    1895 [ #  # ][ #  # ]:          0 :             geom_headers[i].maxDim = std::max( geom_headers[i].maxDim, (int)CN::Dimension( elem_type ) );
    1896         [ #  # ]:          0 :             if( j < geom_headers[i].elemTypeCt - 1 )
    1897                 :            :             {
    1898                 :          0 :                 int num_skipped_ints = num_elem + num_elem * nodes_per_elem;
    1899         [ #  # ]:          0 :                 if( major >= 14 ) num_skipped_ints += num_elem;
    1900         [ #  # ]:          0 :                 instance->FREADI( num_skipped_ints );
    1901                 :            :             }
    1902                 :            :         }
    1903                 :            :     }
    1904                 :            : 
    1905                 :          0 :     return MB_SUCCESS;
    1906                 :            : }
    1907                 :            : 
    1908                 :          0 : ErrorCode Tqdcfr::GroupHeader::read_info_header( const unsigned int model_offset,
    1909                 :            :                                                  const Tqdcfr::FEModelHeader::ArrayInfo& info, Tqdcfr* instance,
    1910                 :            :                                                  Tqdcfr::GroupHeader*& group_headers )
    1911                 :            : {
    1912 [ #  # ][ #  # ]:          0 :     group_headers = new GroupHeader[info.numEntities];
                 [ #  # ]
    1913                 :          0 :     instance->FSEEK( model_offset + info.tableOffset );
    1914                 :            :     ErrorCode result;
    1915                 :            : 
    1916         [ #  # ]:          0 :     if( 0 == instance->categoryTag )
    1917                 :            :     {
    1918                 :            :         static const char val[CATEGORY_TAG_SIZE] = { 0 };
    1919                 :            :         result = instance->mdbImpl->tag_get_handle( CATEGORY_TAG_NAME, CATEGORY_TAG_SIZE, MB_TYPE_OPAQUE,
    1920                 :          0 :                                                     instance->categoryTag, MB_TAG_SPARSE | MB_TAG_CREAT, val );
    1921         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1922                 :            :     }
    1923                 :            : 
    1924         [ #  # ]:          0 :     for( unsigned int i = 0; i < info.numEntities; i++ )
    1925                 :            :     {
    1926                 :            :         // Create an entity set for this entity
    1927                 :          0 :         result = instance->create_set( group_headers[i].setHandle );
    1928         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1929                 :            :         static const char group_category[CATEGORY_TAG_SIZE] = "Group\0";
    1930                 :            : 
    1931                 :          0 :         instance->FREADI( 6 );
    1932                 :          0 :         group_headers[i].grpID     = instance->uint_buf[0];
    1933                 :          0 :         group_headers[i].grpType   = instance->uint_buf[1];
    1934                 :          0 :         group_headers[i].memCt     = instance->uint_buf[2];
    1935                 :          0 :         group_headers[i].memOffset = instance->uint_buf[3];
    1936                 :          0 :         group_headers[i].memTypeCt = instance->uint_buf[4];
    1937                 :          0 :         group_headers[i].grpLength = instance->uint_buf[5];
    1938                 :            : 
    1939                 :            :         // Set the category tag to signify this is a group
    1940                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->categoryTag, &( group_headers[i].setHandle ), 1,
    1941                 :          0 :                                                   group_category );
    1942         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1943                 :            : 
    1944                 :            :         // Set a global id tag
    1945                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->globalIdTag, &( group_headers[i].setHandle ), 1,
    1946                 :          0 :                                                   &( group_headers[i].grpID ) );
    1947         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1948                 :            : 
    1949         [ #  # ]:          0 :         instance->gidSetMap[5][group_headers[i].grpID] = group_headers[i].setHandle;
    1950                 :            :     }
    1951                 :            : 
    1952                 :          0 :     return MB_SUCCESS;
    1953                 :            : }
    1954                 :            : 
    1955                 :          0 : ErrorCode Tqdcfr::BlockHeader::read_info_header( const double data_version, const unsigned int model_offset,
    1956                 :            :                                                  const Tqdcfr::FEModelHeader::ArrayInfo& info, Tqdcfr* instance,
    1957                 :            :                                                  Tqdcfr::BlockHeader*& block_headers )
    1958                 :            : {
    1959 [ #  # ][ #  # ]:          0 :     block_headers = new BlockHeader[info.numEntities];
                 [ #  # ]
    1960                 :          0 :     instance->FSEEK( model_offset + info.tableOffset );
    1961                 :            :     ErrorCode result;
    1962                 :            : 
    1963         [ #  # ]:          0 :     if( 0 == instance->categoryTag )
    1964                 :            :     {
    1965                 :            :         static const char val[CATEGORY_TAG_SIZE] = { 0 };
    1966                 :            :         result = instance->mdbImpl->tag_get_handle( CATEGORY_TAG_NAME, CATEGORY_TAG_SIZE, MB_TYPE_OPAQUE,
    1967                 :          0 :                                                     instance->categoryTag, MB_TAG_SPARSE | MB_TAG_CREAT, val );
    1968 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != result && MB_ALREADY_ALLOCATED != result ) return result;
    1969                 :            :     }
    1970                 :            : 
    1971         [ #  # ]:          0 :     for( unsigned int i = 0; i < info.numEntities; i++ )
    1972                 :            :     {
    1973                 :            :         // Create an entity set for this entity
    1974         [ #  # ]:          0 :         result = instance->create_set( block_headers[i].setHandle );
    1975         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    1976                 :            :         static const char material_category[CATEGORY_TAG_SIZE] = "Material Set\0";
    1977                 :            : 
    1978         [ #  # ]:          0 :         instance->FREADI( 12 );
    1979         [ #  # ]:          0 :         block_headers[i].blockID          = instance->uint_buf[0];
    1980         [ #  # ]:          0 :         block_headers[i].blockElemType    = instance->uint_buf[1];
    1981         [ #  # ]:          0 :         block_headers[i].memCt            = instance->uint_buf[2];
    1982         [ #  # ]:          0 :         block_headers[i].memOffset        = instance->uint_buf[3];
    1983         [ #  # ]:          0 :         block_headers[i].memTypeCt        = instance->uint_buf[4];
    1984         [ #  # ]:          0 :         block_headers[i].attribOrder      = instance->uint_buf[5];  // Attrib order
    1985         [ #  # ]:          0 :         block_headers[i].blockCol         = instance->uint_buf[6];
    1986         [ #  # ]:          0 :         block_headers[i].blockMixElemType = instance->uint_buf[7];  // Mixed elem type
    1987         [ #  # ]:          0 :         block_headers[i].blockPyrType     = instance->uint_buf[8];
    1988         [ #  # ]:          0 :         block_headers[i].blockMat         = instance->uint_buf[9];
    1989         [ #  # ]:          0 :         block_headers[i].blockLength      = instance->uint_buf[10];
    1990         [ #  # ]:          0 :         block_headers[i].blockDim         = instance->uint_buf[11];
    1991                 :            : 
    1992                 :            :         Tag bhTag_header;
    1993                 :            :         {
    1994         [ #  # ]:          0 :             std::vector< int > def_uint_zero( 3, 0 );
    1995                 :            :             result = instance->mdbImpl->tag_get_handle( BLOCK_HEADER, 3 * sizeof( unsigned int ), MB_TYPE_INTEGER,
    1996                 :            :                                                         bhTag_header, MB_TAG_CREAT | MB_TAG_SPARSE | MB_TAG_BYTES,
    1997 [ #  # ][ #  # ]:          0 :                                                         &def_uint_zero[0] );
    1998         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
    1999                 :          0 :             int block_header_data[] = { static_cast< int >( block_headers[i].blockCol ),
    2000                 :          0 :                                         static_cast< int >( block_headers[i].blockMat ),
    2001                 :          0 :                                         static_cast< int >( block_headers[i].blockDim ) };
    2002                 :            :             result =
    2003 [ #  # ][ #  # ]:          0 :                 instance->mdbImpl->tag_set_data( bhTag_header, &( block_headers[i].setHandle ), 1, block_header_data );
    2004                 :            :         }
    2005                 :            : 
    2006         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2007                 :            : 
    2008                 :            :         // Adjust element type for data version; older element types didn't include
    2009                 :            :         // 4 new trishell element types
    2010 [ #  # ][ #  # ]:          0 :         if( data_version <= 1.0 && block_headers[i].blockElemType >= 15 ) block_headers[i].blockElemType += 4;
    2011                 :            : 
    2012         [ #  # ]:          0 :         if( block_headers[i].blockElemType >= (unsigned)cub_elem_num_verts_len )
    2013                 :            :         {
    2014                 :            :             // Block element type unassigned, will have to infer from verts/element; make sure it's
    2015                 :            :             // the expected value of 52
    2016 [ #  # ][ #  # ]:          0 :             if( ( 14 == major && 2 < minor ) || 15 <= major )
                 [ #  # ]
    2017                 :            :             {
    2018         [ #  # ]:          0 :                 if( 55 != block_headers[i].blockElemType )
    2019 [ #  # ][ #  # ]:          0 :                     MB_SET_ERR( MB_FAILURE, "Invalid block element type: " << block_headers[i].blockElemType );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2020                 :            :             }
    2021                 :            :             else
    2022                 :            :             {
    2023         [ #  # ]:          0 :                 if( 52 != block_headers[i].blockElemType )
    2024 [ #  # ][ #  # ]:          0 :                     MB_SET_ERR( MB_FAILURE, "Invalid block element type: " << block_headers[i].blockElemType );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2025                 :            :             }
    2026                 :            :         }
    2027                 :            : 
    2028                 :            :         // Set the material set tag and id tag both to id
    2029                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->blockTag, &( block_headers[i].setHandle ), 1,
    2030         [ #  # ]:          0 :                                                   &( block_headers[i].blockID ) );
    2031         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2032                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->globalIdTag, &( block_headers[i].setHandle ), 1,
    2033         [ #  # ]:          0 :                                                   &( block_headers[i].blockID ) );
    2034         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2035                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->categoryTag, &( block_headers[i].setHandle ), 1,
    2036         [ #  # ]:          0 :                                                   material_category );
    2037         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2038                 :            : 
    2039                 :            :         // If this block is empty, continue
    2040         [ #  # ]:          0 :         if( !block_headers[i].memCt ) continue;
    2041                 :            : 
    2042                 :            :         // Check the number of vertices in the element type, and set the has mid nodes tag
    2043                 :            :         // accordingly; if element type wasn't set, they're unlikely to have mid nodes
    2044                 :            :         // 52 is for CUBIT versions below 14.1, 55 for CUBIT version 14.9 and above
    2045 [ #  # ][ #  # ]:          0 :         if( 52 != block_headers[i].blockElemType && 55 != block_headers[i].blockElemType )
    2046                 :            :         {
    2047                 :          0 :             int num_verts                    = cub_elem_num_verts[block_headers[i].blockElemType];
    2048                 :          0 :             block_headers[i].blockEntityType = block_type_to_mb_type[block_headers[i].blockElemType];
    2049 [ #  # ][ #  # ]:          0 :             if( ( block_headers[i].blockEntityType < MBMAXTYPE ) &&
                 [ #  # ]
    2050         [ #  # ]:          0 :                 ( num_verts != CN::VerticesPerEntity( block_headers[i].blockEntityType ) ) )
    2051                 :            :             {
    2052                 :            :                 // Not a linear element; try to find hasMidNodes values
    2053         [ #  # ]:          0 :                 for( int j = 0; j < 4; j++ )
    2054                 :          0 :                     block_headers[i].hasMidNodes[j] = 0;
    2055         [ #  # ]:          0 :                 if( 0 == instance->hasMidNodesTag )
    2056                 :            :                 {
    2057                 :            :                     result = instance->mdbImpl->tag_get_handle( HAS_MID_NODES_TAG_NAME, 4, MB_TYPE_INTEGER,
    2058                 :            :                                                                 instance->hasMidNodesTag, MB_TAG_SPARSE | MB_TAG_CREAT,
    2059         [ #  # ]:          0 :                                                                 block_headers[i].hasMidNodes );
    2060         [ #  # ]:          0 :                     if( MB_SUCCESS != result ) return result;
    2061                 :            :                 }
    2062                 :            : 
    2063         [ #  # ]:          0 :                 CN::HasMidNodes( block_headers[i].blockEntityType, num_verts, block_headers[i].hasMidNodes );
    2064                 :            : 
    2065                 :            :                 // Now set the tag on this set
    2066                 :          0 :                 result = instance->mdbImpl->tag_set_data( instance->hasMidNodesTag, &block_headers[i].setHandle, 1,
    2067         [ #  # ]:          0 :                                                           block_headers[i].hasMidNodes );
    2068         [ #  # ]:          0 :                 if( MB_SUCCESS != result ) return result;
    2069                 :            :             }
    2070                 :            :         }
    2071                 :            :     }
    2072                 :            : 
    2073                 :          0 :     return MB_SUCCESS;
    2074                 :            : }
    2075                 :            : 
    2076                 :          0 : ErrorCode Tqdcfr::NodesetHeader::read_info_header( const unsigned int model_offset,
    2077                 :            :                                                    const Tqdcfr::FEModelHeader::ArrayInfo& info, Tqdcfr* instance,
    2078                 :            :                                                    Tqdcfr::NodesetHeader*& nodeset_headers )
    2079                 :            : {
    2080 [ #  # ][ #  # ]:          0 :     nodeset_headers = new NodesetHeader[info.numEntities];
                 [ #  # ]
    2081                 :          0 :     instance->FSEEK( model_offset + info.tableOffset );
    2082                 :            :     ErrorCode result;
    2083                 :            : 
    2084         [ #  # ]:          0 :     if( 0 == instance->categoryTag )
    2085                 :            :     {
    2086                 :            :         static const char val[CATEGORY_TAG_SIZE] = { 0 };
    2087                 :            :         result = instance->mdbImpl->tag_get_handle( CATEGORY_TAG_NAME, CATEGORY_TAG_SIZE, MB_TYPE_OPAQUE,
    2088                 :          0 :                                                     instance->categoryTag, MB_TAG_SPARSE | MB_TAG_CREAT, val );
    2089         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2090                 :            :     }
    2091                 :            : 
    2092         [ #  # ]:          0 :     for( unsigned int i = 0; i < info.numEntities; i++ )
    2093                 :            :     {
    2094                 :            :         // Create an entity set for this entity
    2095                 :          0 :         result = instance->create_set( nodeset_headers[i].setHandle );
    2096         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2097                 :            :         static const char dirichlet_category[CATEGORY_TAG_SIZE] = "Dirichlet Set\0";
    2098                 :            : 
    2099                 :          0 :         instance->FREADI( 8 );
    2100                 :          0 :         nodeset_headers[i].nsID      = instance->uint_buf[0];
    2101                 :          0 :         nodeset_headers[i].memCt     = instance->uint_buf[1];
    2102                 :          0 :         nodeset_headers[i].memOffset = instance->uint_buf[2];
    2103                 :          0 :         nodeset_headers[i].memTypeCt = instance->uint_buf[3];
    2104                 :          0 :         nodeset_headers[i].pointSym  = instance->uint_buf[4];  // Point sym
    2105                 :          0 :         nodeset_headers[i].nsCol     = instance->uint_buf[5];
    2106                 :          0 :         nodeset_headers[i].nsLength  = instance->uint_buf[6];
    2107                 :            :         // Pad
    2108                 :            : 
    2109                 :            :         // Set the dirichlet set tag and id tag both to id
    2110                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->nsTag, &( nodeset_headers[i].setHandle ), 1,
    2111                 :          0 :                                                   &( nodeset_headers[i].nsID ) );
    2112         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2113                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->globalIdTag, &( nodeset_headers[i].setHandle ), 1,
    2114                 :          0 :                                                   &( nodeset_headers[i].nsID ) );
    2115         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2116                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->categoryTag, &( nodeset_headers[i].setHandle ), 1,
    2117                 :          0 :                                                   dirichlet_category );
    2118         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2119                 :            :     }
    2120                 :            : 
    2121                 :          0 :     return MB_SUCCESS;
    2122                 :            : }
    2123                 :            : 
    2124                 :          0 : ErrorCode Tqdcfr::SidesetHeader::read_info_header( const unsigned int model_offset,
    2125                 :            :                                                    const Tqdcfr::FEModelHeader::ArrayInfo& info, Tqdcfr* instance,
    2126                 :            :                                                    Tqdcfr::SidesetHeader*& sideset_headers )
    2127                 :            : {
    2128 [ #  # ][ #  # ]:          0 :     sideset_headers = new SidesetHeader[info.numEntities];
                 [ #  # ]
    2129                 :          0 :     instance->FSEEK( model_offset + info.tableOffset );
    2130                 :            :     ErrorCode result;
    2131                 :            : 
    2132         [ #  # ]:          0 :     if( 0 == instance->categoryTag )
    2133                 :            :     {
    2134                 :            :         static const char val[CATEGORY_TAG_SIZE] = { 0 };
    2135                 :            :         result = instance->mdbImpl->tag_get_handle( CATEGORY_TAG_NAME, CATEGORY_TAG_SIZE, MB_TYPE_OPAQUE,
    2136                 :          0 :                                                     instance->categoryTag, MB_TAG_SPARSE | MB_TAG_CREAT, val );
    2137         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2138                 :            :     }
    2139                 :            : 
    2140         [ #  # ]:          0 :     for( unsigned int i = 0; i < info.numEntities; i++ )
    2141                 :            :     {
    2142                 :            :         // Create an entity set for this entity
    2143                 :          0 :         result = instance->create_set( sideset_headers[i].setHandle );
    2144         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2145                 :            :         static const char neumann_category[CATEGORY_TAG_SIZE] = "Neumann Set\0";
    2146                 :            : 
    2147                 :          0 :         instance->FREADI( 8 );
    2148                 :          0 :         sideset_headers[i].ssID      = instance->uint_buf[0];
    2149                 :          0 :         sideset_headers[i].memCt     = instance->uint_buf[1];
    2150                 :          0 :         sideset_headers[i].memOffset = instance->uint_buf[2];
    2151                 :          0 :         sideset_headers[i].memTypeCt = instance->uint_buf[3];
    2152                 :          0 :         sideset_headers[i].numDF     = instance->uint_buf[4];  // Num dist factors
    2153                 :          0 :         sideset_headers[i].ssCol     = instance->uint_buf[5];
    2154                 :          0 :         sideset_headers[i].useShell  = instance->uint_buf[6];
    2155                 :          0 :         sideset_headers[i].ssLength  = instance->uint_buf[7];
    2156                 :            : 
    2157                 :            :         // Set the neumann set tag and id tag both to id
    2158                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->ssTag, &( sideset_headers[i].setHandle ), 1,
    2159                 :          0 :                                                   &( sideset_headers[i].ssID ) );
    2160         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2161                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->globalIdTag, &( sideset_headers[i].setHandle ), 1,
    2162                 :          0 :                                                   &( sideset_headers[i].ssID ) );
    2163         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2164                 :          0 :         result = instance->mdbImpl->tag_set_data( instance->categoryTag, &( sideset_headers[i].setHandle ), 1,
    2165                 :          0 :                                                   neumann_category );
    2166         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2167                 :            :     }
    2168                 :            : 
    2169                 :          0 :     return MB_SUCCESS;
    2170                 :            : }
    2171                 :            : 
    2172                 :          0 : void Tqdcfr::ModelEntry::print_geom_headers( const char* prefix, GeomHeader* header, const unsigned int num_headers )
    2173                 :            : {
    2174         [ #  # ]:          0 :     if( !debug ) return;
    2175                 :          0 :     std::cout << prefix << std::endl;
    2176         [ #  # ]:          0 :     if( NULL != header )
    2177                 :            :     {
    2178         [ #  # ]:          0 :         for( unsigned int i = 0; i < num_headers; i++ )
    2179                 :            :         {
    2180                 :          0 :             std::cout << "Index " << i << std::endl;
    2181                 :          0 :             header[i].print();
    2182                 :            :         }
    2183                 :            :     }
    2184                 :            : }
    2185                 :            : 
    2186                 :          0 : void Tqdcfr::ModelEntry::print_group_headers( const char* prefix, GroupHeader* header, const unsigned int num_headers )
    2187                 :            : {
    2188         [ #  # ]:          0 :     if( !debug ) return;
    2189                 :          0 :     std::cout << prefix << std::endl;
    2190         [ #  # ]:          0 :     if( NULL != header )
    2191                 :            :     {
    2192         [ #  # ]:          0 :         for( unsigned int i = 0; i < num_headers; i++ )
    2193                 :          0 :             header[i].print();
    2194                 :            :     }
    2195                 :            : }
    2196                 :            : 
    2197                 :          0 : void Tqdcfr::ModelEntry::print_block_headers( const char* prefix, BlockHeader* header, const unsigned int num_headers )
    2198                 :            : {
    2199         [ #  # ]:          0 :     if( !debug ) return;
    2200                 :          0 :     std::cout << prefix << std::endl;
    2201         [ #  # ]:          0 :     if( NULL != header )
    2202                 :            :     {
    2203         [ #  # ]:          0 :         for( unsigned int i = 0; i < num_headers; i++ )
    2204                 :          0 :             header[i].print();
    2205                 :            :     }
    2206                 :            : }
    2207                 :            : 
    2208                 :          0 : void Tqdcfr::ModelEntry::print_nodeset_headers( const char* prefix, NodesetHeader* header,
    2209                 :            :                                                 const unsigned int num_headers )
    2210                 :            : {
    2211         [ #  # ]:          0 :     if( !debug ) return;
    2212                 :          0 :     std::cout << prefix << std::endl;
    2213         [ #  # ]:          0 :     if( NULL != header )
    2214                 :            :     {
    2215         [ #  # ]:          0 :         for( unsigned int i = 0; i < num_headers; i++ )
    2216                 :          0 :             header[i].print();
    2217                 :            :     }
    2218                 :            : }
    2219                 :            : 
    2220                 :          0 : void Tqdcfr::ModelEntry::print_sideset_headers( const char* prefix, SidesetHeader* header,
    2221                 :            :                                                 const unsigned int num_headers )
    2222                 :            : {
    2223         [ #  # ]:          0 :     if( !debug ) return;
    2224                 :          0 :     std::cout << prefix << std::endl;
    2225         [ #  # ]:          0 :     if( NULL != header )
    2226                 :            :     {
    2227         [ #  # ]:          0 :         for( unsigned int i = 0; i < num_headers; i++ )
    2228                 :          0 :             header[i].print();
    2229                 :            :     }
    2230                 :            : }
    2231                 :            : 
    2232                 :          0 : ErrorCode Tqdcfr::ModelEntry::read_header_info( Tqdcfr* instance, const double data_version )
    2233                 :            : {
    2234         [ #  # ]:          0 :     feModelHeader.init( modelOffset, instance );
    2235                 :          0 :     int negone = -1;
    2236                 :            :     ErrorCode result;
    2237         [ #  # ]:          0 :     instance->globalIdTag = instance->mdbImpl->globalId_tag();
    2238                 :            : 
    2239         [ #  # ]:          0 :     if( feModelHeader.geomArray.numEntities > 0 )
    2240                 :            :     {
    2241                 :            :         result = instance->mdbImpl->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1, MB_TYPE_INTEGER, instance->geomTag,
    2242         [ #  # ]:          0 :                                                     MB_TAG_SPARSE | MB_TAG_CREAT, &negone );
    2243         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2244                 :            : 
    2245                 :            :         result = instance->mdbImpl->tag_get_handle( "UNIQUE_ID", 1, MB_TYPE_INTEGER, instance->uniqueIdTag,
    2246         [ #  # ]:          0 :                                                     MB_TAG_SPARSE | MB_TAG_CREAT, &negone );
    2247         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2248                 :            : 
    2249         [ #  # ]:          0 :         result = Tqdcfr::GeomHeader::read_info_header( modelOffset, feModelHeader.geomArray, instance, feGeomH );
    2250         [ #  # ]:          0 :         print_geom_headers( "Geom headers:", feGeomH, feModelHeader.geomArray.numEntities );
    2251         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2252                 :            :     }
    2253                 :            : 
    2254         [ #  # ]:          0 :     if( feModelHeader.groupArray.numEntities > 0 )
    2255                 :            :     {
    2256         [ #  # ]:          0 :         result = Tqdcfr::GroupHeader::read_info_header( modelOffset, feModelHeader.groupArray, instance, feGroupH );
    2257         [ #  # ]:          0 :         print_group_headers( "Group headers:", feGroupH, feModelHeader.groupArray.numEntities );
    2258         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2259                 :            :     }
    2260                 :            : 
    2261         [ #  # ]:          0 :     if( feModelHeader.blockArray.numEntities > 0 )
    2262                 :            :     {
    2263                 :            :         result = instance->mdbImpl->tag_get_handle( MATERIAL_SET_TAG_NAME, 1, MB_TYPE_INTEGER, instance->blockTag,
    2264         [ #  # ]:          0 :                                                     MB_TAG_SPARSE | MB_TAG_CREAT, &negone );
    2265         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2266                 :            : 
    2267                 :            :         result = Tqdcfr::BlockHeader::read_info_header( data_version, modelOffset, feModelHeader.blockArray, instance,
    2268         [ #  # ]:          0 :                                                         feBlockH );
    2269         [ #  # ]:          0 :         print_block_headers( "Block headers:", feBlockH, feModelHeader.blockArray.numEntities );
    2270         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2271                 :            :     }
    2272         [ #  # ]:          0 :     if( feModelHeader.nodesetArray.numEntities > 0 )
    2273                 :            :     {
    2274                 :            :         result = instance->mdbImpl->tag_get_handle( DIRICHLET_SET_TAG_NAME, 1, MB_TYPE_INTEGER, instance->nsTag,
    2275         [ #  # ]:          0 :                                                     MB_TAG_SPARSE | MB_TAG_CREAT, &negone );
    2276         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2277                 :            : 
    2278                 :            :         result =
    2279         [ #  # ]:          0 :             Tqdcfr::NodesetHeader::read_info_header( modelOffset, feModelHeader.nodesetArray, instance, feNodeSetH );
    2280         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2281         [ #  # ]:          0 :         print_nodeset_headers( "Nodeset headers:", feNodeSetH, feModelHeader.nodesetArray.numEntities );
    2282                 :            :     }
    2283         [ #  # ]:          0 :     if( feModelHeader.sidesetArray.numEntities > 0 )
    2284                 :            :     {
    2285                 :            :         result = instance->mdbImpl->tag_get_handle( NEUMANN_SET_TAG_NAME, 1, MB_TYPE_INTEGER, instance->ssTag,
    2286         [ #  # ]:          0 :                                                     MB_TAG_SPARSE | MB_TAG_CREAT, &negone );
    2287         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2288                 :            : 
    2289                 :            :         result =
    2290         [ #  # ]:          0 :             Tqdcfr::SidesetHeader::read_info_header( modelOffset, feModelHeader.sidesetArray, instance, feSideSetH );
    2291         [ #  # ]:          0 :         print_sideset_headers( "SideSet headers:", feSideSetH, feModelHeader.sidesetArray.numEntities );
    2292                 :            :     }
    2293                 :            : 
    2294                 :          0 :     return MB_SUCCESS;
    2295                 :            : }
    2296                 :            : 
    2297                 :          0 : ErrorCode Tqdcfr::ModelEntry::read_metadata_info( Tqdcfr* tqd )
    2298                 :            : {
    2299         [ #  # ]:          0 :     if( debug ) std::cout << "Geom metadata:" << std::endl;
    2300                 :          0 :     tqd->read_meta_data( modelOffset + feModelHeader.geomArray.metaDataOffset, geomMD );
    2301         [ #  # ]:          0 :     if( debug ) std::cout << "Node metadata:" << std::endl;
    2302                 :          0 :     tqd->read_meta_data( modelOffset + feModelHeader.nodeArray.metaDataOffset, nodeMD );
    2303         [ #  # ]:          0 :     if( debug ) std::cout << "Elem metadata:" << std::endl;
    2304                 :          0 :     tqd->read_meta_data( modelOffset + feModelHeader.elementArray.metaDataOffset, elementMD );
    2305         [ #  # ]:          0 :     if( debug ) std::cout << "Group metadata:" << std::endl;
    2306                 :          0 :     tqd->read_meta_data( modelOffset + feModelHeader.groupArray.metaDataOffset, groupMD );
    2307         [ #  # ]:          0 :     if( debug ) std::cout << "Block metadata:" << std::endl;
    2308                 :          0 :     tqd->read_meta_data( modelOffset + feModelHeader.blockArray.metaDataOffset, blockMD );
    2309         [ #  # ]:          0 :     if( debug ) std::cout << "Nodeset metadata:" << std::endl;
    2310                 :          0 :     tqd->read_meta_data( modelOffset + feModelHeader.nodesetArray.metaDataOffset, nodesetMD );
    2311         [ #  # ]:          0 :     if( debug ) std::cout << "Sideset metadata:" << std::endl;
    2312                 :          0 :     tqd->read_meta_data( modelOffset + feModelHeader.sidesetArray.metaDataOffset, sidesetMD );
    2313                 :            : 
    2314                 :          0 :     return MB_SUCCESS;
    2315                 :            : }
    2316                 :            : 
    2317                 :          0 : ErrorCode Tqdcfr::read_acis_records( const char* sat_filename )
    2318                 :            : {
    2319                 :            :     // Get the acis model location
    2320                 :          0 :     unsigned int acis_model_offset = 0, acis_model_length = 0, acis_model_handle = 1, acis_sat_type = 1;
    2321         [ #  # ]:          0 :     for( unsigned int i = 0; i < fileTOC.numModels; i++ )
    2322                 :            :     {
    2323 [ #  # ][ #  # ]:          0 :         if( modelEntries[i].modelHandle == acis_model_handle && modelEntries[i].modelType == acis_sat_type )
         [ #  # ][ #  # ]
                 [ #  # ]
    2324                 :            :         {
    2325         [ #  # ]:          0 :             acis_model_offset = modelEntries[i].modelOffset;
    2326         [ #  # ]:          0 :             acis_model_length = modelEntries[i].modelLength;
    2327                 :          0 :             break;
    2328                 :            :         }
    2329                 :            :     }
    2330                 :            : 
    2331         [ #  # ]:          0 :     if( acis_model_length == 0 ) return MB_SUCCESS;
    2332                 :            : 
    2333         [ #  # ]:          0 :     std::vector< AcisRecord > records;
    2334                 :            : 
    2335                 :          0 :     acisDumpFile = NULL;
    2336         [ #  # ]:          0 :     if( sat_filename )
    2337                 :            :     {
    2338         [ #  # ]:          0 :         acisDumpFile = fopen( sat_filename, "w+" );
    2339         [ #  # ]:          0 :         if( NULL == acisDumpFile ) return MB_FAILURE;
    2340                 :            :     }
    2341                 :            : 
    2342                 :            :     // Position the file at the start of the acis model
    2343         [ #  # ]:          0 :     FSEEK( acis_model_offset );
    2344                 :            : 
    2345                 :          0 :     unsigned int bytes_left = acis_model_length;
    2346                 :            : 
    2347         [ #  # ]:          0 :     struct AcisRecord this_record;
    2348         [ #  # ]:          0 :     reset_record( this_record );
    2349                 :            :     char* ret;
    2350                 :            : 
    2351                 :            :     // Make the char buffer at least buf_size + 1 long, to fit null char
    2352                 :          0 :     const unsigned int buf_size = 1023;
    2353                 :            : 
    2354                 :            :     // CHECK_SIZE(char_buf, buf_size + 1);
    2355         [ #  # ]:          0 :     char_buf.resize( buf_size + 1 );
    2356                 :            : 
    2357         [ #  # ]:          0 :     while( 0 != bytes_left )
    2358                 :            :     {
    2359                 :            :         // Read the next buff characters, or bytes_left if smaller
    2360                 :          0 :         unsigned int next_buf = ( bytes_left > buf_size ? buf_size : bytes_left );
    2361         [ #  # ]:          0 :         FREADC( next_buf );
    2362                 :            : 
    2363 [ #  # ][ #  # ]:          0 :         if( NULL != acisDumpFile ) fwrite( &char_buf[0], sizeof( char ), next_buf, acisDumpFile );
                 [ #  # ]
    2364                 :            : 
    2365                 :            :         // Put null at end of string to stop searches
    2366         [ #  # ]:          0 :         char_buf.resize( next_buf + 1 );
    2367         [ #  # ]:          0 :         char_buf[next_buf]   = '\0';
    2368                 :          0 :         unsigned int buf_pos = 0;
    2369                 :            : 
    2370                 :            :         // Check for first read, and if so, get rid of the header
    2371         [ #  # ]:          0 :         if( bytes_left == acis_model_length )
    2372                 :            :         {
    2373                 :            :             // Look for 3 newlines
    2374         [ #  # ]:          0 :             ret = strchr( &( char_buf[0] ), '\n' );
    2375                 :          0 :             ret = strchr( ret + 1, '\n' );
    2376                 :          0 :             ret = strchr( ret + 1, '\n' );
    2377         [ #  # ]:          0 :             if( NULL == ret ) return MB_FAILURE;
    2378         [ #  # ]:          0 :             buf_pos += ret - &( char_buf[0] ) + 1;
    2379                 :            :         }
    2380                 :            : 
    2381                 :          0 :         bytes_left -= next_buf;
    2382                 :            : 
    2383                 :            :         // Now start grabbing records
    2384         [ #  # ]:          0 :         do
    2385                 :            :         {
    2386                 :            :             // Get next occurrence of '#' (record terminator)
    2387         [ #  # ]:          0 :             ret = strchr( &( char_buf[buf_pos] ), '#' );
    2388 [ #  # ][ #  # ]:          0 :             while( ret && (unsigned int)( ret + 1 - &char_buf[0] ) < bytes_left && *( ret + 1 ) != '\n' &&
         [ #  # ][ #  # ]
                 [ #  # ]
    2389 [ #  # ][ #  # ]:          0 :                    *( ret + 1 ) != '\r' && *( ret + 1 ) != 0 )  // CR added for windows
    2390                 :          0 :                 ret = strchr( ret + 1, '#' );
    2391         [ #  # ]:          0 :             if( NULL != ret )
    2392                 :            :             {
    2393                 :            :                 // Grab the string (inclusive of the record terminator and the line feed) and
    2394                 :            :                 // complete the record
    2395         [ #  # ]:          0 :                 int num_chars = ret - &( char_buf[buf_pos] ) + 2;
    2396         [ #  # ]:          0 :                 if( *( ret + 1 ) == '\r' ) num_chars++;  // add more one character for Windows CR
    2397 [ #  # ][ #  # ]:          0 :                 this_record.att_string.append( &( char_buf[buf_pos] ), num_chars );
    2398                 :          0 :                 buf_pos += num_chars;
    2399         [ #  # ]:          0 :                 process_record( this_record );
    2400                 :            : 
    2401                 :            :                 // Put the record in the list...
    2402         [ #  # ]:          0 :                 records.push_back( this_record );
    2403                 :            : 
    2404                 :            :                 // And reset the record
    2405         [ #  # ]:          0 :                 reset_record( this_record );
    2406                 :            :             }
    2407                 :            :             else
    2408                 :            :             {
    2409                 :            :                 // Reached end of buffer; cache string then go get another; discard last character,
    2410                 :            :                 // which will be the null character
    2411 [ #  # ][ #  # ]:          0 :                 this_record.att_string.append( &( char_buf[buf_pos] ), next_buf - buf_pos );
    2412                 :          0 :                 buf_pos = next_buf;
    2413                 :            :             }
    2414                 :            :         } while( buf_pos < next_buf );
    2415                 :            :     }
    2416                 :            : 
    2417         [ #  # ]:          0 :     if( NULL != acisDumpFile )
    2418         [ #  # ]:          0 :         fwrite( "\n======================\nSorted acis records:\n======================\n", 1, 68, acisDumpFile );
    2419                 :            : 
    2420                 :            :     // Now interpret the records
    2421         [ #  # ]:          0 :     interpret_acis_records( records );
    2422                 :            : 
    2423 [ #  # ][ #  # ]:          0 :     if( NULL != acisDumpFile ) fclose( acisDumpFile );
    2424                 :            : 
    2425                 :          0 :     return MB_SUCCESS;
    2426                 :            : }
    2427                 :            : 
    2428                 :          0 : ErrorCode Tqdcfr::interpret_acis_records( std::vector< AcisRecord >& records )
    2429                 :            : {
    2430                 :            :     // Make a tag for the vector holding unrecognized attributes
    2431                 :          0 :     void* default_val = NULL;
    2432                 :            :     ErrorCode result  = mdbImpl->tag_get_handle( "ATTRIB_VECTOR", sizeof( void* ), MB_TYPE_OPAQUE, attribVectorTag,
    2433         [ #  # ]:          0 :                                                 MB_TAG_CREAT | MB_TAG_SPARSE, &default_val );
    2434         [ #  # ]:          0 :     if( MB_SUCCESS != result ) return result;
    2435                 :            : 
    2436                 :          0 :     unsigned int current_record = 0;
    2437                 :            : 
    2438                 :            : #define REC records[current_record]
    2439                 :            : 
    2440         [ #  # ]:          0 :     while( current_record != records.size() )
    2441                 :            :     {
    2442                 :            :         // If this record's been processed, or if it's an attribute, continue
    2443 [ #  # ][ #  # ]:          0 :         if( REC.processed || REC.rec_type == Tqdcfr::ATTRIB )
         [ #  # ][ #  # ]
                 [ #  # ]
    2444                 :            :         {
    2445                 :          0 :             current_record++;
    2446                 :          0 :             continue;
    2447                 :            :         }
    2448                 :            : 
    2449 [ #  # ][ #  # ]:          0 :         if( REC.rec_type == Tqdcfr::UNKNOWN )
    2450                 :            :         {
    2451         [ #  # ]:          0 :             REC.processed = true;
    2452                 :          0 :             current_record++;
    2453                 :          0 :             continue;
    2454                 :            :         }
    2455                 :            : 
    2456                 :            :         // It's a known, non-attrib rec type; parse for any attribs
    2457         [ #  # ]:          0 :         parse_acis_attribs( current_record, records );
    2458                 :            : 
    2459         [ #  # ]:          0 :         REC.processed = true;
    2460                 :            : 
    2461                 :          0 :         current_record++;
    2462                 :            :     }
    2463                 :            : 
    2464                 :          0 :     return MB_SUCCESS;
    2465                 :            : }
    2466                 :            : 
    2467                 :          0 : ErrorCode Tqdcfr::parse_acis_attribs( const unsigned int entity_rec_num, std::vector< AcisRecord >& records )
    2468                 :            : {
    2469                 :            :     unsigned int num_read;
    2470         [ #  # ]:          0 :     std::vector< std::string > attrib_vec;
    2471                 :            :     char temp_name[1024];
    2472                 :            :     char name_tag_val[NAME_TAG_SIZE];
    2473         [ #  # ]:          0 :     std::string name_tag;
    2474                 :          0 :     int id          = -1;
    2475                 :          0 :     int uid         = -1;
    2476                 :          0 :     int next_attrib = -1;
    2477                 :            :     ErrorCode result;
    2478                 :            : 
    2479         [ #  # ]:          0 :     int current_attrib = records[entity_rec_num].first_attrib;
    2480         [ #  # ]:          0 :     if( -1 == current_attrib ) return MB_SUCCESS;
    2481                 :            : 
    2482         [ #  # ]:          0 :     if( NULL != acisDumpFile )
    2483                 :            :     {
    2484         [ #  # ]:          0 :         fwrite( "-----------------------------------------------------------------------\n", 1, 72, acisDumpFile );
    2485   [ #  #  #  # ]:          0 :         fwrite( records[entity_rec_num].att_string.c_str(), sizeof( char ), records[entity_rec_num].att_string.length(),
    2486         [ #  # ]:          0 :                 acisDumpFile );
    2487                 :            :     }
    2488                 :            : 
    2489         [ #  # ]:          0 :     while( -1 != current_attrib )
    2490                 :            :     {
    2491 [ #  # ][ #  # ]:          0 :         if( records[current_attrib].rec_type != Tqdcfr::UNKNOWN &&
         [ #  # ][ #  # ]
    2492 [ #  # ][ #  # ]:          0 :             ( records[current_attrib].att_next != next_attrib ||
    2493         [ #  # ]:          0 :               records[current_attrib].att_ent_num != (int)entity_rec_num ) )
    2494                 :          0 :             return MB_FAILURE;
    2495                 :            : 
    2496         [ #  # ]:          0 :         if( NULL != acisDumpFile )
    2497         [ #  # ]:          0 :             fwrite( records[current_attrib].att_string.c_str(), sizeof( char ),
    2498 [ #  # ][ #  # ]:          0 :                     records[current_attrib].att_string.length(), acisDumpFile );
    2499                 :            : 
    2500                 :            :         // Is the attrib one we already recognize?
    2501 [ #  # ][ #  # ]:          0 :         if( strncmp( records[current_attrib].att_string.c_str(), "ENTITY_NAME", 11 ) == 0 )
    2502                 :            :         {
    2503                 :            :             // Parse name
    2504                 :            :             int num_chars;
    2505                 :            :             num_read =
    2506         [ #  # ]:          0 :                 sscanf( records[current_attrib].att_string.c_str(), "ENTITY_NAME @%d %s", &num_chars, temp_name );
    2507         [ #  # ]:          0 :             if( num_read != 2 )
    2508                 :            :                 num_read =
    2509         [ #  # ]:          0 :                     sscanf( records[current_attrib].att_string.c_str(), "ENTITY_NAME %d %s", &num_chars, temp_name );
    2510         [ #  # ]:          0 :             if( num_read != 2 ) return MB_FAILURE;
    2511                 :            : 
    2512                 :            :             // Put the name on the entity
    2513 [ #  # ][ #  # ]:          0 :             name_tag = std::string( temp_name, num_chars );
    2514                 :            :         }
    2515 [ #  # ][ #  # ]:          0 :         else if( strncmp( records[current_attrib].att_string.c_str(), "ENTITY_ID", 9 ) == 0 )
    2516                 :            :         {
    2517                 :            :             // Parse id
    2518                 :            :             int bounding_uid, bounding_sense;
    2519         [ #  # ]:          0 :             num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_ID 0 3 %d %d %d", &id, &bounding_uid,
    2520                 :          0 :                                &bounding_sense );
    2521         [ #  # ]:          0 :             if( 3 != num_read )
    2522                 :            :             {
    2523                 :            :                 // Try reading updated entity_id format, which has coordinate triple embedded in it
    2524                 :            :                 // too
    2525                 :            :                 float dumx, dumy, dumz;
    2526         [ #  # ]:          0 :                 num_read = sscanf( records[current_attrib].att_string.c_str(), "ENTITY_ID 3 %f %f %f 3 %d %d %d", &dumx,
    2527                 :          0 :                                    &dumy, &dumz, &id, &bounding_uid, &bounding_sense );
    2528                 :          0 :                 num_read -= 3;
    2529                 :            :             }
    2530                 :            : 
    2531         [ #  # ]:          0 :             if( 3 != num_read )
    2532 [ #  # ][ #  # ]:          0 :                 std::cout << "Warning: bad ENTITY_ID attribute in .sat file, record number " << entity_rec_num
    2533 [ #  # ][ #  # ]:          0 :                           << ", record follows:" << std::endl
    2534 [ #  # ][ #  # ]:          0 :                           << records[current_attrib].att_string.c_str() << std::endl;
                 [ #  # ]
    2535                 :            :         }
    2536 [ #  # ][ #  # ]:          0 :         else if( strncmp( records[current_attrib].att_string.c_str(), "UNIQUE_ID", 9 ) == 0 )
    2537                 :            :         {
    2538                 :            :             // Parse uid
    2539         [ #  # ]:          0 :             if( major >= 14 )  // Change of format for cubit 14:
    2540         [ #  # ]:          0 :                 num_read = sscanf( records[current_attrib].att_string.c_str(), "UNIQUE_ID 0 1 %d", &uid );
    2541                 :            :             else
    2542         [ #  # ]:          0 :                 num_read = sscanf( records[current_attrib].att_string.c_str(), "UNIQUE_ID 1 0 1 %d", &uid );
    2543         [ #  # ]:          0 :             if( 1 != num_read ) return MB_FAILURE;
    2544                 :            :         }
    2545 [ #  # ][ #  # ]:          0 :         else if( strncmp( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 UNIQUE_ID", 29 ) == 0 )
    2546                 :            :         {
    2547                 :            :             // Parse uid
    2548                 :            :             int dum1, dum2, dum3, dum4;
    2549         [ #  # ]:          0 :             num_read = sscanf( records[current_attrib].att_string.c_str(),
    2550                 :          0 :                                "COMPOSITE_ATTRIB @9 UNIQUE_ID %d %d %d %d %d", &dum1, &dum2, &dum3, &dum4, &uid );
    2551         [ #  # ]:          0 :             if( 5 != num_read ) return MB_FAILURE;
    2552                 :            :         }
    2553 [ #  # ][ #  # ]:          0 :         else if( strncmp( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID", 29 ) == 0 )
    2554                 :            :         {
    2555                 :            :             // Parse id
    2556                 :            :             int dum1, dum2, dum3;
    2557         [ #  # ]:          0 :             num_read = sscanf( records[current_attrib].att_string.c_str(), "COMPOSITE_ATTRIB @9 ENTITY_ID %d %d %d %d",
    2558                 :          0 :                                &dum1, &dum2, &dum3, &id );
    2559         [ #  # ]:          0 :             if( 4 != num_read ) return MB_FAILURE;
    2560                 :            :         }
    2561                 :            :         else
    2562                 :            :         {
    2563 [ #  # ][ #  # ]:          0 :             attrib_vec.push_back( records[current_attrib].att_string );
    2564                 :            :         }
    2565                 :            : 
    2566         [ #  # ]:          0 :         records[current_attrib].processed = true;
    2567                 :          0 :         next_attrib                       = current_attrib;
    2568         [ #  # ]:          0 :         current_attrib                    = records[current_attrib].att_prev;
    2569                 :            :     }
    2570                 :            : 
    2571                 :            :     // At this point, there aren't entity sets for entity types which don't contain mesh
    2572                 :            :     // in this case, just return
    2573 [ #  # ][ #  # ]:          0 :     if( records[entity_rec_num].rec_type == aBODY || ( records[entity_rec_num].entity == 0 && uid == -1 ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2574                 :            :     {
    2575                 :          0 :         return MB_SUCCESS;
    2576                 :            :         // Warning: couldn't resolve entity of type 1 because no uid was found.
    2577                 :            :         // ddriv: GeomTopoTool.cpp:172: ErrorCode GeomTopoTool::separate_by_dimension(const Range&,
    2578                 :            :         // Range*, void**): Assertion `false' failed. xxx
    2579                 :            :     }
    2580                 :            : 
    2581                 :            :     // Parsed the data; now put on mdb entities; first we need to find the entity
    2582 [ #  # ][ #  # ]:          0 :     if( records[entity_rec_num].entity == 0 ) { records[entity_rec_num].entity = uidSetMap[uid]; }
         [ #  # ][ #  # ]
    2583                 :            : 
    2584 [ #  # ][ #  # ]:          0 :     if( 0 == records[entity_rec_num].entity ) return MB_SUCCESS;  // We do not have a MOAB entity for this, skip
    2585                 :            : 
    2586                 :            :     // assert(records[entity_rec_num].entity);
    2587                 :            : 
    2588                 :            :     // Set the id
    2589         [ #  # ]:          0 :     if( id != -1 )
    2590                 :            :     {
    2591 [ #  # ][ #  # ]:          0 :         result = mdbImpl->tag_set_data( globalIdTag, &( records[entity_rec_num].entity ), 1, &id );
    2592         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2593                 :            : 
    2594                 :          0 :         int ent_dim = -1;
    2595 [ #  # ][ #  # ]:          0 :         if( records[entity_rec_num].rec_type == aBODY )
    2596                 :          0 :             ent_dim = 4;
    2597 [ #  # ][ #  # ]:          0 :         else if( records[entity_rec_num].rec_type == LUMP )
    2598                 :          0 :             ent_dim = 3;
    2599 [ #  # ][ #  # ]:          0 :         else if( records[entity_rec_num].rec_type == FACE )
    2600                 :          0 :             ent_dim = 2;
    2601 [ #  # ][ #  # ]:          0 :         else if( records[entity_rec_num].rec_type == aEDGE )
    2602                 :          0 :             ent_dim = 1;
    2603 [ #  # ][ #  # ]:          0 :         else if( records[entity_rec_num].rec_type == aVERTEX )
    2604                 :          0 :             ent_dim = 0;
    2605 [ #  # ][ #  # ]:          0 :         if( -1 != ent_dim ) gidSetMap[ent_dim][id] = records[entity_rec_num].entity;
                 [ #  # ]
    2606                 :            :     }
    2607                 :            : 
    2608                 :            :     // Set the name
    2609         [ #  # ]:          0 :     if( !name_tag.empty() )
    2610                 :            :     {
    2611         [ #  # ]:          0 :         if( 0 == entityNameTag )
    2612                 :            :         {
    2613                 :          0 :             char dum_val[NAME_TAG_SIZE] = { 0 };
    2614                 :            :             result = mdbImpl->tag_get_handle( NAME_TAG_NAME, NAME_TAG_SIZE, MB_TYPE_OPAQUE, entityNameTag,
    2615         [ #  # ]:          0 :                                               MB_TAG_SPARSE | MB_TAG_CREAT, dum_val );
    2616         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
    2617                 :            :         }
    2618                 :            : 
    2619                 :          0 :         size_t len = name_tag.size();
    2620         [ #  # ]:          0 :         if( len >= NAME_TAG_SIZE ) len = NAME_TAG_SIZE - 1;  // Truncate a name that is too big
    2621                 :          0 :         memcpy( name_tag_val, name_tag.c_str(), len );
    2622                 :          0 :         memset( name_tag_val + len, '\0', NAME_TAG_SIZE - len );
    2623 [ #  # ][ #  # ]:          0 :         result = mdbImpl->tag_set_data( entityNameTag, &( records[entity_rec_num].entity ), 1, name_tag_val );
    2624         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
    2625                 :            :     }
    2626                 :            : 
    2627         [ #  # ]:          0 :     if( !attrib_vec.empty() )
    2628                 :            :     {
    2629                 :            :         // Put the attrib vector in a tag on the entity
    2630                 :            :         std::vector< std::string >* dum_vec;
    2631 [ #  # ][ #  # ]:          0 :         result = mdbImpl->tag_get_data( attribVectorTag, &( records[entity_rec_num].entity ), 1, &dum_vec );
    2632 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != result && MB_TAG_NOT_FOUND != result ) return result;
    2633 [ #  # ][ #  # ]:          0 :         if( MB_TAG_NOT_FOUND == result || dum_vec == NULL )
    2634                 :            :         {
    2635                 :            :             // Put this list directly on the entity
    2636 [ #  # ][ #  # ]:          0 :             dum_vec = new std::vector< std::string >;
    2637                 :          0 :             dum_vec->swap( attrib_vec );
    2638 [ #  # ][ #  # ]:          0 :             result = mdbImpl->tag_set_data( attribVectorTag, &( records[entity_rec_num].entity ), 1, &dum_vec );
    2639         [ #  # ]:          0 :             if( MB_SUCCESS != result )
    2640                 :            :             {
    2641         [ #  # ]:          0 :                 delete dum_vec;
    2642                 :          0 :                 return result;
    2643                 :            :             }
    2644                 :            :         }
    2645                 :            :         else
    2646                 :            :         {
    2647                 :            :             // Copy this list over, and delete this list
    2648 [ #  # ][ #  # ]:          0 :             std::copy( attrib_vec.begin(), attrib_vec.end(), std::back_inserter( *dum_vec ) );
    2649                 :            :         }
    2650                 :            :     }
    2651                 :            : 
    2652                 :          0 :     return MB_SUCCESS;
    2653                 :            : }
    2654                 :            : 
    2655                 :          0 : ErrorCode Tqdcfr::reset_record( AcisRecord& this_record )
    2656                 :            : {
    2657                 :          0 :     this_record.rec_type = Tqdcfr::UNKNOWN;
    2658                 :          0 :     this_record.att_string.clear();
    2659                 :          0 :     this_record.first_attrib = this_record.att_prev = this_record.att_next = this_record.att_ent_num = -1;
    2660                 :          0 :     this_record.processed                                                                            = false;
    2661                 :          0 :     this_record.entity                                                                               = 0;
    2662                 :            : 
    2663                 :          0 :     return MB_SUCCESS;
    2664                 :            : }
    2665                 :            : 
    2666                 :          0 : ErrorCode Tqdcfr::process_record( AcisRecord& this_record )
    2667                 :            : {
    2668                 :            :     // Get the entity type
    2669                 :            :     const char* type_substr;
    2670                 :            : 
    2671                 :            :     // Try attribs first, since the others have some common processing between them
    2672   [ #  #  #  # ]:          0 :     if( ( type_substr = strstr( this_record.att_string.c_str(), "attrib" ) ) != NULL &&
                 [ #  # ]
    2673                 :          0 :         type_substr - this_record.att_string.c_str() < 20 )
    2674                 :            :     {
    2675                 :          0 :         this_record.rec_type = Tqdcfr::ATTRIB;
    2676                 :          0 :         bool simple_attrib   = false;
    2677                 :          0 :         bool generic_attrib  = false;
    2678         [ #  # ]:          0 :         if( ( type_substr = strstr( this_record.att_string.c_str(), "simple-snl-attrib" ) ) != NULL )
    2679                 :          0 :             simple_attrib = true;
    2680         [ #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "integer_attrib-name_attrib-gen-attrib" ) ) !=
    2681                 :            :                  NULL )
    2682                 :          0 :             generic_attrib = true;
    2683                 :            :         else
    2684                 :            :         {
    2685                 :          0 :             this_record.rec_type = Tqdcfr::UNKNOWN;
    2686                 :          0 :             return MB_SUCCESS;
    2687                 :            :         }
    2688                 :            : 
    2689                 :            :         // Find next space
    2690                 :          0 :         type_substr = strchr( type_substr, ' ' );
    2691         [ #  # ]:          0 :         if( NULL == type_substr ) return MB_FAILURE;
    2692                 :            : 
    2693                 :            :         // Read the numbers from there
    2694                 :            :         int num_converted = sscanf( type_substr, " $-1 -1 $%d $%d $%d -1", &( this_record.att_prev ),
    2695                 :          0 :                                     &( this_record.att_next ), &( this_record.att_ent_num ) );
    2696         [ #  # ]:          0 :         if( num_converted != 3 ) return MB_FAILURE;
    2697                 :            : 
    2698                 :            :         // Trim the string to the attribute, if it's a simple attrib
    2699         [ #  # ]:          0 :         if( simple_attrib )
    2700                 :            :         {
    2701                 :          0 :             type_substr = strstr( this_record.att_string.c_str(), "NEW_SIMPLE_ATTRIB" );
    2702         [ #  # ]:          0 :             if( NULL == type_substr ) return MB_FAILURE;
    2703                 :          0 :             type_substr = strstr( type_substr, "@" );
    2704         [ #  # ]:          0 :             if( NULL == type_substr ) return MB_FAILURE;
    2705                 :          0 :             type_substr = strstr( type_substr, " " ) + 1;
    2706                 :            :             // Copy the rest of the string to a dummy string
    2707         [ #  # ]:          0 :             std::string dum_str( type_substr );
    2708         [ #  # ]:          0 :             this_record.att_string = dum_str;
    2709                 :            :         }
    2710         [ #  # ]:          0 :         else if( generic_attrib )
    2711                 :            :         {
    2712                 :          0 :             type_substr = strstr( this_record.att_string.c_str(), "CUBIT_ID" );
    2713         [ #  # ]:          0 :             if( NULL == type_substr ) return MB_FAILURE;
    2714                 :            :             // Copy the rest of the string to a dummy string
    2715         [ #  # ]:          0 :             std::string dum_str( type_substr );
    2716         [ #  # ]:          0 :             this_record.att_string = dum_str;
    2717                 :            :         }
    2718                 :            :     }
    2719                 :            :     else
    2720                 :            :     {
    2721                 :            :         // Else it's a topological entity, I think
    2722   [ #  #  #  # ]:          0 :         if( ( type_substr = strstr( this_record.att_string.c_str(), "body" ) ) != NULL &&
                 [ #  # ]
    2723                 :          0 :             type_substr - this_record.att_string.c_str() < 20 )
    2724                 :          0 :         { this_record.rec_type = Tqdcfr::aBODY; }
    2725   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "lump" ) ) != NULL &&
                 [ #  # ]
    2726                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2727                 :            :         {
    2728                 :          0 :             this_record.rec_type = Tqdcfr::LUMP;
    2729                 :            :         }
    2730   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "shell" ) ) != NULL &&
                 [ #  # ]
    2731                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2732                 :            :         {
    2733                 :            :             // Don't care about shells
    2734                 :          0 :             this_record.rec_type = Tqdcfr::UNKNOWN;
    2735                 :            :         }
    2736   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "surface" ) ) != NULL &&
                 [ #  # ]
    2737                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2738                 :            :         {
    2739                 :            :             // Don't care about surfaces
    2740                 :          0 :             this_record.rec_type = Tqdcfr::UNKNOWN;
    2741                 :            :         }
    2742   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "face" ) ) != NULL &&
                 [ #  # ]
    2743                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2744                 :            :         {
    2745                 :          0 :             this_record.rec_type = Tqdcfr::FACE;
    2746                 :            :         }
    2747   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "loop" ) ) != NULL &&
                 [ #  # ]
    2748                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2749                 :            :         {
    2750                 :            :             // Don't care about loops
    2751                 :          0 :             this_record.rec_type = Tqdcfr::UNKNOWN;
    2752                 :            :         }
    2753   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "coedge" ) ) != NULL &&
                 [ #  # ]
    2754                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2755                 :            :         {
    2756                 :            :             // Don't care about coedges
    2757                 :          0 :             this_record.rec_type = Tqdcfr::UNKNOWN;
    2758                 :            :         }
    2759   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "edge" ) ) != NULL &&
                 [ #  # ]
    2760                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2761                 :            :         {
    2762                 :          0 :             this_record.rec_type = Tqdcfr::aEDGE;
    2763                 :            :         }
    2764   [ #  #  #  # ]:          0 :         else if( ( type_substr = strstr( this_record.att_string.c_str(), "vertex" ) ) != NULL &&
                 [ #  # ]
    2765                 :          0 :                  type_substr - this_record.att_string.c_str() < 20 )
    2766                 :            :         {
    2767                 :          0 :             this_record.rec_type = Tqdcfr::aVERTEX;
    2768                 :            :         }
    2769                 :            :         else
    2770                 :          0 :             this_record.rec_type = Tqdcfr::UNKNOWN;
    2771                 :            : 
    2772         [ #  # ]:          0 :         if( this_record.rec_type != Tqdcfr::UNKNOWN )
    2773                 :            :         {
    2774                 :            :             // Print a warning if it looks like there are sequence numbers
    2775 [ #  # ][ #  # ]:          0 :             if( type_substr != this_record.att_string.c_str() && !printedSeqWarning )
                 [ #  # ]
    2776                 :            :             {
    2777                 :          0 :                 std::cout << "Warning: acis file has sequence numbers!" << std::endl;
    2778                 :          0 :                 printedSeqWarning = true;
    2779                 :            :             }
    2780                 :            : 
    2781                 :            :             // Scan ahead to the next white space
    2782                 :          0 :             type_substr = strchr( type_substr, ' ' );
    2783         [ #  # ]:          0 :             if( NULL == type_substr ) return MB_FAILURE;
    2784                 :            : 
    2785                 :            :             // Get the id of the first attrib
    2786                 :          0 :             int num_converted = sscanf( type_substr, " $%d", &( this_record.first_attrib ) );
    2787         [ #  # ]:          0 :             if( num_converted != 1 ) return MB_FAILURE;
    2788                 :            :         }
    2789                 :            :     }
    2790                 :            : 
    2791                 :          0 :     return MB_SUCCESS;
    2792                 :            : }
    2793                 :            : 
    2794                 :          1 : Tqdcfr::FileTOC::FileTOC()
    2795                 :            :     : fileEndian( 0 ), fileSchema( 0 ), numModels( 0 ), modelTableOffset( 0 ), modelMetaDataOffset( 0 ),
    2796                 :          1 :       activeFEModel( 0 )
    2797                 :            : {
    2798                 :          1 : }
    2799                 :            : 
    2800                 :          0 : void Tqdcfr::FileTOC::print()
    2801                 :            : {
    2802                 :          0 :     std::cout << "FileTOC:End, Sch, #Mdl, TabOff, "
    2803                 :          0 :               << "MdlMDOff, actFEMdl = ";
    2804                 :          0 :     std::cout << fileEndian << ", " << fileSchema << ", " << numModels << ", " << modelTableOffset << ", "
    2805                 :          0 :               << modelMetaDataOffset << ", " << activeFEModel << std::endl;
    2806                 :          0 : }
    2807                 :            : 
    2808                 :          0 : Tqdcfr::FEModelHeader::ArrayInfo::ArrayInfo() : numEntities( 0 ), tableOffset( 0 ), metaDataOffset( 0 ) {}
    2809                 :            : 
    2810                 :          0 : void Tqdcfr::FEModelHeader::ArrayInfo::print()
    2811                 :            : {
    2812                 :          0 :     std::cout << "ArrayInfo:numEntities, tableOffset, metaDataOffset = " << numEntities << ", " << tableOffset << ", "
    2813                 :          0 :               << metaDataOffset << std::endl;
    2814                 :          0 : }
    2815                 :            : 
    2816                 :          0 : void Tqdcfr::FEModelHeader::ArrayInfo::init( const std::vector< unsigned int >& uint_buf_in )
    2817                 :            : {
    2818                 :          0 :     numEntities    = uint_buf_in[0];
    2819                 :          0 :     tableOffset    = uint_buf_in[1];
    2820                 :          0 :     metaDataOffset = uint_buf_in[2];
    2821                 :          0 : }
    2822                 :            : 
    2823                 :          0 : void Tqdcfr::FEModelHeader::print()
    2824                 :            : {
    2825                 :          0 :     std::cout << "FEModelHeader:feEndian, feSchema, feCompressFlag, feLength = " << feEndian << ", " << feSchema << ", "
    2826                 :          0 :               << feCompressFlag << ", " << feLength << std::endl;
    2827                 :          0 :     std::cout << "geomArray: ";
    2828                 :          0 :     geomArray.print();
    2829                 :          0 :     std::cout << "nodeArray: ";
    2830                 :          0 :     nodeArray.print();
    2831                 :          0 :     std::cout << "elementArray: ";
    2832                 :          0 :     elementArray.print();
    2833                 :          0 :     std::cout << "groupArray: ";
    2834                 :          0 :     groupArray.print();
    2835                 :          0 :     std::cout << "blockArray: ";
    2836                 :          0 :     blockArray.print();
    2837                 :          0 :     std::cout << "nodesetArray: ";
    2838                 :          0 :     nodesetArray.print();
    2839                 :          0 :     std::cout << "sidesetArray: ";
    2840                 :          0 :     sidesetArray.print();
    2841                 :          0 : }
    2842                 :            : 
    2843                 :          0 : Tqdcfr::GeomHeader::GeomHeader()
    2844                 :            :     : geomID( 0 ), nodeCt( 0 ), nodeOffset( 0 ), elemCt( 0 ), elemOffset( 0 ), elemTypeCt( 0 ), elemLength( 0 ),
    2845                 :          0 :       maxDim( 0 ), setHandle( 0 )
    2846                 :            : {
    2847                 :          0 : }
    2848                 :            : 
    2849                 :          0 : void Tqdcfr::GeomHeader::print()
    2850                 :            : {
    2851                 :          0 :     std::cout << "geomID = " << geomID << std::endl;
    2852                 :          0 :     std::cout << "nodeCt = " << nodeCt << std::endl;
    2853                 :          0 :     std::cout << "nodeOffset = " << nodeOffset << std::endl;
    2854                 :          0 :     std::cout << "elemCt = " << elemCt << std::endl;
    2855                 :          0 :     std::cout << "elemOffset = " << elemOffset << std::endl;
    2856                 :          0 :     std::cout << "elemTypeCt = " << elemTypeCt << std::endl;
    2857                 :          0 :     std::cout << "elemLength = " << elemLength << std::endl;
    2858                 :          0 :     std::cout << "setHandle = " << setHandle << std::endl;
    2859                 :          0 : }
    2860                 :            : 
    2861                 :          0 : Tqdcfr::GroupHeader::GroupHeader()
    2862                 :          0 :     : grpID( 0 ), grpType( 0 ), memCt( 0 ), memOffset( 0 ), memTypeCt( 0 ), grpLength( 0 ), setHandle( 0 )
    2863                 :            : {
    2864                 :          0 : }
    2865                 :            : 
    2866                 :          0 : void Tqdcfr::GroupHeader::print()
    2867                 :            : {
    2868                 :          0 :     std::cout << "grpID = " << grpID << std::endl;
    2869                 :          0 :     std::cout << "grpType = " << grpType << std::endl;
    2870                 :          0 :     std::cout << "memCt = " << memCt << std::endl;
    2871                 :          0 :     std::cout << "memOffset = " << memOffset << std::endl;
    2872                 :          0 :     std::cout << "memTypeCt = " << memTypeCt << std::endl;
    2873                 :          0 :     std::cout << "grpLength = " << grpLength << std::endl;
    2874                 :          0 :     std::cout << "setHandle = " << setHandle << std::endl;
    2875                 :          0 : }
    2876                 :            : 
    2877                 :          0 : Tqdcfr::BlockHeader::BlockHeader()
    2878                 :            :     : blockID( 0 ), blockElemType( 0 ), memCt( 0 ), memOffset( 0 ), memTypeCt( 0 ), attribOrder( 0 ), blockCol( 0 ),
    2879                 :            :       blockMixElemType( 0 ), blockPyrType( 0 ), blockMat( 0 ), blockLength( 0 ), blockDim( 0 ), setHandle( 0 ),
    2880                 :          0 :       blockEntityType( MBMAXTYPE )
    2881                 :            : {
    2882                 :          0 : }
    2883                 :            : 
    2884                 :          0 : void Tqdcfr::BlockHeader::print()
    2885                 :            : {
    2886                 :          0 :     std::cout << "blockID = " << blockID << std::endl;
    2887                 :          0 :     std::cout << "blockElemType = " << blockElemType << std::endl;
    2888                 :          0 :     std::cout << "memCt = " << memCt << std::endl;
    2889                 :          0 :     std::cout << "memOffset = " << memOffset << std::endl;
    2890                 :          0 :     std::cout << "memTypeCt = " << memTypeCt << std::endl;
    2891                 :          0 :     std::cout << "attribOrder = " << attribOrder << std::endl;
    2892                 :          0 :     std::cout << "blockCol = " << blockCol << std::endl;
    2893                 :          0 :     std::cout << "blockMixElemType = " << blockMixElemType << std::endl;
    2894                 :          0 :     std::cout << "blockPyrType = " << blockPyrType << std::endl;
    2895                 :          0 :     std::cout << "blockMat = " << blockMat << std::endl;
    2896                 :          0 :     std::cout << "blockLength = " << blockLength << std::endl;
    2897                 :          0 :     std::cout << "blockDim = " << blockDim << std::endl;
    2898                 :          0 :     std::cout << "setHandle = " << setHandle << std::endl;
    2899                 :          0 :     std::cout << "blockEntityType = " << blockEntityType << std::endl;
    2900                 :          0 : }
    2901                 :            : 
    2902                 :          0 : Tqdcfr::NodesetHeader::NodesetHeader()
    2903                 :          0 :     : nsID( 0 ), memCt( 0 ), memOffset( 0 ), memTypeCt( 0 ), pointSym( 0 ), nsCol( 0 ), nsLength( 0 ), setHandle( 0 )
    2904                 :            : {
    2905                 :          0 : }
    2906                 :            : 
    2907                 :          0 : void Tqdcfr::NodesetHeader::print()
    2908                 :            : {
    2909                 :          0 :     std::cout << "nsID = " << nsID << std::endl;
    2910                 :          0 :     std::cout << "memCt = " << memCt << std::endl;
    2911                 :          0 :     std::cout << "memOffset = " << memOffset << std::endl;
    2912                 :          0 :     std::cout << "memTypeCt = " << memTypeCt << std::endl;
    2913                 :          0 :     std::cout << "pointSym = " << pointSym << std::endl;
    2914                 :          0 :     std::cout << "nsCol = " << nsCol << std::endl;
    2915                 :          0 :     std::cout << "nsLength = " << nsLength << std::endl;
    2916                 :          0 :     std::cout << "setHandle = " << setHandle << std::endl;
    2917                 :          0 : }
    2918                 :            : 
    2919                 :          0 : Tqdcfr::SidesetHeader::SidesetHeader()
    2920                 :            :     : ssID( 0 ), memCt( 0 ), memOffset( 0 ), memTypeCt( 0 ), numDF( 0 ), ssCol( 0 ), useShell( 0 ), ssLength( 0 ),
    2921                 :          0 :       setHandle( 0 )
    2922                 :            : {
    2923                 :          0 : }
    2924                 :            : 
    2925                 :          0 : void Tqdcfr::SidesetHeader::print()
    2926                 :            : {
    2927                 :          0 :     std::cout << "ssID = " << ssID << std::endl;
    2928                 :          0 :     std::cout << "memCt = " << memCt << std::endl;
    2929                 :          0 :     std::cout << "memOffset = " << memOffset << std::endl;
    2930                 :          0 :     std::cout << "memTypeCt = " << memTypeCt << std::endl;
    2931                 :          0 :     std::cout << "numDF = " << numDF << std::endl;
    2932                 :          0 :     std::cout << "ssCol = " << ssCol << std::endl;
    2933                 :          0 :     std::cout << "useShell = " << useShell << std::endl;
    2934                 :          0 :     std::cout << "ssLength = " << ssLength << std::endl;
    2935                 :          0 :     std::cout << "setHandle = " << setHandle << std::endl;
    2936                 :          0 : }
    2937                 :            : 
    2938                 :          0 : Tqdcfr::MetaDataContainer::MetaDataEntry::MetaDataEntry()
    2939 [ #  # ][ #  # ]:          0 :     : mdOwner( 0 ), mdDataType( 0 ), mdIntValue( 0 ), mdName( "(uninit)" ), mdStringValue( "(uninit)" ), mdDblValue( 0 )
         [ #  # ][ #  # ]
    2940                 :            : {
    2941                 :          0 : }
    2942                 :            : 
    2943                 :          0 : void Tqdcfr::MetaDataContainer::MetaDataEntry::print()
    2944                 :            : {
    2945                 :          0 :     std::cout << "MetaDataEntry:own, typ, name, I, D, S = " << mdOwner << ", " << mdDataType << ", " << mdName << ", "
    2946                 :          0 :               << mdIntValue << ", " << mdDblValue << ", " << mdStringValue;
    2947                 :            :     unsigned int i;
    2948         [ #  # ]:          0 :     if( mdIntArrayValue.size() )
    2949                 :            :     {
    2950                 :          0 :         std::cout << std::endl << "IArray = " << mdIntArrayValue[0];
    2951         [ #  # ]:          0 :         for( i = 1; i < mdIntArrayValue.size(); i++ )
    2952                 :          0 :             std::cout << ", " << mdIntArrayValue[i];
    2953                 :            :     }
    2954         [ #  # ]:          0 :     if( mdDblArrayValue.size() )
    2955                 :            :     {
    2956                 :          0 :         std::cout << std::endl << "DArray = " << mdDblArrayValue[0];
    2957         [ #  # ]:          0 :         for( i = 1; i < mdDblArrayValue.size(); i++ )
    2958                 :          0 :             std::cout << ", " << mdDblArrayValue[i];
    2959                 :            :     }
    2960                 :          0 :     std::cout << std::endl;
    2961                 :          0 : }
    2962                 :            : 
    2963                 :          0 : void Tqdcfr::MetaDataContainer::print()
    2964                 :            : {
    2965                 :          0 :     std::cout << "MetaDataContainer:mdSchema, compressFlag, numDatums = " << mdSchema << ", " << compressFlag << ", "
    2966                 :          0 :               << metadataEntries.size() << std::endl;
    2967                 :            : 
    2968         [ #  # ]:          0 :     for( unsigned int i = 0; i < metadataEntries.size(); i++ )
    2969                 :          0 :         metadataEntries[i].print();
    2970                 :          0 : }
    2971                 :            : 
    2972                 :          2 : Tqdcfr::MetaDataContainer::MetaDataContainer() : mdSchema( 0 ), compressFlag( 0 ) {}
    2973                 :            : 
    2974                 :          0 : int Tqdcfr::MetaDataContainer::get_md_entry( const unsigned int owner, const std::string& name )
    2975                 :            : {
    2976         [ #  # ]:          0 :     for( unsigned int i = 0; i < metadataEntries.size(); i++ )
    2977                 :            :     {
    2978 [ #  # ][ #  # ]:          0 :         if( owner == metadataEntries[i].mdOwner && name == metadataEntries[i].mdName ) return i;
                 [ #  # ]
    2979                 :            :     }
    2980                 :            : 
    2981                 :          0 :     return -1;
    2982                 :            : }
    2983                 :            : 
    2984                 :          0 : Tqdcfr::ModelEntry::ModelEntry()
    2985                 :            :     : modelHandle( 0 ), modelOffset( 0 ), modelLength( 0 ), modelType( 0 ), modelOwner( 0 ), modelPad( 0 ),
    2986 [ #  # ][ #  # ]:          0 :       feGeomH( NULL ), feGroupH( NULL ), feBlockH( NULL ), feNodeSetH( NULL ), feSideSetH( NULL )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2987                 :            : {
    2988                 :          0 : }
    2989                 :            : 
    2990                 :          0 : Tqdcfr::ModelEntry::~ModelEntry()
    2991                 :            : {
    2992         [ #  # ]:          0 :     delete[] feGeomH;
    2993         [ #  # ]:          0 :     delete[] feGroupH;
    2994         [ #  # ]:          0 :     delete[] feBlockH;
    2995         [ #  # ]:          0 :     delete[] feNodeSetH;
    2996         [ #  # ]:          0 :     delete[] feSideSetH;
    2997                 :          0 : }
    2998                 :            : 
    2999                 :          0 : void Tqdcfr::ModelEntry::print()
    3000                 :            : {
    3001                 :          0 :     std::cout << "ModelEntry: Han, Of, Len, Tp, Own, Pd = " << modelHandle << ", " << modelOffset << ", " << modelLength
    3002                 :          0 :               << ", " << modelType << ", " << modelOwner << ", " << modelPad << std::endl;
    3003                 :          0 : }
    3004                 :            : 
    3005                 :          0 : ErrorCode Tqdcfr::create_set( EntityHandle& h, unsigned int flags )
    3006                 :            : {
    3007                 :          0 :     return mdbImpl->create_meshset( flags, h );
    3008                 :            : }
    3009                 :            : 
    3010 [ +  - ][ +  - ]:        228 : }  // namespace moab

Generated by: LCOV version 1.11