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. More... | |
virtual ErrorCode | leaf (EntityHandle node) |
Process a leaf node during tree traversal. More... | |
![]() | |
virtual | ~Op () |
Private Attributes | |
OrientedBoxTreeTool * | tool |
const CartVect | ray_origin |
const CartVect | ray_direction |
OrientedBoxTreeTool::IntersectSearchWindow & | search_win |
const double | tol |
OrientedBoxTreeTool::IntRegCtxt & | int_reg_callback |
int * | surfTriOrient |
int | surfTriOrient_val |
unsigned int * | raytri_test_count |
EntityHandle | lastSet |
int | lastSetDepth |
Definition at line 888 of file OrientedBoxTreeTool.cpp.
|
inline |
Definition at line 911 of file OrientedBoxTreeTool.cpp.
918 : tool( tool_ptr ), ray_origin( ray_point ), ray_direction( unit_ray_dir ), search_win( win ), tol( tolerance ),
919 int_reg_callback( intRegCallback ), surfTriOrient_val( 0 ), raytri_test_count( ray_tri_test_count ),
920 lastSet( 0 ), lastSetDepth( 0 )
921 {
922
923 // specified orientation should be 1 or -1, indicating ray and surface
924 // normal in the same or opposite directions, respectively.
925 if( int_reg_callback.getDesiredOrient() )
926 {
927 surfTriOrient = &surfTriOrient_val;
928 }
929 else
930 {
931 surfTriOrient = NULL;
932 }
933
934 // check the limits
935 if( search_win.first )
936 {
937 assert( 0 <= *( search_win.first ) );
938 }
939 if( search_win.second )
940 {
941 assert( 0 >= *( search_win.second ) );
942 }
943 };
References moab::OrientedBoxTreeTool::IntRegCtxt::getDesiredOrient().
|
virtual |
Process a leaf node during tree traversal.
Implements moab::OrientedBoxTreeTool::Op.
Definition at line 981 of file OrientedBoxTreeTool.cpp.
982 {
983 assert( lastSet );
984 if( !lastSet ) // if no surface has been visited yet, something's messed up.
985 return MB_FAILURE;
986
987 #ifndef MB_OBB_USE_VECTOR_QUERIES
988 Range tris;
989 #ifdef MB_OBB_USE_TYPE_QUERIES
990 ErrorCode rval = tool->get_moab_instance()->get_entities_by_type( node, MBTRI, tris );
991 #else
992 ErrorCode rval = tool->get_moab_instance()->get_entities_by_handle( node, tris );
993 #endif
994 #else
995 std::vector< EntityHandle > tris;
996 ErrorCode rval = tool->get_moab_instance()->get_entities_by_handle( node, tris );
997 #endif
998 assert( MB_SUCCESS == rval );
999 if( MB_SUCCESS != rval ) return rval;
1000
1001 #ifndef MB_OBB_USE_VECTOR_QUERIES
1002 for( Range::iterator t = tris.begin(); t != tris.end(); ++t )
1003 #else
1004 for( std::vector< EntityHandle >::iterator t = tris.begin(); t != tris.end(); ++t )
1005 #endif
1006 {
1007 #ifndef MB_OBB_USE_TYPE_QUERIES
1008 if( TYPE_FROM_HANDLE( *t ) != MBTRI ) continue;
1009 #endif
1010
1011 const EntityHandle* conn;
1012 int num_conn;
1013 rval = tool->get_moab_instance()->get_connectivity( *t, conn, num_conn, true );
1014 assert( MB_SUCCESS == rval );
1015 if( MB_SUCCESS != rval ) return rval;
1016
1017 CartVect coords[3];
1018 rval = tool->get_moab_instance()->get_coords( conn, 3, coords[0].array() );
1019 assert( MB_SUCCESS == rval );
1020 if( MB_SUCCESS != rval ) return rval;
1021
1022 if( raytri_test_count ) *raytri_test_count += 1;
1023
1024 double int_dist;
1025 GeomUtil::intersection_type int_type = GeomUtil::NONE;
1026
1027 if( GeomUtil::plucker_ray_tri_intersect( coords, ray_origin, ray_direction, int_dist, search_win.first,
1028 search_win.second, surfTriOrient, &int_type ) )
1029 {
1030 int_reg_callback.register_intersection( lastSet, *t, int_dist, search_win, int_type );
1031 }
1032 }
1033 return MB_SUCCESS;
1034 }
References moab::Range::begin(), moab::Range::end(), ErrorCode, MB_SUCCESS, MBTRI, moab::GeomUtil::NONE, moab::GeomUtil::plucker_ray_tri_intersect(), and moab::TYPE_FROM_HANDLE().
|
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.
node | The EntityHandle for the entity set for the tree node. |
depth | The current depth in the tree. |
descend | Output: 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.
950 {
951 OrientedBox box;
952 ErrorCode rval = tool->box( node, box );
953 assert( MB_SUCCESS == rval );
954 if( MB_SUCCESS != rval ) return rval;
955
956 descend = box.intersect_ray( ray_origin, ray_direction, tol, search_win.first, search_win.second );
957
958 if( lastSet && depth <= lastSetDepth ) lastSet = 0;
959
960 if( descend && !lastSet )
961 {
962 Range tmp_sets;
963 rval = tool->get_moab_instance()->get_entities_by_type( node, MBENTITYSET, tmp_sets );
964 assert( MB_SUCCESS == rval );
965 if( MB_SUCCESS != rval ) return rval;
966
967 if( !tmp_sets.empty() )
968 {
969 if( tmp_sets.size() > 1 ) return MB_FAILURE;
970 lastSet = *tmp_sets.begin();
971 lastSetDepth = depth;
972
973 rval = int_reg_callback.update_orient( lastSet, surfTriOrient );
974 if( MB_SUCCESS != rval ) return rval;
975 }
976 }
977
978 return MB_SUCCESS;
979 }
References moab::Range::begin(), moab::OrientedBoxTreeTool::box(), moab::Range::empty(), ErrorCode, MB_SUCCESS, MBENTITYSET, and moab::Range::size().
|
private |
Definition at line 899 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 907 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 908 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 894 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 893 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 906 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 895 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 902 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 903 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 896 of file OrientedBoxTreeTool.cpp.
|
private |
Definition at line 892 of file OrientedBoxTreeTool.cpp.