std::vector<geo::Bounds::Ptr> Quad::retrieve_all_bounds( Quad::Ptr& quadptr, bool leaf_only, bool fuzzy ) { std::vector<geo::Bounds::Ptr> ret; PtrStack quadstack; quadstack.push(quadptr); while (!quadstack.empty()) { Ptr currquad = quadstack.top(); quadstack.pop(); if (currquad->haschildren()) { for (auto& child : currquad->children_) { quadstack.push(child); } if (!leaf_only) { if (fuzzy) { ret.push_back(std::make_shared<geo::Bounds>(currquad->fuzzybounds_)); } else { ret.push_back(std::make_shared<geo::Bounds>(*currquad)); } } } else { if (fuzzy) { ret.push_back(std::make_shared<geo::Bounds>(currquad->fuzzybounds_)); } else { ret.push_back(std::make_shared<geo::Bounds>(*currquad)); } } } return ret; }
int ObjPool <T>::delete_obj_stack (PtrStack &ptr_stack, bool destroy_flag) { assert (&ptr_stack != 0); PtrStack::CellType * cell_ptr = 0; int count = 0; do { cell_ptr = ptr_stack.pop (); if (cell_ptr != 0) { if (destroy_flag) { ObjType * & obj_ptr = cell_ptr->_val; delete obj_ptr; obj_ptr = 0; } _obj_cell_pool.return_cell (*cell_ptr); ++ count; } } while (cell_ptr != 0); return (count); }
bool Quad::insert( Quad::Ptr& quadptr, geo::Entity::CPtr entity_ptr ) { if ( !entity_ptr->touches(quadptr->fuzzybounds_) ) return false; PtrStack quadstack; quadstack.push(quadptr); while (!quadstack.empty()) { // attempt to insert this element (edge) in the quad at the top of // the stack. Ptr currquad = quadstack.top(); quadstack.pop(); // Create a list of entities to process. if (currquad->haschildren()) { // this quad has children (implies no elements in this quad) for ( auto& quad : currquad->children_ ) { // attempt to insert into all child quads that contain the edge. if (entity_ptr->touches(quad->fuzzybounds_)) { quadstack.push( quad ); } } continue; } // This is a leaf node. Try to insert. currquad->element_list_.push_back(entity_ptr); // Try to split the quad if its full. if (currquad->full() && currquad->split()) { // quad is saturated with elements; split and redistribute. // add it first so we redistribute everything including this // element. for ( auto& e : currquad->element_list_ ) { for ( auto& quad : currquad->children_ ) { insert(quad, e); } } currquad->element_list_.clear(); } } return true; }