Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
moab::BSPTreeBoxIter Class Reference

Iterate over leaves of a BSPTree. More...

#include <BSPTree.hpp>

+ Inheritance diagram for moab::BSPTreeBoxIter:
+ Collaboration diagram for moab::BSPTreeBoxIter:

Classes

struct  Corners
 

Public Types

enum  SideBits {
  B0154 = 0x33 , B1265 = 0x66 , B2376 = 0xCC , B3047 = 0x99 ,
  B3210 = 0x0F , B4567 = 0xF0
}
 Faces of a hex : corner bitmap. More...
 
enum  XSect { MISS = 0 , SPLIT = 1 , NONHEX = -1 }
 test if a plane intersects the leaf box More...
 
- Public Types inherited from moab::BSPTreeIter
enum  Direction { LEFT = 0 , RIGHT = 1 }
 

Public Member Functions

 BSPTreeBoxIter ()
 
virtual ~BSPTreeBoxIter ()
 
virtual ErrorCode step (Direction direction)
 Advance the iterator either left or right in the tree Note: stepping past the end of the tree will invalidate the iterator. It will not work to subsequently step the other direction. More...
 
ErrorCode step ()
 Advance to next leaf Returns MB_ENTITY_NOT_FOUND if at end. Note: stepping past the end of the tree will invalidate the iterator. Calling back() will not work. More...
 
ErrorCode back ()
 Move back to previous leaf Returns MB_ENTITY_NOT_FOUND if at beginning. Note: stepping past the start of the tree will invalidate the iterator. Calling step() will not work. More...
 
ErrorCode get_box_corners (double coords[8][3]) const
 Get coordinates of box corners, in Exodus II hexahedral ordering. More...
 
double volume () const
 Get volume of leaf box. More...
 
XSect splits (const BSPTree::Plane &plane) const
 
bool intersects (const BSPTree::Plane &plane) const
 test if a plane intersects the leaf box More...
 
bool intersect_ray (const double ray_point[3], const double ray_vect[3], double &t_enter, double &t_exit) const
 Find range of overlap between ray and leaf. More...
 
ErrorCode sibling_side (SideBits &side_out) const
 Return the side of the box bounding this tree node that is shared with the immediately adjacent sibling (the tree node that shares a common parent node with this node in the binary tree.) More...
 
ErrorCode get_neighbors (SideBits side, std::vector< BSPTreeBoxIter > &results, double epsilon=0.0) const
 Get adjacent leaf nodes on indicated side. More...
 
ErrorCode calculate_polyhedron (BSPTreePoly &polyhedron_out) const
 Calculate the convex polyhedron bounding this leaf. More...
 
- Public Member Functions inherited from moab::BSPTreeIter
 BSPTreeIter ()
 
virtual ~BSPTreeIter ()
 
BSPTreetool () const
 
EntityHandle handle () const
 Get handle for current leaf. More...
 
unsigned depth () const
 Get depth in tree. root is at depth of 1. More...
 
ErrorCode step ()
 Advance to next leaf Returns MB_ENTITY_NOT_FOUND if at end. Note: stepping past the end of the tree will invalidate the iterator. Calling back() will not work. More...
 
ErrorCode back ()
 Move back to previous leaf Returns MB_ENTITY_NOT_FOUND if at beginning. Note: stepping past the start of the tree will invalidate the iterator. Calling step() will not work. More...
 
ErrorCode get_parent_split_plane (BSPTree::Plane &plane) const
 Get split plane that separates this node from its immediate sibling. More...
 
bool is_sibling (const BSPTreeIter &other_leaf) const
 Return true if thos node and the passed node share the same immediate parent. More...
 
bool is_sibling (EntityHandle other_leaf) const
 Return true if thos node and the passed node share the same immediate parent. More...
 
bool sibling_is_forward () const
 Returns true if calling step() will advance to the immediate sibling of the current node. Returns false if current node is root or back() will move to the immediate sibling. More...
 

Static Public Member Functions

static SideBits side_above_plane (const double hex_coords[8][3], const BSPTree::Plane &plane)
 
static SideBits side_on_plane (const double hex_coords[8][3], const BSPTree::Plane &plane)
 
static SideBits opposite_face (const SideBits &bits)
 
static ErrorCode face_corners (const SideBits face, const double hex_corners[8][3], double face_corners_out[4][3])
 

Protected Member Functions

virtual ErrorCode step_to_first_leaf (Direction direction)
 
virtual ErrorCode up ()
 
virtual ErrorCode down (const BSPTree::Plane &plane, Direction direction)
 
virtual ErrorCode initialize (BSPTree *tool, EntityHandle root, const double *point=0)
 

Private Attributes

double leafCoords [8][3]
 
std::vector< CornersstackData
 

Additional Inherited Members

- Protected Attributes inherited from moab::BSPTreeIter
std::vector< EntityHandlemStack
 
std::vector< EntityHandlechildVect
 

Detailed Description

Iterate over leaves of a BSPTree.

Definition at line 369 of file BSPTree.hpp.

Member Enumeration Documentation

◆ SideBits

Faces of a hex : corner bitmap.

Enumerator
B0154 

Face defined by corners {0,1,5,4}: 1st Exodus side.

B1265 

Face defined by corners {1,2,6,5}: 2nd Exodus side.

B2376 

Face defined by corners {2,3,7,6}: 3rd Exodus side.

B3047 

Face defined by corners {3,0,4,7}: 4th Exodus side.

B3210 

Face defined by corners {3,2,1,0}: 5th Exodus side.

B4567 

Face defined by corners {4,5,6,7}: 6th Exodus side.

Definition at line 392 of file BSPTree.hpp.

393  {
394  B0154 = 0x33, //!< Face defined by corners {0,1,5,4}: 1st Exodus side
395  B1265 = 0x66, //!< Face defined by corners {1,2,6,5}: 2nd Exodus side
396  B2376 = 0xCC, //!< Face defined by corners {2,3,7,6}: 3rd Exodus side
397  B3047 = 0x99, //!< Face defined by corners {3,0,4,7}: 4th Exodus side
398  B3210 = 0x0F, //!< Face defined by corners {3,2,1,0}: 5th Exodus side
399  B4567 = 0xF0 //!< Face defined by corners {4,5,6,7}: 6th Exodus side
400  };

◆ XSect

test if a plane intersects the leaf box

Enumerator
MISS 
SPLIT 
NONHEX 

Definition at line 444 of file BSPTree.hpp.

445  {
446  MISS = 0,
447  SPLIT = 1,
448  NONHEX = -1
449  };

Constructor & Destructor Documentation

◆ BSPTreeBoxIter()

moab::BSPTreeBoxIter::BSPTreeBoxIter ( )
inline

Definition at line 388 of file BSPTree.hpp.

388 {}

◆ ~BSPTreeBoxIter()

virtual moab::BSPTreeBoxIter::~BSPTreeBoxIter ( )
inlinevirtual

Definition at line 389 of file BSPTree.hpp.

389 {}

Member Function Documentation

◆ back()

ErrorCode moab::BSPTreeBoxIter::back ( )
inline

Move back to previous leaf Returns MB_ENTITY_NOT_FOUND if at beginning. Note: stepping past the start of the tree will invalidate the iterator. Calling step() will not work.

Definition at line 432 of file BSPTree.hpp.

433  {
434  return BSPTreeIter::back();
435  }

References moab::BSPTreeIter::back().

Referenced by get_neighbors().

◆ calculate_polyhedron()

ErrorCode moab::BSPTreeBoxIter::calculate_polyhedron ( BSPTreePoly polyhedron_out) const
virtual

Calculate the convex polyhedron bounding this leaf.

Reimplemented from moab::BSPTreeIter.

Definition at line 1129 of file BSPTree.cpp.

1130 {
1131  const CartVect* ptr = reinterpret_cast< const CartVect* >( leafCoords );
1132  return poly_out.set( ptr );
1133 }

References leafCoords, and moab::BSPTreePoly::set().

◆ down()

ErrorCode moab::BSPTreeBoxIter::down ( const BSPTree::Plane plane,
Direction  direction 
)
protectedvirtual

Reimplemented from moab::BSPTreeIter.

Definition at line 827 of file BSPTree.cpp.

828 {
829  childVect.clear();
830  ErrorCode rval = tool()->moab()->get_child_meshsets( mStack.back(), childVect );
831  if( MB_SUCCESS != rval ) return rval;
832  if( childVect.empty() ) return MB_ENTITY_NOT_FOUND;
833 
834  BSPTree::Plane plane( plane_ref );
835  if( direction == RIGHT ) plane.flip();
836 
837  Corners clipped_face;
838  rval = plane_cut_box( clipped_face.coords, leafCoords, plane );
839  if( MB_SUCCESS != rval ) return rval;
840 
841  mStack.push_back( childVect[direction] );
842  stackData.push_back( clipped_face );
843  return MB_SUCCESS;
844 }

