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