1 #ifndef OCTREE_SEARCH_HPP
2 #define OCTREE_SEARCH_HPP
4 #include "blub/math/axisAlignedBox.hpp"
5 #include "blub/math/octree/container.hpp"
6 #include "blub/math/sphere.hpp"
8 #include <boost/bind.hpp>
9 #include <boost/function/function1.hpp>
18 template<
typename containerType>
28 typedef typename t_container::t_data t_data;
32 static t_leafList getLeafesBySphere(
const t_container& toSearchIn,
const sphere& insideSphere)
34 return getLeafsByUserDefinedFunction(toSearchIn, boost::bind(&t_thisClass::getLeafsBySphereSearchFunction, insideSphere, _1));
37 static t_dataList getDataBySphere(
const t_container& toSearchIn,
const sphere& insideSphere)
41 t_leafList leafs(getLeafesBySphere(toSearchIn, insideSphere));
43 for (t_leafPtr leaf : leafs)
45 for (t_data
data : leaf->getData())
54 static t_leafList getLeafsByUserDefinedFunction(
const t_container& toSearchIn,
const boost::function<
bool (t_nodePtr)>& isInside)
57 getLeafsByUserDefinedFunctionRecursively(toSearchIn, toSearchIn.getRootNode(), isInside, &result);
62 static t_dataList getDataByUserDefinedFunction(
const t_container& toSearchIn,
const boost::function<
bool (t_nodePtr)>& isInside)
66 t_leafList leafs(getLeafsByUserDefinedFunction(toSearchIn, isInside));
68 for (t_leafPtr leaf : leafs)
70 for (t_data
data : leaf->getData())
80 static void getLeafsByUserDefinedFunctionRecursively(
const t_container& tree,
81 const t_nodePtr& toSearchIn,
82 const boost::function<
bool (t_nodePtr)>& isInside,
85 if (isInside(toSearchIn))
87 t_leafPtr lf(tree.isLeaf(toSearchIn));
93 for (int8 child = 0; child < 8; ++child)
95 t_nodePtr childNode(toSearchIn->getNode(child));
96 if (childNode !=
nullptr)
98 getLeafsByUserDefinedFunctionRecursively(tree, childNode, isInside, result);
105 static bool getLeafsBySphereSearchFunction(
const sphere& sphere_, t_nodePtr node)
107 return sphere_.
intersects(node->getBoundingBox());
118 #endif // OCTREE_SEARCH_HPP
bool intersects(const sphere &s) const
Definition: sphere.cpp:9
Definition: container.hpp:74
Definition: container.hpp:20
Definition: search.hpp:19
Definition: hashList.hpp:19
Definition: container.hpp:23
Definition: deadlineTimer.hpp:10
Definition: customVertexInformation.cpp:177
Definition: sphere.hpp:10