68int main(
int argc,
char * argv[])
70 const std::string output_path =
71 argc > 1 ? argv[1] :
"tikz_missing_primitives_example.tex";
73 std::ofstream
out(output_path);
76 std::cerr <<
"Cannot open output file: " << output_path <<
'\n';
86 "Delaunay sites=" + std::to_string(dt.sites.size()) +
87 ", triangles=" + std::to_string(dt.triangles.size())),
94 minkowski_plane, make_convex_p(), make_convex_q());
97 "Minkowski vertices=" + std::to_string(
sum.size())),
104 halfplane_plane, make_hps());
107 "Half-plane intersection vertices=" +
108 std::to_string(feasible.
size())),
116 sweep_plane, make_segments());
119 "Line sweep intersections=" +
120 std::to_string(intersections.size())),
124 out <<
"\\documentclass[tikz,border=8pt]{standalone}\n"
125 <<
"\\usepackage{tikz}\n"
126 <<
"\\begin{document}\n\n";
128 delaunay_plane.
draw(
out,
true);
129 out <<
"\n\\vspace{4mm}\n\n";
130 minkowski_plane.
draw(
out,
true);
131 out <<
"\n\\vspace{4mm}\n\n";
132 halfplane_plane.
draw(
out,
true);
133 out <<
"\n\\vspace{4mm}\n\n";
135 out <<
"\n\\end{document}\n";
137 std::cout <<
"Generated " << output_path <<
'\n';
138 std::cout <<
"Compile with: pdflatex " << output_path <<
'\n';
size_t size_t int32_t * out
Simple dynamic array with automatic resizing and functional operations.
T & append(const T &data)
Append a copy of data
Doubly-linked list (defined in tpl_dynList.H).
T & append(const T &item)
Represents a point with rectangular coordinates in a 2D plane.
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 size_t & size() const
Get the number of vertices.
Represents a line segment between two points.
Represents a text string positioned at a 2D point.
2D TikZ canvas storing geometry objects and emitting LaTeX output.
void draw(std::ostream &output, const bool squarize=true) const
Emit a complete tikzpicture with all inserted objects.
void put_cartesian_axis()
Enable Cartesian axes drawing (only when 0 lies in range).
void set_point_radius_mm(const double &radius_mm)
Configure point marker radius.
static constexpr int Layer_Overlay
Main namespace for Aleph-w library functions.
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.
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.
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.
Tikz_Style make_tikz_draw_style(const std::string &draw_color)
Create a basic draw style with a custom color.
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.
T sum(const Container &container, const T &init=T{})
Compute sum of all elements.
Helpers to visualize computational-geometry algorithm results in TikZ.