Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tikzgeom_scene.H
Go to the documentation of this file.
1/*
2 Aleph_w
3
4 Data structures & Algorithms
5 version 2.0.0b
6 https://github.com/lrleon/Aleph-w
7
8 This file is part of Aleph-w library
9
10 Copyright (c) 2002-2026 Leandro Rabindranath Leon
11
12 Permission is hereby granted, free of charge, to any person obtaining a copy
13 of this software and associated documentation files (the "Software"), to deal
14 in the Software without restriction, including without limitation the rights
15 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
16 copies of the Software, and to permit persons to whom the Software is
17 furnished to do so, subject to the following conditions:
18
19 The above copyright notice and this permission notice shall be included in all
20 copies or substantial portions of the Software.
21
22 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
25 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28 SOFTWARE.
29*/
30
41# ifndef TIKZGEOM_SCENE_H
42# define TIKZGEOM_SCENE_H
43
44# include <cmath>
45# include <iomanip>
46# include <ostream>
47# include <sstream>
48# include <string>
49# include <type_traits>
50# include <utility>
51# include <vector>
52
53# include "tikzgeom_algorithms.H"
54
55namespace Aleph
56{
57
60{
61 std::string document_class = "standalone";
62 std::string class_options = "tikz,border=8pt";
63 std::string extra_preamble;
64};
65
68{
70 std::string class_options = "aspectratio=169";
72 std::string frame_options = "t";
74 std::string frame_title = "TikZ Scene";
78 std::string extra_preamble;
80 double max_picture_width_mm = 105.0;
82 double max_picture_height_mm = 60.0;
83};
84
97{
100 const Array<std::string> & source)
101 {
102 for (size_t i = 0; i < source.size(); ++i)
103 append_unique_tikz_library(destination, source(i));
104 }
105
108 const std::vector<Tikz_Scene> & steps)
109 {
111 for (const Tikz_Scene & step : steps)
113 step.plane_.required_tikz_libraries());
114 return libraries;
115 }
116
119 std::ostream & output,
121 {
122 if (libraries.is_empty())
123 return;
124
125 output << "\\usetikzlibrary{";
126 for (size_t i = 0; i < libraries.size(); ++i)
127 output << (i == 0 ? "" : ",") << libraries(i);
128 output << "}\n";
129 }
130
133 const Tikz_Scene & scene,
135 {
136 ah_domain_error_if(not std::isfinite(options.max_picture_width_mm) or
137 not std::isfinite(options.max_picture_height_mm) or
138 options.max_picture_width_mm <= 0.0 or
139 options.max_picture_height_mm <= 0.0)
140 << "Beamer picture bounds must be positive and finite";
141
142 double scale = 1.0;
143 if (scene.plane_.get_wide() * scale > options.max_picture_width_mm)
144 scale = options.max_picture_width_mm / scene.plane_.get_wide();
145 if (scene.plane_.get_height() * scale > options.max_picture_height_mm)
146 scale = options.max_picture_height_mm / scene.plane_.get_height();
147 return scale;
148 }
149
152 std::ostream & output,
153 const Tikz_Scene & scene,
155 {
156 const double scale = beamer_picture_scale(scene, options);
157 std::ostringstream formatted_scale;
158 formatted_scale << std::fixed << std::setprecision(6) << scale;
159
160 output << "\\centering\n"
161 << "\\scalebox{" << formatted_scale.str() << "}{%\n";
162 scene.draw(output);
163 output << "}\n";
164 }
165
167 const bool handout_mode,
168 const std::string & class_options)
169 {
170 if (not handout_mode)
171 return class_options;
172
173 if (class_options.empty())
174 return "handout";
175
176 if (class_options.find("handout") != std::string::npos)
177 return class_options;
178
179 return "handout," + class_options;
180 }
181
183 std::ostream & output,
185 const bool handout_mode,
187 {
188 output << "\\documentclass";
189
190 const std::string class_options =
192 if (not class_options.empty())
193 output << "[" << class_options << "]";
194
195 output << "{beamer}\n"
196 << "\\usepackage{tikz}\n"
197 << "\\usepackage{graphicx}\n";
199
200 if (options.hide_navigation_symbols)
201 output << "\\setbeamertemplate{navigation symbols}{}\n";
202
203 if (not options.extra_preamble.empty())
204 output << options.extra_preamble << '\n';
205
206 output << "\\begin{document}\n\n";
207 }
208
209 static void draw_beamer_document_epilogue(std::ostream & output)
210 {
211 output << "\n\\end{document}\n";
212 }
213
215 std::ostream & output,
216 const std::string & frame_title,
217 const std::string & frame_options)
218 {
219 output << "\\begin{frame}";
220 if (not frame_options.empty())
221 output << "[" << frame_options << "]";
222 output << "{" << frame_title << "}\n";
223 }
224
226 std::ostream & output,
227 const std::vector<Tikz_Scene> & steps,
229 const bool handout_mode)
230 {
233 draw_beamer_frame_begin(output, options.frame_title, options.frame_options);
234
235 if (steps.empty())
236 output << "\\centering\\small No overlays provided.\n";
237 else if (handout_mode)
239 else
240 for (size_t i = 0; i < steps.size(); ++i)
241 {
242 output << "\\only<" << (i + 1) << ">{\n";
244 output << "}\n";
245 }
246
247 output << "\\end{frame}\n";
249 }
250
252 std::ostream & output,
254 const bool handout_mode) const
255 {
258 draw_beamer_frame_begin(output, options.frame_title, options.frame_options);
260 output << "\\end{frame}\n";
262 }
263
265 bool squarize_ = true;
266
267public:
268 Tikz_Scene(const double width_mm,
269 const double height_mm,
270 const double xoffset_mm = 0.0,
271 const double yoffset_mm = 0.0,
272 const bool squarize = true)
275 {
276 }
277
278 [[nodiscard]] Tikz_Plane & plane() { return plane_; }
279 [[nodiscard]] const Tikz_Plane & plane() const { return plane_; }
280
286
287 [[nodiscard]] bool squarize() const { return squarize_; }
288 void set_squarize(const bool value) { squarize_ = value; }
289
291 {
292 plane_.clear();
293 return *this;
294 }
295
297 {
299 return *this;
300 }
301
303 {
305 return *this;
306 }
307
309 const double step_y = 1.0,
310 const bool draw_ticks = true)
311 {
313 return *this;
314 }
315
317 {
319 return *this;
320 }
321
323 {
325 return *this;
326 }
327
329 {
330 plane_.set_axis_style(style);
331 return *this;
332 }
333
335 {
336 plane_.set_grid_style(style);
337 return *this;
338 }
339
341 {
343 return *this;
344 }
345
346 Tikz_Scene & enable_native_tikz_layers(const bool enabled = true)
347 {
349 return *this;
350 }
351
352 Tikz_Scene & enable_auto_legend(const bool enabled = true)
353 {
354 plane_.enable_auto_legend(enabled);
355 return *this;
356 }
357
358 Tikz_Scene & add_legend_entry(const std::string & label,
359 const Tikz_Style & style)
360 {
361 plane_.add_legend_entry(label, style);
362 return *this;
363 }
364
366 {
368 return *this;
369 }
370
371 Tikz_Scene & register_tikz_style(const std::string & name,
372 const Tikz_Style & style)
373 {
374 plane_.register_tikz_style(name, style);
375 return *this;
376 }
377
378 template <typename Geom>
379 Tikz_Scene & add(const Geom & object)
380 {
381 put_in_plane(plane_, object);
382 return *this;
383 }
384
385 template <typename Geom>
386 Tikz_Scene & add(const Geom & object,
387 const Tikz_Style & style,
388 const int layer = Tikz_Plane::Layer_Default)
389 {
390 put_in_plane(plane_, object, style, layer);
391 return *this;
392 }
393
395 const Array<Point> & points,
396 const Tikz_Style & style = tikz_points_style("black"),
397 const int layer = Tikz_Plane::Layer_Default)
398 {
399 Aleph::put_points(plane_, points, style, layer);
400 return *this;
401 }
402
404 const DynList<Point> & points,
405 const Tikz_Style & style = tikz_points_style("black"),
406 const int layer = Tikz_Plane::Layer_Default)
407 {
408 Aleph::put_points(plane_, points, style, layer);
409 return *this;
410 }
411
413 const Array<Polygon> & polys,
414 const Tikz_Style & style = tikz_wire_style("black", true),
415 const int layer = Tikz_Plane::Layer_Default)
416 {
417 Aleph::put_polygons(plane_, polys, style, layer);
418 return *this;
419 }
420
421 template <typename Points, typename HullAlgorithm, typename... Args>
424 Args &&... args)
425 {
426 if constexpr (std::is_same_v<std::decay_t<Points>, Array<Point>>)
427 {
429 for (size_t i = 0; i < points.size(); ++i)
430 converted.append(points(i));
431
433 plane_,
434 converted,
435 std::forward<HullAlgorithm>(algorithm),
436 std::forward<Args>(args)...);
437 }
438 else
439 {
441 plane_,
442 points,
443 std::forward<HullAlgorithm>(algorithm),
444 std::forward<Args>(args)...);
445 }
446 }
447
448 template <typename... Args>
450 {
452 plane_, std::forward<Args>(args)...);
453 }
454
455 template <typename... Args>
457 {
459 plane_, std::forward<Args>(args)...);
460 }
461
462 template <typename... Args>
464 {
466 plane_, std::forward<Args>(args)...);
467 }
468
469 template <typename... Args>
471 {
473 plane_, std::forward<Args>(args)...);
474 }
475
476 template <typename... Args>
478 {
480 plane_, std::forward<Args>(args)...);
481 }
482
483 template <typename... Args>
489
490 template <typename... Args>
496
497 template <typename... Args>
499 {
501 plane_, std::forward<Args>(args)...);
502 }
503
504 template <typename... Args>
506 {
508 plane_, std::forward<Args>(args)...);
509 }
510
511 template <typename... Args>
513 {
515 plane_, std::forward<Args>(args)...);
516 }
517
518 template <typename... Args>
520 {
522 plane_, std::forward<Args>(args)...);
523 }
524
525 template <typename... Args>
527 {
529 plane_, std::forward<Args>(args)...);
530 }
531
532 template <typename... Args>
534 {
536 plane_, std::forward<Args>(args)...);
537 }
538
539 template <typename... Args>
541 {
543 plane_, std::forward<Args>(args)...);
544 }
545
546 template <typename... Args>
548 {
550 plane_, std::forward<Args>(args)...);
551 }
552
553 template <typename... Args>
555 {
557 plane_, std::forward<Args>(args)...);
558 }
559
560 template <typename... Args>
562 {
564 plane_, std::forward<Args>(args)...);
565 }
566
567 template <typename... Args>
569 {
571 plane_, std::forward<Args>(args)...);
572 }
573
574 template <typename... Args>
576 {
578 plane_, std::forward<Args>(args)...);
579 }
580
581 template <typename... Args>
583 {
585 plane_, std::forward<Args>(args)...);
586 }
587
588 template <typename... Args>
590 {
592 plane_, std::forward<Args>(args)...);
593 }
594
595 template <typename... Args>
597 {
599 plane_, std::forward<Args>(args)...);
600 }
601
602 template <typename... Args>
604 {
606 plane_, std::forward<Args>(args)...);
607 }
608
609 template <typename... Args>
611 {
612 Aleph::put_funnel_trace_step(plane_, std::forward<Args>(args)...);
613 }
614
615 template <typename Callable>
616 decltype(auto) run(Callable && callable)
617 {
618 return std::forward<Callable>(callable)(plane_);
619 }
620
621 template <typename Callable>
622 decltype(auto) run(Callable && callable) const
623 {
624 return std::forward<Callable>(callable)(plane_);
625 }
626
627 void draw(std::ostream & output) const
628 {
630 }
631
632 [[nodiscard]] std::string to_tikz() const
633 {
634 std::ostringstream out;
635 draw(out);
636 return out.str();
637 }
638
640 std::ostream & output,
641 const std::string & frame_title = "TikZ Scene",
642 const std::string & frame_options = "t") const
643 {
644 draw_beamer_frame_begin(output, frame_title, frame_options);
647 output << "\\end{frame}\n";
648 }
649
651 std::ostream & output,
652 const Tikz_Standalone_Document_Options & options = {}) const
653 {
654 output << "\\documentclass";
655 if (not options.class_options.empty())
656 output << "[" << options.class_options << "]";
657
658 output << "{";
659 if (options.document_class.empty())
660 output << "standalone";
661 else
662 output << options.document_class;
663 output << "}\n"
664 << "\\usepackage{tikz}\n";
666
667 if (not options.extra_preamble.empty())
668 output << options.extra_preamble << '\n';
669
670 output << "\\begin{document}\n\n";
671 draw(output);
672 output << "\n\\end{document}\n";
673 }
674
675 [[nodiscard]] std::string to_standalone(
676 const Tikz_Standalone_Document_Options & options = {}) const
677 {
678 std::ostringstream out;
680 return out.str();
681 }
682
684 std::ostream & output,
685 const Tikz_Beamer_Document_Options & options = {}) const
686 {
688 }
689
690 [[nodiscard]] std::string to_beamer(
691 const Tikz_Beamer_Document_Options & options = {}) const
692 {
693 std::ostringstream out;
695 return out.str();
696 }
697
699 std::ostream & output,
700 const Tikz_Beamer_Document_Options & options = {}) const
701 {
703 }
704
705 [[nodiscard]] std::string to_handout(
706 const Tikz_Beamer_Document_Options & options = {}) const
707 {
708 std::ostringstream out;
710 return out.str();
711 }
712
715 std::ostream & output,
716 const std::vector<Tikz_Scene> & steps,
718 {
720 }
721
723 [[nodiscard]] static std::string to_beamer_overlays(
724 const std::vector<Tikz_Scene> & steps,
726 {
727 std::ostringstream out;
729 return out.str();
730 }
731
738 std::ostream & output,
739 const std::vector<Tikz_Scene> & steps,
741 {
743 }
744
746 [[nodiscard]] static std::string to_handout_overlays(
747 const std::vector<Tikz_Scene> & steps,
749 {
750 std::ostringstream out;
752 return out.str();
753 }
754};
755
756} // namespace Aleph
757
758# endif // TIKZGEOM_SCENE_H
#define ah_domain_error_if(C)
Throws std::domain_error if condition holds.
Definition ah-errors.H:527
size_t steps
Definition ca-c-api.h:126
size_t size_t int32_t value
Definition ca-c-api.h:116
size_t size_t int32_t * out
Definition ca-c-api.h:120
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
Doubly-linked list (defined in tpl_dynList.H).
Definition htlist.H:1155
T & append(const T &item)
Definition htlist.H:1271
size_t size() const noexcept
Count the number of elements of the list.
Definition htlist.H:1065
A general (irregular) 2D polygon defined by a sequence of vertices.
Definition polygon.H:247
2D TikZ canvas storing geometry objects and emitting LaTeX output.
Definition tikzgeom.H:200
void set_axis_style(const Tikz_Style &style)
Configure the style used to draw Cartesian axes.
Definition tikzgeom.H:1296
Array< std::string > required_tikz_libraries() const
Collect TikZ libraries required by currently emitted features.
Definition tikzgeom.H:1257
void draw(std::ostream &output, const bool squarize=true) const
Emit a complete tikzpicture with all inserted objects.
Definition tikzgeom.H:1422
void remove_coordinate_grid()
Disable coordinate grid rendering.
Definition tikzgeom.H:1355
void put_cartesian_axis()
Enable Cartesian axes drawing (only when 0 lies in range).
Definition tikzgeom.H:1330
static constexpr int Layer_Default
Definition tikzgeom.H:203
void clear()
Remove all inserted objects from the plane.
Definition tikzgeom.H:1398
void enable_auto_legend(const bool enabled=true)
Enable auto-legend generation from style colors.
Definition tikzgeom.H:1367
void enable_native_tikz_layers(const bool enabled=true)
Enable native PGF layers (\pgfdeclarelayer).
Definition tikzgeom.H:1361
void put_coordinate_grid(const double step_x=1.0, const double step_y=1.0, const bool draw_ticks=true)
Enable coordinate grid/ticks with user step sizes.
Definition tikzgeom.H:1342
void set_point_radius_mm(const double &radius_mm)
Configure point marker radius.
Definition tikzgeom.H:1314
void set_grid_style(const Tikz_Style &style)
Configure the style used to draw coordinate grids.
Definition tikzgeom.H:1304
void register_tikz_style(const std::string &name, const Tikz_Style &style)
Register a reusable \tikzset style for the rendered picture.
Definition tikzgeom.H:1385
void add_legend_entry(const std::string &label, const Tikz_Style &style)
Add a legend entry to be rendered in the top-left corner.
Definition tikzgeom.H:1373
void clear_legend()
Remove user-provided legend entries.
Definition tikzgeom.H:1379
void set_default_style(const Tikz_Style &style)
Configure the default style for subsequent non-styled inserts.
Definition tikzgeom.H:1288
void remove_cartesian_axis()
Disable Cartesian axes drawing.
Definition tikzgeom.H:1336
High-level scene wrapper to compose objects and algorithm visualizations.
Array< Polygon > visualize_convex_decomposition(Args &&... args)
Polygon visualize_convex_intersection(Args &&... args)
Tikz_Scene & clear()
auto visualize_closest_pair(Args &&... args)
Tikz_Scene & remove_coordinate_grid()
auto visualize_regular_triangulation(Args &&... args)
static void draw_beamer_frame_begin(std::ostream &output, const std::string &frame_title, const std::string &frame_options)
Tikz_Scene & put_coordinate_grid(const double step_x=1.0, const double step_y=1.0, const bool draw_ticks=true)
auto visualize_rotating_calipers(Args &&... args)
static void draw_tikz_libraries(std::ostream &output, const Array< std::string > &libraries)
Emit one \\usetikzlibrary{...} command when needed.
Tikz_Scene & enable_native_tikz_layers(const bool enabled=true)
std::string to_standalone(const Tikz_Standalone_Document_Options &options={}) const
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 void draw_handout_overlays(std::ostream &output, const std::vector< Tikz_Scene > &steps, const Tikz_Beamer_Document_Options &options={})
Export the final overlay scene as a static handout frame.
auto visualize_half_plane_intersection(Args &&... args)
static void draw_fitted_beamer_picture(std::ostream &output, const Tikz_Scene &scene, const Tikz_Beamer_Document_Options &options)
Render a centered scene scaled to the configured Beamer bounds.
decltype(auto) run(Callable &&callable)
Tikz_Plane & plane()
static void draw_beamer_document_preamble(std::ostream &output, const Tikz_Beamer_Document_Options &options, const bool handout_mode, const Array< std::string > &libraries)
static void draw_beamer_document_epilogue(std::ostream &output)
void draw_standalone(std::ostream &output, const Tikz_Standalone_Document_Options &options={}) const
Tikz_Scene & enable_auto_legend(const bool enabled=true)
std::string to_tikz() const
auto visualize_segment_arrangement(Args &&... args)
Tikz_Scene & add(const Geom &object, const Tikz_Style &style, const int layer=Tikz_Plane::Layer_Default)
auto visualize_line_sweep(Args &&... args)
static void draw_beamer_overlays_document(std::ostream &output, const std::vector< Tikz_Scene > &steps, const Tikz_Beamer_Document_Options &options, const bool handout_mode)
decltype(auto) run(Callable &&callable) const
Tikz_Scene & put_cartesian_axis()
auto visualize_visibility_polygon(Args &&... args)
auto visualize_minkowski_sum(Args &&... args)
Tikz_Scene & set_axis_style(const Tikz_Style &style)
static double beamer_picture_scale(const Tikz_Scene &scene, const Tikz_Beamer_Document_Options &options)
Compute a uniform scale that fits a scene in a Beamer frame.
Tikz_Scene & add_legend_entry(const std::string &label, const Tikz_Style &style)
void set_squarize(const bool value)
DynList< Point > visualize_shortest_path_in_polygon(Args &&... args)
Array< Polygon > visualize_boolean_operation(Args &&... args)
auto visualize_range_tree_query(Args &&... args)
void put_funnel_trace_step(Args &&... args)
void draw_beamer_frame(std::ostream &output, const std::string &frame_title="TikZ Scene", const std::string &frame_options="t") const
Tikz_Scene & set_default_style(const Tikz_Style &style)
const Tikz_Plane & plane() const
Tikz_Scene & add(const Geom &object)
auto visualize_voronoi(Args &&... args)
Tikz_Scene & clear_legend()
std::string to_handout(const Tikz_Beamer_Document_Options &options={}) const
auto visualize_range_tree(Args &&... args)
bool squarize() const
Tikz_Scene & register_tikz_style(const std::string &name, const Tikz_Style &style)
Tikz_Scene & add_points(const Array< Point > &points, const Tikz_Style &style=tikz_points_style("black"), const int layer=Tikz_Plane::Layer_Default)
static std::string compose_beamer_class_options(const bool handout_mode, const std::string &class_options)
static void draw_beamer_overlays(std::ostream &output, const std::vector< Tikz_Scene > &steps, const Tikz_Beamer_Document_Options &options={})
Export multiple scenes as beamer overlays (\\only<k>{...}) in one frame.
auto visualize_aabb_tree(Args &&... args)
Tikz_Scene & add_polygons(const Array< Polygon > &polys, const Tikz_Style &style=tikz_wire_style("black", true), const int layer=Tikz_Plane::Layer_Default)
Tikz_Scene & remove_cartesian_axis()
void draw_handout(std::ostream &output, const Tikz_Beamer_Document_Options &options={}) const
Array< std::string > required_tikz_libraries() const
Return TikZ library dependencies required by this scene.
void draw_beamer(std::ostream &output, const Tikz_Beamer_Document_Options &options={}) const
void draw_beamer_document(std::ostream &output, const Tikz_Beamer_Document_Options &options, const bool handout_mode) const
static std::string to_beamer_overlays(const std::vector< Tikz_Scene > &steps, const Tikz_Beamer_Document_Options &options={})
String variant of draw_beamer_overlays.
Tikz_Scene(const double width_mm, const double height_mm, const double xoffset_mm=0.0, const double yoffset_mm=0.0, const bool squarize=true)
auto visualize_aabb_tree_query(Args &&... args)
static void append_unique_libraries(Array< std::string > &destination, const Array< std::string > &source)
Append unique library names from source to destination.
auto visualize_kdtree_partitions(Args &&... args)
Polygon visualize_convex_hull(const Points &points, HullAlgorithm &&algorithm, Args &&... args)
Tikz_Scene & add_points(const DynList< Point > &points, const Tikz_Style &style=tikz_points_style("black"), const int layer=Tikz_Plane::Layer_Default)
AlphaShape::Result visualize_alpha_shape(Args &&... args)
auto visualize_monotone_triangulation(Args &&... args)
Tikz_Scene & set_grid_style(const Tikz_Style &style)
auto visualize_delaunay(Args &&... args)
ShortestPathDebugResult visualize_shortest_path_with_portals(Args &&... args)
void draw(std::ostream &output) const
static Array< std::string > collect_required_libraries(const std::vector< Tikz_Scene > &steps)
Collect the union of TikZ dependencies across overlay steps.
auto visualize_power_diagram(Args &&... args)
Tikz_Scene & set_point_radius_mm(const double radius_mm)
std::string to_beamer(const Tikz_Beamer_Document_Options &options={}) const
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
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.
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.
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.
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.
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.
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
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.
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_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.
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.
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 append_unique_tikz_library(Array< std::string > &libraries, const std::string &library)
Append library into libraries unless already present.
Definition tikzgeom.H:86
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.
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.
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.
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.
static struct argp_option options[]
Definition ntreepic.C:1886
Result of an alpha-shape computation.
Result bundle for shortest-path + funnel portal visualization.
Options used by Tikz_Scene beamer/handout export helpers.
std::string frame_title
Frame title used by scene exports.
std::string extra_preamble
Extra LaTeX preamble lines inserted before \\begin{document}.
double max_picture_width_mm
Maximum rendered picture width in millimeters.
std::string class_options
beamer class options (for example aspectratio=169).
std::string frame_options
Frame options passed to \\begin{frame}[...].
bool hide_navigation_symbols
Whether to hide navigation symbols (\\setbeamertemplate).
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
DynList< Point > Points
Helpers to visualize computational-geometry algorithm results in TikZ.
ofstream output
Definition writeHeap.C:215