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