MOAB: Mesh Oriented datABase  (version 5.5.0)
read_obj_test.cpp File Reference
#include <iostream>
#include "moab/Interface.hpp"
#include "TestUtil.hpp"
#include "Internals.hpp"
#include "moab/Core.hpp"
#include "MBTagConventions.hpp"
#include "moab/Types.hpp"
#include "moab/GeomTopoTool.hpp"
+ Include dependency graph for read_obj_test.cpp:

Go to the source code of this file.

Macros

#define CHKERR(A)
 

Functions

void read_file (Interface &moab, const char *input_file)
 
void test_check_num_entities ()
 
void test_check_meshsets ()
 
void test_check_groups ()
 
int main ()
 

Variables

std::string test = TestDir + "unittest/io/test.obj"
 
std::string shuttle = TestDir + "unittest/io/shuttle.obj"
 
GeomTopoToolmyGeomTool
 
Tag geom_tag
 
Tag name_tag
 
Tag id_tag
 

Macro Definition Documentation

◆ CHKERR

#define CHKERR (   A)
Value:
do \
{ \
if( MB_SUCCESS != ( A ) ) \
{ \
std::cerr << "Failure (error code " << ( A ) << ") at " __FILE__ ":" << __LINE__ << std::endl; \
return A; \
} \
} while( false )

Definition at line 12 of file read_obj_test.cpp.

Function Documentation

◆ main()

int main ( )

Definition at line 36 of file read_obj_test.cpp.

37 {
38  int result = 0;
39 
40  result += RUN_TEST( test_check_num_entities );
41  result += RUN_TEST( test_check_meshsets );
42  result += RUN_TEST( test_check_groups );
43 
44  return result;
45 }

References RUN_TEST, test_check_groups(), test_check_meshsets(), and test_check_num_entities().

◆ read_file()

void read_file ( Interface moab,
const char *  input_file 
)

Definition at line 47 of file read_obj_test.cpp.

48 {
49  ErrorCode rval = moab.load_file( input_file );CHECK_ERR( rval );
50 }

References CHECK_ERR, ErrorCode, and input_file.

Referenced by test_check_groups(), test_check_meshsets(), and test_check_num_entities().

◆ test_check_groups()

void test_check_groups ( )

Definition at line 125 of file read_obj_test.cpp.

126 {
127  ErrorCode rval;
128  Core core;
129  Interface* mbi = &core;
130  read_file( core, shuttle.c_str() );
131 
132  // check that number of tris created is 616
133  // 170 tris + 223 quads split into 2 tris = 616
134  Range tris;
135  int tri_dim = 2;
136  rval = mbi->get_entities_by_dimension( 0, tri_dim, tris );CHECK_ERR( rval );
137  CHECK_EQUAL( 616, (int)tris.size() );
138 
139  // check that 11 mesh sets are created
140  // 1 for global vert set + 1 for each of 10 groups
141  Range ent_sets, mesh_sets;
142  id_tag = mbi->globalId_tag();
143  rval = mbi->get_entities_by_type_and_tag( 0, MBENTITYSET, &id_tag, NULL, 1, ent_sets );
144 
145  CHECK_EQUAL( 11, (int)ent_sets.size() );
146 }

References CHECK_EQUAL, CHECK_ERR, ErrorCode, moab::Interface::get_entities_by_dimension(), moab::Interface::get_entities_by_type_and_tag(), moab::Interface::globalId_tag(), id_tag, MBENTITYSET, read_file(), shuttle, and moab::Range::size().

Referenced by main().

◆ test_check_meshsets()

void test_check_meshsets ( )

Definition at line 72 of file read_obj_test.cpp.

