cgma
RStarTree.hpp
Go to the documentation of this file.
00001 //---------------------------------------------------------------------------
00002 // Class Name:  RStarTree
00003 // Description: Rectangle tree.  A tree for multidimensional access methods.
00004 // The algorithm was taken from the following paper:
00005 //        Norbert Beckmann, H. Kriegel, R. Schnieder, and B. Seegar,
00006 //              "The R*-tree: An Efficient and Robust Access Method
00007 //              for Points and Rectangles", Proceedings of ACM SIGMOD
00008 //              Int'l. Conf. on Management of Data, pp. 322-331, 1990.
00009 // Creation Date: 7/20/02
00010 // Owner:  David R. White
00011 //---------------------------------------------------------------------------
00012 #ifndef RSTARTREE_HPP
00013 #define RSTARTREE_HPP
00014 
00015 #include "CubitDefines.h"
00016 #include "GeometryDefines.h"
00017 
00018 class CubitBox;
00019 class CubitVector;
00020 
00021 template <class X> class DLIList;
00022 template <class Y> class RStarTreeNode;
00023 
00024 template <class Z> class RStarTree 
00025 {
00026 private:
00027   double myTolerance;
00028   int maxChildren;
00029   int minChildren;
00030   RStarTreeNode<Z> *myRoot;
00031   CubitStatus recursive_find(RStarTreeNode<Z> *rect_tree,
00032                              const CubitBox &range_box,
00033                              DLIList <Z> &range_members);
00034     //- recurses down the rtree to find all all the data members
00035     //- that fall in the range of the range_box.
00036 
00037   void to_list(DLIList <RStarTreeNode<Z>*> &member_list,
00038                RStarTreeNode<Z> *top);
00039     //- converts the tree under top to a list.  Note, top is NOT in the list
00040     //- at the end.
00041   double min_dist_sq(CubitVector &q,
00042                      CubitBox &b_box);
00043     //- Calculates the distance between a point and a box, this is
00044 //- for the nearest neighbor point search.
00045 
00046   
00047    class LessThan
00048    {
00049      public:
00050      bool operator()(const Z& x, const Z& y) const
00051        {
00052          return x->get_dist() < y->get_dist(); 
00053        }
00054      
00055    };
00056 
00057 
00058   
00059 public:
00060   
00061   RStarTree(double tol = GEOMETRY_RESABS);
00062   RStarTree(double tol, int max_c, int min_c);
00063   ~RStarTree();
00064     //- Constructor/Destructor
00065 
00066   typedef double (*DistSqFunc)(CubitVector &a, Z& b);
00067   
00068   void set_tol(double tol)
00069     {myTolerance = tol;}
00070   double get_tol()
00071     {return myTolerance;}
00072     //- Sets/Gets the tolerance used for the bounding box overlap test,
00073     //- which is used during the range search.
00074 
00075 };
00076 
00077 #include "RStarTree.cpp"
00078 
00079 #endif
00080 
00081 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines