Code

add SPCurve::first_segment and last_segment
authorjohanengelen <johanengelen@users.sourceforge.net>
Sun, 29 Jun 2008 13:29:23 +0000 (13:29 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Sun, 29 Jun 2008 13:29:23 +0000 (13:29 +0000)
src/display/curve.cpp
src/display/curve.h

index 1261cf9b0b968b9e59f2b6b9a0f59e4ac6e813ca..065365973cdb66a2a1598b06745aa04345e95167 100644 (file)
@@ -894,6 +894,23 @@ SPCurve::last_bpath() const
     return _bpath + _end - 1;
 }
 
+/**
+ * Return last pathsegment (possibly the closing path segment) in PathVector or NULL.
+ * equal in functionality to SPCurve::last_bpath()
+ */
+Geom::Curve const *
+SPCurve::last_segment() const
+{
+    if (is_empty()) {
+        return NULL;
+    }
+    if (_pathv.back().empty()) {
+        return NULL;
+    }
+
+    return &_pathv.back().back_default();
+}
+
 /**
  * Return last path in PathVector or NULL.
  */
@@ -924,6 +941,23 @@ SPCurve::first_bpath() const
     return _bpath;
 }
 
+/**
+ * Return first pathsegment in PathVector or NULL.
+ * equal in functionality to SPCurve::first_bpath()
+ */
+Geom::Curve const *
+SPCurve::first_segment() const
+{
+    if (is_empty()) {
+        return NULL;
+    }
+    if (_pathv.front().empty()) {
+        return NULL;
+    }
+
+    return &_pathv.front().front();
+}
+
 /**
  * Return first path in PathVector or NULL.
  */
@@ -1020,8 +1054,8 @@ SPCurve::last_point() const
         return NR::Point(0, 0);
 
     debug_check("SPCurve::last_point", bpath->c(3) == _pathv.back().finalPoint() );
-    return bpath->c(3);
-    // return from_2geom( _pathv.back().finalPoint() );
+    //return bpath->c(3);
+    return from_2geom( _pathv.back().finalPoint() );
 }
 
 inline static bool
index 0bb45677770704d3dbd9a8d61932f4ea96a6db4e..0ac5d069e8a08d045af7266d35db895216fa9bb1 100644 (file)
@@ -78,8 +78,10 @@ public:
     bool is_empty() const;
     bool is_closed() const;
     NArtBpath const * last_bpath() const;
+    Geom::Curve const * last_segment() const;
     Geom::Path const * last_path() const;
     NArtBpath const * first_bpath() const;
+    Geom::Curve const * first_segment() const;
     Geom::Path const * first_path() const;
     NR::Point first_point() const;
     NR::Point last_point() const;