19#include <simgear/math/SGGeometry.hxx>
51 assert(!SGMisc<double>::isNaN(x));
69 return _order < other._order;
74 return _order > other._order;
129 return intersects(aPos,
_box);
134 return dist(aPos,
_box.getClosestPoint(aPos));
137 virtual void visit(
const SGVec3d& aPos,
double aCutoff,
143 virtual void visitForLines(
const SGVec3d& aPos,
double aCutoff,
153 Node(
const SGBoxd& aBox, int64_t aIdent,
bool persistent);
166 Leaf(
const SGBoxd& aBox, int64_t aIdent,
bool persistent);
168 virtual void visit(
const SGVec3d& aPos,
double aCutoff,
174 return const_cast<Leaf*
>(
this);
181 bool _childrenLoaded =
false;
183 typedef std::multimap<FGPositioned::Type, PositionedID> ChildMap;
192 Branch(
const SGBoxd& aBox, int64_t aIdent,
bool persistent);
194 virtual void visit(
const SGVec3d& aPos,
double aCutoff,
201 return childForPos(aPos)->findLeafForPos(aPos);
206 virtual void visitForLines(
const SGVec3d& aPos,
double aCutoff,
213 Node* childForPos(
const SGVec3d& aCart)
const;
214 Node* childAtIndex(
int childIndex)
const;
219 SGBoxd boxForChild(
unsigned int aCorner)
const
221 SGBoxd r(
_box.getCenter());
222 r.expandBy(
_box.getCorner(aCorner));
226 void loadChildren()
const;
228 mutable std::array<Node*, 8> _children;
229 mutable bool _childrenLoaded =
false;
Predicate class to support custom filtering of FGPositioned queries Default implementation of this pa...
virtual Leaf * findLeafForPos(const SGVec3d &aPos) const
Branch(const SGBoxd &aBox, int64_t aIdent, bool persistent)
virtual Node * findNodeForBox(const SGBoxd &box) const
virtual void visit(const SGVec3d &aPos, double aCutoff, FGPositioned::Filter *, FindNearestResults &, FindNearestPQueue &aQ)
virtual void visitForLines(const SGVec3d &aPos, double aCutoff, PolyLineList &aLines, FindLinesDeque &aQ) const
Leaf(const SGBoxd &aBox, int64_t aIdent, bool persistent)
void removeChild(PositionedID id)
virtual void visit(const SGVec3d &aPos, double aCutoff, FGPositioned::Filter *aFilter, FindNearestResults &aResults, FindNearestPQueue &)
void insertChild(FGPositioned::Type ty, PositionedID id)
virtual Leaf * findLeafForPos(const SGVec3d &) const
Octree node base class, tracks its bounding box and provides various queries relating to it.
double distToNearest(const SGVec3d &aPos) const
virtual void visit(const SGVec3d &aPos, double aCutoff, FGPositioned::Filter *aFilter, FindNearestResults &aResults, FindNearestPQueue &)=0
void addPolyLine(const PolyLineRef &)
virtual void visitForLines(const SGVec3d &aPos, double aCutoff, PolyLineList &aLines, FindLinesDeque &aQ) const
Node(const SGBoxd &aBox, int64_t aIdent, bool persistent)
bool contains(const SGVec3d &aPos) const
const SGBoxd & bbox() const
virtual Leaf * findLeafForPos(const SGVec3d &aPos) const =0
virtual Node * findNodeForBox(const SGBoxd &box) const
Decorate an object with a double value, and use that value to order items, for the purpoises of the S...
Ordered< T > & operator=(const Ordered< T > &a)
bool operator>(const Ordered< T > &other) const
bool operator<(const Ordered< T > &other) const
Ordered(const Ordered< T > &a)
Ordered(const T &v, double x)
Ordered< FGPositioned * > OrderedPositioned
std::deque< Node * > FindLinesDeque
bool findAllWithinRange(const SGVec3d &aPos, double aRangeM, FGPositioned::Filter *aFilter, FGPositionedList &aResults, int aCutoffMsec)
const double LEAF_SIZE_SQR
std::vector< OrderedPositioned > FindNearestResults
Node * globalTransientOctree()
bool findNearestN(const SGVec3d &aPos, unsigned int aN, double aCutoffM, FGPositioned::Filter *aFilter, FGPositionedList &aResults, int aCutoffMsec)
Node * globalPersistentOctree()
std::greater< OrderedNode > FNPQCompare
std::priority_queue< OrderedNode, std::vector< OrderedNode >, FNPQCompare > FindNearestPQueue
the priority queue is fundamental to our search algorithm.
Ordered< Node * > OrderedNode
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
std::vector< PolyLineRef > PolyLineList
SGSharedPtr< PolyLine > PolyLineRef
std::vector< FGPositionedRef > FGPositionedList