LCOV - code coverage report
Current view: top level - itaps/fbigeom - testSmooth.cpp (source / functions) Hit Total Coverage
Test: coverage_sk.info Lines: 301 779 38.6 %
Date: 2020-12-16 07:07:30 Functions: 40 59 67.8 %
Branches: 396 2262 17.5 %

           Branch data     Line data    Source code
       1                 :            : /**
       2                 :            :  * This library is free software; you can redistribute it and/or
       3                 :            :  * modify it under the terms of the GNU Lesser General Public
       4                 :            :  * License as published by the Free Software Foundation; either
       5                 :            :  * version 2.1 of the License, or (at your option) any later version.
       6                 :            :  *
       7                 :            :  */
       8                 :            : /**
       9                 :            :  * \file testgeom.cc
      10                 :            :  *
      11                 :            :  * \brief testgeom, a unit test for the ITAPS geometry interface
      12                 :            :  *
      13                 :            :  */
      14                 :            : #include "FBiGeom.h"
      15                 :            : #include <iostream>
      16                 :            : #include <set>
      17                 :            : #include <algorithm>
      18                 :            : #include <vector>
      19                 :            : #include <iterator>
      20                 :            : #include <algorithm>
      21                 :            : #include <iomanip>
      22                 :            : #include <assert.h>
      23                 :            : #include <string.h>
      24                 :            : #include <math.h>
      25                 :            : #define CHECK( STR ) \
      26                 :            :     if( err != iBase_SUCCESS ) return print_error( STR, err, geom, __FILE__, __LINE__ )
      27                 :            : 
      28                 :            : #define STRINGIFY( S )  XSTRINGIFY( S )
      29                 :            : #define XSTRINGIFY( S ) #S
      30                 :            : 
      31                 :          0 : static bool print_error( const char* desc, int err, FBiGeom_Instance geom, const char* file, int line )
      32                 :            : {
      33                 :            :     char buffer[1024];
      34         [ #  # ]:          0 :     FBiGeom_getDescription( geom, buffer, sizeof( buffer ) );
      35                 :          0 :     buffer[sizeof( buffer ) - 1] = '\0';
      36                 :            : 
      37 [ #  # ][ #  # ]:          0 :     std::cerr << "ERROR: " << desc << std::endl
                 [ #  # ]
      38 [ #  # ][ #  # ]:          0 :               << "  Error code: " << err << std::endl
                 [ #  # ]
      39 [ #  # ][ #  # ]:          0 :               << "  Error desc: " << buffer << std::endl
                 [ #  # ]
      40 [ #  # ][ #  # ]:          0 :               << "  At        : " << file << ':' << line << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
      41                 :            : 
      42                 :          0 :     return false;  // must always return false or CHECK macro will break
      43                 :            : }
      44                 :            : 
      45                 :            : typedef iBase_TagHandle TagHandle;
      46                 :            : typedef iBase_EntityHandle GentityHandle;
      47                 :            : typedef iBase_EntitySetHandle GentitysetHandle;
      48                 :            : 
      49                 :            : /* Frees allocated arrays for us */
      50                 :            : template < typename T >
      51                 :            : class SimpleArray
      52                 :            : {
      53                 :            :   private:
      54                 :            :     T* arr;
      55                 :            :     int arrSize;
      56                 :            :     int arrAllocated;
      57                 :            : 
      58                 :            :   public:
      59                 :         85 :     SimpleArray() : arr( 0 ), arrSize( 0 ), arrAllocated( 0 ) {}
      60                 :          0 :     SimpleArray( unsigned s ) : arrSize( s ), arrAllocated( s )
      61                 :            :     {
      62                 :          0 :         arr = (T*)malloc( s * sizeof( T ) );
      63         [ #  # ]:          0 :         for( unsigned i = 0; i < s; ++i )
      64         [ #  # ]:          0 :             new( arr + i ) T();
      65                 :          0 :     }
      66                 :            : 
      67                 :         85 :     ~SimpleArray()
      68                 :            :     {
      69 [ +  + ][ #  # ]:        360 :         for( int i = 0; i < size(); ++i )
         [ +  + ][ +  + ]
                 [ +  + ]
      70                 :        275 :             arr[i].~T();
      71                 :         85 :         free( arr );
      72                 :         85 :     }
      73                 :            : 
      74                 :         85 :     T** ptr()
      75                 :            :     {
      76                 :         85 :         return &arr;
      77                 :            :     }
      78                 :        502 :     int& size()
      79                 :            :     {
      80                 :        502 :         return arrSize;
      81                 :            :     }
      82                 :            :     int size() const
      83                 :            :     {
      84                 :            :         return arrSize;
      85                 :            :     }
      86                 :         85 :     int& capacity()
      87                 :            :     {
      88                 :         85 :         return arrAllocated;
      89                 :            :     }
      90                 :            :     int capacity() const
      91                 :            :     {
      92                 :            :         return arrAllocated;
      93                 :            :     }
      94                 :            : 
      95                 :            :     typedef T* iterator;
      96                 :            :     typedef const T* const_iterator;
      97                 :         57 :     iterator begin()
      98                 :            :     {
      99                 :         57 :         return arr;
     100                 :            :     }
     101                 :            :     const_iterator begin() const
     102                 :            :     {
     103                 :            :         return arr;
     104                 :            :     }
     105                 :         87 :     iterator end()
     106                 :            :     {
     107                 :         87 :         return arr + arrSize;
     108                 :            :     }
     109                 :            :     const_iterator end() const
     110                 :            :     {
     111                 :            :         return arr + arrSize;
     112                 :            :     }
     113                 :            : 
     114                 :         64 :     T& operator[]( unsigned idx )
     115                 :            :     {
     116                 :         64 :         return arr[idx];
     117                 :            :     }
     118                 :            :     T operator[]( unsigned idx ) const
     119                 :            :     {
     120                 :            :         return arr[idx];
     121                 :            :     }
     122                 :            : };
     123                 :            : 
     124                 :            : #define ARRAY_INOUT( A ) A.ptr(), &A.capacity(), &A.size()
     125                 :            : #define ARRAY_IN( A )    &A[0], A.size()
     126                 :            : 
     127                 :            : bool smooth_test( const std::string& filename, FBiGeom_Instance );
     128                 :            : 
     129                 :            : bool tags_test( FBiGeom_Instance geom );
     130                 :            : bool tag_get_set_test( FBiGeom_Instance geom );
     131                 :            : bool tag_info_test( FBiGeom_Instance geom );
     132                 :            : bool gentityset_test( FBiGeom_Instance geom, bool /*multiset*/, bool /*ordered*/ );
     133                 :            : bool topology_adjacencies_test( FBiGeom_Instance geom );
     134                 :            : bool geometry_evaluation_test( FBiGeom_Instance geom );
     135                 :            : bool construct_test( FBiGeom_Instance geom );
     136                 :            : bool primitives_test( FBiGeom_Instance geom );
     137                 :            : bool transforms_test( FBiGeom_Instance geom );
     138                 :            : bool booleans_test( FBiGeom_Instance geom );
     139                 :            : bool shutdown_test( FBiGeom_Instance geom, std::string& engine_opt );
     140                 :            : bool save_entset_test( FBiGeom_Instance geom );
     141                 :            : bool mesh_size_test( FBiGeom_Instance geom );
     142                 :            : bool normals_test( FBiGeom_Instance geom );
     143                 :            : 
     144                 :            : bool ray_test( FBiGeom_Instance geom );
     145                 :            : 
     146                 :          7 : void handle_error_code( const bool result, int& number_failed, int& /*number_not_implemented*/, int& number_successful )
     147                 :            : {
     148         [ +  - ]:          7 :     if( result )
     149                 :            :     {
     150                 :          7 :         std::cout << "Success";
     151                 :          7 :         number_successful++;
     152                 :            :     }
     153                 :            :     else
     154                 :            :     {
     155                 :          0 :         std::cout << "Failure";
     156                 :          0 :         number_failed++;
     157                 :            :     }
     158                 :          7 : }
     159                 :            : 
     160                 :          1 : int main( int argc, char* argv[] )
     161                 :            : {
     162         [ +  - ]:          1 :     std::string filename = STRINGIFY( MESHDIR ) "/shell.h5m";
     163         [ +  - ]:          2 :     std::string engine_opt;
     164                 :            : 
     165 [ +  - ][ +  - ]:          1 :     if( argc == 1 ) { std::cout << "Using default input file: " << filename << std::endl; }
         [ +  - ][ +  - ]
     166         [ #  # ]:          0 :     else if( argc == 2 )
     167                 :            :     {
     168         [ #  # ]:          0 :         filename = argv[1];
     169                 :            :     }
     170                 :            :     else
     171                 :            :     {
     172 [ #  # ][ #  # ]:          0 :         std::cerr << "Usage: " << argv[0] << " [geom_filename]" << std::endl;
         [ #  # ][ #  # ]
     173                 :          0 :         return 1;
     174                 :            :     }
     175                 :            : 
     176                 :            :     bool result;
     177                 :          1 :     int number_tests                 = 0;
     178                 :          1 :     int number_tests_successful      = 0;
     179                 :          1 :     int number_tests_not_implemented = 0;
     180                 :          1 :     int number_tests_failed          = 0;
     181                 :            : 
     182                 :            :     // initialize the Mesh
     183                 :            :     int err;
     184                 :            :     FBiGeom_Instance geom;
     185         [ +  - ]:          1 :     FBiGeom_newGeom( engine_opt.c_str(), &geom, &err, engine_opt.length() );
     186 [ -  + ][ #  # ]:          1 :     CHECK( "Interface initialization didn't work properly." );
     187                 :            : 
     188                 :            :     // Print out Header information
     189         [ +  - ]:          1 :     std::cout << "\n\nITAPS GEOMETRY INTERFACE TEST PROGRAM:\n\n";
     190                 :            :     // gLoad test
     191                 :            : 
     192         [ +  - ]:          1 :     std::cout << "   Smooth faceting load and initialization: \n";
     193         [ +  - ]:          1 :     result = smooth_test( filename, geom );
     194         [ +  - ]:          1 :     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
     195                 :            : 
     196                 :          1 :     number_tests++;
     197         [ +  - ]:          1 :     std::cout << "\n";
     198                 :            : 
     199                 :            :     // tags test
     200         [ +  - ]:          1 :     std::cout << "   tags: ";
     201         [ +  - ]:          1 :     result = tags_test( geom );
     202         [ +  - ]:          1 :     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
     203                 :          1 :     number_tests++;
     204         [ +  - ]:          1 :     std::cout << "\n";
     205                 :            :     /*
     206                 :            :      // gentitysets test
     207                 :            :      std::cout << "   gentity sets: ";
     208                 :            :      result = gentityset_test(geom, false, false);
     209                 :            :      handle_error_code(result, number_tests_failed,
     210                 :            :      number_tests_not_implemented,
     211                 :            :      number_tests_successful);
     212                 :            :      number_tests++;
     213                 :            :      std::cout << "\n";
     214                 :            :      */
     215                 :            :     // topology adjacencies test
     216         [ +  - ]:          1 :     std::cout << "   topology adjacencies: ";
     217         [ +  - ]:          1 :     result = topology_adjacencies_test( geom );
     218         [ +  - ]:          1 :     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
     219                 :          1 :     number_tests++;
     220         [ +  - ]:          1 :     std::cout << "\n";
     221                 :            : 
     222                 :            :     // geometry evaluation test
     223         [ +  - ]:          1 :     std::cout << "   geometry evaluation: \n";
     224         [ +  - ]:          1 :     result = geometry_evaluation_test( geom );
     225         [ +  - ]:          1 :     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
     226                 :          1 :     number_tests++;
     227         [ +  - ]:          1 :     std::cout << "\n";
     228                 :            : 
     229                 :            :     // normals evaluation test
     230         [ +  - ]:          1 :     std::cout << "   normals geometry evaluation: \n";
     231         [ +  - ]:          1 :     result = normals_test( geom );
     232         [ +  - ]:          1 :     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
     233                 :          1 :     number_tests++;
     234         [ +  - ]:          1 :     std::cout << "\n";
     235                 :            : 
     236                 :            :     // ray tracing test
     237         [ +  - ]:          1 :     std::cout << "   ray intersection test: \n";
     238         [ +  - ]:          1 :     result = ray_test( geom );
     239         [ +  - ]:          1 :     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
     240                 :          1 :     number_tests++;
     241         [ +  - ]:          1 :     std::cout << "\n";
     242                 :            :     /*
     243                 :            :      // construct test
     244                 :            :      std::cout << "   construct: ";
     245                 :            :      result = construct_test(geom);
     246                 :            :      handle_error_code(result, number_tests_failed,
     247                 :            :      number_tests_not_implemented,
     248                 :            :      number_tests_successful);
     249                 :            :      number_tests++;
     250                 :            :      std::cout << "\n";
     251                 :            : 
     252                 :            :      // primitives test
     253                 :            :      std::cout << "   primitives: ";
     254                 :            :      result = primitives_test(geom);
     255                 :            :      handle_error_code(result, number_tests_failed,
     256                 :            :      number_tests_not_implemented,
     257                 :            :      number_tests_successful);
     258                 :            :      number_tests++;
     259                 :            :      std::cout << "\n";
     260                 :            : 
     261                 :            :      // transforms test
     262                 :            :      std::cout << "   transforms: ";
     263                 :            :      result = transforms_test(geom);
     264                 :            :      handle_error_code(result, number_tests_failed,
     265                 :            :      number_tests_not_implemented,
     266                 :            :      number_tests_successful);
     267                 :            :      number_tests++;
     268                 :            :      std::cout << "\n";
     269                 :            : 
     270                 :            :      // booleans test
     271                 :            :      std::cout << "   booleans: ";
     272                 :            :      result = booleans_test(geom);
     273                 :            :      handle_error_code(result, number_tests_failed,
     274                 :            :      number_tests_not_implemented,
     275                 :            :      number_tests_successful);
     276                 :            :      number_tests++;
     277                 :            :      std::cout << "\n";
     278                 :            : 
     279                 :            :      #if defined(HAVE_ACIS) && !defined(FORCE_OCC)
     280                 :            :      std::cout << "   mesh size: ";
     281                 :            :      result = mesh_size_test(geom);
     282                 :            :      handle_error_code(result, number_tests_failed,
     283                 :            :      number_tests_not_implemented,
     284                 :            :      number_tests_successful);
     285                 :            :      number_tests++;
     286                 :            :      std::cout << "\n";
     287                 :            : 
     288                 :            :      // save entset test
     289                 :            :      std::cout << "   save entset: ";
     290                 :            :      result = save_entset_test(geom);
     291                 :            :      handle_error_code(result, number_tests_failed,
     292                 :            :      number_tests_not_implemented,
     293                 :            :      number_tests_successful);
     294                 :            :      number_tests++;
     295                 :            :      std::cout << "\n";
     296                 :            :      #endif
     297                 :            :      */
     298                 :            :     // shutdown test
     299         [ +  - ]:          1 :     std::cout << "   shutdown: ";
     300         [ +  - ]:          1 :     result = shutdown_test( geom, engine_opt );
     301         [ +  - ]:          1 :     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
     302                 :          1 :     number_tests++;
     303         [ +  - ]:          1 :     std::cout << "\n";
     304                 :            : 
     305                 :            :     // summary
     306                 :            : 
     307         [ +  - ]:          1 :     std::cout << "\nTSTT TEST SUMMARY: \n"
     308 [ +  - ][ +  - ]:          1 :               << "   Number Tests:           " << number_tests << "\n"
                 [ +  - ]
     309 [ +  - ][ +  - ]:          1 :               << "   Number Successful:      " << number_tests_successful << "\n"
                 [ +  - ]
     310 [ +  - ][ +  - ]:          1 :               << "   Number Not Implemented: " << number_tests_not_implemented << "\n"
                 [ +  - ]
     311 [ +  - ][ +  - ]:          1 :               << "   Number Failed:          " << number_tests_failed << "\n\n"
                 [ +  - ]
     312         [ +  - ]:          1 :               << std::endl;
     313                 :            : 
     314                 :          2 :     return number_tests_failed;
     315                 :            : }
     316                 :            : 
     317                 :            : /*!
     318                 :            :  @test
     319                 :            :  Load Mesh
     320                 :            :  @li Load a mesh file
     321                 :            :  */
     322                 :            : 
     323                 :          1 : bool smooth_test( const std::string& filename, FBiGeom_Instance geom )
     324                 :            : {
     325                 :            :     int err;
     326                 :          1 :     char opts[] = "SMOOTH;";
     327 [ +  - ][ +  - ]:          1 :     FBiGeom_load( geom, &filename[0], opts, &err, filename.length(), 8 );
     328                 :            :     // FBiGeom_load( geom, &filename[0], 0, &err, filename.length(), 0 );
     329 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : can not load a geometry" );
     330                 :            : 
     331                 :            :     iBase_EntitySetHandle root_set;
     332         [ +  - ]:          1 :     FBiGeom_getRootSet( geom, &root_set, &err );
     333 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : getRootSet failed!" );
     334                 :            : 
     335                 :            :     // print out the number of entities
     336 [ +  - ][ +  - ]:          1 :     std::cout << "Model contents: " << std::endl;
     337                 :          1 :     const char* gtype[] = { "vertices: ", "edges: ", "faces: ", "regions: " };
     338         [ +  + ]:          5 :     for( int i = 0; i <= 3; ++i )
     339                 :            :     {
     340                 :            :         int count;
     341         [ +  - ]:          4 :         FBiGeom_getNumOfType( geom, root_set, i, &count, &err );
     342 [ -  + ][ #  # ]:          4 :         CHECK( "Error: problem getting entities after gLoad." );
     343 [ +  - ][ +  - ]:          4 :         std::cout << gtype[i] << count << std::endl;
                 [ +  - ]
     344                 :            :     }
     345                 :            : 
     346                 :          1 :     return true;
     347                 :            : }
     348                 :            : /*!
     349                 :            :  @test
     350                 :            :  Test tag creating, reading, writing, deleting
     351                 :            :  @li Load a mesh file
     352                 :            :  */
     353                 :          1 : bool tags_test( FBiGeom_Instance geom )
     354                 :            : {
     355                 :          1 :     bool success = tag_info_test( geom );
     356         [ -  + ]:          1 :     if( !success ) return success;
     357                 :            : 
     358                 :          1 :     success = tag_get_set_test( geom );
     359         [ -  + ]:          1 :     if( !success ) return success;
     360                 :            : 
     361                 :          1 :     return true;
     362                 :            : }
     363                 :            : 
     364                 :          1 : bool tag_info_test( FBiGeom_Instance geom )
     365                 :            : {
     366                 :            :     int err;
     367                 :            : 
     368                 :            :     iBase_EntitySetHandle root_set;
     369         [ +  - ]:          1 :     FBiGeom_getRootSet( geom, &root_set, &err );
     370 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : getRootSet failed!" );
     371                 :            : 
     372                 :            :     // create an arbitrary tag, size 4
     373                 :            :     iBase_TagHandle this_tag, tmp_handle;
     374 [ +  - ][ +  - ]:          2 :     std::string tag_name( "tag_info tag" ), tmp_name;
     375 [ +  - ][ +  - ]:          1 :     FBiGeom_createTag( geom, &tag_name[0], 4, iBase_BYTES, &this_tag, &err, tag_name.length() );
     376 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : can not create a tag." );
     377                 :            : 
     378                 :            :     // get information on the tag
     379                 :            : 
     380                 :            :     char name_buffer[256];
     381         [ +  - ]:          1 :     FBiGeom_getTagName( geom, this_tag, name_buffer, &err, sizeof( name_buffer ) );
     382 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : Couldn't get tag name." );
     383 [ +  - ][ -  + ]:          1 :     if( tag_name != name_buffer )
     384                 :            :     {
     385 [ #  # ][ #  # ]:          0 :         std::cerr << "ERROR: getTagName returned '" << name_buffer << "' for tag created as '" << tag_name << "'"
         [ #  # ][ #  # ]
                 [ #  # ]
     386         [ #  # ]:          0 :                   << std::endl;
     387                 :          0 :         return false;
     388                 :            :     }
     389                 :            : 
     390 [ +  - ][ +  - ]:          1 :     FBiGeom_getTagHandle( geom, &tag_name[0], &tmp_handle, &err, tag_name.length() );
     391 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : Couldn't get tag handle." );
     392         [ -  + ]:          1 :     if( tmp_handle != this_tag )
     393                 :            :     {
     394 [ #  # ][ #  # ]:          0 :         std::cerr << "ERROR: getTagHandle didn't return consistent result." << std::endl;
     395                 :          0 :         return false;
     396                 :            :     }
     397                 :            : 
     398                 :            :     int tag_size;
     399         [ +  - ]:          1 :     FBiGeom_getTagSizeBytes( geom, this_tag, &tag_size, &err );
     400 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : Couldn't get tag size." );
     401         [ -  + ]:          1 :     if( tag_size != 4 )
     402                 :            :     {
     403 [ #  # ][ #  # ]:          0 :         std::cerr << "ERROR: getTagSizeBytes: expected 4, got " << tag_size << std::endl;
                 [ #  # ]
     404                 :          0 :         return false;
     405                 :            :     }
     406                 :            : 
     407         [ +  - ]:          1 :     FBiGeom_getTagSizeValues( geom, this_tag, &tag_size, &err );
     408 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : Couldn't get tag size." );
     409         [ -  + ]:          1 :     if( tag_size != 4 )
     410                 :            :     {
     411 [ #  # ][ #  # ]:          0 :         std::cerr << "ERROR: getTagSizeValues: expected 4, got " << tag_size << std::endl;
                 [ #  # ]
     412                 :          0 :         return false;
     413                 :            :     }
     414                 :            : 
     415                 :            :     int tag_type;
     416         [ +  - ]:          1 :     FBiGeom_getTagType( geom, this_tag, &tag_type, &err );
     417 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : Couldn't get tag type." );
     418         [ -  + ]:          1 :     if( tag_type != iBase_BYTES )
     419                 :            :     {
     420 [ #  # ][ #  # ]:          0 :         std::cerr << "ERROR: getTagType: expected " << iBase_BYTES << ", got " << tag_type << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
     421                 :          0 :         return false;
     422                 :            :     }
     423                 :            : 
     424         [ +  - ]:          1 :     FBiGeom_destroyTag( geom, this_tag, true, &err );
     425 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : Couldn't delete a tag." );
     426                 :            : 
     427                 :            :     // print information about all the tags in the model
     428                 :            : 
     429         [ +  - ]:          2 :     std::set< iBase_TagHandle > tags;
     430         [ +  - ]:          2 :     SimpleArray< iBase_EntityHandle > entities;
     431 [ +  - ][ +  - ]:          1 :     FBiGeom_getEntities( geom, root_set, iBase_ALL_TYPES, ARRAY_INOUT( entities ), &err );
         [ +  - ][ +  - ]
     432 [ -  + ][ #  # ]:          1 :     CHECK( "getEntities( ..., iBase_ALL_TYPES, ... ) failed." );
     433 [ +  - ][ +  + ]:         16 :     for( int i = 0; i < entities.size(); ++i )
     434                 :            :     {
     435         [ +  - ]:         15 :         SimpleArray< iBase_TagHandle > tag_arr;
     436 [ +  - ][ +  - ]:         15 :         FBiGeom_getAllTags( geom, entities[i], ARRAY_INOUT( tag_arr ), &err );
         [ +  - ][ +  - ]
                 [ +  - ]
     437 [ -  + ][ #  # ]:         15 :         CHECK( "getAllTags failed." );
     438 [ +  - ][ +  - ]:         15 :         std::copy( tag_arr.begin(), tag_arr.end(), std::inserter( tags, tags.begin() ) );
         [ +  - ][ +  - ]
                 [ +  - ]
     439                 :         15 :     }
     440                 :            : 
     441         [ +  - ]:          1 :     std::cout << "Tags defined on model: ";
     442                 :          1 :     bool first = true;
     443 [ +  - ][ +  - ]:          4 :     for( std::set< iBase_TagHandle >::iterator sit = tags.begin(); sit != tags.end(); ++sit )
                 [ +  + ]
     444                 :            :     {
     445 [ +  - ][ +  - ]:          3 :         FBiGeom_getTagName( geom, *sit, name_buffer, &err, sizeof( name_buffer ) );
     446                 :          3 :         name_buffer[sizeof( name_buffer ) - 1] = '\0';  // mnake sure of NUL termination
     447 [ -  + ][ #  # ]:          3 :         CHECK( "getTagName failed." );
     448                 :            : 
     449 [ +  + ][ +  - ]:          3 :         if( !first ) std::cout << ", ";
     450         [ +  - ]:          3 :         std::cout << name_buffer;
     451                 :          3 :         first = false;
     452                 :            :     }
     453 [ -  + ][ #  # ]:          1 :     if( first ) std::cout << "<none>";
     454         [ +  - ]:          1 :     std::cout << std::endl;
     455                 :            : 
     456                 :          2 :     return true;
     457                 :            : }
     458                 :            : 
     459                 :          1 : bool tag_get_set_test( FBiGeom_Instance geom )
     460                 :            : {
     461                 :            :     int err;
     462                 :            : 
     463                 :            :     // create an arbitrary tag, size 4
     464                 :            :     iBase_TagHandle this_tag;
     465         [ +  - ]:          1 :     std::string tag_name( "tag_get_set tag" );
     466 [ +  - ][ +  - ]:          1 :     FBiGeom_createTag( geom, &tag_name[0], sizeof( int ), iBase_BYTES, &this_tag, &err, tag_name.length() );
     467 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : can not create a tag for get_set test." );
     468                 :            : 
     469                 :            :     iBase_EntitySetHandle root_set;
     470         [ +  - ]:          1 :     FBiGeom_getRootSet( geom, &root_set, &err );
     471 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : getRootSet failed!" );
     472                 :            : 
     473                 :            :     // set this tag to an integer on each entity; keep track of total sum
     474                 :          1 :     int sum = 0, num = 0, dim;
     475         [ +  + ]:          5 :     for( dim = 0; dim <= 3; dim++ )
     476                 :            :     {
     477         [ +  - ]:          4 :         SimpleArray< iBase_EntityHandle > gentity_handles;
     478 [ +  - ][ +  - ]:          4 :         FBiGeom_getEntities( geom, root_set, dim, ARRAY_INOUT( gentity_handles ), &err );
         [ +  - ][ +  - ]
     479         [ +  - ]:          4 :         int num_ents = gentity_handles.size();
     480 [ +  - ][ +  - ]:          8 :         std::vector< int > tag_vals( num_ents );
     481         [ +  + ]:         19 :         for( int i = 0; i < num_ents; ++i )
     482                 :            :         {
     483         [ +  - ]:         15 :             tag_vals[i] = num;
     484                 :         15 :             sum += num;
     485                 :         15 :             ++num;
     486                 :            :         }
     487                 :            : 
     488 [ +  - ][ +  - ]:          4 :         FBiGeom_setArrData( geom, ARRAY_IN( gentity_handles ), this_tag, (char*)&tag_vals[0],
                 [ +  - ]
     489         [ +  - ]:          8 :                             tag_vals.size() * sizeof( int ), &err );
     490 [ -  + ][ #  # ]:          4 :         CHECK( "ERROR : can't set tag on entities" );
                 [ +  - ]
     491                 :          4 :     }
     492                 :            : 
     493                 :            :     // check tag values for entities now
     494                 :          1 :     int get_sum = 0;
     495         [ +  + ]:          5 :     for( dim = 0; dim <= 3; dim++ )
     496                 :            :     {
     497         [ +  - ]:          4 :         SimpleArray< iBase_EntityHandle > gentity_handles;
     498 [ +  - ][ +  - ]:          4 :         FBiGeom_getEntities( geom, root_set, dim, ARRAY_INOUT( gentity_handles ), &err );
         [ +  - ][ +  - ]
     499         [ +  - ]:          4 :         int num_ents = gentity_handles.size();
     500                 :            : 
     501 [ +  - ][ +  - ]:          8 :         SimpleArray< char > tag_vals;
     502 [ +  - ][ +  - ]:          4 :         FBiGeom_getArrData( geom, ARRAY_IN( gentity_handles ), this_tag, (void**)tag_vals.ptr(), &tag_vals.capacity(),
         [ +  - ][ +  - ]
     503 [ +  - ][ +  - ]:          8 :                             &tag_vals.size(), &err );
     504 [ -  + ][ #  # ]:          4 :         CHECK( "ERROR : can't get tag on entities" );
     505                 :            : 
     506         [ +  - ]:          4 :         int* tag_ptr = (int*)( &tag_vals[0] );
     507 [ +  + ][ +  - ]:         19 :         for( int i = 0; i < num_ents; ++i )
     508                 :         15 :             get_sum += tag_ptr[i];
     509                 :          4 :     }
     510                 :            : 
     511         [ -  + ]:          1 :     if( get_sum != sum )
     512                 :            :     {
     513 [ #  # ][ #  # ]:          0 :         std::cerr << "ERROR: getData didn't return consistent results." << std::endl;
     514                 :          0 :         return false;
     515                 :            :     }
     516                 :            : 
     517         [ +  - ]:          1 :     FBiGeom_destroyTag( geom, this_tag, true, &err );
     518 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : couldn't delete tag." );
     519                 :            : 
     520                 :          1 :     return true;
     521                 :            : }
     522                 :            : 
     523                 :            : /*!
     524                 :            :  @test
     525                 :            :  TSTT gentity sets test (just implemented parts for now)
     526                 :            :  @li Check gentity sets
     527                 :            :  */
     528                 :          0 : bool gentityset_test( FBiGeom_Instance geom, bool /*multiset*/, bool /*ordered*/ )
     529                 :            : {
     530                 :          0 :     int num_type = 4;
     531                 :            :     iBase_EntitySetHandle ges_array[4];
     532                 :            :     int number_array[4];
     533                 :            :     // int num_all_gentities_super = 0;
     534                 :          0 :     int ent_type = iBase_VERTEX;
     535                 :            : 
     536                 :            :     int err;
     537                 :            :     iBase_EntitySetHandle root_set;
     538         [ #  # ]:          0 :     FBiGeom_getRootSet( geom, &root_set, &err );
     539 [ #  # ][ #  # ]:          0 :     CHECK( "ERROR : getRootSet failed!" );
     540                 :            : 
     541                 :            :     // get the number of sets in the whole model
     542                 :          0 :     int all_sets = 0;
     543         [ #  # ]:          0 :     FBiGeom_getNumEntSets( geom, root_set, 0, &all_sets, &err );
     544 [ #  # ][ #  # ]:          0 :     CHECK( "Problem getting the number of all gentity sets in whole model." );
     545                 :            : 
     546                 :            :     // add gentities to entitysets by type
     547         [ #  # ]:          0 :     for( ; ent_type < num_type; ent_type++ )
     548                 :            :     {
     549                 :            :         // initialize the entityset
     550         [ #  # ]:          0 :         FBiGeom_createEntSet( geom, true, &ges_array[ent_type], &err );
     551 [ #  # ][ #  # ]:          0 :         CHECK( "Problem creating entityset." );
     552                 :            : 
     553                 :            :         // get entities by type in total "mesh"
     554         [ #  # ]:          0 :         SimpleArray< iBase_EntityHandle > gentities;
     555 [ #  # ][ #  # ]:          0 :         FBiGeom_getEntities( geom, root_set, ent_type, ARRAY_INOUT( gentities ), &err );
         [ #  # ][ #  # ]
     556 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to get gentities by type in gentityset_test." );
     557                 :            : 
     558                 :            :         // add gentities into gentity set
     559 [ #  # ][ #  # ]:          0 :         FBiGeom_addEntArrToSet( geom, ARRAY_IN( gentities ), ges_array[ent_type], &err );
                 [ #  # ]
     560 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to add gentities in entityset_test." );
     561                 :            : 
     562                 :            :         // Check to make sure entity set really has correct number of entities in it
     563         [ #  # ]:          0 :         FBiGeom_getNumOfType( geom, ges_array[ent_type], ent_type, &number_array[ent_type], &err );
     564 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to get number of gentities by type in entityset_test." );
     565                 :            : 
     566                 :            :         // compare the number of entities by type
     567         [ #  # ]:          0 :         int num_type_gentity = gentities.size();
     568                 :            : 
     569         [ #  # ]:          0 :         if( number_array[ent_type] != num_type_gentity )
     570                 :            :         {
     571 [ #  # ][ #  # ]:          0 :             std::cerr << "Number of gentities by type is not correct" << std::endl;
     572         [ #  # ]:          0 :             return false;
     573                 :            :         }
     574                 :            : 
     575                 :            :         // add to number of all entities in super set
     576                 :            :         // num_all_gentities_super += num_type_gentity;
     577                 :          0 :     }
     578                 :            : 
     579                 :            :     // make a super set having all entitysets
     580                 :            :     iBase_EntitySetHandle super_set;
     581         [ #  # ]:          0 :     FBiGeom_createEntSet( geom, true, &super_set, &err );
     582 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to create a super set in gentityset_test." );
     583                 :            : 
     584         [ #  # ]:          0 :     for( int i = 0; i < num_type; i++ )
     585                 :            :     {
     586         [ #  # ]:          0 :         FBiGeom_addEntSet( geom, ges_array[i], super_set, &err );
     587 [ #  # ][ #  # ]:          0 :         CHECK( "Failed to create a super set in gentityset_test." );
     588                 :            :     }
     589                 :            : 
     590                 :            :     //----------TEST BOOLEAN OPERATIONS----------------//
     591                 :            : 
     592                 :            :     iBase_EntitySetHandle temp_ges1;
     593         [ #  # ]:          0 :     FBiGeom_createEntSet( geom, true, &temp_ges1, &err );
     594 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to create a super set in gentityset_test." );
     595                 :            : 
     596                 :            :     // Subtract
     597                 :            :     // add all EDGEs and FACEs to temp_es1
     598                 :            :     // get all EDGE entities
     599 [ #  # ][ #  # ]:          0 :     SimpleArray< iBase_EntityHandle > gedges, gfaces, temp_gentities1;
                 [ #  # ]
     600 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntities( geom, ges_array[iBase_EDGE], iBase_EDGE, ARRAY_INOUT( gedges ), &err );
         [ #  # ][ #  # ]
     601 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get gedge gentities in gentityset_test." );
     602                 :            : 
     603                 :            :     // add EDGEs to ges1
     604 [ #  # ][ #  # ]:          0 :     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gedges ), temp_ges1, &err );
                 [ #  # ]
     605 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to add gedge gentities in gentityset_test." );
     606                 :            : 
     607                 :            :     // get all FACE gentities
     608 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntities( geom, ges_array[iBase_FACE], iBase_FACE, ARRAY_INOUT( gfaces ), &err );
         [ #  # ][ #  # ]
     609 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get gface gentities in gentityset_test." );
     610                 :            : 
     611                 :            :     // add FACEs to es1
     612 [ #  # ][ #  # ]:          0 :     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gfaces ), temp_ges1, &err );
                 [ #  # ]
     613 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to add gface gentities in gentityset_test." );
     614                 :            : 
     615                 :            :     // subtract EDGEs
     616         [ #  # ]:          0 :     FBiGeom_subtract( geom, temp_ges1, ges_array[iBase_EDGE], &temp_ges1, &err );
     617 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to subtract gentitysets in gentityset_test." );
     618                 :            : 
     619 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntities( geom, temp_ges1, iBase_FACE, ARRAY_INOUT( temp_gentities1 ), &err );
         [ #  # ][ #  # ]
     620 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get gface gentities in gentityset_test." );
     621                 :            : 
     622 [ #  # ][ #  # ]:          0 :     if( gfaces.size() != temp_gentities1.size() )
                 [ #  # ]
     623                 :            :     {
     624         [ #  # ]:          0 :         std::cerr << "Number of entitysets after subtraction not correct \
     625                 :            :              in gentityset_test."
     626         [ #  # ]:          0 :                   << std::endl;
     627                 :          0 :         return false;
     628                 :            :     }
     629                 :            : 
     630                 :            :     // check there's nothing but gfaces in temp_ges1
     631                 :            :     int num_gents;
     632         [ #  # ]:          0 :     FBiGeom_getNumOfType( geom, temp_ges1, iBase_EDGE, &num_gents, &err );
     633 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get dimensions of gentities in gentityset_test." );
     634         [ #  # ]:          0 :     if( 0 != num_gents )
     635                 :            :     {
     636 [ #  # ][ #  # ]:          0 :         std::cerr << "Subtraction failed to remove all edges" << std::endl;
     637                 :          0 :         return false;
     638                 :            :     }
     639                 :            : 
     640                 :            :     //------------Intersect------------
     641                 :            :     //
     642                 :            : 
     643                 :            :     // clean out the temp_ges1
     644 [ #  # ][ #  # ]:          0 :     FBiGeom_rmvEntArrFromSet( geom, ARRAY_IN( gfaces ), temp_ges1, &err );
                 [ #  # ]
     645 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to remove gface gentities in gentityset_test." );
     646                 :            : 
     647                 :            :     // check if it is really cleaned out
     648         [ #  # ]:          0 :     FBiGeom_getNumOfType( geom, temp_ges1, iBase_FACE, &num_gents, &err );
     649 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get number of gentities by type in gentityset_test." );
     650                 :            : 
     651         [ #  # ]:          0 :     if( num_gents != 0 )
     652                 :            :     {
     653 [ #  # ][ #  # ]:          0 :         std::cerr << "failed to remove correctly." << std::endl;
     654                 :          0 :         return false;
     655                 :            :     }
     656                 :            : 
     657                 :            :     // add EDGEs to temp ges1
     658 [ #  # ][ #  # ]:          0 :     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gedges ), temp_ges1, &err );
                 [ #  # ]
     659 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to add gedge gentities in gentityset_test." );
     660                 :            : 
     661                 :            :     // add FACEs to temp ges1
     662 [ #  # ][ #  # ]:          0 :     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gfaces ), temp_ges1, &err );
                 [ #  # ]
     663 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to add gface gentities in gentityset_test." );
     664                 :            : 
     665                 :            :     // intersect temp_ges1 with gedges set
     666                 :            :     // temp_ges1 entityset is altered
     667         [ #  # ]:          0 :     FBiGeom_intersect( geom, temp_ges1, ges_array[iBase_EDGE], &temp_ges1, &err );
     668 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to intersect in gentityset_test." );
     669                 :            : 
     670                 :            :     // try to get FACEs, but there should be nothing but EDGE
     671         [ #  # ]:          0 :     FBiGeom_getNumOfType( geom, temp_ges1, iBase_FACE, &num_gents, &err );
     672 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get gface gentities in gentityset_test." );
     673                 :            : 
     674         [ #  # ]:          0 :     if( num_gents != 0 )
     675                 :            :     {
     676 [ #  # ][ #  # ]:          0 :         std::cerr << "wrong number of gfaces." << std::endl;
     677                 :          0 :         return false;
     678                 :            :     }
     679                 :            : 
     680                 :            :     //-------------Unite--------------
     681                 :            : 
     682                 :            :     // get all regions
     683                 :            :     iBase_EntitySetHandle temp_ges2;
     684         [ #  # ]:          0 :     SimpleArray< iBase_EntityHandle > gregions;
     685                 :            : 
     686         [ #  # ]:          0 :     FBiGeom_createEntSet( geom, true, &temp_ges2, &err );
     687 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to create a temp gentityset in gentityset_test." );
     688                 :            : 
     689 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntities( geom, ges_array[iBase_REGION], iBase_REGION, ARRAY_INOUT( gregions ), &err );
         [ #  # ][ #  # ]
     690 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get gregion gentities in gentityset_test." );
     691                 :            : 
     692                 :            :     // add REGIONs to temp es2
     693 [ #  # ][ #  # ]:          0 :     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gregions ), temp_ges2, &err );
                 [ #  # ]
     694 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to add gregion gentities in gentityset_test." );
     695                 :            : 
     696                 :            :     // unite temp_ges1 and temp_ges2
     697                 :            :     // temp_ges1 gentityset is altered
     698         [ #  # ]:          0 :     FBiGeom_unite( geom, temp_ges1, temp_ges2, &temp_ges1, &err );
     699 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to unite in gentityset_test." );
     700                 :            : 
     701                 :            :     // perform the check
     702         [ #  # ]:          0 :     FBiGeom_getNumOfType( geom, temp_ges1, iBase_REGION, &num_gents, &err );
     703 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get number of gregion gentities by type in gentityset_test." );
     704                 :            : 
     705         [ #  # ]:          0 :     if( num_gents != number_array[iBase_REGION] )
     706                 :            :     {
     707 [ #  # ][ #  # ]:          0 :         std::cerr << "different number of gregions in gentityset_test." << std::endl;
     708                 :          0 :         return false;
     709                 :            :     }
     710                 :            : 
     711                 :            :     //--------Test parent/child stuff in entiysets-----------
     712                 :            : 
     713                 :            :     // Add 2 sets as children to another
     714                 :            :     iBase_EntitySetHandle parent_child;
     715         [ #  # ]:          0 :     FBiGeom_createEntSet( geom, true, &parent_child, &err );
     716 [ #  # ][ #  # ]:          0 :     CHECK( "Problem creating gentityset in gentityset_test." );
     717                 :            : 
     718         [ #  # ]:          0 :     FBiGeom_addPrntChld( geom, ges_array[iBase_VERTEX], parent_child, &err );
     719 [ #  # ][ #  # ]:          0 :     CHECK( "Problem add parent in gentityset_test." );
     720                 :            : 
     721                 :            :     // check if parent is really added
     722         [ #  # ]:          0 :     SimpleArray< iBase_EntitySetHandle > parents;
     723 [ #  # ][ #  # ]:          0 :     FBiGeom_getPrnts( geom, parent_child, 1, ARRAY_INOUT( parents ), &err );
         [ #  # ][ #  # ]
     724 [ #  # ][ #  # ]:          0 :     CHECK( "Problem getting parents in gentityset_test." );
     725                 :            : 
     726 [ #  # ][ #  # ]:          0 :     if( parents.size() != 1 )
     727                 :            :     {
     728 [ #  # ][ #  # ]:          0 :         std::cerr << "number of parents is not correct in gentityset_test." << std::endl;
     729                 :          0 :         return false;
     730                 :            :     }
     731                 :            : 
     732                 :            :     // add parent and child
     733                 :            :     // sidl::array<void*> parent_child_array = sidl::array<void*>::create1d(1);
     734                 :            :     // int num_parent_child_array;
     735                 :            :     // sidl::array<void*> temp_gedge_array = sidl::array<void*>::create1d(1);
     736                 :            :     // int num_temp_gedge_array;
     737                 :            :     // parent_child_array.set(0, parent_child);
     738                 :            :     // temp_gedge_array.set(0, ges_array[TSTTG::EntityType_EDGE]);
     739         [ #  # ]:          0 :     FBiGeom_addPrntChld( geom, ges_array[iBase_EDGE], parent_child, &err );
     740 [ #  # ][ #  # ]:          0 :     CHECK( "Problem adding parent and child in gentityset_test." );
     741                 :            : 
     742                 :            :     // sidl::array<void*> temp_gface_array = sidl::array<void*>::create1d(1);
     743                 :            :     // int num_temp_gface_array;
     744                 :            :     // temp_gface_array.set(0, ges_array[TSTTG::EntityType_FACE]);
     745         [ #  # ]:          0 :     FBiGeom_addPrntChld( geom, parent_child, ges_array[iBase_FACE], &err );
     746 [ #  # ][ #  # ]:          0 :     CHECK( "Problem adding parent and child in gentityset_test." );
     747                 :            : 
     748                 :            :     // add child
     749         [ #  # ]:          0 :     FBiGeom_addPrntChld( geom, parent_child, ges_array[iBase_REGION], &err );
     750 [ #  # ][ #  # ]:          0 :     CHECK( "Problem adding child in gentityset_test." );
     751                 :            : 
     752                 :            :     // get the number of parent gentitysets
     753                 :          0 :     num_gents = -1;
     754         [ #  # ]:          0 :     FBiGeom_getNumPrnt( geom, parent_child, 1, &num_gents, &err );
     755 [ #  # ][ #  # ]:          0 :     CHECK( "Problem getting number of parents in gentityset_test." );
     756                 :            : 
     757         [ #  # ]:          0 :     if( num_gents != 2 )
     758                 :            :     {
     759 [ #  # ][ #  # ]:          0 :         std::cerr << "number of parents is not correct in gentityset_test." << std::endl;
     760                 :          0 :         return false;
     761                 :            :     }
     762                 :            : 
     763                 :            :     // get the number of child gentitysets
     764                 :          0 :     num_gents = -1;
     765         [ #  # ]:          0 :     FBiGeom_getNumChld( geom, parent_child, 1, &num_gents, &err );
     766 [ #  # ][ #  # ]:          0 :     CHECK( "Problem getting number of children in gentityset_test." );
     767                 :            : 
     768         [ #  # ]:          0 :     if( num_gents != 2 )
     769                 :            :     {
     770 [ #  # ][ #  # ]:          0 :         std::cerr << "number of children is not correct in gentityset_test." << std::endl;
     771                 :          0 :         return false;
     772                 :            :     }
     773                 :            : 
     774         [ #  # ]:          0 :     SimpleArray< iBase_EntitySetHandle > children;
     775 [ #  # ][ #  # ]:          0 :     FBiGeom_getChldn( geom, parent_child, 1, ARRAY_INOUT( children ), &err );
         [ #  # ][ #  # ]
     776 [ #  # ][ #  # ]:          0 :     CHECK( "Problem getting children in gentityset_test." );
     777                 :            : 
     778 [ #  # ][ #  # ]:          0 :     if( children.size() != 2 )
     779                 :            :     {
     780 [ #  # ][ #  # ]:          0 :         std::cerr << "number of children is not correct in gentityset_test." << std::endl;
     781                 :          0 :         return false;
     782                 :            :     }
     783                 :            : 
     784                 :            :     // remove children
     785         [ #  # ]:          0 :     FBiGeom_rmvPrntChld( geom, parent_child, ges_array[iBase_FACE], &err );
     786 [ #  # ][ #  # ]:          0 :     CHECK( "Problem removing parent child in gentityset_test." );
     787                 :            : 
     788                 :            :     // get the number of child gentitysets
     789         [ #  # ]:          0 :     FBiGeom_getNumChld( geom, parent_child, 1, &num_gents, &err );
     790 [ #  # ][ #  # ]:          0 :     CHECK( "Problem getting number of children in gentityset_test." );
     791                 :            : 
     792         [ #  # ]:          0 :     if( num_gents != 1 )
     793                 :            :     {
     794 [ #  # ][ #  # ]:          0 :         std::cerr << "number of children is not correct in gentityset_test." << std::endl;
     795                 :          0 :         return false;
     796                 :            :     }
     797                 :            : 
     798                 :            :     // parent_child and ges_array[TSTTG::EntityType_EDGE] should be related
     799                 :          0 :     int result = 0;
     800         [ #  # ]:          0 :     FBiGeom_isChildOf( geom, ges_array[iBase_EDGE], parent_child, &result, &err );
     801 [ #  # ][ #  # ]:          0 :     CHECK( "Problem checking relation in gentityset_test." );
     802         [ #  # ]:          0 :     if( !result )
     803                 :            :     {
     804 [ #  # ][ #  # ]:          0 :         std::cerr << "parent_child and ges_array[TSTTG::EntityType_EDGE] should be related" << std::endl;
     805                 :          0 :         return false;
     806                 :            :     }
     807                 :            : 
     808                 :            :     // ges_array[TSTTG::EntityType_FACE] and ges_array[TSTTG::REGION] are not related
     809                 :          0 :     result = 2;
     810         [ #  # ]:          0 :     FBiGeom_isChildOf( geom, ges_array[iBase_FACE], ges_array[iBase_REGION], &result, &err );
     811         [ #  # ]:          0 :     if( result )
     812                 :            :     {
     813                 :            :         std::cerr << "ges_array[TSTTG::REGION] and ges_array[TSTTG::EntityType_FACE] should not be "
     814         [ #  # ]:          0 :                      "related"
     815         [ #  # ]:          0 :                   << std::endl;
     816                 :          0 :         return false;
     817                 :            :     }
     818                 :            : 
     819                 :            :     //--------test modify and query functions-----------------------------
     820                 :            : 
     821                 :            :     // check the number of gentity sets in whole mesh
     822         [ #  # ]:          0 :     SimpleArray< iBase_EntitySetHandle > gentity_sets;
     823 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntSets( geom, root_set, 1, ARRAY_INOUT( gentity_sets ), &err );
         [ #  # ][ #  # ]
     824 [ #  # ][ #  # ]:          0 :     CHECK( "Problem to get all gentity sets in mesh." );
     825                 :            : 
     826 [ #  # ][ #  # ]:          0 :     if( gentity_sets.size() != all_sets + 8 )
     827                 :            :     {
     828 [ #  # ][ #  # ]:          0 :         std::cerr << "the number of gentity sets in whole mesh should be 8 times of num_iter." << std::endl;
     829                 :          0 :         return false;
     830                 :            :     }
     831                 :            : 
     832                 :            :     // get all gentity sets in super set
     833         [ #  # ]:          0 :     SimpleArray< iBase_EntitySetHandle > ges_array1;
     834 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntSets( geom, super_set, 1, ARRAY_INOUT( ges_array1 ), &err );
         [ #  # ][ #  # ]
     835 [ #  # ][ #  # ]:          0 :     CHECK( "Problem to get gentity sets in super set." );
     836                 :            : 
     837                 :            :     // get the number of gentity sets in super set
     838                 :            :     int num_super;
     839         [ #  # ]:          0 :     FBiGeom_getNumEntSets( geom, super_set, 1, &num_super, &err );
     840 [ #  # ][ #  # ]:          0 :     CHECK( "Problem to get the number of all gentity sets in super set." );
     841                 :            : 
     842                 :            :     // the number of gentity sets in super set should be same
     843 [ #  # ][ #  # ]:          0 :     if( num_super != ges_array1.size() )
     844                 :            :     {
     845 [ #  # ][ #  # ]:          0 :         std::cerr << "the number of gentity sets in super set should be same." << std::endl;
     846                 :          0 :         return false;
     847                 :            :     }
     848                 :            : 
     849                 :            :     // get all entities in super set
     850         [ #  # ]:          0 :     SimpleArray< iBase_EntitySetHandle > all_gentities;
     851 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntSets( geom, super_set, 1, ARRAY_INOUT( all_gentities ), &err );
         [ #  # ][ #  # ]
     852 [ #  # ][ #  # ]:          0 :     CHECK( "Problem to get all gentities in super set." );
     853                 :            : 
     854                 :            :     // compare the number of all gentities in super set
     855                 :            :     // HJK : num_hops is not implemented
     856                 :            :     // if (num_all_gentities_super != ARRAY_SIZE(all_gentities)) {
     857                 :            :     // std::cerr << "number of all gentities in super set should be same." << std::endl;
     858                 :            :     // success = false;
     859                 :            :     //}
     860                 :            : 
     861                 :            :     // test add, remove and get all entitiy sets using super set
     862                 :            :     // check GetAllGentitysets works recursively and dosen't return
     863                 :            :     // multi sets
     864         [ #  # ]:          0 :     for( int k = 0; k < num_super; k++ )
     865                 :            :     {
     866                 :            :         // add gentity sets of super set to each gentity set of super set
     867                 :            :         // make multiple child super sets
     868         [ #  # ]:          0 :         iBase_EntitySetHandle ges_k = ges_array1[k];
     869                 :            : 
     870 [ #  # ][ #  # ]:          0 :         for( int a = 0; a < ges_array1.size(); a++ )
     871                 :            :         {
     872 [ #  # ][ #  # ]:          0 :             FBiGeom_addEntSet( geom, ges_array1[a], ges_k, &err );
     873 [ #  # ][ #  # ]:          0 :             CHECK( "Problem to add entity set." );
     874                 :            :         }
     875                 :            : 
     876                 :            :         // add super set to each entity set
     877                 :            :         //    sidl::array<GentitysetHandle> superset_array
     878                 :            :         //= sidl::array<GentitysetHandle>::create1d(1);
     879                 :            :         // superset_array.set(0, super_set);
     880                 :            :         // int num_superset_array;
     881                 :            : 
     882         [ #  # ]:          0 :         FBiGeom_addEntSet( geom, super_set, ges_k, &err );
     883 [ #  # ][ #  # ]:          0 :         CHECK( "Problem to add super set to gentitysets." );
     884                 :            : 
     885                 :            :         // add one gentity sets multiple times
     886                 :            :         // HJK: ??? how to deal this case?
     887                 :            :         // sidl::array<GentitysetHandle> temp_array1
     888                 :            :         //= sidl::array<GentitysetHandle>::create1d(1);
     889                 :            :         // int num_temp_array1;
     890                 :            :         // temp_array1.set(0, temp_ges1);
     891                 :            : 
     892                 :            :         // for (int l = 0; l < 3; l++) {
     893         [ #  # ]:          0 :         FBiGeom_addEntSet( geom, temp_ges1, ges_k, &err );
     894 [ #  # ][ #  # ]:          0 :         CHECK( "Problem to add temp set to gentitysets." );
     895                 :            :         //}
     896                 :            :     }
     897                 :            : 
     898                 :          0 :     return true;
     899                 :            : }
     900                 :            : 
     901                 :            : /*!
     902                 :            :  @test
     903                 :            :  TSTTG topology adjacencies Test
     904                 :            :  @li Check topology information
     905                 :            :  @li Check adjacency
     906                 :            :  */
     907                 :            : // make each topological entity vectors, check their topology
     908                 :            : // types, get interior and exterior faces of model
     909                 :          1 : bool topology_adjacencies_test( FBiGeom_Instance geom )
     910                 :            : {
     911                 :            :     int i, err;
     912                 :            :     iBase_EntitySetHandle root_set;
     913         [ +  - ]:          1 :     FBiGeom_getRootSet( geom, &root_set, &err );
     914 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : getRootSet failed!" );
     915                 :            : 
     916                 :          1 :     int top          = iBase_VERTEX;
     917                 :          1 :     int num_test_top = iBase_ALL_TYPES;
     918         [ +  - ]:          1 :     std::vector< std::vector< iBase_EntityHandle > > gentity_vectors( num_test_top );
     919                 :            : 
     920                 :            :     // fill the vectors of each topology entities
     921                 :            :     // like lines vector, polygon vector, triangle vector,
     922                 :            :     // quadrilateral, polyhedrron, tet, hex, prism, pyramid,
     923                 :            :     // septahedron vectors
     924         [ +  + ]:          5 :     for( i = top; i < num_test_top; i++ )
     925                 :            :     {
     926         [ +  - ]:          4 :         SimpleArray< iBase_EntityHandle > gentities;
     927 [ +  - ][ +  - ]:          4 :         FBiGeom_getEntities( geom, root_set, i, ARRAY_INOUT( gentities ), &err );
         [ +  - ][ +  - ]
     928 [ -  + ][ #  # ]:          4 :         CHECK( "Failed to get gentities in adjacencies_test." );
     929                 :            : 
     930 [ +  - ][ +  - ]:          4 :         gentity_vectors[i].resize( gentities.size() );
                 [ +  - ]
     931 [ +  - ][ +  - ]:          4 :         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
         [ +  - ][ +  - ]
                 [ +  - ]
     932                 :          4 :     }
     933                 :            : 
     934                 :            :     // check number of entities for each topology
     935         [ +  + ]:          5 :     for( i = top; i < num_test_top; i++ )
     936                 :            :     {
     937                 :          4 :         int num_tops = 0;
     938         [ +  - ]:          4 :         FBiGeom_getNumOfType( geom, root_set, i, &num_tops, &err );
     939 [ -  + ][ #  # ]:          4 :         CHECK( "Failed to get number of gentities in adjacencies_test." );
     940                 :            : 
     941 [ +  - ][ -  + ]:          4 :         if( static_cast< int >( gentity_vectors[i].size() ) != num_tops )
     942                 :            :         {
     943 [ #  # ][ #  # ]:          0 :             std::cerr << "Number of gentities doesn't agree with number returned for dimension " << i << std::endl;
                 [ #  # ]
     944                 :          0 :             return false;
     945                 :            :         }
     946                 :            :     }
     947                 :            : 
     948                 :            :     // check adjacencies in both directions
     949                 :          1 :     std::vector< iBase_EntityHandle >::iterator vit;
     950         [ +  + ]:          5 :     for( i = iBase_REGION; i >= iBase_VERTEX; i-- )
     951                 :            :     {
     952 [ +  - ][ +  - ]:         19 :         for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
         [ +  - ][ +  - ]
                 [ +  + ]
     953                 :            :         {
     954         [ +  - ]:         15 :             iBase_EntityHandle this_gent = *vit;
     955                 :            : 
     956                 :            :             // check downward adjacencies
     957         [ +  + ]:         26 :             for( int j = iBase_VERTEX; j < i; j++ )
     958                 :            :             {
     959                 :            : 
     960         [ +  - ]:         11 :                 SimpleArray< iBase_EntityHandle > lower_ents;
     961 [ +  - ][ +  - ]:         11 :                 FBiGeom_getEntAdj( geom, this_gent, j, ARRAY_INOUT( lower_ents ), &err );
         [ +  - ][ +  - ]
     962 [ -  + ][ #  # ]:         11 :                 CHECK( "Bi-directional adjacencies test failed." );
     963                 :            : 
     964                 :            :                 // for each of them, make sure they are adjacent to the upward ones
     965         [ +  - ]:         11 :                 int num_lower = lower_ents.size();
     966 [ +  + ][ +  - ]:         41 :                 for( int k = 0; k < num_lower; k++ )
     967                 :            :                 {
     968         [ +  - ]:         30 :                     SimpleArray< iBase_EntityHandle > upper_ents;
     969 [ +  - ][ +  - ]:         30 :                     FBiGeom_getEntAdj( geom, lower_ents[k], i, ARRAY_INOUT( upper_ents ), &err );
         [ +  - ][ +  - ]
                 [ +  - ]
     970 [ -  + ][ #  # ]:         30 :                     CHECK( "Bi-directional adjacencies test failed." );
     971 [ +  - ][ +  - ]:         30 :                     if( std::find( upper_ents.begin(), upper_ents.end(), this_gent ) == upper_ents.end() )
         [ +  - ][ +  - ]
                 [ -  + ]
     972                 :            :                     {
     973                 :            :                         std::cerr << "Didn't find lower-upper adjacency which was supposed to be "
     974         [ #  # ]:          0 :                                      "there, dims = "
     975 [ #  # ][ #  # ]:          0 :                                   << i << ", " << j << std::endl;
         [ #  # ][ #  # ]
     976         [ +  - ]:         30 :                         return false;
     977                 :            :                     }
     978                 :         30 :                 }
     979                 :         11 :             }
     980                 :            :         }
     981                 :            :     }
     982                 :            : 
     983                 :          1 :     return true;
     984                 :            : }
     985                 :            : 
     986                 :            : /*!
     987                 :            :  @test
     988                 :            :  FBiGeom_MOAB topology adjacencies Test
     989                 :            :  @li Check topology information
     990                 :            :  @li Check adjacency
     991                 :            :  */
     992                 :            : // make each topological entity vectors, check their topology
     993                 :            : // types, get interior and exterior faces of model
     994                 :          1 : bool geometry_evaluation_test( FBiGeom_Instance geom )
     995                 :            : {
     996                 :            :     int i, err;
     997                 :            :     iBase_EntitySetHandle root_set;
     998         [ +  - ]:          1 :     FBiGeom_getRootSet( geom, &root_set, &err );
     999 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : getRootSet failed!" );
    1000                 :            : 
    1001                 :          1 :     int top          = iBase_VERTEX;
    1002                 :          1 :     int num_test_top = iBase_ALL_TYPES;
    1003         [ +  - ]:          1 :     std::vector< std::vector< iBase_EntityHandle > > gentity_vectors( num_test_top );
    1004                 :            : 
    1005                 :            :     // fill the vectors of each topology entities
    1006                 :            :     // like lines vector, polygon vector, triangle vector,
    1007                 :            :     // quadrilateral, polyhedrron, tet, hex, prism, pyramid,
    1008                 :            :     // septahedron vectors
    1009         [ +  + ]:          5 :     for( i = top; i < num_test_top; i++ )
    1010                 :            :     {
    1011         [ +  - ]:          4 :         SimpleArray< iBase_EntityHandle > gentities;
    1012 [ +  - ][ +  - ]:          4 :         FBiGeom_getEntities( geom, root_set, i, ARRAY_INOUT( gentities ), &err );
         [ +  - ][ +  - ]
    1013 [ -  + ][ #  # ]:          4 :         CHECK( "Failed to get gentities in adjacencies_test." );
    1014                 :            : 
    1015 [ +  - ][ +  - ]:          4 :         gentity_vectors[i].resize( gentities.size() );
                 [ +  - ]
    1016 [ +  - ][ +  - ]:          4 :         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
         [ +  - ][ +  - ]
                 [ +  - ]
    1017                 :          4 :     }
    1018                 :            : 
    1019                 :            :     // check adjacencies in both directions
    1020                 :            :     double min[3], max[3], on[3];
    1021                 :          1 :     double near[3] = { .0, .0, .0 };
    1022                 :          1 :     std::vector< iBase_EntityHandle >::iterator vit;
    1023         [ +  + ]:          5 :     for( i = iBase_REGION; i >= iBase_VERTEX; i-- )
    1024                 :            :     {
    1025         [ +  + ]:          4 :         if( i != iBase_EDGE )
    1026                 :            :         {
    1027 [ +  - ][ +  - ]:         11 :             for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
         [ +  - ][ +  - ]
                 [ +  + ]
    1028                 :            :             {
    1029         [ +  - ]:          8 :                 iBase_EntityHandle this_gent = *vit;
    1030         [ +  - ]:          8 :                 FBiGeom_getEntBoundBox( geom, this_gent, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2], &err );
    1031 [ -  + ][ #  # ]:          8 :                 CHECK( "Failed to get bounding box of entity." );
    1032                 :            : 
    1033         [ +  + ]:         32 :                 for( int j = 0; j < 3; j++ )
    1034                 :         24 :                     near[j] = ( min[j] + max[j] ) / 2;
    1035         [ +  - ]:          8 :                 FBiGeom_getEntClosestPt( geom, this_gent, near[0], near[1], near[2], &on[0], &on[1], &on[2], &err );
    1036 [ -  + ][ #  # ]:          8 :                 CHECK( "Failed to get closest point on entity." );
    1037 [ +  - ][ +  - ]:          8 :                 std::cout << " entity of type " << i << " closest point to \n  " << near[0] << " " << near[1] << " "
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
    1038 [ +  - ][ +  - ]:          8 :                           << near[2] << "\n  is " << on[0] << " " << on[1] << " " << on[2] << "\n";
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1039                 :            :             }
    1040                 :            :         }
    1041                 :            :     }
    1042                 :            : 
    1043                 :          1 :     return true;
    1044                 :            : }
    1045                 :            : //
    1046                 :            : //  test normals evaluations on the surface only
    1047                 :          1 : bool normals_test( FBiGeom_Instance geom )
    1048                 :            : {
    1049                 :            :     int i, err;
    1050                 :            :     iBase_EntitySetHandle root_set;
    1051         [ +  - ]:          1 :     FBiGeom_getRootSet( geom, &root_set, &err );
    1052 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : getRootSet failed!" );
    1053                 :            : 
    1054                 :          1 :     int top          = iBase_VERTEX;
    1055                 :          1 :     int num_test_top = iBase_ALL_TYPES;
    1056         [ +  - ]:          1 :     std::vector< std::vector< iBase_EntityHandle > > gentity_vectors( num_test_top );
    1057                 :            : 
    1058                 :            :     // fill the vectors of each topology entities
    1059                 :            :     // like lines vector, polygon vector, triangle vector,
    1060                 :            :     // quadrilateral, polyhedrron, tet, hex, prism, pyramid,
    1061                 :            :     // septahedron vectors
    1062         [ +  + ]:          5 :     for( i = top; i < num_test_top; i++ )
    1063                 :            :     {
    1064         [ +  - ]:          4 :         SimpleArray< iBase_EntityHandle > gentities;
    1065 [ +  - ][ +  - ]:          4 :         FBiGeom_getEntities( geom, root_set, i, ARRAY_INOUT( gentities ), &err );
         [ +  - ][ +  - ]
    1066 [ -  + ][ #  # ]:          4 :         CHECK( "Failed to get gentities in adjacencies_test." );
    1067                 :            : 
    1068 [ +  - ][ +  - ]:          4 :         gentity_vectors[i].resize( gentities.size() );
                 [ +  - ]
    1069 [ +  - ][ +  - ]:          4 :         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
         [ +  - ][ +  - ]
                 [ +  - ]
    1070                 :          4 :     }
    1071                 :            : 
    1072                 :            :     // check adjacencies in both directions
    1073                 :            :     double min[3], max[3];
    1074                 :          1 :     double normal[3] = { .0, .0, .0 };
    1075                 :          1 :     std::vector< iBase_EntityHandle >::iterator vit;
    1076         [ +  + ]:          3 :     for( i = iBase_REGION; i > iBase_EDGE; i-- )
    1077                 :            :     {
    1078 [ +  - ][ +  - ]:          4 :         for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
         [ +  - ][ +  - ]
                 [ +  + ]
    1079                 :            :         {
    1080         [ +  - ]:          2 :             iBase_EntityHandle this_gent = *vit;
    1081         [ +  - ]:          2 :             FBiGeom_getEntBoundBox( geom, this_gent, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2], &err );
    1082 [ -  + ][ #  # ]:          2 :             CHECK( "Failed to get bounding box of entity." );
    1083                 :            : 
    1084                 :          4 :             FBiGeom_getEntNrmlXYZ( geom, this_gent, ( max[0] + min[0] ) / 2, ( max[1] + min[1] ) / 2,
    1085         [ +  - ]:          2 :                                    ( max[2] + min[2] ) / 2, &normal[0], &normal[1], &normal[2], &err );
    1086                 :            : 
    1087 [ -  + ][ #  # ]:          2 :             CHECK( "Failed to get normal to the closest point." );
    1088 [ +  - ][ +  - ]:          2 :             std::cout << " entity of type " << i << " closest normal to center:\n  " << normal[0] << " " << normal[1]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1089 [ +  - ][ +  - ]:          2 :                       << " " << normal[2] << "\n";
                 [ +  - ]
    1090                 :            :         }
    1091                 :            :     }
    1092                 :            : 
    1093                 :          1 :     return true;
    1094                 :            : }
    1095                 :            : 
    1096                 :            : //  test normals evaluations on the surface only
    1097                 :          1 : bool ray_test( FBiGeom_Instance geom )
    1098                 :            : {
    1099                 :            :     int err;
    1100                 :            :     iBase_EntitySetHandle root_set;
    1101         [ +  - ]:          1 :     FBiGeom_getRootSet( geom, &root_set, &err );
    1102 [ -  + ][ #  # ]:          1 :     CHECK( "ERROR : getRootSet failed!" );
    1103                 :            : 
    1104                 :          1 :     int top = iBase_FACE;
    1105                 :            : 
    1106         [ +  - ]:          1 :     SimpleArray< iBase_EntityHandle > faces;
    1107 [ +  - ][ +  - ]:          1 :     FBiGeom_getEntities( geom, root_set, top, ARRAY_INOUT( faces ), &err );
         [ +  - ][ +  - ]
    1108 [ -  + ][ #  # ]:          1 :     CHECK( "Failed to get gentities in adjacencies_test." );
    1109                 :            : 
    1110                 :            :     // check only the first face
    1111                 :            : 
    1112                 :            :     // check adjacencies in both directions
    1113                 :            :     double min[3], max[3];
    1114                 :            : 
    1115         [ +  - ]:          1 :     iBase_EntityHandle first_face = faces[0];
    1116                 :            : 
    1117         [ +  - ]:          1 :     FBiGeom_getEntBoundBox( geom, first_face, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2], &err );
    1118 [ -  + ][ #  # ]:          1 :     CHECK( "Failed to get bounding box of entity." );
    1119                 :            : 
    1120                 :            :     // assume that the ray shot from the bottom of the box (middle) is a pretty good candidate
    1121                 :            :     // in z direction
    1122                 :          1 :     double x = ( min[0] + max[0] ) / 2, y = ( min[1] + max[1] ) / 2, z = min[2];
    1123         [ +  - ]:          2 :     SimpleArray< iBase_EntityHandle > intersect_entity_handles;
    1124         [ +  - ]:          2 :     SimpleArray< double > intersect_coords;
    1125         [ +  - ]:          2 :     SimpleArray< double > param_coords;
    1126                 :            :     FBiGeom_getPntRayIntsct( geom, x, y, z,  // shot from
    1127                 :            :                              0., 0., 1.,     // direction
    1128 [ +  - ][ +  - ]:          1 :                              ARRAY_INOUT( intersect_entity_handles ), iBase_INTERLEAVED,
    1129 [ +  - ][ +  - ]:          2 :                              ARRAY_INOUT( intersect_coords ), ARRAY_INOUT( param_coords ), &err );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1130                 :            : 
    1131 [ -  + ][ #  # ]:          1 :     CHECK( "Failed to find ray intersections points " );
    1132 [ +  - ][ +  + ]:          2 :     for( int i = 0; i < intersect_entity_handles.size(); i++ )
    1133                 :            :     {
    1134                 :            :         int j;
    1135 [ +  - ][ +  - ]:          1 :         FBiGeom_getEntType( geom, intersect_entity_handles[i], &j, &err );
    1136 [ -  + ][ #  # ]:          1 :         CHECK( "Failed to get type of entity." );
    1137                 :            : 
    1138 [ +  - ][ +  - ]:          1 :         std::cout << " entity of type " << j << " n: " << intersect_entity_handles[i] << "\n"
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1139 [ +  - ][ +  - ]:          2 :                   << intersect_coords[3 * i] << " " << intersect_coords[3 * i + 1] << " " << intersect_coords[3 * i + 2]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    1140         [ +  - ]:          1 :                   << "\n"
    1141 [ +  - ][ +  - ]:          2 :                   << " distance: " << param_coords[i] << "\n";
         [ +  - ][ +  - ]
    1142                 :            :     }
    1143                 :            : 
    1144                 :          2 :     return true;
    1145                 :            : }
    1146                 :            : 
    1147                 :            : /*!
    1148                 :            :  @test
    1149                 :            :  TSTTG construct Test
    1150                 :            :  @li Check construction of geometry
    1151                 :            :  */
    1152                 :          0 : bool construct_test( FBiGeom_Instance geom )
    1153                 :            : {
    1154                 :            :     int err;
    1155                 :          0 :     iBase_EntityHandle new_body = 0;
    1156                 :            : 
    1157                 :            :     // construct a cylinder, sweep it about an axis, and delete the result
    1158                 :          0 :     iBase_EntityHandle cyl = 0;
    1159         [ #  # ]:          0 :     FBiGeom_createCylinder( geom, 1.0, 1.0, 0.0, &cyl, &err );
    1160                 :            :     // Is the minor radius really supposed to be zero??? - JK
    1161 [ #  # ][ #  # ]:          0 :     CHECK( "Creating cylinder failed." );
    1162                 :            : 
    1163                 :            :     // move it onto the y axis
    1164         [ #  # ]:          0 :     FBiGeom_moveEnt( geom, cyl, 0.0, 1.0, -0.5, &err );
    1165 [ #  # ][ #  # ]:          0 :     CHECK( "Problems moving surface." );
    1166                 :            : 
    1167                 :            :     // get the surface with max z
    1168                 :          0 :     iBase_EntityHandle max_surf = 0;
    1169         [ #  # ]:          0 :     SimpleArray< iBase_EntityHandle > surfs;
    1170 [ #  # ][ #  # ]:          0 :     FBiGeom_getEntAdj( geom, cyl, iBase_FACE, ARRAY_INOUT( surfs ), &err );
         [ #  # ][ #  # ]
    1171 [ #  # ][ #  # ]:          0 :     CHECK( "Problems getting max surf for rotation." );
    1172                 :            : 
    1173 [ #  # ][ #  # ]:          0 :     SimpleArray< double > max_corn, min_corn;
    1174 [ #  # ][ #  # ]:          0 :     FBiGeom_getArrBoundBox( geom, ARRAY_IN( surfs ), iBase_INTERLEAVED, ARRAY_INOUT( min_corn ),
         [ #  # ][ #  # ]
    1175 [ #  # ][ #  # ]:          0 :                             ARRAY_INOUT( max_corn ), &err );
         [ #  # ][ #  # ]
                 [ #  # ]
    1176 [ #  # ][ #  # ]:          0 :     CHECK( "Problems getting max surf for rotation." );
    1177                 :          0 :     double dtol = 1.0e-6;
    1178 [ #  # ][ #  # ]:          0 :     for( int i = 0; i < surfs.size(); ++i )
    1179                 :            :     {
    1180 [ #  # ][ #  # ]:          0 :         if( ( max_corn[3 * i + 2] ) <= dtol && ( max_corn[3 * i + 2] ) >= -dtol && ( min_corn[3 * i + 2] ) <= dtol &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1181         [ #  # ]:          0 :             ( min_corn[3 * i + 2] ) >= -dtol )
    1182                 :            :         {
    1183         [ #  # ]:          0 :             max_surf = surfs[i];
    1184                 :          0 :             break;
    1185                 :            :         }
    1186                 :            :     }
    1187                 :            : 
    1188         [ #  # ]:          0 :     if( 0 == max_surf )
    1189                 :            :     {
    1190 [ #  # ][ #  # ]:          0 :         std::cerr << "Couldn't find max surf for rotation." << std::endl;
    1191                 :          0 :         return false;
    1192                 :            :     }
    1193                 :            : 
    1194                 :            :     // sweep it around the x axis
    1195         [ #  # ]:          0 :     FBiGeom_moveEnt( geom, cyl, 0.0, 1.0, 0.0, &err );
    1196 [ #  # ][ #  # ]:          0 :     CHECK( "Problems moving surface." );
    1197                 :            : 
    1198         [ #  # ]:          0 :     FBiGeom_sweepEntAboutAxis( geom, max_surf, 360.0, 1.0, 0.0, 0.0, &new_body, &err );
    1199 [ #  # ][ #  # ]:          0 :     CHECK( "Problems sweeping surface about axis." );
    1200                 :            : 
    1201                 :            :     // now delete
    1202         [ #  # ]:          0 :     FBiGeom_deleteEnt( geom, new_body, &err );
    1203 [ #  # ][ #  # ]:          0 :     CHECK( "Problems deleting cylinder or swept surface body." );
    1204                 :            : 
    1205                 :            :     // if we got here, we were successful
    1206                 :          0 :     return true;
    1207                 :            : }
    1208                 :            : 
    1209                 :          0 : static bool compare_box( const double* expected_min, const double* expected_max, const double* actual_min,
    1210                 :            :                          const double* actual_max )
    1211                 :            : {
    1212                 :          0 :     bool same   = true;
    1213                 :          0 :     double dtol = 1.0e-6;
    1214                 :            : 
    1215         [ #  # ]:          0 :     for( int i = 0; i < 3; ++i )
    1216                 :            :     {
    1217 [ #  # ][ #  # ]:          0 :         if( expected_min[i] < actual_min[i] - dtol || expected_min[i] * 10 > actual_min[i] ||
                 [ #  # ]
    1218         [ #  # ]:          0 :             expected_max[i] > actual_max[i] + dtol || expected_max[i] * 10 < actual_max[i] )
    1219                 :          0 :             same = false;
    1220                 :            :     }
    1221                 :          0 :     return same;
    1222                 :            : }
    1223                 :            : 
    1224                 :          0 : bool primitives_test( FBiGeom_Instance geom )
    1225                 :            : {
    1226                 :            :     int err;
    1227         [ #  # ]:          0 :     SimpleArray< iBase_EntityHandle > prims( 3 );
    1228                 :            :     iBase_EntityHandle prim;
    1229                 :            : 
    1230         [ #  # ]:          0 :     FBiGeom_createBrick( geom, 1.0, 2.0, 3.0, &prim, &err );
    1231 [ #  # ][ #  # ]:          0 :     CHECK( "createBrick failed." );
    1232         [ #  # ]:          0 :     prims[0] = prim;
    1233                 :            : 
    1234         [ #  # ]:          0 :     FBiGeom_createCylinder( geom, 1.0, 4.0, 2.0, &prim, &err );
    1235 [ #  # ][ #  # ]:          0 :     CHECK( "createCylinder failed." );
    1236         [ #  # ]:          0 :     prims[1] = prim;
    1237                 :            : 
    1238         [ #  # ]:          0 :     FBiGeom_createTorus( geom, 2.0, 1.0, &prim, &err );
    1239 [ #  # ][ #  # ]:          0 :     CHECK( "createTorus failed." );
    1240         [ #  # ]:          0 :     prims[2] = prim;
    1241                 :            : 
    1242                 :            :     // verify the bounding boxes for Acis based entities
    1243 [ #  # ][ #  # ]:          0 :     SimpleArray< double > max_corn, min_corn;
    1244 [ #  # ][ #  # ]:          0 :     FBiGeom_getArrBoundBox( geom, ARRAY_IN( prims ), iBase_INTERLEAVED, ARRAY_INOUT( min_corn ),
         [ #  # ][ #  # ]
    1245 [ #  # ][ #  # ]:          0 :                             ARRAY_INOUT( max_corn ), &err );
         [ #  # ][ #  # ]
                 [ #  # ]
    1246                 :            : 
    1247                 :            :     double preset_min_corn[] =
    1248                 :            :         // min brick corner xyz
    1249                 :            :         { -0.5, -1.0, -1.5,
    1250                 :            :           // min cyl corner xyz
    1251                 :            :           -4.0, -2.0, -0.5,
    1252                 :            :           // min torus corner xyz
    1253                 :          0 :           -3.0, -3.0, -1.0 };
    1254                 :            : 
    1255                 :            :     double preset_max_corn[] =
    1256                 :            :         // max brick corner xyz
    1257                 :            :         { 0.5, 1.0, 1.5,
    1258                 :            :           // max cyl corner xyz
    1259                 :            :           4.0, 2.0, 0.5,
    1260                 :            :           // max torus corner xyz
    1261                 :          0 :           3.0, 3.0, 1.0 };
    1262                 :            : 
    1263 [ #  # ][ #  # ]:          0 :     if( !compare_box( preset_min_corn, preset_max_corn, &min_corn[0], &max_corn[0] ) )
                 [ #  # ]
    1264                 :            :     {
    1265 [ #  # ][ #  # ]:          0 :         std::cerr << "Box check failed for brick" << std::endl;
    1266                 :          0 :         return false;
    1267                 :            :     }
    1268                 :            : 
    1269 [ #  # ][ #  # ]:          0 :     if( !compare_box( preset_min_corn + 3, preset_max_corn + 3, &min_corn[3], &max_corn[3] ) )
                 [ #  # ]
    1270                 :            :     {
    1271 [ #  # ][ #  # ]:          0 :         std::cerr << "Box check failed for cylinder" << std::endl;
    1272                 :          0 :         return false;
    1273                 :            :     }
    1274                 :            : 
    1275 [ #  # ][ #  # ]:          0 :     if( !compare_box( preset_min_corn + 6, preset_max_corn + 6, &min_corn[6], &max_corn[6] ) )
                 [ #  # ]
    1276                 :            :     {
    1277 [ #  # ][ #  # ]:          0 :         std::cerr << "Box check failed for torus" << std::endl;
    1278                 :          0 :         return false;
    1279                 :            :     }
    1280                 :            :     // must have worked; delete the entities then return
    1281         [ #  # ]:          0 :     for( int i = 0; i < 3; ++i )
    1282                 :            :     {
    1283 [ #  # ][ #  # ]:          0 :         FBiGeom_deleteEnt( geom, prims[i], &err );
    1284 [ #  # ][ #  # ]:          0 :         CHECK( "Problems deleting primitive after boolean check." );
    1285                 :            :     }
    1286                 :            : 
    1287                 :          0 :     return true;
    1288                 :            : }
    1289                 :            : 
    1290                 :          0 : bool transforms_test( FBiGeom_Instance geom )
    1291                 :            : {
    1292                 :            :     int err;
    1293                 :            : 
    1294                 :            :     // construct a brick
    1295                 :          0 :     iBase_EntityHandle brick = 0;
    1296         [ #  # ]:          0 :     FBiGeom_createBrick( geom, 1.0, 2.0, 3.0, &brick, &err );
    1297 [ #  # ][ #  # ]:          0 :     CHECK( "Problems creating brick for transforms test." );
    1298                 :            : 
    1299                 :            :     // move it, then test bounding box
    1300         [ #  # ]:          0 :     FBiGeom_moveEnt( geom, brick, 0.5, 1.0, 1.5, &err );
    1301 [ #  # ][ #  # ]:          0 :     CHECK( "Problems moving brick for transforms test." );
    1302                 :            : 
    1303                 :            :     double bb_min[3], bb_max[3];
    1304         [ #  # ]:          0 :     FBiGeom_getEntBoundBox( geom, brick, bb_min, bb_min + 1, bb_min + 2, bb_max, bb_max + 1, bb_max + 2, &err );
    1305 [ #  # ][ #  # ]:          0 :     CHECK( "Problems getting bounding box after move." );
    1306                 :            : 
    1307                 :          0 :     double dtol = 1.0e-6;
    1308 [ #  # ][ #  # ]:          0 :     if( ( bb_min[0] ) >= dtol || ( bb_min[0] ) <= -dtol || ( bb_min[1] ) >= dtol || ( bb_min[1] ) <= -dtol ||
         [ #  # ][ #  # ]
                 [ #  # ]
    1309 [ #  # ][ #  # ]:          0 :         ( bb_min[2] ) >= dtol || ( bb_min[2] ) <= -dtol || ( bb_max[0] - 1 ) >= dtol || 1 - bb_max[0] >= dtol ||
         [ #  # ][ #  # ]
    1310 [ #  # ][ #  # ]:          0 :         ( bb_max[1] - 2 ) >= dtol || 2 - bb_max[1] >= dtol || ( bb_max[2] - 3 ) >= dtol || 3 - bb_max[2] >= dtol )
                 [ #  # ]
    1311                 :            :     {
    1312 [ #  # ][ #  # ]:          0 :         std::cerr << "Wrong bounding box after move." << std::endl;
    1313                 :          0 :         return false;
    1314                 :            :     }
    1315                 :            : 
    1316                 :            :     // now rotate it about +x, then test bounding box
    1317         [ #  # ]:          0 :     FBiGeom_rotateEnt( geom, brick, 90, 1.0, 0.0, 0.0, &err );
    1318 [ #  # ][ #  # ]:          0 :     CHECK( "Problems rotating brick for transforms test." );
    1319                 :            : 
    1320         [ #  # ]:          0 :     FBiGeom_getEntBoundBox( geom, brick, bb_min, bb_min + 1, bb_min + 2, bb_max, bb_max + 1, bb_max + 2, &err );
    1321 [ #  # ][ #  # ]:          0 :     CHECK( "Problems getting bounding box after rotate." );
    1322                 :            : 
    1323 [ #  # ][ #  # ]:          0 :     if( ( bb_min[0] ) >= dtol || -bb_min[0] >= dtol || ( bb_min[1] + 3 ) >= dtol || -( bb_min[1] + 3 ) >= dtol ||
         [ #  # ][ #  # ]
                 [ #  # ]
    1324 [ #  # ][ #  # ]:          0 :         ( bb_min[2] ) >= dtol || -( bb_min[2] ) >= dtol || ( bb_max[0] - 1 ) >= dtol || 1 - bb_max[0] >= dtol ||
         [ #  # ][ #  # ]
    1325 [ #  # ][ #  # ]:          0 :         ( bb_max[1] ) >= dtol || -( bb_max[1] ) >= dtol || ( bb_max[2] - 2 ) >= dtol || 2 - bb_max[2] >= dtol )
                 [ #  # ]
    1326                 :            :     {
    1327 [ #  # ][ #  # ]:          0 :         std::cerr << "Wrong bounding box after rotate." << std::endl;
    1328                 :          0 :         return false;
    1329                 :            :     }
    1330                 :            : 
    1331                 :            :     // now reflect through y plane; should recover original bb
    1332         [ #  # ]:          0 :     FBiGeom_reflectEnt( geom, brick, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, &err );
    1333 [ #  # ][ #  # ]:          0 :     CHECK( "Problems reflecting brick for transforms test." );
    1334                 :            : 
    1335         [ #  # ]:          0 :     FBiGeom_getEntBoundBox( geom, brick, bb_min, bb_min + 1, bb_min + 2, bb_max, bb_max + 1, bb_max + 2, &err );
    1336 [ #  # ][ #  # ]:          0 :     CHECK( "Problems getting bounding box after reflect." );
    1337                 :            : 
    1338 [ #  # ][ #  # ]:          0 :     if( ( bb_min[0] ) >= dtol || -( bb_min[0] ) >= dtol || ( bb_min[1] ) >= dtol || ( bb_min[2] ) >= dtol ||
         [ #  # ][ #  # ]
                 [ #  # ]
    1339 [ #  # ][ #  # ]:          0 :         -( bb_min[1] ) >= dtol || -( bb_min[2] ) >= dtol || ( bb_max[0] - 1 ) >= dtol || 1 - bb_max[0] >= dtol ||
         [ #  # ][ #  # ]
    1340 [ #  # ][ #  # ]:          0 :         ( bb_max[1] - 3 ) >= dtol || 3 - bb_max[1] >= dtol || ( bb_max[2] - 2 ) >= dtol || 2 - bb_max[2] >= dtol )
                 [ #  # ]
    1341                 :            :     {
    1342 [ #  # ][ #  # ]:          0 :         std::cerr << "Wrong bounding box after reflect." << std::endl;
    1343                 :          0 :         return false;
    1344                 :            :     }
    1345                 :            : 
    1346                 :            :     // must have worked; delete the entities then return
    1347         [ #  # ]:          0 :     FBiGeom_deleteEnt( geom, brick, &err );
    1348 [ #  # ][ #  # ]:          0 :     CHECK( "Problems deleting brick after transforms check." );
    1349                 :          0 :     return true;
    1350                 :            : }
    1351                 :            : 
    1352                 :          0 : bool booleans_test( FBiGeom_Instance geom )
    1353                 :            : {
    1354                 :            :     int err;
    1355                 :            : 
    1356                 :            :     // construct a brick size 1, and a cylinder rad 0.25 height 2
    1357                 :          0 :     iBase_EntityHandle brick = 0, cyl = 0;
    1358         [ #  # ]:          0 :     FBiGeom_createBrick( geom, 1.0, 0.0, 0.0, &brick, &err );
    1359 [ #  # ][ #  # ]:          0 :     CHECK( "Problems creating brick for booleans test." );
    1360         [ #  # ]:          0 :     FBiGeom_createCylinder( geom, 1.0, 0.25, 0.0, &cyl, &err );
    1361 [ #  # ][ #  # ]:          0 :     CHECK( "Problems creating cylinder for booleans test." );
    1362                 :            : 
    1363                 :            :     // subtract the cylinder from the brick
    1364                 :          0 :     iBase_EntityHandle subtract_result = 0;
    1365         [ #  # ]:          0 :     FBiGeom_subtractEnts( geom, brick, cyl, &subtract_result, &err );
    1366 [ #  # ][ #  # ]:          0 :     CHECK( "Problems subtracting for booleans subtract test." );
    1367                 :            : 
    1368                 :            :     // section the brick
    1369                 :          0 :     iBase_EntityHandle section_result = 0;
    1370         [ #  # ]:          0 :     FBiGeom_sectionEnt( geom, subtract_result, 1.0, 0.0, 0.0, 0.25, true, &section_result, &err );
    1371 [ #  # ][ #  # ]:          0 :     CHECK( "Problems sectioning for booleans section test." );
    1372                 :            : 
    1373                 :            :     // unite the section result with a new cylinder
    1374         [ #  # ]:          0 :     FBiGeom_createCylinder( geom, 1.0, 0.25, 0.0, &cyl, &err );
    1375 [ #  # ][ #  # ]:          0 :     CHECK( "Problems creating cylinder for unite test." );
    1376                 :            :     iBase_EntityHandle unite_results;
    1377                 :          0 :     iBase_EntityHandle unite_input[] = { section_result, cyl };
    1378         [ #  # ]:          0 :     FBiGeom_uniteEnts( geom, unite_input, 2, &unite_results, &err );
    1379 [ #  # ][ #  # ]:          0 :     CHECK( "Problems uniting for booleans unite test." );
    1380                 :            : 
    1381         [ #  # ]:          0 :     FBiGeom_deleteEnt( geom, unite_results, &err );
    1382 [ #  # ][ #  # ]:          0 :     CHECK( "Problems deleting for booleans unite test." );
    1383                 :          0 :     return true;
    1384                 :            : }
    1385                 :            : 
    1386                 :          0 : static int get_entities( FBiGeom_Instance geom, int entity_type, std::vector< iBase_EntityHandle >& entities_out,
    1387                 :            :                          iBase_TagHandle id_tag = 0, std::vector< int >* ids_out = 0 )
    1388                 :            : {
    1389                 :            :     int err, num;
    1390                 :            :     iBase_EntitySetHandle root;
    1391         [ #  # ]:          0 :     FBiGeom_getRootSet( geom, &root, &err );
    1392         [ #  # ]:          0 :     if( iBase_SUCCESS != err ) return err;
    1393         [ #  # ]:          0 :     FBiGeom_getNumOfType( geom, root, entity_type, &num, &err );
    1394         [ #  # ]:          0 :     if( iBase_SUCCESS != err ) return err;
    1395                 :            : 
    1396         [ #  # ]:          0 :     entities_out.resize( num );
    1397                 :          0 :     int junk1                    = entities_out.size(), junk2;
    1398         [ #  # ]:          0 :     iBase_EntityHandle* junk_ptr = &entities_out[0];
    1399                 :            :     ;
    1400         [ #  # ]:          0 :     FBiGeom_getEntities( geom, root, entity_type, &junk_ptr, &junk1, &junk2, &err );
    1401         [ #  # ]:          0 :     if( iBase_SUCCESS != err ) return err;
    1402 [ #  # ][ #  # ]:          0 :     assert( num == junk1 && num == junk2 );
    1403                 :            : 
    1404         [ #  # ]:          0 :     if( !ids_out ) return iBase_SUCCESS;
    1405                 :            : 
    1406         [ #  # ]:          0 :     ids_out->resize( num );
    1407         [ #  # ]:          0 :     int* int_ptr = &( *ids_out )[0];
    1408 [ #  # ][ #  # ]:          0 :     FBiGeom_getIntArrData( geom, &entities_out[0], num, id_tag, &int_ptr, &junk1, &junk2, &err );
    1409         [ #  # ]:          0 :     if( iBase_SUCCESS != err ) return err;
    1410 [ #  # ][ #  # ]:          0 :     assert( num == junk1 && num == junk2 );
    1411                 :            : 
    1412                 :          0 :     return iBase_SUCCESS;
    1413                 :            : }
    1414                 :            : 
    1415                 :          0 : static int check_firmness( FBiGeom_Instance geom, const std::vector< iBase_EntityHandle >& entities,
    1416                 :            :                            const std::vector< int >& ids, iBase_TagHandle firmness_tag, const char* expected_value,
    1417                 :            :                            const char* ent_type_str )
    1418                 :            : {
    1419                 :          0 :     const int firmness_size = 4;
    1420         [ #  # ]:          0 :     std::vector< char > firmness( firmness_size * entities.size() );
    1421                 :            : 
    1422         [ #  # ]:          0 :     char* byte_ptr = &firmness[0];
    1423                 :          0 :     int err, junk1 = firmness.size(), junk2 = entities.size() * firmness_size;
    1424 [ #  # ][ #  # ]:          0 :     FBiGeom_getArrData( geom, &entities[0], entities.size(), firmness_tag, (void**)&byte_ptr, &junk1, &junk2, &err );
    1425         [ #  # ]:          0 :     if( iBase_SUCCESS != err ) return err;
    1426                 :            : 
    1427                 :          0 :     bool all_correct = true;
    1428         [ #  # ]:          0 :     for( unsigned i = 0; i < entities.size(); ++i )
    1429 [ #  # ][ #  # ]:          0 :         if( std::string( &firmness[firmness_size * i], firmness_size ) != expected_value ) all_correct = false;
         [ #  # ][ #  # ]
    1430         [ #  # ]:          0 :     if( !all_correct )
    1431                 :            :     {
    1432 [ #  # ][ #  # ]:          0 :         std::cout << "ERROR: Expected \"" << expected_value << "\" firmness "
                 [ #  # ]
    1433 [ #  # ][ #  # ]:          0 :                   << "for all " << ent_type_str << "." << std::endl;
         [ #  # ][ #  # ]
    1434 [ #  # ][ #  # ]:          0 :         std::cout << "ID  Actual  " << std::endl;
    1435         [ #  # ]:          0 :         for( unsigned i = 0; i < entities.size(); ++i )
    1436 [ #  # ][ #  # ]:          0 :             std::cout << std::setw( 2 ) << ids[i] << "  " << std::string( &firmness[firmness_size * i], firmness_size )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1437         [ #  # ]:          0 :                       << std::endl;
    1438                 :          0 :         return iBase_FAILURE;
    1439                 :            :     }
    1440                 :            : 
    1441                 :          0 :     return iBase_SUCCESS;
    1442                 :            : }
    1443                 :            : 
    1444                 :          0 : static int count_num_with_tag( FBiGeom_Instance geom, const std::vector< iBase_EntityHandle >& ents,
    1445                 :            :                                iBase_TagHandle tag )
    1446                 :            : {
    1447                 :            :     int err, bytes;
    1448         [ #  # ]:          0 :     FBiGeom_getTagSizeBytes( geom, tag, &bytes, &err );
    1449         [ #  # ]:          0 :     if( iBase_SUCCESS != err ) return -1;
    1450         [ #  # ]:          0 :     std::vector< char > data( bytes );
    1451                 :            : 
    1452                 :          0 :     int success_count = 0;
    1453         [ #  # ]:          0 :     for( size_t i = 0; i < ents.size(); ++i )
    1454                 :            :     {
    1455         [ #  # ]:          0 :         char* ptr = &data[0];
    1456                 :          0 :         int junk1 = bytes, junk2;
    1457 [ #  # ][ #  # ]:          0 :         FBiGeom_getData( geom, ents[i], tag, (void**)&ptr, &junk1, &junk2, &err );
    1458         [ #  # ]:          0 :         if( iBase_TAG_NOT_FOUND == err ) continue;
    1459         [ #  # ]:          0 :         if( iBase_SUCCESS != err ) return -1;
    1460                 :          0 :         ++success_count;
    1461                 :            :     }
    1462                 :            : 
    1463                 :          0 :     return success_count;
    1464                 :            : }
    1465                 :            : 
    1466                 :          0 : bool mesh_size_test( FBiGeom_Instance geom )
    1467                 :            : {
    1468                 :          0 :     const char* filename = STRINGIFY( SRCDIR ) "/size.sat";
    1469                 :            :     int err, junk1, junk2;
    1470                 :          0 :     bool result = true;
    1471                 :            : 
    1472         [ #  # ]:          0 :     FBiGeom_deleteAll( geom, &err );
    1473 [ #  # ][ #  # ]:          0 :     CHECK( "" );
    1474         [ #  # ]:          0 :     FBiGeom_load( geom, filename, 0, &err, strlen( filename ), 0 );
    1475 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to load input file: 'size.sat'" );
    1476                 :            : 
    1477                 :            :     // get tag handles
    1478                 :            :     iBase_TagHandle interval, size, firmness, id;
    1479         [ #  # ]:          0 :     FBiGeom_getTagHandle( geom, "MESH_INTERVAL", &interval, &err, strlen( "MESH_INTERVAL" ) );
    1480 [ #  # ][ #  # ]:          0 :     CHECK( "FBiGeom_getTagHandle(\"MESH_INTERVAL\")" );
    1481         [ #  # ]:          0 :     FBiGeom_getTagHandle( geom, "MESH_SIZE", &size, &err, strlen( "MESH_SIZE" ) );
    1482 [ #  # ][ #  # ]:          0 :     CHECK( "FBiGeom_getTagHandle(\"MESH_SIZE\")" );
    1483         [ #  # ]:          0 :     FBiGeom_getTagHandle( geom, "SIZE_FIRMNESS", &firmness, &err, strlen( "SIZE_FIRMNESS" ) );
    1484 [ #  # ][ #  # ]:          0 :     CHECK( "FBiGeom_getTagHandle(\"SIZE_FIRMNESS\")" );
    1485         [ #  # ]:          0 :     FBiGeom_getTagHandle( geom, "GLOBAL_ID", &id, &err, strlen( "GLOBAL_ID" ) );
    1486 [ #  # ][ #  # ]:          0 :     CHECK( "FBiGeom_getTagHandle(\"GLOBAL_ID\")" );
    1487                 :            : 
    1488                 :            :     // get entity lists
    1489 [ #  # ][ #  # ]:          0 :     std::vector< iBase_EntityHandle > verts, curves, surfs, vols;
         [ #  # ][ #  # ]
    1490 [ #  # ][ #  # ]:          0 :     std::vector< int > vert_ids, curve_ids, surf_ids, vol_ids;
         [ #  # ][ #  # ]
    1491         [ #  # ]:          0 :     err = get_entities( geom, iBase_VERTEX, verts, id, &vert_ids );
    1492 [ #  # ][ #  # ]:          0 :     CHECK( "" );
    1493         [ #  # ]:          0 :     err = get_entities( geom, iBase_EDGE, curves, id, &curve_ids );
    1494 [ #  # ][ #  # ]:          0 :     CHECK( "" );
    1495         [ #  # ]:          0 :     err = get_entities( geom, iBase_FACE, surfs, id, &surf_ids );
    1496 [ #  # ][ #  # ]:          0 :     CHECK( "" );
    1497         [ #  # ]:          0 :     err = get_entities( geom, iBase_REGION, vols, id, &vol_ids );
    1498 [ #  # ][ #  # ]:          0 :     CHECK( "" );
    1499                 :            : 
    1500                 :            :     // expect interval count to be the same as ID for every curve
    1501         [ #  # ]:          0 :     std::vector< int > intervals( curves.size() );
    1502         [ #  # ]:          0 :     int* int_ptr = &intervals[0];
    1503                 :          0 :     junk1 = junk2 = curves.size();
    1504 [ #  # ][ #  # ]:          0 :     FBiGeom_getIntArrData( geom, &curves[0], curves.size(), interval, &int_ptr, &junk1, &junk2, &err );
    1505 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get intervals for curves" );
    1506 [ #  # ][ #  # ]:          0 :     if( intervals != curve_ids )
    1507                 :            :     {
    1508 [ #  # ][ #  # ]:          0 :         std::cout << "ERROR: Incorrect curve intervals for one or more curves." << std::endl;
    1509 [ #  # ][ #  # ]:          0 :         std::cout << "ID  Expected  Actual" << std::endl;
    1510         [ #  # ]:          0 :         for( unsigned i = 0; i < curves.size(); ++i )
    1511 [ #  # ][ #  # ]:          0 :             std::cout << std::setw( 2 ) << curve_ids[i] << "  " << std::setw( 8 ) << curve_ids[i] << "  "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1512 [ #  # ][ #  # ]:          0 :                       << std::setw( 6 ) << intervals[i] << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1513                 :          0 :         result = false;
    1514                 :            :     }
    1515                 :            : 
    1516                 :            :     // expect size to be the same as ID for every surface
    1517         [ #  # ]:          0 :     std::vector< double > sizes( surfs.size() );
    1518         [ #  # ]:          0 :     double* dbl_ptr = &sizes[0];
    1519                 :          0 :     junk1 = junk2 = surfs.size();
    1520 [ #  # ][ #  # ]:          0 :     FBiGeom_getDblArrData( geom, &surfs[0], surfs.size(), size, &dbl_ptr, &junk1, &junk2, &err );
    1521 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get sizes for surfaces" );
    1522                 :          0 :     bool all_correct = true;
    1523         [ #  # ]:          0 :     for( unsigned i = 0; i < surfs.size(); ++i )
    1524 [ #  # ][ #  # ]:          0 :         if( fabs( sizes[i] - (double)surf_ids[i] ) > 1e-8 ) all_correct = false;
                 [ #  # ]
    1525         [ #  # ]:          0 :     if( !all_correct )
    1526                 :            :     {
    1527 [ #  # ][ #  # ]:          0 :         std::cout << "ERROR: Incorrect mesh size for one or more surfaces." << std::endl;
    1528 [ #  # ][ #  # ]:          0 :         std::cout << "ID  Expected  Actual  " << std::endl;
    1529         [ #  # ]:          0 :         for( unsigned i = 0; i < surfs.size(); ++i )
    1530 [ #  # ][ #  # ]:          0 :             std::cout << std::setw( 2 ) << surf_ids[i] << "  " << std::setw( 8 ) << (double)surf_ids[i] << "  "
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1531 [ #  # ][ #  # ]:          0 :                       << std::setw( 8 ) << sizes[i] << std::endl;
         [ #  # ][ #  # ]
                 [ #  # ]
    1532                 :          0 :         result = false;
    1533                 :            :     }
    1534                 :            : 
    1535         [ #  # ]:          0 :     err = result ? iBase_SUCCESS : iBase_FAILURE;
    1536 [ #  # ][ #  # ]:          0 :     CHECK( "Invalid size or interval data" );
    1537                 :            : 
    1538                 :            :     // expect "HARD" firmness on all curves
    1539         [ #  # ]:          0 :     err = check_firmness( geom, curves, curve_ids, firmness, "HARD", "curves" );
    1540 [ #  # ][ #  # ]:          0 :     CHECK( "Invalid curve firmness" );
    1541                 :            :     // expect "SOFT" firmness on all surfaces
    1542         [ #  # ]:          0 :     err = check_firmness( geom, surfs, surf_ids, firmness, "SOFT", "surfaces" );
    1543 [ #  # ][ #  # ]:          0 :     CHECK( "Invalid surface firmness" );
    1544                 :            : 
    1545                 :            :     // expect no firmnes on other entities
    1546 [ #  # ][ #  # ]:          0 :     err = count_num_with_tag( geom, verts, firmness ) ? iBase_FAILURE : iBase_SUCCESS;
    1547 [ #  # ][ #  # ]:          0 :     CHECK( "Got firmness for vertex." );
    1548 [ #  # ][ #  # ]:          0 :     err = count_num_with_tag( geom, vols, firmness ) ? iBase_FAILURE : iBase_SUCCESS;
    1549 [ #  # ][ #  # ]:          0 :     CHECK( "Got firmness for volume." );
    1550                 :            : 
    1551                 :            :     // expect no interval tag on any entities except curves
    1552 [ #  # ][ #  # ]:          0 :     err = count_num_with_tag( geom, verts, interval ) ? iBase_FAILURE : iBase_SUCCESS;
    1553 [ #  # ][ #  # ]:          0 :     CHECK( "Got interval count for vertex." );
    1554 [ #  # ][ #  # ]:          0 :     err = count_num_with_tag( geom, vols, interval ) ? iBase_FAILURE : iBase_SUCCESS;
    1555 [ #  # ][ #  # ]:          0 :     CHECK( "Got interval count for volume." );
    1556                 :            : 
    1557                 :            :     // expect no size tag on any entities except surfaces
    1558                 :            :     // curves should have size of one of their parent surfaces
    1559 [ #  # ][ #  # ]:          0 :     err = count_num_with_tag( geom, verts, size ) ? iBase_FAILURE : iBase_SUCCESS;
    1560 [ #  # ][ #  # ]:          0 :     CHECK( "Got mesh size for vertex." );
    1561 [ #  # ][ #  # ]:          0 :     err = count_num_with_tag( geom, vols, size ) ? iBase_FAILURE : iBase_SUCCESS;
    1562 [ #  # ][ #  # ]:          0 :     CHECK( "Got mesh size for volume." );
    1563                 :            : 
    1564                 :          0 :     return true;
    1565                 :            : }
    1566                 :            : 
    1567                 :          1 : bool shutdown_test( FBiGeom_Instance geom, std::string& engine_opt )
    1568                 :            : {
    1569                 :            :     int err;
    1570                 :            : 
    1571                 :            :     // test shutdown & startup of interface
    1572         [ +  - ]:          1 :     FBiGeom_dtor( geom, &err );
    1573 [ -  + ][ #  # ]:          1 :     CHECK( "Interface destruction didn't work properly." );
    1574                 :            : 
    1575         [ +  - ]:          1 :     FBiGeom_newGeom( engine_opt.c_str(), &geom, &err, engine_opt.length() );
    1576 [ -  + ][ #  # ]:          1 :     CHECK( "Interface re-construction didn't work properly." );
    1577                 :            : 
    1578         [ +  - ]:          1 :     FBiGeom_dtor( geom, &err );
    1579 [ -  + ][ #  # ]:          1 :     CHECK( "2nd Interface destruction didn't work properly." );
    1580                 :            : 
    1581                 :          1 :     return true;
    1582                 :            : }
    1583                 :            : 
    1584                 :          0 : bool save_entset_test( FBiGeom_Instance geom )
    1585                 :            : {
    1586                 :            :     int err;
    1587                 :            : 
    1588                 :            : #ifdef FORCE_OCC
    1589                 :            :     std::string filename = "testout.brep";
    1590                 :            : #elif defined( HAVE_ACIS )
    1591                 :            :     std::string filename = "testout.sat";
    1592                 :            : #elif defined( HAVE_OCC )
    1593                 :            :     std::string filename = "testout.brep";
    1594                 :            : #else
    1595         [ #  # ]:          0 :     std::string filename = "testout.sat";
    1596                 :            : #endif
    1597                 :            : 
    1598                 :            :     // initialize number of ents and sets to compare with later
    1599                 :            :     int num_ents_bef, num_sets_bef;
    1600                 :            :     iBase_EntitySetHandle root;
    1601         [ #  # ]:          0 :     FBiGeom_getRootSet( geom, &root, &err );
    1602 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get root set." );
    1603         [ #  # ]:          0 :     FBiGeom_getNumEntSets( geom, root, 1, &num_sets_bef, &err );
    1604 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get number of ent sets." );
    1605         [ #  # ]:          0 :     FBiGeom_getNumOfType( geom, root, iBase_REGION, &num_ents_bef, &err );
    1606 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get number of entities." );
    1607                 :            : 
    1608                 :            :     // create set, and entity to add to set
    1609                 :            :     iBase_EntityHandle cyl;
    1610         [ #  # ]:          0 :     FBiGeom_createCylinder( geom, 1.0, 0.25, 0.0, &cyl, &err );
    1611 [ #  # ][ #  # ]:          0 :     CHECK( "Problems creating cylinder for save entset test." );
    1612                 :            :     iBase_EntitySetHandle seth;
    1613         [ #  # ]:          0 :     FBiGeom_createEntSet( geom, true, &seth, &err );
    1614 [ #  # ][ #  # ]:          0 :     CHECK( "Problems creating entity set for save entset test." );
    1615                 :            : 
    1616                 :            :     // add the entity
    1617         [ #  # ]:          0 :     FBiGeom_addEntToSet( geom, cyl, seth, &err );
    1618 [ #  # ][ #  # ]:          0 :     CHECK( "Problems adding entity to set for save entset test." );
    1619                 :            : 
    1620                 :            :     // save/restore the model, and see if the entity is there
    1621         [ #  # ]:          0 :     FBiGeom_save( geom, filename.c_str(), NULL, &err, filename.length(), 0 );
    1622 [ #  # ][ #  # ]:          0 :     CHECK( "Problems saving file for save entset test." );
    1623                 :            : 
    1624         [ #  # ]:          0 :     FBiGeom_destroyEntSet( geom, seth, &err );
    1625 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to destroy entity set." );
    1626         [ #  # ]:          0 :     FBiGeom_deleteEnt( geom, cyl, &err );
    1627 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to destroy entity." );
    1628                 :            : 
    1629                 :            :     // read the file back in
    1630         [ #  # ]:          0 :     FBiGeom_load( geom, filename.c_str(), NULL, &err, filename.length(), 0 );
    1631 [ #  # ][ #  # ]:          0 :     CHECK( "Problems reading file for save entset test." );
    1632                 :            : 
    1633                 :            :     // check number of sets and entities
    1634                 :            :     int num_ents_aft, num_sets_aft;
    1635         [ #  # ]:          0 :     FBiGeom_getNumEntSets( geom, root, 1, &num_sets_aft, &err );
    1636 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get number of ent sets." );
    1637         [ #  # ]:          0 :     FBiGeom_getNumOfType( geom, root, iBase_REGION, &num_ents_aft, &err );
    1638 [ #  # ][ #  # ]:          0 :     CHECK( "Failed to get number of entities." );
    1639                 :          0 :     bool success = true;
    1640         [ #  # ]:          0 :     if( num_ents_aft != 2 * num_ents_bef + 1 )
    1641                 :            :     {
    1642         [ #  # ]:          0 :         print_error( "Failed to get the right number of entities.", iBase_FAILURE, geom, __FILE__, __LINE__ );
    1643                 :          0 :         success = false;
    1644                 :            :     }
    1645         [ #  # ]:          0 :     else if( num_sets_aft != 2 * num_sets_bef + 1 )
    1646                 :            :     {
    1647         [ #  # ]:          0 :         print_error( "Failed to get the right number of entity sets.", iBase_FAILURE, geom, __FILE__, __LINE__ );
    1648                 :          0 :         success = false;
    1649                 :            :     }
    1650                 :            : 
    1651                 :            :     // otherwise, we succeeded
    1652                 :          0 :     return success;
    1653 [ +  - ][ +  - ]:          4 : }

Generated by: LCOV version 1.11