LCOV - code coverage report
Current view: top level - src/io - ReadSms.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 31 229 13.5 %
Date: 2020-12-16 07:07:30 Functions: 7 11 63.6 %
Branches: 16 579 2.8 %

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
       3                 :            :  * storing and accessing finite element mesh data.
       4                 :            :  *
       5                 :            :  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
       6                 :            :  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
       7                 :            :  * retains certain rights in this software.
       8                 :            :  *
       9                 :            :  * This library is free software; you can redistribute it and/or
      10                 :            :  * modify it under the terms of the GNU Lesser General Public
      11                 :            :  * License as published by the Free Software Foundation; either
      12                 :            :  * version 2.1 of the License, or (at your option) any later version.
      13                 :            :  *
      14                 :            :  */
      15                 :            : 
      16                 :            : /**
      17                 :            :  * \class ReadSms
      18                 :            :  * \brief Sms (http://www.geuz.org/sms) file reader
      19                 :            :  * \author Jason Kraftcheck
      20                 :            :  */
      21                 :            : 
      22                 :            : #include "ReadSms.hpp"
      23                 :            : #include "FileTokenizer.hpp"  // For file tokenizer
      24                 :            : #include "Internals.hpp"
      25                 :            : #include "moab/Interface.hpp"
      26                 :            : #include "moab/ReadUtilIface.hpp"
      27                 :            : #include "moab/Range.hpp"
      28                 :            : #include "MBTagConventions.hpp"
      29                 :            : #include "MBParallelConventions.h"
      30                 :            : #include "moab/CN.hpp"
      31                 :            : 
      32                 :            : #include <errno.h>
      33                 :            : #include <string.h>
      34                 :            : #include <map>
      35                 :            : #include <set>
      36                 :            : #include <iostream>
      37                 :            : 
      38                 :            : #define CHECK( a )                   \
      39                 :            :     if( MB_SUCCESS != result )       \
      40                 :            :     {                                \
      41                 :            :         std::cerr << a << std::endl; \
      42                 :            :         return result;               \
      43                 :            :     }
      44                 :            : 
      45                 :            : #define CHECKN( a ) \
      46                 :            :     if( n != ( a ) ) return MB_FILE_WRITE_ERROR
      47                 :            : 
      48                 :            : namespace moab
      49                 :            : {
      50                 :            : 
      51                 :          1 : ReaderIface* ReadSms::factory( Interface* iface )
      52                 :            : {
      53         [ +  - ]:          1 :     return new ReadSms( iface );
      54                 :            : }
      55                 :            : 
      56                 :          2 : ReadSms::ReadSms( Interface* impl ) : mdbImpl( impl ), globalId( 0 ), paramCoords( 0 ), geomDimension( 0 ), setId( 0 )
      57                 :            : {
      58         [ +  - ]:          1 :     mdbImpl->query_interface( readMeshIface );
      59                 :          1 : }
      60                 :            : 
      61                 :          3 : ReadSms::~ReadSms()
      62                 :            : {
      63         [ +  - ]:          1 :     if( readMeshIface )
      64                 :            :     {
      65                 :          1 :         mdbImpl->release_interface( readMeshIface );
      66                 :          1 :         readMeshIface = 0;
      67                 :            :     }
      68         [ -  + ]:          2 : }
      69                 :            : 
      70                 :          0 : ErrorCode ReadSms::read_tag_values( const char* /* file_name */, const char* /* tag_name */,
      71                 :            :                                     const FileOptions& /* opts */, std::vector< int >& /* tag_values_out */,
      72                 :            :                                     const SubsetList* /* subset_list */ )
      73                 :            : {
      74                 :          0 :     return MB_NOT_IMPLEMENTED;
      75                 :            : }
      76                 :            : 
      77                 :          1 : ErrorCode ReadSms::load_file( const char* filename, const EntityHandle* /* file_set */, const FileOptions& /* opts */,
      78                 :            :                               const ReaderIface::SubsetList* subset_list, const Tag* file_id_tag )
      79                 :            : {
      80 [ -  + ][ #  # ]:          1 :     if( subset_list ) { MB_SET_ERR( MB_UNSUPPORTED_OPERATION, "Reading subset of files not supported for Sms" ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      81                 :            : 
      82                 :          1 :     setId = 1;
      83                 :            : 
      84                 :            :     // Open file
      85                 :          1 :     FILE* file_ptr = fopen( filename, "r" );
      86 [ -  + ][ #  # ]:          1 :     if( !file_ptr ) { MB_SET_ERR( MB_FILE_DOES_NOT_EXIST, filename << ": " << strerror( errno ) ); }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      87                 :            : 
      88                 :          1 :     const ErrorCode result = load_file_impl( file_ptr, file_id_tag );
      89                 :          1 :     fclose( file_ptr );
      90                 :            : 
      91                 :          1 :     return result;
      92                 :            : }
      93                 :            : 
      94                 :          1 : ErrorCode ReadSms::load_file_impl( FILE* file_ptr, const Tag* file_id_tag )
      95                 :            : {
      96                 :          1 :     bool warned         = false;
      97                 :          1 :     double dum_params[] = { 0.0, 0.0, 0.0 };
      98                 :            : 
      99         [ +  - ]:          1 :     globalId = mdbImpl->globalId_tag();
     100                 :            : 
     101                 :            :     ErrorCode result =
     102         [ +  - ]:          1 :         mdbImpl->tag_get_handle( "PARAMETER_COORDS", 3, MB_TYPE_DOUBLE, paramCoords, MB_TAG_DENSE | MB_TAG_CREAT );
     103 [ -  + ][ #  # ]:          1 :     CHECK( "Failed to create param coords tag." );
                 [ #  # ]
     104                 :            : 
     105                 :          1 :     int negone = -1;
     106                 :            :     result     = mdbImpl->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1, MB_TYPE_INTEGER, geomDimension,
     107         [ +  - ]:          1 :                                       MB_TAG_SPARSE | MB_TAG_CREAT, &negone );
     108 [ -  + ][ #  # ]:          1 :     CHECK( "Failed to create geom dim tag." );
                 [ #  # ]
     109                 :            : 
     110                 :            :     int n;
     111                 :            :     char line[256], all_line[1024];
     112                 :            :     int file_type;
     113                 :            : 
     114 [ +  - ][ -  + ]:          1 :     if( fgets( all_line, sizeof( all_line ), file_ptr ) == NULL ) { return MB_FAILURE; }
     115         [ +  - ]:          1 :     if( sscanf( all_line, "%s %d", line, &file_type ) != 2 ) { return MB_FAILURE; }
     116                 :            : 
     117         [ #  # ]:          0 :     if( 3 == file_type )
     118                 :            :     {
     119         [ #  # ]:          0 :         result = read_parallel_info( file_ptr );
     120 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to read parallel info." );
                 [ #  # ]
     121                 :            :     }
     122                 :            : 
     123                 :            :     int nregions, nfaces, nedges, nvertices, npoints;
     124         [ #  # ]:          0 :     n = fscanf( file_ptr, "%d %d %d %d %d", &nregions, &nfaces, &nedges, &nvertices, &npoints );
     125         [ #  # ]:          0 :     CHECKN( 5 );
     126 [ #  # ][ #  # ]:          0 :     if( nregions < 0 || nfaces < 0 || nedges < 0 || nvertices < 0 || npoints < 0 ) return MB_FILE_WRITE_ERROR;
         [ #  # ][ #  # ]
                 [ #  # ]
     127                 :            : 
     128                 :            :     // Create the vertices
     129         [ #  # ]:          0 :     std::vector< double* > coord_arrays;
     130                 :          0 :     EntityHandle vstart = 0;
     131         [ #  # ]:          0 :     result              = readMeshIface->get_node_coords( 3, nvertices, MB_START_ID, vstart, coord_arrays );
     132 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get node arrays." );
                 [ #  # ]
     133                 :            : 
     134         [ #  # ]:          0 :     if( file_id_tag )
     135                 :            :     {
     136 [ #  # ][ #  # ]:          0 :         result = add_entities( vstart, nvertices, file_id_tag );MB_CHK_ERR( result );
         [ #  # ][ #  # ]
     137                 :            :     }
     138                 :            : 
     139                 :            :     EntityHandle this_gent, new_handle;
     140 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > gentities[4];
                 [ #  # ]
           [ #  #  #  # ]
     141                 :            :     int gent_id, dum_int;
     142                 :            :     int gent_type, num_connections;
     143                 :            : 
     144         [ #  # ]:          0 :     for( int i = 0; i < nvertices; i++ )
     145                 :            :     {
     146         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d", &gent_id );
     147         [ #  # ]:          0 :         CHECKN( 1 );
     148         [ #  # ]:          0 :         if( !gent_id ) continue;
     149                 :            : 
     150         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d %d %lf %lf %lf", &gent_type, &num_connections, coord_arrays[0] + i,
     151 [ #  # ][ #  # ]:          0 :                     coord_arrays[1] + i, coord_arrays[2] + i );
                 [ #  # ]
     152         [ #  # ]:          0 :         CHECKN( 5 );
     153                 :            : 
     154 [ #  # ][ #  # ]:          0 :         result = get_set( gentities, gent_type, gent_id, geomDimension, this_gent, file_id_tag );MB_CHK_ERR( result );
         [ #  # ][ #  # ]
     155                 :            : 
     156                 :          0 :         new_handle = vstart + i;
     157         [ #  # ]:          0 :         result     = mdbImpl->add_entities( this_gent, &new_handle, 1 );
     158 [ #  # ][ #  # ]:          0 :         CHECK( "Adding vertex to geom set failed." );
                 [ #  # ]
     159                 :            : 
     160      [ #  #  # ]:          0 :         switch( gent_type )
     161                 :            :         {
     162                 :            :             case 1:
     163         [ #  # ]:          0 :                 n = fscanf( file_ptr, "%le", dum_params );
     164         [ #  # ]:          0 :                 CHECKN( 1 );
     165         [ #  # ]:          0 :                 result = mdbImpl->tag_set_data( paramCoords, &new_handle, 1, dum_params );
     166 [ #  # ][ #  # ]:          0 :                 CHECK( "Failed to set param coords tag for vertex." );
                 [ #  # ]
     167                 :          0 :                 break;
     168                 :            :             case 2:
     169         [ #  # ]:          0 :                 n = fscanf( file_ptr, "%le %le %d", dum_params, dum_params + 1, &dum_int );
     170         [ #  # ]:          0 :                 CHECKN( 3 );
     171                 :          0 :                 dum_params[2] = dum_int;
     172         [ #  # ]:          0 :                 result        = mdbImpl->tag_set_data( paramCoords, &new_handle, 1, dum_params );
     173 [ #  # ][ #  # ]:          0 :                 CHECK( "Failed to set param coords tag for vertex." );
                 [ #  # ]
     174                 :          0 :                 break;
     175                 :            :             default:
     176                 :          0 :                 break;
     177                 :            :         }
     178                 :            :     }  // End of reading vertices
     179                 :            : 
     180                 :            :     // *******************************
     181                 :            :     //  Read Edges
     182                 :            :     // *******************************
     183                 :            : 
     184                 :            :     int vert1, vert2, num_pts;
     185         [ #  # ]:          0 :     std::vector< EntityHandle > everts( 2 );
     186                 :            :     EntityHandle estart, *connect;
     187         [ #  # ]:          0 :     result = readMeshIface->get_element_connect( nedges, 2, MBEDGE, 1, estart, connect );
     188 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to create array of edges." );
                 [ #  # ]
     189                 :            : 
     190         [ #  # ]:          0 :     if( file_id_tag )
     191                 :            :     {
     192         [ #  # ]:          0 :         result = add_entities( estart, nedges, file_id_tag );
     193         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     194                 :            :     }
     195                 :            : 
     196         [ #  # ]:          0 :     for( int i = 0; i < nedges; i++ )
     197                 :            :     {
     198         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d", &gent_id );
     199         [ #  # ]:          0 :         CHECKN( 1 );
     200         [ #  # ]:          0 :         if( !gent_id ) continue;
     201                 :            : 
     202         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d %d %d %d %d", &gent_type, &vert1, &vert2, &num_connections, &num_pts );
     203         [ #  # ]:          0 :         CHECKN( 5 );
     204 [ #  # ][ #  # ]:          0 :         if( vert1 < 1 || vert1 > nvertices ) return MB_FILE_WRITE_ERROR;
     205 [ #  # ][ #  # ]:          0 :         if( vert2 < 1 || vert2 > nvertices ) return MB_FILE_WRITE_ERROR;
     206                 :            : 
     207                 :          0 :         connect[0] = vstart + vert1 - 1;
     208                 :          0 :         connect[1] = vstart + vert2 - 1;
     209 [ #  # ][ #  # ]:          0 :         if( num_pts > 1 && !warned )
     210                 :            :         {
     211 [ #  # ][ #  # ]:          0 :             std::cout << "Warning: num_points > 1 not supported; choosing last one." << std::endl;
     212                 :          0 :             warned = true;
     213                 :            :         }
     214                 :            : 
     215         [ #  # ]:          0 :         result = get_set( gentities, gent_type, gent_id, geomDimension, this_gent, file_id_tag );
     216 [ #  # ][ #  # ]:          0 :         CHECK( "Problem getting geom set for edge." );
                 [ #  # ]
     217                 :            : 
     218                 :          0 :         new_handle = estart + i;
     219         [ #  # ]:          0 :         result     = mdbImpl->add_entities( this_gent, &new_handle, 1 );
     220 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to add edge to geom set." );
                 [ #  # ]
     221                 :            : 
     222                 :          0 :         connect += 2;
     223                 :            : 
     224         [ #  # ]:          0 :         for( int j = 0; j < num_pts; j++ )
     225                 :            :         {
     226      [ #  #  # ]:          0 :             switch( gent_type )
     227                 :            :             {
     228                 :            :                 case 1:
     229         [ #  # ]:          0 :                     n = fscanf( file_ptr, "%le", dum_params );
     230         [ #  # ]:          0 :                     CHECKN( 1 );
     231         [ #  # ]:          0 :                     result = mdbImpl->tag_set_data( paramCoords, &new_handle, 1, dum_params );
     232 [ #  # ][ #  # ]:          0 :                     CHECK( "Failed to set param coords tag for edge." );
                 [ #  # ]
     233                 :          0 :                     break;
     234                 :            :                 case 2:
     235         [ #  # ]:          0 :                     n = fscanf( file_ptr, "%le %le %d", dum_params, dum_params + 1, &dum_int );
     236         [ #  # ]:          0 :                     CHECKN( 3 );
     237                 :          0 :                     dum_params[2] = dum_int;
     238         [ #  # ]:          0 :                     result        = mdbImpl->tag_set_data( paramCoords, &new_handle, 1, dum_params );
     239 [ #  # ][ #  # ]:          0 :                     CHECK( "Failed to set param coords tag for edge." );
                 [ #  # ]
     240                 :          0 :                     break;
     241                 :            :                 default:
     242                 :          0 :                     break;
     243                 :            :             }
     244                 :            :         }
     245                 :            :     }  // End of reading edges
     246                 :            : 
     247                 :            :     // *******************************
     248                 :            :     //  Read Faces
     249                 :            :     // *******************************
     250 [ #  # ][ #  # ]:          0 :     std::vector< EntityHandle > bound_ents, bound_verts, new_faces;
                 [ #  # ]
     251                 :            :     int bound_id;
     252         [ #  # ]:          0 :     Range shverts;
     253         [ #  # ]:          0 :     new_faces.resize( nfaces );
     254                 :            :     int num_bounding;
     255                 :            : 
     256         [ #  # ]:          0 :     for( int i = 0; i < nfaces; i++ )
     257                 :            :     {
     258         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d", &gent_id );
     259         [ #  # ]:          0 :         CHECKN( 1 );
     260         [ #  # ]:          0 :         if( !gent_id ) continue;
     261                 :            : 
     262         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d %d", &gent_type, &num_bounding );
     263         [ #  # ]:          0 :         CHECKN( 2 );
     264                 :            : 
     265         [ #  # ]:          0 :         result = get_set( gentities, gent_type, gent_id, geomDimension, this_gent, file_id_tag );
     266 [ #  # ][ #  # ]:          0 :         CHECK( "Problem getting geom set for face." );
                 [ #  # ]
     267                 :            : 
     268         [ #  # ]:          0 :         bound_ents.resize( num_bounding + 1 );
     269         [ #  # ]:          0 :         bound_verts.resize( num_bounding );
     270         [ #  # ]:          0 :         for( int j = 0; j < num_bounding; j++ )
     271                 :            :         {
     272         [ #  # ]:          0 :             n = fscanf( file_ptr, "%d ", &bound_id );
     273         [ #  # ]:          0 :             CHECKN( 1 );
     274         [ #  # ]:          0 :             if( 0 > bound_id ) bound_id = abs( bound_id );
     275 [ #  # ][ #  # ]:          0 :             assert( 0 < bound_id && bound_id <= nedges );
     276 [ #  # ][ #  # ]:          0 :             if( bound_id < 1 || bound_id > nedges ) return MB_FILE_WRITE_ERROR;
     277         [ #  # ]:          0 :             bound_ents[j] = estart + abs( bound_id ) - 1;
     278                 :            :         }
     279                 :            : 
     280                 :            :         // Convert edge-based model to vertex-based one
     281         [ #  # ]:          0 :         for( int j = 0; j < num_bounding; j++ )
     282                 :            :         {
     283 [ #  # ][ #  # ]:          0 :             if( j == num_bounding - 1 ) bound_ents[j + 1] = bound_ents[0];
                 [ #  # ]
     284 [ #  # ][ #  # ]:          0 :             result = mdbImpl->get_adjacencies( &bound_ents[j], 2, 0, false, shverts );
     285 [ #  # ][ #  # ]:          0 :             CHECK( "Failed to get vertices bounding edge." );
                 [ #  # ]
     286 [ #  # ][ #  # ]:          0 :             assert( shverts.size() == 1 );
     287 [ #  # ][ #  # ]:          0 :             bound_verts[j] = *shverts.begin();
                 [ #  # ]
     288         [ #  # ]:          0 :             shverts.clear();
     289                 :            :         }
     290                 :            : 
     291         [ #  # ]:          0 :         result = mdbImpl->create_element( ( EntityType )( MBTRI + num_bounding - 3 ), &bound_verts[0],
     292 [ #  # ][ #  # ]:          0 :                                           bound_verts.size(), new_faces[i] );
     293 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to create edge." );
                 [ #  # ]
     294                 :            : 
     295 [ #  # ][ #  # ]:          0 :         result = mdbImpl->add_entities( this_gent, &new_faces[i], 1 );
     296 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to add edge to geom set." );
                 [ #  # ]
     297                 :            : 
     298         [ #  # ]:          0 :         int num_read = fscanf( file_ptr, "%d", &num_pts );
     299 [ #  # ][ #  # ]:          0 :         if( !num_pts || !num_read ) continue;
     300                 :            : 
     301         [ #  # ]:          0 :         for( int j = 0; j < num_pts; j++ )
     302                 :            :         {
     303      [ #  #  # ]:          0 :             switch( gent_type )
     304                 :            :             {
     305                 :            :                 case 1:
     306         [ #  # ]:          0 :                     n = fscanf( file_ptr, "%le", dum_params );
     307         [ #  # ]:          0 :                     CHECKN( 1 );
     308 [ #  # ][ #  # ]:          0 :                     result = mdbImpl->tag_set_data( paramCoords, &new_faces[i], 1, dum_params );
     309 [ #  # ][ #  # ]:          0 :                     CHECK( "Failed to set param coords tag for face." );
                 [ #  # ]
     310                 :          0 :                     break;
     311                 :            :                 case 2:
     312         [ #  # ]:          0 :                     n = fscanf( file_ptr, "%le %le %d", dum_params, dum_params + 1, &dum_int );
     313         [ #  # ]:          0 :                     CHECKN( 3 );
     314                 :          0 :                     dum_params[2] = dum_int;
     315 [ #  # ][ #  # ]:          0 :                     result        = mdbImpl->tag_set_data( paramCoords, &new_faces[i], 1, dum_params );
     316 [ #  # ][ #  # ]:          0 :                     CHECK( "Failed to set param coords tag for face." );
                 [ #  # ]
     317                 :          0 :                     break;
     318                 :            :                 default:
     319                 :          0 :                     break;
     320                 :            :             }
     321                 :            :         }
     322                 :            :     }  // End of reading faces
     323                 :            : 
     324         [ #  # ]:          0 :     if( file_id_tag )
     325                 :            :     {
     326 [ #  # ][ #  # ]:          0 :         result = readMeshIface->assign_ids( *file_id_tag, &new_faces[0], new_faces.size(), 1 );
     327         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     328                 :            :     }
     329                 :            : 
     330                 :            :     // *******************************
     331                 :            :     //  Read Regions
     332                 :            :     // *******************************
     333                 :            :     int sense[MAX_SUB_ENTITIES];
     334         [ #  # ]:          0 :     bound_verts.resize( MAX_SUB_ENTITIES );
     335                 :            : 
     336         [ #  # ]:          0 :     std::vector< EntityHandle > regions;
     337 [ #  # ][ #  # ]:          0 :     if( file_id_tag ) regions.resize( nregions );
     338         [ #  # ]:          0 :     for( int i = 0; i < nregions; i++ )
     339                 :            :     {
     340         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d", &gent_id );
     341         [ #  # ]:          0 :         CHECKN( 1 );
     342         [ #  # ]:          0 :         if( !gent_id ) continue;
     343         [ #  # ]:          0 :         result = get_set( gentities, 3, gent_id, geomDimension, this_gent, file_id_tag );
     344 [ #  # ][ #  # ]:          0 :         CHECK( "Couldn't get geom set for region." );
                 [ #  # ]
     345         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d", &num_bounding );
     346         [ #  # ]:          0 :         CHECKN( 1 );
     347         [ #  # ]:          0 :         bound_ents.resize( num_bounding );
     348         [ #  # ]:          0 :         for( int j = 0; j < num_bounding; j++ )
     349                 :            :         {
     350         [ #  # ]:          0 :             n = fscanf( file_ptr, "%d ", &bound_id );
     351         [ #  # ]:          0 :             CHECKN( 1 );
     352 [ #  # ][ #  # ]:          0 :             assert( abs( bound_id ) < (int)new_faces.size() + 1 && bound_id );
     353 [ #  # ][ #  # ]:          0 :             if( !bound_id || abs( bound_id ) > nfaces ) return MB_FILE_WRITE_ERROR;
     354         [ #  # ]:          0 :             sense[j]      = ( bound_id < 0 ) ? -1 : 1;
     355 [ #  # ][ #  # ]:          0 :             bound_ents[j] = new_faces[abs( bound_id ) - 1];
     356                 :            :         }
     357                 :            : 
     358                 :            :         EntityType etype;
     359 [ #  # ][ #  # ]:          0 :         result = readMeshIface->get_ordered_vertices( &bound_ents[0], sense, num_bounding, 3, &bound_verts[0], etype );
                 [ #  # ]
     360 [ #  # ][ #  # ]:          0 :         CHECK( "Failed in get_ordered_vertices." );
                 [ #  # ]
     361                 :            : 
     362                 :            :         // Make the element
     363 [ #  # ][ #  # ]:          0 :         result = mdbImpl->create_element( etype, &bound_verts[0], CN::VerticesPerEntity( etype ), new_handle );
                 [ #  # ]
     364 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to create region." );
                 [ #  # ]
     365                 :            : 
     366         [ #  # ]:          0 :         result = mdbImpl->add_entities( this_gent, &new_handle, 1 );
     367 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to add region to geom set." );
                 [ #  # ]
     368                 :            : 
     369 [ #  # ][ #  # ]:          0 :         if( file_id_tag ) regions[i] = new_handle;
     370                 :            : 
     371         [ #  # ]:          0 :         n = fscanf( file_ptr, "%d ", &dum_int );
     372         [ #  # ]:          0 :         CHECKN( 1 );
     373                 :            :     }  // End of reading regions
     374                 :            : 
     375         [ #  # ]:          0 :     if( file_id_tag )
     376                 :            :     {
     377 [ #  # ][ #  # ]:          0 :         result = readMeshIface->assign_ids( *file_id_tag, &regions[0], regions.size(), 1 );
     378         [ #  # ]:          0 :         if( MB_SUCCESS != result ) return result;
     379                 :            :     }
     380                 :            : 
     381         [ #  # ]:          1 :     return MB_SUCCESS;
     382                 :            : }
     383                 :            : 
     384                 :          0 : ErrorCode ReadSms::get_set( std::vector< EntityHandle >* sets, int set_dim, int set_id, Tag dim_tag,
     385                 :            :                             EntityHandle& this_set, const Tag* file_id_tag )
     386                 :            : {
     387                 :          0 :     ErrorCode result = MB_SUCCESS;
     388                 :            : 
     389 [ #  # ][ #  # ]:          0 :     if( set_dim < 0 || set_dim > 3 ) return MB_FILE_WRITE_ERROR;
     390                 :            : 
     391 [ #  # ][ #  # ]:          0 :     if( (int)sets[set_dim].size() <= set_id || !sets[set_dim][set_id] )
                 [ #  # ]
     392                 :            :     {
     393 [ #  # ][ #  # ]:          0 :         if( (int)sets[set_dim].size() <= set_id ) sets[set_dim].resize( set_id + 1, 0 );
     394                 :            : 
     395         [ #  # ]:          0 :         if( !sets[set_dim][set_id] )
     396                 :            :         {
     397                 :          0 :             result = mdbImpl->create_meshset( MESHSET_SET, sets[set_dim][set_id] );
     398         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     399                 :          0 :             result = mdbImpl->tag_set_data( globalId, &sets[set_dim][set_id], 1, &set_id );
     400         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     401                 :          0 :             result = mdbImpl->tag_set_data( dim_tag, &sets[set_dim][set_id], 1, &set_dim );
     402         [ #  # ]:          0 :             if( MB_SUCCESS != result ) return result;
     403                 :            : 
     404         [ #  # ]:          0 :             if( file_id_tag )
     405                 :            :             {
     406                 :          0 :                 result = mdbImpl->tag_set_data( *file_id_tag, &sets[set_dim][set_id], 1, &setId );
     407                 :          0 :                 ++setId;
     408                 :            :             }
     409                 :            :         }
     410                 :            :     }
     411                 :            : 
     412                 :          0 :     this_set = sets[set_dim][set_id];
     413                 :            : 
     414                 :          0 :     return result;
     415                 :            : }
     416                 :            : 
     417                 :          0 : ErrorCode ReadSms::read_parallel_info( FILE* file_ptr )
     418                 :            : {
     419                 :            :     // ErrorCode result;
     420                 :            : 
     421                 :            :     // Read partition info
     422                 :            :     int nparts, part_id, num_ifaces, num_corner_ents;
     423         [ #  # ]:          0 :     int num_read = fscanf( file_ptr, "%d %d %d %d", &nparts, &part_id, &num_ifaces, &num_corner_ents );
     424         [ #  # ]:          0 :     if( !num_read ) return MB_FAILURE;
     425                 :            : 
     426                 :            :     // Read interfaces
     427                 :            :     int iface_id, iface_dim, iface_own, num_iface_corners;
     428                 :            :     // EntityHandle this_iface;
     429                 :          0 :     std::vector< int >* iface_corners = NULL;
     430         [ #  # ]:          0 :     for( int i = 0; i < num_ifaces; i++ )
     431                 :            :     {
     432         [ #  # ]:          0 :         num_read = fscanf( file_ptr, "%d %d %d %d", &iface_id, &iface_dim, &iface_own, &num_iface_corners );
     433         [ #  # ]:          0 :         if( !num_read ) return MB_FAILURE;
     434                 :            : 
     435                 :            :         // result = get_set(sets, iface_dim, iface_id, dim_tag, iface_own, this_iface);
     436                 :            :         // CHECK("Failed to make iface set.");
     437                 :            : 
     438                 :            :         // Read the corner ids and store them on the set for now
     439 [ #  # ][ #  # ]:          0 :         iface_corners = new std::vector< int >( num_iface_corners );
     440         [ #  # ]:          0 :         for( int j = 0; j < num_iface_corners; j++ )
     441                 :            :         {
     442 [ #  # ][ #  # ]:          0 :             num_read = fscanf( file_ptr, "%d", &( *iface_corners )[j] );
     443         [ #  # ]:          0 :             if( !num_read )
     444                 :            :             {
     445         [ #  # ]:          0 :                 delete iface_corners;
     446                 :          0 :                 return MB_FAILURE;
     447                 :            :             }
     448                 :            :         }
     449                 :            : 
     450                 :            :         // result = tag_set_data(ifaceCornerTag, &this_iface, 1,
     451                 :            :         //&iface_corners);
     452                 :            :         // CHECK("Failed to set iface corner tag.");
     453                 :            : 
     454         [ #  # ]:          0 :         delete iface_corners;
     455                 :          0 :         iface_corners = NULL;
     456                 :            :     }
     457                 :            : 
     458                 :            :     // Interface data has been read
     459                 :          0 :     return MB_SUCCESS;
     460                 :            : }
     461                 :            : 
     462                 :          0 : ErrorCode ReadSms::add_entities( EntityHandle start, EntityHandle count, const Tag* file_id_tag )
     463                 :            : {
     464 [ #  # ][ #  # ]:          0 :     if( !count || !file_id_tag ) return MB_FAILURE;
     465                 :            : 
     466         [ #  # ]:          0 :     Range range;
     467         [ #  # ]:          0 :     range.insert( start, start + count - 1 );
     468         [ #  # ]:          0 :     return readMeshIface->assign_ids( *file_id_tag, range, 1 );
     469                 :            : }
     470                 :            : 
     471 [ +  - ][ +  - ]:        228 : }  // namespace moab

Generated by: LCOV version 1.11