Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tikzgeom_algorithms_test.cc
Go to the documentation of this file.
1#include <gtest/gtest.h>
2
3#include <cctype>
4#include <chrono>
5#include <cstdlib>
6#include <filesystem>
7#include <fstream>
8#include <iterator>
9#include <sstream>
10#include <string>
11#include <system_error>
12#include <vector>
13
14#include <tikzgeom_algorithms.H>
15#include <tikzgeom_scene.H>
16#include <tpl_r_star_tree.H>
17
18using namespace Aleph;
19
20namespace
21{
22
23bool has_nan_or_inf(std::string s)
24{
25 for (char & c : s)
27
28 return s.find("nan") != std::string::npos or
29 s.find("inf") != std::string::npos;
30}
31
32#ifdef ALEPH_PDFLATEX_EXECUTABLE
33
35std::string shell_quote(const std::string & value)
36{
37 std::string quoted = "'";
38 for (const char c : value)
39 if (c == '\'')
40 quoted += "'\\''";
41 else
42 quoted += c;
43 return quoted + "'";
44}
45
48{
49 std::filesystem::path path_;
50
51public:
53 {
54 const auto stamp = std::chrono::high_resolution_clock::now()
55 .time_since_epoch().count();
56 path_ = std::filesystem::temp_directory_path() /
57 ("aleph-tikz-latex-" + std::to_string(stamp));
58 std::filesystem::create_directories(path_);
59 }
60
63 const Scoped_Latex_Temp_Directory &) = delete;
64
66 {
67 std::error_code error;
68 std::filesystem::remove_all(path_, error);
69 }
70
72 [[nodiscard]] const std::filesystem::path & path() const noexcept
73 {
74 return path_;
75 }
76};
77
79bool write_text_file(const std::filesystem::path & path,
80 const std::string & text)
81{
82 std::ofstream output(path);
83 output << text;
84 return output.good();
85}
86
88std::string read_text_file(const std::filesystem::path & path)
89{
90 std::ifstream input(path);
91 return {std::istreambuf_iterator<char>(input),
92 std::istreambuf_iterator<char>()};
93}
94
95#endif
96
98{
99 Polygon p;
100 p.add_vertex(Point(-20, -10));
101 p.add_vertex(Point(10, -12));
102 p.add_vertex(Point(18, 4));
103 p.add_vertex(Point(-8, 18));
104 p.close();
105 return p;
106}
107
109{
110 Polygon p;
111 p.add_vertex(Point(-14, -18));
112 p.add_vertex(Point(22, -2));
113 p.add_vertex(Point(8, 22));
114 p.add_vertex(Point(-18, 8));
115 p.close();
116 return p;
117}
118
120{
121 Polygon p;
122 p.add_vertex(Point(0, 0));
123 p.add_vertex(Point(20, 0));
124 p.add_vertex(Point(20, 20));
125 p.add_vertex(Point(12, 20));
126 p.add_vertex(Point(12, 8));
127 p.add_vertex(Point(8, 8));
128 p.add_vertex(Point(8, 20));
129 p.add_vertex(Point(0, 20));
130 p.close();
131 return p;
132}
133
135{
136 Polygon p;
137 p.add_vertex(Point(0, 0));
138 p.add_vertex(Point(12, 0));
139 p.add_vertex(Point(12, 10));
140 p.add_vertex(Point(7, 10));
141 p.add_vertex(Point(7, 4));
142 p.add_vertex(Point(4, 4));
143 p.add_vertex(Point(4, 10));
144 p.add_vertex(Point(0, 10));
145 p.close();
146 return p;
147}
148
150{
151 Polygon p;
152 p.add_vertex(Point(-10, -4));
153 p.add_vertex(Point(10, -6));
154 p.add_vertex(Point(16, 2));
155 p.add_vertex(Point(7, 12));
156 p.add_vertex(Point(-8, 10));
157 p.close();
158 return p;
159}
160
162{
163 Polygon p;
164 p.add_vertex(Point(0, 0));
165 p.add_vertex(Point(20, 0));
166 p.add_vertex(Point(20, 18));
167 p.add_vertex(Point(11, 18));
168 p.add_vertex(Point(11, 8));
169 p.add_vertex(Point(7, 8));
170 p.add_vertex(Point(7, 18));
171 p.add_vertex(Point(0, 18));
172 p.close();
173 return p;
174}
175
176size_t count_points(const DynList<Point> & pts)
177{
178 size_t n = 0;
179 for (DynList<Point>::Iterator it(pts); it.has_curr(); it.next_ne())
180 ++n;
181 return n;
182}
183
184size_t count_points(const Array<Point> & pts)
185{
186 return pts.size();
187}
188
189} // namespace
190
192{
193 Tikz_Plane plane(100, 60);
194
195 Tikz_Style back = tikz_wire_style("green");
196 Tikz_Style front = tikz_wire_style("red");
197
198 put_in_plane(plane, Segment(Point(0, 0), Point(50, 50)), front, 10);
199 put_in_plane(plane, Segment(Point(0, 50), Point(50, 0)), back, -10);
200
201 std::ostringstream output;
202 plane.draw(output);
203 const std::string result = output.str();
204
205 const size_t green_pos = result.find("draw=green");
206 const size_t red_pos = result.find("draw=red");
207
208 ASSERT_NE(green_pos, std::string::npos);
209 ASSERT_NE(red_pos, std::string::npos);
211}
212
214{
216 pts.append(Point(-15, -8));
217 pts.append(Point(-8, 10));
218 pts.append(Point(0, -10));
219 pts.append(Point(8, 8));
220 pts.append(Point(14, -3));
221 pts.append(Point(2, 16));
222
223 Tikz_Plane plane(120, 80);
225
227 plane, pts, hull_algo,
228 tikz_points_style("black"),
229 tikz_wire_style("red"),
230 tikz_points_style("red"));
231
232 EXPECT_GE(hull.size(), 3U);
233
234 std::ostringstream output;
235 plane.draw(output);
236 const std::string result = output.str();
237
238 EXPECT_NE(result.find("draw=red"), std::string::npos);
240}
241
243{
244 const Polygon a = make_convex_a();
245 const Polygon b = make_convex_b();
246
247 Tikz_Plane plane(120, 80);
249
250 EXPECT_GT(inter.size(), 0U);
251
252 std::ostringstream output;
253 plane.draw(output);
254 const std::string result = output.str();
255
256 EXPECT_NE(result.find("fill=red!30"), std::string::npos);
258}
259
261{
262 DynList<Point> sites;
263 sites.append(Point(-18, -8));
264 sites.append(Point(-6, 14));
265 sites.append(Point(8, -10));
266 sites.append(Point(16, 9));
267 sites.append(Point(2, 20));
268
269 Tikz_Plane plane(150, 100);
270 const auto vor = visualize_voronoi(plane, sites, VoronoiDiagram(), true);
271
272 EXPECT_EQ(vor.sites.size(), 5U);
273
274 std::ostringstream output;
275 plane.draw(output);
276 const std::string result = output.str();
277
278 EXPECT_NE(result.find("dashed"), std::string::npos);
280}
281
283{
284 DynList<Point> points;
285 points.append(Point(-12, -8));
286 points.append(Point(-8, 9));
287 points.append(Point(0, 14));
288 points.append(Point(11, 9));
289 points.append(Point(14, -7));
290 points.append(Point(2, -13));
291 points.append(Point(0, 0));
292
293 Tikz_Plane plane(160, 110);
294 const auto dt = visualize_delaunay(plane, points);
295
296 EXPECT_GE(dt.sites.size(), 5U);
297 EXPECT_GT(dt.triangles.size(), 0U);
298
299 std::ostringstream output;
300 plane.draw(output);
301 const std::string result = output.str();
302 EXPECT_NE(result.find("draw=blue"), std::string::npos);
304}
305
307{
309 sites.append({Point(-16, -6), Geom_Number(1)});
310 sites.append({Point(-2, 12), Geom_Number(4)});
311 sites.append({Point(12, -8), Geom_Number(2)});
312 sites.append({Point(18, 10), Geom_Number(6)});
313
314 Tikz_Plane plane(150, 100);
315 const auto pd = visualize_power_diagram(plane, sites);
316
317 EXPECT_EQ(pd.sites.size(), 4U);
318
319 std::ostringstream output;
320 plane.draw(output);
321 const std::string result = output.str();
322
323 EXPECT_NE(result.find("violet"), std::string::npos);
325}
326
328{
329 Array<Segment> segments;
330 segments.append(Segment(Point(-20, 0), Point(20, 0)));
331 segments.append(Segment(Point(0, -20), Point(0, 20)));
332 segments.append(Segment(Point(-20, -20), Point(20, 20)));
333
334 Tikz_Plane plane(150, 100);
336 plane, segments, SegmentArrangement(),
337 true, true, false,
338 tikz_area_style("teal!60!black", "teal!12", 0.30),
339 tikz_wire_style("teal!70!black"),
340 tikz_points_style("teal!70!black"),
341 true);
342
343 EXPECT_GT(arrangement.vertices.size(), 4U);
344 EXPECT_GT(arrangement.edges.size(), 3U);
345
346 std::ostringstream output;
347 plane.draw(output);
348 const std::string result = output.str();
349
350 EXPECT_NE(result.find("teal!70!black"), std::string::npos);
352}
353
355{
356 Array<Segment> segments;
357 segments.append(Segment(Point(0, 0), Point(20, 0)));
358 segments.append(Segment(Point(20, 0), Point(20, 20)));
359 segments.append(Segment(Point(20, 20), Point(0, 20)));
360 segments.append(Segment(Point(0, 20), Point(0, 0)));
361 segments.append(Segment(Point(0, 0), Point(20, 20)));
362
363 Tikz_Plane plane(150, 100);
365 plane, segments, SegmentArrangement(),
366 true, true, false,
367 tikz_area_style("teal!60!black", "teal!12", 0.30),
368 tikz_wire_style("teal!70!black"),
369 tikz_points_style("teal!70!black"),
370 true);
371
372 EXPECT_GT(arrangement.faces.size(), 1U);
373
374 std::ostringstream output;
375 plane.draw(output);
376 const std::string result = output.str();
377
378 EXPECT_NE(result.find("blue!20"), std::string::npos);
380}
381
383{
384 const Polygon polygon = make_shortest_path_polygon();
385 const Point source(2, 16);
386 const Point target(18, 16);
387
388 Tikz_Plane plane(170, 110);
389 const auto path = visualize_shortest_path_in_polygon(
390 plane, polygon, source, target, ShortestPathInPolygon());
391
392 EXPECT_GE(count_points(path), 2U);
393
394 std::ostringstream output;
395 plane.draw(output);
396 const std::string result = output.str();
397
398 EXPECT_NE(result.find("draw=red"), std::string::npos);
399 EXPECT_NE(result.find("fill=green!50!black"), std::string::npos);
400 EXPECT_NE(result.find("fill=blue"), std::string::npos);
402}
403
405{
406 DynList<Point> points;
407 points.append(Point(-12, -8));
408 points.append(Point(-10, 9));
409 points.append(Point(-1, 14));
410 points.append(Point(10, 10));
411 points.append(Point(13, -7));
412 points.append(Point(0, -13));
413 points.append(Point(0, 0));
414
415 Tikz_Plane plane(170, 110);
417 plane, points, Geom_Number(10000), AlphaShape(),
418 true);
419
420 EXPECT_GT(alpha_shape.boundary_edges.size(), 0U);
421
422 std::ostringstream output;
423 plane.draw(output);
424 const std::string result = output.str();
425
426 EXPECT_NE(result.find("orange!90!black"), std::string::npos);
428}
429
431{
433 sites.append({Point(-10, -6), Geom_Number(0)});
434 sites.append({Point(-2, 10), Geom_Number(2)});
435 sites.append({Point(10, -4), Geom_Number(1)});
436 sites.append({Point(15, 8), Geom_Number(3)});
437 sites.append({Point(2, -12), Geom_Number(0)});
438
439 Tikz_Plane plane(160, 110);
440 const auto rt = visualize_regular_triangulation(plane, sites);
441
442 EXPECT_GE(rt.sites.size(), 4U);
443 EXPECT_GT(rt.triangles.size(), 0U);
444
445 std::ostringstream output;
446 plane.draw(output);
447 const std::string result = output.str();
448 EXPECT_NE(result.find("blue!60"), std::string::npos);
450}
451
453{
454 DynList<Point> points;
455 points.append(Point(-12, -8));
456 points.append(Point(-2, 5));
457 points.append(Point(1, 7));
458 points.append(Point(2, 7));
459 points.append(Point(10, -6));
460
461 Tikz_Plane plane(150, 100);
462 const auto cp = visualize_closest_pair(plane, points);
463
464 EXPECT_TRUE(cp.distance_squared >= 0);
465
466 std::ostringstream output;
467 plane.draw(output);
468 const std::string result = output.str();
469 EXPECT_NE(result.find("draw=red"), std::string::npos);
471}
472
474{
475 const Polygon poly = make_convex_for_calipers();
476 Tikz_Plane plane(160, 110);
477
478 const auto rc = visualize_rotating_calipers(plane, poly);
479
480 EXPECT_TRUE(rc.diameter.distance_squared > 0);
481 EXPECT_TRUE(rc.width.width_squared >= 0);
482
483 std::ostringstream output;
484 plane.draw(output);
485 const std::string result = output.str();
486 EXPECT_NE(result.find("draw=red"), std::string::npos);
487 EXPECT_NE(result.find("draw=blue"), std::string::npos);
489}
490
492{
495
496 Tikz_Plane plane(160, 110);
498
499 EXPECT_GT(inter.size(), 0U);
500
501 std::ostringstream output;
502 plane.draw(output);
503 const std::string result = output.str();
504 EXPECT_NE(result.find("fill=red!25"), std::string::npos);
506}
507
509{
510 Polygon p;
511 p.add_vertex(Point(-4, -2));
512 p.add_vertex(Point(3, -2));
513 p.add_vertex(Point(1, 4));
514 p.close();
515
516 Polygon q;
517 q.add_vertex(Point(-3, -1));
518 q.add_vertex(Point(2, -1));
519 q.add_vertex(Point(0, 3));
520 q.close();
521
522 Tikz_Plane plane(160, 110);
523 const Polygon sum = visualize_minkowski_sum(plane, p, q);
524
525 EXPECT_GT(sum.size(), 0U);
526
527 std::ostringstream output;
528 plane.draw(output);
529 const std::string result = output.str();
530 EXPECT_NE(result.find("fill=red!26"), std::string::npos);
532}
533
535{
537 Tikz_Plane plane(170, 110);
538
540 size_t tri_count = 0;
541 for (DynList<Triangle>::Iterator it(tris); it.has_curr(); it.next_ne())
542 ++tri_count;
544
545 std::ostringstream output;
546 plane.draw(output);
547 const std::string result = output.str();
548 EXPECT_NE(result.find("blue!65"), std::string::npos);
550}
551
553{
554 const Polygon polygon = make_visibility_polygon();
555 const Point query(2, 16);
556
557 Tikz_Plane plane(170, 110);
558 const Polygon vis = visualize_visibility_polygon(plane, polygon, query);
559 EXPECT_GT(vis.size(), 0U);
560
561 std::ostringstream output;
562 plane.draw(output);
563 const std::string result = output.str();
564 EXPECT_NE(result.find("orange!90!black"), std::string::npos);
566}
567
569{
570 Array<Segment> segments;
571 segments.append(Segment(Point(-15, -8), Point(15, 10)));
572 segments.append(Segment(Point(-12, 11), Point(14, -7)));
573 segments.append(Segment(Point(-15, 2), Point(15, 2)));
574
575 Tikz_Plane plane(170, 110);
576 const auto intersections = visualize_line_sweep(plane, segments);
577
578 EXPECT_GT(intersections.size(), 0U);
579
580 std::ostringstream output;
581 plane.draw(output);
582 const std::string result = output.str();
583 EXPECT_NE(result.find("blue!60"), std::string::npos);
584 EXPECT_NE(result.find("fill=red"), std::string::npos);
586}
587
589{
590 Array<Point> points;
591 points.append(Point(10, 10));
592 points.append(Point(20, 30));
593 points.append(Point(50, 40));
594 points.append(Point(70, 80));
595 points.append(Point(90, 20));
596 const auto kd = KDTreePointSearch::build(points, 0, 0, 100, 100);
597
598 Tikz_Plane plane(180, 110);
599 const auto snap = visualize_kdtree_partitions(plane, kd, true, true);
600
601 EXPECT_EQ(snap.points.size(), points.size());
602 EXPECT_GT(snap.partitions.size(), 0U);
603
604 std::ostringstream output;
605 plane.draw(output);
606 const std::string result = output.str();
607 EXPECT_NE(result.find("fill=red"), std::string::npos);
609}
610
612{
613 DynList<Point> points;
614 points.append(Point(1, 1));
615 points.append(Point(3, 5));
616 points.append(Point(4, 4));
617 points.append(Point(7, 2));
618 points.append(Point(9, 8));
619
620 RangeTree2D tree;
621 tree.build(points);
622
623 Tikz_Plane plane(180, 110);
624 const auto viz = visualize_range_tree_query(
625 plane, tree, Rectangle(2, 1, 6, 5));
626
627 EXPECT_GT(viz.snapshot.nodes.size(), 0U);
628 EXPECT_GT(viz.query_hits.size(), 0U);
629
630 std::ostringstream output;
631 plane.draw(output);
632 const std::string result = output.str();
633 EXPECT_NE(result.find("draw=red"), std::string::npos);
635}
636
638{
639 AABBTree tree;
641 entries.append({Rectangle(0, 0, 5, 5), 0});
642 entries.append({Rectangle(3, 3, 8, 8), 1});
643 entries.append({Rectangle(10, 10, 15, 15), 2});
644 tree.build(entries);
645
646 Tikz_Plane plane(180, 110);
647 const auto viz = visualize_aabb_tree_query(
648 plane, tree, Rectangle(2, 2, 6, 6));
649
650 EXPECT_GT(viz.snapshot.nodes.size(), 0U);
651 EXPECT_GT(viz.query_hit_ids.size(), 0U);
652
653 std::ostringstream output;
654 plane.draw(output);
655 const std::string result = output.str();
656 EXPECT_NE(result.find("draw=red"), std::string::npos);
658}
659
661{
662 RTree<int, 4, 2> tree;
663 tree.insert(Rectangle(0, 0, 5, 5), 0);
664 tree.insert(Rectangle(3, 3, 8, 8), 1);
665 tree.insert(Rectangle(10, 10, 15, 15), 2);
666
667 Tikz_Plane plane(180, 110);
668 const auto viz = visualize_rtree_query(plane, tree, Rectangle(2, 2, 6, 6));
669
670 EXPECT_GT(viz.snapshot.nodes.size(), 0U);
671 EXPECT_GT(viz.query_hit_boxes.size(), 0U);
672
673 std::ostringstream output;
674 plane.draw(output);
675 const std::string result = output.str();
676 EXPECT_NE(result.find("draw=red"), std::string::npos);
678}
679
681{
683 tree.insert(Rectangle(0, 0, 5, 5), 0);
684 tree.insert(Rectangle(3, 3, 8, 8), 1);
685 tree.insert(Rectangle(10, 10, 15, 15), 2);
686
687 Tikz_Plane plane(180, 110);
688 const auto viz = visualize_rtree_query(plane, tree, Rectangle(2, 2, 6, 6));
689
690 EXPECT_GT(viz.snapshot.nodes.size(), 0U);
691 EXPECT_GT(viz.query_hit_boxes.size(), 0U);
692
693 std::ostringstream output;
694 plane.draw(output);
695 const std::string result = output.str();
696 EXPECT_NE(result.find("draw=red"), std::string::npos);
698}
699
701{
702 RTree<int, 4, 2> tree;
703 for (int i = 0; i < 20; ++i)
704 tree.insert(Rectangle(i, i, i + 2, i + 2), i);
705
706 Tikz_Plane plane(180, 110);
707 const auto snapshot = visualize_rtree(plane, tree);
708 EXPECT_GT(snapshot.nodes.size(), 0U);
709
710 std::ostringstream output;
711 plane.draw(output);
713}
714
716{
717 const Polygon polygon = make_shortest_path_polygon();
718 const Point source(2, 16);
719 const Point target(18, 16);
720
721 Tikz_Plane plane(170, 110);
723 plane, polygon, source, target, ShortestPathInPolygon());
724
725 EXPECT_GE(debug.portals.size(), 2U);
726 EXPECT_GE(count_points(debug.path), 2U);
727
728 std::ostringstream output;
729 plane.draw(output);
730 const std::string result = output.str();
731
732 EXPECT_NE(result.find("draw=purple"), std::string::npos);
733 EXPECT_NE(result.find("dashed"), std::string::npos);
734 EXPECT_NE(result.find("draw=red"), std::string::npos);
736}
737
739{
741
742 Tikz_Plane plane(170, 110);
745 true, tikz_wire_style("black", true),
746 true);
747
748 EXPECT_GT(parts.size(), 1U);
749
750 std::ostringstream output;
751 plane.draw(output);
752 const std::string result = output.str();
753
754 EXPECT_NE(result.find("blue!20"), std::string::npos);
756}
757
759{
760 const Polygon polygon = make_shortest_path_polygon();
761 const Point source(2, 16);
762 const Point target(18, 16);
763
765 compute_shortest_path_funnel_trace(polygon, source, target);
766
767 EXPECT_GE(trace.portals.size(), 2U);
768 EXPECT_GT(trace.steps.size(), 0U);
769 EXPECT_GE(count_points(trace.final_path), 2U);
770 EXPECT_EQ(trace.final_path(0), source);
771 EXPECT_EQ(trace.final_path(trace.final_path.size() - 1), target);
772}
773
775{
776 const Polygon polygon = make_shortest_path_polygon();
777 const Point source(2, 16);
778 const Point target(18, 16);
779
781 compute_shortest_path_funnel_trace(polygon, source, target);
782 ASSERT_GT(trace.steps.size(), 0U);
783
784 Tikz_Plane plane(170, 110);
785 put_funnel_trace_step(plane, polygon, source, target, trace, 0);
786
787 std::ostringstream output;
788 plane.draw(output);
789 const std::string result = output.str();
790
791 EXPECT_NE(result.find("draw=purple"), std::string::npos);
792 EXPECT_NE(result.find("draw=orange!90!black"), std::string::npos);
794}
795
797{
798 Array<Segment> segments;
799 segments.append(Segment(Point(-20, 0), Point(20, 0)));
800 segments.append(Segment(Point(0, -20), Point(0, 20)));
801 segments.append(Segment(Point(-18, -14), Point(18, 14)));
802
803 Tikz_Scene scene(190, 120, 0, 0, true);
804 scene.put_cartesian_axis()
805 .set_point_radius_mm(0.65);
806
807 const auto arrangement = scene.visualize_segment_arrangement(
808 segments,
810 true,
811 true,
812 false,
813 tikz_area_style("teal!60!black", "teal!12", 0.30),
814 tikz_wire_style("teal!70!black"),
815 tikz_points_style("teal!70!black"),
816 true);
817
819 for (size_t i = 0; i < arrangement.vertices.size(); ++i)
821
822 const Polygon hull = scene.visualize_convex_hull(
825 tikz_points_style("black"),
826 tikz_wire_style("red"),
827 tikz_points_style("red"),
830 true);
831
832 EXPECT_GE(hull.size(), 3U);
833
834 const std::string tikz = scene.to_tikz();
835 EXPECT_NE(tikz.find("draw=teal!70!black"), std::string::npos);
836 EXPECT_NE(tikz.find("draw=red"), std::string::npos);
838}
839
841{
842 Tikz_Scene scene(190, 120, 0, 0, true);
843
844 DynList<Point> points;
845 points.append(Point(-10, -7));
846 points.append(Point(-2, 9));
847 points.append(Point(8, -6));
848 points.append(Point(12, 8));
849 points.append(Point(0, 0));
850
851 const auto dt = scene.visualize_delaunay(points);
852 EXPECT_GT(dt.triangles.size(), 0U);
853
854 const auto cp = scene.visualize_closest_pair(points);
855 EXPECT_TRUE(cp.distance_squared >= 0);
856
857 Array<Segment> segments;
858 segments.append(Segment(Point(-12, -8), Point(12, 10)));
859 segments.append(Segment(Point(-12, 10), Point(12, -8)));
860 const auto intersections = scene.visualize_line_sweep(segments);
861 EXPECT_GT(intersections.size(), 0U);
862
864 kd_points.append(Point(5, 5));
865 kd_points.append(Point(15, 20));
866 kd_points.append(Point(35, 10));
867 kd_points.append(Point(45, 30));
868 const auto kd = KDTreePointSearch::build(kd_points, 0, 0, 50, 40);
869 const auto kd_snap = scene.visualize_kdtree_partitions(kd);
870 EXPECT_GT(kd_snap.partitions.size(), 0U);
871
875 range_points.append(Point(3, 4));
876 range_points.append(Point(6, 2));
878 const auto rv = scene.visualize_range_tree_query(
879 range_tree, Rectangle(0, 0, 4, 5));
880 EXPECT_GT(rv.query_hits.size(), 0U);
881
884 aabb_entries.append({Rectangle(0, 0, 4, 4), 0});
885 aabb_entries.append({Rectangle(2, 2, 8, 8), 1});
886 aabb_tree.build(aabb_entries);
887 const auto av = scene.visualize_aabb_tree_query(
888 aabb_tree, Rectangle(1, 1, 3, 3));
889 EXPECT_GT(av.query_hit_ids.size(), 0U);
890
891 const std::string tikz = scene.to_tikz();
892 EXPECT_NE(tikz.find("draw=blue"), std::string::npos);
893 EXPECT_NE(tikz.find("draw=red"), std::string::npos);
895}
896
898{
899 Tikz_Scene scene(120, 80, 2, 3, true);
900 scene.add(Segment(Point(0, 0), Point(10, 15)), tikz_wire_style("blue"));
901
903 opts.class_options = "tikz,border=6pt";
904 const std::string latex = scene.to_standalone(opts);
905
906 EXPECT_NE(latex.find("\\documentclass[tikz,border=6pt]{standalone}"),
907 std::string::npos);
908 EXPECT_NE(latex.find("}\n\\usepackage{tikz}\n"), std::string::npos);
909 EXPECT_EQ(latex.find("}\\n\\usepackage{tikz}\\n"), std::string::npos);
910 EXPECT_NE(latex.find("\\usepackage{tikz}"), std::string::npos);
911 EXPECT_NE(latex.find("\\begin{tikzpicture}"), std::string::npos);
912 EXPECT_NE(latex.find("\\end{document}"), std::string::npos);
914}
915
917{
918 Tikz_Scene patterned(120, 80, 0, 0, true);
919 Tikz_Style pattern = tikz_area_style("black", "gray!20", 0.5);
920 pattern.pattern = "north east lines";
921 pattern.pattern_color = "black";
922 patterned.add(Triangle(Point(0, 0), Point(10, 0), Point(5, 8)), pattern);
923
924 const std::string standalone = patterned.to_standalone();
925 const size_t library_pos = standalone.find("\\usetikzlibrary{patterns}");
926 ASSERT_NE(library_pos, std::string::npos);
927 EXPECT_LT(library_pos, standalone.find("\\begin{document}"));
928
929 std::vector<Tikz_Scene> steps;
930 steps.push_back(patterned);
931 steps.emplace_back(120, 80, 0, 0, true);
932 steps.back().add(Point(1, 1), tikz_points_style("red"));
933
934 const std::string overlays = Tikz_Scene::to_beamer_overlays(steps);
935 const size_t overlay_library_pos =
936 overlays.find("\\usetikzlibrary{patterns}");
937 ASSERT_NE(overlay_library_pos, std::string::npos);
938 EXPECT_LT(overlay_library_pos, overlays.find("\\begin{document}"));
939}
940
942{
943 Tikz_Scene scene(120, 80, 0, 0, true);
944 Tikz_Style pattern = tikz_area_style("black", "gray!20", 0.5);
945 pattern.pattern = "north east lines";
946 pattern.pattern_color = "black";
947 scene.add_legend_entry("Patterned region", pattern);
948
949 const std::string standalone = scene.to_standalone();
950 EXPECT_NE(standalone.find("\\usetikzlibrary{patterns}"),
951 std::string::npos);
952 EXPECT_NE(standalone.find("Patterned region"), std::string::npos);
953}
954
956{
957 Tikz_Scene scene(120, 80, 0, 0, true);
958 Tikz_Style pattern = tikz_area_style("black", "gray!20", 0.5);
959 pattern.pattern = "grid";
960 pattern.pattern_color = "gray";
961 scene.register_tikz_style("patternedArea", pattern);
962
963 const std::string standalone = scene.to_standalone();
964 EXPECT_NE(standalone.find("\\usetikzlibrary{patterns}"),
965 std::string::npos);
966 EXPECT_NE(standalone.find("\\tikzset{patternedArea/.style="),
967 std::string::npos);
968}
969
971{
972 Tikz_Scene scene(120, 80, 2, 3, true);
973 scene.add(Segment(Point(0, 0), Point(10, 15)), tikz_wire_style("blue"));
974
976 opts.class_options = "aspectratio=43";
977 opts.frame_title = "Scene Demo";
978 opts.frame_options = "t";
979
980 const std::string latex = scene.to_beamer(opts);
981
982 EXPECT_NE(latex.find("\\documentclass[aspectratio=43]{beamer}"),
983 std::string::npos);
984 EXPECT_NE(latex.find("\\setbeamertemplate{navigation symbols}{}"),
985 std::string::npos);
986 EXPECT_NE(latex.find("\\begin{frame}[t]{Scene Demo}"), std::string::npos);
987 EXPECT_NE(latex.find("\\usepackage{graphicx}"), std::string::npos);
988 EXPECT_NE(latex.find("\\scalebox{"), std::string::npos);
989 EXPECT_NE(latex.find("\\begin{tikzpicture}"), std::string::npos);
990 EXPECT_EQ(latex.find("\\documentclass[handout,aspectratio=43]{beamer}"),
991 std::string::npos);
993}
994
996{
997 Tikz_Scene scene(120, 80, 0, 0, true);
998 scene.add(Point(1, 1), tikz_points_style("red"));
999
1001 opts.class_options = "aspectratio=169";
1002 opts.frame_title = "Handout Demo";
1003
1004 const std::string latex = scene.to_handout(opts);
1005
1006 EXPECT_NE(latex.find("\\documentclass[handout,aspectratio=169]{beamer}"),
1007 std::string::npos);
1008 EXPECT_NE(latex.find("\\begin{frame}[t]{Handout Demo}"), std::string::npos);
1010
1011 opts.class_options = "handout,aspectratio=169";
1012 const std::string latex_no_dup = scene.to_handout(opts);
1013 EXPECT_NE(latex_no_dup.find("\\documentclass[handout,aspectratio=169]{beamer}"),
1014 std::string::npos);
1015 EXPECT_EQ(latex_no_dup.find("handout,handout"), std::string::npos);
1016}
1017
1019{
1020 std::vector<Tikz_Scene> steps;
1021 steps.emplace_back(120, 80, 0, 0, true);
1022 steps.back().add(Point(2, 3), tikz_points_style("red"));
1023 steps.emplace_back(120, 80, 0, 0, true);
1024 steps.back().add(Segment(Point(0, 0), Point(12, 9)), tikz_wire_style("blue"));
1025
1027 opts.class_options = "aspectratio=169";
1028 opts.frame_title = "Overlay Demo";
1029 opts.frame_options = "t";
1030
1031 const std::string latex = Tikz_Scene::to_beamer_overlays(steps, opts);
1032
1033 EXPECT_NE(latex.find("\\documentclass[aspectratio=169]{beamer}"),
1034 std::string::npos);
1035 EXPECT_NE(latex.find("\\begin{frame}[t]{Overlay Demo}"), std::string::npos);
1036 EXPECT_NE(latex.find("\\only<1>{"), std::string::npos);
1037 EXPECT_NE(latex.find("\\only<2>{"), std::string::npos);
1038 EXPECT_NE(latex.find("\\scalebox{"), std::string::npos);
1039 EXPECT_EQ(latex.find("\\only<3>{"), std::string::npos);
1040 EXPECT_EQ(latex.find("\\documentclass[handout,aspectratio=169]{beamer}"),
1041 std::string::npos);
1043}
1044
1046{
1047 std::vector<Tikz_Scene> steps;
1048 steps.emplace_back(120, 80, 0, 0, true);
1049 steps.back().add(Point(4, 5), tikz_points_style("black"));
1050 steps.emplace_back(120, 80, 0, 0, true);
1051 steps.back().add(Segment(Point(0, 0), Point(5, 5)),
1052 tikz_wire_style("blue"));
1053
1055 opts.class_options = "handout,aspectratio=43";
1056 opts.frame_title = "Overlay Handout";
1057
1058 const std::string latex = Tikz_Scene::to_handout_overlays(steps, opts);
1059 EXPECT_NE(latex.find("\\documentclass[handout,aspectratio=43]{beamer}"),
1060 std::string::npos);
1061 EXPECT_EQ(latex.find("handout,handout"), std::string::npos);
1062 EXPECT_EQ(latex.find("\\only<1>{"), std::string::npos);
1063 EXPECT_NE(latex.find("draw=blue"), std::string::npos);
1064 EXPECT_EQ(latex.find("fill=black"), std::string::npos);
1065 const size_t picture = latex.find("\\begin{tikzpicture}");
1066 ASSERT_NE(picture, std::string::npos);
1067 EXPECT_EQ(latex.find("\\begin{tikzpicture}", picture + 1),
1068 std::string::npos);
1070}
1071
1073{
1074 Tikz_Scene scene(120, 80, 0, 0, true);
1077 EXPECT_THROW(scene.to_beamer(opts), std::domain_error);
1078}
1079
1081{
1082 const std::vector<Tikz_Scene> steps;
1083 const std::string latex = Tikz_Scene::to_beamer_overlays(steps);
1084
1085 EXPECT_NE(latex.find("No overlays provided."), std::string::npos);
1086 EXPECT_EQ(latex.find("\\only<1>{"), std::string::npos);
1088}
1089
1091{
1092#ifndef ALEPH_PDFLATEX_EXECUTABLE
1093 GTEST_SKIP() << "pdflatex, standalone, beamer, or TikZ is unavailable";
1094#else
1095 Tikz_Scene patterned(220, 130, 0, 0, true);
1096 Tikz_Style pattern = tikz_area_style("black", "orange!20", 0.5);
1097 pattern.pattern = "north east lines";
1098 pattern.pattern_color = "orange!80!black";
1099 patterned.add(Triangle(Point(0, 0), Point(20, 0), Point(10, 16)), pattern);
1100
1101 std::vector<Tikz_Scene> steps;
1102 for (size_t i = 0; i < 3; ++i)
1103 {
1104 steps.emplace_back(178, 108, 0, 0, true);
1105 steps.back().add(
1106 Segment(Point(-20, static_cast<long>(i)),
1107 Point(20, 20 - static_cast<long>(i))),
1108 tikz_wire_style(i == 2 ? "blue" : "black"));
1109 }
1110
1112 options.frame_title = "TikZ layout smoke test";
1113 const std::string beamer = Tikz_Scene::to_beamer_overlays(steps, options);
1115
1117 const std::vector<std::pair<std::string, std::string>> documents = {
1118 {"standalone", patterned.to_standalone()},
1119 {"beamer", beamer},
1120 {"handout", handout}
1121 };
1122
1123 for (const auto & [name, document] : documents)
1124 {
1125 const std::filesystem::path tex = temporary.path() / (name + ".tex");
1126 const std::filesystem::path transcript =
1127 temporary.path() / (name + ".stdout");
1129
1130 const std::string command =
1131 shell_quote(ALEPH_PDFLATEX_EXECUTABLE) +
1132 " -interaction=nonstopmode -halt-on-error -output-directory=" +
1133 shell_quote(temporary.path().string()) + " " +
1134 shell_quote(tex.string()) + " > " +
1135 shell_quote(transcript.string()) + " 2>&1";
1136 const int status = std::system(command.c_str());
1137 const std::string diagnostics = read_text_file(transcript);
1138 ASSERT_EQ(status, 0) << name << " failed:\n" << diagnostics;
1139
1140 const std::string log =
1141 read_text_file(temporary.path() / (name + ".log"));
1142 EXPECT_EQ(log.find("Overfull"), std::string::npos)
1143 << name << " contains a layout overflow:\n" << log;
1144 EXPECT_EQ(log.find("LaTeX Error"), std::string::npos)
1145 << name << " contains a LaTeX error:\n" << log;
1146 EXPECT_EQ(log.find("Undefined control sequence"), std::string::npos)
1147 << name << " contains an undefined command:\n" << log;
1148 }
1149#endif
1150}
size_t steps
Definition ca-c-api.h:126
size_t size_t int32_t value
Definition ca-c-api.h:116
Axis-aligned bounding box tree for spatial queries.
size_t build(Array< size_t > &idx, const size_t lo, const size_t hi)
Alpha shape of a point set.
Andrew's monotonic chain convex hull algorithm.
Simple dynamic array with automatic resizing and functional operations.
Definition tpl_array.H:138
constexpr size_t size() const noexcept
Return the number of elements stored in the stack.
Definition tpl_array.H:365
T & append(const T &data)
Append a copy of data
Definition tpl_array.H:250
Decompose a simple polygon into convex parts using Hertel-Mehlhorn.
Iterator on the items of list.
Definition htlist.H:1420
Doubly-linked list (defined in tpl_dynList.H).
Definition htlist.H:1155
T & append(const T &item)
Definition htlist.H:1271
bool has_curr() const noexcept
Definition htlist.H:930
static Array< HalfPlane > from_convex_polygon(const Polygon &poly)
Build half-planes from the edges of a closed convex polygon.
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.
Definition point.H:221
A general (irregular) 2D polygon defined by a sequence of vertices.
Definition polygon.H:247
void add_vertex(const Point &point)
Add a vertex to the polygon.
Definition polygon.H:678
void close()
Close the polygon.
Definition polygon.H:843
const size_t & size() const
Get the number of vertices.
Definition polygon.H:478
Dynamic R-tree indexing axis-aligned rectangles by payload.
Definition tpl_r_tree.H:118
void insert(const Rectangle &bbox, const Payload &value)
Insert a (bbox, value) entry, copying value.
Definition tpl_r_tree.H:969
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.
Definition point.H:1789
Compute the full planar subdivision induced by a set of segments.
Represents a line segment between two points.
Definition point.H:837
Compute the shortest Euclidean path between two points inside a simple polygon.
2D TikZ canvas storing geometry objects and emitting LaTeX output.
Definition tikzgeom.H:200
void draw(std::ostream &output, const bool squarize=true) const
Emit a complete tikzpicture with all inserted objects.
Definition tikzgeom.H:1422
static constexpr int Layer_Default
Definition tikzgeom.H:203
static constexpr int Layer_Overlay
Definition tikzgeom.H:205
High-level scene wrapper to compose objects and algorithm visualizations.
static std::string to_handout_overlays(const std::vector< Tikz_Scene > &steps, const Tikz_Beamer_Document_Options &options={})
String variant of draw_handout_overlays.
static std::string to_beamer_overlays(const std::vector< Tikz_Scene > &steps, const Tikz_Beamer_Document_Options &options={})
String variant of draw_beamer_overlays.
A non-degenerate triangle defined by three points.
Definition point.H:1512
O(n log n) Voronoi diagram construction.
#define TEST(name)
__gmp_expr< T, __gmp_unary_expr< __gmp_expr< T, U >, __gmp_log_function > > log(const __gmp_expr< T, U > &expr)
Definition gmpfrxx.h:4074
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Definition Blossom.H:466
std::string shell_quote(const std::string &s)
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
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.
std::string tolower(const char *str)
Convert a C std::string to lower-case.
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.
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.
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.
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.
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.
void put_in_plane(Tikz_Plane &plane, const Geom &geom_obj)
Insert any supported geometry type in a Tikz_Plane.
Definition tikzgeom.H:1511
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.
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.
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.
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.
mpq_class Geom_Number
Numeric type used by the geometry module.
Definition point.H:113
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 error(const char *file, int line, const char *format,...)
Print an error message with file and line info.
Definition ahDefs.C:100
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.
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 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.
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.
FunnelTraceResult compute_shortest_path_funnel_trace(const Polygon &polygon, const Point &source, const Point &target)
Compute a full SSFA trace (portal-by-portal states).
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.
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.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
static struct argp_option options[]
Definition ntreepic.C:1886
Full trace for shortest-path funnel processing.
Options used by Tikz_Scene beamer/handout export helpers.
std::string frame_title
Frame title used by scene exports.
std::string class_options
beamer class options (for example aspectratio=169).
double max_picture_height_mm
Maximum rendered picture height in millimeters.
Options used by Tikz_Scene standalone document export.
Style descriptor for TikZ primitives.
Definition tikzgeom.H:102
std::string pattern
TikZ pattern (e.g. north east lines)
Definition tikzgeom.H:106
std::string pattern_color
TikZ pattern color (pattern color=<color>)
Definition tikzgeom.H:107
Helpers to visualize computational-geometry algorithm results in TikZ.
High-level scene management for TikZ geometry visualization.
R*-tree: an R-tree tuned with the Beckmann-Kriegel-Schneider-Seeger heuristics.
ofstream output
Definition writeHeap.C:215