Code

use if(dynamic_cast<>) instead of if(typeid==) to check 2geom segment types for strai...
authorjohanengelen <johanengelen@users.sourceforge.net>
Fri, 4 Jul 2008 22:52:34 +0000 (22:52 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Fri, 4 Jul 2008 22:52:34 +0000 (22:52 +0000)
src/display/inkscape-cairo.cpp
src/display/nr-arena-shape.cpp
src/helper/geom.cpp
src/livarot/PathCutting.cpp

index 9a114f48ed7e2950f3ae2d9817ac6a52055c7b8d..b67ac1311cb703d229ff472e768a30cb5c738872 100644 (file)
@@ -10,7 +10,6 @@
 
 #include <cairo.h>
 
-#include <typeinfo>
 #ifdef HAVE_CONFIG_H
 # include <config.h>
 #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<Geom::LineSegment const*>(&c) ||
+        dynamic_cast<Geom::HLineSegment const*>(&c) ||
+        dynamic_cast<Geom::VLineSegment const*>(&c) )
     {
         Geom::Point end_tr = c.finalPoint() * trans;
         if (!optimize_stroke) {
index 6974b000817f7dca8e0efeafa83d628d56e0a5c0..23bf70be5eb597e34a8cd58d67f61d4e71b5568e 100644 (file)
@@ -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<Geom::LineSegment const*>(c) ||
+             dynamic_cast<Geom::HLineSegment const*>(c) ||
+             dynamic_cast<Geom::VLineSegment const*>(c) )
+        {
             return false;
+        }
     }
 
     return true; //too costly to see if it has region to be filled, so return true.
index 9ec21a44da73230332b45d90b9e282f9134af441..9b3b9889443118c5099c7fd636f44c2eda1e5709 100644 (file)
@@ -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) {\r
             Geom::Curve const &c = *cit;\r
 \r
-            if( typeid(c) == typeid(Geom::LineSegment) ||\r
-                typeid(c) == typeid(Geom::HLineSegment) ||\r
-                typeid(c) == typeid(Geom::VLineSegment)    )\r
+            if( dynamic_cast<Geom::LineSegment const*>(&c) ||\r
+                dynamic_cast<Geom::HLineSegment const*>(&c) ||\r
+                dynamic_cast<Geom::VLineSegment const*>(&c)    )\r
             {\r
                 bbox.expandTo( c.finalPoint() * t );\r
             }\r
@@ -350,9 +350,9 @@ geom_curve_bbox_wind_distance(Geom::Curve const & c, Geom::Matrix const &m,
                  Geom::Coord tolerance, Geom::Rect const *viewbox,\r
                  Geom::Point &p0) // pass p0 through as it represents the last endpoint added (the finalPoint of last curve)\r
 {\r
-    if( typeid(c) == typeid(Geom::LineSegment) ||\r
-        typeid(c) == typeid(Geom::HLineSegment) ||\r
-        typeid(c) == typeid(Geom::VLineSegment) )\r
+    if( dynamic_cast<Geom::LineSegment const*>(&c) ||\r
+        dynamic_cast<Geom::HLineSegment const*>(&c) ||\r
+        dynamic_cast<Geom::VLineSegment const*>(&c) )\r
     {\r
         Geom::Point pe = c.finalPoint() * m;\r
         if (bbox) {\r
index 718017851f205c133c22cc674368ced85b83eda9..1ab2faf608e4316f977ae9e6066c4e50e44f03e3 100644 (file)
@@ -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<Geom::LineSegment const*>(&c) ||
+        dynamic_cast<Geom::HLineSegment const*>(&c) ||
+        dynamic_cast<Geom::VLineSegment const*>(&c) )
     {
-        LineTo( to_2geom(c.finalPoint()) );
+        LineTo( from_2geom(c.finalPoint()) );
     }
     /*
     else if(Geom::QuadraticBezier const *quadratic_bezier = dynamic_cast<Geom::QuadraticBezier const  *>(c)) {