GLC_lib  2.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
glc_octreenode.h
Go to the documentation of this file.
1 /****************************************************************************
2 
3  This file is part of the GLC-lib library.
4  Copyright (C) 2005-2008 Laurent Ribon (laumaya@users.sourceforge.net)
5  http://glc-lib.sourceforge.net
6 
7  GLC-lib is free software; you can redistribute it and/or modify
8  it under the terms of the GNU Lesser General Public License as published by
9  the Free Software Foundation; either version 3 of the License, or
10  (at your option) any later version.
11 
12  GLC-lib is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with GLC-lib; if not, write to the Free Software
19  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 
21  *****************************************************************************/
23 
24 
25 #ifndef GLC_OCTREENODE_H_
26 #define GLC_OCTREENODE_H_
27 
28 #include "glc_3dviewinstance.h"
29 #include "../glc_boundingbox.h"
30 #include "../glc_config.h"
31 #include "../viewport/glc_frustum.h"
32 #include <QList>
33 #include <QSet>
34 
36 
39 
40 
42 {
43  typedef QList<GLC_OctreeNode*> NodeList;
45 
47 
48 public:
50  GLC_OctreeNode(const GLC_BoundingBox&, GLC_OctreeNode* pParent= NULL);
51 
53  GLC_OctreeNode(const GLC_OctreeNode&, GLC_OctreeNode* pParent= NULL);
54 
56  virtual ~GLC_OctreeNode();
58 
59 
61 
62 public:
63 
64  // Return this octree node bounding box
66  {return m_BoundingBox;}
67 
69  inline bool intersect(const GLC_BoundingBox& boundingBox);
70 
72  inline bool hasChild() const
73  {return !m_Children.isEmpty();}
74 
76 
77  inline GLC_OctreeNode* childAt(int i) const
78  {
79  Q_ASSERT(i < m_Children.size());
80  return m_Children.at(i);
81  }
82 
84  inline int childCount() const
85  {return m_Children.size();}
86 
88  inline bool hasGeometry() const
89  {return !m_3DViewInstanceSet.isEmpty();}
90 
92 
93  inline bool isEmpty() const
94  {return m_Empty;}
95 
98 
100  QSet<GLC_3DViewInstance*> setOfIntersectedInstances(const GLC_BoundingBox& bBox);
101 
102 
104 
106 
108 
109 public:
110 
112  void addChildren();
113 
115  void addInstance(GLC_3DViewInstance*, int);
116 
118 
119  void updateViewableInstances(const GLC_Frustum&, QSet<GLC_3DViewInstance*>* pInstanceSet= NULL);
120 
122  void removeEmptyChildren();
123 
125  static void useBoundingSphereIntersection(bool);
127 
129 // Private services function
131 private:
133  void unableViewFlag(QSet<GLC_3DViewInstance*>*);
134 
136  void disableViewFlag(QSet<GLC_3DViewInstance*>*);
137 
139 // Private members
141 private:
144 
147 
150 
152  QSet<GLC_3DViewInstance*> m_3DViewInstanceSet;
153 
155  bool m_Empty;
156 
158  static bool m_useBoundingSphere;
159 
160 };
161 
163 {
165  return m_BoundingBox.intersectBoundingSphere(boundingBox);
166  else
167  return m_BoundingBox.intersect(boundingBox);
168 }
169 
170 #endif /* GLC_OCTREENODE_H_ */

©2005-2013 Laurent Ribon