BoundingBoxCompare.hpp

00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #ifndef stk_search_BoundingBoxCompare_hpp
00010 #define stk_search_BoundingBoxCompare_hpp
00011 
00012 namespace stk {
00013 namespace search {
00014 namespace box {
00015 namespace compare{
00016 
00017 enum {
00018 LOWER = 0,
00019 MIDDLE = 1,
00020 UPPER = 2,
00021 LENGTH = 3,
00022 KEY = 4
00023 };
00024 
00025 template <class BoundingBox, int Mode>
00026 class Compare;
00027 
00028 template <class BoundingBox, int Mode>
00029 class Partition;
00030 
00031 template<class BoundingBox>
00032 class Compare<BoundingBox, LOWER> {
00033   public:
00034     Compare(int axis) : m_axis(axis) {}
00035     inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const {
00036       return a.lower(m_axis) < b.lower(m_axis);
00037     }
00038   private:
00039     const int m_axis;
00040 };
00041 
00042 template<class BoundingBox>
00043 class Compare<BoundingBox, UPPER> {
00044   public:
00045     Compare(int axis) : m_axis(axis) {}
00046     inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const {
00047       return a.upper(m_axis) < b.upper(m_axis);
00048     }
00049   private:
00050     const int m_axis;
00051 };
00052 
00053 template<class BoundingBox>
00054 class Compare<BoundingBox, MIDDLE> {
00055   public:
00056     Compare(int axis) : m_axis(axis) {}
00057     inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const {
00058       return a.middle(m_axis) < b.middle(m_axis);
00059     }
00060   private:
00061     const int m_axis;
00062 };
00063 
00064 template<class BoundingBox>
00065 class Compare<BoundingBox, LENGTH> {
00066   public:
00067     Compare(int axis) : m_axis(axis) {}
00068     inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const {
00069       return a.length(m_axis) < b.length(m_axis);
00070     }
00071   private:
00072     const int m_axis;
00073 };
00074 
00075 template<class BoundingBox>
00076 class Compare<BoundingBox, KEY> {
00077   public:
00078     Compare(int /*axis*/ = 0) {}
00079     inline bool operator ()(const BoundingBox &a, const BoundingBox &b) const {
00080       return a.key < b.key;
00081     }
00082   private:
00083 };
00084 
00085 template<class BoundingBox>
00086 class Partition<BoundingBox, LOWER> {
00087   public:
00088     Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {}
00089     inline bool operator ()(const BoundingBox &a) const {
00090       return a.lower(m_axis) < m_split_plane;
00091     }
00092   private:
00093     const int m_axis;
00094     typename BoundingBox::Data m_split_plane;
00095 };
00096 
00097 template<class BoundingBox>
00098 class Partition<BoundingBox, UPPER> {
00099   public:
00100     Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {}
00101     inline bool operator ()(const BoundingBox &a) const {
00102       return a.upper(m_axis) < m_split_plane;
00103     }
00104   private:
00105     const int m_axis;
00106     typename BoundingBox::Data m_split_plane;
00107 };
00108 
00109 template<class BoundingBox>
00110 class Partition<BoundingBox, MIDDLE> {
00111   public:
00112     Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {}
00113     inline bool operator ()(const BoundingBox &a) const {
00114       return a.middle(m_axis) < m_split_plane;
00115     }
00116   private:
00117     const int m_axis;
00118     typename BoundingBox::Data m_split_plane;
00119 };
00120 
00121 template<class BoundingBox>
00122 class Partition<BoundingBox, LENGTH> {
00123   public:
00124     Partition(int axis, typename BoundingBox::Data split_plane) : m_axis(axis), m_split_plane(split_plane) {}
00125     inline bool operator ()(const BoundingBox &a) const {
00126       return a.length(m_axis) < m_split_plane;
00127     }
00128   private:
00129     const int m_axis;
00130     typename BoundingBox::Data m_split_plane;
00131 };
00132 
00133 template<class BoundingBox>
00134 class Partition<BoundingBox, KEY> {
00135   public:
00136     Partition(typename BoundingBox::Key split_plane) : m_split_plane(split_plane) {}
00137     inline bool operator ()(const BoundingBox &a) const {
00138       return a.key < m_split_plane;
00139     }
00140   private:
00141     typename BoundingBox::Key m_split_plane;
00142 };
00143 
00144 } // namespace compare
00145 } // namespace box
00146 } // namespace search
00147 } // namespace stk
00148 
00149 #endif // stk_search_BoundingBoxCompare_hpp

Generated on Tue Jul 13 09:27:31 2010 for Sierra Toolkit by  doxygen 1.4.7