References moab::BSPTreeIter::childVect, moab::BSPTreeBoxIter::Corners::coords, ErrorCode, moab::BSPTree::Plane::flip(), moab::Interface::get_child_meshsets(), leafCoords, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::BSPTree::moab(), moab::BSPTreeIter::mStack, moab::plane_cut_box(), moab::BSPTreeIter::RIGHT, stackData, and moab::BSPTreeIter::tool().

Referenced by get_neighbors().

◆ face_corners()

ErrorCode moab::BSPTreeBoxIter::face_corners ( const SideBits  face,
const double  hex_corners[8][3],
double  face_corners_out[4][3] 
)
static

Definition at line 587 of file BSPTree.cpp.

588 {
589  switch( face )
590  {
596  break;
602  break;
608  break;
614  break;
620  break;
626  break;
627  default:
628  return MB_FAILURE; // child is not a box
629  }
630 
631  return MB_SUCCESS;
632 }

References B0154, B1265, B2376, B3047, B3210, B4567, moab::copy_coords(), hex_corners, and MB_SUCCESS.

Referenced by get_neighbors().

◆ get_box_corners()

ErrorCode moab::BSPTreeBoxIter::get_box_corners ( double  coords[8][3]) const

Get coordinates of box corners, in Exodus II hexahedral ordering.

Definition at line 907 of file BSPTree.cpp.

908 {
909  memcpy( coords, leafCoords, 24 * sizeof( double ) );
910  return MB_SUCCESS;
911 }

References leafCoords, and MB_SUCCESS.

◆ get_neighbors()

ErrorCode moab::BSPTreeBoxIter::get_neighbors ( SideBits  side,
std::vector< BSPTreeBoxIter > &  results,
double  epsilon = 0.0 
) const

Get adjacent leaf nodes on indicated side.

Parameters
sideFace of box for which to retrieve neighbors
resultsList to which to append results. This function does not clear existing values in list.
epsilonTolerance on overlap. A positive value E will result in nodes that are separated by as much as E to be considered touching. A negative value -E will cause leaves that do not overlap by at least E to be considered non-overlapping. Amongst other things, this value can be used to control whether or not leaves adjacent at only their edges or corners are returned.

Definition at line 1024 of file BSPTree.cpp.

