cgma
RStarTree< Z > Class Template Reference

#include <RStarTree.hpp>

List of all members.

Classes

class  LessThan

Public Types

typedef double(* DistSqFunc )(CubitVector &a, Z &b)

Public Member Functions

 RStarTree (double tol=GEOMETRY_RESABS)
 RStarTree (double tol, int max_c, int min_c)
 ~RStarTree ()
void set_tol (double tol)
double get_tol ()

Private Member Functions

CubitStatus recursive_find (RStarTreeNode< Z > *rect_tree, const CubitBox &range_box, DLIList< Z > &range_members)
void to_list (DLIList< RStarTreeNode< Z > * > &member_list, RStarTreeNode< Z > *top)
double min_dist_sq (CubitVector &q, CubitBox &b_box)

Private Attributes

double myTolerance
int maxChildren
int minChildren
RStarTreeNode< Z > * myRoot

Detailed Description

template<class Z>
class RStarTree< Z >

Definition at line 24 of file RStarTree.hpp.


Member Typedef Documentation

template<class Z >
typedef double(* RStarTree< Z >::DistSqFunc)(CubitVector &a, Z &b)

Definition at line 66 of file RStarTree.hpp.


Constructor & Destructor Documentation

template<class Z >
RStarTree< Z >::RStarTree ( double  tol = GEOMETRY_RESABS)
template<class Z >
RStarTree< Z >::RStarTree ( double  tol,
int  max_c,
int  min_c 
)
template<class Z >
MY_INLINE RStarTree< Z >::~RStarTree ( )

Definition at line 33 of file RStarTree.cpp.

{
  if ( myRoot != NULL )
  {
      //Go through and get all the children in a list.
    DLIList <RStarTreeNode<Z>*> to_delete;
    to_list(to_delete, myRoot);
    int ii;
    for(ii = to_delete.size(); ii > 0; ii-- )
      delete to_delete.pop();
    delete myRoot;
  }
}

Member Function Documentation

template<class Z >
double RStarTree< Z >::get_tol ( ) [inline]

Definition at line 70 of file RStarTree.hpp.

    {return myTolerance;}
template<class Z >
MY_INLINE double RStarTree< Z >::min_dist_sq ( CubitVector q,
CubitBox b_box 
) [private]

Definition at line 110 of file RStarTree.cpp.

{
  CubitVector b_min, b_max;
  b_min = b_box.minimum();
  b_max = b_box.maximum();
  double dist;
  CubitVector r;

  if ( q.x() < b_min.x() )
    r.x(b_min.x());
  else if ( q.x() > b_max.x() )
    r.x(b_max.x());
  else
    r.x(q.x());
  
  if ( q.y() < b_min.y() )
    r.y(b_min.y());
  else if ( q.y() > b_max.y() )
    r.y(b_max.y());
  else
    r.y(q.y());
  
  if ( q.z() < b_min.z() )
    r.z(b_min.z());
  else if ( q.z() > b_max.z() )
    r.z(b_max.z());
  else
    r.z(q.z());
  
  dist = (q-r).length_squared();

  return dist;
}
template<class Z >
MY_INLINE CubitStatus RStarTree< Z >::recursive_find ( RStarTreeNode< Z > *  rect_tree,
const CubitBox range_box,
DLIList< Z > &  range_members 
) [private]

Definition at line 64 of file RStarTree.cpp.

{
  CubitBox rect_box = rect_tree->bounding_box();
  if ( !range_box.overlap(myTolerance, rect_box ) )
    return CUBIT_SUCCESS;

    //Now see if this is a data member.  If it is, append the data to the
    //list.
  if (rect_tree->is_data() )
  {
    range_members.append(rect_tree->get_data());
    return CUBIT_SUCCESS;
  }
    //Now if this is anything else we need to keep iterating...
  int loop_size = rect_tree->num_children();
    //We are doing a depth-first search of the tree.  Not
    //all branches will need to be followed since they won't
    //all overlap...
  int ii;
  RStarTreeNode<Z> *curr_node;
  CubitStatus stat;
  for ( ii = 0; ii < loop_size; ii++ )
  {
    curr_node = rect_tree->get_child(ii);
    if ( curr_node == NULL )
    {
      PRINT_ERROR("Problems finding boxes in range.\n");
      assert(curr_node != NULL);
      return CUBIT_FAILURE;
    }
    stat = recursive_find(curr_node, range_box, range_members);
    if ( stat != CUBIT_SUCCESS )
      return stat;
  }
  
  return CUBIT_SUCCESS;
}
template<class Z >
void RStarTree< Z >::set_tol ( double  tol) [inline]

Definition at line 68 of file RStarTree.hpp.

    {myTolerance = tol;}
template<class Z >
MY_INLINE void RStarTree< Z >::to_list ( DLIList< RStarTreeNode< Z > * > &  member_list,
RStarTreeNode< Z > *  top 
) [private]

Definition at line 46 of file RStarTree.cpp.

{
    //Get the children of the top into the list.
  int ii;
  RStarTreeNode <Z> *curr_node;
  for ( ii = 0; ii < top->num_children(); ii++ )
  {
    curr_node = top->get_child(ii);
    member_list.append(curr_node);
      //don't go below the bottom level...
    if ( curr_node->get_leaf_level() == 0 )
      continue;
    to_list(member_list, curr_node);
  }
  return;
}

Member Data Documentation

template<class Z >
int RStarTree< Z >::maxChildren [private]

Definition at line 28 of file RStarTree.hpp.

template<class Z >
int RStarTree< Z >::minChildren [private]

Definition at line 29 of file RStarTree.hpp.

template<class Z >
RStarTreeNode<Z>* RStarTree< Z >::myRoot [private]

Definition at line 30 of file RStarTree.hpp.

template<class Z >
double RStarTree< Z >::myTolerance [private]

Definition at line 27 of file RStarTree.hpp.


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