21 #ifndef GF_SPACE_TREE_H 22 #define GF_SPACE_TREE_H 27 #include "Portability.h" 33 #ifndef DOXYGEN_SHOULD_SKIP_THIS 52 using Callback = std::function<bool(const SpaceTree&)>;
84 void removeChildren();
96 bool splitOnce(
Random& random,
Vector2i minSize,
float maxRatio = 1.5f);
107 void splitRecursive(
Random& random,
int levelMax,
Vector2i minSize,
Vector2i maxSize,
float maxRatio = 1.5f);
117 return !m_left && !m_right;
144 return m_right.get();
153 return m_right.get();
183 bool contains(
Vector2i position)
const;
200 bool traversePreOrder(
Callback callback)
const;
209 bool traverseInOrder(
Callback callback)
const;
218 bool traversePostOrder(
Callback callback)
const;
229 bool traverseLevelOrder(
Callback callback)
const;
238 bool traverseInvertedLevelOrder(
Callback callback)
const;
254 std::unique_ptr<SpaceTree> m_left;
255 std::unique_ptr<SpaceTree> m_right;
260 #ifndef DOXYGEN_SHOULD_SKIP_THIS 265 #endif // GF_SPACE_TREE_H A random engine.
Definition: Random.h:43
SpaceTree * getRightChild()
Get the right child.
Definition: SpaceTree.h:152
const SpaceTree * getRightChild() const
Get the right child.
Definition: SpaceTree.h:143
std::function< bool(const SpaceTree &)> Callback
A callback function for traversing the tree.
Definition: SpaceTree.h:52
The namespace for gf classes.
Definition: Action.h:34
const SpaceTree * getFather() const
Get the father of the node.
Definition: SpaceTree.h:163
SpaceTree * getLeftChild()
Get the left child.
Definition: SpaceTree.h:134
bool isLeaf() const
Check if a node is a leaf.
Definition: SpaceTree.h:116
const RectI & getArea() const
Get the area of the node.
Definition: SpaceTree.h:66
Binary space random partionning tree.
Definition: SpaceTree.h:44
int getLevel() const
Get the level of the node in the tree.
Definition: SpaceTree.h:77
SpaceTree * getFather()
Get the father of the node.
Definition: SpaceTree.h:174
const SpaceTree * getLeftChild() const
Get the left child.
Definition: SpaceTree.h:125