31#ifndef TIKZGEOM_ALGORITHMS_H
32#define TIKZGEOM_ALGORITHMS_H
42 static const char *colors[] = {
"blue!20",
"orange!25",
"green!20",
"red!20",
"cyan!22",
43 "magenta!20",
"yellow!28",
"teal!22",
"lime!24",
"brown!20"};
44 static constexpr size_t kNumColors =
sizeof(colors) /
sizeof(colors[0]);
45 return colors[idx % kNumColors];
60constexpr size_t SPP_NONE = ~static_cast<size_t>(0);
64 for (
size_t i = 0; i < pts.
size(); ++i)
74 for (
auto it = tl.
get_it(); it.has_curr(); it.next_ne())
81 ti.adj[0] = ti.adj[1] = ti.adj[2] =
SPP_NONE;
96 for (
size_t ti = 0; ti < tris.
size(); ++ti)
97 for (
int e = 0; e < 3; ++e)
99 size_t u = tris(ti).v[(e + 1) % 3];
100 size_t v = tris(ti).v[(e + 2) % 3];
103 edges.
append(EdgeEntry{u, v, ti,
static_cast<size_t>(e)});
106 quicksort_op(edges, [](
const EdgeEntry &a,
const EdgeEntry &b)
112 return a.tri < b.tri;
115 for (
size_t i = 0; i + 1 < edges.
size(); ++i)
116 if (edges(i).u == edges(i + 1).u
and edges(i).v == edges(i + 1).v)
118 const size_t t1 = edges(i).tri;
119 const size_t l1 = edges(i).local;
120 const size_t t2 = edges(i + 1).tri;
121 const size_t l2 = edges(i + 1).local;
122 tris(t1).adj[
l1] = t2;
123 tris(t2).adj[
l2] = t1;
138 return not (has_cw
and has_ccw);
144 for (
size_t i = 0; i < tris.
size(); ++i)
162 for (
size_t i = 0; i < tris.
size(); ++i)
175 for (
size_t nb : tris(cur).adj)
187 for (
size_t cur = dst; cur != src; cur = parent(cur))
191 for (
size_t i = 0; i < path.
size() / 2; ++i)
192 std::swap(path(i), path(path.
size() - 1 - i));
209 <<
"Source must be inside the polygon";
211 <<
"Target must be inside the polygon";
214 if (source == target)
220 const Segment seg(source, target);
221 bool blocked =
false;
235 pts.
append(it.get_current_vertex().to_point());
253 if (sleeve.
size() <= 1)
259 for (
size_t i = 0; i + 1 < sleeve.
size(); ++i)
261 size_t s0 = 0, s1 = 0;
265 bool found[3] = {
false,
false,
false};
266 for (
int a = 0; a < 3; ++a)
267 for (
const size_t b : tris(sleeve(i + 1)).v)
268 if (tris(sleeve(i)).v[a] == b)
274 for (
int a = 0; a < 3; ++a)
278 s0 = tris(sleeve(i)).v[a];
280 s1 = tris(sleeve(i)).v[a];
284 v_prev = tris(sleeve(i)).v[a];
391 const std::string &fill_color =
"gray!25",
392 const double opacity = 0.6)
413 for (
size_t i = 0; i < pts.
size(); ++i)
428 for (
auto it = pts.
get_it(); it.has_curr(); it.next_ne())
444 const std::string &
prefix =
"p",
445 const std::string &placement =
"above right",
449 for (
size_t i = 0; i < pts.
size(); ++i)
465 const std::string &
prefix =
"p",
466 const std::string &placement =
"above right",
471 for (
auto it = pts.
get_it(); it.has_curr(); it.next_ne(), ++idx)
487 for (
size_t i = 0; i < polys.
size(); ++i)
503 put_in_plane(plane, it.get_current_vertex().to_point(), style, layer);
517 for (
size_t i = 0; i < poly.
size(); ++i)
531 for (
size_t i = 0; i < vertices.
size(); ++i)
534 if (close
and poly.
size() >= 3)
554 for (
auto it = indices.
get_it(); it.has_curr(); it.next_ne())
555 if (
const size_t idx = it.get_curr(); idx < vertices.
size())
558 if (close
and poly.
size() >= 3)
583template <
typename HullAlgorithm>
585 const HullAlgorithm &hull_algorithm,
591 const bool draw_hull_vertices =
true)
593 put_points(plane, points, point_style, point_layer);
595 Polygon hull = hull_algorithm(points);
599 if (draw_hull_vertices
and hull.
size() > 0)
630 put_in_plane(plane, subject, subject_style, input_layer);
633 Polygon inter = intersection_algorithm(subject, clip);
634 if (inter.
size() > 0)
672 put_polygons(plane, result, result_style, result_layer);
683 const bool draw_sites =
true,
688 for (
size_t i = 0; i < dt.
triangles.size(); ++i)
706 auto dt = algorithm(points);
722 return {src.
get_x() + dx * scale, src.
get_y() + dy * scale};
730template <
typename VoronoiResult>
743 for (
size_t i = 0; i < vor.cells.size(); ++i)
745 const auto &
cell = vor.cells(i);
746 if (not
cell.bounded or
cell.vertices.size() < 3)
753 for (
size_t i = 0; i < vor.edges.size(); ++i)
754 if (
const auto &e = vor.edges(i); e.unbounded)
762 put_points(plane, vor.sites, site_style, site_layer);
771 const bool draw_cells =
false,
779 put_voronoi_result(plane, vor, draw_cells, cell_style, edge_style, unbounded_edge_style,
796 for (
size_t i = 0; i < pd.
cells.size(); ++i)
799 if (
cell.vertices.size() < 3)
806 for (
size_t i = 0; i < pd.
edges.size(); ++i)
808 const auto &e = pd.
edges(i);
812 for (
size_t i = 0; i < pd.
sites.size(); ++i)
819 const PowerDiagram &algorithm = {},
const bool draw_cells =
true,
834 const bool draw_vertices =
true,
const bool draw_unbounded_face =
false,
844 size_t face_color_idx = 0;
845 for (
size_t i = 0; i < arrangement.
faces.size(); ++i)
847 const auto &[boundary, unbounded] = arrangement.
faces(i);
848 if (unbounded
and not draw_unbounded_face)
852 if (poly.
size() >= 3)
855 if (color_faces_by_index)
868 for (
size_t i = 0; i < arrangement.
edges.size(); ++i)
870 const auto &e = arrangement.
edges(i);
871 if (e.src >= arrangement.
vertices.size() or e.tgt >= arrangement.
vertices.size())
875 edge_style, edge_layer);
885 const bool draw_faces =
true,
const bool draw_vertices =
true,
886 const bool draw_unbounded_face =
false,
890 const bool color_faces_by_index =
false)
896 color_faces_by_index);
903 const bool draw_partition_boxes =
false,
const bool draw_points =
true,
911 for (
size_t i = 0; i < snapshot.partitions.size(); ++i)
913 const auto &part = snapshot.partitions(i);
914 if (draw_partition_boxes)
915 put_in_plane(plane, part.region, partition_style, partition_layer);
924 Segment split_seg = part.split_on_x
934 put_points(plane, snapshot.points, point_style, point_layer);
946 split_style, point_style);
952 const bool draw_points =
true,
962 if (snapshot.x_sorted_points.size() == 0)
965 Geom_Number ymin = snapshot.x_sorted_points(0).get_y();
967 for (
size_t i = 1; i < snapshot.x_sorted_points.size(); ++i)
969 if (snapshot.x_sorted_points(i).get_y() < ymin)
970 ymin = snapshot.x_sorted_points(i).get_y();
971 if (snapshot.x_sorted_points(i).get_y() > ymax)
972 ymax = snapshot.x_sorted_points(i).get_y();
975 for (
size_t i = 0; i < snapshot.
nodes.size(); ++i)
977 const auto &node = snapshot.
nodes(i);
988 put_points(plane, snapshot.x_sorted_points, point_style, point_layer);
990 if (query_rect !=
nullptr)
991 put_in_plane(plane, *query_rect, query_rect_style, point_layer + 1);
993 if (query_hits !=
nullptr)
994 put_points(plane, *query_hits, query_hit_style, point_layer + 2);
1026 out.query_rect = query_rect;
1030 split_style, point_style, query_rect_style, query_hit_style);
1045 for (
size_t i = 0; i < snapshot.
nodes.size(); ++i)
1047 const auto &node = snapshot.
nodes(i);
1048 Tikz_Style style = node.is_leaf ? leaf_bbox_style : node_bbox_style;
1053 if (query_rect !=
nullptr)
1054 put_in_plane(plane, *query_rect, query_rect_style, query_layer);
1056 if (query_hit_ids !=
nullptr)
1057 for (
size_t i = 0; i < snapshot.
nodes.size(); ++i)
1058 if (snapshot.
nodes(i).is_leaf)
1059 for (
size_t j = 0; j < query_hit_ids->size(); ++j)
1060 if (snapshot.
nodes(i).user_index == (*query_hit_ids)(j))
1096 out.query_rect = query_rect;
1097 out.query_hit_ids = tree.
query(query_rect);
1099 leaf_bbox_style, query_rect_style, query_hit_style);
1112template <
typename Snapshot>
1125 for (
size_t i = 0; i < snapshot.
nodes.size(); ++i)
1127 const auto &node = snapshot.
nodes(i);
1128 Tikz_Style style = node.is_leaf ? leaf_bbox_style : node_bbox_style;
1133 for (
size_t j = 0; j < node.entry_boxes.size(); ++j)
1134 put_in_plane(plane, node.entry_boxes(j), entry_bbox_style, entry_layer);
1137 if (query_rect !=
nullptr)
1138 put_in_plane(plane, *query_rect, query_rect_style, query_layer);
1140 if (query_hit_boxes !=
nullptr)
1141 for (
size_t i = 0; i < query_hit_boxes->size(); ++i)
1142 put_in_plane(plane, (*query_hit_boxes)(i), query_hit_style, query_layer + 1);
1148template <
typename Payload,
size_t MaxEntries,
size_t MinEntries, RTreeVariant Variant>
1156 put_rtree_result(plane, snapshot,
nullptr,
nullptr, node_bbox_style, leaf_bbox_style,
1162template <
typename Payload,
size_t MaxEntries,
size_t MinEntries, RTreeVariant Variant>
1173template <
typename Payload,
size_t MaxEntries,
size_t MinEntries, RTreeVariant Variant>
1184 out.query_rect = query_rect;
1187 out.query_hit_boxes.append(bbox);
1190 leaf_bbox_style, entry_bbox_style, query_rect_style, query_hit_style);
1197 const bool draw_waypoints =
true,
1202 bool has_prev =
false;
1205 for (
auto it = path.
get_it(); it.has_curr(); it.next_ne())
1207 const Point &curr = it.get_curr();
1216 put_points(plane, path, waypoint_style, waypoint_layer);
1222 const bool draw_waypoints =
true,
1227 if (path.
size() == 0)
1230 for (
size_t i = 1; i < path.
size(); ++i)
1234 put_points(plane, path, waypoint_style, waypoint_layer);
1241 const bool skip_degenerate =
true,
1245 for (
size_t i = 0; i < portals.
size(); ++i)
1247 const auto &[left, right] = portals(i);
1248 if (skip_degenerate
and left == right)
1296 if (trace.portals.size() == 0)
1299 Point apex = source;
1307 committed.
append(source);
1309 for (
size_t i = 1; i < trace.portals.size(); ++i)
1311 const Point &pr = trace.portals(i).right;
1312 const Point &pl = trace.portals(i).left;
1323 bool restart =
false;
1377 trace.steps.append(step);
1383 committed.
append(target);
1384 trace.final_path = committed;
1407 put_in_plane(plane, polygon, polygon_style, polygon_layer);
1408 put_in_plane(plane, source, source_style, highlight_layer + 1);
1409 put_in_plane(plane, target, target_style, highlight_layer + 1);
1411 put_portals(plane, trace.portals,
true, all_portals_style, portal_layer);
1413 if (trace.steps.size() == 0)
1416 if (step_index >= trace.steps.size())
1417 step_index = trace.steps.size() - 1;
1434 highlight_layer + 1, highlight_layer + 2);
1453 put_in_plane(plane, polygon, polygon_style, polygon_layer);
1454 put_in_plane(plane, source, source_style, path_layer + 1);
1455 put_in_plane(plane, target, target_style, path_layer + 1);
1458 put_path(plane, path, path_style, draw_waypoints, waypoint_style, path_layer, path_layer + 1);
1482 put_in_plane(plane, polygon, polygon_style, polygon_layer);
1483 put_in_plane(plane, source, source_style, portal_layer + 1);
1484 put_in_plane(plane, target, target_style, portal_layer + 1);
1488 put_portals(plane,
out.portals,
true, portal_style, portal_layer);
1490 out.path = algorithm(polygon, source, target);
1491 put_path(plane,
out.path, path_style, draw_waypoints, waypoint_style, path_layer, path_layer + 1);
1504 size_t color_idx = 0;
1505 for (
size_t i = 0; i < parts.
size(); ++i)
1508 if (color_parts_by_index)
1523 const bool draw_input_polygon =
true,
1525 const bool color_parts_by_index =
true,
1530 if (draw_input_polygon)
1531 put_in_plane(plane, polygon, input_style, input_layer);
1548 if (draw_kept_triangles)
1549 for (
size_t n = 0; n < alpha_shape.
triangles.size(); ++n)
1551 const auto &[i, j,
k] = alpha_shape.
triangles(n);
1552 if (i >= alpha_shape.
sites.size() or j >= alpha_shape.
sites.size() or
1553 k >= alpha_shape.
sites.size())
1558 triangle_style, triangle_layer);
1571 const AlphaShape &algorithm = {},
const bool draw_kept_triangles =
false,
1591 for (
size_t i = 0; i < rt.
triangles.size(); ++i)
1595 put_in_plane(plane, t, triangle_style, triangle_layer);
1599 for (
size_t i = 0; i < rt.
sites.size(); ++i)
1610 auto result = algorithm(weighted_sites);
1624 put_points(plane, points, points_style, points_layer);
1637 auto result = algorithm(points);
1659 put_in_plane(plane, polygon, polygon_style, polygon_layer);
1691 for (
size_t i = 0; i < halfplanes.
size(); ++i)
1692 put_in_plane(plane,
Segment(halfplanes(i).p, halfplanes(i).q), boundary_style, boundary_layer);
1694 if (intersection.
size() > 0)
1695 put_in_plane(plane, intersection, result_style, result_layer);
1705 Polygon intersection = algorithm(halfplanes);
1707 return intersection;
1720 put_in_plane(plane, second, second_style, input_layer + 1);
1721 if (result.
size() > 0)
1722 put_in_plane(plane, result, result_style, result_layer);
1733 Polygon result = algorithm(first, second);
1746 put_in_plane(plane, polygon, polygon_style, polygon_layer);
1747 for (
auto it = triangles.
get_it(); it.has_curr(); it.next_ne())
1748 put_in_plane(plane, it.get_curr(), triangle_style, triangle_layer);
1771 put_in_plane(plane, polygon, polygon_style, polygon_layer);
1772 if (visibility_polygon.
size() > 0)
1773 put_in_plane(plane, visibility_polygon, visibility_style, visibility_layer);
1774 put_in_plane(plane, query_point, query_style, visibility_layer + 1);
1784 Polygon visibility_polygon = algorithm(polygon, query_point);
1786 visibility_style, query_style);
1787 return visibility_polygon;
1798 for (
size_t i = 0; i < segments.
size(); ++i)
1799 put_in_plane(plane, segments(i), segment_style, segment_layer);
1801 for (
size_t i = 0; i < intersections.
size(); ++i)
1802 put_in_plane(plane, intersections(i).point, intersection_style, intersection_layer);
1814 return intersections;
1825 const bool draw_sites =
true,
1831 for (
size_t i = 0; i < cdt.
triangles.size(); ++i)
1835 put_in_plane(plane, t, triangle_style, triangle_layer);
1842 put_in_plane(plane, s, constraint_style, constraint_layer);
1857 auto result = algorithm(points, constraints);
1858 put_cdt_result(plane, result, triangle_style, constraint_style, draw_sites, site_style);
1873 const bool draw_sites =
true,
1882 put_points(plane, points, site_style, site_layer);
1895 auto circle = algorithm(points);
1896 put_mec_result(plane, circle, points, circle_style, draw_sites, site_style);
1939 Polygon simplified = algorithm.simplify_polygon(poly, epsilon);
1941 draw_vertices, vertex_style);
1957 Polygon simplified = algorithm.simplify_polygon(poly, area_threshold);
1959 draw_vertices, vertex_style);
1982 const bool draw_vertices =
true,
1986 for (
size_t i = 0; i < result.
polygons.size(); ++i)
2008 put_offset_result(plane, poly, result, original_style, offset_style, draw_vertices, vertex_style);
2030 const bool draw_vertices =
true,
2075 const bool draw_trapezoids =
true,
const double trapezoid_opacity = 0.3,
2083 if (draw_trapezoids)
2085 size_t color_idx = 0;
2086 for (
size_t i = 0; i < res.
trapezoids.size(); ++i)
2112 return (
y1 + y2) / 2;
2113 return y1 + (y2 -
y1) * (x - x1) / (x2 - x1);
2124 const Point tl_corner(lx, y_at_x(top_seg, lx));
2125 const Point tr_corner(rx, y_at_x(top_seg, rx));
2126 const Point br_corner(rx, y_at_x(bot_seg, rx));
2127 const Point bl_corner(lx, y_at_x(bot_seg, lx));
2134 ts.
opacity = trapezoid_opacity;
2170 for (
size_t j = 0; j < res.
trapezoids.size(); ++j)
2175 if (t.leftp == NONE or t.rightp == NONE)
2189 return (
y1 + y2) / 2;
2190 return y1 + (y2 -
y1) * (x - x1) / (x2 - x1);
2201 extension_style, ext_layer);
2218 const bool draw_trapezoids =
true,
const double trapezoid_opacity = 0.3)
2221 auto result = tm(segments);
2233 const bool draw_trapezoids =
true,
const double trapezoid_opacity = 0.3)
2236 auto result = tm(polygon);
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
static int cell(const aleph_ca_engine_t *e, size_t r, size_t c)
size_t size_t int32_t * out
Axis-aligned bounding box tree for spatial queries.
DebugSnapshot debug_snapshot() const
Return the full tree structure for visualization/debug.
Array< size_t > query(const Rectangle &query) const
Find all entries whose bounding box overlaps the query rectangle.
Alpha shape of a point set.
Simple dynamic array with automatic resizing and functional operations.
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
T & append(const T &data)
Append a copy of data
void reserve(size_t cap)
Reserves cap cells into the array.
Boolean operations on simple polygons (union, intersection, difference) using the Greiner-Hormann alg...
Op
Type of Boolean operation to perform.
static Polygon smooth_polygon(const Polygon &poly, size_t iterations, const Geom_Number &ratio=Geom_Number(1, 4))
Smooth a closed polygon.
Closest pair of points via divide and conquer.
Constrained Delaunay Triangulation via Sloan's flip-based method.
Decompose a simple polygon into convex parts using Hertel-Mehlhorn.
Basic exact intersection for closed convex polygons.
Polygon triangulation using the ear-cutting algorithm.
Exact Delaunay triangulation using the Bowyer-Watson incremental algorithm.
bool has_curr() const noexcept
Return true if the iterator has current item.
Douglas-Peucker polyline simplification.
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
T remove_first()
See remove().
constexpr bool is_empty() const noexcept
Exact bounded intersection of half-planes.
Spatial point index for O(log n) nearest-neighbor queries.
DebugSnapshot debug_snapshot() const
Build a deterministic geometric partition snapshot for visualization.
Smallest circle enclosing a point set (Welzl's algorithm).
Exact Minkowski sum of two closed convex polygons.
O(n log n) triangulation of simple polygons via y-monotone partition + linear-time monotone triangula...
static bool contains(const Polygon &poly, const Point &p)
Return true if the point is inside or on the boundary.
Represents a point with rectangular coordinates in a 2D plane.
const Geom_Number & get_x() const noexcept
Gets the x-coordinate value.
const Geom_Number & get_y() const noexcept
Gets the y-coordinate value.
Offset (inflate/deflate) an arbitrary simple polygon.
JoinType
Strategy for connecting offset edges at vertices.
@ Miter
Extend edges until they intersect.
Iterator over the edges (segments) of a polygon.
bool has_curr() const
Check if there is a current segment.
A general (irregular) 2D polygon defined by a sequence of vertices.
void add_vertex(const Point &point)
Add a vertex to the polygon.
void close()
Close the polygon.
const bool & is_closed() const
Check if the polygon is closed.
const size_t & size() const
Get the number of vertices.
Power diagram (weighted Voronoi diagram).
Dynamic R-tree indexing axis-aligned rectangles by payload.
DebugSnapshot debug_snapshot() const
Capture the full tree structure for visualization/debugging.
void for_each_intersecting(const Rectangle &rect, F &&f) const
Invoke f for every entry whose bbox intersects rect.
Static 2D range tree for orthogonal range queries.
DynList< Point > query(const Geom_Number &xmin, const Geom_Number &xmax, const Geom_Number &ymin, const Geom_Number &ymax) const
Query: return all points inside [xmin,xmax] × [ymin,ymax].
DebugSnapshot debug_snapshot() const
Return structural snapshot for visualization/debug.
An axis-aligned rectangle.
const Geom_Number & get_xmin() const
Gets the minimum x-coordinate.
const Geom_Number & get_ymax() const
Gets the maximum y-coordinate.
const Geom_Number & get_ymin() const
Gets the minimum y-coordinate.
const Geom_Number & get_xmax() const
Gets the maximum x-coordinate.
Exact regular triangulation (weighted Delaunay) via Bowyer-Watson.
A regular polygon defined by center, side length, and vertex count.
Point get_vertex(const size_t &i) const
Get the i-th vertex of the polygon.
const size_t & size() const
Get the number of vertices.
static DiameterResult diameter(const Polygon &poly)
Compute convex polygon diameter (farthest vertex pair).
static WidthResult minimum_width(const Polygon &poly)
Compute the minimum width of a closed convex polygon.
Compute the full planar subdivision induced by a set of segments.
Represents a line segment between two points.
bool intersects_properly_with(const Segment &s) const
Checks if this segment properly intersects another segment.
const Point & get_tgt_point() const noexcept
Gets the target point of the segment.
const Point & get_src_point() const noexcept
Gets the source point of the segment.
Compute the shortest Euclidean path between two points inside a simple polygon.
Report all pairwise intersection points among a set of segments.
2D TikZ canvas storing geometry objects and emitting LaTeX output.
static constexpr int Layer_Default
static constexpr int Layer_Foreground
static constexpr int Layer_Background
static constexpr int Layer_Overlay
O(log n) point location via trapezoidal map with DAG search.
static constexpr size_t NONE
A non-degenerate triangle defined by three points.
const Point & get_p3() const
Gets the third vertex.
const Point & get_p2() const
Gets the second vertex.
const Point & get_p1() const
Gets the first vertex.
Compute the visibility polygon from a point inside a simple polygon.
Visvalingam-Whyatt polyline simplification.
O(n log n) Voronoi diagram construction.
auto get_it()
Return a properly initialized iterator positioned at the first item on the container.
Computational geometry algorithms.
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y1_function > > y1(const __gmp_expr< T, U > &expr)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_y0_function > > y0(const __gmp_expr< T, U > &expr)
bool spp_point_in_triangle(const Array< Point > &pts, const SPP_ITri &t, const Point &p)
size_t spp_find_tri(const Array< Point > &pts, const Array< SPP_ITri > &tris, const Point &p)
constexpr size_t SPP_NONE
size_t spp_find_index(const Array< Point > &pts, const Point &p)
Array< size_t > spp_find_sleeve(const Array< SPP_ITri > &tris, const size_t src, const size_t dst)
std::string tikz_palette_color(const size_t idx)
Geom_Number spp_cross(const Point &a, const Point &b, const Point &c)
Array< SPP_Portal > shortest_path_portals(const Polygon &polygon, const Point &source, const Point &target)
Array< SPP_ITri > spp_build_tris(const Array< Point > &pts, const DynList< Triangle > &tl)
Main namespace for Aleph-w library functions.
void put_convex_decomposition_result(Tikz_Plane &plane, const Array< Polygon > &parts, const bool color_parts_by_index=true, const Tikz_Style &part_style=tikz_area_style("blue!60!black", "blue!15", 0.40), const int part_layer=Tikz_Plane::Layer_Default)
Insert convex decomposition polygons.
void put_half_plane_intersection_result(Tikz_Plane &plane, const Array< HalfPlaneIntersection::HalfPlane > &halfplanes, const Polygon &intersection, const Tikz_Style &boundary_style=tikz_wire_style("gray!60", true, true), const Tikz_Style &result_style=tikz_area_style("red", "red!25", 0.50), const int boundary_layer=Tikz_Plane::Layer_Default, const int result_layer=Tikz_Plane::Layer_Foreground)
Draw half-plane boundaries and their bounded intersection polygon.
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.
void put_rtree_result(Tikz_Plane &plane, const Snapshot &snapshot, const Rectangle *query_rect=nullptr, const Array< Rectangle > *query_hit_boxes=nullptr, 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"), const int node_layer=Tikz_Plane::Layer_Default, const int entry_layer=Tikz_Plane::Layer_Default, const int query_layer=Tikz_Plane::Layer_Foreground)
Draw every node MBR (colored by depth) of an R-tree/R*-tree snapshot, plus its leaf entry boxes,...
void put_range_tree_result(Tikz_Plane &plane, const RangeTree2D::DebugSnapshot &snapshot, const bool draw_points=true, const Rectangle *query_rect=nullptr, const DynList< Point > *query_hits=nullptr, 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"), const int split_layer=Tikz_Plane::Layer_Default, const int point_layer=Tikz_Plane::Layer_Foreground)
Draw range-tree X-axis hierarchy and optional query highlights.
Polygon visualize_convex_intersection(Tikz_Plane &plane, const Polygon &subject, const Polygon &clip, const ConvexPolygonIntersectionBasic &intersection_algorithm={}, const Tikz_Style &subject_style=tikz_area_style("blue", "blue!15", 0.45), const Tikz_Style &clip_style=tikz_area_style("orange", "orange!20", 0.45), const Tikz_Style &result_style=tikz_area_style("red", "red!30", 0.60), const int input_layer=Tikz_Plane::Layer_Default, const int result_layer=Tikz_Plane::Layer_Foreground)
Visualizes the intersection of two convex polygons.
Orientation
Classification of three-point orientation.
AlphaShape::Result visualize_alpha_shape(Tikz_Plane &plane, const DynList< Point > &points, const Geom_Number &alpha_squared, const AlphaShape &algorithm={}, const bool draw_kept_triangles=false, const Tikz_Style &triangle_style=tikz_wire_style("gray!55"), const Tikz_Style &boundary_style=tikz_path_style("orange!90!black"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"))
Compute and insert alpha-shape for input points.
void put_funnel_trace_step(Tikz_Plane &plane, const Polygon &polygon, const Point &source, const Point &target, const FunnelTraceResult &trace, size_t step_index, const Tikz_Style &polygon_style=tikz_area_style("black", "gray!15", 0.22), const Tikz_Style &source_style=tikz_points_style("green!50!black"), const Tikz_Style &target_style=tikz_points_style("blue"), const Tikz_Style &all_portals_style=tikz_wire_style("purple", true), const Tikz_Style &active_portal_style=tikz_path_style("purple"), const Tikz_Style &funnel_leg_style=tikz_path_style("orange!90!black"), const Tikz_Style &committed_style=tikz_path_style("red"), const bool draw_waypoints=true, const Tikz_Style &waypoint_style=tikz_points_style("red"), const int polygon_layer=Tikz_Plane::Layer_Default, const int portal_layer=Tikz_Plane::Layer_Foreground, const int highlight_layer=Tikz_Plane::Layer_Overlay)
Render one funnel-trace frame in a plane.
PolygonOffset::Result visualize_polygon_offset(Tikz_Plane &plane, const Polygon &poly, const Geom_Number &distance, const PolygonOffset &algorithm={}, PolygonOffset::JoinType join=PolygonOffset::JoinType::Miter, const Geom_Number &miter_limit=Geom_Number(2), const Tikz_Style &original_style=tikz_wire_style("gray!50"), const Tikz_Style &offset_style=tikz_bold_wire_style("blue!80"), const bool draw_vertices=true, const Tikz_Style &vertex_style=tikz_points_style("red"))
Offset a polygon and draw the result.
Tikz_Style tikz_bold_wire_style(const std::string &color, const double width_mm=1.2)
Creates a solid wireframe style with an explicit line width.
void put_visibility_polygon_result(Tikz_Plane &plane, const Polygon &polygon, const Point &query_point, const Polygon &visibility_polygon, const Tikz_Style &polygon_style=tikz_wire_style("black"), const Tikz_Style &visibility_style=tikz_area_style("orange!90!black", "orange!25", 0.50), const Tikz_Style &query_style=tikz_points_style("red"), const int polygon_layer=Tikz_Plane::Layer_Default, const int visibility_layer=Tikz_Plane::Layer_Foreground)
Draw visibility polygon with source polygon and query point.
void put_rotating_calipers_result(Tikz_Plane &plane, const Polygon &polygon, const RotatingCalipersResult &result, const Tikz_Style &polygon_style=tikz_wire_style("gray!55"), const Tikz_Style &diameter_style=tikz_path_style("red"), const Tikz_Style &width_style=tikz_path_style("blue"), const Tikz_Style &witness_style=tikz_points_style("orange!90!black"), const int polygon_layer=Tikz_Plane::Layer_Default, const int witness_layer=Tikz_Plane::Layer_Foreground)
Draw diameter and minimum-width witnesses for a convex polygon.
@ Trap
Unreachable code path marker.
Polygon visualize_visvalingam_whyatt(Tikz_Plane &plane, const Polygon &poly, const Geom_Number &area_threshold, const VisvalingamWhyattSimplification &algorithm={}, const Tikz_Style &original_style=tikz_wire_style("gray!50"), const Tikz_Style &simplified_style=tikz_bold_wire_style("green!70!black"), const bool draw_vertices=true, const Tikz_Style &vertex_style=tikz_points_style("red"))
Simplify a polygon with Visvalingam-Whyatt and draw the result.
void put_cdt_result(Tikz_Plane &plane, const ConstrainedDelaunayTriangulation::Result &cdt, const Tikz_Style &triangle_style=tikz_wire_style("blue!60"), const Tikz_Style &constraint_style=tikz_path_style("red"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"), const int triangle_layer=Tikz_Plane::Layer_Default, const int constraint_layer=Tikz_Plane::Layer_Foreground, const int site_layer=Tikz_Plane::Layer_Overlay)
Insert constrained Delaunay triangulation result.
AABBTree::DebugSnapshot visualize_aabb_tree(Tikz_Plane &plane, const AABBTree &tree, const Tikz_Style &node_bbox_style=tikz_wire_style("teal!70!black"), const Tikz_Style &leaf_bbox_style=tikz_wire_style("blue!70"))
Visualize AABB tree hierarchy.
MinimumEnclosingCircle::Circle visualize_mec(Tikz_Plane &plane, const DynList< Point > &points, const MinimumEnclosingCircle &algorithm={}, const Tikz_Style &circle_style=tikz_wire_style("blue!70"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"))
Compute minimum enclosing circle and insert into plane.
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.
PowerDiagram::Result visualize_power_diagram(Tikz_Plane &plane, const Array< PowerDiagram::WeightedSite > &sites, const PowerDiagram &algorithm={}, const bool draw_cells=true, const Tikz_Style &cell_style=tikz_area_style("violet", "violet!18", 0.35), const Tikz_Style &edge_style=tikz_wire_style("violet"), const Tikz_Style &site_style=tikz_points_style("purple"))
Compute and insert Power diagram for weighted sites.
void put_alpha_shape_result(Tikz_Plane &plane, const AlphaShape::Result &alpha_shape, const bool draw_kept_triangles=false, const Tikz_Style &triangle_style=tikz_wire_style("gray!55"), const Tikz_Style &boundary_style=tikz_path_style("orange!90!black"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"), const int triangle_layer=Tikz_Plane::Layer_Background, const int boundary_layer=Tikz_Plane::Layer_Foreground, const int site_layer=Tikz_Plane::Layer_Overlay)
Insert alpha-shape structures (kept triangles, boundary, sites).
DelaunayTriangulationBowyerWatson::Result visualize_delaunay(Tikz_Plane &plane, const DynList< Point > &points, const DelaunayTriangulationBowyerWatson &algorithm={}, const Tikz_Style &triangle_style=tikz_wire_style("blue"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"))
Compute and insert Delaunay triangulation as triangle outlines.
RangeTree2D::DebugSnapshot visualize_range_tree(Tikz_Plane &plane, const RangeTree2D &tree, const bool draw_points=true, const Tikz_Style &split_style=tikz_wire_style("purple"), const Tikz_Style &point_style=tikz_points_style("black"))
Visualize range-tree structure without a query overlay.
void put_monotone_triangulation_result(Tikz_Plane &plane, const Polygon &polygon, const DynList< Triangle > &triangles, const Tikz_Style &polygon_style=tikz_wire_style("black"), const Tikz_Style &triangle_style=tikz_wire_style("blue!65"), const int polygon_layer=Tikz_Plane::Layer_Default, const int triangle_layer=Tikz_Plane::Layer_Foreground)
Draw a monotone triangulation result plus polygon boundary.
VoronoiDiagram::Result visualize_voronoi(Tikz_Plane &plane, const DynList< Point > &sites, const VoronoiDiagram &algorithm={}, const bool draw_cells=false, const Tikz_Style &cell_style=tikz_area_style("gray!50!black", "gray!15", 0.35), const Tikz_Style &edge_style=tikz_wire_style("black"), const Tikz_Style &unbounded_edge_style=tikz_wire_style("black", true, true), const Tikz_Style &site_style=tikz_points_style("red"), const Geom_Number &unbounded_ray_length=Geom_Number(50))
Compute and insert Voronoi diagram for input sites.
RegularTriangulationBowyerWatson::Result visualize_regular_triangulation(Tikz_Plane &plane, const Array< RegularTriangulationBowyerWatson::WeightedSite > &weighted_sites, const RegularTriangulationBowyerWatson &algorithm={}, const Tikz_Style &triangle_style=tikz_wire_style("blue!60"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"))
Compute and insert regular (weighted Delaunay) triangulation.
Polygon visualize_half_plane_intersection(Tikz_Plane &plane, const Array< HalfPlaneIntersection::HalfPlane > &halfplanes, const HalfPlaneIntersection &algorithm={}, const Tikz_Style &boundary_style=tikz_wire_style("gray!60", true, true), const Tikz_Style &result_style=tikz_area_style("red", "red!25", 0.50))
Compute and draw bounded half-plane intersection.
TrapezoidalMapPointLocation::Result visualize_trapezoidal_map(Tikz_Plane &plane, const Array< Segment > &segments, const Tikz_Style &segment_style=tikz_path_style("red"), const Tikz_Style &extension_style=tikz_wire_style("gray!60", true), const bool draw_trapezoids=true, const double trapezoid_opacity=0.3)
Build a trapezoidal map and draw it.
Polygon polygon_from_vertex_indices(const Array< Point > &vertices, const DynList< size_t > &indices, const bool close=true)
Constructs a Polygon from a list of indices into a vertex array.
void put_in_plane(Tikz_Plane &plane, const Geom &geom_obj)
Insert any supported geometry type in a Tikz_Plane.
RTree< Payload, MaxEntries, MinEntries, Variant >::DebugSnapshot visualize_rtree(Tikz_Plane &plane, const RTree< Payload, MaxEntries, MinEntries, Variant > &tree, 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"))
Visualize an R-tree/R*-tree hierarchy (node MBRs by depth, plus leaf entry boxes).
Polygon visualize_visibility_polygon(Tikz_Plane &plane, const Polygon &polygon, const Point &query_point, const VisibilityPolygon &algorithm={}, const Tikz_Style &polygon_style=tikz_wire_style("black"), const Tikz_Style &visibility_style=tikz_area_style("orange!90!black", "orange!25", 0.50), const Tikz_Style &query_style=tikz_points_style("red"))
Compute and draw visibility polygon from a query point.
void put_mec_result(Tikz_Plane &plane, const MinimumEnclosingCircle::Circle &circle, const DynList< Point > &points, const Tikz_Style &circle_style=tikz_wire_style("blue!70"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"), const int circle_layer=Tikz_Plane::Layer_Default, const int site_layer=Tikz_Plane::Layer_Overlay)
Draw a precomputed minimum enclosing circle result.
Polygon polygon_from_vertices(const Array< Point > &vertices, const bool close=true)
Constructs a Polygon from an ordered array of vertices.
void put_minkowski_sum_result(Tikz_Plane &plane, const Polygon &first, const Polygon &second, const Polygon &result, const Tikz_Style &first_style=tikz_area_style("blue", "blue!14", 0.30), const Tikz_Style &second_style=tikz_area_style("green!60!black", "green!16", 0.30), const Tikz_Style &result_style=tikz_area_style("red", "red!26", 0.60), const int input_layer=Tikz_Plane::Layer_Default, const int result_layer=Tikz_Plane::Layer_Foreground)
Draw input polygons and their Minkowski sum result.
void put_closest_pair_result(Tikz_Plane &plane, const DynList< Point > &points, const ClosestPairDivideAndConquer::Result &result, const Tikz_Style &points_style=tikz_points_style("black"), const Tikz_Style &pair_style=tikz_path_style("red"), const Tikz_Style &pair_points_style=tikz_points_style("red"), const int points_layer=Tikz_Plane::Layer_Default, const int pair_layer=Tikz_Plane::Layer_Foreground)
Draw closest-pair result over the full point set.
void put_segment_arrangement_result(Tikz_Plane &plane, const SegmentArrangement::Result &arrangement, const bool draw_faces=true, const bool draw_vertices=true, const bool draw_unbounded_face=false, const Tikz_Style &face_style=tikz_area_style("teal!60!black", "teal!12", 0.30), const Tikz_Style &edge_style=tikz_wire_style("teal!70!black"), const Tikz_Style &vertex_style=tikz_points_style("teal!70!black"), const int face_layer=Tikz_Plane::Layer_Background, const int edge_layer=Tikz_Plane::Layer_Default, const int vertex_layer=Tikz_Plane::Layer_Foreground, const bool color_faces_by_index=false)
Insert segment arrangement structures (faces, edges, vertices).
void put_kdtree_partitions_result(Tikz_Plane &plane, const KDTreePointSearch::DebugSnapshot &snapshot, 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"), const int partition_layer=Tikz_Plane::Layer_Background, const int split_layer=Tikz_Plane::Layer_Default, const int point_layer=Tikz_Plane::Layer_Foreground)
Draw KD-tree partitions from a debug snapshot.
Geom_Number square_root(const Geom_Number &x)
Square root of x (wrapper over mpfr).
static void prefix(Node *root, DynList< Node * > &acc)
ShortestPathDebugResult visualize_shortest_path_with_portals(Tikz_Plane &plane, const Polygon &polygon, const Point &source, const Point &target, const ShortestPathInPolygon &algorithm={}, const Tikz_Style &polygon_style=tikz_area_style("black", "gray!15", 0.25), const Tikz_Style &source_style=tikz_points_style("green!50!black"), const Tikz_Style &target_style=tikz_points_style("blue"), const Tikz_Style &portal_style=tikz_wire_style("purple", true), const Tikz_Style &path_style=tikz_path_style("red"), const bool draw_waypoints=true, const Tikz_Style &waypoint_style=tikz_points_style("red"), const int polygon_layer=Tikz_Plane::Layer_Default, const int portal_layer=Tikz_Plane::Layer_Foreground, const int path_layer=Tikz_Plane::Layer_Overlay)
Visualize the shortest path plus funnel portals.
void put_polygon_vertices(Tikz_Plane &plane, const Polygon &poly, const Tikz_Style &style=tikz_points_style(), const int layer=Tikz_Plane::Layer_Overlay)
Inserts the vertices of a polygon as styled points.
Array< SweepLineSegmentIntersection::Intersection > visualize_line_sweep(Tikz_Plane &plane, const Array< Segment > &segments, const SweepLineSegmentIntersection &algorithm={}, const Tikz_Style &segment_style=tikz_wire_style("blue!60"), const Tikz_Style &intersection_style=tikz_points_style("red"))
Compute and draw Bentley-Ottmann line-sweep intersections.
void put_regular_triangulation_result(Tikz_Plane &plane, const RegularTriangulationBowyerWatson::Result &rt, const Tikz_Style &triangle_style=tikz_wire_style("blue!60"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"), const int triangle_layer=Tikz_Plane::Layer_Default, const int site_layer=Tikz_Plane::Layer_Foreground)
Draw regular (weighted Delaunay) triangulation output.
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.
Tikz_Style tikz_path_style(const std::string &color="red", const bool with_arrow=false)
Creates a style optimized for polyline paths.
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.
void put_offset_result(Tikz_Plane &plane, const Polygon &original, const PolygonOffset::Result &result, const Tikz_Style &original_style=tikz_wire_style("gray!50"), const Tikz_Style &offset_style=tikz_bold_wire_style("blue!80"), const bool draw_vertices=true, const Tikz_Style &vertex_style=tikz_points_style("red"))
Draw a polygon offset result overlaid on the original polygon.
and
Check uniqueness with explicit hash + equality functors.
void put_simplification_result(Tikz_Plane &plane, const Polygon &original, const Polygon &simplified, const Tikz_Style &original_style=tikz_wire_style("gray!50"), const Tikz_Style &simplified_style=tikz_bold_wire_style("blue!80"), const bool draw_vertices=true, const Tikz_Style &vertex_style=tikz_points_style("red"))
Draw original and simplified polygons overlaid.
void put_power_diagram_result(Tikz_Plane &plane, const PowerDiagram::Result &pd, const bool draw_cells=true, const Tikz_Style &cell_style=tikz_area_style("violet", "violet!18", 0.35), const Tikz_Style &edge_style=tikz_wire_style("violet"), const Tikz_Style &site_style=tikz_points_style("purple"), const int cell_layer=Tikz_Plane::Layer_Background, const int edge_layer=Tikz_Plane::Layer_Default, const int site_layer=Tikz_Plane::Layer_Foreground)
Insert Power diagram structures (cells, edges, weighted sites).
Orientation orientation(const Point &a, const Point &b, const Point &c)
Return the orientation of the triple (a, b, c).
void put_polygons(Tikz_Plane &plane, const Array< Polygon > &polys, const Tikz_Style &style=tikz_wire_style(), const int layer=Tikz_Plane::Layer_Default)
Inserts all polygons from an Array<Polygon> into the plane.
void put_voronoi_result(Tikz_Plane &plane, const VoronoiResult &vor, const bool draw_cells=false, const Tikz_Style &cell_style=tikz_area_style("gray!50!black", "gray!15", 0.35), const Tikz_Style &edge_style=tikz_wire_style("black"), const Tikz_Style &unbounded_edge_style=tikz_wire_style("black", true, true), const Tikz_Style &site_style=tikz_points_style("red"), const Geom_Number &unbounded_ray_length=Geom_Number(50), const int cell_layer=Tikz_Plane::Layer_Background, const int edge_layer=Tikz_Plane::Layer_Default, const int site_layer=Tikz_Plane::Layer_Foreground)
Insert Voronoi diagram structures (cells, edges, sites).
mpq_class Geom_Number
Numeric type used by the geometry module.
DynList< Point > visualize_shortest_path_in_polygon(Tikz_Plane &plane, const Polygon &polygon, const Point &source, const Point &target, const ShortestPathInPolygon &algorithm={}, const Tikz_Style &polygon_style=tikz_area_style("black", "gray!15", 0.25), const Tikz_Style &source_style=tikz_points_style("green!50!black"), const Tikz_Style &target_style=tikz_points_style("blue"), const Tikz_Style &path_style=tikz_path_style("red"), const bool draw_waypoints=true, const Tikz_Style &waypoint_style=tikz_points_style("red"), const int polygon_layer=Tikz_Plane::Layer_Default, const int path_layer=Tikz_Plane::Layer_Foreground)
Visualize the shortest path inside a simple polygon.
void put_point_label_in_plane(Tikz_Plane &plane, const Point &point, const std::string &label, const std::string &placement="above", const Tikz_Style &style=make_tikz_draw_style("black"), const int layer=Tikz_Plane::Layer_Overlay)
Insert a point label with configurable placement (above, etc.).
ClosestPairDivideAndConquer::Result visualize_closest_pair(Tikz_Plane &plane, const DynList< Point > &points, const ClosestPairDivideAndConquer &algorithm={}, const Tikz_Style &points_style=tikz_points_style("black"), const Tikz_Style &pair_style=tikz_path_style("red"), const Tikz_Style &pair_points_style=tikz_points_style("red"))
Compute and draw the closest pair from an input point set.
void put_point_labels(Tikz_Plane &plane, const Array< Point > &pts, const std::string &prefix="p", const std::string &placement="above right", const Tikz_Style &style=make_tikz_draw_style("black"), const int layer=Tikz_Plane::Layer_Overlay)
Adds a text label to each point in an Array<Point>.
void put_line_sweep_result(Tikz_Plane &plane, const Array< Segment > &segments, const Array< SweepLineSegmentIntersection::Intersection > &intersections, const Tikz_Style &segment_style=tikz_wire_style("blue!60"), const Tikz_Style &intersection_style=tikz_points_style("red"), const int segment_layer=Tikz_Plane::Layer_Default, const int intersection_layer=Tikz_Plane::Layer_Foreground)
Draw line segments and all sweep-line intersection points.
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...
RotatingCalipersResult visualize_rotating_calipers(Tikz_Plane &plane, const Polygon &polygon, const Tikz_Style &polygon_style=tikz_wire_style("gray!55"), const Tikz_Style &diameter_style=tikz_path_style("red"), const Tikz_Style &width_style=tikz_path_style("blue"), const Tikz_Style &witness_style=tikz_points_style("orange!90!black"))
Compute and draw rotating-calipers diameter and minimum width.
Tikz_Style make_tikz_draw_style(const std::string &draw_color)
Create a basic draw style with a custom color.
Polygon visualize_chaikin_smoothing(Tikz_Plane &plane, const Polygon &poly, const size_t iterations, const Geom_Number &ratio=Geom_Number(1, 4), const Tikz_Style &original_style=tikz_wire_style("gray!50"), const Tikz_Style &smoothed_style=tikz_bold_wire_style("violet!80"), const bool draw_vertices=true, const Tikz_Style &vertex_style=tikz_points_style("red"))
Smooth a polygon with Chaikin subdivision and draw the result.
void put_aabb_tree_result(Tikz_Plane &plane, const AABBTree::DebugSnapshot &snapshot, const Rectangle *query_rect=nullptr, const Array< size_t > *query_hit_ids=nullptr, 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"), const int node_layer=Tikz_Plane::Layer_Default, const int query_layer=Tikz_Plane::Layer_Foreground)
Draw AABB tree hierarchy and optional query results.
std::ostream & join(const C &c, const std::string &sep, std::ostream &out)
Join elements of an Aleph-style container into a stream.
Point ray_endpoint(const Point &src, const Point &direction, const Geom_Number &length)
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.
void put_trapezoidal_map_result(Tikz_Plane &plane, const TrapezoidalMapPointLocation::Result &res, const Tikz_Style &segment_style=tikz_path_style("red"), const Tikz_Style &extension_style=tikz_wire_style("gray!60", true), const bool draw_trapezoids=true, const double trapezoid_opacity=0.3, const int trap_layer=Tikz_Plane::Layer_Background, const int seg_layer=Tikz_Plane::Layer_Foreground, const int ext_layer=Tikz_Plane::Layer_Default)
Draw the trapezoidal map result into a Tikz_Plane.
ConstrainedDelaunayTriangulation::Result visualize_cdt(Tikz_Plane &plane, const DynList< Point > &points, const DynList< Segment > &constraints, const ConstrainedDelaunayTriangulation &algorithm={}, const Tikz_Style &triangle_style=tikz_wire_style("blue!60"), const Tikz_Style &constraint_style=tikz_path_style("red"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"))
Compute and insert constrained Delaunay triangulation.
SegmentArrangement::Result visualize_segment_arrangement(Tikz_Plane &plane, const Array< Segment > &segments, const SegmentArrangement &algorithm={}, const bool draw_faces=true, const bool draw_vertices=true, const bool draw_unbounded_face=false, const Tikz_Style &face_style=tikz_area_style("teal!60!black", "teal!12", 0.30), const Tikz_Style &edge_style=tikz_wire_style("teal!70!black"), const Tikz_Style &vertex_style=tikz_points_style("teal!70!black"), const bool color_faces_by_index=false)
Compute and insert arrangement for input segments.
Polygon visualize_minkowski_sum(Tikz_Plane &plane, const Polygon &first, const Polygon &second, const MinkowskiSumConvex &algorithm={}, const Tikz_Style &first_style=tikz_area_style("blue", "blue!14", 0.30), const Tikz_Style &second_style=tikz_area_style("green!60!black", "green!16", 0.30), const Tikz_Style &result_style=tikz_area_style("red", "red!26", 0.60))
Compute and draw Minkowski sum of two convex polygons.
Array< Polygon > visualize_boolean_operation(Tikz_Plane &plane, const Polygon &a, const Polygon &b, const BooleanPolygonOperations::Op op, const BooleanPolygonOperations &bop={}, const Tikz_Style &a_style=tikz_area_style("blue", "blue!15", 0.35), const Tikz_Style &b_style=tikz_area_style("green!60!black", "green!20", 0.35), const Tikz_Style &result_style=tikz_area_style("red", "red!35", 0.65), const int input_layer=Tikz_Plane::Layer_Default, const int result_layer=Tikz_Plane::Layer_Foreground)
Visualizes a boolean operation (union, intersection, difference) on two polygons.
Polygon visualize_douglas_peucker(Tikz_Plane &plane, const Polygon &poly, const Geom_Number &epsilon, const DouglasPeuckerSimplification &algorithm={}, const Tikz_Style &original_style=tikz_wire_style("gray!50"), const Tikz_Style &simplified_style=tikz_bold_wire_style("blue!80"), const bool draw_vertices=true, const Tikz_Style &vertex_style=tikz_points_style("red"))
Simplify a polygon with Douglas-Peucker and draw the result.
FunnelTraceResult compute_shortest_path_funnel_trace(const Polygon &polygon, const Point &source, const Point &target)
Compute a full SSFA trace (portal-by-portal states).
void put_smoothing_result(Tikz_Plane &plane, const Polygon &original, const Polygon &smoothed, const Tikz_Style &original_style=tikz_wire_style("gray!50"), const Tikz_Style &smoothed_style=tikz_bold_wire_style("violet!80"), const bool draw_vertices=true, const Tikz_Style &vertex_style=tikz_points_style("red"))
Draw original and smoothed polygons overlaid.
void put_portals(Tikz_Plane &plane, const Array< FunnelPortal > &portals, const bool skip_degenerate=true, const Tikz_Style &portal_style=tikz_wire_style("purple", true), const int portal_layer=Tikz_Plane::Layer_Default)
Insert funnel portals as segment connectors.
DynList< Triangle > visualize_monotone_triangulation(Tikz_Plane &plane, const Polygon &polygon, const MonotonePolygonTriangulation &algorithm={}, const Tikz_Style &polygon_style=tikz_wire_style("black"), const Tikz_Style &triangle_style=tikz_wire_style("blue!65"))
Compute and draw triangulation via monotone partition pipeline.
Tikz_Style tikz_area_style(const std::string &draw_color="black", const std::string &fill_color="gray!25", const double opacity=0.6)
Creates a style for drawing filled polygons.
Polygon visualize_convex_hull(Tikz_Plane &plane, const DynList< Point > &points, const HullAlgorithm &hull_algorithm, const Tikz_Style &point_style=tikz_points_style("black", 0.6), const Tikz_Style &hull_style=tikz_wire_style("red"), const Tikz_Style &hull_vertex_style=tikz_points_style("red"), const int point_layer=Tikz_Plane::Layer_Default, const int hull_layer=Tikz_Plane::Layer_Foreground, const bool draw_hull_vertices=true)
Runs a convex hull algorithm and visualizes the result.
void put_delaunay_result(Tikz_Plane &plane, const DelaunayTriangulationBowyerWatson::Result &dt, const Tikz_Style &triangle_style=tikz_wire_style("blue"), const bool draw_sites=true, const Tikz_Style &site_style=tikz_points_style("black"), const int triangle_layer=Tikz_Plane::Layer_Default, const int site_layer=Tikz_Plane::Layer_Foreground)
Insert Delaunay triangulation as triangle outlines.
Tikz_Style tikz_points_style(const std::string &color="black", const double opacity=-1.0)
Creates a style optimized for point clouds.
Array< Polygon > visualize_convex_decomposition(Tikz_Plane &plane, const Polygon &polygon, const ConvexPolygonDecomposition &algorithm={}, const bool draw_input_polygon=true, const Tikz_Style &input_style=tikz_wire_style("black", true), const bool color_parts_by_index=true, const Tikz_Style &part_style=tikz_area_style("blue!60!black", "blue!15", 0.40), const int input_layer=Tikz_Plane::Layer_Default, const int part_layer=Tikz_Plane::Layer_Foreground)
Compute and insert convex decomposition for a polygon.
void put_path(Tikz_Plane &plane, const DynList< Point > &path, const Tikz_Style &segment_style=tikz_path_style("red"), const bool draw_waypoints=true, const Tikz_Style &waypoint_style=tikz_points_style("red"), const int segment_layer=Tikz_Plane::Layer_Foreground, const int waypoint_layer=Tikz_Plane::Layer_Overlay)
Insert a point path as connected segments and optional waypoints.
static long & color(typename GT::Node *p)
void quicksort_op(C< T > &a, const Compare &cmp=Compare(), const size_t threshold=Quicksort_Threshold)
Optimized quicksort for containers using operator().
Result bundle for AABB query visualization.
AABBTree::DebugSnapshot snapshot
Array< size_t > query_hit_ids
A snapshot of the entire tree for debugging.
Result of an alpha-shape computation.
Array< DelaunayTriangulationBowyerWatson::IndexedTriangle > triangles
Triangles that satisfy the alpha criterion.
Array< Point > sites
Deduplicated and sorted input sites.
Array< Segment > boundary_edges
Segments forming the boundary of the alpha-shape.
Array< IndexedEdge > constrained_edges
Array< IndexedTriangle > triangles
The result of a Delaunay triangulation.
Array< IndexedTriangle > triangles
Triangles forming the Delaunay triangulation.
Array< Point > sites
Unique, sorted input points used for triangulation.
Full trace for shortest-path funnel processing.
Array< FunnelPortal > portals
Array< FunnelTraceStep > steps
Array< Point > final_path
One SSFA (funnel) iteration snapshot.
Array< Point > committed_path
A complete snapshot of the tree for debugging.
Result type: a circle defined by center and squared radius.
Geom_Number radius() const
Exact radius (square root of radius_squared).
The result of an offset operation, which may produce multiple polygons.
Array< Polygon > polygons
Set of resulting simple polygons.
Iterator over the vertices of a polygon.
Complete result of a power diagram computation.
Array< PowerCell > cells
Cells of the power diagram.
Array< WeightedSite > sites
Sorted and unique input sites.
Array< PowerEdge > edges
Edges of the power diagram.
Result bundle for R-tree/R*-tree query visualization.
RTree< Payload, MaxEntries, MinEntries, Variant >::DebugSnapshot snapshot
Array< Rectangle > query_hit_boxes
bboxes of every entry intersecting query_rect
Full tree structure captured for visualization/debugging.
A complete snapshot of the range tree for debugging.
Result bundle for range-tree query visualization.
RangeTree2D::DebugSnapshot snapshot
DynList< Point > query_hits
Array< IndexedTriangle > triangles
Array< WeightedSite > sites
Bundle of rotating-calipers results used by visualization helpers.
RotatingCalipersConvexPolygon::WidthResult width
RotatingCalipersConvexPolygon::DiameterResult diameter
The complete result of the segment arrangement computation.
Array< Point > vertices
Unique vertices (endpoints and intersection points).
Array< ArrEdge > edges
Sub-segments forming the arrangement graph.
Array< ArrFace > faces
Faces defined by the arrangement.
Result bundle for shortest-path + funnel portal visualization.
Array< FunnelPortal > portals
Style descriptor for TikZ primitives.
std::string fill_color
TikZ fill color (fill=<color>)
double opacity
opacity=<value> in [0,1], when >= 0
bool fill
Fill closed shapes (polygon/triangle/ellipse)
double line_width_mm
line width=<value>mm when > 0
std::string draw_color
TikZ draw color (draw=<color>)
The trapezoidal map and DAG search structure.
Array< Trapezoid > trapezoids
All trapezoids created during construction.
Array< Segment > segments
Input segments.
size_t num_input_points
Number of unique points derived from segments.
Array< Point > points
Unique endpoints of all segments.
size_t num_input_segments
Number of segments originally provided.
A trapezoid in the decomposition.
The complete result of a Voronoi diagram computation.
Aleph::Array< Display_Node > nodes
Root at index zero.
TikZ/LaTeX geometric drawing utilities.
Dynamic R-tree spatial index over axis-aligned rectangles.