MOAB: Mesh Oriented datABase  (version 5.4.0)
read_cgm_senses_test.cpp
Go to the documentation of this file.
00001 #include <iostream>
00002 #include "moab/Interface.hpp"
00003 #ifndef IS_BUILDING_MB
00004 #define IS_BUILDING_MB
00005 #endif
00006 #include "TestUtil.hpp"
00007 #include "Internals.hpp"
00008 #include "moab/Core.hpp"
00009 #include "MBTagConventions.hpp"
00010 #include "moab/GeomTopoTool.hpp"
00011 #include "InitCGMA.hpp"
00012 #include "GeometryQueryTool.hpp"
00013 #include "CGMConfig.h"
00014 
00015 #define SENSE_FORWARD 1
00016 #define SENSE_REVERSE ( -1 )
00017 #define SENSE_UNKNOWN 0
00018 using namespace moab;
00019 
00020 #define CHKERR( A )                                                                                        \
00021     do                                                                                                     \
00022     {                                                                                                      \
00023         if( MB_SUCCESS != ( A ) )                                                                          \
00024         {                                                                                                  \
00025             std::cerr << "Failure (error code " << ( A ) << ") at " __FILE__ ":" << __LINE__ << std::endl; \
00026             return A;                                                                                      \
00027         }                                                                                                  \
00028     } while( false )
00029 
00030 #ifdef HAVE_OCC_STEP
00031 std::string input_cylcube = TestDir + "unittest/io/cylcube.stp";
00032 #else
00033 std::string input_cylcube = TestDir + "unittest/io/cylcube.sat";
00034 #endif
00035 
00036 // Function used to load the test file
00037 void read_file( Interface* moab, const char* input_file );
00038 
00039 // Functions containing known sense data
00040 ErrorCode load_sat_curve_sense_data( Interface* moab,
00041                                      EntityHandle curve,
00042                                      std::vector< int >& surf_ids_out,
00043                                      std::vector< int >& senses_out );
00044 ErrorCode load_stp_curve_sense_data( Interface* moab,
00045                                      EntityHandle curve,
00046                                      std::vector< int >& surf_ids_out,
00047                                      std::vector< int >& senses_out );
00048 ErrorCode load_precgm14_stp_curve_sense_data( Interface* moab,
00049                                               EntityHandle curve,
00050                                               std::vector< int >& surf_ids_out,
00051                                               std::vector< int >& senses_out );
00052 ErrorCode load_sat_surf_sense_data( Interface* moab,
00053                                     EntityHandle surf,
00054                                     std::vector< int >& vol_ids_out,
00055                                     std::vector< int >& senses_out );
00056 ErrorCode load_stp_surf_sense_data( Interface* moab,
00057                                     EntityHandle surf,
00058                                     std::vector< int >& vol_ids_out,
00059                                     std::vector< int >& senses_out );
00060 ErrorCode load_precgm14_stp_surf_sense_data( Interface* moab,
00061                                              EntityHandle surf,
00062                                              std::vector< int >& vol_ids_out,
00063                                              std::vector< int >& senses_out );
00064 
00065 // Functions used to compare sense information found in
00066 // the model to reference information
00067 void check_sense_data( Interface* moab,
00068                        std::vector< EntityHandle > wrt_ents,
00069                        std::vector< int > senses,
00070                        std::vector< int > known_wrt_ids,
00071                        std::vector< int > known_senses );
00072 
00073 // Function used to get id's from entity handles
00074 int geom_id_by_handle( Interface* moab, const EntityHandle set );
00075 
00076 // List of tests in this file
00077 void read_cylcube_curve_senses_test();
00078 void read_cylcube_surf_senses_test();
00079 void delete_mesh_test();
00080 
00081 int main( int /* argc */, char** /* argv */ )
00082 {
00083     int result = 0;
00084 
00085     result += RUN_TEST( read_cylcube_surf_senses_test );
00086     result += RUN_TEST( read_cylcube_curve_senses_test );
00087 
00088     return result;
00089 }
00090 
00091 void read_file( Interface* moab, const char* input_file )
00092 {
00093     InitCGMA::initialize_cgma();
00094     GeometryQueryTool::instance()->delete_geometry();
00095 
00096     ErrorCode rval = moab->load_file( input_file );CHECK_ERR( rval );
00097 }
00098 
00099 // Gets the sense data for each curve from a file
00100 // containing a cube and a cylinder. It then checks
00101 // that this sense data matches the reference
00102 // sense data from prior file reads.
00103 void read_cylcube_curve_senses_test()
00104 {
00105     ErrorCode rval;
00106     // Open the test file
00107     Core moab;
00108     Interface* mb = &moab;
00109     read_file( mb, input_cylcube.c_str() );
00110 
00111     // Get all curve handles
00112     Tag geom_tag;
00113     rval = mb->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1, MB_TYPE_INTEGER, geom_tag,
00114                                moab::MB_TAG_DENSE | moab::MB_TAG_CREAT );CHECK_ERR( rval );
00115 
00116     // Check that the proper number of curves exist
00117     int dim     = 1;
00118     void* val[] = { &dim };
00119     int number_of_curves;
00120     rval = mb->get_number_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag, val, 1, number_of_curves );CHECK_ERR( rval );
00121     // Step format adds a surface on the barrel of the cylinder.
00122     // This created 4 extra surfaces in comparison to the .sat format from Cubit.
00123     //(New surface breaks the barrel of the cylinder into two half-pipes)
00124 #ifdef HAVE_OCC_STEP
00125     CHECK_EQUAL( 18, number_of_curves );
00126 #else
00127     CHECK_EQUAL( 14, number_of_curves );
00128 #endif
00129 
00130     // Get curve handles
00131     Range curves;
00132     rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag, val, 1, curves );CHECK_ERR( rval );
00133 
00134     // Establish GeomTopoTool instance needed to get curve data
00135     moab::GeomTopoTool gt( mb, false );
00136     // Initialize vectors for sense checking
00137     std::vector< EntityHandle > surfs;
00138     std::vector< int > senses;
00139     std::vector< int > known_surf_ids;
00140     std::vector< int > known_senses;
00141 
00142     for( unsigned int i = 0; i < curves.size(); i++ )
00143     {
00144 
00145         // Clean data from previous curve
00146         surfs.clear();
00147         senses.clear();
00148         // Get sense info for the current curve
00149         rval = gt.get_senses( curves[i], surfs, senses );CHECK_ERR( rval );
00150 
00151         // Clear reference data from previous curve
00152         known_surf_ids.clear();
00153         known_senses.clear();
00154         // Load known curve-sense ID data
00155 #ifdef HAVE_OCC_STEP
00156         if( CGM_MAJOR_VERSION >= 14 )
00157         {
00158             rval = load_stp_curve_sense_data( mb, curves[i], known_surf_ids, known_senses );
00159         }
00160         else
00161         {
00162             rval = load_precgm14_stp_curve_sense_data( mb, curves[i], known_surf_ids, known_senses );
00163         }
00164         CHECK_ERR( rval );
00165 #else
00166         rval = load_sat_curve_sense_data( mb, curves[i], known_surf_ids, known_senses );CHECK_ERR( rval );
00167 #endif
00168 
00169         // Check that each surf and sense has a match in the references
00170         check_sense_data( mb, surfs, senses, known_surf_ids, known_senses );
00171     }
00172 }
00173 
00174 int geom_id_by_handle( Interface* moab, const EntityHandle set )
00175 {
00176 
00177     ErrorCode rval;
00178     // Get the id_tag handle
00179     Tag id_tag = moab->globalId_tag();
00180     // Load the ID for the EntHandle given to the function
00181     int id;
00182     rval = moab->tag_get_data( id_tag, &set, 1, &id );CHECK_ERR( rval );
00183     return id;
00184 }
00185 
00186 void check_sense_data( Interface* moab,
00187                        std::vector< EntityHandle > wrt_ents,
00188                        std::vector< int > senses,
00189                        std::vector< int > known_wrt_ids,
00190                        std::vector< int > known_senses )
00191 {
00192 
00193     // Get ID's of the wrt entities
00194     std::vector< int > wrt_ent_ids;
00195     for( unsigned int i = 0; i < wrt_ents.size(); i++ )
00196     {
00197         wrt_ent_ids.push_back( geom_id_by_handle( moab, wrt_ents[i] ) );
00198     }
00199 
00200     for( unsigned int i = 0; i < wrt_ent_ids.size(); i++ )
00201     {
00202         for( unsigned int j = 0; j < known_wrt_ids.size(); j++ )
00203         {
00204             if( wrt_ent_ids[i] == known_wrt_ids[j] )
00205             {
00206                 // Make sure the senses of the matching wrt entities
00207                 // are correct
00208                 CHECK_EQUAL( senses[i], known_senses[j] );
00209                 // Once a wrt entity is matched with a known entity,
00210                 // remove it from the list
00211                 wrt_ent_ids.erase( wrt_ent_ids.begin() + i );
00212                 senses.erase( senses.begin() + i );
00213                 --i;
00214                 break;
00215             }
00216         }
00217     }
00218 
00219     // After both loops are complete, known_wrt_ents should be empty
00220     int leftovers = wrt_ent_ids.size();
00221     CHECK_EQUAL( leftovers, 0 );
00222 }
00223 
00224 // Loads two vectors with reference curve and curve_sense data
00225 ErrorCode load_sat_curve_sense_data( Interface* moab,
00226                                      EntityHandle curve,
00227                                      std::vector< int >& surf_ids_out,
00228                                      std::vector< int >& senses_out )
00229 {
00230 
00231     int curve_id = geom_id_by_handle( moab, curve );
00232     switch( curve_id )
00233     {
00234         case 1:
00235             surf_ids_out.push_back( 1 );
00236             surf_ids_out.push_back( 6 );
00237             senses_out.push_back( SENSE_FORWARD );
00238             senses_out.push_back( SENSE_REVERSE );
00239             break;
00240 
00241         case 2:
00242             surf_ids_out.push_back( 1 );
00243             surf_ids_out.push_back( 5 );
00244             senses_out.push_back( SENSE_FORWARD );
00245             senses_out.push_back( SENSE_REVERSE );
00246             break;
00247 
00248         case 3:
00249             surf_ids_out.push_back( 1 );
00250             surf_ids_out.push_back( 4 );
00251             senses_out.push_back( SENSE_FORWARD );
00252             senses_out.push_back( SENSE_REVERSE );
00253             break;
00254 
00255         case 4:
00256             surf_ids_out.push_back( 1 );
00257             surf_ids_out.push_back( 3 );
00258             senses_out.push_back( SENSE_FORWARD );
00259             senses_out.push_back( SENSE_REVERSE );
00260             break;
00261 
00262         case 5:
00263             surf_ids_out.push_back( 2 );
00264             surf_ids_out.push_back( 6 );
00265             senses_out.push_back( SENSE_FORWARD );
00266             senses_out.push_back( SENSE_REVERSE );
00267             break;
00268 
00269         case 6:
00270             surf_ids_out.push_back( 2 );
00271             surf_ids_out.push_back( 3 );
00272             senses_out.push_back( SENSE_FORWARD );
00273             senses_out.push_back( SENSE_REVERSE );
00274             break;
00275 
00276         case 7:
00277             surf_ids_out.push_back( 2 );
00278             surf_ids_out.push_back( 4 );
00279             senses_out.push_back( SENSE_FORWARD );
00280             senses_out.push_back( SENSE_REVERSE );
00281             break;
00282 
00283         case 8:
00284             surf_ids_out.push_back( 2 );
00285             surf_ids_out.push_back( 5 );
00286             senses_out.push_back( SENSE_FORWARD );
00287             senses_out.push_back( SENSE_REVERSE );
00288             break;
00289 
00290         case 9:
00291             surf_ids_out.push_back( 3 );
00292             surf_ids_out.push_back( 4 );
00293             senses_out.push_back( SENSE_FORWARD );
00294             senses_out.push_back( SENSE_REVERSE );
00295             break;
00296 
00297         case 10:
00298             surf_ids_out.push_back( 3 );
00299             surf_ids_out.push_back( 6 );
00300             senses_out.push_back( SENSE_REVERSE );
00301             senses_out.push_back( SENSE_FORWARD );
00302             break;
00303 
00304         case 11:
00305             surf_ids_out.push_back( 4 );
00306             surf_ids_out.push_back( 5 );
00307             senses_out.push_back( SENSE_FORWARD );
00308             senses_out.push_back( SENSE_REVERSE );
00309             break;
00310 
00311         case 12:
00312             surf_ids_out.push_back( 5 );
00313             surf_ids_out.push_back( 6 );
00314             senses_out.push_back( SENSE_FORWARD );
00315             senses_out.push_back( SENSE_REVERSE );
00316             break;
00317 
00318         case 13:
00319             surf_ids_out.push_back( 7 );
00320             surf_ids_out.push_back( 8 );
00321             senses_out.push_back( SENSE_REVERSE );
00322             senses_out.push_back( SENSE_FORWARD );
00323             break;
00324 
00325         case 14:
00326             surf_ids_out.push_back( 7 );
00327             surf_ids_out.push_back( 9 );
00328             senses_out.push_back( SENSE_REVERSE );
00329             senses_out.push_back( SENSE_FORWARD );
00330             break;
00331         default:
00332             return MB_FAILURE;
00333     }
00334     return MB_SUCCESS;
00335 }
00336 
00337 // Loads two vectors with reference curve and curve_sense data
00338 ErrorCode load_stp_curve_sense_data( Interface* moab,
00339                                      EntityHandle curve,
00340                                      std::vector< int >& surf_ids_out,
00341                                      std::vector< int >& senses_out )
00342 {
00343 
00344     int curve_id = geom_id_by_handle( moab, curve );
00345     switch( curve_id )
00346     {
00347         case 1:
00348             surf_ids_out.push_back( 1 );
00349             surf_ids_out.push_back( 6 );
00350             senses_out.push_back( SENSE_FORWARD );
00351             senses_out.push_back( SENSE_FORWARD );
00352             break;
00353 
00354         case 2:
00355             surf_ids_out.push_back( 1 );
00356             surf_ids_out.push_back( 5 );
00357             senses_out.push_back( SENSE_FORWARD );
00358             senses_out.push_back( SENSE_FORWARD );
00359             break;
00360 
00361         case 3:
00362             surf_ids_out.push_back( 1 );
00363             surf_ids_out.push_back( 4 );
00364             senses_out.push_back( SENSE_FORWARD );
00365             senses_out.push_back( SENSE_FORWARD );
00366             break;
00367 
00368         case 4:
00369             surf_ids_out.push_back( 1 );
00370             surf_ids_out.push_back( 3 );
00371             senses_out.push_back( SENSE_FORWARD );
00372             senses_out.push_back( SENSE_FORWARD );
00373             break;
00374 
00375         case 5:
00376             surf_ids_out.push_back( 2 );
00377             surf_ids_out.push_back( 6 );
00378             senses_out.push_back( SENSE_REVERSE );
00379             senses_out.push_back( SENSE_FORWARD );
00380             break;
00381 
00382         case 6:
00383             surf_ids_out.push_back( 2 );
00384             surf_ids_out.push_back( 5 );
00385             senses_out.push_back( SENSE_REVERSE );
00386             senses_out.push_back( SENSE_FORWARD );
00387             break;
00388 
00389         case 7:
00390             surf_ids_out.push_back( 2 );
00391             surf_ids_out.push_back( 4 );
00392             senses_out.push_back( SENSE_REVERSE );
00393             senses_out.push_back( SENSE_FORWARD );
00394             break;
00395 
00396         case 8:
00397             surf_ids_out.push_back( 2 );
00398             surf_ids_out.push_back( 3 );
00399             senses_out.push_back( SENSE_REVERSE );
00400             senses_out.push_back( SENSE_FORWARD );
00401             break;
00402 
00403         case 9:
00404             surf_ids_out.push_back( 3 );
00405             surf_ids_out.push_back( 4 );
00406             senses_out.push_back( SENSE_REVERSE );
00407             senses_out.push_back( SENSE_FORWARD );
00408             break;
00409 
00410         case 10:
00411             surf_ids_out.push_back( 3 );
00412             surf_ids_out.push_back( 6 );
00413             senses_out.push_back( SENSE_FORWARD );
00414             senses_out.push_back( SENSE_REVERSE );
00415             break;
00416 
00417         case 11:
00418             surf_ids_out.push_back( 4 );
00419             surf_ids_out.push_back( 5 );
00420             senses_out.push_back( SENSE_REVERSE );
00421             senses_out.push_back( SENSE_FORWARD );
00422             break;
00423 
00424         case 12:
00425             surf_ids_out.push_back( 5 );
00426             surf_ids_out.push_back( 6 );
00427             senses_out.push_back( SENSE_REVERSE );
00428             senses_out.push_back( SENSE_FORWARD );
00429             break;
00430 
00431         case 13:
00432             surf_ids_out.push_back( 7 );
00433             surf_ids_out.push_back( 8 );
00434             senses_out.push_back( SENSE_REVERSE );
00435             senses_out.push_back( SENSE_FORWARD );
00436             break;
00437 
00438         case 14:
00439             surf_ids_out.push_back( 7 );
00440             surf_ids_out.push_back( 9 );
00441             senses_out.push_back( SENSE_REVERSE );
00442             senses_out.push_back( SENSE_FORWARD );
00443             break;
00444         case 15:
00445             surf_ids_out.push_back( 7 );
00446             surf_ids_out.push_back( 8 );
00447             senses_out.push_back( SENSE_REVERSE );
00448             senses_out.push_back( SENSE_FORWARD );
00449             break;
00450         case 16:
00451             surf_ids_out.push_back( 7 );
00452             surf_ids_out.push_back( 10 );
00453             senses_out.push_back( SENSE_REVERSE );
00454             senses_out.push_back( SENSE_FORWARD );
00455             break;
00456         case 17:
00457             surf_ids_out.push_back( 8 );
00458             surf_ids_out.push_back( 10 );
00459             senses_out.push_back( SENSE_REVERSE );
00460             senses_out.push_back( SENSE_FORWARD );
00461             break;
00462         case 18:
00463             surf_ids_out.push_back( 8 );
00464             surf_ids_out.push_back( 9 );
00465             senses_out.push_back( SENSE_REVERSE );
00466             senses_out.push_back( SENSE_FORWARD );
00467             break;
00468         default:
00469             return MB_FAILURE;
00470     }
00471     return MB_SUCCESS;
00472 }
00473 
00474 ErrorCode load_precgm14_stp_curve_sense_data( Interface* moab,
00475                                               EntityHandle curve,
00476                                               std::vector< int >& surf_ids_out,
00477                                               std::vector< int >& senses_out )
00478 {
00479 
00480     int curve_id = geom_id_by_handle( moab, curve );
00481     switch( curve_id )
00482     {
00483         case 1:
00484             surf_ids_out.push_back( 1 );
00485             surf_ids_out.push_back( 6 );
00486             senses_out.push_back( SENSE_FORWARD );
00487             senses_out.push_back( SENSE_REVERSE );
00488             break;
00489 
00490         case 2:
00491             surf_ids_out.push_back( 1 );
00492             surf_ids_out.push_back( 5 );
00493             senses_out.push_back( SENSE_FORWARD );
00494             senses_out.push_back( SENSE_REVERSE );
00495             break;
00496 
00497         case 3:
00498             surf_ids_out.push_back( 1 );
00499             surf_ids_out.push_back( 4 );
00500             senses_out.push_back( SENSE_FORWARD );
00501             senses_out.push_back( SENSE_REVERSE );
00502             break;
00503 
00504         case 4:
00505             surf_ids_out.push_back( 1 );
00506             surf_ids_out.push_back( 3 );
00507             senses_out.push_back( SENSE_FORWARD );
00508             senses_out.push_back( SENSE_REVERSE );
00509             break;
00510 
00511         case 5:
00512             surf_ids_out.push_back( 2 );
00513             surf_ids_out.push_back( 6 );
00514             senses_out.push_back( SENSE_FORWARD );
00515             senses_out.push_back( SENSE_REVERSE );
00516             break;
00517 
00518         case 6:
00519             surf_ids_out.push_back( 2 );
00520             surf_ids_out.push_back( 3 );
00521             senses_out.push_back( SENSE_FORWARD );
00522             senses_out.push_back( SENSE_REVERSE );
00523             break;
00524 
00525         case 7:
00526             surf_ids_out.push_back( 2 );
00527             surf_ids_out.push_back( 4 );
00528             senses_out.push_back( SENSE_FORWARD );
00529             senses_out.push_back( SENSE_REVERSE );
00530             break;
00531 
00532         case 8:
00533             surf_ids_out.push_back( 2 );
00534             surf_ids_out.push_back( 5 );
00535             senses_out.push_back( SENSE_FORWARD );
00536             senses_out.push_back( SENSE_REVERSE );
00537             break;
00538 
00539         case 9:
00540             surf_ids_out.push_back( 3 );
00541             surf_ids_out.push_back( 4 );
00542             senses_out.push_back( SENSE_FORWARD );
00543             senses_out.push_back( SENSE_REVERSE );
00544             break;
00545 
00546         case 10:
00547             surf_ids_out.push_back( 3 );
00548             surf_ids_out.push_back( 6 );
00549             senses_out.push_back( SENSE_REVERSE );
00550             senses_out.push_back( SENSE_FORWARD );
00551             break;
00552 
00553         case 11:
00554             surf_ids_out.push_back( 4 );
00555             surf_ids_out.push_back( 5 );
00556             senses_out.push_back( SENSE_FORWARD );
00557             senses_out.push_back( SENSE_REVERSE );
00558             break;
00559 
00560         case 12:
00561             surf_ids_out.push_back( 5 );
00562             surf_ids_out.push_back( 6 );
00563             senses_out.push_back( SENSE_FORWARD );
00564             senses_out.push_back( SENSE_REVERSE );
00565             break;
00566 
00567         case 13:
00568             surf_ids_out.push_back( 7 );
00569             surf_ids_out.push_back( 8 );
00570             senses_out.push_back( SENSE_REVERSE );
00571             senses_out.push_back( SENSE_FORWARD );
00572             break;
00573 
00574         case 14:
00575             surf_ids_out.push_back( 7 );
00576             surf_ids_out.push_back( 9 );
00577             senses_out.push_back( SENSE_REVERSE );
00578             senses_out.push_back( SENSE_FORWARD );
00579             break;
00580         case 15:
00581             surf_ids_out.push_back( 7 );
00582             surf_ids_out.push_back( 8 );
00583             senses_out.push_back( SENSE_REVERSE );
00584             senses_out.push_back( SENSE_FORWARD );
00585             break;
00586         case 16:
00587             surf_ids_out.push_back( 7 );
00588             surf_ids_out.push_back( 10 );
00589             senses_out.push_back( SENSE_REVERSE );
00590             senses_out.push_back( SENSE_FORWARD );
00591             break;
00592         case 17:
00593             surf_ids_out.push_back( 8 );
00594             surf_ids_out.push_back( 10 );
00595             senses_out.push_back( SENSE_REVERSE );
00596             senses_out.push_back( SENSE_FORWARD );
00597             break;
00598         case 18:
00599             surf_ids_out.push_back( 8 );
00600             surf_ids_out.push_back( 9 );
00601             senses_out.push_back( SENSE_REVERSE );
00602             senses_out.push_back( SENSE_FORWARD );
00603             break;
00604         default:
00605             return MB_FAILURE;
00606     }
00607     return MB_SUCCESS;
00608 }
00609 
00610 // SURFACE SENSE CHECKING
00611 // Gets the sense data for each surface from a file
00612 // containing a cube and a cylinder. It then checks
00613 // that this sense data matches the reference
00614 // sense data from prior file reads.
00615 void read_cylcube_surf_senses_test()
00616 {
00617     ErrorCode rval;
00618     // Open the test file
00619     Core moab;
00620     Interface* mb = &moab;
00621     read_file( mb, input_cylcube.c_str() );
00622 
00623     // Get geometry tag for gathering surface information from the mesh
00624     Tag geom_tag;
00625     rval = mb->tag_get_handle( GEOM_DIMENSION_TAG_NAME, 1, MB_TYPE_INTEGER, geom_tag,
00626                                moab::MB_TAG_DENSE | moab::MB_TAG_CREAT );CHECK_ERR( rval );
00627 
00628     // Check that the proper number of surfaces exist
00629     int dim     = 2;
00630     void* val[] = { &dim };
00631     int number_of_surfs;
00632     rval = mb->get_number_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag, val, 1, number_of_surfs );CHECK_ERR( rval );
00633     // Step format adds a surface on barrel of the cylinder.
00634     // (Breaks it into two half-pipes)
00635 #ifdef HAVE_OCC_STEP
00636     CHECK_EQUAL( 10, number_of_surfs );
00637 #else
00638     CHECK_EQUAL( 9, number_of_surfs );
00639 #endif
00640     // Get surface handles
00641     Range surfs;
00642     rval = mb->get_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag, val, 1, surfs );CHECK_ERR( rval );
00643 
00644     // Establish GeomTopoTool instance needed to get surf data
00645     moab::GeomTopoTool gt( mb, false );
00646     std::vector< EntityHandle > vols;
00647     std::vector< int > senses;
00648     std::vector< int > known_vol_ids;
00649     std::vector< int > known_senses;
00650 
00651     for( unsigned int i = 0; i < surfs.size(); i++ )
00652     {
00653         // Clean data from previous surface
00654         vols.clear();
00655         senses.clear();
00656         // Get sense information for the current
00657         // surface from the mesh
00658         rval = gt.get_senses( surfs[i], vols, senses );CHECK_ERR( rval );
00659         // Clear previous reverence data
00660         known_vol_ids.clear();
00661         known_senses.clear();
00662         // Load known surface-volume data
00663         // for this surface and check that it's correct
00664 #ifdef HAVE_OCC_STEP
00665         if( CGM_MAJOR_VERSION >= 14 )
00666         {
00667             rval = load_stp_surf_sense_data( mb, surfs[i], known_vol_ids, known_senses );
00668         }
00669         else
00670         {
00671             rval = load_precgm14_stp_surf_sense_data( mb, surfs[i], known_vol_ids, known_senses );
00672         }
00673         CHECK_ERR( rval );
00674 #else
00675         rval = load_sat_surf_sense_data( mb, surfs[i], known_vol_ids, known_senses );CHECK_ERR( rval );
00676 #endif
00677         // Check sense information from the loaded mesh against
00678         // reference sense information
00679         check_sense_data( mb, vols, senses, known_vol_ids, known_senses );
00680     }
00681 }
00682 
00683 // Loads reference surface to volume sense data into the reference vectors
00684 ErrorCode load_sat_surf_sense_data( Interface* moab,
00685                                     EntityHandle surf,
00686                                     std::vector< int >& vol_ids_out,
00687                                     std::vector< int >& senses_out )
00688 {
00689 
00690     int surf_id = geom_id_by_handle( moab, surf );
00691     switch( surf_id )
00692     {
00693         case 1:
00694             vol_ids_out.push_back( 1 );
00695             senses_out.push_back( SENSE_FORWARD );
00696             break;
00697 
00698         case 2:
00699             vol_ids_out.push_back( 1 );
00700             senses_out.push_back( SENSE_FORWARD );
00701             break;
00702 
00703         case 3:
00704             vol_ids_out.push_back( 1 );
00705             senses_out.push_back( SENSE_FORWARD );
00706             break;
00707 
00708         case 4:
00709             vol_ids_out.push_back( 1 );
00710             senses_out.push_back( SENSE_FORWARD );
00711             break;
00712 
00713         case 5:
00714             vol_ids_out.push_back( 1 );
00715             senses_out.push_back( SENSE_FORWARD );
00716             break;
00717 
00718         case 6:
00719             vol_ids_out.push_back( 1 );
00720             senses_out.push_back( SENSE_FORWARD );
00721             break;
00722 
00723         case 7:
00724             vol_ids_out.push_back( 2 );
00725             senses_out.push_back( SENSE_FORWARD );
00726             break;
00727 
00728         case 8:
00729             vol_ids_out.push_back( 2 );
00730             senses_out.push_back( SENSE_FORWARD );
00731             break;
00732 
00733         case 9:
00734             vol_ids_out.push_back( 2 );
00735             senses_out.push_back( SENSE_FORWARD );
00736             break;
00737         default:
00738             return MB_FAILURE;
00739     }
00740     return MB_SUCCESS;
00741 }
00742 
00743 // Loads reference surface to volume sense data into the reference vectors
00744 ErrorCode load_stp_surf_sense_data( Interface* moab,
00745                                     EntityHandle surf,
00746                                     std::vector< int >& vol_ids_out,
00747                                     std::vector< int >& senses_out )
00748 {
00749 
00750     int surf_id = geom_id_by_handle( moab, surf );
00751     switch( surf_id )
00752     {
00753         case 1:
00754             vol_ids_out.push_back( 1 );
00755             senses_out.push_back( SENSE_FORWARD );
00756             break;
00757 
00758         case 2:
00759             vol_ids_out.push_back( 1 );
00760             senses_out.push_back( SENSE_REVERSE );
00761             break;
00762 
00763         case 3:
00764             vol_ids_out.push_back( 1 );
00765             senses_out.push_back( SENSE_REVERSE );
00766             break;
00767 
00768         case 4:
00769             vol_ids_out.push_back( 1 );
00770             senses_out.push_back( SENSE_REVERSE );
00771             break;
00772 
00773         case 5:
00774             vol_ids_out.push_back( 1 );
00775             senses_out.push_back( SENSE_REVERSE );
00776             break;
00777 
00778         case 6:
00779             vol_ids_out.push_back( 1 );
00780             senses_out.push_back( SENSE_REVERSE );
00781             break;
00782 
00783         case 7:
00784             vol_ids_out.push_back( 2 );
00785             senses_out.push_back( SENSE_FORWARD );
00786             break;
00787 
00788         case 8:
00789             vol_ids_out.push_back( 2 );
00790             senses_out.push_back( SENSE_FORWARD );
00791             break;
00792 
00793         case 9:
00794             vol_ids_out.push_back( 2 );
00795             senses_out.push_back( SENSE_FORWARD );
00796             break;
00797 
00798         case 10:
00799             vol_ids_out.push_back( 2 );
00800             senses_out.push_back( SENSE_FORWARD );
00801             break;
00802         default:
00803             std::cout << "Failure to find surface sense reference data. Returning failure..." << std::endl;
00804             return MB_FAILURE;
00805     }
00806     return MB_SUCCESS;
00807 }
00808 
00809 // Loads reference surface to volume sense data into the reference vectors
00810 ErrorCode load_precgm14_stp_surf_sense_data( Interface* moab,
00811                                              EntityHandle surf,
00812                                              std::vector< int >& vol_ids_out,
00813                                              std::vector< int >& senses_out )
00814 {
00815 
00816     int surf_id = geom_id_by_handle( moab, surf );
00817     switch( surf_id )
00818     {
00819         case 1:
00820         case 2:
00821         case 3:
00822         case 4:
00823         case 5:
00824         case 6:
00825             vol_ids_out.push_back( 1 );
00826             senses_out.push_back( SENSE_FORWARD );
00827             break;
00828 
00829         case 7:
00830         case 8:
00831         case 9:
00832         case 10:
00833             vol_ids_out.push_back( 2 );
00834             senses_out.push_back( SENSE_FORWARD );
00835             break;
00836 
00837         default:
00838             std::cout << "Failure to find surface sense reference data. Returning failure..." << std::endl;
00839             return MB_FAILURE;
00840     }
00841     return MB_SUCCESS;
00842 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines