56struct QuadTreeSnapshot
72 snap.leaf_depths.append(depth);
73 for (
const Point & p : node->get_points_set())
74 snap.points.append(p);
86 QuadTreeSnapshot
snap;
95 static const char *
colors[] =
96 {
"blue!55",
"orange!70!black",
"green!55!black",
"red!60",
"violet!65",
"brown!60"};
131 for (
int i = 0; i < 24; ++i)
133 const int col = i % 6;
134 const int row = i / 6;
147 argc > 1 ?
argv[1] :
"tikz_tree_structures_example.tex";
152 std::cerr <<
"Cannot open output file: " <<
output_path <<
'\n';
158 kd_plane.put_coordinate_grid(5, 5,
true);
166 "KD-tree partitions=" + std::to_string(
kd_snap.partitions.size())),
182 "Range-tree nodes=" + std::to_string(
rv.snapshot.nodes.size()) +
183 ", hits=" + std::to_string(
rv.query_hits.size())),
197 "AABB nodes=" + std::to_string(
av.snapshot.nodes.size()) +
198 ", hits=" + std::to_string(
av.query_hit_ids.size())),
216 for (
size_t i = 0; i <
qsnap.leaf_regions.size(); ++i)
223 "QuadTree leaves=" + std::to_string(
qsnap.leaf_regions.size()) +
224 ", points=" + std::to_string(
qsnap.points.size())),
240 for (
size_t i = 0; i <
rects.size(); ++i)
250 "R-tree (Guttman) nodes=" + std::to_string(
rt_result.snapshot.nodes.size()) +
251 ", hits=" + std::to_string(
rt_result.query_hit_boxes.size())),
262 "R*-tree nodes=" + std::to_string(
rstar_result.snapshot.nodes.size()) +
263 ", hits=" + std::to_string(
rstar_result.query_hit_boxes.size())),
267 out <<
"\\documentclass[tikz,border=8pt]{standalone}\n"
268 <<
"\\usepackage{tikz}\n"
269 <<
"\\begin{document}\n\n";
272 out <<
"\n\\vspace{4mm}\n\n";
274 out <<
"\n\\vspace{4mm}\n\n";
276 out <<
"\n\\vspace{4mm}\n\n";
278 out <<
"\n\\vspace{4mm}\n\n";
280 out <<
"\n\\vspace{4mm}\n\n";
282 out <<
"\n\\end{document}\n";
285 std::cout <<
"Compile with: pdflatex " <<
output_path <<
'\n';
size_t size_t int32_t * out
Axis-aligned bounding box tree for spatial queries.
size_t build(Array< size_t > &idx, const size_t lo, const size_t hi)
Simple dynamic array with automatic resizing and functional operations.
T & append(const T &data)
Append a copy of data
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
static KDTreePointSearch build(const Array< Point > &points, const Geom_Number &xmin, const Geom_Number &ymin, const Geom_Number &xmax, const Geom_Number &ymax)
Build a balanced KD-tree from a point array.
Represents a point with rectangular coordinates in a 2D plane.
Dynamic R-tree indexing axis-aligned rectangles by payload.
Static 2D range tree for orthogonal range queries.
void build(const DynList< Point > &points)
Build the range tree from a point set.
An axis-aligned rectangle.
Represents a text string positioned at a 2D point.
2D TikZ canvas storing geometry objects and emitting LaTeX output.
static constexpr int Layer_Default
static constexpr int Layer_Overlay
Node for QuadTree spatial data structure.
QuadNode *& get_sw_child() noexcept
Get reference to SW child (for reading/writing via SW_CHILD macro).
QuadNode *& get_se_child() noexcept
Get reference to SE child (for reading/writing via SE_CHILD macro).
QuadNode *& get_ne_child() noexcept
Get reference to NE child (for reading/writing via NE_CHILD macro).
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.
const Geom_Number & get_min_x() const noexcept
Get minimum X coordinate of this region.
QuadNode *& get_nw_child() noexcept
Get reference to NW child (for reading/writing via NW_CHILD macro).
bool is_leaf() const noexcept
Check if this node is a leaf (has no children).
const Geom_Number & get_max_x() const noexcept
Get maximum X coordinate of this region.
QuadTree - Hierarchical spatial index for 2D points.
Node * get_root() noexcept
Get the root node.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y0_function > > y0(const __gmp_expr< T, U > &expr)
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
AABBTreeQueryVizResult visualize_aabb_tree_query(Tikz_Plane &plane, const AABBTree &tree, const Rectangle &query_rect, const Tikz_Style &node_bbox_style=tikz_wire_style("teal!70!black"), const Tikz_Style &leaf_bbox_style=tikz_wire_style("blue!70"), const Tikz_Style &query_rect_style=tikz_wire_style("red", true), const Tikz_Style &query_hit_style=tikz_wire_style("red"))
Visualize AABB tree with a rectangle query overlay.
RangeTreeQueryVizResult visualize_range_tree_query(Tikz_Plane &plane, const RangeTree2D &tree, const Rectangle &query_rect, const bool draw_points=true, const Tikz_Style &split_style=tikz_wire_style("purple"), const Tikz_Style &point_style=tikz_points_style("black"), const Tikz_Style &query_rect_style=tikz_wire_style("red", true), const Tikz_Style &query_hit_style=tikz_points_style("red"))
Visualize range-tree plus a query rectangle and matching points.
void put_in_plane(Tikz_Plane &plane, const Geom &geom_obj)
Insert any supported geometry type in a Tikz_Plane.
KDTreePointSearch::DebugSnapshot visualize_kdtree_partitions(Tikz_Plane &plane, const KDTreePointSearch &kd_tree, const bool draw_partition_boxes=false, const bool draw_points=true, const Tikz_Style &partition_style=tikz_wire_style("gray!55", true), const Tikz_Style &split_style=tikz_wire_style("blue!70"), const Tikz_Style &point_style=tikz_points_style("red"))
Visualize KD-tree recursive space partitions.
void put_points(Tikz_Plane &plane, const Array< Point > &pts, const Tikz_Style &style=tikz_points_style(), const int layer=Tikz_Plane::Layer_Default)
Inserts all points from an Array<Point> into the plane.
mpq_class Geom_Number
Numeric type used by the geometry module.
RTreeQueryVizResult< Payload, MaxEntries, MinEntries, Variant > visualize_rtree_query(Tikz_Plane &plane, const RTree< Payload, MaxEntries, MinEntries, Variant > &tree, const Rectangle &query_rect, const Tikz_Style &node_bbox_style=tikz_wire_style("teal!70!black"), const Tikz_Style &leaf_bbox_style=tikz_wire_style("blue!70"), const Tikz_Style &entry_bbox_style=tikz_wire_style("gray!55"), const Tikz_Style &query_rect_style=tikz_wire_style("red", true), const Tikz_Style &query_hit_style=tikz_wire_style("red"))
Visualize an R-tree/R*-tree with a rectangle query overlay, highlighting every entry whose bbox inter...
Tikz_Style make_tikz_draw_style(const std::string &draw_color)
Create a basic draw style with a custom color.
Tikz_Style tikz_wire_style(const std::string &color="black", const bool dashed=false, const bool with_arrow=false)
Creates a style optimized for wireframe segments and polygons.
Tikz_Style tikz_points_style(const std::string &color="black", const double opacity=-1.0)
Creates a style optimized for point clouds.
QuadTree spatial data structure for efficient 2D point indexing.
Helpers to visualize computational-geometry algorithm results in TikZ.
R*-tree: an R-tree tuned with the Beckmann-Kriegel-Schneider-Seeger heuristics.