summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/display/inkscape-cairo.cpp5
-rw-r--r--src/display/nr-arena-shape.cpp6
-rw-r--r--src/extension/internal/javafx-out.cpp5
-rw-r--r--src/extension/internal/latex-pstricks.cpp5
-rw-r--r--src/extension/internal/odf.cpp5
-rw-r--r--src/extension/internal/pov-out.cpp5
-rw-r--r--src/extension/internal/ps.cpp5
-rw-r--r--src/helper/geom.cpp15
-rw-r--r--src/livarot/PathCutting.cpp5
-rw-r--r--src/sp-path.cpp5
-rw-r--r--src/sp-polygon.cpp5
11 files changed, 25 insertions, 41 deletions
diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp
index d4a9f7062..8bc9eade2 100644
--- a/src/display/inkscape-cairo.cpp
+++ b/src/display/inkscape-cairo.cpp
@@ -27,6 +27,7 @@
#include <2geom/path.h>
#include <2geom/transforms.h>
#include <2geom/sbasis-to-bezier.h>
+#include "helper/geom-curves.h"
/** Creates a cairo context to render to the given pixblock on the given area */
cairo_t *
@@ -74,9 +75,7 @@ nr_create_cairo_context (NRRectL *area, NRPixBlock *pb)
static void
feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix const & trans, Geom::Rect view, bool optimize_stroke)
{
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
Geom::Point end_tr = c.finalPoint() * trans;
if (!optimize_stroke) {
diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp
index 325681650..840f5044a 100644
--- a/src/display/nr-arena-shape.cpp
+++ b/src/display/nr-arena-shape.cpp
@@ -32,6 +32,7 @@
#include "prefs-utils.h"
#include "inkscape-cairo.h"
#include "helper/geom.h"
+#include "helper/geom-curves.h"
#include "sp-filter.h"
#include "sp-filter-reference.h"
#include "display/nr-filter.h"
@@ -428,10 +429,7 @@ static bool has_inner_area(Geom::PathVector const & pv) {
if ( (pv.size() == 1) && (pv.front().size() <= 1) ) {
// vector has only one path with only one segment, see if that's a non-curve segment: that would mean no internal region
- Geom::Curve const * c = & pv.front().front();
- if ( dynamic_cast<Geom::LineSegment const*>(c) ||
- dynamic_cast<Geom::HLineSegment const*>(c) ||
- dynamic_cast<Geom::VLineSegment const*>(c) )
+ if ( is_straight_curve(pv.front().front()) )
{
return false;
}
diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp
index 2e0f2d59f..29c2bdab0 100644
--- a/src/extension/internal/javafx-out.cpp
+++ b/src/extension/internal/javafx-out.cpp
@@ -30,6 +30,7 @@
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
#include "helper/geom.h"
+#include "helper/geom-curves.h"
#include <io/sys.h>
@@ -473,9 +474,7 @@ bool JavaFXOutput::doCurve(SPItem *item, const String &id)
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit)
{
//### LINE
- if( dynamic_cast<Geom::LineSegment const *> (&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if( is_straight_curve(*cit) )
{
Geom::Point p = cit->finalPoint();
out(" LineTo {\n");
diff --git a/src/extension/internal/latex-pstricks.cpp b/src/extension/internal/latex-pstricks.cpp
index 9909d7436..c1dcec361 100644
--- a/src/extension/internal/latex-pstricks.cpp
+++ b/src/extension/internal/latex-pstricks.cpp
@@ -31,6 +31,7 @@
#include <2geom/sbasis-to-bezier.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
#include "sp-item.h"
@@ -305,9 +306,7 @@ PrintLatex::print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c )
using Geom::X;
using Geom::Y;
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
os << "\\lineto(" << c.finalPoint()[X] << "," << c.finalPoint()[Y] << ")\n";
}
diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp
index 2a71eabca..02c3626bf 100644
--- a/src/extension/internal/odf.cpp
+++ b/src/extension/internal/odf.cpp
@@ -56,6 +56,7 @@
#include <2geom/hvlinesegment.h>
#include <2geom/transforms.h>
#include <helper/geom.h>
+#include "helper/geom-curves.h"
#include "extension/system.h"
#include "xml/repr.h"
@@ -1504,9 +1505,7 @@ writePath(Writer &outs, Geom::PathVector const &pathv,
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit) {
- if( dynamic_cast<Geom::LineSegment const *> (&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if( is_straight_curve(*cit) )
{
double destx = cit->finalPoint()[X];
double desty = cit->finalPoint()[Y];
diff --git a/src/extension/internal/pov-out.cpp b/src/extension/internal/pov-out.cpp
index 01b8e64b5..ea746eae7 100644
--- a/src/extension/internal/pov-out.cpp
+++ b/src/extension/internal/pov-out.cpp
@@ -32,6 +32,7 @@
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
#include "helper/geom.h"
+#include "helper/geom-curves.h"
#include <io/sys.h>
#include <string>
@@ -352,9 +353,7 @@ bool PovOutput::doCurve(SPItem *item, const String &id)
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_closed(); ++cit)
{
- if( dynamic_cast<Geom::LineSegment const *> (&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if( is_straight_curve(*cit) )
{
Geom::Point p0 = cit->initialPoint();
Geom::Point p1 = cit->finalPoint();
diff --git a/src/extension/internal/ps.cpp b/src/extension/internal/ps.cpp
index cad576975..6f1405de2 100644
--- a/src/extension/internal/ps.cpp
+++ b/src/extension/internal/ps.cpp
@@ -78,6 +78,7 @@
#include <2geom/sbasis-to-bezier.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
/*
using std::atof;
@@ -1465,9 +1466,7 @@ PrintPS::print_2geomcurve(SVGOStringStream &os, Geom::Curve const & c )
using Geom::X;
using Geom::Y;
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
os << c.finalPoint()[X] << " " << c.finalPoint()[Y] << " lineto\n";
}
diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp
index ac8930412..bf487f652 100644
--- a/src/helper/geom.cpp
+++ b/src/helper/geom.cpp
@@ -12,6 +12,7 @@
*/
#include "helper/geom.h"
+#include "helper/geom-curves.h"
#include <typeinfo>
#include <2geom/pathvector.h>
#include <2geom/path.h>
@@ -173,9 +174,7 @@ bounds_exact_transformed(Geom::PathVector const & pv, Geom::Matrix const & t)
for (Geom::Path::const_iterator cit = it->begin(); cit != it->end_open(); ++cit) {
Geom::Curve const &c = *cit;
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
bbox.expandTo( c.finalPoint() * t );
}
@@ -363,9 +362,7 @@ geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Matrix const &m,
Geom::Coord tolerance, Geom::Rect const *viewbox,
Geom::Point &p0) // pass p0 through as it represents the last endpoint added (the finalPoint of last curve)
{
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
Geom::Point pe = c.finalPoint() * m;
if (bbox) {
@@ -509,10 +506,8 @@ pathv_to_linear_and_cubic_beziers( Geom::PathVector const &pathv )
output.back().close( pit->closed() );
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_open(); ++cit) {
- if( dynamic_cast<Geom::CubicBezier const*>(&*cit) ||
- dynamic_cast<Geom::LineSegment const*>(&*cit) ||
- dynamic_cast<Geom::HLineSegment const*>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const*>(&*cit) )
+ if( dynamic_cast<Geom::CubicBezier const*>(&*cit) ||
+ is_straight_curve(*cit) )
{
output.back().append(*cit);
}
diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp
index 3a7bd71ad..47956031f 100644
--- a/src/livarot/PathCutting.cpp
+++ b/src/livarot/PathCutting.cpp
@@ -28,6 +28,7 @@
#include <2geom/sbasis-to-bezier.h>
#include <2geom/curves.h>
#include "../display/canvas-bpath.h"
+#include "helper/geom-curves.h"
void Path::DashPolyline(float head,float tail,float body,int nbD,float *dashs,bool stPlain,float stOffset)
{
@@ -379,9 +380,7 @@ Path::MakePathVector()
void Path::AddCurve(Geom::Curve const &c)
{
- if( dynamic_cast<Geom::LineSegment const*>(&c) ||
- dynamic_cast<Geom::HLineSegment const*>(&c) ||
- dynamic_cast<Geom::VLineSegment const*>(&c) )
+ if( is_straight_curve(c) )
{
LineTo( from_2geom(c.finalPoint()) );
}
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index e641632d9..e0e10b6de 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -25,6 +25,7 @@
#include <2geom/pathvector.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
#include "svg/svg.h"
#include "xml/repr.h"
@@ -157,9 +158,7 @@ sp_path_convert_to_guides(SPItem *item)
for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) {
for(Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
// only add curves for straight line segments
- if( dynamic_cast<Geom::LineSegment const *>(&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if( is_straight_curve(*cit) )
{
pts.push_back(std::make_pair(cit->initialPoint() * i2d, cit->finalPoint() * i2d));
}
diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp
index fddc9d1db..014c68c9b 100644
--- a/src/sp-polygon.cpp
+++ b/src/sp-polygon.cpp
@@ -21,6 +21,7 @@
#include <2geom/pathvector.h>
#include <2geom/bezier-curve.h>
#include <2geom/hvlinesegment.h>
+#include "helper/geom-curves.h"
#include "svg/stringstream.h"
#include "xml/repr.h"
#include "document.h"
@@ -98,9 +99,7 @@ static gchar *sp_svg_write_polygon(Geom::PathVector const & pathv)
for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) {
for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
- if ( dynamic_cast<Geom::LineSegment const *>(&*cit) ||
- dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
- dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ if ( is_straight_curve(*cit) )
{
os << cit->finalPoint()[0] << "," << cit->finalPoint()[1] << " ";
} else {