1025 {
1026  EntityHandle tmp_handle;
1027  BSPTree::Plane plane;
1028  ErrorCode rval;
1029  int n;
1030 
1031  Corners face;
1032  rval = face_corners( side, leafCoords, face.coords );
1033  if( MB_SUCCESS != rval ) return rval;
1034 
1035  // Move up tree until we find the split that created the specified side.
1036  // Push the sibling at that level onto the iterator stack as
1037  // all neighbors will be rooted at that node.
1038  BSPTreeBoxIter iter( *this ); // temporary iterator (don't modifiy *this)
1039  for( ;; )
1040  {
1041  tmp_handle = iter.handle();
1042 
1043  rval = iter.up();
1044  if( MB_SUCCESS != rval ) // reached root - no neighbors on that side
1045  return ( rval == MB_ENTITY_NOT_FOUND ) ? MB_SUCCESS : rval;
1046 
1047  iter.childVect.clear();
1048  rval = tool()->moab()->get_child_meshsets( iter.handle(), iter.childVect );
1049  if( MB_SUCCESS != rval ) return rval;
1050 
1051  rval = tool()->get_split_plane( iter.handle(), plane );
1052  if( MB_SUCCESS != rval ) return rval;
1053  SideBits s = side_above_plane( iter.leafCoords, plane );
1054 
1055  if( tmp_handle == iter.childVect[0] && s == side )
1056  {
1057  rval = iter.down( plane, RIGHT );
1058  if( MB_SUCCESS != rval ) return rval;
1059  break;
1060  }
1061  else if( tmp_handle == iter.childVect[1] && opposite_face( s ) == side )
1062  {
1063  rval = iter.down( plane, LEFT );
1064  if( MB_SUCCESS != rval ) return rval;
1065  break;
1066  }
1067  }
1068 
1069  // now move down tree, searching for adjacent boxes
1070  std::vector< BSPTreeBoxIter > list;
1071  // loop over all potential paths to neighbors (until list is empty)
1072  for( ;; )
1073  {
1074  // follow a single path to a leaf, append any other potential
1075  // paths to neighbors to 'list'
1076  for( ;; )
1077  {
1078  rval = tool()->moab()->num_child_meshsets( iter.handle(), &n );
1079  if( MB_SUCCESS != rval ) return rval;
1080 
1081  // if leaf
1082  if( !n )
1083  {
1084  results.push_back( iter );
1085  break;
1086  }
1087 
1088  rval = tool()->get_split_plane( iter.handle(), plane );
1089  if( MB_SUCCESS != rval ) return rval;
1090 
1091  bool some_above = false, some_below = false;
1092  for( int i = 0; i < 4; ++i )
1093  {
1094  double signed_d = plane.signed_distance( face.coords[i] );
1095  if( signed_d > -epsilon ) some_above = true;
1096  if( signed_d < epsilon ) some_below = true;
1097  }
1098 
1099  if( some_above && some_below )
1100  {
1101  list.push_back( iter );
1102  list.back().down( plane, RIGHT );
1103  iter.down( plane, LEFT );
1104  }
1105  else if( some_above )
1106  {
1107  iter.down( plane, RIGHT );
1108  }
1109  else if( some_below )
1110  {
1111  iter.down( plane, LEFT );
1112  }
1113  else
1114  {
1115  // tolerance issue -- epsilon to small? 2D box?
1116  return MB_FAILURE;
1117  }
1118  }
1119 
1120  if( list.empty() ) break;
1121 
1122  iter = list.back();
1123  list.pop_back();
1124  }
1125 
1126  return MB_SUCCESS;
1127 }

References back(), moab::BSPTreeIter::childVect, down(), ErrorCode, face_corners(), moab::Interface::get_child_meshsets(), moab::BSPTree::get_split_plane(), moab::BSPTreeIter::handle(), leafCoords, moab::BSPTreeIter::LEFT, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::BSPTree::moab(), moab::Interface::num_child_meshsets(), opposite_face(), moab::BSPTreeIter::RIGHT, side_above_plane(), moab::BSPTree::Plane::signed_distance(), moab::BSPTreeIter::tool(), and up().

◆ initialize()

ErrorCode moab::BSPTreeBoxIter::initialize ( BSPTree tool,
EntityHandle  root,
const double *  point = 0 
)
protectedvirtual

Reimplemented from moab::BSPTreeIter.

Definition at line 547 of file BSPTree.cpp.

548 {
549  ErrorCode rval = BSPTreeIter::initialize( tool_ptr, root );
550  if( MB_SUCCESS != rval ) return rval;
551 
552  rval = tool()->get_tree_box( root, leafCoords );
553  if( MB_SUCCESS != rval ) return rval;
554 
555  if( point && !point_in_box( leafCoords, point ) ) return MB_ENTITY_NOT_FOUND;
556 
557  stackData.resize( 1 );
558  return MB_SUCCESS;
559 }

References ErrorCode, moab::BSPTree::get_tree_box(), moab::BSPTreeIter::initialize(), leafCoords, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::point_in_box(), stackData, and moab::BSPTreeIter::tool().

◆ intersect_ray()

bool moab::BSPTreeBoxIter::intersect_ray ( const double  ray_point[3],
const double  ray_vect[3],
double &  t_enter,
double &  t_exit 
) const
virtual

Find range of overlap between ray and leaf.

Parameters
ray_pointCoordinates of start point of ray
ray_vectDirectionion vector for ray such that the ray is defined by r(t) = ray_point + t * ray_vect for t > 0.
t_enterOutput: if return value is true, this value is the parameter location along the ray at which the ray entered the leaf. If return value is false, then this value is undefined.
t_exitOutput: if return value is true, this value is the parameter location along the ray at which the ray exited the leaf. If return value is false, then this value is undefined.
Returns
true if ray intersects leaf, false otherwise.

Reimplemented from moab::BSPTreeIter.

Definition at line 1267 of file BSPTree.cpp.

1271 {
1272  BoxPlaneIter iter( this->leafCoords ), end;
1273  return ray_intersect_halfspaces( CartVect( ray_point ), CartVect( ray_vect ), iter, end, t_enter, t_exit );
1274 }

