MOAB: Mesh Oriented datABase  (version 5.4.1)
gqt_pointinvol_test.cpp File Reference
#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_pointinvol_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_point_in ()
int gqt_point_in_vol_dir (double origin[3], double dir[3], int vol_idx)
void gqt_point_in_vol_1 ()
void gqt_point_in_vol_2 ()
void gqt_point_in_vol_3 ()
void gqt_point_in_vol_4 ()
void gqt_point_in_vol_5 ()
void gqt_point_in_vol_6 ()
void gqt_point_on_corner_1 ()
void gqt_point_on_corner_2 ()
void gqt_point_on_corner_3 ()
void gqt_point_on_corner_4 ()
void gqt_point_on_corner_5 ()
void gqt_point_on_corner_6 ()
void gqt_point_on_corner_7 ()
void gqt_point_on_corner_8 ()
int main (int, char **)

Variables

CoreMBI
GeomTopoToolGTT
GeomQueryToolGQT
const std::string input_file = "unittest/test_geom.h5m"

Define Documentation

#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 19 of file gqt_pointinvol_test.cpp.

#define IS_BUILDING_MB

Definition at line 4 of file gqt_pointinvol_test.cpp.


Function Documentation

void gqt_point_in ( )

Definition at line 41 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, CHECK_ERR, moab::GeomTopoTool::entity_by_id(), ErrorCode, GQT, moab::GeomQueryTool::gttool(), and moab::GeomQueryTool::point_in_volume().

Referenced by main().

{
    int result          = 0;
    int expected_result = 1;
    double xyz[3]       = { 0.0, 0.0, 0.0 };
    int vol_idx         = 1;
    EntityHandle vol_h  = GQT->gttool()->entity_by_id( 3, vol_idx );
    ErrorCode rval      = GQT->point_in_volume( vol_h, xyz, result );CHECK_ERR( rval );
    CHECK_EQUAL( expected_result, result );
}

Definition at line 79 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    double dir[3]       = { -1.0, 0.0, 0.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };
    int vol_idx         = 1;
    int expected_result = 1;

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );
    CHECK_EQUAL( expected_result, result );
}

Definition at line 90 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 1.0, 0.0, 0.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 102 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 0.0, -1.0, 0.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 114 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 0.0, 1.0, 0.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 126 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 0.0, 0.0, -1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 138 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 0.0, 0.0, 1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}
int gqt_point_in_vol_dir ( double  origin[3],
double  dir[3],
int  vol_idx 
)

Definition at line 52 of file gqt_pointinvol_test.cpp.

References CHECK_ERR, moab::GeomTopoTool::entity_by_id(), ErrorCode, GQT, moab::GeomQueryTool::gttool(), moab::GeomQueryTool::point_in_volume(), and moab::GeomQueryTool::ray_fire().

Referenced by gqt_point_in_vol_1(), gqt_point_in_vol_2(), gqt_point_in_vol_3(), gqt_point_in_vol_4(), gqt_point_in_vol_5(), gqt_point_in_vol_6(), gqt_point_on_corner_1(), gqt_point_on_corner_2(), gqt_point_on_corner_3(), gqt_point_on_corner_4(), gqt_point_on_corner_5(), gqt_point_on_corner_6(), gqt_point_on_corner_7(), and gqt_point_on_corner_8().

{
    int result         = 0;
    EntityHandle vol_h = GQT->gttool()->entity_by_id( 3, vol_idx );
    double xyz[3];
    double next_surf_dist;
    EntityHandle next_surf;

    // normalise the vector
    double dir_norm = ( dir[0] * dir[0] ) + ( dir[1] * dir[1] ) + ( dir[2] * dir[2] );

    dir[0] = dir[0] / sqrt( dir_norm );
    dir[1] = dir[1] / sqrt( dir_norm );
    dir[2] = dir[2] / sqrt( dir_norm );

    ErrorCode rval = GQT->ray_fire( vol_h, origin, dir, next_surf, next_surf_dist );CHECK_ERR( rval );

    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] );

    std::cout << xyz[0] << " " << xyz[1] << " " << xyz[2] << std::endl;

    rval = GQT->point_in_volume( vol_h, xyz, result, dir );CHECK_ERR( rval );
    return result;
}

