MOAB: Mesh Oriented datABase  (version 5.5.0)
read_cgm_facet_test.cpp
Go to the documentation of this file.
1 #include <iostream>
2 #include "moab/Interface.hpp"
3 #ifndef IS_BUILDING_MB
4 #define IS_BUILDING_MB
5 #endif
6 #include "TestUtil.hpp"
7 #include "Internals.hpp"
8 #include "moab/Core.hpp"
9 #include "MBTagConventions.hpp"
10 #include "InitCGMA.hpp"
11 #include "GeometryQueryTool.hpp"
12 #include "ReadCGM.hpp"
13 #include "moab/FileOptions.hpp"
14 using namespace moab;
15 
16 #ifdef HAVE_OCC_STEP
17 std::string input_cube = TestDir + "unittest/io/cube.stp";
18 #else
19 std::string input_cube = TestDir + "unittest/io/cube.sat";
20 #endif
21 
22 #ifdef HAVE_OCC_STEP
23 std::string input_cone = TestDir + "unittest/io/cone.stp";
24 #else
25 std::string input_cone = TestDir + "unittest/io/cone.sat";
26 #endif
27 
28 // Function used to load the test file
29 void read_file( Interface* moab, const char* input_file );
30 
31 // List of tests in this file
34 
36  bool curve_fatal,
37  const char* input_file,
38  ErrorCode check_val,
39  int& curve_fail,
40  int& surface_fail )
41 {
42  InitCGMA::initialize_cgma();
43  GeometryQueryTool::instance()->delete_geometry();
44  EntityHandle fs = 0;
45 
46  // set the options
47  std::string options;
48 #define OPTION_APPEND( X ) \
49  { \
50  if( options.length() ) options += ";"; \
51  options += ( X ); \
52  }
53 
54  OPTION_APPEND( "CGM_ATTRIBS=no" );
55  if( curve_fatal ) OPTION_APPEND( "FATAL_ON_CURVES" );
56  OPTION_APPEND( "VERBOSE_CGM_WARNINGS" );
57 
58  // set the file options
59  FileOptions opts( options.c_str() );
60 
61  // new ReadCGM instance
62  ReadCGM* RCGM = new ReadCGM( moab );
63  ErrorCode rval = RCGM->load_file( input_file, &fs, opts );
64  // CHKERR(rval);
65  curve_fail = RCGM->get_failed_curve_count();
66  surface_fail = RCGM->get_failed_surface_count();
67  // std::cout << curve_fail << " " << surface_fail << std::endl;
68 
69  CHECK_EQUAL( rval, check_val );
70  CHECK_EQUAL( curve_fail, 0 );
71  CHECK_EQUAL( surface_fail, 0 );
72 }
73 
74 // Gets the vertex entities from a simple cube file load and checks that the
75 // correct number of them exist.
77 {
78  // Open the test file
79  Core moab;
80  Interface* mb = &moab;
81  int curve_fail = 0;
82  int surface_fail = 0;
83  // should succeed since we are not fatal error on curves
84  read_file( mb, false, input_cube.c_str(), MB_SUCCESS, curve_fail, surface_fail );
85 }
86 
87 // Gets the vertex entities from a simple cube file load and checks that the
88 // correct number of them exist.
90 {
91  // Open the test file
92  Core moab;
93  Interface* mb = &moab;
94  int curve_fail = 0;
95  int surface_fail = 0;
96  // should expect MB_FAILURE since we fail on curves
97  read_file( mb, true, input_cone.c_str(), MB_FAILURE, curve_fail, surface_fail );
98 }
99 
100 // void delete_mesh_test();
101 int main( int /* argc */, char** /* argv */ )
102 {
103  int result = 0;
104 
105  result += RUN_TEST( test_cube_curve_facet );
106 #ifndef HAVE_OCC_STEP
107  result += RUN_TEST( test_cone_curve_facet );
108 #endif
109  return result;
110 }