/*protected*/ std::auto_ptr<BoundableList> SIRtree::createParentBoundables(BoundableList *childBoundables,int newLevel) { assert(!childBoundables->empty()); std::auto_ptr<BoundableList> parentBoundables ( new BoundableList() ); parentBoundables->push_back(createNode(newLevel)); std::auto_ptr<BoundableList> sortedChildBoundables ( sortBoundables(childBoundables) ); //for(unsigned int i=0;i<sortedChildBoundables->size();i++) for (BoundableList::iterator i=sortedChildBoundables->begin(), e=sortedChildBoundables->end(); i!=e; ++i) { //Boundable *childBoundable=(AbstractNode*)(*sortedChildBoundables)[i]; Boundable *childBoundable=*i; AbstractNode* lNode = lastNode(parentBoundables.get()); if (lNode->getChildBoundables()->size() == nodeCapacity) { parentBoundables->push_back(createNode(newLevel)); } lNode->addChildBoundable(childBoundable); } return parentBoundables; }
/*protected*/ std::auto_ptr<BoundableList> AbstractSTRtree::createParentBoundables(BoundableList* childBoundables, int newLevel) { assert(!childBoundables->empty()); std::auto_ptr< BoundableList > parentBoundables ( new BoundableList() ); parentBoundables->push_back(createNode(newLevel)); std::auto_ptr< BoundableList > sortedChildBoundables ( sortBoundables(childBoundables) ); for (BoundableList::iterator i=sortedChildBoundables->begin(), e=sortedChildBoundables->end(); i!=e; i++) //for(std::size_t i=0, scbsize=sortedChildBoundables->size(); i<scbsize; ++i) { Boundable *childBoundable=*i; // (*sortedChildBoundables)[i]; AbstractNode *last = lastNode(parentBoundables.get()); if (last->getChildBoundables()->size() == nodeCapacity) { last=createNode(newLevel); parentBoundables->push_back(last); } last->addChildBoundable(childBoundable); } return parentBoundables; }
/*private*/ AbstractNode* AbstractSTRtree::createHigherLevels(BoundableList* boundablesOfALevel, int level) { assert(!boundablesOfALevel->empty()); std::auto_ptr< BoundableList > parentBoundables ( createParentBoundables(boundablesOfALevel,level+1) ); if (parentBoundables->size()==1) { // Cast from Boundable to AbstractNode AbstractNode *ret = static_cast<AbstractNode*>(parentBoundables->front()); return ret; } AbstractNode *ret = createHigherLevels(parentBoundables.get(), level+1); return ret; }
/*private*/ std::auto_ptr<BoundableList> STRtree::createParentBoundablesFromVerticalSlices(std::vector<BoundableList*>* verticalSlices, int newLevel) { assert(!verticalSlices->empty()); std::auto_ptr<BoundableList> parentBoundables( new BoundableList() ); for (size_t i=0, vssize=verticalSlices->size(); i<vssize; ++i) { std::auto_ptr<BoundableList> toAdd ( createParentBoundablesFromVerticalSlice( (*verticalSlices)[i], newLevel) ); assert(!toAdd->empty()); parentBoundables->insert( parentBoundables->end(), toAdd->begin(), toAdd->end()); } return parentBoundables; }