StelSphericalIndex.hpp   StelSphericalIndex.hpp 
skipping to change at line 37 skipping to change at line 37
class StelSphericalIndex class StelSphericalIndex
{ {
public: public:
StelSphericalIndex(int maxObjectsPerNode = 100, int maxLevel=7); StelSphericalIndex(int maxObjectsPerNode = 100, int maxLevel=7);
virtual ~StelSphericalIndex(); virtual ~StelSphericalIndex();
//! Insert the given object in the StelSphericalIndex. //! Insert the given object in the StelSphericalIndex.
void insert(StelRegionObjectP obj); void insert(StelRegionObjectP obj);
//! Process all the objects intersecting the given region using the passed function object. //! Process all the objects intersecting the given region using the passed function object.
template<class FuncObject> void processIntersectingRegions(const Sph ericalRegionP& region, FuncObject& func) const template<class FuncObject> void processIntersectingRegions(const Sph ericalRegion* region, FuncObject& func) const
{ {
rootNode->processIntersectingRegions(region, func); rootNode->processIntersectingRegions(region, func);
} }
//! Process all the objects intersecting the given region using the passed function object. //! Process all the objects intersecting the given region using the passed function object.
template<class FuncObject> void processIntersectingPointInRegions(co
nst SphericalRegion* region, FuncObject& func) const
{
rootNode->processIntersectingPointInRegions(region, func);
}
//! Process all the objects intersecting the given region using the
passed function object.
template<class FuncObject> void processBoundingCapIntersectingRegion s(const SphericalCap& cap, FuncObject& func) const template<class FuncObject> void processBoundingCapIntersectingRegion s(const SphericalCap& cap, FuncObject& func) const
{ {
rootNode->processBoundingCapIntersectingRegions(cap, func); rootNode->processBoundingCapIntersectingRegions(cap, func);
} }
//! Process all the objects contained in the given region using the passed function object. //! Process all the objects contained in the given region using the passed function object.
template<class FuncObject> void processContainedRegions(const Spheri calRegionP& region, FuncObject& func) const template<class FuncObject> void processContainedRegions(const Spheri calRegion* region, FuncObject& func) const
{ {
rootNode->processContainedRegions(region, func); rootNode->processContainedRegions(region, func);
} }
//! Process all the objects intersecting the given region using the passed function object. //! Process all the objects intersecting the given region using the passed function object.
template<class FuncObject> void processAll(FuncObject& func) const template<class FuncObject> void processAll(FuncObject& func) const
{ {
rootNode->processAll(func); rootNode->processAll(func);
} }
skipping to change at line 150 skipping to change at line 156
//! @class RootNode //! @class RootNode
//! The first Node of a tree. It has a special subdivision of the sp here in an octahedron. //! The first Node of a tree. It has a special subdivision of the sp here in an octahedron.
class RootNode : public Node class RootNode : public Node
{ {
public: public:
RootNode(int amaxObjectsPerNode, int amaxLevel) : ma xObjectsPerNode(amaxObjectsPerNode), maxLevel(amaxLevel) RootNode(int amaxObjectsPerNode, int amaxLevel) : ma xObjectsPerNode(amaxObjectsPerNode), maxLevel(amaxLevel)
{ {
} }
virtual ~RootNode() {}
//! Create the 8 triangles of the octahedron. //! Create the 8 triangles of the octahedron.
virtual void split() virtual void split()
{ {
static const Vec3d vertice[6] = static const Vec3d vertice[6] =
{ {
Vec3d(0,0,1), Vec3d(1,0,0), Vec3d(0, 1,0), Vec3d(-1,0,0), Vec3d(0,-1,0), Vec3d(0,0,-1) Vec3d(0,0,1), Vec3d(1,0,0), Vec3d(0, 1,0), Vec3d(-1,0,0), Vec3d(0,-1,0), Vec3d(0,0,-1)
}; };
static const int verticeIndice[8][3] = static const int verticeIndice[8][3] =
{ {
skipping to change at line 180 skipping to change at line 188
} }
} }
//! Insert the given element in the StelSphericalInd ex. //! Insert the given element in the StelSphericalInd ex.
void insert(const NodeElem& el, int level) void insert(const NodeElem& el, int level)
{ {
insert(*this, el, level); insert(*this, el, level);
} }
//! Process all the objects intersecting the given r egion using the passed function object. //! Process all the objects intersecting the given r egion using the passed function object.
template<class FuncObject> void processIntersectingR egions(const SphericalRegionP& region, FuncObject& func) const template<class FuncObject> void processIntersectingR egions(const SphericalRegion* region, FuncObject& func) const
{ {
processIntersectingRegions(*this, region, fu nc); processIntersectingRegions(*this, region, fu nc);
} }
//! Process all the objects intersecting the given r
egion using the passed function object.
template<class FuncObject> void processIntersectingP
ointInRegions(const SphericalRegion* region, FuncObject& func) const
{
processIntersectingPointInRegions(*this, reg
ion, func);
}
template<class FuncObject> void processBoundingCapIn tersectingRegions(const SphericalCap& cap, FuncObject& func) const template<class FuncObject> void processBoundingCapIn tersectingRegions(const SphericalCap& cap, FuncObject& func) const
{ {
processBoundingCapIntersectingRegions(*this, cap, func); processBoundingCapIntersectingRegions(*this, cap, func);
} }
//! Process all the objects contained the given regi on using the passed function object. //! Process all the objects contained the given regi on using the passed function object.
template<class FuncObject> void processContainedRegi ons(const SphericalRegionP& region, FuncObject& func) const template<class FuncObject> void processContainedRegi ons(const SphericalRegion* region, FuncObject& func) const
{ {
processContainedRegions(*this, region, func) ; processContainedRegions(*this, region, func) ;
} }
//! Process all the objects intersecting the given r egion using the passed function object. //! Process all the objects intersecting the given r egion using the passed function object.
template<class FuncObject> void processAll(FuncObjec t& func) const template<class FuncObject> void processAll(FuncObjec t& func) const
{ {
processAll(*this, func); processAll(*this, func);
} }
skipping to change at line 238 skipping to change at line 252
{ {
insert(*iter, el, level+1); insert(*iter, el, level+1);
return; return;
} }
} }
// Else store it here // Else store it here
node.elements.append(el); node.elements.append(el);
} }
//! Process all the objects intersecting the given r egion using the passed function object. //! Process all the objects intersecting the given r egion using the passed function object.
template<class FuncObject> void processIntersectingR egions(const Node& node, const SphericalRegionP& region, FuncObject& func) const template<class FuncObject> void processIntersectingR egions(const Node& node, const SphericalRegion* region, FuncObject& func) c onst
{ {
foreach (const NodeElem& el, node.elements) foreach (const NodeElem& el, node.elements)
{ {
// Optimization: We pass a plain poi
nter here, not smart pointer.
// As long as the FuncObject does no
t need to store the pointer,
// this isn't a problem.
if (region->intersects(el.obj->getRe gion().data())) if (region->intersects(el.obj->getRe gion().data()))
func(&(*el.obj)); func(&(*el.obj));
} }
foreach (const Node& child, node.children) foreach (const Node& child, node.children)
{ {
if (region->contains(child.triangle) ) if (region->contains(child.triangle) )
processAll(child, func); processAll(child, func);
else if (region->intersects(child.tr iangle)) else if (region->intersects(child.tr iangle))
processIntersectingRegions(c hild, region, func); processIntersectingRegions(c hild, region, func);
} }
} }
//! Process all the objects with point intersecting
the given region using the passed function object.
template<class FuncObject> void processIntersectingP
ointInRegions(const Node& node, const SphericalRegion* region, FuncObject&
func) const
{
foreach (const NodeElem& el, node.elements)
{
if (region->contains(el.obj->getPoin
tInRegion()))
func(&(*el.obj));
}
foreach (const Node& child, node.children)
{
if (region->contains(child.triangle)
)
processAll(child, func);
else if (region->intersects(child.tr
iangle))
processIntersectingPointInRe
gions(child, region, func);
}
}
template<class FuncObject> void processBoundingCapIn tersectingRegions(const Node& node, const SphericalCap& cap, FuncObject& fu nc) const template<class FuncObject> void processBoundingCapIn tersectingRegions(const Node& node, const SphericalCap& cap, FuncObject& fu nc) const
{ {
foreach (const NodeElem& el, node.elements) foreach (const NodeElem& el, node.elements)
{ {
// Optimization: We pass a plain poi
nter here, not smart pointer.
// As long as the FuncObject does no
t need to store the pointer,
// this isn't a problem.
if (cap.intersects(el.cap)) if (cap.intersects(el.cap))
func(&(*el.obj)); func(&(*el.obj));
} }
foreach (const Node& child, node.children) foreach (const Node& child, node.children)
{ {
if (cap.contains(child.triangle)) if (cap.contains(child.triangle))
processAll(child, func); processAll(child, func);
else if (cap.intersects(child.triang le)) else if (cap.intersects(child.triang le))
processBoundingCapIntersecti ngRegions(child, cap, func); processBoundingCapIntersecti ngRegions(child, cap, func);
} }
} }
//! Process all the objects contained the given regi on using the passed function object. //! Process all the objects contained the given regi on using the passed function object.
template<class FuncObject> void processContainedRegi ons(const Node& node, const SphericalRegionP& region, FuncObject& func) con st template<class FuncObject> void processContainedRegi ons(const Node& node, const SphericalRegion* region, FuncObject& func) cons t
{ {
foreach (const NodeElem& el, node.elements) foreach (const NodeElem& el, node.elements)
{ {
// Optimization: We pass a plain poi
nter here, not smart pointer.
// As long as the FuncObject does no
t need to store the pointer,
// this isn't a problem.
if (region->contains(el.obj->getRegi on().data())) if (region->contains(el.obj->getRegi on().data()))
func(&(*el.obj)); func(&(*el.obj));
} }
foreach (const Node& child, node.children) foreach (const Node& child, node.children)
{ {
if (region->contains(child.triangle) ) if (region->contains(child.triangle) )
processAll(child, func); processAll(child, func);
else if (region->intersects(child.tr iangle)) else if (region->intersects(child.tr iangle))
processContainedRegions(chil d, region, func); processContainedRegions(chil d, region, func);
} }
} }
//! Process all the objects intersecting the given r egion using the passed function object. //! Process all the objects intersecting the given r egion using the passed function object.
template<class FuncObject> void processAll(const Nod e& node, FuncObject& func) const template<class FuncObject> void processAll(const Nod e& node, FuncObject& func) const
{ {
// Optimization: We pass a plain pointer her
e, not smart pointer.
// As long as the FuncObject does not need t
o store the pointer,
// this isn't a problem.
foreach (const NodeElem& el, node.elements) foreach (const NodeElem& el, node.elements)
func(&(*el.obj)); func(&(*el.obj));
foreach (const Node& child, node.children) foreach (const Node& child, node.children)
processAll(child, func); processAll(child, func);
} }
//! The maximum number of objects per node. //! The maximum number of objects per node.
int maxObjectsPerNode; int maxObjectsPerNode;
//! The maximum level of the grid. Prevents grid spl it into too small triangles if unecessary. //! The maximum level of the grid. Prevents grid spl it into too small triangles if unecessary.
int maxLevel; int maxLevel;
 End of changes. 14 change blocks. 
26 lines changed or deleted 49 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/