LCOV - code coverage report
Current view: top level - itaps/irel - test_entsetFB.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 156 286 54.5 %
Date: 2020-12-16 07:07:30 Functions: 6 8 75.0 %
Branches: 100 343 29.2 %

           Branch data     Line data    Source code
       1                 :            : #include "moab/MOABConfig.h"
       2                 :            : #include "FBiGeom.h"
       3                 :            : #include "iMesh.h"
       4                 :            : #include "iRel.h"
       5                 :            : 
       6                 :            : #include "stdio.h"
       7                 :            : #include "stdlib.h"
       8                 :            : #include "string.h"
       9                 :            : 
      10                 :            : #define DEFAULT_TEST_FILE  shell.h5m
      11                 :            : #define DEFAULT_TEST_FILE1 shellQuad.h5m
      12                 :            : 
      13                 :            : // clang-format off
      14                 :            : 
      15                 :            : #define STRINGIFY_( X ) #X
      16                 :            : #define STRINGIFY( X )  STRINGIFY_( X )
      17                 :            : #if defined( MESHDIR ) && defined( MOAB_HAVE_HDF5 )
      18                 :            : #define DEFAULT_INPUT_FILE  STRINGIFY( MESHDIR/fbigeom/DEFAULT_TEST_FILE )
      19                 :            : #define DEFAULT_INPUT_FILE1 STRINGIFY( MESHDIR/fbigeom/DEFAULT_TEST_FILE1 )
      20                 :            : #else
      21                 :            : #error Specify MESHDIR to compile test
      22                 :            : #endif
      23                 :            : 
      24                 :            : #define CHECK_SIZE_C( type, array, allocated_size, size )            \
      25                 :            :     if( NULL == *array || *allocated_size == 0 )                     \
      26                 :            :     {                                                                \
      27                 :            :         *array          = (type*)malloc( sizeof( type ) * size );    \
      28                 :            :         *allocated_size = size;                                      \
      29                 :            :     }                                                                \
      30                 :            :     else if( *allocated_size < size )                                \
      31                 :            :     {                                                                \
      32                 :            :         printf( "   Array passed in is non-zero but too short.\n" ); \
      33                 :            :     }
      34                 :            : 
      35                 :            : // clang-format on
      36                 :            : 
      37                 :            : typedef void* iRel_EntityHandle;
      38                 :            : 
      39                 :            : /*!
      40                 :            :   prints out a result string based on the value of error_code
      41                 :            : */
      42                 :          4 : void handle_error_code( const int result, int* number_failed, int* number_not_implemented, int* number_successful )
      43                 :            : {
      44         [ +  - ]:          4 :     if( result )
      45                 :            :     {
      46                 :          4 :         printf( "Success" );
      47                 :          4 :         ( *number_successful )++;
      48                 :            :     }
      49                 :            :     else
      50                 :            :     {
      51                 :          0 :         printf( "Failure" );
      52                 :          0 :         ( *number_failed )++;
      53                 :            :     }
      54                 :          4 : }
      55                 :            : 
      56                 :          0 : int print_geom_info( FBiGeom_Instance geom, iBase_EntityHandle gent )
      57                 :            : {
      58                 :            :     /* print information about this entity */
      59                 :            :     int ent_type;
      60                 :            :     int result;
      61                 :          0 :     const char* type_names[] = { "Vertex", "Edge", "Face", "Region" };
      62                 :            : 
      63         [ #  # ]:          0 :     FBiGeom_getEntType( geom, gent, &ent_type, &result );
      64                 :            : 
      65         [ #  # ]:          0 :     if( iBase_SUCCESS != result )
      66                 :            :     {
      67         [ #  # ]:          0 :         printf( "Trouble getting entity adjacencies or types." );
      68                 :          0 :         return 0;
      69                 :            :     }
      70                 :            : 
      71         [ #  # ]:          0 :     printf( "%s 0x%lx\n", type_names[ent_type], (unsigned long)gent );
      72                 :            : 
      73                 :          0 :     return 1;
      74                 :            : }
      75                 :            : 
      76                 :          0 : int print_mesh_info( iMesh_Instance mesh, iBase_EntityHandle ment )
      77                 :            : {
      78                 :            :     /* print information about this entity */
      79                 :            : 
      80                 :            :     /* get adjacencies first; assume not more than 50 */
      81                 :          0 :     iBase_EntityHandle adj_ents[50], *adj_ents_ptr = adj_ents;
      82                 :          0 :     int ent_types[50], *ent_types_ptr              = ent_types;
      83                 :          0 :     int adj_ents_alloc = 50, adj_ents_size, ent_types_size, ent_types_allocated = 50;
      84                 :            :     int result;
      85                 :          0 :     iBase_TagHandle* ment_tags = NULL;
      86                 :            :     int ment_tags_size, ment_tags_alloc;
      87                 :            :     char** tag_names;
      88                 :            :     int i;
      89                 :          0 :     const char* type_names[] = { "Vertex", "Edge", "Face", "Region" };
      90                 :            :     int tag_type;
      91                 :            : 
      92                 :          0 :     char* dum_handle     = NULL;
      93                 :          0 :     int dum_handle_alloc = 0, dum_handle_size = 0;
      94                 :            :     int int_data;
      95                 :            :     double dbl_data;
      96                 :            :     iBase_EntityHandle eh_data;
      97                 :            : 
      98         [ #  # ]:          0 :     iMesh_getEntAdj( mesh, ment, iBase_ALL_TYPES, &adj_ents_ptr, &adj_ents_alloc, &adj_ents_size, &result );
      99                 :            : 
     100         [ #  # ]:          0 :     if( iBase_SUCCESS != result ) return 0;
     101                 :            : 
     102                 :            :     /* put this ent on the end, then get types */
     103                 :          0 :     adj_ents[adj_ents_size] = ment;
     104                 :            :     iMesh_getEntArrType( mesh, adj_ents, adj_ents_size + 1, &ent_types_ptr, &ent_types_allocated, &ent_types_size,
     105         [ #  # ]:          0 :                          &result );
     106         [ #  # ]:          0 :     if( iBase_SUCCESS != result )
     107                 :            :     {
     108         [ #  # ]:          0 :         printf( "Trouble getting entity adjacencies or types." );
     109                 :          0 :         return 0;
     110                 :            :     }
     111                 :            : 
     112                 :            :     /* get tags on ment */
     113         [ #  # ]:          0 :     iMesh_getAllTags( mesh, ment, &ment_tags, &ment_tags_alloc, &ment_tags_size, &result );
     114                 :            : 
     115         [ #  # ]:          0 :     printf( "Trouble getting tags on an entity or their names." );
     116                 :            : 
     117                 :            :     /* while we're at it, get all the tag names */
     118                 :            : 
     119                 :          0 :     tag_names = (char**)malloc( ment_tags_size * sizeof( char* ) );
     120                 :            : 
     121         [ #  # ]:          0 :     for( i = 0; i < ment_tags_size; i++ )
     122                 :            :     {
     123                 :          0 :         tag_names[i] = (char*)malloc( 120 * sizeof( char ) );
     124         [ #  # ]:          0 :         iMesh_getTagName( mesh, ment_tags[i], tag_names[i], &result, 120 );
     125                 :            :     }
     126                 :            : 
     127                 :            :     /* now print the information */
     128         [ #  # ]:          0 :     printf( "%s %ld:\n", type_names[ent_types[ent_types_size - 1]], (long)ment );
     129         [ #  # ]:          0 :     printf( "Adjacencies:" );
     130         [ #  # ]:          0 :     for( i = 0; i < adj_ents_size; i++ )
     131                 :            :     {
     132 [ #  # ][ #  # ]:          0 :         if( i > 0 ) printf( ", " );
     133         [ #  # ]:          0 :         printf( "%s %ld", type_names[ent_types[i]], (long)adj_ents[i] );
     134                 :            :     }
     135         [ #  # ]:          0 :     printf( "\nTags: \n" );
     136         [ #  # ]:          0 :     for( i = 0; i < ment_tags_size; i++ )
     137                 :            :     {
     138         [ #  # ]:          0 :         printf( "%s ", tag_names[i] );
     139         [ #  # ]:          0 :         iMesh_getTagType( mesh, ment_tags[i], &tag_type, &result );
     140         [ #  # ]:          0 :         if( iBase_SUCCESS != result )
     141         [ #  # ]:          0 :             printf( "(trouble getting type...)\n" );
     142                 :            :         else
     143                 :            :         {
     144                 :          0 :             dum_handle       = NULL;
     145                 :          0 :             dum_handle_alloc = 0, dum_handle_size = 0;
     146                 :            : 
     147   [ #  #  #  #  :          0 :             switch( tag_type )
                      # ]
     148                 :            :             {
     149                 :            :                 case iBase_INTEGER:
     150         [ #  # ]:          0 :                     iMesh_getIntData( mesh, ment, ment_tags[i], &int_data, &result );
     151         [ #  # ]:          0 :                     printf( "(Int value=%d)", int_data );
     152                 :          0 :                     break;
     153                 :            :                 case iBase_DOUBLE:
     154         [ #  # ]:          0 :                     iMesh_getDblData( mesh, ment, ment_tags[i], &dbl_data, &result );
     155         [ #  # ]:          0 :                     printf( "(Dbl value=%f)", dbl_data );
     156                 :          0 :                     break;
     157                 :            :                 case iBase_ENTITY_HANDLE:
     158         [ #  # ]:          0 :                     iMesh_getEHData( mesh, ment, ment_tags[i], &eh_data, &result );
     159         [ #  # ]:          0 :                     printf( "(EH value=%ld)", (long)eh_data );
     160                 :          0 :                     break;
     161                 :            :                 case iBase_BYTES:
     162                 :          0 :                     iMesh_getData( mesh, ment, ment_tags[i], (void**)&dum_handle, &dum_handle_alloc, &dum_handle_size,
     163         [ #  # ]:          0 :                                    &result );
     164 [ #  # ][ #  # ]:          0 :                     if( NULL != dum_handle && dum_handle_size > 0 ) printf( "(Opaque value=%c)", dum_handle[0] );
                 [ #  # ]
     165                 :          0 :                     break;
     166                 :            :             }
     167                 :            :         }
     168                 :            : 
     169         [ #  # ]:          0 :         printf( "\n" );
     170                 :            :     }
     171         [ #  # ]:          0 :     printf( "(end tags)\n\n" );
     172                 :          0 :     free( ment_tags );
     173                 :          0 :     return 1;
     174                 :            : }
     175                 :            : 
     176                 :            : /*!
     177                 :            :   @test
     178                 :            :   Load Mesh
     179                 :            :   @li Load a geom and a mesh file
     180                 :            : */
     181                 :          1 : int load_geom_mesh_test( const char* geom_filename, const char* mesh_filename, FBiGeom_Instance geom,
     182                 :            :                          iMesh_Instance mesh )
     183                 :            : {
     184                 :            :     /* load a geom */
     185                 :            :     int result;
     186         [ +  - ]:          1 :     FBiGeom_load( geom, geom_filename, 0, &result, strlen( geom_filename ), 0 );
     187         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     188                 :            :     {
     189         [ #  # ]:          0 :         printf( "ERROR : can not load a geometry\n" );
     190                 :          0 :         return 0;
     191                 :            :     }
     192                 :            : 
     193                 :            :     /* load a mesh */
     194         [ +  - ]:          1 :     iMesh_load( mesh, 0, mesh_filename, 0, &result, strlen( mesh_filename ), 0 );
     195         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     196                 :            :     {
     197         [ #  # ]:          0 :         printf( "ERROR : can not load a mesh\n" );
     198                 :          0 :         return 0;
     199                 :            :     }
     200                 :            : 
     201                 :          1 :     return 1;
     202                 :            : }
     203                 :            : 
     204                 :            : /*!
     205                 :            :   @test
     206                 :            :   TSTTLasso create relation  Test
     207                 :            :   @li Create relation between geom and mesh
     208                 :            : */
     209                 :          1 : int create_relation_test( iRel_Instance assoc, FBiGeom_Instance geom, iMesh_Instance mesh, iRel_PairHandle* pair )
     210                 :            : {
     211                 :            :     int result;
     212                 :            : 
     213                 :            :     iBase_Instance iface1, iface2;
     214                 :            :     int type1, type2;
     215                 :            :     int ent_or_set1, ent_or_set2;
     216                 :            :     int status1, status2;
     217                 :            : 
     218                 :            :     iRel_PairHandle tmp_pair;
     219                 :          1 :     iRel_PairHandle* pair_ptr = &tmp_pair;
     220                 :          1 :     int pairs_alloc           = 1, pairs_size;
     221                 :            : 
     222                 :            :     /* create an relation, entity to set */
     223                 :            :     iRel_createPair( assoc, geom, iRel_ENTITY, iRel_FBIGEOM_IFACE, iRel_ACTIVE, mesh, iRel_SET, iRel_IMESH_IFACE,
     224         [ +  - ]:          1 :                      iRel_ACTIVE, pair, &result );
     225         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     226                 :            :     {
     227         [ #  # ]:          0 :         printf( "Couldn't create a new relation.\n" );
     228                 :          0 :         return 0;
     229                 :            :     }
     230                 :            : 
     231                 :            :     iRel_getPairInfo( assoc, *pair, &iface1, &ent_or_set1, &type1, &status1, &iface2, &ent_or_set2, &type2, &status2,
     232         [ +  - ]:          1 :                       &result );
     233         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     234                 :            :     {
     235         [ #  # ]:          0 :         printf( "Couldn't retrieve relation info.\n" );
     236                 :          0 :         return 0;
     237                 :            :     }
     238 [ +  - ][ +  - ]:          1 :     if( iface1 != geom || ent_or_set1 != iRel_ENTITY || type1 != iRel_FBIGEOM_IFACE || iface2 != mesh ||
         [ +  - ][ +  - ]
                 [ +  - ]
     239         [ -  + ]:          1 :         ent_or_set2 != iRel_SET || type2 != iRel_IMESH_IFACE )
     240                 :            :     {
     241         [ #  # ]:          0 :         printf( "Unexpected relation info returned.\n" );
     242                 :          0 :         return 0;
     243                 :            :     }
     244                 :            : 
     245         [ +  - ]:          1 :     iRel_findPairs( assoc, geom, &pair_ptr, &pairs_alloc, &pairs_size, &result );
     246         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     247                 :            :     {
     248         [ #  # ]:          0 :         printf( "Couldn't find relation pair when querying geom.\n" );
     249                 :          0 :         return 0;
     250                 :            :     }
     251 [ +  - ][ -  + ]:          1 :     if( pairs_size != 1 || tmp_pair != *pair )
     252                 :            :     {
     253         [ #  # ]:          0 :         printf( "Unexpected relation pairs returned when querying geom.\n" );
     254                 :          0 :         return 0;
     255                 :            :     }
     256                 :            : 
     257         [ +  - ]:          1 :     iRel_findPairs( assoc, mesh, &pair_ptr, &pairs_alloc, &pairs_size, &result );
     258         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     259                 :            :     {
     260         [ #  # ]:          0 :         printf( "Couldn't find relation pair when querying mesh.\n" );
     261                 :          0 :         return 0;
     262                 :            :     }
     263 [ +  - ][ -  + ]:          1 :     if( pairs_size != 1 || tmp_pair != *pair )
     264                 :            :     {
     265         [ #  # ]:          0 :         printf( "Unexpected relation pairs returned when querying mesh.\n" );
     266                 :          0 :         return 0;
     267                 :            :     }
     268                 :            : 
     269                 :          1 :     return 1;
     270                 :            : }
     271                 :            : 
     272                 :            : /*!
     273                 :            :   @test
     274                 :            :   TSTTLasso relate geom and mesh Test
     275                 :            :   @li Check relation between geom and mesh
     276                 :            : */
     277                 :          1 : int relate_geom_mesh_test( iRel_Instance assoc, FBiGeom_Instance geom, iMesh_Instance mesh, iRel_PairHandle pair )
     278                 :            : {
     279                 :            :     /* relate geometry entities with coresponding mesh entity sets */
     280                 :          1 :     iBase_EntityHandle* gentities = NULL;
     281                 :          1 :     int gentities_size = 0, gentities_alloc = 0;
     282                 :            :     int result;
     283                 :            : 
     284                 :          1 :     iBase_EntitySetHandle* mentity_handles = NULL;
     285                 :          1 :     int mentity_handles_size = 0, mentity_handles_alloc = 0;
     286                 :            : 
     287                 :          1 :     const char* dim_tag_name = "GEOM_DIMENSION";
     288                 :            :     iBase_TagHandle dim_tag_mesh;
     289                 :            : 
     290                 :            :     iBase_EntitySetHandle* mentities_vec;
     291                 :            :     int mentities_vec_size;
     292                 :            :     int i;
     293                 :            : 
     294                 :          1 :     iBase_EntitySetHandle* out_mentities = NULL;
     295                 :          1 :     int out_mentities_size = 0, out_mentities_alloc = 0;
     296                 :            : 
     297                 :          1 :     iBase_EntitySetHandle* out_mentities2 = NULL;
     298                 :          1 :     int out_mentities2_size = 0, out_mentities2_alloc = 0;
     299                 :            : 
     300                 :          1 :     iBase_EntityHandle* out_gentities = NULL;
     301                 :          1 :     int out_gentities_size = 0, out_gentities_alloc = 0;
     302                 :            : 
     303         [ +  - ]:          1 :     FBiGeom_getEntities( geom, NULL, iBase_VERTEX, &gentities, &gentities_alloc, &gentities_size, &result );
     304         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     305                 :            :     {
     306         [ #  # ]:          0 :         printf( "Failed to get gentities by type in relate_geom_mesh_test.\n" );
     307                 :          0 :         return 0;
     308                 :            :     }
     309                 :            : 
     310         [ +  - ]:          1 :     iRel_inferEntArrRelations( assoc, pair, gentities, gentities_size, 0, &result );
     311         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     312                 :            :     {
     313         [ #  # ]:          0 :         printf( "Failed to relate geom entities in relate_geom_mesh_test.\n" );
     314                 :          0 :         return 0;
     315                 :            :     }
     316                 :            : 
     317                 :            :     /* relate coresponding mesh entity sets for geometry entities */
     318                 :            :     /* get 1-dimensional mesh entitysets */
     319                 :            : 
     320         [ +  - ]:          1 :     iMesh_getEntSets( mesh, NULL, 1, &mentity_handles, &mentity_handles_alloc, &mentity_handles_size, &result );
     321         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     322                 :            :     {
     323         [ #  # ]:          0 :         printf( "Problem to get all entity sets.\n" );
     324                 :          0 :         return 0;
     325                 :            :     }
     326                 :            : 
     327                 :            :     /* get geom dimension tags for mesh entitysets */
     328         [ +  - ]:          1 :     iMesh_createTag( mesh, dim_tag_name, 1, iBase_INTEGER, &dim_tag_mesh, &result, 15 );
     329 [ +  - ][ -  + ]:          1 :     if( iBase_SUCCESS != result && result != iBase_TAG_ALREADY_EXISTS )
     330                 :            :     {
     331         [ #  # ]:          0 :         printf( "Couldn't create geom dim tag for mesh entities.\n" );
     332                 :          0 :         return 0;
     333                 :            :     }
     334                 :            : 
     335                 :            :     /* get 1-dimensional mesh entitysets */
     336                 :          1 :     mentities_vec      = (iBase_EntitySetHandle*)malloc( mentity_handles_size * sizeof( iBase_EntitySetHandle ) );
     337                 :          1 :     mentities_vec_size = 0;
     338                 :            : 
     339         [ +  + ]:         16 :     for( i = 0; i < mentity_handles_size; i++ )
     340                 :            :     {
     341                 :            :         int dim;
     342         [ +  - ]:         15 :         iMesh_getEntSetIntData( mesh, mentity_handles[i], dim_tag_mesh, &dim, &result );
     343         [ -  + ]:         15 :         if( iBase_SUCCESS != result ) continue;
     344                 :            : 
     345         [ +  + ]:         15 :         if( dim == 1 ) mentities_vec[mentities_vec_size++] = mentity_handles[i];
     346                 :            :     }
     347                 :            : 
     348         [ +  - ]:          1 :     iRel_inferSetArrRelations( assoc, pair, mentities_vec, mentities_vec_size, 1, &result );
     349         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     350                 :            :     {
     351         [ #  # ]:          0 :         printf( "Failed to relate mesh entities in relate_geom_mesh_test.\n" );
     352                 :          0 :         return 0;
     353                 :            :     }
     354                 :            : 
     355                 :            :     /* relate all geometry and mesh entities */
     356         [ +  - ]:          1 :     iRel_inferAllRelations( assoc, pair, &result );
     357         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     358                 :            :     {
     359         [ #  # ]:          0 :         printf( "Failed to relate all geom and mesh entities in relate_geom_mesh_test.\n" );
     360                 :          0 :         return 0;
     361                 :            :     }
     362                 :            : 
     363                 :            :     /* reset geom entities list and get all geom entities (prev
     364                 :            :        only vertices) */
     365                 :          1 :     free( gentities );
     366                 :          1 :     gentities       = NULL;
     367                 :          1 :     gentities_alloc = 0;
     368         [ +  - ]:          1 :     FBiGeom_getEntities( geom, NULL, iBase_ALL_TYPES, &gentities, &gentities_alloc, &gentities_size, &result );
     369         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     370                 :            :     {
     371         [ #  # ]:          0 :         printf( "Failed to get gentities by type in relate_geom_mesh_test.\n" );
     372                 :          0 :         return 0;
     373                 :            :     }
     374                 :            : 
     375                 :            :     /* get related mesh entity sets for geometry entities */
     376                 :            :     iRel_getEntArrSetArrRelation( assoc, pair, gentities, gentities_size, 0, &out_mentities, &out_mentities_alloc,
     377         [ +  - ]:          1 :                                   &out_mentities_size, &result );
     378         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     379                 :            :     {
     380         [ #  # ]:          0 :         printf( "Failed to get geom entities in relate_geom_mesh_test.\n" );
     381                 :          0 :         return 0;
     382                 :            :     }
     383                 :            : 
     384         [ -  + ]:          1 :     if( out_mentities_size != gentities_size )
     385                 :            :     {
     386         [ #  # ]:          0 :         printf( "Number of input geom entities and output mesh entity sets should be same\n" );
     387                 :          0 :         return 0;
     388                 :            :     }
     389                 :            : 
     390                 :            :     /* now try deleting this relation */
     391         [ +  - ]:          1 :     iRel_rmvEntArrRelation( assoc, pair, gentities, gentities_size, 0, &result );
     392         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     393                 :            :     {
     394         [ #  # ]:          0 :         printf( "Failed to remove relation in relate_geom_mesh_test.\n" );
     395                 :          0 :         return 0;
     396                 :            :     }
     397                 :            :     iRel_getEntArrSetArrRelation( assoc, pair, gentities, gentities_size, 0, &out_mentities2, &out_mentities2_alloc,
     398         [ +  - ]:          1 :                                   &out_mentities2_size, &result );
     399         [ -  + ]:          1 :     if( iBase_SUCCESS == result )
     400                 :            :     {
     401         [ #  # ]:          0 :         printf( "Shouldn't have gotten mesh sets in relate_geom_mesh_test.\n" );
     402                 :          0 :         return 0;
     403                 :            :     }
     404                 :            : 
     405                 :            :     /* restore the relation, since we need it later */
     406         [ +  - ]:          1 :     iRel_setEntArrSetArrRelation( assoc, pair, gentities, gentities_size, out_mentities, out_mentities_size, &result );
     407         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     408                 :            :     {
     409         [ #  # ]:          0 :         printf( "Failed to restore relation in relate_geom_mesh_test.\n" );
     410                 :          0 :         return 0;
     411                 :            :     }
     412                 :            : 
     413                 :            :     /* get related geometry entities for mesh entity sets */
     414                 :            :     iRel_getSetArrEntArrRelation( assoc, pair, out_mentities, out_mentities_size, 1, &out_gentities,
     415         [ +  - ]:          1 :                                   &out_gentities_alloc, &out_gentities_size, &result );
     416         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     417                 :            :     {
     418         [ #  # ]:          0 :         printf( "Failed to get mesh entities in relate_geom_mesh_test.\n" );
     419                 :          0 :         return 0;
     420                 :            :     }
     421                 :            : 
     422         [ -  + ]:          1 :     if( out_mentities_size != out_gentities_size )
     423                 :            :     {
     424         [ #  # ]:          0 :         printf( "Number of input mesh entity sets and output geom entities should be same\n" );
     425                 :          0 :         return 0;
     426                 :            :     }
     427                 :          1 :     free( mentity_handles );
     428                 :          1 :     mentity_handles = NULL;
     429                 :          1 :     free( gentities );
     430                 :          1 :     gentities = NULL;
     431                 :          1 :     free( mentity_handles );
     432                 :          1 :     mentity_handles = NULL;
     433                 :          1 :     free( out_mentities );
     434                 :          1 :     out_mentities = NULL;
     435                 :          1 :     free( mentities_vec );
     436                 :          1 :     mentities_vec = NULL;
     437                 :          1 :     free( out_gentities );
     438                 :          1 :     out_gentities = NULL;
     439                 :          1 :     return 1;
     440                 :            : }
     441                 :            : 
     442                 :            : /*!
     443                 :            :   @test
     444                 :            :   TSTTAssoc move to test
     445                 :            :   @li Move meshes onto the given geometry
     446                 :            : */
     447                 :          1 : int query_relations_test( iRel_Instance assoc, FBiGeom_Instance geom, iMesh_Instance mesh, iRel_PairHandle pair )
     448                 :            : {
     449                 :            :     /* get all the geom entities, and find relation to some mesh entity */
     450                 :          1 :     iBase_EntityHandle* gentities = NULL;
     451                 :          1 :     int gentities_size = 0, gentities_alloc = 0;
     452                 :            :     int result;
     453                 :            : 
     454                 :          1 :     iBase_EntitySetHandle* out_mentities = NULL;
     455                 :          1 :     int out_mentities_size, out_mentities_alloc = 0;
     456                 :            : 
     457                 :            :     char descr[120];
     458                 :            :     int i;
     459                 :            :     int is_list;
     460                 :            : 
     461                 :          1 :     iBase_EntityHandle* out_gentities = NULL;
     462                 :          1 :     int out_gentities_size, out_gentities_alloc = 0;
     463                 :            : 
     464         [ +  - ]:          1 :     FBiGeom_getEntities( geom, NULL, iBase_ALL_TYPES, &gentities, &gentities_alloc, &gentities_size, &result );
     465         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     466                 :            :     {
     467         [ #  # ]:          0 :         printf( "Problem getting all geom entities.\n" );
     468                 :          0 :         return 0;
     469                 :            :     }
     470                 :            : 
     471                 :            :     iRel_getEntArrSetArrRelation( assoc, pair, gentities, gentities_size, 0, &out_mentities, &out_mentities_alloc,
     472         [ +  - ]:          1 :                                   &out_mentities_size, &result );
     473                 :            :     /* might not all be */
     474         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     475                 :            :     {
     476         [ #  # ]:          0 :         printf( "Failed to get mesh entities related to geom entities in query_relations_test.\n" );
     477                 :            : 
     478         [ #  # ]:          0 :         iRel_getDescription( assoc, descr, sizeof( descr ) - 1 );
     479         [ #  # ]:          0 :         printf( "Entities missing relations: %s\n", descr );
     480                 :            : 
     481         [ #  # ]:          0 :         for( i = 0; i < gentities_size; i++ )
     482                 :            :         {
     483         [ #  # ]:          0 :             print_geom_info( geom, gentities[i] );
     484                 :            :         }
     485                 :            : 
     486                 :          0 :         return 0;
     487                 :            :     }
     488                 :            : 
     489                 :            :     /* check that they're all non-null */
     490         [ -  + ]:          1 :     if( out_mentities_size != gentities_size )
     491                 :            :     {
     492         [ #  # ]:          0 :         printf( "Number of mesh & related geom entities don't match.\n" );
     493                 :          0 :         return 0;
     494                 :            :     }
     495                 :            : 
     496                 :            :     /* check to make sure they're mesh sets; how to do that? */
     497         [ +  + ]:         16 :     for( i = 0; i < out_mentities_size; i++ )
     498                 :            :     {
     499         [ +  - ]:         15 :         iMesh_isList( mesh, (iBase_EntitySetHandle)out_mentities[i], &is_list, &result );
     500         [ -  + ]:         15 :         if( iBase_SUCCESS != result )
     501                 :            :         {
     502         [ #  # ]:          0 :             printf( "Entity set returned from classification wasn't valid.\n" );
     503                 :          0 :             return 0;
     504                 :            :         }
     505                 :            :     }
     506                 :            : 
     507                 :            :     /* now turn around and check classification of those mesh entities */
     508                 :            :     iRel_getSetArrEntArrRelation( assoc, pair, out_mentities, out_mentities_size, 1, &out_gentities,
     509         [ +  - ]:          1 :                                   &out_gentities_alloc, &out_gentities_size, &result );
     510         [ -  + ]:          1 :     if( iBase_SUCCESS != result )
     511                 :            :     {
     512         [ #  # ]:          0 :         printf( "Failed to get geom entities related to mesh entities in query_relations_test.\n" );
     513                 :          0 :         return 0;
     514                 :            :     }
     515                 :            : 
     516                 :            :     /* check that they're all non-null */
     517         [ -  + ]:          1 :     if( out_mentities_size != out_gentities_size )
     518                 :            :     {
     519         [ #  # ]:          0 :         printf( "Number of geom & related mesh entities don't match.\n" );
     520                 :          0 :         return 0;
     521                 :            :     }
     522                 :            : 
     523                 :          1 :     free( gentities );
     524                 :          1 :     gentities = NULL;
     525                 :          1 :     free( out_mentities );
     526                 :          1 :     out_mentities = NULL;
     527                 :          1 :     free( out_gentities );
     528                 :          1 :     out_gentities = NULL;
     529                 :            :     /* ok, we're done */
     530                 :          1 :     return 1;
     531                 :            : }
     532                 :            : 
     533                 :          1 : int main( int argc, char* argv[] )
     534                 :            : {
     535                 :            :     /* Check command line arg */
     536                 :          1 :     const char* geom_filename = DEFAULT_INPUT_FILE;
     537                 :          1 :     const char* mesh_filename = DEFAULT_INPUT_FILE1;
     538                 :            : 
     539                 :            :     int result;
     540                 :          1 :     int number_tests                 = 0;
     541                 :          1 :     int number_tests_successful      = 0;
     542                 :          1 :     int number_tests_not_implemented = 0;
     543                 :          1 :     int number_tests_failed          = 0;
     544                 :            : 
     545                 :            :     FBiGeom_Instance geom;
     546                 :            :     iMesh_Instance mesh;
     547                 :            :     iRel_Instance assoc;
     548                 :            :     iRel_PairHandle pair;
     549                 :            : 
     550 [ -  + ][ #  # ]:          1 :     if( argc == 2 && !strcmp( argv[1], "-h" ) )
     551                 :            :     {
     552         [ #  # ]:          0 :         printf( "Usage: %s <geom_filename> <mesh_filename>\n", argv[0] );
     553                 :          0 :         return 1;
     554                 :            :     }
     555         [ -  + ]:          1 :     else if( argc == 2 )
     556                 :            :     {
     557                 :          0 :         geom_filename = argv[1];
     558                 :          0 :         mesh_filename = argv[1];
     559                 :            :     }
     560         [ -  + ]:          1 :     else if( argc == 3 )
     561                 :            :     {
     562                 :          0 :         geom_filename = argv[1];
     563                 :          0 :         mesh_filename = argv[2];
     564                 :            :     }
     565                 :            : 
     566                 :            :     /* initialize the Geometry */
     567         [ +  - ]:          1 :     FBiGeom_newGeom( 0, &geom, &result, 0 );
     568                 :            : 
     569                 :            :     /* initialize the Mesh */
     570         [ +  - ]:          1 :     iMesh_newMesh( 0, &mesh, &result, 0 );
     571                 :            : 
     572                 :            :     /* initialize the Associate */
     573         [ +  - ]:          1 :     iRel_create( 0, &assoc, &result, 0 );
     574                 :            : 
     575                 :            :     /* Print out Header information */
     576         [ +  - ]:          1 :     printf( "\n\niRel TEST PROGRAM:\n\n" );
     577                 :            : 
     578                 :            :     /* load_geom_mesh test */
     579         [ +  - ]:          1 :     printf( "   load_geom_mesh: " );
     580         [ +  - ]:          1 :     result = load_geom_mesh_test( geom_filename, mesh_filename, geom, mesh );
     581         [ +  - ]:          1 :     handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
     582                 :          1 :     number_tests++;
     583         [ +  - ]:          1 :     printf( "\n" );
     584                 :            : 
     585                 :            :     /* create_relation test */
     586         [ +  - ]:          1 :     printf( "   create_relation: " );
     587         [ +  - ]:          1 :     result = create_relation_test( assoc, geom, mesh, &pair );
     588         [ +  - ]:          1 :     handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
     589                 :          1 :     number_tests++;
     590         [ +  - ]:          1 :     printf( "\n" );
     591                 :            : 
     592                 :            :     /* relate_geom_mesh test */
     593         [ +  - ]:          1 :     printf( "   relate_geom_mesh: " );
     594         [ +  - ]:          1 :     result = relate_geom_mesh_test( assoc, geom, mesh, pair );
     595         [ +  - ]:          1 :     handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
     596                 :          1 :     number_tests++;
     597         [ +  - ]:          1 :     printf( "\n" );
     598                 :            : 
     599                 :            :     /* query_relations test */
     600         [ +  - ]:          1 :     printf( "   query_relations: " );
     601         [ +  - ]:          1 :     result = query_relations_test( assoc, geom, mesh, pair );
     602         [ +  - ]:          1 :     handle_error_code( result, &number_tests_failed, &number_tests_not_implemented, &number_tests_successful );
     603                 :          1 :     number_tests++;
     604         [ +  - ]:          1 :     printf( "\n" );
     605                 :            : 
     606                 :            :     /* summary */
     607                 :            : 
     608         [ +  - ]:          1 :     printf( "\niRel TEST SUMMARY: \n" );
     609         [ +  - ]:          1 :     printf( "   Number Tests:           %d\n", number_tests );
     610         [ +  - ]:          1 :     printf( "   Number Successful:      %d\n", number_tests_successful );
     611         [ +  - ]:          1 :     printf( "   Number Not Implemented: %d\n", number_tests_not_implemented );
     612         [ +  - ]:          1 :     printf( "   Number Failed:          %d\n", number_tests_failed );
     613         [ +  - ]:          1 :     printf( "\n\n" );
     614                 :            : 
     615         [ +  - ]:          1 :     iRel_destroy( assoc, &result );
     616         [ +  - ]:          1 :     iMesh_dtor( mesh, &result );
     617         [ +  - ]:          1 :     FBiGeom_dtor( geom, &result );
     618                 :            : 
     619                 :          1 :     return number_tests_failed != 0;
     620                 :            : }

Generated by: LCOV version 1.11