73 {
74  ErrorCode rval;
75  Core core;
76  Interface* mbi = &core;
77  read_file( core, test.c_str() );
78 
79  myGeomTool = new GeomTopoTool( mbi );
80 
81  Range ent_sets;
83  rval = mbi->get_entities_by_type_and_tag( 0, MBENTITYSET, &geom_tag, NULL, 1, ent_sets );CHECK_ERR( rval );
84 
85  Range::iterator it;
86  Range parents, children;
87  int sense;
88  int dim, num_surfs = 0, num_vols = 0;
89 
90  for( it = ent_sets.begin(); it != ent_sets.end(); ++it )
91  {
92  rval = mbi->tag_get_data( geom_tag, &( *it ), 1, &dim );
93 
94  if( dim == 2 )
95  {
96  num_surfs++;
97 
98  // check that one parent is created for each surface
99  parents.clear();
100  rval = mbi->get_parent_meshsets( *it, parents );CHECK_ERR( rval );
101  CHECK_EQUAL( 1, (int)parents.size() );
102 
103  // check that sense of surface wrt parent is FORWARD = 1
104  rval = myGeomTool->get_sense( *it, *parents.begin(), sense );CHECK_ERR( rval );
105  CHECK_EQUAL( 1, sense );
106  }
107  else if( dim == 3 )
108  {
109  num_vols++;
110 
111  // check that one child is created for each volume
112  children.clear();
113  rval = mbi->get_child_meshsets( *it, children );CHECK_ERR( rval );
114  CHECK_EQUAL( 1, (int)children.size() );
115  }
116  }
117 
118  // check that two surfaces and two volumes are created
119  CHECK_EQUAL( 2, num_surfs );
120  CHECK_EQUAL( 2, num_vols );
121 
122  delete myGeomTool;
123 }

References moab::Range::begin(), CHECK_EQUAL, CHECK_ERR, children, moab::Range::clear(), dim, moab::Range::end(), ErrorCode, GEOM_DIMENSION_TAG_NAME, geom_tag, moab::Interface::get_child_meshsets(), moab::Interface::get_entities_by_type_and_tag(), moab::Interface::get_parent_meshsets(), moab::GeomTopoTool::get_sense(), MB_TYPE_INTEGER, MBENTITYSET, myGeomTool, read_file(), moab::Range::size(), moab::Interface::tag_get_data(), moab::Interface::tag_get_handle(), and test.

Referenced by main().

◆ test_check_num_entities()

void test_check_num_entities ( )

Definition at line 52 of file read_obj_test.cpp.

53 {
54  ErrorCode rval;
55  Core core;
56  Interface* mbi = &core;
57  read_file( core, test.c_str() );
58 
59  // check that number of verts created is 7
60  Range verts;
61  int vert_dim = 0;
62  rval = mbi->get_entities_by_dimension( 0, vert_dim, verts );CHECK_ERR( rval );
63  CHECK_EQUAL( 7, (int)verts.size() );
64 
65  // check that number of tris created is 3
66  Range tris;
67  int tri_dim = 2;
68  rval = mbi->get_entities_by_dimension( 0, tri_dim, tris );CHECK_ERR( rval );
69  CHECK_EQUAL( 3, (int)tris.size() );
70 }

References CHECK_EQUAL, CHECK_ERR, ErrorCode, moab::Interface::get_entities_by_dimension(), read_file(), moab::Range::size(), and test.

Referenced by main().

Variable Documentation

◆ geom_tag

◆ id_tag

Tag id_tag

Definition at line 29 of file read_obj_test.cpp.

Referenced by test_check_groups().

◆ myGeomTool

GeomTopoTool* myGeomTool

Definition at line 25 of file read_obj_test.cpp.

Referenced by test_check_meshsets().

◆ name_tag

Tag name_tag

Definition at line 28 of file read_obj_test.cpp.

Referenced by moab::Tqdcfr::parse_acis_attribs(), and read_cylcube_groups_test().

◆ shuttle

std::string shuttle = TestDir + "unittest/io/shuttle.obj"

Definition at line 23 of file read_obj_test.cpp.

Referenced by test_check_groups().

◆ test