@@ -88,7 +88,11 @@ class RTree
88
88
// / \param a_dataId Positive Id of data. Maybe zero, but negative numbers not allowed.
89
89
void Insert (const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const DATATYPE& a_dataId);
90
90
91
- // / Remove entry
91
+ // / Remove entry (traverse the whole tree and removes every occurrence)
92
+ // / \param a_dataId Positive Id of data. Maybe zero, but negative numbers not allowed.
93
+ void Remove (const DATATYPE& a_dataId);
94
+
95
+ // / Remove entry (only if inside the given rect)
92
96
// / \param a_min Min of bounding rect
93
97
// / \param a_max Max of bounding rect
94
98
// / \param a_dataId Positive Id of data. Maybe zero, but negative numbers not allowed.
@@ -529,6 +533,13 @@ void RTREE_QUAL::Insert(const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMD
529
533
}
530
534
531
535
536
+ RTREE_TEMPLATE
537
+ void RTREE_QUAL::Remove (const DATATYPE& a_dataId)
538
+ {
539
+ RemoveRect (NULL , a_dataId, &m_root);
540
+ }
541
+
542
+
532
543
RTREE_TEMPLATE
533
544
void RTREE_QUAL::Remove (const ELEMTYPE a_min[NUMDIMS], const ELEMTYPE a_max[NUMDIMS], const DATATYPE& a_dataId)
534
545
{
@@ -1578,7 +1589,7 @@ void RTREE_QUAL::Classify(int a_index, int a_group, PartitionVars* a_parVars)
1578
1589
RTREE_TEMPLATE
1579
1590
bool RTREE_QUAL::RemoveRect (Rect * a_rect, const DATATYPE& a_id, Node** a_root)
1580
1591
{
1581
- RTREE_ASSERT (a_rect && a_root);
1592
+ RTREE_ASSERT (a_root);
1582
1593
RTREE_ASSERT (*a_root);
1583
1594
1584
1595
ListNode* reInsertList = NULL ;
@@ -1632,14 +1643,14 @@ bool RTREE_QUAL::RemoveRect(Rect* a_rect, const DATATYPE& a_id, Node** a_root)
1632
1643
RTREE_TEMPLATE
1633
1644
bool RTREE_QUAL::RemoveRectRec (Rect * a_rect, const DATATYPE& a_id, Node* a_node, ListNode** a_listNode)
1634
1645
{
1635
- RTREE_ASSERT (a_rect && a_node && a_listNode);
1646
+ RTREE_ASSERT (a_node && a_listNode);
1636
1647
RTREE_ASSERT (a_node->m_level >= 0 );
1637
1648
1638
1649
if (a_node->IsInternalNode ()) // not a leaf node
1639
1650
{
1640
1651
for (int index = 0 ; index < a_node->m_count ; ++index )
1641
1652
{
1642
- if (Overlap (a_rect, &(a_node->m_branch [index ].m_rect )))
1653
+ if (a_rect == NULL || Overlap (a_rect, &(a_node->m_branch [index ].m_rect )))
1643
1654
{
1644
1655
if (!RemoveRectRec (a_rect, a_id, a_node->m_branch [index ].m_child , a_listNode))
1645
1656
{
0 commit comments