--- a/include/kdtree.h Tue Apr 22 13:33:12 2008 +0200
+++ b/include/kdtree.h Wed Apr 23 10:38:33 2008 +0200
@@ -53,19 +53,19 @@
~KdNode();
void setLeaf() { flags |= 3; };
- bool isLeaf() { return (flags & 3) == 3; };
+ const bool isLeaf() const { return (flags & 3) == 3; };
void setAxis(int aAxis) { flags &= ~3; flags |= aAxis; };
- short getAxis() { return flags & 3; };
+ const int getAxis() const { return flags & 3; };
void setSplit(Float aSplit) { split = aSplit; };
- Float& getSplit() { return split; };
+ const Float& getSplit() const { return split; };
void setChildren(KdNode *node) { children = node; assert((flags & 3) == 0); };
- KdNode* getLeftChild() { return (KdNode*)((off_t)children & ~3); };
- KdNode* getRightChild() { return (KdNode*)((off_t)children & ~3) + 1; };
+ KdNode* getLeftChild() const { return (KdNode*)((off_t)children & ~3); };
+ KdNode* getRightChild() const { return (KdNode*)((off_t)children & ~3) + 1; };
- ShapeList* getShapes() { return (ShapeList*)((off_t)shapes & ~3); };
+ ShapeList* getShapes() const { return (ShapeList*)((off_t)shapes & ~3); };
void addShape(Shape* aShape) { getShapes()->push_back(aShape); };
};
@@ -79,6 +79,7 @@
int max_depth;
void recursive_build(KdNode *node, BBox bbox, int maxdepth);
+ void recursive_load(istream &st, KdNode *node);
public:
KdTree() : Container(), root(NULL), built(false), max_depth(32) {};
~KdTree() { if (root) delete root; };
@@ -87,9 +88,12 @@
Float &nearest_distance);
void optimize() { build(); };
void build();
- void save(ostream &str, KdNode *node = NULL);
- void load(istream &str, KdNode *node = NULL);
+ const bool isBuilt() const { return built; };
+ KdNode *getRootNode() const { return root; };
void setMaxDepth(int md) { max_depth = md; };
+
+ ostream & dump(ostream &st);
+ istream & load(istream &st);
};
#endif