Definition at line 150 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 1.0, 1.0, 1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 162 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { -1.0, 1.0, 1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 174 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 1.0, 1.0, -1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 186 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

Referenced by main().

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { -1.0, 1.0, -1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 198 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 1.0, -1.0, 1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 210 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { -1.0, -1.0, 1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 222 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { 1.0, -1.0, -1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}

Definition at line 234 of file gqt_pointinvol_test.cpp.

References CHECK_EQUAL, FindVolTestResult::dir, gqt_point_in_vol_dir(), and origin.

{
    int expected_result = 1;
    int vol_idx         = 1;
    double dir[3]       = { -1.0, -1.0, -1.0 };
    double origin[3]    = { 0.0, 0.0, 0.0 };

    int result = gqt_point_in_vol_dir( origin, dir, vol_idx );

    CHECK_EQUAL( expected_result, result );
}
void gqt_setup_test ( )

Definition at line 31 of file gqt_pointinvol_test.cpp.

References CHECK_ERR, ErrorCode, GQT, GTT, moab::GeomQueryTool::initialize(), input_file, and MBI.

Referenced by main().

{
    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 246 of file gqt_pointinvol_test.cpp.

References GQT, gqt_point_in(), gqt_point_in_vol_1(), gqt_point_in_vol_2(), gqt_point_in_vol_3(), gqt_point_in_vol_4(), gqt_point_in_vol_5(), gqt_point_in_vol_6(), gqt_point_on_corner_1(), gqt_point_on_corner_2(), gqt_point_on_corner_3(), gqt_point_on_corner_4(), gqt_setup_test(), GTT, MBI, and RUN_TEST.

{
    int result = 0;

    result += RUN_TEST( gqt_setup_test );  // setup problem
    result += RUN_TEST( gqt_point_in );    // point in centre
    // rays fired along cardinal directions
    result += RUN_TEST( gqt_point_in_vol_1 );  // point in centre
    result += RUN_TEST( gqt_point_in_vol_2 );  // point in centre
    result += RUN_TEST( gqt_point_in_vol_3 );  // point in centre
    result += RUN_TEST( gqt_point_in_vol_4 );  // point in centre
    result += RUN_TEST( gqt_point_in_vol_5 );  // point in centre
    result += RUN_TEST( gqt_point_in_vol_6 );  // point in centre
    // rays fired at nodes
    result += RUN_TEST( gqt_point_on_corner_1 );
    result += RUN_TEST( gqt_point_on_corner_2 );
    result += RUN_TEST( gqt_point_on_corner_3 );
    result += RUN_TEST( gqt_point_on_corner_4 );

    // result += RUN_TEST(dagmc_point_in({0.0, 0.0, 5.0}); // point in centre
    // result += RUN_TEST(dagmc_point_in({0.0, 0.0, -5.0}); // point in centre
    // result += RUN_TEST(dagmc_point_in({0.0, 5.0, 0.0}); // point in centre
    // result += RUN_TEST(dagmc_point_in({0.0, -5.0, 0.0}); // point in centre
    // result += RUN_TEST(dagmc_point_in({5.0, 0.0, 0.0}); // point in centre
    // result += RUN_TEST(dagmc_point_in({-5.0, 0.0, 0.0}); // point in centre

    delete GQT;
    delete GTT;
    delete MBI;

    return result;
}

Variable Documentation

Definition at line 17 of file gqt_pointinvol_test.cpp.

Definition at line 16 of file gqt_pointinvol_test.cpp.

const std::string input_file = "unittest/test_geom.h5m"

Definition at line 29 of file gqt_pointinvol_test.cpp.

Definition at line 15 of file gqt_pointinvol_test.cpp.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines