| VRS - The Virtual Rendering System |
| version 3.3 |
00001 /********************************************************************** 00002 VRS - The Virtual Rendering System 00003 Copyright (C) 2001 Computer Graphics Systems Group at the 00004 Hasso-Plattner-Institute, Potsdam, Germany. 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Lesser General Public 00007 License as published by the Free Software Foundation; either 00008 version 2.1 of the License, or (at your option) any later version. 00009 This library is distributed in the hope that it will be useful, but 00010 WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00012 See the GNU Lesser General Public License for more details. 00013 You should have received a copy of the GNU Lesser+ General Public 00014 License along with this library; if not, write to the FreeSoftware 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA, 02111-1307, USA. 00016 **********************************************************************/ 00017 // $Id: $ 00018 // $Date: $ 00019 // $Revision: $ 00020 // $Author: $ 00021 // 00022 00023 #ifndef VRS_BOUNDINGBOXTREE_H 00024 #define VRS_BOUNDINGBOXTREE_H 00025 00026 #include <vrs/config.h> 00027 #include <vrs/bounds.h> 00028 00029 00030 namespace VRS { 00031 00032 template<typename T> class Iterator; 00033 00037 class VRS_CORE_API BoundingBoxTree : public SharedObj { 00038 public: 00039 00047 BoundingBoxTree(SO<Iterator<Bounds> > bboxes, int objectsPerLeaf = 5, int thresholdFactor = 50); 00048 00051 static SO<BoundingBoxTree> create(SO<Iterator<Vector> > primitives, int verticesPerPrimitive, int objectsPerLeaf = 5, int thresholdFactor = 50); 00052 00055 SO<Iterator<int> > findOverlappingBoxes(const VRS::Bounds& bounds) const; 00056 00057 VRS_TYPEINFO(BoundingBoxTree, SharedObj); 00058 VRS_SERIALIZABLE(BoundingBoxTree); 00059 00060 private: 00061 00062 BoundingBoxTree(); 00063 struct Node : public SharedObj { 00064 SO<Node> childNodes[2]; 00065 Bounds bounds; 00066 SO<Iterator<int> > indices; 00067 VRS_TYPEINFO(Node, SharedObj); 00068 VRS_SERIALIZABLE(Node); 00069 }; 00070 00071 SO<Node> m_root; 00072 SO<Iterator<Bounds> > m_boundingBoxes; 00073 }; 00074 00075 } 00076 00077 #endif // VRS_BOUNDINGBOXTREE_H