MOAB: Mesh Oriented datABase  (version 5.2.1)
testSmooth2.cpp
Go to the documentation of this file.
00001 /**
00002  * This library is free software; you can redistribute it and/or
00003  * modify it under the terms of the GNU Lesser General Public
00004  * License as published by the Free Software Foundation; either
00005  * version 2.1 of the License, or (at your option) any later version.
00006  *
00007  */
00008 /**
00009  * \file testgeom.cc
00010  *
00011  * \brief testgeom, a unit test for the ITAPS geometry interface
00012  *
00013  */
00014 #include "FBiGeom.h"
00015 #include "FBiGeom_MOAB.hpp"
00016 #include "iMesh.h"
00017 #include <iostream>
00018 #include <set>
00019 #include <algorithm>
00020 #include <vector>
00021 #include <iterator>
00022 #include <algorithm>
00023 #include <iomanip>
00024 #include <assert.h>
00025 #include <string.h>
00026 #include <math.h>
00027 #define CHECK( STR ) \
00028     if( err != iBase_SUCCESS ) return print_error( STR, err, geom, __FILE__, __LINE__ )
00029 
00030 #define STRINGIFY( S )  XSTRINGIFY( S )
00031 #define XSTRINGIFY( S ) #S
00032 
00033 static bool print_error( const char* desc, int err, FBiGeom_Instance geom, const char* file, int line )
00034 {
00035     char buffer[1024];
00036     FBiGeom_getDescription( geom, buffer, sizeof( buffer ) );
00037     buffer[sizeof( buffer ) - 1] = '\0';
00038 
00039     std::cerr << "ERROR: " << desc << std::endl
00040               << "  Error code: " << err << std::endl
00041               << "  Error desc: " << buffer << std::endl
00042               << "  At        : " << file << ':' << line << std::endl;
00043 
00044     return false;  // must always return false or CHECK macro will break
00045 }
00046 
00047 typedef iBase_TagHandle TagHandle;
00048 typedef iBase_EntityHandle GentityHandle;
00049 typedef iBase_EntitySetHandle GentitysetHandle;
00050 
00051 extern void FBiGeom_newGeomFromMesh( iMesh_Instance mesh, iBase_EntitySetHandle set, const char* options,
00052                                      FBiGeom_Instance* geom, int* err, int options_len );
00053 // the second destructor
00054 extern void FBiGeom_dtor2( FBiGeom_Instance instance, int* err );
00055 /* Frees allocated arrays for us */
00056 template < typename T >
00057 class SimpleArray
00058 {
00059   private:
00060     T* arr;
00061     int arrSize;
00062     int arrAllocated;
00063 
00064   public:
00065     SimpleArray() : arr( 0 ), arrSize( 0 ), arrAllocated( 0 ) {}
00066     SimpleArray( unsigned s ) : arrSize( s ), arrAllocated( s )
00067     {
00068         arr = (T*)malloc( s * sizeof( T ) );
00069         for( unsigned i = 0; i < s; ++i )
00070             new( arr + i ) T();
00071     }
00072 
00073     ~SimpleArray()
00074     {
00075         for( int i = 0; i < size(); ++i )
00076             arr[i].~T();
00077         free( arr );
00078     }
00079 
00080     T** ptr()
00081     {
00082         return &arr;
00083     }
00084     int& size()
00085     {
00086         return arrSize;
00087     }
00088     int size() const
00089     {
00090         return arrSize;
00091     }
00092     int& capacity()
00093     {
00094         return arrAllocated;
00095     }
00096     int capacity() const
00097     {
00098         return arrAllocated;
00099     }
00100 
00101     typedef T* iterator;
00102     typedef const T* const_iterator;
00103     iterator begin()
00104     {
00105         return arr;
00106     }
00107     const_iterator begin() const
00108     {
00109         return arr;
00110     }
00111     iterator end()
00112     {
00113         return arr + arrSize;
00114     }
00115     const_iterator end() const
00116     {
00117         return arr + arrSize;
00118     }
00119 
00120     T& operator[]( unsigned idx )
00121     {
00122         return arr[idx];
00123     }
00124     T operator[]( unsigned idx ) const
00125     {
00126         return arr[idx];
00127     }
00128 };
00129 
00130 #define ARRAY_INOUT( A ) A.ptr(), &A.capacity(), &A.size()
00131 #define ARRAY_IN( A )    &A[0], A.size()
00132 
00133 bool smooth_test( const std::string& filename, FBiGeom_Instance );
00134 
00135 bool tags_test( FBiGeom_Instance geom );
00136 bool tag_get_set_test( FBiGeom_Instance geom );
00137 bool tag_info_test( FBiGeom_Instance geom );
00138 bool gentityset_test( FBiGeom_Instance geom, bool /*multiset*/, bool /*ordered*/ );
00139 bool topology_adjacencies_test( FBiGeom_Instance geom );
00140 bool geometry_evaluation_test( FBiGeom_Instance geom );
00141 bool construct_test( FBiGeom_Instance geom );
00142 bool primitives_test( FBiGeom_Instance geom );
00143 bool transforms_test( FBiGeom_Instance geom );
00144 bool booleans_test( FBiGeom_Instance geom );
00145 bool shutdown_test2( FBiGeom_Instance geom, std::string& engine_opt );
00146 bool save_entset_test( FBiGeom_Instance geom );
00147 bool mesh_size_test( FBiGeom_Instance geom );
00148 bool normals_test( FBiGeom_Instance geom );
00149 
00150 bool ray_test( FBiGeom_Instance geom );
00151 
00152 void handle_error_code( const bool result, int& number_failed, int& /*number_not_implemented*/, int& number_successful )
00153 {
00154     if( result )
00155     {
00156         std::cout << "Success";
00157         number_successful++;
00158     }
00159     else
00160     {
00161         std::cout << "Failure";
00162         number_failed++;
00163     }
00164 }
00165 
00166 int main( int argc, char* argv[] )
00167 {
00168     std::string filename = STRINGIFY( MESHDIR ) "/shell.h5m";
00169 
00170     if( argc == 1 ) { std::cout << "Using default input file: " << filename << std::endl; }
00171     else if( argc == 2 )
00172     {
00173         filename = argv[1];
00174     }
00175     else
00176     {
00177         std::cerr << "Usage: " << argv[0] << " [geom_filename]" << std::endl;
00178         return 1;
00179     }
00180 
00181     int err;
00182     int number_tests                 = 0;
00183     int number_tests_successful      = 0;
00184     int number_tests_not_implemented = 0;
00185     int number_tests_failed          = 0;
00186 
00187     // initialize the FBiGeom, in a different way
00188     iMesh_Instance mesh = NULL;
00189     FBiGeom_Instance geom;
00190     iMesh_newMesh( NULL, &mesh, &err, 0 );
00191     if( err != iBase_SUCCESS )
00192         std::cerr << " Error code: " << err << "  At        : " << __FILE__ << ':' << __LINE__ << std::endl;
00193 
00194     iBase_EntitySetHandle root_set;
00195     iMesh_createEntSet( mesh, 0, &root_set, &err );
00196     if( err != iBase_SUCCESS )
00197         std::cerr << " Error code: " << err << " failed to create a model set"
00198                   << "  At        : " << __FILE__ << ':' << __LINE__ << std::endl;
00199 
00200     iMesh_load( mesh, root_set, filename.c_str(), NULL, &err, filename.length(), 0 );
00201     if( err != iBase_SUCCESS )
00202         std::cerr << " Error code: " << err << " failed load the file"
00203                   << "  At        : " << __FILE__ << ':' << __LINE__ << std::endl;
00204 
00205     std::string opts( "SMOOTH;" );
00206     // new constructor
00207     FBiGeom_newGeomFromMesh( mesh, root_set, opts.c_str(), &geom, &err, opts.length() );
00208 
00209     CHECK( "Interface initialization didn't work properly." );
00210 
00211     // Print out Header information
00212     std::cout << "\n\nITAPS GEOMETRY INTERFACE TEST PROGRAM:\n\n";
00213     // gLoad test
00214 
00215     bool result;
00216     std::cout << "   Smooth faceting load and initialization: \n";
00217     result = smooth_test( filename, geom );
00218     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
00219 
00220     number_tests++;
00221     std::cout << "\n";
00222 
00223     // tags test
00224     std::cout << "   tags: ";
00225     result = tags_test( geom );
00226     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
00227     number_tests++;
00228     std::cout << "\n";
00229     /*
00230      // gentitysets test
00231      std::cout << "   gentity sets: ";
00232      result = gentityset_test(geom, false, false);
00233      handle_error_code(result, number_tests_failed,
00234      number_tests_not_implemented,
00235      number_tests_successful);
00236      number_tests++;
00237      std::cout << "\n";
00238      */
00239     // topology adjacencies test
00240     std::cout << "   topology adjacencies: ";
00241     result = topology_adjacencies_test( geom );
00242     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
00243     number_tests++;
00244     std::cout << "\n";
00245 
00246     // geometry evaluation test
00247     std::cout << "   geometry evaluation: \n";
00248     result = geometry_evaluation_test( geom );
00249     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
00250     number_tests++;
00251     std::cout << "\n";
00252 
00253     // normals evaluation test
00254     std::cout << "   normals geometry evaluation: \n";
00255     result = normals_test( geom );
00256     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
00257     number_tests++;
00258     std::cout << "\n";
00259 
00260     // ray tracing test
00261     std::cout << "   ray intersection test: \n";
00262     result = ray_test( geom );
00263     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
00264     number_tests++;
00265     std::cout << "\n";
00266     /*
00267      // construct test
00268      std::cout << "   construct: ";
00269      result = construct_test(geom);
00270      handle_error_code(result, number_tests_failed,
00271      number_tests_not_implemented,
00272      number_tests_successful);
00273      number_tests++;
00274      std::cout << "\n";
00275 
00276      // primitives test
00277      std::cout << "   primitives: ";
00278      result = primitives_test(geom);
00279      handle_error_code(result, number_tests_failed,
00280      number_tests_not_implemented,
00281      number_tests_successful);
00282      number_tests++;
00283      std::cout << "\n";
00284 
00285      // transforms test
00286      std::cout << "   transforms: ";
00287      result = transforms_test(geom);
00288      handle_error_code(result, number_tests_failed,
00289      number_tests_not_implemented,
00290      number_tests_successful);
00291      number_tests++;
00292      std::cout << "\n";
00293 
00294      // booleans test
00295      std::cout << "   booleans: ";
00296      result = booleans_test(geom);
00297      handle_error_code(result, number_tests_failed,
00298      number_tests_not_implemented,
00299      number_tests_successful);
00300      number_tests++;
00301      std::cout << "\n";
00302 
00303      #if defined(HAVE_ACIS) && !defined(FORCE_OCC)
00304      std::cout << "   mesh size: ";
00305      result = mesh_size_test(geom);
00306      handle_error_code(result, number_tests_failed,
00307      number_tests_not_implemented,
00308      number_tests_successful);
00309      number_tests++;
00310      std::cout << "\n";
00311 
00312      // save entset test
00313      std::cout << "   save entset: ";
00314      result = save_entset_test(geom);
00315      handle_error_code(result, number_tests_failed,
00316      number_tests_not_implemented,
00317      number_tests_successful);
00318      number_tests++;
00319      std::cout << "\n";
00320      #endif
00321      */
00322     // shutdown test
00323     std::cout << "   shutdown: ";
00324     std::string engine_opt;
00325     result = shutdown_test2( geom, engine_opt );
00326     handle_error_code( result, number_tests_failed, number_tests_not_implemented, number_tests_successful );
00327     number_tests++;
00328     std::cout << "\n";
00329 
00330     // shutdown imesh instance too
00331     iMesh_dtor( mesh, &err );
00332     CHECK( "shutdown imesh error" );
00333     // summary
00334 
00335     std::cout << "\nTSTT TEST SUMMARY: \n"
00336               << "   Number Tests:           " << number_tests << "\n"
00337               << "   Number Successful:      " << number_tests_successful << "\n"
00338               << "   Number Not Implemented: " << number_tests_not_implemented << "\n"
00339               << "   Number Failed:          " << number_tests_failed << "\n\n"
00340               << std::endl;
00341 
00342     return number_tests_failed;
00343 }
00344 
00345 /*!
00346  @test
00347  Load Mesh
00348  @li Load a mesh file
00349  */
00350 
00351 bool smooth_test( const std::string& filename, FBiGeom_Instance geom )
00352 {
00353     int err;
00354     char opts[] = "SMOOTH;";
00355     FBiGeom_load( geom, &filename[0], opts, &err, filename.length(), 8 );
00356     // FBiGeom_load( geom, &filename[0], 0, &err, filename.length(), 0 );
00357     CHECK( "ERROR : can not load a geometry" );
00358 
00359     iBase_EntitySetHandle root_set;
00360     FBiGeom_getRootSet( geom, &root_set, &err );
00361     CHECK( "ERROR : getRootSet failed!" );
00362 
00363     // print out the number of entities
00364     std::cout << "Model contents: " << std::endl;
00365     const char* gtype[] = { "vertices: ", "edges: ", "faces: ", "regions: " };
00366     for( int i = 0; i <= 3; ++i )
00367     {
00368         int count;
00369         FBiGeom_getNumOfType( geom, root_set, i, &count, &err );
00370         CHECK( "Error: problem getting entities after gLoad." );
00371         std::cout << gtype[i] << count << std::endl;
00372     }
00373 
00374     return true;
00375 }
00376 /*!
00377  @test
00378  Test tag creating, reading, writing, deleting
00379  @li Load a mesh file
00380  */
00381 bool tags_test( FBiGeom_Instance geom )
00382 {
00383     bool success = tag_info_test( geom );
00384     if( !success ) return success;
00385 
00386     success = tag_get_set_test( geom );
00387     if( !success ) return success;
00388 
00389     return true;
00390 }
00391 
00392 bool tag_info_test( FBiGeom_Instance geom )
00393 {
00394     int err;
00395 
00396     iBase_EntitySetHandle root_set;
00397     FBiGeom_getRootSet( geom, &root_set, &err );
00398     CHECK( "ERROR : getRootSet failed!" );
00399 
00400     // create an arbitrary tag, size 4
00401     iBase_TagHandle this_tag, tmp_handle;
00402     std::string tag_name( "tag_info tag" ), tmp_name;
00403     FBiGeom_createTag( geom, &tag_name[0], 4, iBase_BYTES, &this_tag, &err, tag_name.length() );
00404     CHECK( "ERROR : can not create a tag." );
00405 
00406     // get information on the tag
00407 
00408     char name_buffer[256];
00409     FBiGeom_getTagName( geom, this_tag, name_buffer, &err, sizeof( name_buffer ) );
00410     CHECK( "ERROR : Couldn't get tag name." );
00411     if( tag_name != name_buffer )
00412     {
00413         std::cerr << "ERROR: getTagName returned '" << name_buffer << "' for tag created as '" << tag_name << "'"
00414                   << std::endl;
00415         return false;
00416     }
00417 
00418     FBiGeom_getTagHandle( geom, &tag_name[0], &tmp_handle, &err, tag_name.length() );
00419     CHECK( "ERROR : Couldn't get tag handle." );
00420     if( tmp_handle != this_tag )
00421     {
00422         std::cerr << "ERROR: getTagHandle didn't return consistent result." << std::endl;
00423         return false;
00424     }
00425 
00426     int tag_size;
00427     FBiGeom_getTagSizeBytes( geom, this_tag, &tag_size, &err );
00428     CHECK( "ERROR : Couldn't get tag size." );
00429     if( tag_size != 4 )
00430     {
00431         std::cerr << "ERROR: getTagSizeBytes: expected 4, got " << tag_size << std::endl;
00432         return false;
00433     }
00434 
00435     FBiGeom_getTagSizeValues( geom, this_tag, &tag_size, &err );
00436     CHECK( "ERROR : Couldn't get tag size." );
00437     if( tag_size != 4 )
00438     {
00439         std::cerr << "ERROR: getTagSizeValues: expected 4, got " << tag_size << std::endl;
00440         return false;
00441     }
00442 
00443     int tag_type;
00444     FBiGeom_getTagType( geom, this_tag, &tag_type, &err );
00445     CHECK( "ERROR : Couldn't get tag type." );
00446     if( tag_type != iBase_BYTES )
00447     {
00448         std::cerr << "ERROR: getTagType: expected " << iBase_BYTES << ", got " << tag_type << std::endl;
00449         return false;
00450     }
00451 
00452     FBiGeom_destroyTag( geom, this_tag, true, &err );
00453     CHECK( "ERROR : Couldn't delete a tag." );
00454 
00455     // print information about all the tags in the model
00456 
00457     std::set< iBase_TagHandle > tags;
00458     SimpleArray< iBase_EntityHandle > entities;
00459     FBiGeom_getEntities( geom, root_set, iBase_ALL_TYPES, ARRAY_INOUT( entities ), &err );
00460     CHECK( "getEntities( ..., iBase_ALL_TYPES, ... ) failed." );
00461     for( int i = 0; i < entities.size(); ++i )
00462     {
00463         SimpleArray< iBase_TagHandle > tag_arr;
00464         FBiGeom_getAllTags( geom, entities[i], ARRAY_INOUT( tag_arr ), &err );
00465         CHECK( "getAllTags failed." );
00466         std::copy( tag_arr.begin(), tag_arr.end(), std::inserter( tags, tags.begin() ) );
00467     }
00468 
00469     std::cout << "Tags defined on model: ";
00470     bool first = true;
00471     for( std::set< iBase_TagHandle >::iterator sit = tags.begin(); sit != tags.end(); ++sit )
00472     {
00473         FBiGeom_getTagName( geom, *sit, name_buffer, &err, sizeof( name_buffer ) );
00474         name_buffer[sizeof( name_buffer ) - 1] = '\0';  // mnake sure of NUL termination
00475         CHECK( "getTagName failed." );
00476 
00477         if( !first ) std::cout << ", ";
00478         std::cout << name_buffer;
00479         first = false;
00480     }
00481     if( first ) std::cout << "<none>";
00482     std::cout << std::endl;
00483 
00484     return true;
00485 }
00486 
00487 bool tag_get_set_test( FBiGeom_Instance geom )
00488 {
00489     int err;
00490 
00491     // create an arbitrary tag, size 4
00492     iBase_TagHandle this_tag;
00493     std::string tag_name( "tag_get_set tag" );
00494     FBiGeom_createTag( geom, &tag_name[0], sizeof( int ), iBase_BYTES, &this_tag, &err, tag_name.length() );
00495     CHECK( "ERROR : can not create a tag for get_set test." );
00496 
00497     iBase_EntitySetHandle root_set;
00498     FBiGeom_getRootSet( geom, &root_set, &err );
00499     CHECK( "ERROR : getRootSet failed!" );
00500 
00501     // set this tag to an integer on each entity; keep track of total sum
00502     int sum = 0, num = 0, dim;
00503     for( dim = 0; dim <= 3; dim++ )
00504     {
00505         SimpleArray< iBase_EntityHandle > gentity_handles;
00506         FBiGeom_getEntities( geom, root_set, dim, ARRAY_INOUT( gentity_handles ), &err );
00507         int num_ents = gentity_handles.size();
00508         std::vector< int > tag_vals( num_ents );
00509         for( int i = 0; i < num_ents; ++i )
00510         {
00511             tag_vals[i] = num;
00512             sum += num;
00513             ++num;
00514         }
00515 
00516         FBiGeom_setArrData( geom, ARRAY_IN( gentity_handles ), this_tag, (char*)&tag_vals[0],
00517                             tag_vals.size() * sizeof( int ), &err );
00518         CHECK( "ERROR : can't set tag on entities" );
00519     }
00520 
00521     // check tag values for entities now
00522     int get_sum = 0;
00523     for( dim = 0; dim <= 3; dim++ )
00524     {
00525         SimpleArray< iBase_EntityHandle > gentity_handles;
00526         FBiGeom_getEntities( geom, root_set, dim, ARRAY_INOUT( gentity_handles ), &err );
00527         int num_ents = gentity_handles.size();
00528 
00529         SimpleArray< char > tag_vals;
00530         FBiGeom_getArrData( geom, ARRAY_IN( gentity_handles ), this_tag, (void**)tag_vals.ptr(), &tag_vals.capacity(),
00531                             &tag_vals.size(), &err );
00532         CHECK( "ERROR : can't get tag on entities" );
00533 
00534         int* tag_ptr = (int*)( &tag_vals[0] );
00535         for( int i = 0; i < num_ents; ++i )
00536             get_sum += tag_ptr[i];
00537     }
00538 
00539     if( get_sum != sum )
00540     {
00541         std::cerr << "ERROR: getData didn't return consistent results." << std::endl;
00542         return false;
00543     }
00544 
00545     FBiGeom_destroyTag( geom, this_tag, true, &err );
00546     CHECK( "ERROR : couldn't delete tag." );
00547 
00548     return true;
00549 }
00550 
00551 /*!
00552  @test
00553  TSTT gentity sets test (just implemented parts for now)
00554  @li Check gentity sets
00555  */
00556 bool gentityset_test( FBiGeom_Instance geom, bool /*multiset*/, bool /*ordered*/ )
00557 {
00558     int num_type = 4;
00559     iBase_EntitySetHandle ges_array[4];
00560     int number_array[4];
00561     // int num_all_gentities_super = 0;
00562     int ent_type = iBase_VERTEX;
00563 
00564     int err;
00565     iBase_EntitySetHandle root_set;
00566     FBiGeom_getRootSet( geom, &root_set, &err );
00567     CHECK( "ERROR : getRootSet failed!" );
00568 
00569     // get the number of sets in the whole model
00570     int all_sets = 0;
00571     FBiGeom_getNumEntSets( geom, root_set, 0, &all_sets, &err );
00572     CHECK( "Problem getting the number of all gentity sets in whole model." );
00573 
00574     // add gentities to entitysets by type
00575     for( ; ent_type < num_type; ent_type++ )
00576     {
00577         // initialize the entityset
00578         FBiGeom_createEntSet( geom, true, &ges_array[ent_type], &err );
00579         CHECK( "Problem creating entityset." );
00580 
00581         // get entities by type in total "mesh"
00582         SimpleArray< iBase_EntityHandle > gentities;
00583         FBiGeom_getEntities( geom, root_set, ent_type, ARRAY_INOUT( gentities ), &err );
00584         CHECK( "Failed to get gentities by type in gentityset_test." );
00585 
00586         // add gentities into gentity set
00587         FBiGeom_addEntArrToSet( geom, ARRAY_IN( gentities ), ges_array[ent_type], &err );
00588         CHECK( "Failed to add gentities in entityset_test." );
00589 
00590         // Check to make sure entity set really has correct number of entities in it
00591         FBiGeom_getNumOfType( geom, ges_array[ent_type], ent_type, &number_array[ent_type], &err );
00592         CHECK( "Failed to get number of gentities by type in entityset_test." );
00593 
00594         // compare the number of entities by type
00595         int num_type_gentity = gentities.size();
00596 
00597         if( number_array[ent_type] != num_type_gentity )
00598         {
00599             std::cerr << "Number of gentities by type is not correct" << std::endl;
00600             return false;
00601         }
00602 
00603         // add to number of all entities in super set
00604         // num_all_gentities_super += num_type_gentity;
00605     }
00606 
00607     // make a super set having all entitysets
00608     iBase_EntitySetHandle super_set;
00609     FBiGeom_createEntSet( geom, true, &super_set, &err );
00610     CHECK( "Failed to create a super set in gentityset_test." );
00611 
00612     for( int i = 0; i < num_type; i++ )
00613     {
00614         FBiGeom_addEntSet( geom, ges_array[i], super_set, &err );
00615         CHECK( "Failed to create a super set in gentityset_test." );
00616     }
00617 
00618     //----------TEST BOOLEAN OPERATIONS----------------//
00619 
00620     iBase_EntitySetHandle temp_ges1;
00621     FBiGeom_createEntSet( geom, true, &temp_ges1, &err );
00622     CHECK( "Failed to create a super set in gentityset_test." );
00623 
00624     // Subtract
00625     // add all EDGEs and FACEs to temp_es1
00626     // get all EDGE entities
00627     SimpleArray< iBase_EntityHandle > gedges, gfaces, temp_gentities1;
00628     FBiGeom_getEntities( geom, ges_array[iBase_EDGE], iBase_EDGE, ARRAY_INOUT( gedges ), &err );
00629     CHECK( "Failed to get gedge gentities in gentityset_test." );
00630 
00631     // add EDGEs to ges1
00632     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gedges ), temp_ges1, &err );
00633     CHECK( "Failed to add gedge gentities in gentityset_test." );
00634 
00635     // get all FACE gentities
00636     FBiGeom_getEntities( geom, ges_array[iBase_FACE], iBase_FACE, ARRAY_INOUT( gfaces ), &err );
00637     CHECK( "Failed to get gface gentities in gentityset_test." );
00638 
00639     // add FACEs to es1
00640     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gfaces ), temp_ges1, &err );
00641     CHECK( "Failed to add gface gentities in gentityset_test." );
00642 
00643     // subtract EDGEs
00644     FBiGeom_subtract( geom, temp_ges1, ges_array[iBase_EDGE], &temp_ges1, &err );
00645     CHECK( "Failed to subtract gentitysets in gentityset_test." );
00646 
00647     FBiGeom_getEntities( geom, temp_ges1, iBase_FACE, ARRAY_INOUT( temp_gentities1 ), &err );
00648     CHECK( "Failed to get gface gentities in gentityset_test." );
00649 
00650     if( gfaces.size() != temp_gentities1.size() )
00651     {
00652         std::cerr << "Number of entitysets after subtraction not correct \
00653              in gentityset_test."
00654                   << std::endl;
00655         return false;
00656     }
00657 
00658     // check there's nothing but gfaces in temp_ges1
00659     int num_gents;
00660     FBiGeom_getNumOfType( geom, temp_ges1, iBase_EDGE, &num_gents, &err );
00661     CHECK( "Failed to get dimensions of gentities in gentityset_test." );
00662     if( 0 != num_gents )
00663     {
00664         std::cerr << "Subtraction failed to remove all edges" << std::endl;
00665         return false;
00666     }
00667 
00668     //------------Intersect------------
00669     //
00670 
00671     // clean out the temp_ges1
00672     FBiGeom_rmvEntArrFromSet( geom, ARRAY_IN( gfaces ), temp_ges1, &err );
00673     CHECK( "Failed to remove gface gentities in gentityset_test." );
00674 
00675     // check if it is really cleaned out
00676     FBiGeom_getNumOfType( geom, temp_ges1, iBase_FACE, &num_gents, &err );
00677     CHECK( "Failed to get number of gentities by type in gentityset_test." );
00678 
00679     if( num_gents != 0 )
00680     {
00681         std::cerr << "failed to remove correctly." << std::endl;
00682         return false;
00683     }
00684 
00685     // add EDGEs to temp ges1
00686     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gedges ), temp_ges1, &err );
00687     CHECK( "Failed to add gedge gentities in gentityset_test." );
00688 
00689     // add FACEs to temp ges1
00690     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gfaces ), temp_ges1, &err );
00691     CHECK( "Failed to add gface gentities in gentityset_test." );
00692 
00693     // intersect temp_ges1 with gedges set
00694     // temp_ges1 entityset is altered
00695     FBiGeom_intersect( geom, temp_ges1, ges_array[iBase_EDGE], &temp_ges1, &err );
00696     CHECK( "Failed to intersect in gentityset_test." );
00697 
00698     // try to get FACEs, but there should be nothing but EDGE
00699     FBiGeom_getNumOfType( geom, temp_ges1, iBase_FACE, &num_gents, &err );
00700     CHECK( "Failed to get gface gentities in gentityset_test." );
00701 
00702     if( num_gents != 0 )
00703     {
00704         std::cerr << "wrong number of gfaces." << std::endl;
00705         return false;
00706     }
00707 
00708     //-------------Unite--------------
00709 
00710     // get all regions
00711     iBase_EntitySetHandle temp_ges2;
00712     SimpleArray< iBase_EntityHandle > gregions;
00713 
00714     FBiGeom_createEntSet( geom, true, &temp_ges2, &err );
00715     CHECK( "Failed to create a temp gentityset in gentityset_test." );
00716 
00717     FBiGeom_getEntities( geom, ges_array[iBase_REGION], iBase_REGION, ARRAY_INOUT( gregions ), &err );
00718     CHECK( "Failed to get gregion gentities in gentityset_test." );
00719 
00720     // add REGIONs to temp es2
00721     FBiGeom_addEntArrToSet( geom, ARRAY_IN( gregions ), temp_ges2, &err );
00722     CHECK( "Failed to add gregion gentities in gentityset_test." );
00723 
00724     // unite temp_ges1 and temp_ges2
00725     // temp_ges1 gentityset is altered
00726     FBiGeom_unite( geom, temp_ges1, temp_ges2, &temp_ges1, &err );
00727     CHECK( "Failed to unite in gentityset_test." );
00728 
00729     // perform the check
00730     FBiGeom_getNumOfType( geom, temp_ges1, iBase_REGION, &num_gents, &err );
00731     CHECK( "Failed to get number of gregion gentities by type in gentityset_test." );
00732 
00733     if( num_gents != number_array[iBase_REGION] )
00734     {
00735         std::cerr << "different number of gregions in gentityset_test." << std::endl;
00736         return false;
00737     }
00738 
00739     //--------Test parent/child stuff in entiysets-----------
00740 
00741     // Add 2 sets as children to another
00742     iBase_EntitySetHandle parent_child;
00743     FBiGeom_createEntSet( geom, true, &parent_child, &err );
00744     CHECK( "Problem creating gentityset in gentityset_test." );
00745 
00746     FBiGeom_addPrntChld( geom, ges_array[iBase_VERTEX], parent_child, &err );
00747     CHECK( "Problem add parent in gentityset_test." );
00748 
00749     // check if parent is really added
00750     SimpleArray< iBase_EntitySetHandle > parents;
00751     FBiGeom_getPrnts( geom, parent_child, 1, ARRAY_INOUT( parents ), &err );
00752     CHECK( "Problem getting parents in gentityset_test." );
00753 
00754     if( parents.size() != 1 )
00755     {
00756         std::cerr << "number of parents is not correct in gentityset_test." << std::endl;
00757         return false;
00758     }
00759 
00760     // add parent and child
00761     // sidl::array<void*> parent_child_array = sidl::array<void*>::create1d(1);
00762     // int num_parent_child_array;
00763     // sidl::array<void*> temp_gedge_array = sidl::array<void*>::create1d(1);
00764     // int num_temp_gedge_array;
00765     // parent_child_array.set(0, parent_child);
00766     // temp_gedge_array.set(0, ges_array[TSTTG::EntityType_EDGE]);
00767     FBiGeom_addPrntChld( geom, ges_array[iBase_EDGE], parent_child, &err );
00768     CHECK( "Problem adding parent and child in gentityset_test." );
00769 
00770     // sidl::array<void*> temp_gface_array = sidl::array<void*>::create1d(1);
00771     // int num_temp_gface_array;
00772     // temp_gface_array.set(0, ges_array[TSTTG::EntityType_FACE]);
00773     FBiGeom_addPrntChld( geom, parent_child, ges_array[iBase_FACE], &err );
00774     CHECK( "Problem adding parent and child in gentityset_test." );
00775 
00776     // add child
00777     FBiGeom_addPrntChld( geom, parent_child, ges_array[iBase_REGION], &err );
00778     CHECK( "Problem adding child in gentityset_test." );
00779 
00780     // get the number of parent gentitysets
00781     num_gents = -1;
00782     FBiGeom_getNumPrnt( geom, parent_child, 1, &num_gents, &err );
00783     CHECK( "Problem getting number of parents in gentityset_test." );
00784 
00785     if( num_gents != 2 )
00786     {
00787         std::cerr << "number of parents is not correct in gentityset_test." << std::endl;
00788         return false;
00789     }
00790 
00791     // get the number of child gentitysets
00792     num_gents = -1;
00793     FBiGeom_getNumChld( geom, parent_child, 1, &num_gents, &err );
00794     CHECK( "Problem getting number of children in gentityset_test." );
00795 
00796     if( num_gents != 2 )
00797     {
00798         std::cerr << "number of children is not correct in gentityset_test." << std::endl;
00799         return false;
00800     }
00801 
00802     SimpleArray< iBase_EntitySetHandle > children;
00803     FBiGeom_getChldn( geom, parent_child, 1, ARRAY_INOUT( children ), &err );
00804     CHECK( "Problem getting children in gentityset_test." );
00805 
00806     if( children.size() != 2 )
00807     {
00808         std::cerr << "number of children is not correct in gentityset_test." << std::endl;
00809         return false;
00810     }
00811 
00812     // remove children
00813     FBiGeom_rmvPrntChld( geom, parent_child, ges_array[iBase_FACE], &err );
00814     CHECK( "Problem removing parent child in gentityset_test." );
00815 
00816     // get the number of child gentitysets
00817     FBiGeom_getNumChld( geom, parent_child, 1, &num_gents, &err );
00818     CHECK( "Problem getting number of children in gentityset_test." );
00819 
00820     if( num_gents != 1 )
00821     {
00822         std::cerr << "number of children is not correct in gentityset_test." << std::endl;
00823         return false;
00824     }
00825 
00826     // parent_child and ges_array[TSTTG::EntityType_EDGE] should be related
00827     int result = 0;
00828     FBiGeom_isChildOf( geom, ges_array[iBase_EDGE], parent_child, &result, &err );
00829     CHECK( "Problem checking relation in gentityset_test." );
00830     if( !result )
00831     {
00832         std::cerr << "parent_child and ges_array[TSTTG::EntityType_EDGE] should be related" << std::endl;
00833         return false;
00834     }
00835 
00836     // ges_array[TSTTG::EntityType_FACE] and ges_array[TSTTG::REGION] are not related
00837     result = 2;
00838     FBiGeom_isChildOf( geom, ges_array[iBase_FACE], ges_array[iBase_REGION], &result, &err );
00839     if( result )
00840     {
00841         std::cerr << "ges_array[TSTTG::REGION] and ges_array[TSTTG::EntityType_FACE] should not be "
00842                      "related"
00843                   << std::endl;
00844         return false;
00845     }
00846 
00847     //--------test modify and query functions-----------------------------
00848 
00849     // check the number of gentity sets in whole mesh
00850     SimpleArray< iBase_EntitySetHandle > gentity_sets;
00851     FBiGeom_getEntSets( geom, root_set, 1, ARRAY_INOUT( gentity_sets ), &err );
00852     CHECK( "Problem to get all gentity sets in mesh." );
00853 
00854     if( gentity_sets.size() != all_sets + 8 )
00855     {
00856         std::cerr << "the number of gentity sets in whole mesh should be 8 times of num_iter." << std::endl;
00857         return false;
00858     }
00859 
00860     // get all gentity sets in super set
00861     SimpleArray< iBase_EntitySetHandle > ges_array1;
00862     FBiGeom_getEntSets( geom, super_set, 1, ARRAY_INOUT( ges_array1 ), &err );
00863     CHECK( "Problem to get gentity sets in super set." );
00864 
00865     // get the number of gentity sets in super set
00866     int num_super;
00867     FBiGeom_getNumEntSets( geom, super_set, 1, &num_super, &err );
00868     CHECK( "Problem to get the number of all gentity sets in super set." );
00869 
00870     // the number of gentity sets in super set should be same
00871     if( num_super != ges_array1.size() )
00872     {
00873         std::cerr << "the number of gentity sets in super set should be same." << std::endl;
00874         return false;
00875     }
00876 
00877     // get all entities in super set
00878     SimpleArray< iBase_EntitySetHandle > all_gentities;
00879     FBiGeom_getEntSets( geom, super_set, 1, ARRAY_INOUT( all_gentities ), &err );
00880     CHECK( "Problem to get all gentities in super set." );
00881 
00882     // compare the number of all gentities in super set
00883     // HJK : num_hops is not implemented
00884     // if (num_all_gentities_super != ARRAY_SIZE(all_gentities)) {
00885     // std::cerr << "number of all gentities in super set should be same." << std::endl;
00886     // success = false;
00887     //}
00888 
00889     // test add, remove and get all entitiy sets using super set
00890     // check GetAllGentitysets works recursively and dosen't return
00891     // multi sets
00892     for( int k = 0; k < num_super; k++ )
00893     {
00894         // add gentity sets of super set to each gentity set of super set
00895         // make multiple child super sets
00896         iBase_EntitySetHandle ges_k = ges_array1[k];
00897 
00898         for( int a = 0; a < ges_array1.size(); a++ )
00899         {
00900             FBiGeom_addEntSet( geom, ges_array1[a], ges_k, &err );
00901             CHECK( "Problem to add entity set." );
00902         }
00903 
00904         // add super set to each entity set
00905         //    sidl::array<GentitysetHandle> superset_array
00906         //= sidl::array<GentitysetHandle>::create1d(1);
00907         // superset_array.set(0, super_set);
00908         // int num_superset_array;
00909 
00910         FBiGeom_addEntSet( geom, super_set, ges_k, &err );
00911         CHECK( "Problem to add super set to gentitysets." );
00912 
00913         // add one gentity sets multiple times
00914         // HJK: ??? how to deal this case?
00915         // sidl::array<GentitysetHandle> temp_array1
00916         //= sidl::array<GentitysetHandle>::create1d(1);
00917         // int num_temp_array1;
00918         // temp_array1.set(0, temp_ges1);
00919 
00920         // for (int l = 0; l < 3; l++) {
00921         FBiGeom_addEntSet( geom, temp_ges1, ges_k, &err );
00922         CHECK( "Problem to add temp set to gentitysets." );
00923         //}
00924     }
00925 
00926     return true;
00927 }
00928 
00929 /*!
00930  @test
00931  TSTTG topology adjacencies Test
00932  @li Check topology information
00933  @li Check adjacency
00934  */
00935 // make each topological entity vectors, check their topology
00936 // types, get interior and exterior faces of model
00937 bool topology_adjacencies_test( FBiGeom_Instance geom )
00938 {
00939     int i, err;
00940     iBase_EntitySetHandle root_set;
00941     FBiGeom_getRootSet( geom, &root_set, &err );
00942     CHECK( "ERROR : getRootSet failed!" );
00943 
00944     int top          = iBase_VERTEX;
00945     int num_test_top = iBase_ALL_TYPES;
00946     std::vector< std::vector< iBase_EntityHandle > > gentity_vectors( num_test_top );
00947 
00948     // fill the vectors of each topology entities
00949     // like lines vector, polygon vector, triangle vector,
00950     // quadrilateral, polyhedrron, tet, hex, prism, pyramid,
00951     // septahedron vectors
00952     for( i = top; i < num_test_top; i++ )
00953     {
00954         SimpleArray< iBase_EntityHandle > gentities;
00955         FBiGeom_getEntities( geom, root_set, i, ARRAY_INOUT( gentities ), &err );
00956         CHECK( "Failed to get gentities in adjacencies_test." );
00957 
00958         gentity_vectors[i].resize( gentities.size() );
00959         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
00960     }
00961 
00962     // check number of entities for each topology
00963     for( i = top; i < num_test_top; i++ )
00964     {
00965         int num_tops = 0;
00966         FBiGeom_getNumOfType( geom, root_set, i, &num_tops, &err );
00967         CHECK( "Failed to get number of gentities in adjacencies_test." );
00968 
00969         if( static_cast< int >( gentity_vectors[i].size() ) != num_tops )
00970         {
00971             std::cerr << "Number of gentities doesn't agree with number returned for dimension " << i << std::endl;
00972             return false;
00973         }
00974     }
00975 
00976     // check adjacencies in both directions
00977     std::vector< iBase_EntityHandle >::iterator vit;
00978     for( i = iBase_REGION; i >= iBase_VERTEX; i-- )
00979     {
00980         for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
00981         {
00982             iBase_EntityHandle this_gent = *vit;
00983 
00984             // check downward adjacencies
00985             for( int j = iBase_VERTEX; j < i; j++ )
00986             {
00987 
00988                 SimpleArray< iBase_EntityHandle > lower_ents;
00989                 FBiGeom_getEntAdj( geom, this_gent, j, ARRAY_INOUT( lower_ents ), &err );
00990                 CHECK( "Bi-directional adjacencies test failed." );
00991 
00992                 // for each of them, make sure they are adjacent to the upward ones
00993                 int num_lower = lower_ents.size();
00994                 for( int k = 0; k < num_lower; k++ )
00995                 {
00996                     SimpleArray< iBase_EntityHandle > upper_ents;
00997                     FBiGeom_getEntAdj( geom, lower_ents[k], i, ARRAY_INOUT( upper_ents ), &err );
00998                     CHECK( "Bi-directional adjacencies test failed." );
00999                     if( std::find( upper_ents.begin(), upper_ents.end(), this_gent ) == upper_ents.end() )
01000                     {
01001                         std::cerr << "Didn't find lower-upper adjacency which was supposed to be "
01002                                      "there, dims = "
01003                                   << i << ", " << j << std::endl;
01004                         return false;
01005                     }
01006                 }
01007             }
01008         }
01009     }
01010 
01011     return true;
01012 }
01013 
01014 /*!
01015  @test
01016  FBiGeom_MOAB topology adjacencies Test
01017  @li Check topology information
01018  @li Check adjacency
01019  */
01020 // make each topological entity vectors, check their topology
01021 // types, get interior and exterior faces of model
01022 bool geometry_evaluation_test( FBiGeom_Instance geom )
01023 {
01024     int i, err;
01025     iBase_EntitySetHandle root_set;
01026     FBiGeom_getRootSet( geom, &root_set, &err );
01027     CHECK( "ERROR : getRootSet failed!" );
01028 
01029     int top          = iBase_VERTEX;
01030     int num_test_top = iBase_ALL_TYPES;
01031     std::vector< std::vector< iBase_EntityHandle > > gentity_vectors( num_test_top );
01032 
01033     // fill the vectors of each topology entities
01034     // like lines vector, polygon vector, triangle vector,
01035     // quadrilateral, polyhedrron, tet, hex, prism, pyramid,
01036     // septahedron vectors
01037     for( i = top; i < num_test_top; i++ )
01038     {
01039         SimpleArray< iBase_EntityHandle > gentities;
01040         FBiGeom_getEntities( geom, root_set, i, ARRAY_INOUT( gentities ), &err );
01041         CHECK( "Failed to get gentities in adjacencies_test." );
01042 
01043         gentity_vectors[i].resize( gentities.size() );
01044         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
01045     }
01046 
01047     // check adjacencies in both directions
01048     double min[3], max[3], on[3];
01049     double near[3] = { .0, .0, .0 };
01050     std::vector< iBase_EntityHandle >::iterator vit;
01051     for( i = iBase_REGION; i >= iBase_VERTEX; i-- )
01052     {
01053         if( i != iBase_EDGE )
01054         {
01055             for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
01056             {
01057                 iBase_EntityHandle this_gent = *vit;
01058                 FBiGeom_getEntBoundBox( geom, this_gent, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2], &err );
01059                 CHECK( "Failed to get bounding box of entity." );
01060 
01061                 for( int j = 0; j < 3; j++ )
01062                     near[j] = ( min[j] + max[j] ) / 2;
01063                 FBiGeom_getEntClosestPt( geom, this_gent, near[0], near[1], near[2], &on[0], &on[1], &on[2], &err );
01064                 CHECK( "Failed to get closest point on entity." );
01065                 std::cout << " entity of type " << i << " closest point to \n  " << near[0] << " " << near[1] << " "
01066                           << near[2] << "\n  is " << on[0] << " " << on[1] << " " << on[2] << "\n";
01067             }
01068         }
01069     }
01070 
01071     return true;
01072 }
01073 //
01074 //  test normals evaluations on the surface only
01075 bool normals_test( FBiGeom_Instance geom )
01076 {
01077     int i, err;
01078     iBase_EntitySetHandle root_set;
01079     FBiGeom_getRootSet( geom, &root_set, &err );
01080     CHECK( "ERROR : getRootSet failed!" );
01081 
01082     int top          = iBase_VERTEX;
01083     int num_test_top = iBase_ALL_TYPES;
01084     std::vector< std::vector< iBase_EntityHandle > > gentity_vectors( num_test_top );
01085 
01086     // fill the vectors of each topology entities
01087     // like lines vector, polygon vector, triangle vector,
01088     // quadrilateral, polyhedrron, tet, hex, prism, pyramid,
01089     // septahedron vectors
01090     for( i = top; i < num_test_top; i++ )
01091     {
01092         SimpleArray< iBase_EntityHandle > gentities;
01093         FBiGeom_getEntities( geom, root_set, i, ARRAY_INOUT( gentities ), &err );
01094         CHECK( "Failed to get gentities in adjacencies_test." );
01095 
01096         gentity_vectors[i].resize( gentities.size() );
01097         std::copy( gentities.begin(), gentities.end(), gentity_vectors[i].begin() );
01098     }
01099 
01100     // check adjacencies in both directions
01101     double min[3], max[3];
01102     double normal[3] = { .0, .0, .0 };
01103     std::vector< iBase_EntityHandle >::iterator vit;
01104     for( i = iBase_REGION; i > iBase_EDGE; i-- )
01105     {
01106         for( vit = gentity_vectors[i].begin(); vit != gentity_vectors[i].end(); ++vit )
01107         {
01108             iBase_EntityHandle this_gent = *vit;
01109             FBiGeom_getEntBoundBox( geom, this_gent, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2], &err );
01110             CHECK( "Failed to get bounding box of entity." );
01111 
01112             FBiGeom_getEntNrmlXYZ( geom, this_gent, ( max[0] + min[0] ) / 2, ( max[1] + min[1] ) / 2,
01113                                    ( max[2] + min[2] ) / 2, &normal[0], &normal[1], &normal[2], &err );
01114 
01115             CHECK( "Failed to get normal to the closest point." );
01116             std::cout << " entity of type " << i << " closest normal to center:\n  " << normal[0] << " " << normal[1]
01117                       << " " << normal[2] << "\n";
01118         }
01119     }
01120 
01121     return true;
01122 }
01123 
01124 //  test normals evaluations on the surface only
01125 bool ray_test( FBiGeom_Instance geom )
01126 {
01127     int err;
01128     iBase_EntitySetHandle root_set;
01129     FBiGeom_getRootSet( geom, &root_set, &err );
01130     CHECK( "ERROR : getRootSet failed!" );
01131 
01132     int top = iBase_FACE;
01133 
01134     SimpleArray< iBase_EntityHandle > faces;
01135     FBiGeom_getEntities( geom, root_set, top, ARRAY_INOUT( faces ), &err );
01136     CHECK( "Failed to get gentities in adjacencies_test." );
01137 
01138     // check only the first face
01139 
01140     // check adjacencies in both directions
01141     double min[3], max[3];
01142 
01143     iBase_EntityHandle first_face = faces[0];
01144 
01145     FBiGeom_getEntBoundBox( geom, first_face, &min[0], &min[1], &min[2], &max[0], &max[1], &max[2], &err );
01146     CHECK( "Failed to get bounding box of entity." );
01147 
01148     // assume that the ray shot from the bottom of the box (middle) is a pretty good candidate
01149     // in z direction
01150     double x = ( min[0] + max[0] ) / 2, y = ( min[1] + max[1] ) / 2, z = min[2];
01151     SimpleArray< iBase_EntityHandle > intersect_entity_handles;
01152     SimpleArray< double > intersect_coords;
01153     SimpleArray< double > param_coords;
01154     FBiGeom_getPntRayIntsct( geom, x, y, z,  // shot from
01155                              0., 0., 1.,     // direction
01156                              ARRAY_INOUT( intersect_entity_handles ), iBase_INTERLEAVED,
01157                              ARRAY_INOUT( intersect_coords ), ARRAY_INOUT( param_coords ), &err );
01158 
01159     CHECK( "Failed to find ray intersections points " );
01160     for( int i = 0; i < intersect_entity_handles.size(); i++ )
01161     {
01162         int j;
01163         FBiGeom_getEntType( geom, intersect_entity_handles[i], &j, &err );
01164         CHECK( "Failed to get type of entity." );
01165 
01166         std::cout << " entity of type " << j << " n: " << intersect_entity_handles[i] << "\n"
01167                   << intersect_coords[3 * i] << " " << intersect_coords[3 * i + 1] << " " << intersect_coords[3 * i + 2]
01168                   << "\n"
01169                   << " distance: " << param_coords[i] << "\n";
01170     }
01171 
01172     return true;
01173 }
01174 
01175 /*!
01176  @test
01177  TSTTG construct Test
01178  @li Check construction of geometry
01179  */
01180 bool construct_test( FBiGeom_Instance geom )
01181 {
01182     int err;
01183     iBase_EntityHandle new_body = 0;
01184 
01185     // construct a cylinder, sweep it about an axis, and delete the result
01186     iBase_EntityHandle cyl = 0;
01187     FBiGeom_createCylinder( geom, 1.0, 1.0, 0.0, &cyl, &err );
01188     // Is the minor radius really supposed to be zero??? - JK
01189     CHECK( "Creating cylinder failed." );
01190 
01191     // move it onto the y axis
01192     FBiGeom_moveEnt( geom, cyl, 0.0, 1.0, -0.5, &err );
01193     CHECK( "Problems moving surface." );
01194 
01195     // get the surface with max z
01196     iBase_EntityHandle max_surf = 0;
01197     SimpleArray< iBase_EntityHandle > surfs;
01198     FBiGeom_getEntAdj( geom, cyl, iBase_FACE, ARRAY_INOUT( surfs ), &err );
01199     CHECK( "Problems getting max surf for rotation." );
01200 
01201     SimpleArray< double > max_corn, min_corn;
01202     FBiGeom_getArrBoundBox( geom, ARRAY_IN( surfs ), iBase_INTERLEAVED, ARRAY_INOUT( min_corn ),
01203                             ARRAY_INOUT( max_corn ), &err );
01204     CHECK( "Problems getting max surf for rotation." );
01205     double dtol = 1.0e-6;
01206     for( int i = 0; i < surfs.size(); ++i )
01207     {
01208         if( ( max_corn[3 * i + 2] ) <= dtol && ( max_corn[3 * i + 2] ) >= -dtol && ( min_corn[3 * i + 2] ) <= dtol &&
01209             ( min_corn[3 * i + 2] ) >= -dtol )
01210         {
01211             max_surf = surfs[i];
01212             break;
01213         }
01214     }
01215 
01216     if( 0 == max_surf )
01217     {
01218         std::cerr << "Couldn't find max surf for rotation." << std::endl;
01219         return false;
01220     }
01221 
01222     // sweep it around the x axis
01223     FBiGeom_moveEnt( geom, cyl, 0.0, 1.0, 0.0, &err );
01224     CHECK( "Problems moving surface." );
01225 
01226     FBiGeom_sweepEntAboutAxis( geom, max_surf, 360.0, 1.0, 0.0, 0.0, &new_body, &err );
01227     CHECK( "Problems sweeping surface about axis." );
01228 
01229     // now delete
01230     FBiGeom_deleteEnt( geom, new_body, &err );
01231     CHECK( "Problems deleting cylinder or swept surface body." );
01232 
01233     // if we got here, we were successful
01234     return true;
01235 }
01236 
01237 static bool compare_box( const double* expected_min, const double* expected_max, const double* actual_min,
01238                          const double* actual_max )
01239 {
01240     bool same   = true;
01241     double dtol = 1.0e-6;
01242 
01243     for( int i = 0; i < 3; ++i )
01244     {
01245         if( expected_min[i] < actual_min[i] - dtol || expected_min[i] * 10 > actual_min[i] ||
01246             expected_max[i] > actual_max[i] + dtol || expected_max[i] * 10 < actual_max[i] )
01247             same = false;
01248     }
01249     return same;
01250 }
01251 
01252 bool primitives_test( FBiGeom_Instance geom )
01253 {
01254     int err;
01255     SimpleArray< iBase_EntityHandle > prims( 3 );
01256     iBase_EntityHandle prim;
01257 
01258     FBiGeom_createBrick( geom, 1.0, 2.0, 3.0, &prim, &err );
01259     CHECK( "createBrick failed." );
01260     prims[0] = prim;
01261 
01262     FBiGeom_createCylinder( geom, 1.0, 4.0, 2.0, &prim, &err );
01263     CHECK( "createCylinder failed." );
01264     prims[1] = prim;
01265 
01266     FBiGeom_createTorus( geom, 2.0, 1.0, &prim, &err );
01267     CHECK( "createTorus failed." );
01268     prims[2] = prim;
01269 
01270     // verify the bounding boxes for Acis based entities
01271     SimpleArray< double > max_corn, min_corn;
01272     FBiGeom_getArrBoundBox( geom, ARRAY_IN( prims ), iBase_INTERLEAVED, ARRAY_INOUT( min_corn ),
01273                             ARRAY_INOUT( max_corn ), &err );
01274 
01275     double preset_min_corn[] =
01276         // min brick corner xyz
01277         { -0.5, -1.0, -1.5,
01278           // min cyl corner xyz
01279           -4.0, -2.0, -0.5,
01280           // min torus corner xyz
01281           -3.0, -3.0, -1.0 };
01282 
01283     double preset_max_corn[] =
01284         // max brick corner xyz
01285         { 0.5, 1.0, 1.5,
01286           // max cyl corner xyz
01287           4.0, 2.0, 0.5,
01288           // max torus corner xyz
01289           3.0, 3.0, 1.0 };
01290 
01291     if( !compare_box( preset_min_corn, preset_max_corn, &min_corn[0], &max_corn[0] ) )
01292     {
01293         std::cerr << "Box check failed for brick" << std::endl;
01294         return false;
01295     }
01296 
01297     if( !compare_box( preset_min_corn + 3, preset_max_corn + 3, &min_corn[3], &max_corn[3] ) )
01298     {
01299         std::cerr << "Box check failed for cylinder" << std::endl;
01300         return false;
01301     }
01302 
01303     if( !compare_box( preset_min_corn + 6, preset_max_corn + 6, &min_corn[6], &max_corn[6] ) )
01304     {
01305         std::cerr << "Box check failed for torus" << std::endl;
01306         return false;
01307     }
01308     // must have worked; delete the entities then return
01309     for( int i = 0; i < 3; ++i )
01310     {
01311         FBiGeom_deleteEnt( geom, prims[i], &err );
01312         CHECK( "Problems deleting primitive after boolean check." );
01313     }
01314 
01315     return true;
01316 }
01317 
01318 bool transforms_test( FBiGeom_Instance geom )
01319 {
01320     int err;
01321 
01322     // construct a brick
01323     iBase_EntityHandle brick = 0;
01324     FBiGeom_createBrick( geom, 1.0, 2.0, 3.0, &brick, &err );
01325     CHECK( "Problems creating brick for transforms test." );
01326 
01327     // move it, then test bounding box
01328     FBiGeom_moveEnt( geom, brick, 0.5, 1.0, 1.5, &err );
01329     CHECK( "Problems moving brick for transforms test." );
01330 
01331     double bb_min[3], bb_max[3];
01332     FBiGeom_getEntBoundBox( geom, brick, bb_min, bb_min + 1, bb_min + 2, bb_max, bb_max + 1, bb_max + 2, &err );
01333     CHECK( "Problems getting bounding box after move." );
01334 
01335     double dtol = 1.0e-6;
01336     if( ( bb_min[0] ) >= dtol || ( bb_min[0] ) <= -dtol || ( bb_min[1] ) >= dtol || ( bb_min[1] ) <= -dtol ||
01337         ( bb_min[2] ) >= dtol || ( bb_min[2] ) <= -dtol || ( bb_max[0] - 1 ) >= dtol || 1 - bb_max[0] >= dtol ||
01338         ( bb_max[1] - 2 ) >= dtol || 2 - bb_max[1] >= dtol || ( bb_max[2] - 3 ) >= dtol || 3 - bb_max[2] >= dtol )
01339     {
01340         std::cerr << "Wrong bounding box after move." << std::endl;
01341         return false;
01342     }
01343 
01344     // now rotate it about +x, then test bounding box
01345     FBiGeom_rotateEnt( geom, brick, 90, 1.0, 0.0, 0.0, &err );
01346     CHECK( "Problems rotating brick for transforms test." );
01347 
01348     FBiGeom_getEntBoundBox( geom, brick, bb_min, bb_min + 1, bb_min + 2, bb_max, bb_max + 1, bb_max + 2, &err );
01349     CHECK( "Problems getting bounding box after rotate." );
01350 
01351     if( ( bb_min[0] ) >= dtol || -bb_min[0] >= dtol || ( bb_min[1] + 3 ) >= dtol || -( bb_min[1] + 3 ) >= dtol ||
01352         ( bb_min[2] ) >= dtol || -( bb_min[2] ) >= dtol || ( bb_max[0] - 1 ) >= dtol || 1 - bb_max[0] >= dtol ||
01353         ( bb_max[1] ) >= dtol || -( bb_max[1] ) >= dtol || ( bb_max[2] - 2 ) >= dtol || 2 - bb_max[2] >= dtol )
01354     {
01355         std::cerr << "Wrong bounding box after rotate." << std::endl;
01356         return false;
01357     }
01358 
01359     // now reflect through y plane; should recover original bb
01360     FBiGeom_reflectEnt( geom, brick, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, &err );
01361     CHECK( "Problems reflecting brick for transforms test." );
01362 
01363     FBiGeom_getEntBoundBox( geom, brick, bb_min, bb_min + 1, bb_min + 2, bb_max, bb_max + 1, bb_max + 2, &err );
01364     CHECK( "Problems getting bounding box after reflect." );
01365 
01366     if( ( bb_min[0] ) >= dtol || -( bb_min[0] ) >= dtol || ( bb_min[1] ) >= dtol || ( bb_min[2] ) >= dtol ||
01367         -( bb_min[1] ) >= dtol || -( bb_min[2] ) >= dtol || ( bb_max[0] - 1 ) >= dtol || 1 - bb_max[0] >= dtol ||
01368         ( bb_max[1] - 3 ) >= dtol || 3 - bb_max[1] >= dtol || ( bb_max[2] - 2 ) >= dtol || 2 - bb_max[2] >= dtol )
01369     {
01370         std::cerr << "Wrong bounding box after reflect." << std::endl;
01371         return false;
01372     }
01373 
01374     // must have worked; delete the entities then return
01375     FBiGeom_deleteEnt( geom, brick, &err );
01376     CHECK( "Problems deleting brick after transforms check." );
01377     return true;
01378 }
01379 
01380 bool booleans_test( FBiGeom_Instance geom )
01381 {
01382     int err;
01383 
01384     // construct a brick size 1, and a cylinder rad 0.25 height 2
01385     iBase_EntityHandle brick = 0, cyl = 0;
01386     FBiGeom_createBrick( geom, 1.0, 0.0, 0.0, &brick, &err );
01387     CHECK( "Problems creating brick for booleans test." );
01388     FBiGeom_createCylinder( geom, 1.0, 0.25, 0.0, &cyl, &err );
01389     CHECK( "Problems creating cylinder for booleans test." );
01390 
01391     // subtract the cylinder from the brick
01392     iBase_EntityHandle subtract_result = 0;
01393     FBiGeom_subtractEnts( geom, brick, cyl, &subtract_result, &err );
01394     CHECK( "Problems subtracting for booleans subtract test." );
01395 
01396     // section the brick
01397     iBase_EntityHandle section_result = 0;
01398     FBiGeom_sectionEnt( geom, subtract_result, 1.0, 0.0, 0.0, 0.25, true, &section_result, &err );
01399     CHECK( "Problems sectioning for booleans section test." );
01400 
01401     // unite the section result with a new cylinder
01402     FBiGeom_createCylinder( geom, 1.0, 0.25, 0.0, &cyl, &err );
01403     CHECK( "Problems creating cylinder for unite test." );
01404     iBase_EntityHandle unite_results;
01405     iBase_EntityHandle unite_input[] = { section_result, cyl };
01406     FBiGeom_uniteEnts( geom, unite_input, 2, &unite_results, &err );
01407     CHECK( "Problems uniting for booleans unite test." );
01408 
01409     FBiGeom_deleteEnt( geom, unite_results, &err );
01410     CHECK( "Problems deleting for booleans unite test." );
01411     return true;
01412 }
01413 
01414 static int get_entities( FBiGeom_Instance geom, int entity_type, std::vector< iBase_EntityHandle >& entities_out,
01415                          iBase_TagHandle id_tag = 0, std::vector< int >* ids_out = 0 )
01416 {
01417     int err, num;
01418     iBase_EntitySetHandle root;
01419     FBiGeom_getRootSet( geom, &root, &err );
01420     if( iBase_SUCCESS != err ) return err;
01421     FBiGeom_getNumOfType( geom, root, entity_type, &num, &err );
01422     if( iBase_SUCCESS != err ) return err;
01423 
01424     entities_out.resize( num );
01425     int junk1                    = entities_out.size(), junk2;
01426     iBase_EntityHandle* junk_ptr = &entities_out[0];
01427     ;
01428     FBiGeom_getEntities( geom, root, entity_type, &junk_ptr, &junk1, &junk2, &err );
01429     if( iBase_SUCCESS != err ) return err;
01430     assert( num == junk1 && num == junk2 );
01431 
01432     if( !ids_out ) return iBase_SUCCESS;
01433 
01434     ids_out->resize( num );
01435     int* int_ptr = &( *ids_out )[0];
01436     FBiGeom_getIntArrData( geom, &entities_out[0], num, id_tag, &int_ptr, &junk1, &junk2, &err );
01437     if( iBase_SUCCESS != err ) return err;
01438     assert( num == junk1 && num == junk2 );
01439 
01440     return iBase_SUCCESS;
01441 }
01442 
01443 static int check_firmness( FBiGeom_Instance geom, const std::vector< iBase_EntityHandle >& entities,
01444                            const std::vector< int >& ids, iBase_TagHandle firmness_tag, const char* expected_value,
01445                            const char* ent_type_str )
01446 {
01447     const int firmness_size = 4;
01448     std::vector< char > firmness( firmness_size * entities.size() );
01449 
01450     char* byte_ptr = &firmness[0];
01451     int err, junk1 = firmness.size(), junk2 = entities.size() * firmness_size;
01452     FBiGeom_getArrData( geom, &entities[0], entities.size(), firmness_tag, (void**)&byte_ptr, &junk1, &junk2, &err );
01453     if( iBase_SUCCESS != err ) return err;
01454 
01455     bool all_correct = true;
01456     for( unsigned i = 0; i < entities.size(); ++i )
01457         if( std::string( &firmness[firmness_size * i], firmness_size ) != expected_value ) all_correct = false;
01458     if( !all_correct )
01459     {
01460         std::cout << "ERROR: Expected \"" << expected_value << "\" firmness "
01461                   << "for all " << ent_type_str << "." << std::endl;
01462         std::cout << "ID  Actual  " << std::endl;
01463         for( unsigned i = 0; i < entities.size(); ++i )
01464             std::cout << std::setw( 2 ) << ids[i] << "  " << std::string( &firmness[firmness_size * i], firmness_size )
01465                       << std::endl;
01466         return iBase_FAILURE;
01467     }
01468 
01469     return iBase_SUCCESS;
01470 }
01471 
01472 static int count_num_with_tag( FBiGeom_Instance geom, const std::vector< iBase_EntityHandle >& ents,
01473                                iBase_TagHandle tag )
01474 {
01475     int err, bytes;
01476     FBiGeom_getTagSizeBytes( geom, tag, &bytes, &err );
01477     if( iBase_SUCCESS != err ) return -1;
01478     std::vector< char > data( bytes );
01479 
01480     int success_count = 0;
01481     for( size_t i = 0; i < ents.size(); ++i )
01482     {
01483         char* ptr = &data[0];
01484         int junk1 = bytes, junk2;
01485         FBiGeom_getData( geom, ents[i], tag, (void**)&ptr, &junk1, &junk2, &err );
01486         if( iBase_TAG_NOT_FOUND == err ) continue;
01487         if( iBase_SUCCESS != err ) return -1;
01488         ++success_count;
01489     }
01490 
01491     return success_count;
01492 }
01493 
01494 bool mesh_size_test( FBiGeom_Instance geom )
01495 {
01496     const char* filename = STRINGIFY( SRCDIR ) "/size.sat";
01497     int err, junk1, junk2;
01498     bool result = true;
01499 
01500     FBiGeom_deleteAll( geom, &err );
01501     CHECK( "" );
01502     FBiGeom_load( geom, filename, 0, &err, strlen( filename ), 0 );
01503     CHECK( "Failed to load input file: 'size.sat'" );
01504 
01505     // get tag handles
01506     iBase_TagHandle interval, size, firmness, id;
01507     FBiGeom_getTagHandle( geom, "MESH_INTERVAL", &interval, &err, strlen( "MESH_INTERVAL" ) );
01508     CHECK( "FBiGeom_getTagHandle(\"MESH_INTERVAL\")" );
01509     FBiGeom_getTagHandle( geom, "MESH_SIZE", &size, &err, strlen( "MESH_SIZE" ) );
01510     CHECK( "FBiGeom_getTagHandle(\"MESH_SIZE\")" );
01511     FBiGeom_getTagHandle( geom, "SIZE_FIRMNESS", &firmness, &err, strlen( "SIZE_FIRMNESS" ) );
01512     CHECK( "FBiGeom_getTagHandle(\"SIZE_FIRMNESS\")" );
01513     FBiGeom_getTagHandle( geom, "GLOBAL_ID", &id, &err, strlen( "GLOBAL_ID" ) );
01514     CHECK( "FBiGeom_getTagHandle(\"GLOBAL_ID\")" );
01515 
01516     // get entity lists
01517     std::vector< iBase_EntityHandle > verts, curves, surfs, vols;
01518     std::vector< int > vert_ids, curve_ids, surf_ids, vol_ids;
01519     err = get_entities( geom, iBase_VERTEX, verts, id, &vert_ids );
01520     CHECK( "" );
01521     err = get_entities( geom, iBase_EDGE, curves, id, &curve_ids );
01522     CHECK( "" );
01523     err = get_entities( geom, iBase_FACE, surfs, id, &surf_ids );
01524     CHECK( "" );
01525     err = get_entities( geom, iBase_REGION, vols, id, &vol_ids );
01526     CHECK( "" );
01527 
01528     // expect interval count to be the same as ID for every curve
01529     std::vector< int > intervals( curves.size() );
01530     int* int_ptr = &intervals[0];
01531     junk1 = junk2 = curves.size();
01532     FBiGeom_getIntArrData( geom, &curves[0], curves.size(), interval, &int_ptr, &junk1, &junk2, &err );
01533     CHECK( "Failed to get intervals for curves" );
01534     if( intervals != curve_ids )
01535     {
01536         std::cout << "ERROR: Incorrect curve intervals for one or more curves." << std::endl;
01537         std::cout << "ID  Expected  Actual" << std::endl;
01538         for( unsigned i = 0; i < curves.size(); ++i )
01539             std::cout << std::setw( 2 ) << curve_ids[i] << "  " << std::setw( 8 ) << curve_ids[i] << "  "
01540                       << std::setw( 6 ) << intervals[i] << std::endl;
01541         result = false;
01542     }
01543 
01544     // expect size to be the same as ID for every surface
01545     std::vector< double > sizes( surfs.size() );
01546     double* dbl_ptr = &sizes[0];
01547     junk1 = junk2 = surfs.size();
01548     FBiGeom_getDblArrData( geom, &surfs[0], surfs.size(), size, &dbl_ptr, &junk1, &junk2, &err );
01549     CHECK( "Failed to get sizes for surfaces" );
01550     bool all_correct = true;
01551     for( unsigned i = 0; i < surfs.size(); ++i )
01552         if( fabs( sizes[i] - (double)surf_ids[i] ) > 1e-8 ) all_correct = false;
01553     if( !all_correct )
01554     {
01555         std::cout << "ERROR: Incorrect mesh size for one or more surfaces." << std::endl;
01556         std::cout << "ID  Expected  Actual  " << std::endl;
01557         for( unsigned i = 0; i < surfs.size(); ++i )
01558             std::cout << std::setw( 2 ) << surf_ids[i] << "  " << std::setw( 8 ) << (double)surf_ids[i] << "  "
01559                       << std::setw( 8 ) << sizes[i] << std::endl;
01560         result = false;
01561     }
01562 
01563     err = result ? iBase_SUCCESS : iBase_FAILURE;
01564     CHECK( "Invalid size or interval data" );
01565 
01566     // expect "HARD" firmness on all curves
01567     err = check_firmness( geom, curves, curve_ids, firmness, "HARD", "curves" );
01568     CHECK( "Invalid curve firmness" );
01569     // expect "SOFT" firmness on all surfaces
01570     err = check_firmness( geom, surfs, surf_ids, firmness, "SOFT", "surfaces" );
01571     CHECK( "Invalid surface firmness" );
01572 
01573     // expect no firmnes on other entities
01574     err = count_num_with_tag( geom, verts, firmness ) ? iBase_FAILURE : iBase_SUCCESS;
01575     CHECK( "Got firmness for vertex." );
01576     err = count_num_with_tag( geom, vols, firmness ) ? iBase_FAILURE : iBase_SUCCESS;
01577     CHECK( "Got firmness for volume." );
01578 
01579     // expect no interval tag on any entities except curves
01580     err = count_num_with_tag( geom, verts, interval ) ? iBase_FAILURE : iBase_SUCCESS;
01581     CHECK( "Got interval count for vertex." );
01582     err = count_num_with_tag( geom, vols, interval ) ? iBase_FAILURE : iBase_SUCCESS;
01583     CHECK( "Got interval count for volume." );
01584 
01585     // expect no size tag on any entities except surfaces
01586     // curves should have size of one of their parent surfaces
01587     err = count_num_with_tag( geom, verts, size ) ? iBase_FAILURE : iBase_SUCCESS;
01588     CHECK( "Got mesh size for vertex." );
01589     err = count_num_with_tag( geom, vols, size ) ? iBase_FAILURE : iBase_SUCCESS;
01590     CHECK( "Got mesh size for volume." );
01591 
01592     return true;
01593 }
01594 
01595 bool shutdown_test2( FBiGeom_Instance geom, std::string& /*engine_opt*/ )
01596 {
01597     int err;
01598 
01599     // test shutdown2
01600     FBiGeom_dtor2( geom, &err );
01601     CHECK( "Interface destruction didn't work properly." );
01602 
01603     //   FBiGeom_newGeom(engine_opt.c_str(), &geom, &err, engine_opt.length());
01604     //   CHECK( "Interface re-construction didn't work properly." );
01605     //
01606     //   FBiGeom_dtor(geom, &err);
01607     //   CHECK( "2nd Interface destruction didn't work properly." );
01608 
01609     return true;
01610 }
01611 
01612 bool save_entset_test( FBiGeom_Instance geom )
01613 {
01614     int err;
01615 
01616 #ifdef FORCE_OCC
01617     std::string filename = "testout.brep";
01618 #elif defined( HAVE_ACIS )
01619     std::string filename = "testout.sat";
01620 #elif defined( HAVE_OCC )
01621     std::string filename = "testout.brep";
01622 #else
01623     std::string filename = "testout.sat";
01624 #endif
01625 
01626     // initialize number of ents and sets to compare with later
01627     int num_ents_bef, num_sets_bef;
01628     iBase_EntitySetHandle root;
01629     FBiGeom_getRootSet( geom, &root, &err );
01630     CHECK( "Failed to get root set." );
01631     FBiGeom_getNumEntSets( geom, root, 1, &num_sets_bef, &err );
01632     CHECK( "Failed to get number of ent sets." );
01633     FBiGeom_getNumOfType( geom, root, iBase_REGION, &num_ents_bef, &err );
01634     CHECK( "Failed to get number of entities." );
01635 
01636     // create set, and entity to add to set
01637     iBase_EntityHandle cyl;
01638     FBiGeom_createCylinder( geom, 1.0, 0.25, 0.0, &cyl, &err );
01639     CHECK( "Problems creating cylinder for save entset test." );
01640     iBase_EntitySetHandle seth;
01641     FBiGeom_createEntSet( geom, true, &seth, &err );
01642     CHECK( "Problems creating entity set for save entset test." );
01643 
01644     // add the entity
01645     FBiGeom_addEntToSet( geom, cyl, seth, &err );
01646     CHECK( "Problems adding entity to set for save entset test." );
01647 
01648     // save/restore the model, and see if the entity is there
01649     FBiGeom_save( geom, filename.c_str(), NULL, &err, filename.length(), 0 );
01650     CHECK( "Problems saving file for save entset test." );
01651 
01652     FBiGeom_destroyEntSet( geom, seth, &err );
01653     CHECK( "Failed to destroy entity set." );
01654     FBiGeom_deleteEnt( geom, cyl, &err );
01655     CHECK( "Failed to destroy entity." );
01656 
01657     // read the file back in
01658     FBiGeom_load( geom, filename.c_str(), NULL, &err, filename.length(), 0 );
01659     CHECK( "Problems reading file for save entset test." );
01660 
01661     // check number of sets and entities
01662     int num_ents_aft, num_sets_aft;
01663     FBiGeom_getNumEntSets( geom, root, 1, &num_sets_aft, &err );
01664     CHECK( "Failed to get number of ent sets." );
01665     FBiGeom_getNumOfType( geom, root, iBase_REGION, &num_ents_aft, &err );
01666     CHECK( "Failed to get number of entities." );
01667     bool success = true;
01668     if( num_ents_aft != 2 * num_ents_bef + 1 )
01669     {
01670         print_error( "Failed to get the right number of entities.", iBase_FAILURE, geom, __FILE__, __LINE__ );
01671         success = false;
01672     }
01673     else if( num_sets_aft != 2 * num_sets_bef + 1 )
01674     {
01675         print_error( "Failed to get the right number of entity sets.", iBase_FAILURE, geom, __FILE__, __LINE__ );
01676         success = false;
01677     }
01678 
01679     // otherwise, we succeeded
01680     return success;
01681 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines