gerbolyze/svg-flatten/include/flatten.hpp
jaseg 1180ebdc1f Remove cairo dependency
We initially used Cairo for its bezier flattening algorithm. That
algorithm turned out to be a bit too imprecise at the scales we're
working at here (#17), so I ended up porting over some code from
Antigrain Graphics. The only other thing we used Cairo for was debug
output and coordinate transforms, so I just wrote the relevant vector
math in a small header file, deleted all debug output code and thus
eliminated the cairo dependency. This is a step towards Windows builds.
2021-04-25 00:20:51 +02:00

27 lines
984 B
C++

#include "gerbolyze.hpp"
namespace gerbolyze {
class curve4_div {
public:
curve4_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, double x4, double y4);
const std::vector<d2p> &points() { return m_points; }
private:
void recursive_bezier(double x1, double y1, double x2, double y2,
double x3, double y3, double x4, double y4,
unsigned level);
double m_cusp_limit;
double m_distance_tolerance_square;
double m_angle_tolerance;
std::vector<d2p> m_points;
};
}