MOAB: Mesh Oriented datABase
(version 5.5.0)
readutil_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 "
Internals.hpp
"
7
#include "
moab/ReadUtilIface.hpp
"
8
#include "
moab/Core.hpp
"
9
#include "
moab/Range.hpp
"
10
11
using namespace
moab
;
12
13
#define CHKERR( A ) \
14
do \
15
{ \
16
if( MB_SUCCESS != ( A ) ) \
17
{ \
18
std::cerr << "Failure (error code "
<< ( A ) << ") at " __FILE__ ":" << __LINE__ << std::endl; \
19
return A; \
20
} \
21
} while( false )
22
23
ErrorCode
gather_related_test
()
24
{
25
// create an entityset structure and test related entities function
26
// sets: A
27
// |
28
// B C
29
// |/ |
30
// D E
31
// if D is passed in to gather_related_ents, A-D should be returned, and E should not be
32
//
33
EntityHandle
A, B, C, D,
E
;
34
Core
mb
;
35
ErrorCode
rval =
mb
.
create_meshset
(
MESHSET_SET
, A );
CHKERR
( rval );
36
rval =
mb
.
create_meshset
(
MESHSET_SET
, B );
CHKERR
( rval );
37
rval =
mb
.
create_meshset
(
MESHSET_SET
, C );
CHKERR
( rval );
38
rval =
mb
.
create_meshset
(
MESHSET_SET
, D );
CHKERR
( rval );
39
rval =
mb
.
create_meshset
(
MESHSET_SET
,
E
);
CHKERR
( rval );
40
41
rval =
mb
.
add_parent_child
( A, B );
CHKERR
( rval );
42
rval =
mb
.
add_parent_child
( B, D );
CHKERR
( rval );
43
rval =
mb
.
add_parent_child
( C, D );
CHKERR
( rval );
44
rval =
mb
.
add_parent_child
( C,
E
);
CHKERR
( rval );
45
46
// now test it
47
ReadUtilIface
* readMeshIface;
48
mb
.Interface::query_interface( readMeshIface );
49
50
Range
init_range, set_range, all_sets( A,
E
);
51
init_range.
insert
( D );
52
rval = readMeshIface->
gather_related_ents
( init_range, set_range );
CHKERR
( rval );
53
54
if
( set_range.
size
() != 4 )
return
MB_FAILURE;
55
all_sets -= set_range;
56
if
( 1 != all_sets.
size
() || *all_sets.
begin
() !=
E
)
return
MB_FAILURE;
57
58
return
MB_SUCCESS
;
59
}
60
61
int
number_tests
= 0;
62
int
number_tests_failed
= 0;
63
#define RUN_TEST( A ) _run_test( ( A ), #A )
64
65
typedef
ErrorCode
( *
TestFunc
)();
66
static
void
_run_test
(
TestFunc
func,
const
char
* func_str )
67
{
68
++
number_tests
;
69
std::cout <<
" "
<< func_str <<
": "
;
70
std::cout.flush();
71
ErrorCode
error
= func();
72
73
if
(
MB_SUCCESS
==
error
)
74
std::cout <<
"Success"
<< std::endl;
75
else
if
( MB_FAILURE ==
error
)
76
std::cout <<
"Failure"
<< std::endl;
77
else
78
{
79
Core
moab
;
80
std::cout <<
"Failed: "
<<
moab
.get_error_string(
error
) << std::endl;
81
}
82
83
if
(
MB_SUCCESS
!=
error
)
84
{
85
++
number_tests_failed
;
86
}
87
}
88
89
int
main
(
int
/*argc*/
,
char
**
/*argv[]*/
)
90
{
91
RUN_TEST
(
gather_related_test
);
92
93
std::cout <<
"\nMB TEST SUMMARY: \n"
94
<<
" Number Tests: "
<<
number_tests
<<
"\n"
95
<<
" Number Successful: "
<<
number_tests
-
number_tests_failed
<<
"\n"
96
<<
" Number Failed: "
<<
number_tests_failed
<<
"\n\n"
;
97
98
return
number_tests_failed
;
99
}
test
io
readutil_test.cpp
Generated on Wed Oct 4 2023 14:20:31 for MOAB: Mesh Oriented datABase by
1.9.1