Code

create pathvector_for_curve method.
authorjohanengelen <johanengelen@users.sourceforge.net>
Fri, 4 Jul 2008 23:36:25 +0000 (23:36 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Fri, 4 Jul 2008 23:36:25 +0000 (23:36 +0000)
src/object-snapper.cpp
src/splivarot.cpp
src/splivarot.h

index 88e709b7fb4eb3591452544e3c3842ac3f2d5635..ef6c5fce26c55be8d1ad802037b488574670ace2 100644 (file)
@@ -320,7 +320,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
                     if (!very_lenghty_prose && !very_complex_path) {
                         SPCurve *curve = curve_for_item(root_item); 
                         if (curve) {
-                            NArtBpath *bpath = bpath_for_curve(root_item, curve, true, true);
+                            NArtBpath *bpath = bpath_for_curve(root_item, curve, true, true); // perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. apply transformation on the snap points, instead of generating whole new path
                             _bpaths_to_snap_to->push_back(bpath); // we will get a dupe of the path, which must be freed at some point
                             curve->unref();
                         }
index 944c15f842b11942e61e3f441cdd8e509732fb34..88daaa666f707df17de1ec9f810053789146e360 100644 (file)
@@ -48,7 +48,7 @@
 #include "libnr/nr-path.h"
 #include "xml/repr.h"
 #include "xml/repr-sorting.h"
-
+#include <2geom/pathvector.h>
 #include <libnr/nr-matrix-fns.h>
 #include <libnr/nr-matrix-ops.h>
 #include <libnr/nr-matrix-translate-ops.h>
@@ -1764,6 +1764,27 @@ bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transf
     return new_bpath;
 }
 
+/* 
+ * NOTE: Returns empty pathvector if curve == NULL
+ * TODO: see if calling this method can be optimized. All the pathvector copying might be slow.
+ */
+Geom::PathVector
+pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull)
+{
+    if (curve == NULL)
+        return Geom::PathVector();
+
+    if (doTransformation) {
+        if (transformFull) {
+            return (curve->get_pathvector()) * sp_item_i2doc_affine(item);
+        } else {
+            return (curve->get_pathvector()) * to_2geom(item->transform);
+        }
+    } else {
+        return curve->get_pathvector();
+    }
+}
+
 SPCurve* curve_for_item(SPItem *item)
 {
     if (!item)
index 2ac47135a947434211fe5770b87d8a8dc5da0192..6e59d2cc501e3056d216b91970449f379c6d3e5b 100644 (file)
@@ -8,6 +8,7 @@
  */
 
 #include "livarot/Path.h"
+#include <2geom/forward.h>
 
 // boolean operations
 // work on the current selection
@@ -45,6 +46,7 @@ void sp_selected_path_simplify ();
 
 Path *Path_for_item(SPItem *item, bool doTransformation, bool transformFull = true);
 NArtBpath *bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull);
+Geom::PathVector pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull);
 SPCurve *curve_for_item(SPItem *item);
 NR::Maybe<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg = 0);
 NR::Point get_point_on_Path(Path *path, int piece, double t);