2
* $Id: SG_Tree.h,v 1.2 2004/05/21 09:21:15 kester Exp $
4
* ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
6
* This program is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version. The Blender
10
* Foundation also sells licenses for use in proprietary software under
11
* the Blender License. See http://www.blender.org/BL/ for information
14
* This program is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this program; if not, write to the Free Software Foundation,
21
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24
* All rights reserved.
26
* The Original Code is: all of this file.
28
* Contributor(s): none yet.
30
* ***** END GPL/BL DUAL LICENSE BLOCK *****
37
#include "MT_Point3.h"
47
* Holds a binary tree of SG_Nodes.
57
SG_Node* m_client_object;
60
SG_Tree(SG_Tree* left, SG_Tree* right);
62
SG_Tree(SG_Node* client);
66
* Computes the volume of the bounding box.
68
MT_Scalar volume() const;
71
* Prints the tree (for debugging.)
76
* Returns the left node.
78
SG_Tree *Left() const;
79
SG_Tree *Right() const;
80
SG_Node *Client() const;
82
SG_Tree* Find(SG_Node *node);
84
* Gets the eight corners of this treenode's bounding box,
85
* in world coordinates.
86
* @param box: an array of 8 MT_Point3
87
* @example MT_Point3 box[8];
90
void get(MT_Point3 *box) const;
92
* Get the tree node's bounding box.
94
const SG_BBox& BBox() const;
97
* Test if the given bounding box is inside this bounding box.
99
bool inside(const MT_Point3 &point) const;
101
void SetLeft(SG_Tree *left);
102
void SetRight(SG_Tree *right);
104
MT_Point3 Centre() const { return m_centre; }
105
MT_Scalar Radius() { return m_radius; }
107
//friend class SG_TreeFactory;
111
bool operator()(const SG_Tree *a, const SG_Tree *b)
113
return a->volume() > b->volume();
121
* SG_TreeFactory generates an SG_Tree from a list of SG_Nodes.
122
* It joins pairs of SG_Nodes to minimise the size of the resultant
124
* cf building an optimised Huffman tree.
129
typedef std::multiset<SG_Tree*, SG_Tree::greater> TreeSet;
136
* Add a node to be added to the tree.
138
void Add(SG_Node* client);
139
void Add(SG_Tree* tree);
142
* Build the tree from the set of nodes added by
145
SG_Tree* MakeTreeUp();
148
* Build the tree from the set of nodes top down.
150
SG_Tree* MakeTreeDown(SG_BBox &bbox);
156
#endif /* __SG_BBOX_H__ */