References leafCoords, and moab::ray_intersect_halfspaces().

◆ intersects()

bool moab::BSPTreeBoxIter::intersects ( const BSPTree::Plane plane) const

test if a plane intersects the leaf box

Definition at line 1001 of file BSPTree.cpp.

1002 {
1003  // test each corner relative to the plane
1004  unsigned count = 0;
1005  for( unsigned i = 0; i < 8u; ++i )
1006  count += plane.above( leafCoords[i] );
1007  return count > 0 && count < 8u;
1008 }

References moab::BSPTree::Plane::above(), and leafCoords.

◆ opposite_face()

static SideBits moab::BSPTreeBoxIter::opposite_face ( const SideBits bits)
inlinestatic

Definition at line 406 of file BSPTree.hpp.

407  {
408  return (SideBits)( ( ~bits ) & 0xFF );
409  }

Referenced by get_neighbors().

◆ sibling_side()

ErrorCode moab::BSPTreeBoxIter::sibling_side ( SideBits side_out) const

Return the side of the box bounding this tree node that is shared with the immediately adjacent sibling (the tree node that shares a common parent node with this node in the binary tree.)

Returns
MB_ENTITY_NOT FOUND if root node. MB_FAILURE if internal error. MB_SUCCESS otherwise.

Definition at line 1010 of file BSPTree.cpp.

1011 {
1012  if( mStack.size() < 2 ) // at tree root
1013  return MB_ENTITY_NOT_FOUND;
1014 
1015  EntityHandle parent = mStack[mStack.size() - 2];
1016  BSPTree::Plane plane;
1017  ErrorCode rval = tool()->get_split_plane( parent, plane );
1018  if( MB_SUCCESS != rval ) return MB_FAILURE;
1019 
1020  side_out = side_on_plane( leafCoords, plane );
1021  return MB_SUCCESS;
1022 }

References ErrorCode, moab::BSPTree::get_split_plane(), leafCoords, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::BSPTreeIter::mStack, side_on_plane(), and moab::BSPTreeIter::tool().

◆ side_above_plane()

BSPTreeBoxIter::SideBits moab::BSPTreeBoxIter::side_above_plane ( const double  hex_coords[8][3],
const BSPTree::Plane plane 
)
static

Definition at line 561 of file BSPTree.cpp.

562 {
563  unsigned result = 0;
564  for( unsigned i = 0; i < 8u; ++i )
565  result |= plane.above( hex_coords[i] ) << i;
566  return (BSPTreeBoxIter::SideBits)result;
567 }

References moab::BSPTree::Plane::above().

Referenced by get_neighbors(), and moab::plane_cut_box().

◆ side_on_plane()

BSPTreeBoxIter::SideBits moab::BSPTreeBoxIter::side_on_plane ( const double  hex_coords[8][3],
const BSPTree::Plane plane 
)
static

Definition at line 569 of file BSPTree.cpp.

570 {
571  unsigned result = 0;
572  for( unsigned i = 0; i < 8u; ++i )
573  {
574  bool on = plane.distance( hex_coords[i] ) <= BSPTree::epsilon();
575  result |= on << i;
576  }
577  return (BSPTreeBoxIter::SideBits)result;
578 }

References moab::BSPTree::Plane::distance(), and moab::BSPTree::epsilon().

Referenced by moab::plane_uncut_box(), and sibling_side().

◆ splits()

BSPTreeBoxIter::XSect moab::BSPTreeBoxIter::splits ( const BSPTree::Plane plane) const

Definition at line 961 of file BSPTree.cpp.

962 {
963  // test each corner relative to the plane
964  unsigned result = 0;
965  for( unsigned i = 0; i < 8u; ++i )
966  {
967  double d = plane.signed_distance( leafCoords[i] );
968  // if corner is on plane, than intersection
969  // will result in a degenerate hex
970  if( fabs( d ) < BSPTree::epsilon() ) return NONHEX;
971  // if mark vertices above plane
972  if( d > 0.0 ) result |= 1 << i;
973  }
974 
975  switch( result )
976  {
977  // if all vertices or no vertices above plane,
978  // then plane doesn't intersect
979  case 0:
980  case 0xFF:
981  return MISS;
982 
983  // if there are four vertices above the plane
984  // and they compose a single face of the hex,
985  // then the cut will result in two hexes
986  case B0154:
987  case B1265:
988  case B2376:
989  case B3047:
990  case B3210:
991  case B4567:
992  return SPLIT;
993 
994  // otherwise intersects, but split would not result
995  // in two hexahedrons
996  default:
997  return NONHEX;
998  }
999 }

