MOAB: Mesh Oriented datABase  (version 5.3.0)
read_cgm_facet_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 "InitCGMA.hpp"
00011 #include "GeometryQueryTool.hpp"
00012 #include "ReadCGM.hpp"
00013 #include "moab/FileOptions.hpp"
00014 using namespace moab;
00015 
00016 #ifdef HAVE_OCC_STEP
00017 std::string input_cube = TestDir + "/io/cube.stp";
00018 #else
00019 std::string input_cube = TestDir + "/io/cube.sat";
00020 #endif
00021 
00022 #ifdef HAVE_OCC_STEP
00023 std::string input_cone = TestDir + "/io/cone.stp";
00024 #else
00025 std::string input_cone = TestDir + "/io/cone.sat";
00026 #endif
00027 
00028 // Function used to load the test file
00029 void read_file( Interface* moab, const char* input_file );
00030 
00031 // List of tests in this file
00032 void test_cube_curve_facet();
00033 void test_cone_curve_facet();
00034 
00035 void read_file( Interface* moab, bool curve_fatal, const char* input_file, ErrorCode check_val, int& curve_fail,
00036                 int& surface_fail )
00037 {
00038     InitCGMA::initialize_cgma();
00039     GeometryQueryTool::instance()->delete_geometry();
00040     EntityHandle fs = 0;
00041 
00042     // set the options
00043     std::string options;
00044 #define OPTION_APPEND( X )                     \
00045     {                                          \
00046         if( options.length() ) options += ";"; \
00047         options += ( X );                      \
00048     }
00049 
00050     OPTION_APPEND( "CGM_ATTRIBS=no" );
00051     if( curve_fatal ) OPTION_APPEND( "FATAL_ON_CURVES" );
00052     OPTION_APPEND( "VERBOSE_CGM_WARNINGS" );
00053 
00054     // set the file options
00055     FileOptions opts( options.c_str() );
00056 
00057     // new ReadCGM instance
00058     ReadCGM* RCGM  = new ReadCGM( moab );
00059     ErrorCode rval = RCGM->load_file( input_file, &fs, opts );
00060     //  CHKERR(rval);
00061     curve_fail   = RCGM->get_failed_curve_count();
00062     surface_fail = RCGM->get_failed_surface_count();
00063     //  std::cout << curve_fail << " " << surface_fail << std::endl;
00064 
00065     CHECK_EQUAL( rval, check_val );
00066     CHECK_EQUAL( curve_fail, 0 );
00067     CHECK_EQUAL( surface_fail, 0 );
00068 }
00069 
00070 // Gets the vertex entities from a simple cube file load and checks that the
00071 // correct number of them exist.
00072 void test_cube_curve_facet()
00073 {
00074     // Open the test file
00075     Core moab;
00076     Interface* mb    = &moab;
00077     int curve_fail   = 0;
00078     int surface_fail = 0;
00079     // should succeed since we are not fatal error on curves
00080     read_file( mb, false, input_cube.c_str(), MB_SUCCESS, curve_fail, surface_fail );
00081 }
00082 
00083 // Gets the vertex entities from a simple cube file load and checks that the
00084 // correct number of them exist.
00085 void test_cone_curve_facet()
00086 {
00087     // Open the test file
00088     Core moab;
00089     Interface* mb    = &moab;
00090     int curve_fail   = 0;
00091     int surface_fail = 0;
00092     // should expect MB_FAILURE since we fail on curves
00093     read_file( mb, true, input_cone.c_str(), MB_FAILURE, curve_fail, surface_fail );
00094 }
00095 
00096 // void delete_mesh_test();
00097 int main( int /* argc */, char** /* argv */ )
00098 {
00099     int result = 0;
00100 
00101     result += RUN_TEST( test_cube_curve_facet );
00102 #ifndef HAVE_OCC_STEP
00103     result += RUN_TEST( test_cone_curve_facet );
00104 #endif
00105     return result;
00106 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines