LCOV - code coverage report
Current view: top level - src/io - ReadABAQUS.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 67 1036 6.5 %
Date: 2020-12-16 07:07:30 Functions: 9 43 20.9 %
Branches: 47 2850 1.6 %

           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                 :            : #ifdef WIN32
      17                 :            : #pragma warning( disable : 4786 )
      18                 :            : #endif
      19                 :            : 
      20                 :            : #include "ReadABAQUS.hpp"
      21                 :            : 
      22                 :            : #include <algorithm>
      23                 :            : #include <time.h>
      24                 :            : #include <string>
      25                 :            : #include <assert.h>
      26                 :            : #include <stdio.h>
      27                 :            : #include <cmath>
      28                 :            : 
      29                 :            : #include "moab/Range.hpp"
      30                 :            : #include "moab/Interface.hpp"
      31                 :            : #include "MBTagConventions.hpp"
      32                 :            : #include "Internals.hpp"
      33                 :            : #include "moab/ReadUtilIface.hpp"
      34                 :            : #include "AffineXform.hpp"
      35                 :            : // #include "abaqus_order.h"
      36                 :            : #include "moab/FileOptions.hpp"
      37                 :            : 
      38                 :            : namespace moab
      39                 :            : {
      40                 :            : 
      41                 :            : #define ABQ_AMBIGUOUS "AMBIGUOUS"
      42                 :            : #define ABQ_UNDEFINED "UNDEFINED"
      43                 :            : #define DEG2RAD       0.017453292519943295769236907684886
      44                 :            : 
      45                 :            : #define MB_RETURN_IF_FAIL \
      46                 :            :     if( MB_SUCCESS != status ) return status
      47                 :            : 
      48                 :          1 : ReaderIface* ReadABAQUS::factory( Interface* iface )
      49                 :            : {
      50         [ +  - ]:          1 :     return new ReadABAQUS( iface );
      51                 :            : }
      52                 :            : 
      53                 :          1 : ReadABAQUS::ReadABAQUS( Interface* impl )
      54 [ +  - ][ +  - ]:          1 :     : mdbImpl( impl ), readMeshIface( NULL ), lineNo( 0 ), next_line_type( abq_undefined_line ), mat_id( 0 )
         [ +  - ][ +  - ]
                 [ +  - ]
      55                 :            : {
      56         [ -  + ]:          1 :     assert( impl != NULL );
      57         [ +  - ]:          1 :     reset();
      58                 :            : 
      59         [ +  - ]:          1 :     impl->query_interface( readMeshIface );
      60                 :            : 
      61                 :            :     // Initialize in case tag_get_handle fails below
      62                 :          1 :     mMaterialSetTag  = 0;
      63                 :          1 :     mDirichletSetTag = 0;
      64                 :          1 :     mNeumannSetTag   = 0;
      65                 :          1 :     mHasMidNodesTag  = 0;
      66                 :            : 
      67                 :          1 :     mSetTypeTag        = 0;
      68                 :          1 :     mPartHandleTag     = 0;
      69                 :          1 :     mInstancePIDTag    = 0;
      70                 :          1 :     mInstanceGIDTag    = 0;
      71                 :          1 :     mLocalIDTag        = 0;
      72                 :          1 :     mInstanceHandleTag = 0;
      73                 :          1 :     mAssemblyHandleTag = 0;
      74                 :          1 :     mSetNameTag        = 0;
      75                 :          1 :     mMatNameTag        = 0;
      76                 :            : 
      77                 :            :     //! Get and cache predefined tag handles
      78                 :          1 :     int negone = -1, negonearr[] = { -1, -1, -1, -1 };
      79         [ +  - ]:          1 :     mMaterialSetTag  = get_tag( MATERIAL_SET_TAG_NAME, 1, MB_TAG_SPARSE, MB_TYPE_INTEGER, &negone );
      80         [ +  - ]:          1 :     mDirichletSetTag = get_tag( DIRICHLET_SET_TAG_NAME, 1, MB_TAG_SPARSE, MB_TYPE_INTEGER, &negone );
      81         [ +  - ]:          1 :     mNeumannSetTag   = get_tag( NEUMANN_SET_TAG_NAME, 1, MB_TAG_SPARSE, MB_TYPE_INTEGER, &negone );
      82         [ +  - ]:          1 :     mHasMidNodesTag  = get_tag( HAS_MID_NODES_TAG_NAME, 4, MB_TAG_SPARSE, MB_TYPE_INTEGER, negonearr );
      83                 :            : 
      84         [ +  - ]:          1 :     mSetTypeTag        = get_tag( ABAQUS_SET_TYPE_TAG_NAME, 1, MB_TAG_SPARSE, MB_TYPE_INTEGER );
      85         [ +  - ]:          1 :     mPartHandleTag     = get_tag( ABAQUS_PART_HANDLE_TAG_NAME, 1, MB_TAG_SPARSE, MB_TYPE_HANDLE );
      86         [ +  - ]:          1 :     mInstanceHandleTag = get_tag( ABAQUS_INSTANCE_HANDLE_TAG_NAME, 1, MB_TAG_DENSE, MB_TYPE_HANDLE );
      87         [ +  - ]:          1 :     mAssemblyHandleTag = get_tag( ABAQUS_ASSEMBLY_HANDLE_TAG_NAME, 1, MB_TAG_DENSE, MB_TYPE_HANDLE );
      88         [ +  - ]:          1 :     mInstancePIDTag    = get_tag( ABAQUS_INSTANCE_PART_ID_TAG_NAME, 1, MB_TAG_SPARSE, MB_TYPE_INTEGER );
      89         [ +  - ]:          1 :     mInstanceGIDTag    = get_tag( ABAQUS_INSTANCE_GLOBAL_ID_TAG_NAME, 1, MB_TAG_SPARSE, MB_TYPE_INTEGER, &negone );
      90         [ +  - ]:          1 :     mLocalIDTag        = get_tag( ABAQUS_LOCAL_ID_TAG_NAME, 1, MB_TAG_DENSE, MB_TYPE_INTEGER );
      91         [ +  - ]:          1 :     mSetNameTag        = get_tag( ABAQUS_SET_NAME_TAG_NAME, ABAQUS_SET_NAME_LENGTH, MB_TAG_SPARSE, MB_TYPE_OPAQUE, 0 );
      92         [ +  - ]:          1 :     mMatNameTag        = get_tag( ABAQUS_MAT_NAME_TAG_NAME, ABAQUS_MAT_NAME_LENGTH, MB_TAG_SPARSE, MB_TYPE_OPAQUE, 0 );
      93                 :          1 : }
      94                 :            : 
      95                 :          1 : void ReadABAQUS::reset() {}
      96                 :            : 
      97                 :          3 : ReadABAQUS::~ReadABAQUS()
      98                 :            : {
      99                 :          1 :     mdbImpl->release_interface( readMeshIface );
     100         [ -  + ]:          1 :     if( abFile.fail() ) abFile.close();
     101         [ -  + ]:          2 : }
     102                 :            : 
     103                 :            : /*
     104                 :            : 
     105                 :            : ErrorCode ReadABAQUS::check_file_stats()
     106                 :            : * check for existence of file
     107                 :            : * initialize meshsets, and offsets if necessary
     108                 :            : 
     109                 :            : */
     110                 :            : 
     111                 :          0 : ErrorCode ReadABAQUS::read_tag_values( const char* /* file_name */, const char* /* tag_name */,
     112                 :            :                                        const FileOptions& /* opts */, std::vector< int >& /* tag_values_out */,
     113                 :            :                                        const SubsetList* /* subset_list */ )
     114                 :            : {
     115                 :          0 :     return MB_NOT_IMPLEMENTED;
     116                 :            : }
     117                 :            : 
     118                 :          1 : ErrorCode ReadABAQUS::load_file( const char* abaqus_file_name, const EntityHandle* file_set_ptr,
     119                 :            :                                  const FileOptions& /*opts*/, const ReaderIface::SubsetList* subset_list,
     120                 :            :                                  const Tag* /*file_id_tag*/ )
     121                 :            : {
     122                 :            :     ErrorCode status;
     123                 :            : 
     124         [ -  + ]:          1 :     if( subset_list )
     125 [ #  # ][ #  # ]:          0 :     { MB_SET_ERR( MB_UNSUPPORTED_OPERATION, "Reading subset of files not supported for ABAQUS data" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     126                 :            : 
     127                 :            :     // Open file
     128                 :          1 :     lineNo = 0;
     129         [ +  - ]:          1 :     abFile.open( abaqus_file_name );
     130 [ +  - ][ -  + ]:          1 :     if( !abFile ) return MB_FILE_DOES_NOT_EXIST;
     131                 :            : 
     132                 :          1 :     bool in_unsupported = false;
     133                 :            : 
     134                 :            :     EntityHandle file_set;
     135         [ +  - ]:          1 :     status = mdbImpl->create_meshset( MESHSET_SET, file_set );
     136         [ -  + ]:          1 :     if( MB_SUCCESS != status ) return status;
     137                 :            : 
     138         [ +  - ]:          1 :     next_line_type = get_next_line_type();
     139         [ +  - ]:          1 :     while( next_line_type != abq_eof )
     140                 :            :     {
     141   [ -  -  +  - ]:          1 :         switch( next_line_type )
     142                 :            :         {
     143                 :            :             case abq_keyword_line:
     144                 :          0 :                 in_unsupported = false;
     145         [ #  # ]:          0 :                 switch( get_keyword() )
           [ #  #  #  # ]
     146                 :            :                 {
     147                 :            :                     case abq_heading:
     148                 :            :                         // Read header
     149         [ #  # ]:          0 :                         status = read_heading( file_set );
     150                 :          0 :                         break;
     151                 :            :                     case abq_part:
     152                 :            :                         // Read parts until done
     153         [ #  # ]:          0 :                         status = read_part( file_set );
     154                 :          0 :                         break;
     155                 :            :                     case abq_assembly:
     156                 :            :                         // Read assembly (or assemblies?)
     157         [ #  # ]:          0 :                         status = read_assembly( file_set );
     158                 :          0 :                         break;
     159                 :            :                     default:
     160                 :            :                         // Skip reading other content for now
     161                 :            :                         // (e.g. material properties, loads, surface interactions, etc)
     162                 :          0 :                         in_unsupported = true;
     163                 :            :                         // std::cout << "Ignoring unsupported keyword: " << readline << std::endl;
     164                 :            :                 }
     165         [ #  # ]:          0 :                 MB_RETURN_IF_FAIL;
     166                 :          0 :                 break;
     167                 :            :             case abq_comment_line:
     168                 :          0 :                 break;
     169                 :            :             case abq_data_line:
     170 [ +  - ][ +  - ]:          1 :                 if( !in_unsupported ) { MB_SET_ERR( MB_FAILURE, "Expected Keyword" ); }
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
     171                 :          0 :                 break;
     172                 :            :             default:
     173 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Invalid/unrecognized line" );
         [ #  # ][ #  # ]
                 [ #  # ]
     174                 :            :         }
     175                 :            : 
     176         [ #  # ]:          0 :         next_line_type = get_next_line_type();
     177                 :            :     }
     178                 :            : 
     179                 :            :     // Temporary??? delete parts
     180                 :            :     // Get all node sets in part
     181         [ #  # ]:          0 :     Range part_sets;
     182                 :          0 :     int tag_val      = ABQ_PART_SET;
     183                 :          0 :     void* tag_data[] = { &tag_val };
     184         [ #  # ]:          0 :     status = mdbImpl->get_entities_by_type_and_tag( file_set, MBENTITYSET, &mSetTypeTag, tag_data, 1, part_sets );
     185         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     186                 :            : 
     187 [ #  # ][ #  # ]:          0 :     for( Range::iterator part_set = part_sets.begin(); part_set != part_sets.end(); ++part_set )
         [ #  # ][ #  # ]
                 [ #  # ]
     188                 :            :     {
     189         [ #  # ]:          0 :         Range ent_sets;
     190                 :          0 :         tag_val     = ABQ_NODE_SET;
     191                 :          0 :         tag_data[0] = &tag_val;
     192                 :            : 
     193 [ #  # ][ #  # ]:          0 :         status = mdbImpl->get_entities_by_type_and_tag( *part_set, MBENTITYSET, &mSetTypeTag, tag_data, 1, ent_sets );
     194         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     195                 :            : 
     196         [ #  # ]:          0 :         status = mdbImpl->delete_entities( ent_sets );
     197         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     198                 :            : 
     199                 :          0 :         tag_val     = ABQ_ELEMENT_SET;
     200                 :          0 :         tag_data[0] = &tag_val;
     201                 :            : 
     202 [ #  # ][ #  # ]:          0 :         status = mdbImpl->get_entities_by_type_and_tag( *part_set, MBENTITYSET, &mSetTypeTag, tag_data, 1, ent_sets );
     203         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     204                 :            : 
     205         [ #  # ]:          0 :         status = mdbImpl->delete_entities( ent_sets );
     206         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     207                 :            : 
     208 [ #  # ][ #  # ]:          0 :         Range node_list, ele_list;
         [ #  # ][ #  # ]
     209 [ #  # ][ #  # ]:          0 :         status = get_set_elements( *part_set, ele_list );
     210         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     211                 :            : 
     212         [ #  # ]:          0 :         status = mdbImpl->delete_entities( ele_list );
     213         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     214                 :            : 
     215 [ #  # ][ #  # ]:          0 :         status = mdbImpl->get_entities_by_dimension( *part_set, 0, node_list );
     216         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     217                 :            : 
     218         [ #  # ]:          0 :         status = mdbImpl->delete_entities( node_list );
     219 [ #  # ][ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     220                 :          0 :     }
     221                 :            : 
     222         [ #  # ]:          0 :     if( file_set_ptr )
     223                 :            :     {
     224         [ #  # ]:          0 :         status = mdbImpl->unite_meshset( *file_set_ptr, file_set );
     225         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     226                 :            :     }
     227                 :            : 
     228         [ #  # ]:          1 :     return mdbImpl->delete_entities( &file_set, 1 );
     229                 :            : }
     230                 :            : 
     231                 :          0 : ErrorCode ReadABAQUS::read_heading( EntityHandle /*file_set*/ )
     232                 :            : {
     233                 :            :     // Current line is only heading token. get next line
     234                 :          0 :     next_line_type = get_next_line_type();
     235                 :            : 
     236                 :            :     // Perhaps keep first line and tag geometry with title?
     237                 :            : 
     238 [ #  # ][ #  # ]:          0 :     while( abq_data_line == next_line_type || abq_comment_line == next_line_type )
     239                 :          0 :         next_line_type = get_next_line_type();
     240                 :            : 
     241                 :          0 :     return MB_SUCCESS;
     242                 :            : }
     243                 :            : 
     244                 :          0 : ErrorCode ReadABAQUS::read_assembly( EntityHandle file_set )
     245                 :            : {
     246                 :          0 :     ErrorCode status = MB_SUCCESS;
     247                 :            : 
     248         [ #  # ]:          0 :     std::vector< std::string > tokens;
     249         [ #  # ]:          0 :     std::map< std::string, std::string > params;
     250         [ #  # ]:          0 :     std::map< std::string, abaqus_assembly_params > requiredParams;
     251 [ #  # ][ #  # ]:          0 :     requiredParams["NAME"] = abq_assembly_name;
     252                 :            : 
     253         [ #  # ]:          0 :     std::map< std::string, abaqus_assembly_params > allowableParams;
     254 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_assembly_ambiguous;
     255                 :            : 
     256                 :            :     abaqus_assembly_params param;
     257                 :            : 
     258         [ #  # ]:          0 :     std::string assembly_name;
     259                 :            : 
     260                 :            :     // Tokenize last line read
     261         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
     262         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
     263                 :            : 
     264                 :            :     // Search for required parameters
     265 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, abaqus_assembly_params >::iterator thisParam = requiredParams.begin();
                 [ #  # ]
     266                 :          0 :          thisParam != requiredParams.end(); ++thisParam )
     267                 :            :     {
     268 [ #  # ][ #  # ]:          0 :         std::string param_key = match( ( *thisParam ).first, params );
     269         [ #  # ]:          0 :         param                 = requiredParams[param_key];
     270         [ #  # ]:          0 :         switch( param )
     271                 :            :         {
     272                 :            :             case abq_assembly_name:
     273 [ #  # ][ #  # ]:          0 :                 assembly_name = params[param_key];
     274         [ #  # ]:          0 :                 params.erase( param_key );
     275                 :            :                 // std::cout << "Adding ASSEMBLY with name: " << assembly_name << std::endl; //
     276                 :            :                 // REMOVE
     277                 :          0 :                 break;
     278                 :            :             default:
     279                 :            :                 // std::cout << "Missing required ASSEMBLY parameter " << (*thisParam).first <<
     280                 :            :                 // std::endl;
     281         [ #  # ]:          0 :                 return MB_FAILURE;
     282                 :            :         }
     283                 :          0 :     }
     284                 :            : 
     285                 :            :     // Process parameters
     286 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
     287                 :            :          ++thisParam )
     288                 :            :     {
     289                 :            :         // Look for unambiguous match with this node parameter
     290 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
     291         [ #  # ]:          0 :         switch( param )
     292                 :            :         {
     293                 :            :             case abq_assembly_ambiguous:
     294                 :            :                 // std::cout << "\tIgnoring ambiguous ASSEMBLY parameter: " << (*thisParam).first
     295                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     296                 :          0 :                 break;
     297                 :            :             default:
     298                 :            :                 // std::cout << "\tIgnoring unsupported ASSEMBLY parameter: " << (*thisParam).first
     299                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     300                 :          0 :                 break;
     301                 :            :         }
     302                 :            :     }
     303                 :            : 
     304                 :            :     EntityHandle assembly_set;
     305                 :            : 
     306         [ #  # ]:          0 :     status = add_entity_set( file_set, ABQ_ASSEMBLY_SET, assembly_name, assembly_set );
     307                 :            : 
     308         [ #  # ]:          0 :     next_line_type = get_next_line_type();
     309                 :            : 
     310                 :          0 :     bool end_assembly   = false;
     311                 :          0 :     bool in_unsupported = false;
     312                 :            : 
     313 [ #  # ][ #  # ]:          0 :     while( next_line_type != abq_eof && !end_assembly )
     314                 :            :     {
     315   [ #  #  #  #  :          0 :         switch( next_line_type )
                      # ]
     316                 :            :         {
     317                 :            :             case abq_keyword_line:
     318                 :          0 :                 in_unsupported = false;
     319         [ #  # ]:          0 :                 switch( get_keyword() )
           [ #  #  #  # ]
     320                 :            :                 {
     321                 :            :                     case abq_end_assembly:
     322                 :          0 :                         end_assembly = true;
     323                 :          0 :                         break;
     324                 :            :                     case abq_instance:
     325         [ #  # ]:          0 :                         status = read_instance( assembly_set, file_set );
     326                 :          0 :                         break;
     327                 :            :                     case abq_nset:
     328         [ #  # ]:          0 :                         status = read_node_set( assembly_set, file_set );
     329                 :          0 :                         break;
     330                 :            :                     default:
     331                 :          0 :                         in_unsupported = true;
     332                 :            :                         // std::cout << "\tIgnoring unsupported keyword in this ASSEMBLY: "
     333                 :            :                         //          << readline << std::endl;
     334         [ #  # ]:          0 :                         next_line_type = get_next_line_type();
     335                 :          0 :                         break;
     336                 :            :                 }
     337                 :          0 :                 break;
     338                 :            :             case abq_comment_line:
     339         [ #  # ]:          0 :                 next_line_type = get_next_line_type();
     340                 :          0 :                 break;
     341                 :            :             case abq_data_line:
     342         [ #  # ]:          0 :                 if( !in_unsupported )
     343                 :            :                 {
     344                 :            :                     // std::cout << "Internal Error: Data lines not allowed in ASSEMBLY keyword."
     345                 :            :                     //          << std::endl << readline << std::endl;
     346                 :          0 :                     return MB_FAILURE;
     347                 :            :                 }
     348         [ #  # ]:          0 :                 next_line_type = get_next_line_type();
     349                 :          0 :                 break;
     350                 :            :             case abq_blank_line:
     351                 :            :                 // std::cout << "Error: Blank lines are not allowed." << std::endl;
     352                 :          0 :                 return MB_FAILURE;
     353                 :            :             default:
     354                 :            :                 // std::cout << "Error reading ASSEMBLY " << assembly_name << std::endl;
     355                 :          0 :                 return MB_FAILURE;
     356                 :            :         }
     357         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     358                 :            :     }
     359                 :            : 
     360         [ #  # ]:          0 :     num_assembly_instances[assembly_set] = 0;
     361                 :            : 
     362                 :          0 :     return MB_SUCCESS;
     363                 :            : }
     364                 :            : 
     365                 :          0 : ErrorCode ReadABAQUS::read_instance( EntityHandle assembly_set, EntityHandle file_set )
     366                 :            : {
     367                 :          0 :     ErrorCode status = MB_SUCCESS;
     368                 :            : 
     369         [ #  # ]:          0 :     std::vector< std::string > tokens;
     370         [ #  # ]:          0 :     std::map< std::string, std::string > params;
     371         [ #  # ]:          0 :     std::map< std::string, abaqus_instance_params > requiredParams;
     372 [ #  # ][ #  # ]:          0 :     requiredParams["NAME"] = abq_instance_name;
     373 [ #  # ][ #  # ]:          0 :     requiredParams["PART"] = abq_instance_part;
     374                 :            : 
     375         [ #  # ]:          0 :     std::map< std::string, abaqus_instance_params > allowableParams;
     376 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_instance_ambiguous;
     377                 :            : 
     378                 :            :     abaqus_instance_params param;
     379                 :            : 
     380 [ #  # ][ #  # ]:          0 :     std::string instance_name, part_name;
     381                 :            : 
     382                 :            :     // Tokenize last line read
     383         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
     384         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
     385                 :            : 
     386                 :            :     // Search for required parameters
     387 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, abaqus_instance_params >::iterator thisParam = requiredParams.begin();
                 [ #  # ]
     388                 :          0 :          thisParam != requiredParams.end(); ++thisParam )
     389                 :            :     {
     390 [ #  # ][ #  # ]:          0 :         std::string param_key = match( ( *thisParam ).first, params );
     391         [ #  # ]:          0 :         param                 = requiredParams[param_key];
     392      [ #  #  # ]:          0 :         switch( param )
     393                 :            :         {
     394                 :            :             case abq_instance_name:
     395 [ #  # ][ #  # ]:          0 :                 instance_name = params[param_key];
     396         [ #  # ]:          0 :                 params.erase( param_key );
     397                 :          0 :                 break;
     398                 :            :             case abq_instance_part:
     399 [ #  # ][ #  # ]:          0 :                 part_name = params[param_key];
     400         [ #  # ]:          0 :                 params.erase( param_key );
     401                 :          0 :                 break;
     402                 :            :             default:
     403                 :            :                 // std::cout << "Missing required INSTANCE parameter " << (*thisParam).first <<
     404                 :            :                 // std::endl;
     405         [ #  # ]:          0 :                 return MB_FAILURE;
     406                 :            :         }
     407                 :          0 :     }
     408                 :            :     // std::cout << "\tAdding INSTANCE with name: " << instance_name << " of PART wit name: " <<
     409                 :            :     // part_name <<  std::endl; // REMOVE
     410                 :            : 
     411                 :            :     // Process parameters
     412 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
     413                 :            :          ++thisParam )
     414                 :            :     {
     415                 :            :         // Look for unambiguous match with this node parameter
     416 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
     417         [ #  # ]:          0 :         switch( param )
     418                 :            :         {
     419                 :            :             case abq_instance_ambiguous:
     420                 :            :                 // std::cout << "\t\tIgnoring ambiguous INSTANCE parameter: " << (*thisParam).first
     421                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     422                 :          0 :                 break;
     423                 :            :             default:
     424                 :            :                 // std::cout << "\t\tIgnoring unsupported INSTANCE parameter: " <<
     425                 :            :                 // (*thisParam).first
     426                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     427                 :          0 :                 break;
     428                 :            :         }
     429                 :            :     }
     430                 :            : 
     431         [ #  # ]:          0 :     next_line_type = get_next_line_type();
     432                 :            : 
     433                 :          0 :     bool read_translation = false;
     434                 :          0 :     bool read_rotation    = false;
     435         [ #  # ]:          0 :     std::vector< double > translation( 3, 0 );
     436         [ #  # ]:          0 :     std::vector< double > rotation( 7, 0 );
     437                 :          0 :     bool end_instance   = false;
     438                 :          0 :     bool in_unsupported = false;
     439                 :            : 
     440                 :            :     EntityHandle instance_set;
     441         [ #  # ]:          0 :     status = add_entity_set( assembly_set, ABQ_INSTANCE_SET, instance_name, instance_set );
     442         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     443                 :            : 
     444 [ #  # ][ #  # ]:          0 :     while( next_line_type != abq_eof && !end_instance )
     445                 :            :     {
     446   [ #  #  #  #  :          0 :         switch( next_line_type )
                      # ]
     447                 :            :         {
     448                 :            :             case abq_keyword_line:
     449                 :          0 :                 in_unsupported = false;
     450 [ #  # ][ #  #  :          0 :                 switch( get_keyword() )
             #  #  #  #  
                      # ]
     451                 :            :                 {
     452                 :            :                     case abq_end_instance:
     453                 :          0 :                         end_instance   = true;
     454         [ #  # ]:          0 :                         next_line_type = get_next_line_type();
     455                 :          0 :                         break;
     456                 :            :                     case abq_node:
     457         [ #  # ]:          0 :                         status = read_node_list( instance_set, assembly_set );
     458                 :          0 :                         break;
     459                 :            :                     case abq_element:
     460         [ #  # ]:          0 :                         status = read_element_list( instance_set, assembly_set );
     461                 :          0 :                         break;
     462                 :            :                     case abq_nset:
     463         [ #  # ]:          0 :                         status = read_node_set( instance_set, file_set, assembly_set );
     464                 :          0 :                         break;
     465                 :            :                     case abq_elset:
     466         [ #  # ]:          0 :                         status = read_element_set( instance_set, file_set, assembly_set );
     467                 :          0 :                         break;
     468                 :            :                     case abq_solid_section:
     469         [ #  # ]:          0 :                         status = read_solid_section( instance_set );
     470                 :          0 :                         break;
     471                 :            :                     default:
     472                 :          0 :                         in_unsupported = true;
     473                 :            :                         // std::cout << "\t\tIgnoring unsupported keyword in this INSTANCE: "
     474                 :            :                         //          << readline << std::endl;
     475         [ #  # ]:          0 :                         next_line_type = get_next_line_type();
     476                 :          0 :                         break;
     477                 :            :                 }
     478                 :          0 :                 break;
     479                 :            :             case abq_comment_line:
     480         [ #  # ]:          0 :                 next_line_type = get_next_line_type();
     481                 :          0 :                 break;
     482                 :            :             case abq_data_line:
     483         [ #  # ]:          0 :                 if( !in_unsupported )
     484                 :            :                 {
     485         [ #  # ]:          0 :                     tokenize( readline, tokens, ", \n" );
     486         [ #  # ]:          0 :                     if( !read_translation )
     487                 :            :                     {
     488         [ #  # ]:          0 :                         if( tokens.size() != 3 )
     489 [ #  # ][ #  # ]:          0 :                         { MB_SET_ERR( MB_FAILURE, "Wrong number of entries on INSTANCE translation line" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     490                 :            : 
     491         [ #  # ]:          0 :                         for( unsigned int i = 0; i < 3; i++ )
     492 [ #  # ][ #  # ]:          0 :                             translation[i] = atof( tokens[i].c_str() );
     493                 :            : 
     494                 :          0 :                         read_translation = true;
     495                 :            :                     }
     496         [ #  # ]:          0 :                     else if( !read_rotation )
     497                 :            :                     {
     498         [ #  # ]:          0 :                         if( tokens.size() != 7 )
     499 [ #  # ][ #  # ]:          0 :                         { MB_SET_ERR( MB_FAILURE, "Wrong number of entries on INSTANCE rotation line" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     500         [ #  # ]:          0 :                         for( unsigned int i = 0; i < 7; i++ )
     501 [ #  # ][ #  # ]:          0 :                             rotation[i] = atof( tokens[i].c_str() );
     502                 :            : 
     503                 :          0 :                         read_rotation = true;
     504                 :            :                     }
     505                 :            :                     else
     506                 :            :                     {
     507 [ #  # ][ #  # ]:          0 :                         MB_SET_ERR( MB_FAILURE, "Too many data lines for this INSTANCE" );
         [ #  # ][ #  # ]
                 [ #  # ]
     508                 :            :                     }
     509                 :            :                 }  // if (!in_unsupported)
     510         [ #  # ]:          0 :                 next_line_type = get_next_line_type();
     511                 :          0 :                 break;
     512                 :            :             case abq_blank_line:
     513 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Error: Blank lines are not allowed" );
         [ #  # ][ #  # ]
                 [ #  # ]
     514                 :            :             default:
     515 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Error reading INSTANCE" );
         [ #  # ][ #  # ]
                 [ #  # ]
     516                 :            :         }  // switch (next_line_type)
     517                 :            :     }      // while (next_line_type != abq_eof && !end_instance)
     518                 :            : 
     519                 :            :     status = create_instance_of_part( file_set, assembly_set, part_name, instance_name, instance_set, translation,
     520         [ #  # ]:          0 :                                       rotation );
     521         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     522                 :            : 
     523                 :          0 :     return MB_SUCCESS;
     524                 :            : }
     525                 :            : 
     526                 :          0 : ErrorCode ReadABAQUS::read_part( EntityHandle file_set )
     527                 :            : {
     528                 :          0 :     ErrorCode status = MB_SUCCESS;
     529                 :            : 
     530         [ #  # ]:          0 :     std::vector< std::string > tokens;
     531         [ #  # ]:          0 :     std::map< std::string, std::string > params;
     532         [ #  # ]:          0 :     std::map< std::string, abaqus_part_params > requiredParams;
     533 [ #  # ][ #  # ]:          0 :     requiredParams["NAME"] = abq_part_name;
     534                 :            : 
     535         [ #  # ]:          0 :     std::map< std::string, abaqus_part_params > allowableParams;
     536 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_part_ambiguous;
     537                 :            : 
     538                 :            :     abaqus_part_params param;
     539                 :            : 
     540         [ #  # ]:          0 :     std::string part_name;
     541                 :            : 
     542                 :            :     // Tokenize last line read
     543         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
     544         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
     545                 :            : 
     546                 :            :     // Search for required parameters
     547 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, abaqus_part_params >::iterator thisParam = requiredParams.begin();
                 [ #  # ]
     548                 :          0 :          thisParam != requiredParams.end(); ++thisParam )
     549                 :            :     {
     550 [ #  # ][ #  # ]:          0 :         std::string param_key = match( ( *thisParam ).first, params );
     551         [ #  # ]:          0 :         param                 = requiredParams[param_key];
     552         [ #  # ]:          0 :         switch( param )
     553                 :            :         {
     554                 :            :             case abq_part_name:
     555 [ #  # ][ #  # ]:          0 :                 part_name = params[param_key];
     556         [ #  # ]:          0 :                 params.erase( param_key );
     557                 :            :                 // std::cout << "Adding PART with name: " << part_name << std::endl; // REMOVE
     558                 :          0 :                 break;
     559                 :            :             default:
     560 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Missing required PART parameter" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     561                 :            :         }
     562                 :          0 :     }
     563                 :            : 
     564                 :            :     // Process parameters
     565 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
     566                 :            :          ++thisParam )
     567                 :            :     {
     568                 :            :         // Look for unambiguous match with this node parameter
     569 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
     570         [ #  # ]:          0 :         switch( param )
     571                 :            :         {
     572                 :            :             case abq_part_ambiguous:
     573                 :            :                 // std::cout << "\tIgnoring ambiguous PART parameter: " << (*thisParam).first
     574                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     575                 :          0 :                 break;
     576                 :            :             default:
     577                 :            :                 // std::cout << "\tIgnoring unsupported PART parameter: " << (*thisParam).first
     578                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     579                 :          0 :                 break;
     580                 :            :         }
     581                 :            :     }
     582                 :            : 
     583                 :            :     EntityHandle part_set;
     584                 :            : 
     585         [ #  # ]:          0 :     status = add_entity_set( file_set, ABQ_PART_SET, part_name, part_set );
     586                 :            : 
     587         [ #  # ]:          0 :     next_line_type = get_next_line_type();
     588                 :            : 
     589                 :          0 :     bool end_part       = false;
     590                 :          0 :     bool in_unsupported = false;
     591                 :            : 
     592 [ #  # ][ #  # ]:          0 :     while( next_line_type != abq_eof && !end_part )
     593                 :            :     {
     594   [ #  #  #  #  :          0 :         switch( next_line_type )
                      # ]
     595                 :            :         {
     596                 :            :             case abq_keyword_line:
     597                 :          0 :                 in_unsupported = false;
     598 [ #  # ][ #  #  :          0 :                 switch( get_keyword() )
             #  #  #  #  
                      # ]
     599                 :            :                 {
     600                 :            :                     case abq_end_part:
     601                 :          0 :                         end_part = true;
     602                 :          0 :                         break;
     603                 :            :                     case abq_node:
     604         [ #  # ]:          0 :                         status = read_node_list( part_set );
     605                 :          0 :                         break;
     606                 :            :                     case abq_element:
     607         [ #  # ]:          0 :                         status = read_element_list( part_set );
     608                 :          0 :                         break;
     609                 :            :                     case abq_nset:
     610         [ #  # ]:          0 :                         status = read_node_set( part_set );
     611                 :          0 :                         break;
     612                 :            :                     case abq_elset:
     613         [ #  # ]:          0 :                         status = read_element_set( part_set );
     614                 :          0 :                         break;
     615                 :            :                     case abq_solid_section:
     616         [ #  # ]:          0 :                         status = read_solid_section( part_set );
     617                 :          0 :                         break;
     618                 :            :                     default:
     619                 :          0 :                         in_unsupported = true;
     620                 :            :                         // std::cout << "\tIgnoring unsupported keyword in this PART: "
     621                 :            :                         //          << readline << std::endl;
     622         [ #  # ]:          0 :                         next_line_type = get_next_line_type();
     623                 :          0 :                         break;
     624                 :            :                 }
     625         [ #  # ]:          0 :                 MB_RETURN_IF_FAIL;
     626                 :          0 :                 break;
     627                 :            :             case abq_comment_line:
     628         [ #  # ]:          0 :                 next_line_type = get_next_line_type();
     629                 :          0 :                 break;
     630                 :            :             case abq_data_line:
     631 [ #  # ][ #  # ]:          0 :                 if( !in_unsupported ) { MB_SET_ERR( MB_FAILURE, "Data lines not allowed in PART keyword" ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     632         [ #  # ]:          0 :                 next_line_type = get_next_line_type();
     633                 :          0 :                 break;
     634                 :            :             case abq_blank_line:
     635 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Blank lines are not allowed" );
         [ #  # ][ #  # ]
                 [ #  # ]
     636                 :            :             default:
     637 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Error reading PART" );
         [ #  # ][ #  # ]
                 [ #  # ]
     638                 :            :         }
     639                 :            :     }
     640                 :            : 
     641         [ #  # ]:          0 :     num_part_instances[part_set] = 0;
     642                 :            : 
     643                 :          0 :     return MB_SUCCESS;
     644                 :            : }
     645                 :            : 
     646                 :          0 : ErrorCode ReadABAQUS::read_solid_section( EntityHandle parent_set )
     647                 :            : {
     648                 :            :     ErrorCode status;
     649                 :            : 
     650         [ #  # ]:          0 :     std::vector< std::string > tokens;
     651         [ #  # ]:          0 :     std::map< std::string, std::string > params;
     652         [ #  # ]:          0 :     std::map< std::string, abaqus_solid_section_params > requiredParams;
     653 [ #  # ][ #  # ]:          0 :     requiredParams["ELSET"]    = abq_solid_section_elset;
     654 [ #  # ][ #  # ]:          0 :     requiredParams["MATERIAL"] = abq_solid_section_matname;
     655                 :            : 
     656         [ #  # ]:          0 :     std::map< std::string, abaqus_solid_section_params > allowableParams;
     657 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_solid_section_ambiguous;
     658                 :            : 
     659                 :            :     abaqus_solid_section_params param;
     660                 :            : 
     661                 :            :     // Tokenize last line read
     662         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
     663         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
     664                 :            : 
     665 [ #  # ][ #  # ]:          0 :     std::string elset_name, mat_name;
     666                 :            : 
     667                 :            :     // Search for required parameters
     668 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, abaqus_solid_section_params >::iterator thisParam = requiredParams.begin();
                 [ #  # ]
     669                 :          0 :          thisParam != requiredParams.end(); ++thisParam )
     670                 :            :     {
     671 [ #  # ][ #  # ]:          0 :         std::string param_key = match( ( *thisParam ).first, params );
     672         [ #  # ]:          0 :         param                 = requiredParams[param_key];
     673      [ #  #  # ]:          0 :         switch( param )
     674                 :            :         {
     675                 :            :             case abq_solid_section_elset:
     676 [ #  # ][ #  # ]:          0 :                 elset_name = params[param_key];
     677         [ #  # ]:          0 :                 params.erase( param_key );
     678                 :          0 :                 break;
     679                 :            :             case abq_solid_section_matname:
     680 [ #  # ][ #  # ]:          0 :                 mat_name = params[param_key];
     681         [ #  # ]:          0 :                 params.erase( param_key );
     682                 :          0 :                 break;
     683                 :            :             default:
     684 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Missing required SOLID SECTION parameter" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     685                 :            :         }
     686                 :          0 :     }
     687                 :            :     // std::cout << "\tAdding SOLID SECTION with to ELEMENT SET: " << elset_name << " with material:
     688                 :            :     // " << mat_name << std::endl; // REMOVE
     689                 :            : 
     690                 :            :     // Process parameters
     691 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
     692                 :            :          ++thisParam )
     693                 :            :     {
     694                 :            :         // Look for unambiguous match with this node parameter
     695 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
     696         [ #  # ]:          0 :         switch( param )
     697                 :            :         {
     698                 :            :             case abq_solid_section_ambiguous:
     699                 :            :                 // std::cout << "\t\tIgnoring ambiguous SOLID_SECTION parameter: " <<
     700                 :            :                 // (*thisParam).first
     701                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     702                 :          0 :                 break;
     703                 :            :             default:
     704                 :            :                 // std::cout << "\t\tIgnoring unsupported SOLID_SECTION parameter: " <<
     705                 :            :                 // (*thisParam).first
     706                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     707                 :          0 :                 break;
     708                 :            :         }
     709                 :            :     }
     710                 :            : 
     711                 :            :     EntityHandle set_handle;
     712         [ #  # ]:          0 :     status = get_set_by_name( parent_set, ABQ_ELEMENT_SET, elset_name, set_handle );
     713         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     714                 :            : 
     715         [ #  # ]:          0 :     status = mdbImpl->tag_set_data( mMatNameTag, &set_handle, 1, mat_name.c_str() );
     716         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     717                 :            : 
     718 [ #  # ][ #  # ]:          0 :     if( 0 == matIDmap[mat_name] ) matIDmap[mat_name] = ++mat_id;
                 [ #  # ]
     719                 :            : 
     720 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_set_data( mMaterialSetTag, &set_handle, 1, &( matIDmap[mat_name] ) );
     721         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     722                 :            : 
     723         [ #  # ]:          0 :     next_line_type = get_next_line_type();
     724                 :            : 
     725 [ #  # ][ #  # ]:          0 :     while( next_line_type != abq_eof && next_line_type != abq_keyword_line )
     726         [ #  # ]:          0 :         next_line_type = get_next_line_type();
     727                 :            : 
     728                 :          0 :     return MB_SUCCESS;
     729                 :            : }
     730                 :            : 
     731                 :          0 : ErrorCode ReadABAQUS::read_element_set( EntityHandle parent_set, EntityHandle file_set, EntityHandle assembly_set )
     732                 :            : {
     733                 :            :     ErrorCode status;
     734                 :            : 
     735         [ #  # ]:          0 :     std::vector< std::string > tokens;
     736         [ #  # ]:          0 :     std::map< std::string, std::string > params;
     737         [ #  # ]:          0 :     std::map< std::string, abaqus_elset_params > requiredParams;
     738 [ #  # ][ #  # ]:          0 :     requiredParams["ELSET"] = abq_elset_elset;
     739                 :            : 
     740         [ #  # ]:          0 :     std::map< std::string, abaqus_elset_params > allowableParams;
     741 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_elset_ambiguous;
     742 [ #  # ][ #  # ]:          0 :     allowableParams["GENERATE"]    = abq_elset_generate;
     743 [ #  # ][ #  # ]:          0 :     allowableParams["INSTANCE"]    = abq_elset_instance;
     744                 :            : 
     745                 :            :     abaqus_elset_params param;
     746                 :            : 
     747         [ #  # ]:          0 :     std::string elset_name;
     748                 :          0 :     bool generate_elset = false;
     749         [ #  # ]:          0 :     std::string instance_name;
     750                 :          0 :     EntityHandle element_container_set = parent_set;
     751                 :            : 
     752                 :            :     // Tokenize last line read
     753         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
     754         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
     755                 :            : 
     756         [ #  # ]:          0 :     Range element_range;
     757                 :            : 
     758                 :            :     // Search for required parameters
     759 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, abaqus_elset_params >::iterator thisParam = requiredParams.begin();
                 [ #  # ]
     760                 :          0 :          thisParam != requiredParams.end(); ++thisParam )
     761                 :            :     {
     762 [ #  # ][ #  # ]:          0 :         std::string param_key = match( ( *thisParam ).first, params );
     763         [ #  # ]:          0 :         param                 = requiredParams[param_key];
     764         [ #  # ]:          0 :         switch( param )
     765                 :            :         {
     766                 :            :             case abq_elset_elset:
     767 [ #  # ][ #  # ]:          0 :                 elset_name = params[param_key];
     768         [ #  # ]:          0 :                 params.erase( param_key );
     769                 :            :                 // std::cout << "\tAdding ELSET with name: " << elset_name << std::endl; // REMOVE
     770                 :          0 :                 break;
     771                 :            :             default:
     772 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Missing required ELSET parameter" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     773                 :            :         }
     774                 :          0 :     }
     775                 :            : 
     776                 :            :     // Process parameters
     777 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
     778                 :            :          ++thisParam )
     779                 :            :     {
     780                 :            :         // Look for unambiguous match with this node parameter
     781 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
     782   [ #  #  #  # ]:          0 :         switch( param )
     783                 :            :         {
     784                 :            :             case abq_elset_generate:
     785                 :          0 :                 generate_elset = true;
     786                 :          0 :                 break;
     787                 :            :             case abq_elset_instance:
     788 [ #  # ][ #  # ]:          0 :                 instance_name = ( *thisParam ).second;
     789         [ #  # ]:          0 :                 status        = get_set_by_name( parent_set, ABQ_INSTANCE_SET, instance_name, element_container_set );
     790         [ #  # ]:          0 :                 MB_RETURN_IF_FAIL;
     791                 :          0 :                 break;
     792                 :            :             case abq_elset_ambiguous:
     793                 :            :                 // std::cout << "\t\tIgnoring ambiguous ELSET parameter: " << (*thisParam).first
     794                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     795                 :          0 :                 break;
     796                 :            :             default:
     797                 :            :                 // std::cout << "\t\tIgnoring unsupported ELSET parameter: " << (*thisParam).first
     798                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     799                 :          0 :                 break;
     800                 :            :         }
     801                 :            :     }
     802                 :            : 
     803         [ #  # ]:          0 :     std::vector< int > element_list;
     804         [ #  # ]:          0 :     Range tmp_element_range;
     805                 :            : 
     806         [ #  # ]:          0 :     next_line_type = get_next_line_type();
     807                 :            : 
     808 [ #  # ][ #  # ]:          0 :     while( next_line_type != abq_eof && next_line_type != abq_keyword_line )
     809                 :            :     {
     810         [ #  # ]:          0 :         if( abq_data_line == next_line_type )
     811                 :            :         {
     812         [ #  # ]:          0 :             tokenize( readline, tokens, ", \n" );
     813         [ #  # ]:          0 :             if( generate_elset )
     814                 :            :             {
     815         [ #  # ]:          0 :                 if( tokens.size() != 3 )
     816 [ #  # ][ #  # ]:          0 :                 { MB_SET_ERR( MB_FAILURE, "Wrong number of entries on GENERATE element set data line" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     817         [ #  # ]:          0 :                 int e1   = atoi( tokens[0].c_str() );
     818         [ #  # ]:          0 :                 int e2   = atoi( tokens[1].c_str() );
     819         [ #  # ]:          0 :                 int incr = atoi( tokens[2].c_str() );
     820 [ #  # ][ #  # ]:          0 :                 if( ( incr == 0 ) || ( ( ( e2 - e1 ) % incr ) != 0 ) )
     821 [ #  # ][ #  # ]:          0 :                 { MB_SET_ERR( MB_FAILURE, "Invalid data on GENERATE element set data line" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     822         [ #  # ]:          0 :                 for( int element_id = e1; element_id <= e2; element_id += incr )
     823         [ #  # ]:          0 :                     element_list.push_back( element_id );
     824                 :            :             }
     825                 :            :             else
     826                 :            :             {
     827         [ #  # ]:          0 :                 for( unsigned int idx = 0; idx < tokens.size(); idx++ )
     828                 :            :                 {
     829 [ #  # ][ #  # ]:          0 :                     if( isalpha( tokens[idx][0] ) )
                 [ #  # ]
     830                 :            :                     {
     831         [ #  # ]:          0 :                         tmp_element_range.clear();
     832         [ #  # ]:          0 :                         status = get_set_elements_by_name( element_container_set, ABQ_ELEMENT_SET, tokens[idx],
     833         [ #  # ]:          0 :                                                            tmp_element_range );
     834         [ #  # ]:          0 :                         MB_RETURN_IF_FAIL;
     835                 :            : 
     836         [ #  # ]:          0 :                         element_range.merge( tmp_element_range );
     837                 :            :                     }
     838                 :            :                     else
     839 [ #  # ][ #  # ]:          0 :                         element_list.push_back( atoi( tokens[idx].c_str() ) );
     840                 :            :                 }
     841                 :            :             }
     842                 :            :         }  // if (abq_data_line == next_line_type)
     843                 :            : 
     844         [ #  # ]:          0 :         next_line_type = get_next_line_type();
     845                 :            :     }  // while (next_line_type != abq_eof && next_line_type != abq_keyword_line)
     846                 :            : 
     847         [ #  # ]:          0 :     tmp_element_range.clear();
     848 [ #  # ][ #  # ]:          0 :     status = get_elements_by_id( element_container_set, element_list, tmp_element_range );
     849         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     850                 :            : 
     851         [ #  # ]:          0 :     element_range.merge( tmp_element_range );
     852                 :            : 
     853                 :            :     EntityHandle element_set;
     854                 :            : 
     855         [ #  # ]:          0 :     status = add_entity_set( parent_set, ABQ_ELEMENT_SET, elset_name, element_set );
     856         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     857                 :            : 
     858         [ #  # ]:          0 :     status = mdbImpl->add_entities( element_set, element_range );
     859         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
     860                 :            : 
     861                 :            :     // SHOULD WE EVER DO THIS???
     862         [ #  # ]:          0 :     if( file_set )
     863                 :            :     {
     864         [ #  # ]:          0 :         status = mdbImpl->add_entities( file_set, &element_set, 1 );
     865         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     866                 :            :     }
     867                 :            : 
     868                 :            :     // SHOULD WE EVER DO THIS???
     869         [ #  # ]:          0 :     if( assembly_set )
     870                 :            :     {
     871         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, &element_set, 1 );
     872         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     873                 :            : 
     874         [ #  # ]:          0 :         status = mdbImpl->tag_set_data( mAssemblyHandleTag, &element_set, 1, &assembly_set );
     875         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     876                 :            :     }
     877                 :            : 
     878                 :          0 :     return MB_SUCCESS;
     879                 :            : }
     880                 :            : 
     881                 :          0 : ErrorCode ReadABAQUS::read_node_set( EntityHandle parent_set, EntityHandle file_set, EntityHandle assembly_set )
     882                 :            : {
     883                 :            :     ErrorCode status;
     884                 :            : 
     885         [ #  # ]:          0 :     std::vector< std::string > tokens;
     886         [ #  # ]:          0 :     std::map< std::string, std::string > params;
     887         [ #  # ]:          0 :     std::map< std::string, abaqus_nset_params > requiredParams;
     888 [ #  # ][ #  # ]:          0 :     requiredParams["NSET"] = abq_nset_nset;
     889                 :            : 
     890         [ #  # ]:          0 :     std::map< std::string, abaqus_nset_params > allowableParams;
     891 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_nset_ambiguous;
     892 [ #  # ][ #  # ]:          0 :     allowableParams["ELSET"]       = abq_nset_elset;
     893 [ #  # ][ #  # ]:          0 :     allowableParams["GENERATE"]    = abq_nset_generate;
     894 [ #  # ][ #  # ]:          0 :     allowableParams["INSTANCE"]    = abq_nset_instance;
     895                 :            : 
     896                 :            :     abaqus_nset_params param;
     897                 :            : 
     898         [ #  # ]:          0 :     std::string nset_name;
     899                 :          0 :     bool make_from_elset = false;
     900                 :          0 :     bool generate_nset   = false;
     901 [ #  # ][ #  # ]:          0 :     std::string elset_name, instance_name;
     902                 :          0 :     EntityHandle node_container_set = parent_set;
     903                 :            : 
     904                 :            :     // Tokenize last line read
     905         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
     906         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
     907                 :            : 
     908         [ #  # ]:          0 :     Range node_range;
     909                 :            : 
     910                 :            :     // Search for required parameters
     911 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, abaqus_nset_params >::iterator thisParam = requiredParams.begin();
                 [ #  # ]
     912                 :          0 :          thisParam != requiredParams.end(); ++thisParam )
     913                 :            :     {
     914 [ #  # ][ #  # ]:          0 :         std::string param_key = match( ( *thisParam ).first, params );
     915         [ #  # ]:          0 :         param                 = requiredParams[param_key];
     916         [ #  # ]:          0 :         switch( param )
     917                 :            :         {
     918                 :            :             case abq_nset_nset:
     919 [ #  # ][ #  # ]:          0 :                 nset_name = params[param_key];
     920         [ #  # ]:          0 :                 params.erase( param_key );
     921                 :            :                 // std::cout << "\tAdding NSET with name: " << nset_name << std::endl; // REMOVE
     922                 :          0 :                 break;
     923                 :            :             default:
     924 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Missing required NSET parameter" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     925                 :            :         }
     926                 :          0 :     }
     927                 :            : 
     928                 :            :     // Process parameters
     929 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
     930                 :            :          ++thisParam )
     931                 :            :     {
     932                 :            :         // Look for unambiguous match with this node parameter
     933 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
     934   [ #  #  #  #  :          0 :         switch( param )
                      # ]
     935                 :            :         {
     936                 :            :             case abq_nset_elset:
     937                 :          0 :                 make_from_elset = true;
     938 [ #  # ][ #  # ]:          0 :                 elset_name      = ( *thisParam ).second;
     939                 :          0 :                 break;
     940                 :            :             case abq_nset_generate:
     941                 :          0 :                 generate_nset = true;
     942                 :          0 :                 break;
     943                 :            :             case abq_nset_instance:
     944 [ #  # ][ #  # ]:          0 :                 instance_name = ( *thisParam ).second;
     945         [ #  # ]:          0 :                 status        = get_set_by_name( parent_set, ABQ_INSTANCE_SET, instance_name, node_container_set );
     946         [ #  # ]:          0 :                 MB_RETURN_IF_FAIL;
     947                 :          0 :                 break;
     948                 :            :             case abq_nset_ambiguous:
     949                 :            :                 // std::cout << "\t\tIgnoring ambiguous NSET parameter: " << (*thisParam).first
     950                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     951                 :          0 :                 break;
     952                 :            :             default:
     953                 :            :                 // std::cout << "\t\tIgnoring unsupported NSET parameter: " << (*thisParam).first
     954                 :            :                 //          << "=" << (*thisParam).second << std::endl;
     955                 :          0 :                 break;
     956                 :            :         }
     957                 :            :     }
     958                 :            : 
     959 [ #  # ][ #  # ]:          0 :     if( make_from_elset && generate_nset )
     960 [ #  # ][ #  # ]:          0 :     { MB_SET_ERR( MB_FAILURE, "Incompatible NSET parameters ELSET & GENERATE" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     961                 :            : 
     962         [ #  # ]:          0 :     if( make_from_elset )
     963                 :            :     {
     964         [ #  # ]:          0 :         status = get_set_nodes( parent_set, ABQ_ELEMENT_SET, elset_name, node_range );
     965         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
     966                 :            :     }
     967                 :            :     else
     968                 :            :     {
     969         [ #  # ]:          0 :         std::vector< int > node_list;
     970 [ #  # ][ #  # ]:          0 :         Range tmp_node_range;
     971                 :            : 
     972         [ #  # ]:          0 :         next_line_type = get_next_line_type();
     973                 :            : 
     974 [ #  # ][ #  # ]:          0 :         while( next_line_type != abq_eof && next_line_type != abq_keyword_line )
     975                 :            :         {
     976         [ #  # ]:          0 :             if( abq_data_line == next_line_type )
     977                 :            :             {
     978         [ #  # ]:          0 :                 tokenize( readline, tokens, ", \n" );
     979         [ #  # ]:          0 :                 if( generate_nset )
     980                 :            :                 {
     981         [ #  # ]:          0 :                     if( tokens.size() != 3 )
     982 [ #  # ][ #  # ]:          0 :                     { MB_SET_ERR( MB_FAILURE, "Wrong number of entries on GENERATE node set data line" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     983         [ #  # ]:          0 :                     int n1   = atoi( tokens[0].c_str() );
     984         [ #  # ]:          0 :                     int n2   = atoi( tokens[1].c_str() );
     985         [ #  # ]:          0 :                     int incr = atoi( tokens[2].c_str() );
     986 [ #  # ][ #  # ]:          0 :                     if( ( incr == 0 ) || ( ( ( n2 - n1 ) % incr ) != 0 ) )
     987 [ #  # ][ #  # ]:          0 :                     { MB_SET_ERR( MB_FAILURE, "Invalid data on GENERATE node set data line" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
     988         [ #  # ]:          0 :                     for( int node_id = n1; node_id <= n2; node_id += incr )
     989         [ #  # ]:          0 :                         node_list.push_back( node_id );
     990                 :            :                 }
     991                 :            :                 else
     992                 :            :                 {
     993         [ #  # ]:          0 :                     for( unsigned int idx = 0; idx < tokens.size(); idx++ )
     994                 :            :                     {
     995 [ #  # ][ #  # ]:          0 :                         if( isalpha( tokens[idx][0] ) )
                 [ #  # ]
     996                 :            :                         {
     997         [ #  # ]:          0 :                             tmp_node_range.clear();
     998 [ #  # ][ #  # ]:          0 :                             status = get_set_nodes( parent_set, ABQ_NODE_SET, tokens[idx], tmp_node_range );
     999         [ #  # ]:          0 :                             MB_RETURN_IF_FAIL;
    1000                 :            : 
    1001         [ #  # ]:          0 :                             node_range.merge( tmp_node_range );
    1002                 :            :                         }
    1003                 :            :                         else
    1004 [ #  # ][ #  # ]:          0 :                             node_list.push_back( atoi( tokens[idx].c_str() ) );
    1005                 :            :                     }
    1006                 :            :                 }
    1007                 :            :             }  // if (abq_data_line == next_line_type)
    1008                 :            : 
    1009         [ #  # ]:          0 :             next_line_type = get_next_line_type();
    1010                 :            :         }  // while (next_line_type != abq_eof && next_line_type != abq_keyword_line)
    1011                 :            : 
    1012         [ #  # ]:          0 :         tmp_node_range.clear();
    1013                 :            : 
    1014 [ #  # ][ #  # ]:          0 :         status = get_nodes_by_id( node_container_set, node_list, tmp_node_range );
    1015         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1016                 :            : 
    1017 [ #  # ][ #  # ]:          0 :         node_range.merge( tmp_node_range );
    1018                 :            :     }
    1019                 :            : 
    1020                 :            :     EntityHandle node_set;
    1021                 :            : 
    1022         [ #  # ]:          0 :     status = add_entity_set( parent_set, ABQ_NODE_SET, nset_name, node_set );
    1023         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1024                 :            : 
    1025         [ #  # ]:          0 :     status = mdbImpl->add_entities( node_set, node_range );
    1026         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1027                 :            : 
    1028         [ #  # ]:          0 :     if( file_set )
    1029                 :            :     {
    1030         [ #  # ]:          0 :         status = mdbImpl->add_entities( file_set, &node_set, 1 );
    1031         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1032                 :            :     }
    1033                 :            : 
    1034         [ #  # ]:          0 :     if( assembly_set )
    1035                 :            :     {
    1036         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, &node_set, 1 );
    1037         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1038                 :            : 
    1039         [ #  # ]:          0 :         status = mdbImpl->tag_set_data( mAssemblyHandleTag, &node_set, 1, &assembly_set );
    1040         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1041                 :            :     }
    1042                 :            : 
    1043                 :          0 :     return MB_SUCCESS;
    1044                 :            : }
    1045                 :            : 
    1046                 :          0 : ErrorCode ReadABAQUS::read_element_list( EntityHandle parent_set, EntityHandle assembly_set )
    1047                 :            : {
    1048                 :            :     ErrorCode status;
    1049                 :            : 
    1050         [ #  # ]:          0 :     std::vector< std::string > tokens;
    1051         [ #  # ]:          0 :     std::map< std::string, std::string > params;
    1052         [ #  # ]:          0 :     std::map< std::string, abaqus_element_params > requiredParams;
    1053 [ #  # ][ #  # ]:          0 :     requiredParams["TYPE"] = abq_element_type;
    1054                 :            : 
    1055         [ #  # ]:          0 :     std::map< std::string, abaqus_element_params > allowableParams;
    1056 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_element_ambiguous;
    1057 [ #  # ][ #  # ]:          0 :     allowableParams["ELSET"]       = abq_element_elset;
    1058                 :            : 
    1059                 :            :     abaqus_element_params param;
    1060                 :            : 
    1061         [ #  # ]:          0 :     std::map< std::string, abaqus_element_type > elementTypes;
    1062         [ #  # ]:          0 :     std::map< abaqus_element_type, unsigned int > nodes_per_element;
    1063         [ #  # ]:          0 :     std::map< abaqus_element_type, EntityType > entityTypeMap;
    1064 [ #  # ][ #  # ]:          0 :     elementTypes["DC3D8"]                = abq_eletype_dc3d8;
    1065         [ #  # ]:          0 :     nodes_per_element[abq_eletype_dc3d8] = 8;
    1066         [ #  # ]:          0 :     entityTypeMap[abq_eletype_dc3d8]     = MBHEX;
    1067                 :            : 
    1068 [ #  # ][ #  # ]:          0 :     elementTypes["DCC3D8"]                = abq_eletype_dcc3d8;
    1069         [ #  # ]:          0 :     nodes_per_element[abq_eletype_dcc3d8] = 8;
    1070         [ #  # ]:          0 :     entityTypeMap[abq_eletype_dcc3d8]     = MBHEX;
    1071                 :            : 
    1072 [ #  # ][ #  # ]:          0 :     elementTypes["C3D4"]                = abq_eletype_c3d4;
    1073         [ #  # ]:          0 :     nodes_per_element[abq_eletype_c3d4] = 4;
    1074         [ #  # ]:          0 :     entityTypeMap[abq_eletype_c3d4]     = MBTET;
    1075                 :            : 
    1076 [ #  # ][ #  # ]:          0 :     elementTypes["DC3D4"]                = abq_eletype_dc3d4;
    1077         [ #  # ]:          0 :     nodes_per_element[abq_eletype_dc3d4] = 4;
    1078         [ #  # ]:          0 :     entityTypeMap[abq_eletype_dc3d4]     = MBTET;
    1079                 :            : 
    1080 [ #  # ][ #  # ]:          0 :     elementTypes["C3D8R"]                = abq_eletype_c3d8r;
    1081         [ #  # ]:          0 :     nodes_per_element[abq_eletype_c3d8r] = 8;
    1082         [ #  # ]:          0 :     entityTypeMap[abq_eletype_c3d8r]     = MBHEX;
    1083                 :            : 
    1084 [ #  # ][ #  # ]:          0 :     elementTypes["DS4"]                = abq_eletype_ds4;
    1085         [ #  # ]:          0 :     nodes_per_element[abq_eletype_ds4] = 4;
    1086         [ #  # ]:          0 :     entityTypeMap[abq_eletype_ds4]     = MBQUAD;
    1087                 :            : 
    1088                 :          0 :     abaqus_element_type element_type = abq_eletype_dc3d8;
    1089                 :            : 
    1090                 :          0 :     bool make_element_set = false;
    1091         [ #  # ]:          0 :     std::string element_set_name;
    1092                 :            : 
    1093                 :            :     // Tokenize last line read
    1094         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
    1095         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
    1096                 :            : 
    1097                 :            :     // Search for required parameters
    1098 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, abaqus_element_params >::iterator thisParam = requiredParams.begin();
                 [ #  # ]
    1099                 :          0 :          thisParam != requiredParams.end(); ++thisParam )
    1100                 :            :     {
    1101 [ #  # ][ #  # ]:          0 :         std::string param_key = match( ( *thisParam ).first, params );
    1102         [ #  # ]:          0 :         param                 = requiredParams[param_key];
    1103      [ #  #  # ]:          0 :         switch( param )
    1104                 :            :         {
    1105                 :            :             case abq_element_type:
    1106 [ #  # ][ #  # ]:          0 :                 element_type = elementTypes[params[param_key]];
    1107         [ #  # ]:          0 :                 if( abq_eletype_unsupported == element_type )
    1108 [ #  # ][ #  # ]:          0 :                 { MB_SET_ERR( MB_FAILURE, "MOAB doesn't currently support this element type" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
    1109                 :            :                 // std::cout << "\tAdding ELEMENTS of type: " << params[param_key] << std::endl; //
    1110                 :            :                 // REMOVE
    1111         [ #  # ]:          0 :                 params.erase( param_key );
    1112                 :          0 :                 break;
    1113                 :            :             case abq_element_undefined:
    1114 [ #  # ][ #  # ]:          0 :                 MB_SET_ERR( MB_FAILURE, "Missing required ELEMENT parameter" );
         [ #  # ][ #  # ]
                 [ #  # ]
    1115                 :            :             default:
    1116         [ #  # ]:          0 :                 break;
    1117                 :            :         }
    1118                 :          0 :     }
    1119                 :            : 
    1120                 :            :     // Process parameters
    1121 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
    1122                 :            :          ++thisParam )
    1123                 :            :     {
    1124                 :            :         // Look for unambiguous match with this node parameter
    1125 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
    1126      [ #  #  # ]:          0 :         switch( param )
    1127                 :            :         {
    1128                 :            :             case abq_element_elset:
    1129                 :          0 :                 make_element_set = true;
    1130 [ #  # ][ #  # ]:          0 :                 element_set_name = ( *thisParam ).second;
    1131                 :          0 :                 break;
    1132                 :            :             case abq_element_ambiguous:
    1133                 :            :                 // std::cout << "\t\tIgnoring ambiguous ELEMENT parameter: " << (*thisParam).first
    1134                 :            :                 //          << "=" << (*thisParam).second << std::endl;
    1135                 :          0 :                 break;
    1136                 :            :             default:
    1137                 :            :                 // std::cout << "\t\tIgnoring unsupported ELEMENT parameter: " << (*thisParam).first
    1138                 :            :                 //          << "=" << (*thisParam).second << std::endl;
    1139                 :          0 :                 break;
    1140                 :            :         }
    1141                 :            :     }
    1142                 :            : 
    1143 [ #  # ][ #  # ]:          0 :     std::vector< int > connect_list, element_ids;
    1144                 :            : 
    1145         [ #  # ]:          0 :     next_line_type = get_next_line_type();
    1146                 :            : 
    1147 [ #  # ][ #  # ]:          0 :     while( next_line_type != abq_eof && next_line_type != abq_keyword_line )
    1148                 :            :     {
    1149         [ #  # ]:          0 :         if( abq_data_line == next_line_type )
    1150                 :            :         {
    1151         [ #  # ]:          0 :             tokenize( readline, tokens, ", \n" );
    1152 [ #  # ][ #  # ]:          0 :             if( tokens.size() < nodes_per_element[element_type] + 1 )
    1153 [ #  # ][ #  # ]:          0 :             { MB_SET_ERR( MB_FAILURE, "Not enough data on node data line" ); }
         [ #  # ][ #  # ]
                 [ #  # ]
    1154 [ #  # ][ #  # ]:          0 :             element_ids.push_back( atoi( tokens[0].c_str() ) );
    1155 [ #  # ][ #  # ]:          0 :             for( unsigned int i = 1; i < nodes_per_element[element_type] + 1; i++ )
    1156 [ #  # ][ #  # ]:          0 :                 connect_list.push_back( atoi( tokens[i].c_str() ) );
    1157                 :            :         }
    1158                 :            : 
    1159         [ #  # ]:          0 :         next_line_type = get_next_line_type();
    1160                 :            :     }
    1161                 :            : 
    1162                 :          0 :     int num_elements = element_ids.size();
    1163                 :            : 
    1164                 :            :     // Get and fill element arrays
    1165                 :          0 :     EntityHandle start_element = 0;
    1166                 :            :     EntityHandle* connect;
    1167                 :            : 
    1168         [ #  # ]:          0 :     status = readMeshIface->get_element_connect( num_elements, nodes_per_element[element_type],
    1169 [ #  # ][ #  # ]:          0 :                                                  entityTypeMap[element_type], MB_START_ID, start_element, connect );
    1170         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1171         [ #  # ]:          0 :     if( 0 == start_element ) return MB_FAILURE;
    1172                 :            : 
    1173                 :            :     // ASSUME: elements must be defined after nodes!
    1174                 :            :     // Get list of node entity handles and node IDs
    1175         [ #  # ]:          0 :     Range node_list;
    1176         [ #  # ]:          0 :     status = mdbImpl->get_entities_by_dimension( parent_set, 0, node_list );
    1177         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1178                 :            : 
    1179 [ #  # ][ #  # ]:          0 :     std::vector< int > node_ids( node_list.size() );
    1180 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_get_data( mLocalIDTag, node_list, &node_ids[0] );
    1181         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1182                 :            : 
    1183         [ #  # ]:          0 :     std::map< int, EntityHandle > nodeIdMap;
    1184 [ #  # ][ #  # ]:          0 :     for( unsigned int idx = 0; idx < node_list.size(); idx++ )
    1185 [ #  # ][ #  # ]:          0 :         nodeIdMap[node_ids[idx]] = node_list[idx];
                 [ #  # ]
    1186                 :            : 
    1187         [ #  # ]:          0 :     for( unsigned int node = 0; node < connect_list.size(); node++ )
    1188 [ #  # ][ #  # ]:          0 :         connect[node] = nodeIdMap[connect_list[node]];
    1189                 :            : 
    1190         [ #  # ]:          0 :     Range element_range( start_element, start_element + num_elements - 1 );
    1191                 :            : 
    1192                 :            :     // Add elements to file_set
    1193                 :            :     // status = mdbImpl->add_entities(file_set, element_range);
    1194                 :            :     // MB_RETURN_IF_FAIL;
    1195                 :            : 
    1196                 :            :     // Add elements to this parent_set
    1197         [ #  # ]:          0 :     status = mdbImpl->add_entities( parent_set, element_range );
    1198         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1199                 :            : 
    1200                 :            :     // Tag elements with their local ID's
    1201 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_set_data( mLocalIDTag, element_range, &element_ids[0] );
    1202         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1203                 :            : 
    1204         [ #  # ]:          0 :     if( assembly_set )
    1205                 :            :     {
    1206         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, element_range );
    1207         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1208                 :            : 
    1209         [ #  # ]:          0 :         std::vector< EntityHandle > tmp_assembly_handles;
    1210 [ #  # ][ #  # ]:          0 :         tmp_assembly_handles.assign( element_range.size(), assembly_set );
    1211 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_set_data( mAssemblyHandleTag, element_range, &( tmp_assembly_handles[0] ) );
    1212 [ #  # ][ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1213                 :            :     }
    1214                 :            : 
    1215                 :            :     // These elements don't know their instance_set (probably not defined)
    1216                 :            : 
    1217         [ #  # ]:          0 :     if( make_element_set )
    1218                 :            :     {
    1219                 :            :         EntityHandle element_set;
    1220                 :            : 
    1221         [ #  # ]:          0 :         status = add_entity_set( parent_set, ABQ_ELEMENT_SET, element_set_name, element_set );
    1222         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1223                 :            : 
    1224         [ #  # ]:          0 :         status = mdbImpl->add_entities( element_set, element_range );
    1225         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1226                 :            : 
    1227                 :            :         // This ad-hoc element set doesn't know its:
    1228                 :            :         // * part_set (probably parent_set)
    1229                 :            :         // * instance_set (probably not defined)
    1230                 :            :         // * assembly_set (probably not defined)
    1231                 :            :     }
    1232                 :            : 
    1233                 :          0 :     return MB_SUCCESS;
    1234                 :            : }
    1235                 :            : 
    1236                 :          0 : ErrorCode ReadABAQUS::read_node_list( EntityHandle parent_set, EntityHandle assembly_set )
    1237                 :            : {
    1238                 :            :     ErrorCode status;
    1239                 :            : 
    1240         [ #  # ]:          0 :     std::vector< std::string > tokens;
    1241         [ #  # ]:          0 :     std::map< std::string, std::string > params;
    1242         [ #  # ]:          0 :     std::map< std::string, abaqus_node_params > allowableParams;
    1243                 :            : 
    1244 [ #  # ][ #  # ]:          0 :     allowableParams[ABQ_AMBIGUOUS] = abq_node_ambiguous;
    1245 [ #  # ][ #  # ]:          0 :     allowableParams["NSET"]        = abq_node_nset;
    1246 [ #  # ][ #  # ]:          0 :     allowableParams["SYSTEM"]      = abq_node_system;
    1247                 :            : 
    1248                 :            :     abaqus_node_params param;
    1249                 :            : 
    1250                 :          0 :     bool make_node_set = false;
    1251         [ #  # ]:          0 :     std::string node_set_name;
    1252                 :            : 
    1253                 :          0 :     char coord_system = 'R';
    1254                 :            : 
    1255                 :            :     // Tokenize last line read
    1256         [ #  # ]:          0 :     tokenize( readline, tokens, ",\n" );
    1257         [ #  # ]:          0 :     extract_keyword_parameters( tokens, params );
    1258                 :            : 
    1259                 :            :     // std::cout << "\tAdding NODES"  << std::endl; // REMOVE
    1260                 :            : 
    1261                 :            :     // Process parameters
    1262 [ #  # ][ #  # ]:          0 :     for( std::map< std::string, std::string >::iterator thisParam = params.begin(); thisParam != params.end();
                 [ #  # ]
    1263                 :            :          ++thisParam )
    1264                 :            :     {
    1265                 :            :         // Look for unambiguous match with this node parameter
    1266 [ #  # ][ #  # ]:          0 :         param = allowableParams[match( ( *thisParam ).first, allowableParams )];
                 [ #  # ]
    1267   [ #  #  #  # ]:          0 :         switch( param )
    1268                 :            :         {
    1269                 :            :             case abq_node_nset:
    1270                 :          0 :                 make_node_set = true;
    1271 [ #  # ][ #  # ]:          0 :                 node_set_name = ( *thisParam ).second;
    1272                 :          0 :                 break;
    1273                 :            :             case abq_node_system:
    1274                 :            :                 // Store coordinate system
    1275 [ #  # ][ #  # ]:          0 :                 coord_system = ( *thisParam ).second[0];
    1276                 :          0 :                 break;
    1277                 :            :             case abq_node_ambiguous:
    1278                 :            :                 // std::cout << "\t\tIgnoring ambiguous NODE parameter: " << (*thisParam).first
    1279                 :            :                 //          << "=" << (*thisParam).second << std::endl;
    1280                 :          0 :                 break;
    1281                 :            :             default:
    1282                 :            :                 // std::cout << "\t\tIgnoring unsupported NODE parameter: " << (*thisParam).first
    1283                 :            :                 //          << "=" << (*thisParam).second << std::endl;
    1284                 :          0 :                 break;
    1285                 :            :         }
    1286                 :            :     }
    1287                 :            : 
    1288         [ #  # ]:          0 :     std::vector< double > coord_list;
    1289         [ #  # ]:          0 :     std::vector< int > node_ids;
    1290                 :            : 
    1291         [ #  # ]:          0 :     next_line_type = get_next_line_type();
    1292                 :            : 
    1293 [ #  # ][ #  # ]:          0 :     while( next_line_type != abq_eof && next_line_type != abq_keyword_line )
    1294                 :            :     {
    1295         [ #  # ]:          0 :         if( abq_data_line == next_line_type )
    1296                 :            :         {
    1297         [ #  # ]:          0 :             tokenize( readline, tokens, ", \n" );
    1298 [ #  # ][ #  # ]:          0 :             if( tokens.size() < 4 ) { MB_SET_ERR( MB_FAILURE, "Not enough data on node data line" ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1299 [ #  # ][ #  # ]:          0 :             node_ids.push_back( atoi( tokens[0].c_str() ) );
    1300         [ #  # ]:          0 :             for( unsigned int i = 1; i < 4; i++ )
    1301 [ #  # ][ #  # ]:          0 :                 coord_list.push_back( atof( tokens[i].c_str() ) );
    1302                 :            :         }
    1303                 :            : 
    1304         [ #  # ]:          0 :         next_line_type = get_next_line_type();
    1305                 :            :     }
    1306                 :            : 
    1307                 :          0 :     unsigned int num_nodes = node_ids.size();
    1308                 :            : 
    1309                 :            :     // Transform coordinate systems
    1310   [ #  #  #  # ]:          0 :     switch( coord_system )
    1311                 :            :     {
    1312                 :            :         case 'R':
    1313                 :          0 :             break;
    1314                 :            :         case 'C':
    1315 [ #  # ][ #  # ]:          0 :             cyl2rect( coord_list );
    1316                 :          0 :             break;
    1317                 :            :         case 'S':
    1318 [ #  # ][ #  # ]:          0 :             sph2rect( coord_list );
    1319                 :          0 :             break;
    1320                 :            :         default:
    1321                 :            :             // std::cout << "Treating undefined coordinate system: " << coord_system
    1322                 :            :             //          << " as rectangular/Cartesian." << std::endl;
    1323                 :          0 :             break;
    1324                 :            :     }
    1325                 :            : 
    1326                 :            :     // Get and fill coordinate arrays
    1327         [ #  # ]:          0 :     std::vector< double* > coord_arrays( 3 );
    1328                 :          0 :     EntityHandle start_node = 0;
    1329         [ #  # ]:          0 :     status                  = readMeshIface->get_node_coords( 3, num_nodes, MB_START_ID, start_node, coord_arrays );
    1330         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1331                 :            : 
    1332         [ #  # ]:          0 :     if( 0 == start_node ) return MB_FAILURE;
    1333                 :            : 
    1334                 :            :     // Cppcheck warning (false positive): variable coord_arrays is assigned a value that is never
    1335                 :            :     // used
    1336         [ #  # ]:          0 :     for( unsigned int idx = 0; idx < num_nodes; idx++ )
    1337                 :            :     {
    1338 [ #  # ][ #  # ]:          0 :         coord_arrays[0][idx] = coord_list[idx * 3];
    1339 [ #  # ][ #  # ]:          0 :         coord_arrays[1][idx] = coord_list[idx * 3 + 1];
    1340 [ #  # ][ #  # ]:          0 :         coord_arrays[2][idx] = coord_list[idx * 3 + 2];
    1341                 :            :     }
    1342                 :            : 
    1343         [ #  # ]:          0 :     Range node_range( start_node, start_node + num_nodes - 1 );
    1344                 :            :     // Add nodes to file_set
    1345                 :            :     // status = mdbImpl->add_entities(file_set, node_range);
    1346                 :            :     // MB_RETURN_IF_FAIL;
    1347                 :            : 
    1348                 :            :     // Add nodes to this parent_set
    1349         [ #  # ]:          0 :     status = mdbImpl->add_entities( parent_set, node_range );
    1350         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1351                 :            : 
    1352                 :            :     // Tag nodes with their local ID's
    1353 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_set_data( mLocalIDTag, node_range, &node_ids[0] );
    1354         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1355                 :            : 
    1356         [ #  # ]:          0 :     if( assembly_set )
    1357                 :            :     {
    1358         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, node_range );
    1359         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1360                 :            : 
    1361         [ #  # ]:          0 :         std::vector< EntityHandle > tmp_assembly_handles;
    1362 [ #  # ][ #  # ]:          0 :         tmp_assembly_handles.assign( node_range.size(), assembly_set );
    1363 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_set_data( mAssemblyHandleTag, node_range, &( tmp_assembly_handles[0] ) );
    1364 [ #  # ][ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1365                 :            :     }
    1366                 :            : 
    1367                 :            :     // These nodes don't know their instance_set (probably not defined)
    1368                 :            : 
    1369         [ #  # ]:          0 :     if( make_node_set )
    1370                 :            :     {
    1371                 :            :         EntityHandle node_set;
    1372                 :            : 
    1373         [ #  # ]:          0 :         status = add_entity_set( parent_set, ABQ_NODE_SET, node_set_name, node_set );
    1374         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1375                 :            : 
    1376         [ #  # ]:          0 :         status = mdbImpl->add_entities( node_set, node_range );
    1377         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1378                 :            : 
    1379                 :            :         // This ad-hoc node set doesn't know its:
    1380                 :            :         // * part_set (probably parent_set)
    1381                 :            :         // * instance_set (probably not defined)
    1382                 :            :         // * assembly_set (probably not defined)
    1383                 :            :     }
    1384                 :            : 
    1385                 :          0 :     return MB_SUCCESS;
    1386                 :            : }
    1387                 :            : 
    1388                 :            : // SET CREATION & ACCESS UTILITIES
    1389                 :            : 
    1390                 :          0 : ErrorCode ReadABAQUS::get_elements_by_id( EntityHandle parent_set, std::vector< int > element_ids_subset,
    1391                 :            :                                           Range& element_range )
    1392                 :            : {
    1393                 :            :     ErrorCode status;
    1394         [ #  # ]:          0 :     Range all_elements;
    1395                 :            : 
    1396         [ #  # ]:          0 :     status = get_set_elements( parent_set, all_elements );
    1397         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1398                 :            : 
    1399 [ #  # ][ #  # ]:          0 :     std::vector< int > element_ids( all_elements.size() );
    1400 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_get_data( mLocalIDTag, all_elements, &element_ids[0] );
    1401         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1402                 :            : 
    1403         [ #  # ]:          0 :     std::map< int, EntityHandle > elementIdMap;
    1404 [ #  # ][ #  # ]:          0 :     for( unsigned int idx = 0; idx < all_elements.size(); idx++ )
    1405 [ #  # ][ #  # ]:          0 :         elementIdMap[element_ids[idx]] = all_elements[idx];
                 [ #  # ]
    1406                 :            : 
    1407 [ #  # ][ #  # ]:          0 :     for( std::vector< int >::iterator element = element_ids_subset.begin(); element != element_ids_subset.end();
                 [ #  # ]
    1408                 :            :          ++element )
    1409 [ #  # ][ #  # ]:          0 :         element_range.insert( elementIdMap[*element] );
                 [ #  # ]
    1410                 :            : 
    1411                 :          0 :     return MB_SUCCESS;
    1412                 :            : }
    1413                 :            : 
    1414                 :          0 : ErrorCode ReadABAQUS::get_nodes_by_id( EntityHandle parent_set, std::vector< int > node_ids_subset, Range& node_range )
    1415                 :            : {
    1416                 :            :     ErrorCode status;
    1417                 :            : 
    1418         [ #  # ]:          0 :     Range all_nodes;
    1419         [ #  # ]:          0 :     status = mdbImpl->get_entities_by_type( parent_set, MBVERTEX, all_nodes );
    1420         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1421                 :            : 
    1422 [ #  # ][ #  # ]:          0 :     std::vector< int > node_ids( all_nodes.size() );
    1423 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_get_data( mLocalIDTag, all_nodes, &node_ids[0] );
    1424         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1425                 :            : 
    1426         [ #  # ]:          0 :     std::map< int, EntityHandle > nodeIdMap;
    1427 [ #  # ][ #  # ]:          0 :     for( unsigned int idx = 0; idx < all_nodes.size(); idx++ )
    1428 [ #  # ][ #  # ]:          0 :         nodeIdMap[node_ids[idx]] = all_nodes[idx];
                 [ #  # ]
    1429                 :            : 
    1430 [ #  # ][ #  # ]:          0 :     for( std::vector< int >::iterator node = node_ids_subset.begin(); node != node_ids_subset.end(); ++node )
                 [ #  # ]
    1431 [ #  # ][ #  # ]:          0 :         node_range.insert( nodeIdMap[*node] );
                 [ #  # ]
    1432                 :            : 
    1433                 :          0 :     return MB_SUCCESS;
    1434                 :            : }
    1435                 :            : 
    1436                 :          0 : ErrorCode ReadABAQUS::get_set_by_name( EntityHandle parent_set, int ABQ_set_type, const std::string& set_name,
    1437                 :            :                                        EntityHandle& set_handle )
    1438                 :            : {
    1439                 :            :     ErrorCode status;
    1440                 :            : 
    1441                 :            :     char this_set_name[ABAQUS_SET_NAME_LENGTH];
    1442                 :            : 
    1443                 :          0 :     set_handle = 0;
    1444                 :            : 
    1445         [ #  # ]:          0 :     Range sets;
    1446                 :          0 :     void* tag_data[] = { &ABQ_set_type };
    1447 [ #  # ][ #  # ]:          0 :     status = mdbImpl->get_entities_by_type_and_tag( parent_set, MBENTITYSET, &mSetTypeTag, tag_data, 1, sets );MB_CHK_SET_ERR( status, "Did not find any sets of that type" );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1448                 :            : 
    1449 [ #  # ][ #  # ]:          0 :     for( Range::iterator this_set = sets.begin(); this_set != sets.end() && 0 == set_handle; ++this_set )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1450                 :            :     {
    1451         [ #  # ]:          0 :         std::fill( this_set_name, this_set_name + ABAQUS_SET_NAME_LENGTH, '\0' );
    1452 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_get_data( mSetNameTag, &( *this_set ), 1, &this_set_name[0] );
    1453 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != status && MB_TAG_NOT_FOUND != status ) return status;
    1454                 :            : 
    1455 [ #  # ][ #  # ]:          0 :         if( set_name == std::string( this_set_name ) ) set_handle = *this_set;
         [ #  # ][ #  # ]
    1456                 :            :     }
    1457                 :            : 
    1458 [ #  # ][ #  # ]:          0 :     if( 0 == set_handle ) { MB_SET_ERR( MB_FAILURE, "Did not find requested set" ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1459                 :            : 
    1460                 :          0 :     return MB_SUCCESS;
    1461                 :            : }
    1462                 :            : 
    1463                 :          0 : ErrorCode ReadABAQUS::get_set_elements( EntityHandle set_handle, Range& element_range )
    1464                 :            : {
    1465                 :            :     ErrorCode status;
    1466                 :            : 
    1467         [ #  # ]:          0 :     Range dim_ent_list;
    1468                 :            : 
    1469                 :            :     // Could have elements of multiple dimensions in this set???
    1470         [ #  # ]:          0 :     for( int dim = 1; dim <= 3; dim++ )
    1471                 :            :     {
    1472         [ #  # ]:          0 :         dim_ent_list.clear();
    1473         [ #  # ]:          0 :         status = mdbImpl->get_entities_by_dimension( set_handle, dim, dim_ent_list );
    1474         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1475                 :            : 
    1476         [ #  # ]:          0 :         element_range.merge( dim_ent_list );
    1477                 :            :     }
    1478                 :            : 
    1479                 :          0 :     return MB_SUCCESS;
    1480                 :            : }
    1481                 :            : 
    1482                 :          0 : ErrorCode ReadABAQUS::get_set_elements_by_name( EntityHandle parent_set, int ABQ_set_type, const std::string& set_name,
    1483                 :            :                                                 Range& element_range )
    1484                 :            : {
    1485                 :            :     ErrorCode status;
    1486                 :            : 
    1487                 :            :     EntityHandle set_handle;
    1488         [ #  # ]:          0 :     status = get_set_by_name( parent_set, ABQ_set_type, set_name, set_handle );
    1489         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1490                 :            : 
    1491         [ #  # ]:          0 :     status = get_set_elements( set_handle, element_range );
    1492         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1493                 :            : 
    1494         [ #  # ]:          0 :     if( element_range.size() == 0 )
    1495                 :            :     {
    1496                 :            :         // std::cout << "No elements were found in set " << set_name << std::endl;
    1497                 :            :     }
    1498                 :            : 
    1499                 :          0 :     return MB_SUCCESS;
    1500                 :            : }
    1501                 :            : 
    1502                 :          0 : ErrorCode ReadABAQUS::get_set_nodes( EntityHandle parent_set, int ABQ_set_type, const std::string& set_name,
    1503                 :            :                                      Range& node_range )
    1504                 :            : {
    1505                 :            :     ErrorCode status;
    1506                 :            : 
    1507                 :            :     EntityHandle set_handle;
    1508         [ #  # ]:          0 :     status = get_set_by_name( parent_set, ABQ_set_type, set_name, set_handle );
    1509         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1510                 :            : 
    1511         [ #  # ]:          0 :     Range ent_list;
    1512         [ #  # ]:          0 :     Range dim_ent_list;
    1513                 :            :     // Could have elements of multiple dimensions in this set???
    1514         [ #  # ]:          0 :     for( int dim = 0; dim <= 3; dim++ )
    1515                 :            :     {
    1516         [ #  # ]:          0 :         dim_ent_list.clear();
    1517         [ #  # ]:          0 :         status = mdbImpl->get_entities_by_dimension( set_handle, dim, dim_ent_list );
    1518         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1519                 :            : 
    1520         [ #  # ]:          0 :         ent_list.merge( dim_ent_list );
    1521                 :            :     }
    1522                 :            : 
    1523         [ #  # ]:          0 :     status = mdbImpl->get_adjacencies( ent_list, 0, false, node_range );
    1524         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1525                 :            : 
    1526 [ #  # ][ #  # ]:          0 :     if( node_range.size() == 0 ) { std::cout << "No nodes were found in set " << set_name << std::endl; }
         [ #  # ][ #  # ]
                 [ #  # ]
    1527                 :            : 
    1528                 :          0 :     return MB_SUCCESS;
    1529                 :            : }
    1530                 :            : 
    1531                 :         13 : Tag ReadABAQUS::get_tag( const char* tag_name, int tag_size, TagType tag_type, DataType tag_data_type,
    1532                 :            :                          const void* def_val )
    1533                 :            : {
    1534                 :            :     Tag retval;
    1535                 :            : 
    1536                 :            :     ErrorCode rval =
    1537         [ +  - ]:         13 :         mdbImpl->tag_get_handle( tag_name, tag_size, tag_data_type, retval, tag_type | MB_TAG_CREAT, def_val );
    1538         [ -  + ]:         13 :     assert( MB_SUCCESS == rval );
    1539         [ +  - ]:         13 :     return MB_SUCCESS == rval ? retval : 0;
    1540                 :            : }
    1541                 :            : 
    1542                 :          0 : ErrorCode ReadABAQUS::create_instance_of_part( const EntityHandle file_set, const EntityHandle assembly_set,
    1543                 :            :                                                const std::string& part_name, const std::string& /*instance_name*/,
    1544                 :            :                                                EntityHandle& instance_set, const std::vector< double >& translation,
    1545                 :            :                                                const std::vector< double >& rotation )
    1546                 :            : {
    1547                 :            :     ErrorCode status;
    1548                 :            : 
    1549                 :            :     EntityHandle part_set;
    1550         [ #  # ]:          0 :     status = get_set_by_name( file_set, ABQ_PART_SET, part_name, part_set );
    1551         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1552                 :            : 
    1553                 :            :     // Cross-reference
    1554         [ #  # ]:          0 :     status = mdbImpl->tag_set_data( mPartHandleTag, &instance_set, 1, &part_set );
    1555         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1556                 :            : 
    1557         [ #  # ]:          0 :     int instance_id = ++num_part_instances[part_set];
    1558         [ #  # ]:          0 :     status          = mdbImpl->tag_set_data( mInstancePIDTag, &instance_set, 1, &instance_id );
    1559         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1560                 :            : 
    1561         [ #  # ]:          0 :     status = mdbImpl->tag_set_data( mAssemblyHandleTag, &instance_set, 1, &assembly_set );
    1562         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1563                 :            : 
    1564         [ #  # ]:          0 :     instance_id = ++num_assembly_instances[assembly_set];
    1565         [ #  # ]:          0 :     status      = mdbImpl->tag_set_data( mInstanceGIDTag, &instance_set, 1, &instance_id );
    1566         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1567                 :            : 
    1568                 :            :     // Create maps to cross-reference the part and instance versions of each entity
    1569 [ #  # ][ #  # ]:          0 :     std::map< EntityHandle, EntityHandle > p2i_nodes, p2i_elements;
    1570                 :            : 
    1571                 :            :     // ---- NODES ----
    1572                 :            : 
    1573                 :            :     // Get all nodes and IDs
    1574         [ #  # ]:          0 :     Range part_node_list;
    1575         [ #  # ]:          0 :     status = mdbImpl->get_entities_by_dimension( part_set, 0, part_node_list );
    1576         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1577                 :            : 
    1578 [ #  # ][ #  # ]:          0 :     if( 0 < part_node_list.size() )
    1579                 :            :     {
    1580 [ #  # ][ #  # ]:          0 :         std::vector< int > node_ids( part_node_list.size() );
    1581 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_get_data( mLocalIDTag, part_node_list, &node_ids[0] );
    1582         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1583                 :            : 
    1584                 :            :         // std::map<int, EntityHandle> nodeIdMap;
    1585                 :            :         // for (unsigned int idx = 0; idx < part_node_list.size(); idx++)
    1586                 :            :         // nodeIdMap[node_ids[idx]] = part_node_list[idx];
    1587                 :            : 
    1588                 :            :         // Create new nodes
    1589 [ #  # ][ #  # ]:          0 :         std::vector< double* > coord_arrays( 3 );
    1590                 :          0 :         EntityHandle start_node = 0;
    1591 [ #  # ][ #  # ]:          0 :         status = readMeshIface->get_node_coords( 3, part_node_list.size(), MB_START_ID, start_node, coord_arrays );
    1592         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1593                 :            : 
    1594         [ #  # ]:          0 :         if( 0 == start_node ) return MB_FAILURE;
    1595                 :            : 
    1596                 :            :         // Copy coordinates into new coord_arrays
    1597 [ #  # ][ #  # ]:          0 :         status = mdbImpl->get_coords( part_node_list, coord_arrays[0], coord_arrays[1], coord_arrays[2] );
         [ #  # ][ #  # ]
    1598                 :            : 
    1599                 :            :         // Rotate to new position
    1600                 :            :         double rot_axis[3];
    1601 [ #  # ][ #  # ]:          0 :         rot_axis[0] = rotation[3] - rotation[0];
    1602 [ #  # ][ #  # ]:          0 :         rot_axis[1] = rotation[4] - rotation[1];
    1603 [ #  # ][ #  # ]:          0 :         rot_axis[2] = rotation[5] - rotation[2];
    1604                 :            : 
    1605         [ #  # ]:          0 :         AffineXform rotationXform;
    1606 [ #  # ][ #  # ]:          0 :         if( rotation[6] != 0 ) rotationXform = AffineXform::rotation( rotation[6] * DEG2RAD, rot_axis );
         [ #  # ][ #  # ]
                 [ #  # ]
    1607                 :            : 
    1608                 :            :         // Translate to new position
    1609 [ #  # ][ #  # ]:          0 :         for( unsigned int idx = 0; idx < part_node_list.size(); idx++ )
    1610                 :            :         {
    1611                 :            :             double coords[3];
    1612                 :            : 
    1613                 :            :             // Transform to new location and then shift origin of rotation
    1614         [ #  # ]:          0 :             for( unsigned int dim = 0; dim < 3; dim++ )
    1615 [ #  # ][ #  # ]:          0 :                 coords[dim] = coord_arrays[dim][idx] + translation[dim] - rotation[dim];
                 [ #  # ]
    1616                 :            : 
    1617                 :            :             // Rotate around this origin
    1618 [ #  # ][ #  # ]:          0 :             if( rotation[6] != 0 ) rotationXform.xform_vector( coords );
                 [ #  # ]
    1619                 :            : 
    1620                 :            :             // Transform origin of rotation back
    1621         [ #  # ]:          0 :             for( unsigned int dim = 0; dim < 3; dim++ )
    1622 [ #  # ][ #  # ]:          0 :                 coord_arrays[dim][idx] = coords[dim] + rotation[dim];
    1623                 :            :         }
    1624                 :            : 
    1625 [ #  # ][ #  # ]:          0 :         Range instance_node_list( start_node, start_node + part_node_list.size() - 1 );
                 [ #  # ]
    1626                 :            : 
    1627                 :            :         // (DO NOT) add nodes to file_set
    1628                 :            :         // status = mdbImpl->add_entities(file_set, instance_node_list);
    1629                 :            :         // MB_RETURN_IF_FAIL;
    1630                 :            : 
    1631                 :            :         // Add nodes to this instance_set
    1632         [ #  # ]:          0 :         status = mdbImpl->add_entities( instance_set, instance_node_list );
    1633         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1634                 :            : 
    1635                 :            :         // Add nodes to this assembly_set
    1636         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, instance_node_list );
    1637         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1638                 :            : 
    1639                 :            :         // Tag nodes with their local ID's
    1640 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_set_data( mLocalIDTag, instance_node_list, &node_ids[0] );
    1641         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1642                 :            : 
    1643                 :            :         // Create a map of old handles to new handles!!!
    1644 [ #  # ][ #  # ]:          0 :         for( unsigned int idx = 0; idx < part_node_list.size(); idx++ )
                 [ #  # ]
    1645 [ #  # ][ #  # ]:          0 :             p2i_nodes[part_node_list[idx]] = instance_node_list[idx];
                 [ #  # ]
    1646                 :            :     }
    1647                 :            : 
    1648                 :            :     //  ---- ELEMENTS ----
    1649                 :            : 
    1650         [ #  # ]:          0 :     Range part_element_list;
    1651         [ #  # ]:          0 :     status = get_set_elements( part_set, part_element_list );
    1652         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1653                 :            : 
    1654 [ #  # ][ #  # ]:          0 :     if( 0 < part_element_list.size() )
    1655                 :            :     {
    1656 [ #  # ][ #  # ]:          0 :         std::vector< int > part_element_ids( part_element_list.size() );
    1657 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_get_data( mLocalIDTag, part_element_list, &part_element_ids[0] );
    1658         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1659                 :            : 
    1660                 :            :         // std::map<int, EntityHandle> elementIdMap;
    1661                 :            :         // for (unsigned int idx = 0; idx < part_element_list.size(); idx++)
    1662                 :            :         // elementIdMap[part_element_ids[idx]] = part_element_list[idx];
    1663                 :            : 
    1664                 :            :         // Create new elements
    1665 [ #  # ][ #  # ]:          0 :         Range instance_element_list;
    1666         [ #  # ]:          0 :         instance_element_list.clear();
    1667                 :            : 
    1668                 :            :         // Cross-referencing storage and pointers/iterators
    1669 [ #  # ][ #  # ]:          0 :         std::vector< int > instance_element_ids;
    1670                 :          0 :         std::vector< int >::iterator part_element_id = part_element_ids.begin();
    1671                 :            : 
    1672 [ #  # ][ #  # ]:          0 :         for( Range::iterator part_element = part_element_list.begin(); part_element != part_element_list.end();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1673                 :            :              ++part_element, ++part_element_id )
    1674                 :            :         {
    1675 [ #  # ][ #  # ]:          0 :             EntityType element_type = mdbImpl->type_from_handle( *part_element );
    1676 [ #  # ][ #  # ]:          0 :             std::vector< EntityHandle > part_connectivity, instance_connectivity;
                 [ #  # ]
    1677                 :            :             EntityHandle new_element;
    1678 [ #  # ][ #  # ]:          0 :             status = mdbImpl->get_connectivity( &( *part_element ), 1, part_connectivity );
    1679         [ #  # ]:          0 :             MB_RETURN_IF_FAIL;
    1680                 :            : 
    1681                 :          0 :             instance_connectivity.clear();
    1682   [ #  #  #  # ]:          0 :             for( std::vector< EntityHandle >::iterator connectivity_node = part_connectivity.begin();
                 [ #  # ]
    1683                 :          0 :                  connectivity_node != part_connectivity.end(); ++connectivity_node )
    1684 [ #  # ][ #  # ]:          0 :                 instance_connectivity.push_back( p2i_nodes[*connectivity_node] );
                 [ #  # ]
    1685                 :            : 
    1686         [ #  # ]:          0 :             status = mdbImpl->create_element( element_type, &instance_connectivity[0], instance_connectivity.size(),
    1687         [ #  # ]:          0 :                                               new_element );
    1688         [ #  # ]:          0 :             MB_RETURN_IF_FAIL;
    1689                 :            : 
    1690         [ #  # ]:          0 :             instance_element_list.insert( new_element );
    1691 [ #  # ][ #  # ]:          0 :             p2i_elements[*part_element] = new_element;
    1692 [ #  # ][ #  # ]:          0 :             instance_element_ids.push_back( *part_element_id );
                 [ #  # ]
    1693                 :          0 :         }
    1694                 :            : 
    1695                 :            :         // (DO NOT) add elements to file_set
    1696                 :            :         // status = mdbImpl->add_entities(file_set, instance_element_list);
    1697                 :            :         // MB_RETURN_IF_FAIL;
    1698                 :            : 
    1699                 :            :         // Add elements to this instance_set
    1700         [ #  # ]:          0 :         status = mdbImpl->add_entities( instance_set, instance_element_list );
    1701         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1702                 :            : 
    1703                 :            :         // Add elements to this assembly_set
    1704         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, instance_element_list );
    1705         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1706                 :            : 
    1707                 :            :         // Tag elements with their local ID's
    1708 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_set_data( mLocalIDTag, instance_element_list, &( instance_element_ids[0] ) );
    1709 [ #  # ][ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1710                 :            :     }
    1711                 :            : 
    1712                 :            :     // ----- NODE SETS -----
    1713                 :            : 
    1714                 :            :     // Get all node sets in part
    1715         [ #  # ]:          0 :     Range part_node_sets;
    1716                 :          0 :     int tag_val      = ABQ_NODE_SET;
    1717                 :          0 :     void* tag_data[] = { &tag_val };
    1718         [ #  # ]:          0 :     status = mdbImpl->get_entities_by_type_and_tag( part_set, MBENTITYSET, &mSetTypeTag, tag_data, 1, part_node_sets );
    1719         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1720                 :            : 
    1721 [ #  # ][ #  # ]:          0 :     Range part_node_set_list, instance_node_set_list;
    1722 [ #  # ][ #  # ]:          0 :     for( Range::iterator part_node_set = part_node_sets.begin(); part_node_set != part_node_sets.end();
         [ #  # ][ #  # ]
                 [ #  # ]
    1723                 :            :          ++part_node_set )
    1724                 :            :     {
    1725                 :            :         char node_set_name[ABAQUS_SET_NAME_LENGTH];
    1726         [ #  # ]:          0 :         std::fill( node_set_name, node_set_name + ABAQUS_SET_NAME_LENGTH, '\0' );
    1727 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_get_data( mSetNameTag, &( *part_node_set ), 1, &node_set_name[0] );
    1728 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != status && MB_TAG_NOT_FOUND != status ) return status;
    1729                 :            : 
    1730         [ #  # ]:          0 :         part_node_set_list.clear();
    1731 [ #  # ][ #  # ]:          0 :         status = mdbImpl->get_entities_by_dimension( *part_node_set, 0, part_node_set_list );
    1732                 :            : 
    1733         [ #  # ]:          0 :         instance_node_set_list.clear();
    1734 [ #  # ][ #  # ]:          0 :         for( Range::iterator set_node = part_node_set_list.begin(); set_node != part_node_set_list.end(); ++set_node )
         [ #  # ][ #  # ]
                 [ #  # ]
    1735 [ #  # ][ #  # ]:          0 :             instance_node_set_list.insert( p2i_nodes[*set_node] );
                 [ #  # ]
    1736                 :            : 
    1737                 :            :         EntityHandle instance_node_set;
    1738                 :            : 
    1739 [ #  # ][ #  # ]:          0 :         status = add_entity_set( instance_set, ABQ_NODE_SET, node_set_name, instance_node_set );
    1740         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1741                 :            : 
    1742         [ #  # ]:          0 :         status = mdbImpl->add_entities( instance_node_set, instance_node_set_list );
    1743         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1744                 :            : 
    1745         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, &instance_node_set, 1 );
    1746         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1747                 :            : 
    1748         [ #  # ]:          0 :         status = mdbImpl->tag_set_data( mPartHandleTag, &instance_node_set, 1, &part_set );
    1749         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1750                 :            : 
    1751         [ #  # ]:          0 :         status = mdbImpl->tag_set_data( mAssemblyHandleTag, &instance_node_set, 1, &assembly_set );
    1752         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1753                 :            :     }
    1754                 :            : 
    1755                 :            :     // ----- ELEMENT SETS -----
    1756                 :            : 
    1757                 :            :     // Get all element sets in part
    1758         [ #  # ]:          0 :     Range part_element_sets;
    1759                 :          0 :     tag_val     = ABQ_ELEMENT_SET;
    1760                 :          0 :     tag_data[0] = &tag_val;
    1761                 :            :     status =
    1762         [ #  # ]:          0 :         mdbImpl->get_entities_by_type_and_tag( part_set, MBENTITYSET, &mSetTypeTag, tag_data, 1, part_element_sets );
    1763         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1764                 :            : 
    1765 [ #  # ][ #  # ]:          0 :     Range part_element_set_list, instance_element_set_list;
    1766 [ #  # ][ #  # ]:          0 :     for( Range::iterator part_element_set = part_element_sets.begin(); part_element_set != part_element_sets.end();
         [ #  # ][ #  # ]
                 [ #  # ]
    1767                 :            :          ++part_element_set )
    1768                 :            :     {
    1769                 :            :         char element_set_name[ABAQUS_SET_NAME_LENGTH];
    1770         [ #  # ]:          0 :         std::fill( element_set_name, element_set_name + ABAQUS_SET_NAME_LENGTH, '\0' );
    1771 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_get_data( mSetNameTag, &( *part_element_set ), 1, &element_set_name[0] );
    1772 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != status && MB_TAG_NOT_FOUND != status ) return status;
    1773                 :            : 
    1774         [ #  # ]:          0 :         part_element_set_list.clear();
    1775 [ #  # ][ #  # ]:          0 :         status = get_set_elements( *part_element_set, part_element_set_list );
    1776                 :            : 
    1777         [ #  # ]:          0 :         instance_element_set_list.clear();
    1778 [ #  # ][ #  # ]:          0 :         for( Range::iterator set_element = part_element_set_list.begin(); set_element != part_element_set_list.end();
         [ #  # ][ #  # ]
                 [ #  # ]
    1779                 :            :              ++set_element )
    1780 [ #  # ][ #  # ]:          0 :             instance_element_set_list.insert( p2i_elements[*set_element] );
                 [ #  # ]
    1781                 :            : 
    1782                 :            :         EntityHandle instance_element_set;
    1783 [ #  # ][ #  # ]:          0 :         status = add_entity_set( instance_set, ABQ_ELEMENT_SET, element_set_name, instance_element_set );
    1784         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1785                 :            : 
    1786                 :            :         // std::cerr << instance_set << "\t" << instance_element_set << std::endl;
    1787         [ #  # ]:          0 :         status = mdbImpl->add_entities( instance_element_set, instance_element_set_list );
    1788         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1789                 :            : 
    1790         [ #  # ]:          0 :         status = mdbImpl->add_entities( assembly_set, &instance_element_set, 1 );
    1791         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1792                 :            : 
    1793                 :            :         // status = mdbImpl->add_entities(file_set, &instance_element_set, 1);
    1794                 :            :         // MB_RETURN_IF_FAIL;
    1795                 :            : 
    1796         [ #  # ]:          0 :         status = mdbImpl->tag_set_data( mPartHandleTag, &instance_element_set, 1, &part_set );
    1797         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1798                 :            : 
    1799         [ #  # ]:          0 :         status = mdbImpl->tag_set_data( mAssemblyHandleTag, &instance_element_set, 1, &assembly_set );
    1800         [ #  # ]:          0 :         MB_RETURN_IF_FAIL;
    1801                 :            : 
    1802                 :            :         char element_set_matname[ABAQUS_SET_NAME_LENGTH];
    1803         [ #  # ]:          0 :         std::fill( element_set_matname, element_set_matname + ABAQUS_SET_NAME_LENGTH, '\0' );
    1804 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_get_data( mMatNameTag, &( *part_element_set ), 1, &element_set_matname[0] );
    1805 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != status && MB_TAG_NOT_FOUND != status ) return status;
    1806                 :            : 
    1807         [ #  # ]:          0 :         if( MB_TAG_NOT_FOUND != status )
    1808                 :            :         {
    1809         [ #  # ]:          0 :             status = mdbImpl->tag_set_data( mMatNameTag, &instance_element_set, 1, element_set_matname );
    1810         [ #  # ]:          0 :             MB_RETURN_IF_FAIL;
    1811                 :            :         }
    1812                 :            : 
    1813                 :            :         int element_set_mat_id;
    1814 [ #  # ][ #  # ]:          0 :         status = mdbImpl->tag_get_data( mMaterialSetTag, &( *part_element_set ), 1, &element_set_mat_id );
    1815 [ #  # ][ #  # ]:          0 :         if( MB_SUCCESS != status && MB_TAG_NOT_FOUND != status ) return status;
    1816                 :            : 
    1817         [ #  # ]:          0 :         if( MB_TAG_NOT_FOUND != status )
    1818                 :            :         {
    1819         [ #  # ]:          0 :             status = mdbImpl->tag_set_data( mMaterialSetTag, &instance_element_set, 1, &element_set_mat_id );
    1820         [ #  # ]:          0 :             MB_RETURN_IF_FAIL;
    1821                 :            :         }
    1822                 :            :     }
    1823                 :            : 
    1824                 :            :     // Tag everything with their instance handle
    1825                 :            :     // some nodes are assigned outside of this routine so query final list of all
    1826                 :            :     // instance nodes, elements, etc
    1827         [ #  # ]:          0 :     Range instance_entity_list;
    1828         [ #  # ]:          0 :     status = mdbImpl->get_entities_by_dimension( instance_set, 0, instance_entity_list );
    1829         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1830                 :            : 
    1831         [ #  # ]:          0 :     std::vector< EntityHandle > tmp_instance_handles;
    1832 [ #  # ][ #  # ]:          0 :     tmp_instance_handles.assign( instance_entity_list.size(), instance_set );
    1833 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_set_data( mInstanceHandleTag, instance_entity_list, &tmp_instance_handles[0] );
    1834         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1835                 :            : 
    1836         [ #  # ]:          0 :     instance_entity_list.clear();
    1837         [ #  # ]:          0 :     status = get_set_elements( instance_set, instance_entity_list );
    1838         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1839                 :            : 
    1840                 :          0 :     tmp_instance_handles.clear();
    1841 [ #  # ][ #  # ]:          0 :     tmp_instance_handles.assign( instance_entity_list.size(), instance_set );
    1842 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_set_data( mInstanceHandleTag, instance_entity_list, &tmp_instance_handles[0] );
    1843         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1844                 :            : 
    1845                 :            :     // Get all node sets in instance
    1846         [ #  # ]:          0 :     instance_entity_list.clear();
    1847                 :          0 :     tag_val     = ABQ_NODE_SET;
    1848                 :          0 :     tag_data[0] = &tag_val;
    1849                 :            :     status      = mdbImpl->get_entities_by_type_and_tag( instance_set, MBENTITYSET, &mSetTypeTag, tag_data, 1,
    1850         [ #  # ]:          0 :                                                     instance_entity_list );
    1851         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1852                 :            : 
    1853                 :          0 :     tmp_instance_handles.clear();
    1854 [ #  # ][ #  # ]:          0 :     tmp_instance_handles.assign( instance_entity_list.size(), instance_set );
    1855 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_set_data( mInstanceHandleTag, instance_entity_list, &tmp_instance_handles[0] );
    1856         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1857                 :            : 
    1858                 :            :     // Get all element sets in part
    1859         [ #  # ]:          0 :     instance_entity_list.clear();
    1860                 :          0 :     tag_val     = ABQ_ELEMENT_SET;
    1861                 :          0 :     tag_data[0] = &tag_val;
    1862                 :            :     status      = mdbImpl->get_entities_by_type_and_tag( instance_set, MBENTITYSET, &mSetTypeTag, tag_data, 1,
    1863         [ #  # ]:          0 :                                                     instance_entity_list );
    1864         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1865                 :            : 
    1866                 :          0 :     tmp_instance_handles.clear();
    1867 [ #  # ][ #  # ]:          0 :     tmp_instance_handles.assign( instance_entity_list.size(), instance_set );
    1868 [ #  # ][ #  # ]:          0 :     status = mdbImpl->tag_set_data( mInstanceHandleTag, instance_entity_list, &tmp_instance_handles[0] );
    1869         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1870                 :            : 
    1871                 :          0 :     return MB_SUCCESS;
    1872                 :            : }
    1873                 :            : 
    1874                 :          0 : ErrorCode ReadABAQUS::add_entity_set( EntityHandle parent_set, int ABQ_Set_Type, const std::string& set_name,
    1875                 :            :                                       EntityHandle& entity_set )
    1876                 :            : {
    1877                 :            :     ErrorCode status;
    1878                 :            : 
    1879                 :          0 :     status = mdbImpl->create_meshset( MESHSET_SET, entity_set );
    1880         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1881                 :            : 
    1882                 :          0 :     status = mdbImpl->tag_set_data( mSetTypeTag, &entity_set, 1, &ABQ_Set_Type );
    1883         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1884                 :            : 
    1885                 :          0 :     status = mdbImpl->tag_set_data( mSetNameTag, &entity_set, 1, set_name.c_str() );
    1886         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1887                 :            : 
    1888                 :          0 :     status = mdbImpl->add_entities( parent_set, &entity_set, 1 );
    1889         [ #  # ]:          0 :     MB_RETURN_IF_FAIL;
    1890                 :            : 
    1891                 :          0 :     return MB_SUCCESS;
    1892                 :            : }
    1893                 :            : 
    1894                 :          0 : void ReadABAQUS::cyl2rect( std::vector< double > coord_list )
    1895                 :            : {
    1896                 :          0 :     int num_nodes = coord_list.size() / 3;
    1897                 :            :     double x, y, r, t;
    1898                 :            : 
    1899         [ #  # ]:          0 :     for( int node = 0; node < num_nodes; node++ )
    1900                 :            :     {
    1901                 :          0 :         r = coord_list[3 * node];
    1902                 :          0 :         t = coord_list[3 * node + 1] * DEG2RAD;
    1903                 :            : 
    1904                 :          0 :         x = r * cos( t );
    1905                 :          0 :         y = r * sin( t );
    1906                 :            : 
    1907                 :          0 :         coord_list[3 * node]     = x;
    1908                 :          0 :         coord_list[3 * node + 1] = y;
    1909                 :            :     }
    1910                 :          0 : }
    1911                 :            : 
    1912                 :          0 : void ReadABAQUS::sph2rect( std::vector< double > coord_list )
    1913                 :            : {
    1914                 :          0 :     int num_nodes = coord_list.size() / 3;
    1915                 :            :     double x, y, z, r, t, p;
    1916                 :            : 
    1917         [ #  # ]:          0 :     for( int node = 0; node < num_nodes; node++ )
    1918                 :            :     {
    1919                 :          0 :         r = coord_list[3 * node];
    1920                 :          0 :         t = coord_list[3 * node + 1] * DEG2RAD;
    1921                 :          0 :         p = coord_list[3 * node + 2] * DEG2RAD;
    1922                 :            : 
    1923                 :          0 :         x = r * cos( p ) * cos( t );
    1924                 :          0 :         y = r * cos( p ) * sin( t );
    1925                 :          0 :         z = r * sin( p );
    1926                 :            : 
    1927                 :          0 :         coord_list[3 * node]     = x;
    1928                 :          0 :         coord_list[3 * node + 1] = y;
    1929                 :          0 :         coord_list[3 * node + 2] = z;
    1930                 :            :     }
    1931                 :          0 : }
    1932                 :            : 
    1933                 :            : // PARSING RECOGNITION
    1934                 :            : 
    1935                 :          1 : abaqus_line_types ReadABAQUS::get_next_line_type()
    1936                 :            : {
    1937                 :          1 :     readline.clear();
    1938                 :          1 :     std::getline( abFile, readline );
    1939                 :          1 :     ++lineNo;
    1940                 :            : 
    1941         [ -  + ]:          1 :     if( abFile.eof() ) return abq_eof;
    1942                 :            : 
    1943                 :          1 :     std::string::size_type pos = readline.find_first_not_of( ' ' );
    1944                 :            : 
    1945         [ -  + ]:          1 :     if( std::string::npos == pos ) return abq_blank_line;
    1946                 :            : 
    1947         [ -  + ]:          1 :     if( '*' == readline[pos] )
    1948         [ #  # ]:          0 :         if( '*' == readline[pos + 1] )
    1949                 :          0 :             return abq_comment_line;
    1950                 :            :         else
    1951                 :          0 :             return abq_keyword_line;
    1952                 :            :     else
    1953                 :          1 :         return abq_data_line;
    1954                 :            : }
    1955                 :            : 
    1956                 :          0 : abaqus_keyword_type ReadABAQUS::get_keyword()
    1957                 :            : {
    1958         [ #  # ]:          0 :     std::vector< std::string > tokens;
    1959         [ #  # ]:          0 :     std::map< std::string, abaqus_keyword_type > keywords;
    1960                 :            : 
    1961                 :            :     // Set up list of supported keywords
    1962                 :            :     // Note: any attempt to match something not in the keyword list
    1963                 :            :     //       using the [] operator will create a new entry in the map
    1964                 :            :     //       but that entry will have value abq_undefined based on the
    1965                 :            :     //       definition of the abaqus_keyword_type enum.
    1966 [ #  # ][ #  # ]:          0 :     keywords[ABQ_AMBIGUOUS]   = abq_ambiguous;
    1967 [ #  # ][ #  # ]:          0 :     keywords["HEADING"]       = abq_heading;
    1968 [ #  # ][ #  # ]:          0 :     keywords["PART"]          = abq_part;
    1969 [ #  # ][ #  # ]:          0 :     keywords["END PART"]      = abq_end_part;
    1970 [ #  # ][ #  # ]:          0 :     keywords["ASSEMBLY"]      = abq_assembly;
    1971 [ #  # ][ #  # ]:          0 :     keywords["END ASSEMBLY"]  = abq_end_assembly;
    1972 [ #  # ][ #  # ]:          0 :     keywords["NODE"]          = abq_node;
    1973 [ #  # ][ #  # ]:          0 :     keywords["ELEMENT"]       = abq_element;
    1974 [ #  # ][ #  # ]:          0 :     keywords["NSET"]          = abq_nset;
    1975 [ #  # ][ #  # ]:          0 :     keywords["ELSET"]         = abq_elset;
    1976 [ #  # ][ #  # ]:          0 :     keywords["SOLID SECTION"] = abq_solid_section;
    1977 [ #  # ][ #  # ]:          0 :     keywords["INSTANCE"]      = abq_instance;
    1978 [ #  # ][ #  # ]:          0 :     keywords["END INSTANCE"]  = abq_end_instance;
    1979                 :            : 
    1980         [ #  # ]:          0 :     tokenize( readline, tokens, "*,\n" );
    1981                 :            : 
    1982                 :            :     // Convert to upper case and test for unambiguous match/partial match
    1983 [ #  # ][ #  # ]:          0 :     stringToUpper( tokens[0], tokens[0] );
                 [ #  # ]
    1984 [ #  # ][ #  # ]:          0 :     return keywords[match( tokens[0], keywords )];
                 [ #  # ]
    1985                 :            : }
    1986                 :            : 
    1987                 :            : // PARSING UTILITY FUNCTIONS
    1988                 :            : 
    1989                 :            : // For a map of strings to values of type T
    1990                 :            : // search the key list of the map for an unambiguous partial match with the token
    1991                 :            : template < typename T >
    1992                 :          0 : std::string ReadABAQUS::match( const std::string& token, std::map< std::string, T >& tokenList )
    1993                 :            : {
    1994                 :            :     // Initialize with no match and ABQ_UNDEFINED as return string
    1995                 :          0 :     bool found_match       = false;
    1996 [ #  # ][ #  # ]:          0 :     std::string best_match = ABQ_UNDEFINED;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1997                 :            : 
    1998                 :            :     // Search the map
    1999 [ #  # ][ #  # ]:          0 :     for( typename std::map< std::string, T >::iterator thisToken = tokenList.begin(); thisToken != tokenList.end();
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2000                 :            :          ++thisToken )
    2001                 :            :     {
    2002                 :            :         // If a perfect match break the loop (assume keyword list is unambiguous)
    2003 [ #  # ][ #  # ]:          0 :         if( token == ( *thisToken ).first )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2004                 :            :         {
    2005 [ #  # ][ #  # ]:          0 :             best_match = token;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2006                 :          0 :             break;
    2007                 :            :         }
    2008                 :            :         else
    2009                 :            :         {
    2010                 :            :             int short_length =
    2011 [ #  # ][ #  # ]:          0 :                 ( token.length() < ( *thisToken ).first.length() ? token.length() : ( *thisToken ).first.length() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2012                 :            :             // If the token matches the first token.length() characters of the keyword
    2013                 :            :             // consider this a match
    2014 [ #  # ][ #  # ]:          0 :             if( token.substr( short_length ) == ( *thisToken ).first.substr( short_length ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2015                 :            :             {
    2016 [ #  # ][ #  # ]:          0 :                 if( !found_match )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2017                 :            :                 {
    2018                 :            :                     // If no match already, record match and matching keyword
    2019                 :          0 :                     found_match = true;
    2020 [ #  # ][ #  # ]:          0 :                     best_match  = ( *thisToken ).first;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2021                 :            :                 }
    2022                 :            :                 else
    2023                 :            :                     // If match already set matching keyword to ABQ_AMBIGUOUS
    2024 [ #  # ][ #  # ]:          0 :                     best_match = ABQ_AMBIGUOUS;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    2025                 :            :             }
    2026                 :            :         }
    2027                 :            :     }
    2028                 :            : 
    2029                 :            :     // Possible return values: ABQ_UNDEFINED, keyword from list, ABQ_AMBIGUOUS
    2030                 :          0 :     return best_match;
    2031                 :            : }
    2032                 :            : 
    2033                 :            : // Convert a string to upper case
    2034                 :          0 : void ReadABAQUS::stringToUpper( const std::string& toBeConverted, std::string& converted )
    2035                 :            : {
    2036                 :          0 :     converted = toBeConverted;
    2037                 :            : 
    2038         [ #  # ]:          0 :     for( unsigned int i = 0; i < toBeConverted.length(); i++ )
    2039                 :          0 :         converted[i] = toupper( toBeConverted[i] );
    2040                 :          0 : }
    2041                 :            : 
    2042                 :            : // Extract key/value pairs from parameter list
    2043                 :          0 : void ReadABAQUS::extract_keyword_parameters( const std::vector< std::string >& tokens,
    2044                 :            :                                              std::map< std::string, std::string >& params )
    2045                 :            : {
    2046 [ #  # ][ #  # ]:          0 :     std::string key, value;
    2047                 :            : 
    2048                 :            :     // NOTE: skip first token - it is the keyword
    2049 [ #  # ][ #  # ]:          0 :     for( std::vector< std::string >::const_iterator token = tokens.begin() + 1; token != tokens.end(); ++token )
         [ #  # ][ #  # ]
    2050                 :            :     {
    2051         [ #  # ]:          0 :         std::string::size_type pos = token->find( '=' );
    2052 [ #  # ][ #  # ]:          0 :         stringToUpper( token->substr( 0, pos ), key );
                 [ #  # ]
    2053         [ #  # ]:          0 :         if( std::string::npos != pos )
    2054 [ #  # ][ #  # ]:          0 :             value = token->substr( pos + 1 );
                 [ #  # ]
    2055                 :            :         else
    2056         [ #  # ]:          0 :             value = "";
    2057                 :          0 :         pos         = key.find_first_not_of( ' ', 0 );
    2058 [ #  # ][ #  # ]:          0 :         key         = key.substr( pos );
    2059 [ #  # ][ #  # ]:          0 :         params[key] = value;
    2060                 :          0 :     }
    2061                 :          0 : }
    2062                 :            : 
    2063                 :            : // Tokenize a string based on a set of possible delimiters
    2064                 :          0 : void ReadABAQUS::tokenize( const std::string& str, std::vector< std::string >& tokens, const char* delimiters )
    2065                 :            : {
    2066                 :          0 :     tokens.clear();
    2067                 :            : 
    2068                 :          0 :     std::string::size_type pos, last = str.find_first_not_of( delimiters, 0 );
    2069                 :            : 
    2070         [ #  # ]:          0 :     while( std::string::npos != last )
    2071                 :            :     {
    2072                 :          0 :         pos = str.find_first_of( delimiters, last );
    2073         [ #  # ]:          0 :         if( std::string::npos == pos )
    2074                 :            :         {
    2075         [ #  # ]:          0 :             tokens.push_back( str.substr( last ) );
    2076                 :          0 :             last = std::string::npos;
    2077                 :            :         }
    2078                 :            :         else
    2079                 :            :         {
    2080         [ #  # ]:          0 :             tokens.push_back( str.substr( last, pos - last ) );
    2081                 :          0 :             last = str.find_first_not_of( delimiters, pos );
    2082                 :            :         }
    2083                 :            :     }
    2084                 :          0 : }
    2085                 :            : 
    2086 [ +  - ][ +  - ]:        228 : }  // namespace moab

Generated by: LCOV version 1.11