Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
tikz_scene_beamer_example.cc
Go to the documentation of this file.
1#include <fstream>
2#include <iostream>
3#include <string>
4
5#include <tikzgeom_scene.H>
6
7using namespace Aleph;
8
9namespace
10{
11
13{
14 Polygon p;
15 p.add_vertex(Point(0, 0));
16 p.add_vertex(Point(24, 0));
17 p.add_vertex(Point(24, 20));
18 p.add_vertex(Point(14, 20));
19 p.add_vertex(Point(14, 8));
20 p.add_vertex(Point(10, 8));
21 p.add_vertex(Point(10, 20));
22 p.add_vertex(Point(0, 20));
23 p.close();
24 return p;
25}
26
27} // namespace
28
29int main(int argc, char * argv[])
30{
31 std::string output_path = "tikz_scene_beamer_example.tex";
32 bool handout = false;
33
34 for (int i = 1; i < argc; ++i)
35 {
36 const std::string arg = argv[i];
37 if (arg == "--handout")
38 handout = true;
39 else
41 }
42
43 std::ofstream out(output_path);
44 if (not out)
45 {
46 std::cerr << "Cannot open output file: " << output_path << '\n';
47 return 1;
48 }
49
50 Tikz_Scene scene(178, 108, 0, 0, true);
51 scene.put_cartesian_axis()
52 .set_point_radius_mm(0.70);
53
54 const Polygon polygon = make_corridor();
55 const Point source(2, 16);
56 const Point target(22, 16);
57
59 scene.visualize_shortest_path_with_portals(
60 polygon,
61 source,
62 target,
64 tikz_area_style("black", "gray!15", 0.24),
65 tikz_points_style("green!50!black"),
66 tikz_points_style("blue"),
67 tikz_wire_style("purple", true),
68 tikz_path_style("orange!90!black"),
69 true,
70 tikz_points_style("orange!90!black"));
71
72 scene.add(Text(Point(-1, 22),
73 "Tikz_Scene beamer export: portals=" +
74 std::to_string(shortest.portals.size())),
75 make_tikz_draw_style("black"),
77
79 opts.frame_title = handout ? "TikZ Scene (Handout)" : "TikZ Scene (Beamer)";
80 opts.frame_options = "t";
81 opts.class_options = "aspectratio=169";
82
83 if (handout)
84 scene.draw_handout(out, opts);
85 else
86 scene.draw_beamer(out, opts);
87
88 std::cout << "Generated " << output_path << '\n'
89 << "Mode: " << (handout ? "handout" : "beamer") << '\n'
90 << "Portals: " << shortest.portals.size() << '\n'
91 << "Compile with: pdflatex " << output_path << '\n';
92
93 return 0;
94}
Represents a point with rectangular coordinates in a 2D plane.
Definition point.H:229
A general (irregular) 2D polygon defined by a sequence of vertices.
Definition polygon.H:246
void add_vertex(const Point &point)
Add a vertex to the polygon.
Definition polygon.H:677
void close()
Close the polygon.
Definition polygon.H:840
Compute the shortest Euclidean path between two points inside a simple polygon.
Represents a text string positioned at a 2D point.
Definition point.H:2739
static constexpr int Layer_Overlay
Definition tikzgeom.H:189
High-level scene wrapper to compose objects and algorithm visualizations.
Main namespace for Aleph-w library functions.
Definition ah-arena.H:89
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
Tikz_Style tikz_path_style(const std::string &color="red", const bool with_arrow=false)
Creates a style optimized for polyline paths.
Tikz_Style make_tikz_draw_style(const std::string &draw_color)
Create a basic draw style with a custom color.
Definition tikzgeom.H:156
Tikz_Style tikz_wire_style(const std::string &color="black", const bool dashed=false, const bool with_arrow=false)
Creates a style optimized for wireframe segments and polygons.
Tikz_Style tikz_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.
Tikz_Style tikz_points_style(const std::string &color="black", const double opacity=-1.0)
Creates a style optimized for point clouds.
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.