MOAB: Mesh Oriented datABase  (version 5.5.0)
smf_test.cpp File Reference
#include "TestUtil.hpp"
#include "moab/Core.hpp"
#include "moab/Range.hpp"
+ Include dependency graph for smf_test.cpp:

Go to the source code of this file.

Macros

#define IS_BUILDING_MB
 

Functions

void read_file (Interface &moab, const char *input_file)
 
void test_read_nodes ()
 
void test_read_triangles ()
 
int main ()
 

Variables

static const char example [] = "three.smf"
 

Macro Definition Documentation

◆ IS_BUILDING_MB

#define IS_BUILDING_MB

Definition at line 3 of file smf_test.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 18 of file smf_test.cpp.

19 {
20  int result = 0;
21 
22  result += RUN_TEST( test_read_nodes );
23  result += RUN_TEST( test_read_triangles );
24 
25  return result;
26 }

References RUN_TEST, test_read_nodes(), and test_read_triangles().

◆ read_file()

void read_file ( Interface moab,
const char *  input_file 
)

Definition at line 28 of file smf_test.cpp.

29 {
30  ErrorCode rval = moab.load_file( input_file );CHECK_ERR( rval );
31 }

References CHECK_ERR, ErrorCode, and input_file.

Referenced by test_read_nodes(), and test_read_triangles().

◆ test_read_nodes()

void test_read_nodes ( )

Definition at line 33 of file smf_test.cpp.

34 {
35  const double eps = 1e-10;
36  ErrorCode rval;
37  Core moab;
38  Interface& mb = moab;
40 
41  std::vector< EntityHandle > nodes;
42  rval = mb.get_entities_by_type( 0, MBVERTEX, nodes );CHECK_ERR( rval );
43  CHECK_EQUAL( (size_t)24, nodes.size() );
44 
45  std::vector< double > coords( 3 * nodes.size() );
46  rval = mb.get_coords( &nodes[0], nodes.size(), &coords[0] );CHECK_ERR( rval );
47 
48  int idx = 0;
49  CHECK_REAL_EQUAL( coords[3 * idx + 0], 0.0, eps );
50  CHECK_REAL_EQUAL( coords[3 * idx + 1], 0.0, eps );
51  CHECK_REAL_EQUAL( coords[3 * idx + 2], 0.0, eps );
52 
53  ++idx;
54  CHECK_REAL_EQUAL( coords[3 * idx + 0], 1.0, eps );
55  CHECK_REAL_EQUAL( coords[3 * idx + 1], 0.0, eps );
56  CHECK_REAL_EQUAL( coords[3 * idx + 2], 0.0, eps );
57 
58  idx = 8; // second cube
59  CHECK_REAL_EQUAL( coords[3 * idx + 0], 1.2, eps );
60  CHECK_REAL_EQUAL( coords[3 * idx + 1], 0.0, eps );
61  CHECK_REAL_EQUAL( coords[3 * idx + 2], 0.0, eps );
62 
63  idx = 15; // last node of second cube
64  CHECK_REAL_EQUAL( coords[3 * idx + 0], 2.2, eps );
65  CHECK_REAL_EQUAL( coords[3 * idx + 1], 1.0, eps );
66  CHECK_REAL_EQUAL( coords[3 * idx + 2], 1.0, eps );
67 
68  idx = 16; // first node of third cube
69  CHECK_REAL_EQUAL( coords[3 * idx + 0], -1.2, eps );
70  CHECK_REAL_EQUAL( coords[3 * idx + 1], 0.5, eps );
71  CHECK_REAL_EQUAL( coords[3 * idx + 2], -0.2071067812, eps );
72 }

References CHECK_EQUAL, CHECK_ERR, CHECK_REAL_EQUAL, eps, ErrorCode, example, moab::Core::get_coords(), moab::Core::get_entities_by_type(), mb, MBVERTEX, and read_file().

Referenced by main().

◆ test_read_triangles()

void test_read_triangles ( )

Definition at line 74 of file smf_test.cpp.

75 {
76  ErrorCode rval;
77  Core moab;
78  Interface& mb = moab;
80 
81  std::vector< EntityHandle > triangles;
82  rval = mb.get_entities_by_type( 0, MBTRI, triangles );CHECK_ERR( rval );
83  CHECK_EQUAL( (size_t)36, triangles.size() );
84 
85  int vtx_ids[3];
86  const EntityHandle* conn;
87  int len;
88 
89  const int conn1[] = { 1, 4, 2 };
90  int pos = 0;
91  rval = mb.get_connectivity( triangles[pos], conn, len );CHECK_ERR( rval );
92  CHECK_EQUAL( 3, len );
93  int i = 0;
94  for( i = 0; i < 3; i++ )
95  vtx_ids[i] = mb.id_from_handle( conn[i] );
96  CHECK_ARRAYS_EQUAL( conn1, 3, vtx_ids, len );
97 
98  // last triangle
99  const int conn2[] = { 19, 21, 23 };
100  rval = mb.get_connectivity( triangles[35], conn, len );CHECK_ERR( rval );
101  CHECK_EQUAL( 3, len );
102  for( i = 0; i < 3; i++ )
103  vtx_ids[i] = mb.id_from_handle( conn[i] );
104  CHECK_ARRAYS_EQUAL( conn2, 3, vtx_ids, len );
105 }

References CHECK_ARRAYS_EQUAL, CHECK_EQUAL, CHECK_ERR, ErrorCode, example, moab::Core::get_connectivity(), moab::Core::get_entities_by_type(), moab::Core::id_from_handle(), mb, MBTRI, and read_file().

Referenced by main().

Variable Documentation

◆ example

const char example[] = "three.smf"
static

Definition at line 11 of file smf_test.cpp.

Referenced by test_read_nodes(), and test_read_triangles().