|
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_rayfire_test.cpp:Go to the source code of this file.
Defines | |
| #define | IS_BUILDING_MB |
| #define | CHKERR(A) |
Functions | |
| void | gqt_setup_test () |
| void | gqt_origin_face_rayfire () |
| void | gqt_outside_face_rayfire () |
| void | gqt_outside_face_rayfire_orient_exit () |
| void | gqt_outside_face_rayfire_orient_entrance () |
| void | gqt_outside_face_rayfire_history_fail () |
| void | gqt_outside_face_rayfire_history () |
| int | main (int, char **) |
Variables | |
| Interface * | MBI |
| GeomTopoTool * | GTT |
| GeomQueryTool * | GQT |
| const std::string | input_file = "unittest/test_geom.h5m" |
| double | eps = 1.0e-6 |
| #define CHKERR | ( | A | ) |
do \ { \ if( MB_SUCCESS != ( A ) ) \ { \ std::cerr << "Failure (error code " << ( A ) << ") at " __FILE__ ":" << __LINE__ << std::endl; \ return A; \ } \ } while( false )
Definition at line 20 of file gqt_rayfire_test.cpp.
| #define IS_BUILDING_MB |
Definition at line 4 of file gqt_rayfire_test.cpp.
| void gqt_origin_face_rayfire | ( | ) |
Definition at line 43 of file gqt_rayfire_test.cpp.
References CHECK_REAL_EQUAL, FindVolTestResult::dir, moab::GeomTopoTool::entity_by_id(), eps, GQT, moab::GeomQueryTool::gttool(), origin, and moab::GeomQueryTool::ray_fire().
Referenced by main().
{
int vol_idx = 1;
EntityHandle vol_h = GQT->gttool()->entity_by_id( 3, vol_idx );
double dir[3] = { -1.0, 0.0, 0.0 };
double origin[3] = { 0.0, 0.0, 0.0 };
double next_surf_dist;
EntityHandle next_surf;
GQT->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist );
double expected_next_surf_dist = 5.0;
CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
}
| void gqt_outside_face_rayfire | ( | ) |
Definition at line 56 of file gqt_rayfire_test.cpp.
References CHECK_REAL_EQUAL, FindVolTestResult::dir, moab::GeomTopoTool::entity_by_id(), eps, GQT, moab::GeomQueryTool::gttool(), origin, and moab::GeomQueryTool::ray_fire().
Referenced by main().
{
int vol_idx = 1;
EntityHandle vol_h = GQT->gttool()->entity_by_id( 3, vol_idx );
double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
double next_surf_dist;
EntityHandle next_surf;
GQT->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist );
std::cout << next_surf_dist << std::endl;
double expected_next_surf_dist = 15.0;
CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
}
| void gqt_outside_face_rayfire_history | ( | ) |
Definition at line 128 of file gqt_rayfire_test.cpp.
References CHECK_EQUAL, FindVolTestResult::dir, moab::GeomTopoTool::entity_by_id(), GQT, moab::GeomQueryTool::gttool(), origin, moab::GeomQueryTool::ray_fire(), moab::GeomQueryTool::RayHistory::reset(), and moab::GeomQueryTool::RayHistory::size().
Referenced by main().
{
GeomQueryTool::RayHistory history;
int vol_idx = 1;
EntityHandle vol_h = GQT->gttool()->entity_by_id( 3, vol_idx );
double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
double xyz[3];
double next_surf_dist;
EntityHandle next_surf;
history.reset();
// first ray fire with history
GQT->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
std::cout << next_surf << " " << history.size() << std::endl;
// second ray fire with history
xyz[0] = origin[0] + ( next_surf_dist * dir[0] );
xyz[1] = origin[1] + ( next_surf_dist * dir[1] );
xyz[2] = origin[2] + ( next_surf_dist * dir[2] );
// ray fired execacyl
GQT->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
GQT->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
// using history with this geom, there should be no next surface, i.e. 0
EntityHandle ZERO = 0;
CHECK_EQUAL( ZERO, next_surf );
}
Definition at line 100 of file gqt_rayfire_test.cpp.
References CHECK_EQUAL, FindVolTestResult::dir, moab::GeomTopoTool::entity_by_id(), GQT, moab::GeomQueryTool::gttool(), origin, moab::GeomQueryTool::ray_fire(), and moab::GeomQueryTool::RayHistory::reset().
Referenced by main().
{
GeomQueryTool::RayHistory history;
int vol_idx = 1;
EntityHandle vol_h = GQT->gttool()->entity_by_id( 3, vol_idx );
double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
double xyz[3];
double next_surf_dist;
EntityHandle next_surf;
history.reset();
// ray fired exactly along boundary shared by 2 facets on a single surface,
// needs two ray_fires to cross, this is expected and ok
// first ray fire with history
GQT->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
// second ray fire with history
GQT->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
// this fire should hit graveyard, i.e. next_surf = 0
GQT->ray_fire( vol_h, xyz, dir, next_surf, next_surf_dist, &history, 0, 1 );
// using history with this geom, there should be no next surface, i.e. 0
EntityHandle ZERO = 0;
CHECK_EQUAL( ZERO, next_surf );
}
Definition at line 85 of file gqt_rayfire_test.cpp.
References CHECK_REAL_EQUAL, FindVolTestResult::dir, moab::GeomTopoTool::entity_by_id(), eps, GQT, moab::GeomQueryTool::gttool(), origin, and moab::GeomQueryTool::ray_fire().
Referenced by main().
{
GeomQueryTool::RayHistory history;
int vol_idx = 1;
EntityHandle vol_h = GQT->gttool()->entity_by_id( 3, vol_idx );
double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
double next_surf_dist;
EntityHandle next_surf;
GQT->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0.0, -1 );
std::cout << next_surf_dist << std::endl;
double expected_next_surf_dist = 5.0;
CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
}
| void gqt_outside_face_rayfire_orient_exit | ( | ) |
Definition at line 70 of file gqt_rayfire_test.cpp.
References CHECK_REAL_EQUAL, FindVolTestResult::dir, moab::GeomTopoTool::entity_by_id(), eps, GQT, moab::GeomQueryTool::gttool(), origin, and moab::GeomQueryTool::ray_fire().
Referenced by main().
{
GeomQueryTool::RayHistory history;
int vol_idx = 1;
EntityHandle vol_h = GQT->gttool()->entity_by_id( 3, vol_idx );
double dir[3] = { 1.0, 0.0, 0.0 }; // ray along x direction
double origin[3] = { -10.0, 0.0, 0.0 }; // origin at -10 0 0
double next_surf_dist;
EntityHandle next_surf;
GQT->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist, &history, 0, 1 );
std::cout << next_surf_dist << std::endl;
double expected_next_surf_dist = 15.0;
CHECK_REAL_EQUAL( expected_next_surf_dist, next_surf_dist, eps );
}
| void gqt_setup_test | ( | ) |
Definition at line 34 of file gqt_rayfire_test.cpp.
References CHECK_ERR, ErrorCode, GQT, GTT, moab::GeomQueryTool::initialize(), input_file, and MBI.
{
MBI = new Core();
ErrorCode rval = MBI->load_file( input_file.c_str() );CHECK_ERR( rval );
GTT = new GeomTopoTool( MBI );
GQT = new GeomQueryTool( GTT );
rval = GQT->initialize();CHECK_ERR( rval );
}
| int main | ( | int | , |
| char ** | |||
| ) |
Definition at line 160 of file gqt_rayfire_test.cpp.
References GQT, 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_setup_test(), GTT, MBI, and RUN_TEST.
{
int result = 0;
result += RUN_TEST( gqt_setup_test ); // setup problem
// rays fired along cardinal directions
result += RUN_TEST( gqt_origin_face_rayfire ); // point in centre
result += RUN_TEST( gqt_outside_face_rayfire );
result += RUN_TEST( gqt_outside_face_rayfire_orient_exit ); // fire ray from point outside volume
// looking for exit intersections
result += RUN_TEST( gqt_outside_face_rayfire_orient_entrance ); // fire ray from point outside volume
// looking for entrance intersection
result += RUN_TEST( gqt_outside_face_rayfire_history_fail ); // fire ray from point outside
// geometry using ray history
result += RUN_TEST( gqt_outside_face_rayfire_history ); // fire ray from point outside geometry
// using ray history
delete GQT;
delete GTT;
delete MBI;
return result;
}
| double eps = 1.0e-6 |
Definition at line 32 of file gqt_rayfire_test.cpp.
Definition at line 18 of file gqt_rayfire_test.cpp.
Definition at line 17 of file gqt_rayfire_test.cpp.
| const std::string input_file = "unittest/test_geom.h5m" |
Definition at line 30 of file gqt_rayfire_test.cpp.
Definition at line 16 of file gqt_rayfire_test.cpp.