References B0154, B1265, B2376, B3047, B3210, B4567, moab::BSPTree::epsilon(), leafCoords, MISS, NONHEX, moab::BSPTree::Plane::signed_distance(), and SPLIT.

◆ step() [1/2]

ErrorCode moab::BSPTreeBoxIter::step ( )
inline

Advance to next leaf Returns MB_ENTITY_NOT_FOUND if at end. Note: stepping past the end of the tree will invalidate the iterator. Calling back() will not work.

Definition at line 423 of file BSPTree.hpp.

424  {
425  return BSPTreeIter::step();
426  }

References moab::BSPTreeIter::step().

◆ step() [2/2]

ErrorCode moab::BSPTreeBoxIter::step ( Direction  direction)
virtual

Advance the iterator either left or right in the tree Note: stepping past the end of the tree will invalidate the iterator. It will not work to subsequently step the other direction.

Reimplemented from moab::BSPTreeIter.

Definition at line 846 of file BSPTree.cpp.

847 {
848  EntityHandle node, parent;
849  Corners clipped_face;
850  ErrorCode rval;
851  BSPTree::Plane plane;
852  const Direction opposite = static_cast< Direction >( 1 - direction );
853 
854  // If stack is empty, then either this iterator is uninitialized
855  // or we reached the end of the iteration (and return
856  // MB_ENTITY_NOT_FOUND) already.
857  if( mStack.empty() ) return MB_FAILURE;
858 
859  // Pop the current node from the stack.
860  // The stack should then contain the parent of the current node.
861  // If the stack is empty after this pop, then we've reached the end.
862  node = mStack.back();
863  mStack.pop_back();
864  clipped_face = stackData.back();
865  stackData.pop_back();
866 
867  while( !mStack.empty() )
868  {
869  // Get data for parent entity
870  parent = mStack.back();
871  childVect.clear();
872  rval = tool()->moab()->get_child_meshsets( parent, childVect );
873  if( MB_SUCCESS != rval ) return rval;
874  rval = tool()->get_split_plane( parent, plane );
875  if( MB_SUCCESS != rval ) return rval;
876  if( direction == LEFT ) plane.flip();
877 
878  // If we're at the left child
879  if( childVect[opposite] == node )
880  {
881  // change from box of left child to box of parent
882  plane_uncut_box( clipped_face.coords, leafCoords, plane );
883  // change from box of parent to box of right child
884  plane.flip();
885  plane_cut_box( clipped_face.coords, leafCoords, plane );
886  // push right child on stack
887  mStack.push_back( childVect[direction] );
888  stackData.push_back( clipped_face );
889  // descend to left-most leaf of the right child
890  return step_to_first_leaf( opposite );
891  }
892 
893  // The current node is the right child of the parent,
894  // continue up the tree.
895  assert( childVect[direction] == node );
896  plane.flip();
897  plane_uncut_box( clipped_face.coords, leafCoords, plane );
898  node = parent;
899  clipped_face = stackData.back();
900  mStack.pop_back();
901  stackData.pop_back();
902  }
903 
904  return MB_ENTITY_NOT_FOUND;
905 }

References moab::BSPTreeIter::childVect, moab::BSPTreeBoxIter::Corners::coords, ErrorCode, moab::BSPTree::Plane::flip(), moab::Interface::get_child_meshsets(), moab::BSPTree::get_split_plane(), leafCoords, moab::BSPTreeIter::LEFT, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::BSPTree::moab(), moab::BSPTreeIter::mStack, moab::plane_cut_box(), moab::plane_uncut_box(), stackData, step_to_first_leaf(), and moab::BSPTreeIter::tool().

◆ step_to_first_leaf()

ErrorCode moab::BSPTreeBoxIter::step_to_first_leaf ( Direction  direction)
protectedvirtual

Reimplemented from moab::BSPTreeIter.

Definition at line 771 of file BSPTree.cpp.

