blob: 08403e2ae14f18385058b2c9fed4af1dd1c3225c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
// SPDX-License-Identifier: GPL-2.0-or-later
#ifndef INKSCAPE_HELPER_GEOM_CURVES_H
#define INKSCAPE_HELPER_GEOM_CURVES_H
/**
* @file
* Specific curve type functions for Inkscape, not provided by lib2geom.
*/
/*
* Author:
* Johan Engelen <goejendaagh@zonnet.nl>
*
* Copyright (C) 2008-2009 Johan Engelen
*
* Released under GNU GPL v2+, read the file 'COPYING' for more information.
*/
#include <2geom/line.h>
#include <2geom/bezier-curve.h>
/// \todo un-inline this function
inline bool is_straight_curve(Geom::Curve const & c)
{
if( dynamic_cast<Geom::LineSegment const*>(&c) )
{
return true;
}
// the curve can be a quad/cubic bezier, but could still be a perfect straight line
// if the control points are exactly on the line connecting the initial and final points.
Geom::BezierCurve const *curve = dynamic_cast<Geom::BezierCurve const *>(&c);
if (curve) {
Geom::Line line(curve->initialPoint(), curve->finalPoint());
std::vector<Geom::Point> pts = curve->controlPoints();
for (unsigned i = 1; i < pts.size() - 1; ++i) {
if (!are_near(pts[i], line))
return false;
}
return true;
}
return false;
}
#endif // INKSCAPE_HELPER_GEOM_CURVES_H
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
|