|
MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <iostream>#include "moab/Interface.hpp"#include "TestUtil.hpp"#include "Internals.hpp"#include "moab/Core.hpp"#include "moab/GeomQueryTool.hpp"#include "moab/GeomTopoTool.hpp"
Include dependency graph for gqt_findvol_test.cpp:Go to the source code of this file.
Classes | |
| struct | FindVolTestResult |
Defines | |
| #define | IS_BUILDING_MB |
Functions | |
| void | find_volume_tests () |
| int | main () |
| ErrorCode | id_lookup (EntityHandle eh, int &id) |
Variables | |
| Core * | MBI |
| GeomTopoTool * | GTT |
| GeomQueryTool * | GQT |
| Tag | id_tag = 0 |
| const std::string | input_file = "unittest/find_vol_test_geom.h5m" |
| #define IS_BUILDING_MB |
Definition at line 4 of file gqt_findvol_test.cpp.
| void find_volume_tests | ( | ) |
Definition at line 101 of file gqt_findvol_test.cpp.
References CHECK, FindVolTestResult::dir, ErrorCode, moab::GeomQueryTool::find_volume(), moab::GeomTopoTool::get_one_vol_root(), GQT, GTT, id_lookup(), MB_CHK_SET_ERR_CONT, MB_ENTITY_NOT_FOUND, num_tests, FindVolTestResult::pnt, FindVolTestResult::resultA, FindVolTestResult::resultB, and test.
Referenced by main().
{
ErrorCode rval;
const struct FindVolTestResult tests[] = {
// one point unambiguously placed in each volume
// and the implicit complement
{ { -0.1, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 2, 4 }, // 1
{ { 0.6, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 3, 4 }, // 2
{ { 3.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 1, -1 }, // 3
{ { -5.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 0, -1 }, // 4
// Point on the negative side of the geometry
{ { -5.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, 0, -1 }, // 5
{ { -5.0, 0.0, 0.0 }, { -1.0, 0.0, 0.0 }, 0, -1 }, // 6
// Point on the positive side of the geometry
{ { 10.0, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 0, -1 }, // 7
{ { 10.0, 0.0, 0.0 }, { -1.0, 0.0, 0.0 }, 0, -1 }, // 8
{ { 10.0, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, 0, -1 }, // 9
// Point between the volumes
{ { 1.5, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 0, 4 }, // 10
{ { 1.5, 0.0, 0.0 }, { -1.0, 0.0, 0.0 }, 4, -1 }, // 11
{ { 1.5, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, 4, -1 }, // 12
{ { 1.5, 0.0, 0.0 }, { 0.0, 1.0, 0.0 }, 0, -1 }, // 13
// Point in the overlap of vols 2 & 3
{ { 0.4, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 2, 3 }, // 14
{ { 0.4, 0.0, 0.0 }, { -1.0, 0.0, 0.0 }, 2, 3 }, // 15
{ { 0.4, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, 2, 3 }, // 16
// Point in Vol 3 w/ different directions applied
{ { 0.6, 0.0, 0.0 }, { 0.0, 0.0, 0.0 }, 3, 4 }, // 17
{ { 0.6, 0.0, 0.0 }, { -1.0, 0.0, 0.0 }, 3, 4 }, // 18
{ { 0.6, 0.0, 0.0 }, { 1.0, 0.0, 0.0 }, 3, 4 }, // 19
// Point on surface of volume 1 w/ tangent direction
{ { 3.0, 0.5, 0.0 }, { 1.0, 0.0, 0.0 }, 1, -1 }, // 20
{ { 3.0, 0.5, 0.0 }, { -1.0, 0.0, 0.0 }, 1, -1 }, // 21
// Point on surface of volume 1 w/ non-tangent direction
{ { 3.0, 0.5, 0.0 }, { 0.0, 1.0, 0.0 }, 1, -1 }, // 22
{ { 3.0, 0.5, 0.0 }, { 0.0, -1.0, 0.0 }, 4, -1 }, // 23
// Checks that the neg ray distance doesn't affect results
// Location: Positive Y Surface of Volume 2
{ { 0.6, 0.25000000000001, 0.0 }, { 0.0, 1.0, 0.0 }, 4, 0 }, // 24
{ { 0.6, 0.25000000000001, 0.0 }, { 0.0, -1.0, 0.0 }, 4, -1 }, // 25
// ON-SURFACE POINT TESTS (not checked using PIV loop)
// Point on surface of volume 1 w/ random directions
{ { 3.0, 0.5, 0.0 }, { 0.0, 0.0, 0.0 }, 1, 4 }, // 26
// Point on surface of volume 2 w/ random directions
{ { 0.6, 0.23, 0.0 }, { 0.0, 0.0, 0.0 }, 3, 4 } // 27
};
int num_tests = sizeof( tests ) / sizeof( FindVolTestResult );
EntityHandle volume_found;
int vol_id;
bool using_find_volume_slow = GTT->get_one_vol_root() == 0;
// Skip the last two tests
if( using_find_volume_slow )
{
std::cout << "Skipping last two tests when"
<< "using find_volume_slow (PIV loop)" << std::endl;
num_tests -= 2;
}
for( int i = 1; i < num_tests + 1; i++ )
{
const FindVolTestResult& test = tests[i - 1];
const double* direction = NULL;
if( test.dir[0] != 0.0 || test.dir[1] != 0.0 || test.dir[2] != 0.0 )
{
direction = test.dir;
}
// if we're testing a random direction, run the test many times
int num_repeats = direction ? 1 : 100;
for( int j = 0; j < num_repeats; j++ )
{
rval = GQT->find_volume( test.pnt, volume_found, direction );
// if not found, we will check later
if( rval != MB_ENTITY_NOT_FOUND )
{
MB_CHK_SET_ERR_CONT( rval, "Failed in find_volume" );
}
rval = id_lookup( volume_found, vol_id );MB_CHK_SET_ERR_CONT( rval, "Failed in id lookup" );
std::cout << "Test " << i << ". Volume found id: " << vol_id << "\n";
// make sure at least one of these checks passed
CHECK( vol_id == test.resultA || vol_id == test.resultB );
// reset result and id for safety
volume_found = 0;
vol_id = -1;
} // repeat loop
} // test loop
}
| ErrorCode id_lookup | ( | EntityHandle | eh, |
| int & | id | ||
| ) |
Definition at line 51 of file gqt_findvol_test.cpp.
References ErrorCode, id_tag, MB_CHK_SET_ERR, MB_SUCCESS, and MBI.
Referenced by find_volume_tests().
{
ErrorCode rval;
if( !id_tag )
{
id_tag = MBI->globalId_tag();
}
rval = MBI->tag_get_data( id_tag, &eh, 1, (void*)&id );MB_CHK_SET_ERR( rval, "Failed to lookup volume id" );
return MB_SUCCESS;
}
| int main | ( | ) |
Definition at line 25 of file gqt_findvol_test.cpp.
References moab::GeomTopoTool::construct_obb_trees(), ErrorCode, find_volume_tests(), GQT, GTT, moab::GeomQueryTool::initialize(), input_file, MB_CHK_SET_ERR, MBI, and RUN_TEST.
{
MBI = new Core();
ErrorCode rval = MBI->load_file( input_file.c_str() );MB_CHK_SET_ERR( rval, "Failed to load test file" );
GTT = new GeomTopoTool( MBI );
GQT = new GeomQueryTool( GTT );
// initialize the rest of the GQT
GQT->initialize();
int result = 0;
// with no global OBB tree (will defer to find_volume_slow)
result += RUN_TEST( find_volume_tests );
// build OBBs with one-vol tree
GTT->construct_obb_trees( true );
// using the global OBB tree
result += RUN_TEST( find_volume_tests );
return result;
}
Definition at line 17 of file gqt_findvol_test.cpp.
Referenced by cleanup(), find_volume_tests(), gqt_build_obb(), gqt_closest_to(), gqt_create_impl_compl(), gqt_load_file(), gqt_load_file_dagmc_build_obb(), gqt_load_file_dagmc_internal_build_obb(), gqt_load_file_dagmc_via_moab_build_obb(), gqt_num_vols(), gqt_origin_face_rayfire(), gqt_outside_face_rayfire(), gqt_outside_face_rayfire_history(), gqt_outside_face_rayfire_history_fail(), gqt_outside_face_rayfire_orient_entrance(), gqt_outside_face_rayfire_orient_exit(), gqt_point_in(), gqt_point_in_box_1(), gqt_point_in_box_2(), gqt_point_in_box_3(), gqt_point_in_box_4(), gqt_point_in_box_5(), gqt_point_in_vol_dir(), gqt_rayfire(), gqt_setup_test(), gqt_test_boundary(), gqt_test_obb_retreval(), gqt_test_obb_retreval_rayfire(), main(), and moab::GeomTopoTool::restore_topology_from_geometric_inclusion().
Definition at line 16 of file gqt_findvol_test.cpp.
Referenced by build_cube(), cleanup(), find_volume_tests(), gqt_load_file(), gqt_load_file_dagmc_build_obb(), gqt_load_file_dagmc_internal_build_obb(), gqt_load_file_dagmc_via_moab_build_obb(), gqt_point_in(), gqt_rayfire(), gqt_setup_test(), gqt_test_obb_retreval(), gqt_test_obb_retreval_rayfire(), heappermute(), and main().
Definition at line 19 of file gqt_findvol_test.cpp.
Referenced by moab::ReadNASTRAN::assign_ids(), build_cube(), check_consistent_ids(), check_tree(), compare_sets(), moab::ReadIDEAS::create_elements(), create_mesh(), create_mesh_in_memory(), moab::ReadIDEAS::create_vertices(), geom_id_by_handle(), get_all_handles(), get_entities(), id_lookup(), moab::ReadParallel::load_file(), main(), make_set(), overlap_write_geometry(), parallel_create_mesh(), print_partitioned_entities(), quads_to_tris(), moab::ReadTetGen::read_elem_file(), moab::ParallelComm::resolve_shared_ents(), test_assign_global_ids(), test_check_groups(), test_elements_on_several_procs(), test_gather_sets_common(), test_gather_sets_ranged(), test_ghost_elements(), test_meshset_tags_1(), test_meshset_tags_2(), test_push_tag_data_common(), test_read_adjacencies(), test_read_containing_sets(), test_read_geom_set(), test_read_nodes(), test_read_nodes_common(), test_read_nothing_common(), test_read_one_set_polyhedra(), test_read_quads(), test_read_set_sets(), test_read_sides(), test_sequences_after_ghosting(), test_shared_sets(), and write_geometry().
| const std::string input_file = "unittest/find_vol_test_geom.h5m" |
Definition at line 21 of file gqt_findvol_test.cpp.
Definition at line 15 of file gqt_findvol_test.cpp.