aboutsummaryrefslogtreecommitdiff
path: root/svg-flatten/include
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-10-26 00:03:27 +0200
committerjaseg <git@jaseg.de>2023-10-26 00:04:17 +0200
commit00eb9594d6089640cbdfe242da3a16c6bdf1f73f (patch)
tree86a40a5471d1686cd80d3a54cfcbc3ffefc3f880 /svg-flatten/include
parent8ab0c9fa017b5ead2e3f5cfc892b242cd0bbc908 (diff)
downloadgerbolyze-00eb9594d6089640cbdfe242da3a16c6bdf1f73f.tar.gz
gerbolyze-00eb9594d6089640cbdfe242da3a16c6bdf1f73f.tar.bz2
gerbolyze-00eb9594d6089640cbdfe242da3a16c6bdf1f73f.zip
svg-flatten: Add cubic bezier support for newer usvg versions
Diffstat (limited to 'svg-flatten/include')
-rw-r--r--svg-flatten/include/flatten.hpp22
-rw-r--r--svg-flatten/include/gerbolyze.hpp1
2 files changed, 23 insertions, 0 deletions
diff --git a/svg-flatten/include/flatten.hpp b/svg-flatten/include/flatten.hpp
index 92cbf38..bd2d8e3 100644
--- a/svg-flatten/include/flatten.hpp
+++ b/svg-flatten/include/flatten.hpp
@@ -2,6 +2,28 @@
#include "gerbolyze.hpp"
namespace gerbolyze {
+ class curve3_div {
+ public:
+ curve3_div(double distance_tolerance=0.1, double angle_tolerance=0.0, double cusp_limit=0.0)
+ : m_cusp_limit(cusp_limit),
+ m_distance_tolerance_square(0.25*distance_tolerance*distance_tolerance),
+ m_angle_tolerance(angle_tolerance)
+ {
+ }
+
+ void run(double x1, double y1, double x2, double y2, double x3, double y3);
+ const std::vector<d2p> &points() { return m_points; }
+
+ private:
+ void recursive_bezier(double x1, double y1, double x2, double y2,
+ double x3, double y3,
+ unsigned level);
+ double m_cusp_limit;
+ double m_distance_tolerance_square;
+ double m_angle_tolerance;
+ std::vector<d2p> m_points;
+ };
+
class curve4_div {
public:
curve4_div(double distance_tolerance=0.1, double angle_tolerance=0.0, double cusp_limit=0.0)
diff --git a/svg-flatten/include/gerbolyze.hpp b/svg-flatten/include/gerbolyze.hpp
index 2fb7605..2b3652c 100644
--- a/svg-flatten/include/gerbolyze.hpp
+++ b/svg-flatten/include/gerbolyze.hpp
@@ -22,6 +22,7 @@
#include <iostream>
#include <string>
#include <array>
+#include <cstdint>
#include <pugixml.hpp>