143 const size_t capacity)
146 <<
"QuadTree leaf capacity must be greater than zero";
147 return new Node(min_x, max_x, min_y, max_y);
163 return node !=
nullptr and not node->is_leaf()
and
174 return NW_CHILD(node)->get_points_set().size() +
175 NE_CHILD(node)->get_points_set().size() +
176 SW_CHILD(node)->get_points_set().size() +
177 SE_CHILD(node)->get_points_set().size();
289 return &
r->add_point(p);
472 <<
"QuadTree leaf capacity must be greater than zero";
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
constexpr bool is_empty() const noexcept
Represents a point with rectangular coordinates in a 2D plane.
Node for QuadTree spatial data structure.
bool contains(const Point &p) const noexcept
Check if a point is contained in this node's region.
const Geom_Number & get_min_y() const noexcept
Get minimum Y coordinate of this region.
const Geom_Number & get_max_y() const noexcept
Get maximum Y coordinate of this region.
void empty() noexcept
Remove all points from this node and mark it as White.
Geom_Number get_mid_x() const noexcept
Get midpoint X coordinate.
QuadNode * get_child_to(const Point &p) const
Find which child node should contain a given point.
DynList< Point > & get_points_set() noexcept
Get reference to the points list (for direct manipulation).
Geom_Number get_mid_y() const noexcept
Get midpoint Y coordinate.
const Geom_Number & get_min_x() const noexcept
Get minimum X coordinate of this region.
Point & add_point(const Point &p)
Add a point to this node.
Point * search_point(const Point &p) noexcept
Search for a point in this node.
bool is_leaf() const noexcept
Check if this node is a leaf (has no children).
bool remove_point(const Point &p)
Remove a point from this node.
const Geom_Number & get_max_x() const noexcept
Get maximum X coordinate of this region.
@ Gray
Internal node with children.
@ Black
Leaf node with points.
QuadTree - Hierarchical spatial index for 2D points.
size_t max_num_points_per_node
Maximum points per leaf node before splitting.
static bool has_four_leaf_children(Node *node) noexcept
Return true when an internal node has four leaf children.
void empty(Node *&r) noexcept
Recursively delete all nodes.
void clear()
Alias for empty().
~QuadTree()
Destructor - frees all nodes.
void for_each(Op &op)
Apply an operation to each node in the tree.
QuadTree(const Geom_Number &min_x, const Geom_Number &max_x, const Geom_Number &min_y, const Geom_Number &max_y, const size_t &_max_num_points_per_node=1)
Construct a quadtree with specified region and capacity.
void for_each(Op &&op=Op())
Apply operation to each node (rvalue reference version).
void remove(const Point &p)
Remove a point from the tree.
QuadTree()
Default constructor - creates an uninitialized tree.
Point * search(const Point &p) noexcept
Search for a point in the tree.
Node * search_container_node(const Point &p) noexcept
Find the leaf node containing a point.
Point * insert(const Geom_Number &x, const Geom_Number &y)
Insert a point given by coordinates.
void copy_tree(QuadNode *src, QuadNode *&tgt, QuadNode *tgt_parent=nullptr)
Deep copy a tree structure.
const Node * get_root() const noexcept
Get the root node (const version).
void set_max_num_points_per_node(const size_t &_max_num_points_per_node)
Set the maximum points per leaf node.
static bool contains_only(Node *node, const Point &p)
Return true when every point stored in a leaf equals p.
static Node * make_root(const Geom_Number &min_x, const Geom_Number &max_x, const Geom_Number &min_y, const Geom_Number &max_y, const size_t capacity)
Validate constructor arguments and allocate the root node.
void split(Node *node)
Subdivide a leaf node into four children.
static size_t leaf_children_size(Node *node) noexcept
Return the number of points directly stored in four leaf children.
void operate_on_nodes(Node *r, Op &op)
Apply operation to all nodes in the tree.
QuadTree(const QuadTree &tree)
Copy constructor - creates a deep copy of the tree.
QuadTree(QuadTree &&tree) noexcept
Move constructor - transfers ownership.
bool contains(const Point &p) const noexcept
Check if a point is within the tree's region.
Point * insert(Node *&r, const Point &p)
Recursive insert helper.
size_t get_max_num_points_per_node() const noexcept
Get the maximum points per leaf node.
QuadTree & operator=(const QuadTree &tree)
Copy assignment operator - creates a deep copy.
void join(Node *node)
Merge four child nodes back into their parent.
Point * insert(const Point &p)
Insert a point into the tree.
Node * get_root() noexcept
Get the root node.
Node * root
Root node of the tree.
void empty()
Remove all points from the tree, keeping only the root.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
and
Check uniqueness with explicit hash + equality functors.
static bool is_leaf(BinNode< std::string > *p) noexcept
QuadTree node implementation for spatial data structures.