MOAB: Mesh Oriented datABase  (version 5.4.1)
moab::RayIntersectSets Class Reference
+ Inheritance diagram for moab::RayIntersectSets:
+ Collaboration diagram for moab::RayIntersectSets:

Public Member Functions

 RayIntersectSets (OrientedBoxTreeTool *tool_ptr, const double *ray_point, const double *unit_ray_dir, const double tolerance, OrientedBoxTreeTool::IntersectSearchWindow &win, unsigned int *ray_tri_test_count, OrientedBoxTreeTool::IntRegCtxt &intRegCallback)
virtual ErrorCode visit (EntityHandle node, int depth, bool &descend)
 Visit a node in the tree during a traversal.
virtual ErrorCode leaf (EntityHandle node)
 Process a leaf node during tree traversal.

Private Attributes

OrientedBoxTreeTooltool
const CartVect ray_origin
const CartVect ray_direction
OrientedBoxTreeTool::IntersectSearchWindowsearch_win
const double tol
OrientedBoxTreeTool::IntRegCtxtint_reg_callback
int * surfTriOrient
int surfTriOrient_val
unsigned int * raytri_test_count
EntityHandle lastSet
int lastSetDepth

Detailed Description

Definition at line 888 of file OrientedBoxTreeTool.cpp.


Constructor & Destructor Documentation

moab::RayIntersectSets::RayIntersectSets ( OrientedBoxTreeTool tool_ptr,
const double *  ray_point,
const double *  unit_ray_dir,
const double  tolerance,
OrientedBoxTreeTool::IntersectSearchWindow win,
unsigned int *  ray_tri_test_count,
OrientedBoxTreeTool::IntRegCtxt intRegCallback 
) [inline]

Definition at line 911 of file OrientedBoxTreeTool.cpp.

        : tool( tool_ptr ), ray_origin( ray_point ), ray_direction( unit_ray_dir ), search_win( win ), tol( tolerance ),
          int_reg_callback( intRegCallback ), surfTriOrient_val( 0 ), raytri_test_count( ray_tri_test_count ),
          lastSet( 0 ), lastSetDepth( 0 )
    {

        // specified orientation should be 1 or -1, indicating ray and surface
        // normal in the same or opposite directions, respectively.
        if( int_reg_callback.getDesiredOrient() )
        {
            surfTriOrient = &surfTriOrient_val;
        }
        else
        {
            surfTriOrient = NULL;
        }

        // check the limits
        if( search_win.first )
        {
            assert( 0 <= *( search_win.first ) );
        }
        if( search_win.second )
        {
            assert( 0 >= *( search_win.second ) );
        }
    };

Member Function Documentation

Process a leaf node during tree traversal.

Implements moab::OrientedBoxTreeTool::Op.

Definition at line 981 of file OrientedBoxTreeTool.cpp.

References ErrorCode, MB_SUCCESS, MBTRI, NONE, moab::GeomUtil::plucker_ray_tri_intersect(), t, and moab::TYPE_FROM_HANDLE().

{
    assert( lastSet );
    if( !lastSet )  // if no surface has been visited yet, something's messed up.
        return MB_FAILURE;

#ifndef MB_OBB_USE_VECTOR_QUERIES
    Range tris;
#ifdef MB_OBB_USE_TYPE_QUERIES
    ErrorCode rval = tool->get_moab_instance()->get_entities_by_type( node, MBTRI, tris );
#else
    ErrorCode rval = tool->get_moab_instance()->get_entities_by_handle( node, tris );
#endif
#else
    std::vector< EntityHandle > tris;
    ErrorCode rval = tool->get_moab_instance()->get_entities_by_handle( node, tris );
#endif
    assert( MB_SUCCESS == rval );
    if( MB_SUCCESS != rval ) return rval;

#ifndef MB_OBB_USE_VECTOR_QUERIES
    for( Range::iterator t = tris.begin(); t != tris.end(); ++t )
#else
    for( std::vector< EntityHandle >::iterator t = tris.begin(); t != tris.end(); ++t )
#endif
    {
#ifndef MB_OBB_USE_TYPE_QUERIES
        if( TYPE_FROM_HANDLE( *t ) != MBTRI ) continue;
#endif

        const EntityHandle* conn;
        int num_conn;
        rval = tool->get_moab_instance()->get_connectivity( *t, conn, num_conn, true );
        assert( MB_SUCCESS == rval );
        if( MB_SUCCESS != rval ) return rval;

        CartVect coords[3];
        rval = tool->get_moab_instance()->get_coords( conn, 3, coords[0].array() );
        assert( MB_SUCCESS == rval );
        if( MB_SUCCESS != rval ) return rval;

        if( raytri_test_count ) *raytri_test_count += 1;

        double int_dist;
        GeomUtil::intersection_type int_type = GeomUtil::NONE;

        if( GeomUtil::plucker_ray_tri_intersect( coords, ray_origin, ray_direction, int_dist, search_win.first,
                                                 search_win.second, surfTriOrient, &int_type ) )
        {
            int_reg_callback.register_intersection( lastSet, *t, int_dist, search_win, int_type );
        }
    }
    return MB_SUCCESS;
}
ErrorCode moab::RayIntersectSets::visit ( EntityHandle  node,
int  depth,
bool &  descend 
) [virtual]

Visit a node in the tree during a traversal.

This method is called for each node in the tree visited during a pre-order traversal.

Parameters:
nodeThe EntityHandle for the entity set for the tree node.
depthThe current depth in the tree.
descendOutput: if false, traversal will skip children of the current node, or if the current node is a leaf, the 'leaf' method will not be called.

Implements moab::OrientedBoxTreeTool::Op.

Definition at line 949 of file OrientedBoxTreeTool.cpp.

References moab::Range::begin(), moab::OrientedBoxTreeTool::box(), moab::Range::empty(), ErrorCode, moab::OrientedBox::intersect_ray(), MB_SUCCESS, MBENTITYSET, and moab::Range::size().

{
    OrientedBox box;
    ErrorCode rval = tool->box( node, box );
    assert( MB_SUCCESS == rval );
    if( MB_SUCCESS != rval ) return rval;

    descend = box.intersect_ray( ray_origin, ray_direction, tol, search_win.first, search_win.second );

    if( lastSet && depth <= lastSetDepth ) lastSet = 0;

    if( descend && !lastSet )
    {
        Range tmp_sets;
        rval = tool->get_moab_instance()->get_entities_by_type( node, MBENTITYSET, tmp_sets );
        assert( MB_SUCCESS == rval );
        if( MB_SUCCESS != rval ) return rval;

        if( !tmp_sets.empty() )
        {
            if( tmp_sets.size() > 1 ) return MB_FAILURE;
            lastSet      = *tmp_sets.begin();
            lastSetDepth = depth;

            rval = int_reg_callback.update_orient( lastSet, surfTriOrient );
            if( MB_SUCCESS != rval ) return rval;
        }
    }

    return MB_SUCCESS;
}

Member Data Documentation

Definition at line 908 of file OrientedBoxTreeTool.cpp.

Definition at line 894 of file OrientedBoxTreeTool.cpp.

Definition at line 893 of file OrientedBoxTreeTool.cpp.

Definition at line 906 of file OrientedBoxTreeTool.cpp.

Definition at line 902 of file OrientedBoxTreeTool.cpp.

Definition at line 903 of file OrientedBoxTreeTool.cpp.

const double moab::RayIntersectSets::tol [private]

Definition at line 896 of file OrientedBoxTreeTool.cpp.

List of all members.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines