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