[Roadnav-commits] SF.net SVN: roadnav:[1844] libsdbx/trunk/sdbx/RTree
Status: Inactive
Brought to you by:
rllynch
From: <vir...@us...> - 2009-03-31 14:19:31
|
Revision: 1844 http://roadnav.svn.sourceforge.net/roadnav/?rev=1844&view=rev Author: virtuald Date: 2009-03-31 14:19:13 +0000 (Tue, 31 Mar 2009) Log Message: ----------- - more verification Modified Paths: -------------- libsdbx/trunk/sdbx/RTree/RTree.h libsdbx/trunk/sdbx/RTree/RTreeBoundingBox.h libsdbx/trunk/sdbx/RTree/RTreeVisitor.h Modified: libsdbx/trunk/sdbx/RTree/RTree.h =================================================================== --- libsdbx/trunk/sdbx/RTree/RTree.h 2009-03-31 13:56:40 UTC (rev 1843) +++ libsdbx/trunk/sdbx/RTree/RTree.h 2009-03-31 14:19:13 UTC (rev 1844) @@ -232,6 +232,10 @@ bool Insert(const BoundingBox &key, const LeafType &leaf) WARN_IF_UNUSED { m_lastError = ERR_NONE; + + // do not insert invalid bounding boxes + if (!key.verify()) + return false; // ID1: Invoke Insert starting with the leaf level as a // parameter, to Insert a new data rectangle Modified: libsdbx/trunk/sdbx/RTree/RTreeBoundingBox.h =================================================================== --- libsdbx/trunk/sdbx/RTree/RTreeBoundingBox.h 2009-03-31 13:56:40 UTC (rev 1843) +++ libsdbx/trunk/sdbx/RTree/RTreeBoundingBox.h 2009-03-31 14:19:13 UTC (rev 1844) @@ -82,6 +82,22 @@ } } + // verifies that the bounding box is valid + bool verify() const + { + for (std::size_t axis = 0; axis < dimensions; axis++) + { + if (edges[axis].second < edges[axis].first) + { + assert(0 && "invalid bounding box!"); + return false; + } + } + + return true; + } + + // returns a new bounding box that has the maximum boundaries static RTreeBoundingBox MaximumBounds() { Modified: libsdbx/trunk/sdbx/RTree/RTreeVisitor.h =================================================================== --- libsdbx/trunk/sdbx/RTree/RTreeVisitor.h 2009-03-31 13:56:40 UTC (rev 1843) +++ libsdbx/trunk/sdbx/RTree/RTreeVisitor.h 2009-03-31 14:19:13 UTC (rev 1844) @@ -52,7 +52,9 @@ struct RTreeAcceptOverlapping { const typename NodeItem::KeyType &m_bound; - explicit RTreeAcceptOverlapping(const typename NodeItem::KeyType &bound) : m_bound(bound) {} + explicit RTreeAcceptOverlapping(const typename NodeItem::KeyType &bound) : m_bound(bound) { + assert(bound.verify()); + } bool operator()(const NodeItem &item) const { @@ -73,7 +75,10 @@ struct RTreeAcceptEnclosing { const typename NodeItem::KeyType &m_bound; - explicit RTreeAcceptEnclosing(const typename NodeItem::KeyType &bound) : m_bound(bound) {} + explicit RTreeAcceptEnclosing(const typename NodeItem::KeyType &bound) : m_bound(bound) + { + assert(bound.verify()); + } bool operator()(const NodeItem &item) const { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |