From: johanengelen Date: Fri, 4 Jul 2008 22:52:34 +0000 (+0000) Subject: use if(dynamic_cast<>) instead of if(typeid==) to check 2geom segment types for strai... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=8eb8a534b36d267df08b0067406586be3c0d4d23;p=inkscape.git use if(dynamic_cast<>) instead of if(typeid==) to check 2geom segment types for straightlines. this because the closing line segment is special class ClosingSegment : public LineSegment. --- diff --git a/src/display/inkscape-cairo.cpp b/src/display/inkscape-cairo.cpp index 9a114f48e..b67ac1311 100644 --- a/src/display/inkscape-cairo.cpp +++ b/src/display/inkscape-cairo.cpp @@ -10,7 +10,6 @@ #include -#include #ifdef HAVE_CONFIG_H # include #endif @@ -160,9 +159,9 @@ feed_curve_to_cairo (cairo_t *ct, NArtBpath const *bpath, NR::Matrix trans, NR:: static void feed_curve_to_cairo(cairo_t *cr, Geom::Curve const &c, Geom::Matrix & trans, Geom::Rect view, bool optimize_stroke) { - if( typeid(c) == typeid(Geom::LineSegment) || - typeid(c) == typeid(Geom::HLineSegment) || - typeid(c) == typeid(Geom::VLineSegment) ) + if( dynamic_cast(&c) || + dynamic_cast(&c) || + dynamic_cast(&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 6974b0008..23bf70be5 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -426,13 +426,13 @@ 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 ( typeid(c) == typeid(Geom::LineSegment) ) - return false; - if ( typeid(c) == typeid(Geom::HLineSegment) ) - return false; - if ( typeid(c) == typeid(Geom::VLineSegment) ) + Geom::Curve const * c = & pv.front().front(); + if ( dynamic_cast(c) || + dynamic_cast(c) || + dynamic_cast(c) ) + { return false; + } } return true; //too costly to see if it has region to be filled, so return true. diff --git a/src/helper/geom.cpp b/src/helper/geom.cpp index 9ec21a44d..9b3b98894 100644 --- a/src/helper/geom.cpp +++ b/src/helper/geom.cpp @@ -160,9 +160,9 @@ 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( typeid(c) == typeid(Geom::LineSegment) || - typeid(c) == typeid(Geom::HLineSegment) || - typeid(c) == typeid(Geom::VLineSegment) ) + if( dynamic_cast(&c) || + dynamic_cast(&c) || + dynamic_cast(&c) ) { bbox.expandTo( c.finalPoint() * t ); } @@ -350,9 +350,9 @@ 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( typeid(c) == typeid(Geom::LineSegment) || - typeid(c) == typeid(Geom::HLineSegment) || - typeid(c) == typeid(Geom::VLineSegment) ) + if( dynamic_cast(&c) || + dynamic_cast(&c) || + dynamic_cast(&c) ) { Geom::Point pe = c.finalPoint() * m; if (bbox) { diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 718017851..1ab2faf60 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -411,11 +411,11 @@ void* Path::MakeArtBPath(void) void Path::AddCurve(Geom::Curve const &c) { - if( typeid(c) == typeid(Geom::LineSegment) || - typeid(c) == typeid(Geom::HLineSegment) || - typeid(c) == typeid(Geom::VLineSegment) ) + if( dynamic_cast(&c) || + dynamic_cast(&c) || + dynamic_cast(&c) ) { - LineTo( to_2geom(c.finalPoint()) ); + LineTo( from_2geom(c.finalPoint()) ); } /* else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast(c)) {