772 {
773  ErrorCode rval;
774  BSPTree::Plane plane;
775  Corners clipped_corners;
776 
777  for( ;; )
778  {
779  childVect.clear();
780  rval = tool()->moab()->get_child_meshsets( mStack.back(), childVect );
781  if( MB_SUCCESS != rval ) return rval;
782  if( childVect.empty() ) // leaf
783  break;
784 
785  rval = tool()->get_split_plane( mStack.back(), plane );
786  if( MB_SUCCESS != rval ) return rval;
787 
788  if( direction == RIGHT ) plane.flip();
789  rval = plane_cut_box( clipped_corners.coords, leafCoords, plane );
790  if( MB_SUCCESS != rval ) return rval;
791  mStack.push_back( childVect[direction] );
792  stackData.push_back( clipped_corners );
793  }
794  return MB_SUCCESS;
795 }

References moab::BSPTreeIter::childVect, moab::BSPTreeBoxIter::Corners::coords, ErrorCode, moab::BSPTree::Plane::flip(), moab::Interface::get_child_meshsets(), moab::BSPTree::get_split_plane(), leafCoords, MB_SUCCESS, moab::BSPTree::moab(), moab::BSPTreeIter::mStack, moab::plane_cut_box(), moab::BSPTreeIter::RIGHT, stackData, and moab::BSPTreeIter::tool().

Referenced by step().

◆ up()

ErrorCode moab::BSPTreeBoxIter::up ( )
protectedvirtual

Reimplemented from moab::BSPTreeIter.

Definition at line 797 of file BSPTree.cpp.

798 {
799  ErrorCode rval;
800  if( mStack.size() == 1 ) return MB_ENTITY_NOT_FOUND;
801 
802  EntityHandle node = mStack.back();
803  Corners clipped_face = stackData.back();
804  mStack.pop_back();
805  stackData.pop_back();
806 
807  BSPTree::Plane plane;
808  rval = tool()->get_split_plane( mStack.back(), plane );
809  if( MB_SUCCESS != rval )
810  {
811  mStack.push_back( node );
812  stackData.push_back( clipped_face );
813  return rval;
814  }
815 
816  rval = plane_uncut_box( clipped_face.coords, leafCoords, plane );
817  if( MB_SUCCESS != rval )
818  {
819  mStack.push_back( node );
820  stackData.push_back( clipped_face );
821  return rval;
822  }
823 
824  return MB_SUCCESS;
825 }

References moab::BSPTreeBoxIter::Corners::coords, ErrorCode, moab::BSPTree::get_split_plane(), leafCoords, MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::BSPTreeIter::mStack, moab::plane_uncut_box(), stackData, and moab::BSPTreeIter::tool().

Referenced by get_neighbors().

◆ volume()

double moab::BSPTreeBoxIter::volume ( ) const
virtual

Get volume of leaf box.

Reimplemented from moab::BSPTreeIter.

Definition at line 942 of file BSPTree.cpp.

943 {
944  // have planar sides, so use mid-face tripple product
945  double f1[3], f2[3], f3[3], f4[3], f5[3], f6[3];
946  sum( f1, leafCoords[0], leafCoords[1], leafCoords[4], leafCoords[5] );
947  sum( f2, leafCoords[1], leafCoords[2], leafCoords[5], leafCoords[6] );
948  sum( f3, leafCoords[2], leafCoords[3], leafCoords[6], leafCoords[7] );
949  sum( f4, leafCoords[0], leafCoords[3], leafCoords[4], leafCoords[7] );
950  sum( f5, leafCoords[0], leafCoords[1], leafCoords[2], leafCoords[3] );
951  sum( f6, leafCoords[4], leafCoords[5], leafCoords[6], leafCoords[7] );
952  double v13[3], v24[3], v65[3];
953  subtr( v13, f1, f3 );
954  subtr( v24, f2, f4 );
955  subtr( v65, f6, f5 );
956  double cr[3];
957  cross( cr, v13, v24 );
958  return ( 1. / 64 ) * dot( cr, v65 );
959 }

References moab::cross(), moab::dot(), leafCoords, moab::subtr(), and moab::sum().

Member Data Documentation

◆ leafCoords

double moab::BSPTreeBoxIter::leafCoords[8][3]
private

◆ stackData

std::vector< Corners > moab::BSPTreeBoxIter::stackData
private

Definition at line 377 of file BSPTree.hpp.

Referenced by down(), initialize(), step(), step_to_first_leaf(), and up().


The documentation for this class was generated from the following files: