summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7929ab0)
raw | patch | inline | side by side (parent: 7929ab0)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 7 Apr 2009 22:58:28 +0000 (22:58 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Tue, 7 Apr 2009 22:58:28 +0000 (22:58 +0000) |
src/helper/geom-curves.h | patch | blob | history |
index f3dc364f2cb44410e46b322a55114e6837886e33..bc5a8213a723074a24aec208533801f92cf9b4a4 100644 (file)
--- a/src/helper/geom-curves.h
+++ b/src/helper/geom-curves.h
* Author:
* Johan Engelen <goejendaagh@zonnet.nl>
*
- * Copyright (C) 2008 Johan Engelen
+ * Copyright (C) 2008-2009 Johan Engelen
*
* Released under GNU GPL
*/
#include <2geom/hvlinesegment.h>
+#include <2geom/line.h>
+#include <2geom/bezier-curve.h>
inline bool is_straight_curve(Geom::Curve const & c) {
if( dynamic_cast<Geom::LineSegment const*>(&c) ||
dynamic_cast<Geom::VLineSegment const*>(&c) )
{
return true;
- } else {
- return false;
}
+ // 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.
+ else if ( Geom::QuadraticBezier const *quad = dynamic_cast<Geom::QuadraticBezier const*>(&c) ) {
+ Geom::Line line( quad->initialPoint(), quad->finalPoint() );
+ if ( are_near((*quad)[1], line) ) {
+ return true;
+ }
+ }
+ else if ( Geom::CubicBezier const *cubic = dynamic_cast<Geom::CubicBezier const*>(&c) ) {
+ Geom::Line line( cubic->initialPoint(), cubic->finalPoint() );
+ if ( are_near((*cubic)[1], line) && are_near((*cubic)[2], line) ) {
+ return true;
+ }
+ }
+
+ return false;
}
#endif // INKSCAPE_HELPER_GEOM_CURVES_H