Code

* [INTL:sk] Slovak translation update
[inkscape.git] / src / livarot / PathConversion.cpp
index a45e7548adf213af1f5234d38fc6849c3918bab5..bf1e9c5c972d50c8eb25a2282299b92689b36592 100644 (file)
@@ -11,8 +11,7 @@
 #include "livarot/path-description.h"
 
 #include <libnr/nr-matrix.h>
-#include <libnr/nr-rotate-ops.h>
-#include <libnr/nr-scale-ops.h>
+#include <2geom/transforms.h>
 
 /*
  * path description -> polyline
@@ -36,7 +35,7 @@ void Path::ConvertWithBackData(double treshhold)
         return;
     }
 
-    NR::Point curX;
+    Geom::Point curX;
     int curP = 1;
     int lastMoveTo = -1;
 
@@ -47,7 +46,7 @@ void Path::ConvertWithBackData(double treshhold)
             curX = dynamic_cast<PathDescrMoveTo *>(descr_cmd[0])->p;
         } else {
             curP = 0;
-            curX[NR::X] = curX[NR::Y] = 0;
+            curX[Geom::X] = curX[Geom::Y] = 0;
         }
         lastMoveTo = AddPoint(curX, 0, 0.0, true);
     }
@@ -56,7 +55,7 @@ void Path::ConvertWithBackData(double treshhold)
     while ( curP < int(descr_cmd.size()) ) {
 
         int const nType = descr_cmd[curP]->getType();
-        NR::Point nextX;
+        Geom::Point nextX;
 
         switch (nType) {
             case descr_forced: {
@@ -76,7 +75,8 @@ void Path::ConvertWithBackData(double treshhold)
 
             case descr_close: {
                 nextX = pts[lastMoveTo].p;
-                AddPoint(nextX, curP, 1.0, false);
+                int n = AddPoint(nextX, curP, 1.0, false);
+                if (n > 0) pts[n].closed = true;
                 curP++;
                 break;
             }
@@ -119,9 +119,9 @@ void Path::ConvertWithBackData(double treshhold)
                 PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
                 if ( nbInterm >= 1 ) {
-                    NR::Point bx = curX;
-                    NR::Point cx = curX;
-                    NR::Point dx = curX;
+                    Geom::Point bx = curX;
+                    Geom::Point cx = curX;
+                    Geom::Point dx = curX;
 
                     dx = nData->p;
                     ip++;
@@ -137,14 +137,14 @@ void Path::ConvertWithBackData(double treshhold)
                         ip++;
                         nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
-                        NR::Point stx;
+                        Geom::Point stx;
                         stx = (bx + cx) / 2;
                         if ( k > 0 ) {
                             AddPoint(stx,curP - 1+k,1.0,false);
                         }
 
                         {
-                            NR::Point mx;
+                            Geom::Point mx;
                             mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8, 0.0, 1.0, curP + k);
                         }
@@ -156,7 +156,7 @@ void Path::ConvertWithBackData(double treshhold)
                         dx = nextX;
                         dx = 2 * dx - cx;
 
-                        NR::Point stx;
+                        Geom::Point stx;
                         stx = (bx + cx) / 2;
 
                         if ( nbInterm > 1 ) {
@@ -164,7 +164,7 @@ void Path::ConvertWithBackData(double treshhold)
                         }
 
                         {
-                            NR::Point mx;
+                            Geom::Point mx;
                             mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8, 0.0, 1.0, curP + nbInterm - 1);
                         }
@@ -201,7 +201,7 @@ void Path::Convert(double treshhold)
         return;
     }
 
-    NR::Point curX;
+    Geom::Point curX;
     int curP = 1;
     int lastMoveTo = 0;
 
@@ -222,7 +222,7 @@ void Path::Convert(double treshhold)
     while ( curP < int(descr_cmd.size()) ) {
 
         int const nType = descr_cmd[curP]->getType();
-        NR::Point nextX;
+        Geom::Point nextX;
 
         switch (nType) {
             case descr_forced: {
@@ -252,6 +252,9 @@ void Path::Convert(double treshhold)
                         descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated;
                     }
                 }
+                if ( descr_cmd[curP]->associated > 0 ) {
+                    pts[descr_cmd[curP]->associated].closed = true;
+                }
                 curP++;
                 break;
             }
@@ -317,12 +320,12 @@ void Path::Convert(double treshhold)
                 PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
                 if ( nbInterm == 1 ) {
-                    NR::Point const midX = nData->p;
+                    Geom::Point const midX = nData->p;
                     RecBezierTo(midX, curX, nextX, treshhold, 8);
                 } else if ( nbInterm > 1 ) {
-                    NR::Point bx = curX;
-                    NR::Point cx = curX;
-                    NR::Point dx = curX;
+                    Geom::Point bx = curX;
+                    Geom::Point cx = curX;
+                    Geom::Point dx = curX;
 
                     dx = nData->p;
                     ip++;
@@ -338,7 +341,7 @@ void Path::Convert(double treshhold)
                         ip++;
                         nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
-                        NR::Point stx = (bx + cx) / 2;
+                        Geom::Point stx = (bx + cx) / 2;
                         if ( k > 0 ) {
                             descr_cmd[ip - 2]->associated = AddPoint(stx, false);
                             if ( descr_cmd[ip - 2]->associated < 0 ) {
@@ -351,7 +354,7 @@ void Path::Convert(double treshhold)
                         }
 
                         {
-                            NR::Point const mx = (cx + dx) / 2;
+                            Geom::Point const mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8);
                         }
                     }
@@ -363,7 +366,7 @@ void Path::Convert(double treshhold)
                         dx = nextX;
                         dx = 2 * dx - cx;
 
-                        NR::Point stx = (bx + cx) / 2;
+                        Geom::Point stx = (bx + cx) / 2;
 
                         descr_cmd[ip - 1]->associated = AddPoint(stx, false);
                         if ( descr_cmd[ip - 1]->associated < 0 ) {
@@ -375,7 +378,7 @@ void Path::Convert(double treshhold)
                         }
 
                         {
-                            NR::Point mx = (cx + dx) / 2;
+                            Geom::Point mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8);
                         }
                     }
@@ -418,15 +421,16 @@ void Path::Convert(NRRectL *area, double treshhold)
         return;
     }
 
-    NR::Point curX;
+    Geom::Point curX;
     int curP = 1;
     int lastMoveTo = 0;
     short last_point_relation = 0;
     short curent_point_relation = 0;
+    bool last_start_elimination = false;
     bool start_elimination = false;
     bool replace = false;
 
-    // le moveto
+    // first point
     {
         int const firstTyp = descr_cmd[0]->getType();
         if ( firstTyp == descr_moveto ) {
@@ -435,17 +439,17 @@ void Path::Convert(NRRectL *area, double treshhold)
             curP = 0;
             curX[0] = curX[1] = 0;
         }
-        
+
         last_point_relation = POINT_RELATION_TO_AREA(curX, area);
         lastMoveTo = AddPoint(curX, true);
     }
     descr_cmd[0]->associated = lastMoveTo;
 
-    // et le reste, 1 par 1
+    // process nodes one by one
     while ( curP < int(descr_cmd.size()) ) {
 
         int const nType = descr_cmd[curP]->getType();
-        NR::Point nextX;
+        Geom::Point nextX;
 
         switch (nType) {
             case descr_forced: {
@@ -460,6 +464,7 @@ void Path::Convert(NRRectL *area, double treshhold)
                 nextX = nData->p;
                 lastMoveTo = AddPoint(nextX, true);
                 descr_cmd[curP]->associated = lastMoveTo;
+
                 last_point_relation = POINT_RELATION_TO_AREA(nextX, area);
                 start_elimination = false;
 
@@ -477,6 +482,9 @@ void Path::Convert(NRRectL *area, double treshhold)
                         descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated;
                     }
                 }
+                if ( descr_cmd[curP]->associated > 0 ) {
+                    pts[descr_cmd[curP]->associated].closed = true;
+                }
                 last_point_relation = 0;
                 curP++;
                 break;
@@ -487,6 +495,7 @@ void Path::Convert(NRRectL *area, double treshhold)
                 nextX = nData->p;
                 curent_point_relation = POINT_RELATION_TO_AREA(nextX, area);
                 replace = false;
+                last_start_elimination = start_elimination;
                 if (curent_point_relation > 0 && curent_point_relation == last_point_relation) {
                     if (!start_elimination) {
                         start_elimination = true;
@@ -503,6 +512,8 @@ void Path::Convert(NRRectL *area, double treshhold)
                 }
 
                 if ( descr_cmd[curP]->associated < 0 ) {
+                    // point is not added as position is equal to the last added
+                    start_elimination = last_start_elimination;
                     if ( curP == 0 ) {
                         descr_cmd[curP]->associated = 0;
                     } else {
@@ -520,6 +531,7 @@ void Path::Convert(NRRectL *area, double treshhold)
 
                 curent_point_relation = POINT_RELATION_TO_AREA(nextX, area);
                 replace = false;
+                last_start_elimination = start_elimination;
                 if (curent_point_relation > 0 && curent_point_relation == last_point_relation &&
                     curent_point_relation == POINT_RELATION_TO_AREA(curX + (nData->start), area) &&
                     curent_point_relation == POINT_RELATION_TO_AREA(nextX + (nData->end), area))
@@ -533,13 +545,15 @@ void Path::Convert(NRRectL *area, double treshhold)
                 } else {
                     start_elimination = false;
                 }
-                
+
                 if (!replace) {
                     RecCubicTo(curX, nData->start, nextX, nData->end, treshhold, 8);
                     descr_cmd[curP]->associated = AddPoint(nextX,false);
                 }
 
                 if ( descr_cmd[curP]->associated < 0 ) {
+                    // point is not added as position is equal to the last added
+                    start_elimination = last_start_elimination;
                     if ( curP == 0 ) {
                         descr_cmd[curP]->associated = 0;
                     } else {
@@ -580,12 +594,12 @@ void Path::Convert(NRRectL *area, double treshhold)
                 PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
                 if ( nbInterm == 1 ) {
-                    NR::Point const midX = nData->p;
+                    Geom::Point const midX = nData->p;
                     RecBezierTo(midX, curX, nextX, treshhold, 8);
                 } else if ( nbInterm > 1 ) {
-                    NR::Point bx = curX;
-                    NR::Point cx = curX;
-                    NR::Point dx = curX;
+                    Geom::Point bx = curX;
+                    Geom::Point cx = curX;
+                    Geom::Point dx = curX;
 
                     dx = nData->p;
                     ip++;
@@ -601,7 +615,7 @@ void Path::Convert(NRRectL *area, double treshhold)
                         ip++;
                         nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
-                        NR::Point stx = (bx + cx) / 2;
+                        Geom::Point stx = (bx + cx) / 2;
                         if ( k > 0 ) {
                             descr_cmd[ip - 2]->associated = AddPoint(stx, false);
                             if ( descr_cmd[ip - 2]->associated < 0 ) {
@@ -614,7 +628,7 @@ void Path::Convert(NRRectL *area, double treshhold)
                         }
 
                         {
-                            NR::Point const mx = (cx + dx) / 2;
+                            Geom::Point const mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8);
                         }
                     }
@@ -626,7 +640,7 @@ void Path::Convert(NRRectL *area, double treshhold)
                         dx = nextX;
                         dx = 2 * dx - cx;
 
-                        NR::Point stx = (bx + cx) / 2;
+                        Geom::Point stx = (bx + cx) / 2;
 
                         descr_cmd[ip - 1]->associated = AddPoint(stx, false);
                         if ( descr_cmd[ip - 1]->associated < 0 ) {
@@ -638,7 +652,7 @@ void Path::Convert(NRRectL *area, double treshhold)
                         }
 
                         {
-                            NR::Point mx = (cx + dx) / 2;
+                            Geom::Point mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8);
                         }
                     }
@@ -681,7 +695,7 @@ void Path::ConvertEvenLines(double treshhold)
         return;
     }
 
-    NR::Point curX;
+    Geom::Point curX;
     int curP = 1;
     int lastMoveTo = 0;
 
@@ -702,7 +716,7 @@ void Path::ConvertEvenLines(double treshhold)
     while ( curP < int(descr_cmd.size()) ) {
 
         int const nType = descr_cmd[curP]->getType();
-        NR::Point nextX;
+        Geom::Point nextX;
 
         switch (nType) {
             case descr_forced: {
@@ -725,12 +739,12 @@ void Path::ConvertEvenLines(double treshhold)
             case descr_close: {
                 nextX = pts[lastMoveTo].p;
                 {
-                    NR::Point nexcur;
+                    Geom::Point nexcur;
                     nexcur = nextX - curX;
-                    const double segL = NR::L2(nexcur);
-                    if ( segL > treshhold ) {
+                    const double segL = Geom::L2(nexcur);
+                    if ( (segL > treshhold) && (treshhold > 0) ) {
                         for (double i = treshhold; i < segL; i += treshhold) {
-                            NR::Point nX;
+                            Geom::Point nX;
                             nX = (segL - i) * curX + i * nextX;
                             nX /= segL;
                             AddPoint(nX);
@@ -746,7 +760,9 @@ void Path::ConvertEvenLines(double treshhold)
                         descr_cmd[curP]->associated = descr_cmd[curP - 1]->associated;
                     }
                 }
-
+                if ( descr_cmd[curP]->associated > 0 ) {
+                    pts[descr_cmd[curP]->associated].closed = true;
+                }
                 curP++;
                 break;
             }
@@ -754,11 +770,11 @@ void Path::ConvertEvenLines(double treshhold)
             case descr_lineto: {
                 PathDescrLineTo* nData = dynamic_cast<PathDescrLineTo *>(descr_cmd[curP]);
                 nextX = nData->p;
-                NR::Point nexcur = nextX - curX;
+                Geom::Point nexcur = nextX - curX;
                 const double segL = L2(nexcur);
-                if ( segL > treshhold ) {
+                if ( (segL > treshhold) && (treshhold > 0)) {
                     for (double i = treshhold; i < segL; i += treshhold) {
-                        NR::Point nX = ((segL - i) * curX + i * nextX) / segL;
+                        Geom::Point nX = ((segL - i) * curX + i * nextX) / segL;
                         AddPoint(nX);
                     }
                 }
@@ -822,12 +838,12 @@ void Path::ConvertEvenLines(double treshhold)
                 PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
                 if ( nbInterm == 1 ) {
-                    NR::Point const midX = nData->p;
+                    Geom::Point const midX = nData->p;
                     RecBezierTo(midX, curX, nextX, treshhold, 8, 4 * treshhold);
                 } else if ( nbInterm > 1 ) {
-                    NR::Point bx = curX;
-                    NR::Point cx = curX;
-                    NR::Point dx = curX;
+                    Geom::Point bx = curX;
+                    Geom::Point cx = curX;
+                    Geom::Point dx = curX;
 
                     dx = nData->p;
                     ip++;
@@ -843,7 +859,7 @@ void Path::ConvertEvenLines(double treshhold)
                         ip++;
                         nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
 
-                        NR::Point stx = (bx+cx) / 2;
+                        Geom::Point stx = (bx+cx) / 2;
                         if ( k > 0 ) {
                             descr_cmd[ip - 2]->associated = AddPoint(stx, false);
                             if ( descr_cmd[ip - 2]->associated < 0 ) {
@@ -856,7 +872,7 @@ void Path::ConvertEvenLines(double treshhold)
                         }
 
                         {
-                            NR::Point const mx = (cx + dx) / 2;
+                            Geom::Point const mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8, 4 * treshhold);
                         }
                     }
@@ -868,7 +884,7 @@ void Path::ConvertEvenLines(double treshhold)
                         dx = nextX;
                         dx = 2 * dx - cx;
 
-                        NR::Point const stx = (bx + cx) / 2;
+                        Geom::Point const stx = (bx + cx) / 2;
 
                         descr_cmd[ip - 1]->associated = AddPoint(stx, false);
                         if ( descr_cmd[ip - 1]->associated < 0 ) {
@@ -880,7 +896,7 @@ void Path::ConvertEvenLines(double treshhold)
                         }
 
                         {
-                            NR::Point const mx = (cx + dx) / 2;
+                            Geom::Point const mx = (cx + dx) / 2;
                             RecBezierTo(cx, stx, mx, treshhold, 8, 4 * treshhold);
                         }
                     }
@@ -900,13 +916,13 @@ void Path::ConvertEvenLines(double treshhold)
                 break;
             }
         }
-        if ( NR::LInfty(curX - nextX) > 0.00001 ) {
+        if ( Geom::LInfty(curX - nextX) > 0.00001 ) {
             curX = nextX;
         }
     }
 }
 
-const NR::Point Path::PrevPoint(int i) const
+const Geom::Point Path::PrevPoint(int i) const
 {
     /* TODO: I suspect this should assert `(unsigned) i < descr_nb'.  We can probably change
        the argument to unsigned.  descr_nb should probably be changed to unsigned too. */
@@ -938,64 +954,64 @@ const NR::Point Path::PrevPoint(int i) const
             return PrevPoint(i - 1);
         default:
             g_assert_not_reached();
-            return NR::Point(0, 0);
+            return Geom::Point(0, 0);
     }
 }
 
 // utilitaries: given a quadratic bezier curve (start point, control point, end point, ie that's a clamped curve),
 // and an abcissis on it, get the point with that abcissis.
 // warning: it's NOT a curvilign abcissis (or whatever you call that in english), so "t" is NOT the length of "start point"->"result point"
-void Path::QuadraticPoint(double t, NR::Point &oPt,
-                          const NR::Point &iS, const NR::Point &iM, const NR::Point &iE)
+void Path::QuadraticPoint(double t, Geom::Point &oPt,
+                          const Geom::Point &iS, const Geom::Point &iM, const Geom::Point &iE)
 {
-    NR::Point const ax = iE - 2 * iM + iS;
-    NR::Point const bx = 2 * iM - 2 * iS;
-    NR::Point const cx = iS;
+    Geom::Point const ax = iE - 2 * iM + iS;
+    Geom::Point const bx = 2 * iM - 2 * iS;
+    Geom::Point const cx = iS;
 
     oPt = t * t * ax + t * bx + cx;
 }
 // idem for cubic bezier patch
-void Path::CubicTangent(double t, NR::Point &oPt, const NR::Point &iS, const NR::Point &isD,
-                        const NR::Point &iE, const NR::Point &ieD)
+void Path::CubicTangent(double t, Geom::Point &oPt, const Geom::Point &iS, const Geom::Point &isD,
+                        const Geom::Point &iE, const Geom::Point &ieD)
 {
-    NR::Point const ax = ieD - 2 * iE + 2 * iS + isD;
-    NR::Point const bx = 3 * iE - ieD - 2 * isD - 3 * iS;
-    NR::Point const cx = isD;
+    Geom::Point const ax = ieD - 2 * iE + 2 * iS + isD;
+    Geom::Point const bx = 3 * iE - ieD - 2 * isD - 3 * iS;
+    Geom::Point const cx = isD;
 
     oPt = 3 * t * t * ax + 2 * t * bx + cx;
 }
 
 // extract interesting info of a SVG arc description
-static void ArcAnglesAndCenter(NR::Point const &iS, NR::Point const &iE,
+static void ArcAnglesAndCenter(Geom::Point const &iS, Geom::Point const &iE,
                               double rx, double ry, double angle,
                               bool large, bool wise,
-                              double &sang, double &eang, NR::Point &dr);
+                              double &sang, double &eang, Geom::Point &dr);
 
-void Path::ArcAngles(const NR::Point &iS, const NR::Point &iE,
+void Path::ArcAngles(const Geom::Point &iS, const Geom::Point &iE,
                      double rx, double ry, double angle, bool large, bool wise, double &sang, double &eang)
 {
-    NR::Point dr;
+    Geom::Point dr;
     ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr);
 }
 
 /* N.B. If iS == iE then sang,eang,dr each become NaN.  Probably a bug. */
-static void ArcAnglesAndCenter(NR::Point const &iS, NR::Point const &iE,
+static void ArcAnglesAndCenter(Geom::Point const &iS, Geom::Point const &iE,
                                double rx, double ry, double angle,
                                bool large, bool wise,
-                               double &sang, double &eang, NR::Point &dr)
+                               double &sang, double &eang, Geom::Point &dr)
 {
-    NR::Point se = iE - iS;
-    NR::Point ca(cos(angle), sin(angle));
-    NR::Point cse(dot(se, ca), cross(se, ca));
+    Geom::Point se = iE - iS;
+    Geom::Point ca(cos(angle), sin(angle));
+    Geom::Point cse(dot(se, ca), cross(se, ca));
     cse[0] /= rx;
     cse[1] /= ry;
     double const lensq = dot(cse,cse);
-    NR::Point csd = ( ( lensq < 4
+    Geom::Point csd = ( ( lensq < 4
                         ? sqrt( 1/lensq - .25 )
                         : 0.0 )
                       * cse.ccw() );
 
-    NR::Point ra = -csd - 0.5 * cse;
+    Geom::Point ra = -csd - 0.5 * cse;
     if ( ra[0] <= -1 ) {
         sang = M_PI;
     } else if ( ra[0] >= 1 ) {
@@ -1067,7 +1083,7 @@ static void ArcAnglesAndCenter(NR::Point const &iS, NR::Point const &iE,
 
 
 
-void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
+void Path::DoArc(Geom::Point const &iS, Geom::Point const &iE,
                  double const rx, double const ry, double const angle,
                  bool const large, bool const wise, double const /*tresh*/)
 {
@@ -1082,23 +1098,24 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
 
     double sang;
     double eang;
-    NR::Point dr;
-    ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr);
+    Geom::Point dr_temp;
+    ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr_temp);
+    Geom::Point dr = dr_temp;
     /* TODO: This isn't as good numerically as treating iS and iE as primary.  E.g. consider
        the case of low curvature (i.e. very large radius). */
 
-    NR::scale const ar(rx, ry);
-    NR::rotate cb( angle + sang );
+    Geom::Scale const ar(rx, ry);
+    Geom::Rotate cb( angle + sang );
     if (wise) {
 
         double const incr = -0.1;
         if ( sang < eang ) {
             sang += 2*M_PI;
         }
-        NR::rotate const omega(incr);
+        Geom::Rotate const omega(incr);
         for (double b = sang + incr ; b > eang ; b += incr) {
             cb = omega * cb;
-            AddPoint( cb.vec * ar + dr );
+            AddPoint( cb.vector() * ar + dr );
         }
 
     } else {
@@ -1107,21 +1124,21 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
         if ( sang > eang ) {
             sang -= 2*M_PI;
         }
-        NR::rotate const omega(incr);
+        Geom::Rotate const omega(incr);
         for (double b = sang + incr ; b < eang ; b += incr) {
             cb = omega * cb;
-            AddPoint( cb.vec * ar + dr);
+            AddPoint( cb.vector() * ar + dr);
         }
     }
 }
 
 
-void Path::RecCubicTo( NR::Point const &iS, NR::Point const &isD,
-                       NR::Point const &iE, NR::Point const &ieD,
+void Path::RecCubicTo( Geom::Point const &iS, Geom::Point const &isD,
+                       Geom::Point const &iE, Geom::Point const &ieD,
                        double tresh, int lev, double maxL)
 {
-    NR::Point se = iE - iS;
-    const double dC = NR::L2(se);
+    Geom::Point se = iE - iS;
+    const double dC = Geom::L2(se);
     if ( dC < 0.01 ) {
 
         const double sC = dot(isD,isD);
@@ -1139,11 +1156,11 @@ void Path::RecCubicTo( NR::Point const &iS, NR::Point const &isD,
                 if ( lev <= 0 ) {
                     return;
                 }
-                NR::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
-                NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+                Geom::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
+                Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
 
-                NR::Point hisD = 0.5 * isD;
-                NR::Point hieD = 0.5 * ieD;
+                Geom::Point hisD = 0.5 * isD;
+                Geom::Point hieD = 0.5 * ieD;
 
                 RecCubicTo(iS, hisD, m, md, tresh, lev - 1, maxL);
                 AddPoint(m);
@@ -1158,11 +1175,11 @@ void Path::RecCubicTo( NR::Point const &iS, NR::Point const &isD,
     }
 
     {
-        NR::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
-        NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+        Geom::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
+        Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
 
-        NR::Point hisD = 0.5 * isD;
-        NR::Point hieD = 0.5 * ieD;
+        Geom::Point hisD = 0.5 * isD;
+        Geom::Point hieD = 0.5 * ieD;
 
         RecCubicTo(iS, hisD, m, md, tresh, lev - 1, maxL);
         AddPoint(m);
@@ -1172,24 +1189,24 @@ void Path::RecCubicTo( NR::Point const &iS, NR::Point const &isD,
 
 
 
-void Path::RecBezierTo(const NR::Point &iP,
-                       const NR::Point &iS,
-                       const NR::Point &iE,
+void Path::RecBezierTo(const Geom::Point &iP,
+                       const Geom::Point &iS,
+                       const Geom::Point &iE,
                        double tresh, int lev, double maxL)
 {
     if ( lev <= 0 ) {
         return;
     }
 
-    NR::Point ps = iS - iP;
-    NR::Point pe = iE - iP;
-    NR::Point se = iE - iS;
+    Geom::Point ps = iS - iP;
+    Geom::Point pe = iE - iP;
+    Geom::Point se = iE - iS;
     double s = fabs(cross(pe, ps));
     if ( s < tresh ) {
         const double l = L2(se);
         if ( maxL > 0 && l > maxL ) {
-            const NR::Point m = 0.25 * (iS + iE + 2 * iP);
-            NR::Point md = 0.5 * (iS + iP);
+            const Geom::Point m = 0.25 * (iS + iE + 2 * iP);
+            Geom::Point md = 0.5 * (iS + iP);
             RecBezierTo(md, iS, m, tresh, lev - 1, maxL);
             AddPoint(m);
             md = 0.5 * (iP + iE);
@@ -1199,8 +1216,8 @@ void Path::RecBezierTo(const NR::Point &iP,
     }
 
     {
-        const NR::Point m = 0.25 * (iS + iE + 2 * iP);
-        NR::Point md = 0.5 * (iS + iP);
+        const Geom::Point m = 0.25 * (iS + iE + 2 * iP);
+        Geom::Point md = 0.5 * (iS + iP);
         RecBezierTo(md, iS, m, tresh, lev - 1, maxL);
         AddPoint(m);
         md = 0.5 * (iP + iE);
@@ -1209,7 +1226,7 @@ void Path::RecBezierTo(const NR::Point &iP,
 }
 
 
-void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
+void Path::DoArc(Geom::Point const &iS, Geom::Point const &iE,
                  double const rx, double const ry, double const angle,
                  bool const large, bool const wise, double const /*tresh*/, int const piece)
 {
@@ -1224,23 +1241,24 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
 
     double sang;
     double eang;
-    NR::Point dr;
-    ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr);
+    Geom::Point dr_temp;
+    ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr_temp);
+    Geom::Point dr = dr_temp;
     /* TODO: This isn't as good numerically as treating iS and iE as primary.  E.g. consider
        the case of low curvature (i.e. very large radius). */
 
-    NR::scale const ar(rx, ry);
-    NR::rotate cb(angle + sang);
+    Geom::Scale const ar(rx, ry);
+    Geom::Rotate cb(angle + sang);
     if (wise) {
 
         double const incr = -0.1;
         if ( sang < eang ) {
             sang += 2*M_PI;
         }
-        NR::rotate const omega(incr);
+        Geom::Rotate const omega(incr);
         for (double b = sang + incr; b > eang; b += incr) {
             cb = omega * cb;
-            AddPoint(cb.vec * ar + dr, piece, (sang - b) / (sang - eang));
+            AddPoint(cb.vector() * ar + dr, piece, (sang - b) / (sang - eang));
         }
 
     } else {
@@ -1249,20 +1267,20 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
         if ( sang > eang ) {
             sang -= 2 * M_PI;
         }
-        NR::rotate const omega(incr);
+        Geom::Rotate const omega(incr);
         for (double b = sang + incr ; b < eang ; b += incr) {
             cb = omega * cb;
-            AddPoint(cb.vec * ar + dr, piece, (b - sang) / (eang - sang));
+            AddPoint(cb.vector() * ar + dr, piece, (b - sang) / (eang - sang));
         }
     }
 }
 
-void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
-                      NR::Point const &iE, NR::Point const &ieD,
+void Path::RecCubicTo(Geom::Point const &iS, Geom::Point const &isD,
+                      Geom::Point const &iE, Geom::Point const &ieD,
                       double tresh, int lev, double st, double et, int piece)
 {
-    const NR::Point se = iE - iS;
-    const double dC = NR::L2(se);
+    const Geom::Point se = iE - iS;
+    const double dC = Geom::L2(se);
     if ( dC < 0.01 ) {
         const double sC = dot(isD, isD);
         const double eC = dot(ieD, ieD);
@@ -1281,12 +1299,12 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
         return;
     }
 
-    NR::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
-    NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+    Geom::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
+    Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
     double mt = (st + et) / 2;
 
-    NR::Point hisD = 0.5 * isD;
-    NR::Point hieD = 0.5 * ieD;
+    Geom::Point hisD = 0.5 * isD;
+    Geom::Point hieD = 0.5 * ieD;
 
     RecCubicTo(iS, hisD, m, md, tresh, lev - 1, st, mt, piece);
     AddPoint(m, piece, mt);
@@ -1296,17 +1314,17 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
 
 
 
-void Path::RecBezierTo(NR::Point const &iP,
-                       NR::Point const &iS,
-                       NR::Point const &iE,
+void Path::RecBezierTo(Geom::Point const &iP,
+                       Geom::Point const &iS,
+                       Geom::Point const &iE,
                        double tresh, int lev, double st, double et, int piece)
 {
     if ( lev <= 0 ) {
         return;
     }
 
-    NR::Point ps = iS - iP;
-    NR::Point pe = iE - iP;
+    Geom::Point ps = iS - iP;
+    Geom::Point pe = iE - iP;
     const double s = fabs(cross(pe, ps));
     if ( s < tresh ) {
         return;
@@ -1314,7 +1332,7 @@ void Path::RecBezierTo(NR::Point const &iP,
 
     {
         const double mt = (st + et) / 2;
-        const NR::Point m = 0.25 * (iS + iE + 2 * iP);
+        const Geom::Point m = 0.25 * (iS + iE + 2 * iP);
         RecBezierTo(0.5 * (iS + iP), iS, m, tresh, lev - 1, st, mt, piece);
         AddPoint(m, piece, mt);
         RecBezierTo(0.5 * (iP + iE), m, iE, tresh, lev - 1, mt, et, piece);
@@ -1323,7 +1341,7 @@ void Path::RecBezierTo(NR::Point const &iP,
 
 
 
-void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
+void Path::DoArc(Geom::Point const &iS, Geom::Point const &iE,
                  double const rx, double const ry, double const angle,
                  bool const large, bool const wise, double const /*tresh*/,
                  int const piece, offset_orig &/*orig*/)
@@ -1341,23 +1359,24 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
 
     double sang;
     double eang;
-    NR::Point dr;
-    ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr);
+    Geom::Point dr_temp;
+    ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr_temp);
+    Geom::Point dr = dr_temp;
     /* TODO: This isn't as good numerically as treating iS and iE as primary.  E.g. consider
        the case of low curvature (i.e. very large radius). */
 
-    NR::scale const ar(rx, ry);
-    NR::rotate cb(angle + sang);
+    Geom::Scale const ar(rx, ry);
+    Geom::Rotate cb(angle + sang);
     if (wise) {
 
         double const incr = -0.1;
         if ( sang < eang ) {
             sang += 2*M_PI;
         }
-        NR::rotate const omega(incr);
+        Geom::Rotate const omega(incr);
         for (double b = sang + incr; b > eang ;b += incr) {
             cb = omega * cb;
-            AddPoint(cb.vec * ar + dr, piece, (sang - b) / (sang - eang));
+            AddPoint(cb.vector() * ar + dr, piece, (sang - b) / (sang - eang));
         }
 
     } else {
@@ -1365,22 +1384,22 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
         if ( sang > eang ) {
             sang -= 2*M_PI;
         }
-        NR::rotate const omega(incr);
+        Geom::Rotate const omega(incr);
         for (double b = sang + incr ; b < eang ; b += incr) {
             cb = omega * cb;
-            AddPoint(cb.vec * ar + dr, piece, (b - sang) / (eang - sang));
+            AddPoint(cb.vector() * ar + dr, piece, (b - sang) / (eang - sang));
         }
     }
 }
 
 
-void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
-                      NR::Point const &iE, NR::Point const &ieD,
+void Path::RecCubicTo(Geom::Point const &iS, Geom::Point const &isD,
+                      Geom::Point const &iE, Geom::Point const &ieD,
                       double tresh, int lev, double st, double et,
                       int piece, offset_orig &orig)
 {
-    const NR::Point se = iE - iS;
-    const double dC = NR::L2(se);
+    const Geom::Point se = iE - iS;
+    const double dC = Geom::L2(se);
     bool doneSub = false;
     if ( dC < 0.01 ) {
         const double sC = dot(isD, isD);
@@ -1404,16 +1423,16 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
     bool stInv = false;
     bool enInv = false;
     {
-        NR::Point os_pos;
-        NR::Point os_tgt;
-        NR::Point oe_pos;
-        NR::Point oe_tgt;
+        Geom::Point os_pos;
+        Geom::Point os_tgt;
+        Geom::Point oe_pos;
+        Geom::Point oe_tgt;
 
         orig.orig->PointAndTangentAt(orig.piece, orig.tSt * (1 - st) + orig.tEn * st, os_pos, os_tgt);
         orig.orig->PointAndTangentAt(orig.piece, orig.tSt * (1 - et) + orig.tEn * et, oe_pos, oe_tgt);
 
 
-        NR::Point n_tgt = isD;
+        Geom::Point n_tgt = isD;
         double si = dot(n_tgt, os_tgt);
         if ( si < 0 ) {
             stInv = true;
@@ -1442,11 +1461,11 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
     }
 
     {
-        const NR::Point m = 0.5 * (iS+iE) + 0.125 * (isD - ieD);
-        const NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+        const Geom::Point m = 0.5 * (iS+iE) + 0.125 * (isD - ieD);
+        const Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
         const double mt = (st + et) / 2;
-        const NR::Point hisD = 0.5 * isD;
-        const NR::Point hieD = 0.5 * ieD;
+        const Geom::Point hisD = 0.5 * isD;
+        const Geom::Point hieD = 0.5 * ieD;
 
         RecCubicTo(iS, hisD, m, md, tresh, lev - 1, st, mt, piece, orig);
         AddPoint(m, piece, mt);
@@ -1456,7 +1475,7 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
 
 
 
-void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const &iE,
+void Path::RecBezierTo(Geom::Point const &iP, Geom::Point const &iS,Geom::Point const &iE,
                        double tresh, int lev, double st, double et,
                        int piece, offset_orig& orig)
 {
@@ -1465,8 +1484,8 @@ void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const
         return;
     }
 
-    const NR::Point ps = iS - iP;
-    const NR::Point pe = iE - iP;
+    const Geom::Point ps = iS - iP;
+    const Geom::Point pe = iE - iP;
     const double s = fabs(cross(pe, ps));
     if ( s < tresh ) {
         doneSub = true ;
@@ -1476,12 +1495,12 @@ void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const
     bool stInv = false;
     bool enInv = false;
     {
-        NR::Point os_pos;
-        NR::Point os_tgt;
-        NR::Point oe_pos;
-        NR::Point oe_tgt;
-        NR::Point n_tgt;
-        NR::Point n_pos;
+        Geom::Point os_pos;
+        Geom::Point os_tgt;
+        Geom::Point oe_pos;
+        Geom::Point oe_tgt;
+        Geom::Point n_tgt;
+        Geom::Point n_pos;
 
         double n_len;
         double n_rad;
@@ -1517,8 +1536,8 @@ void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const
 
     {
         double mt = (st + et) / 2;
-        NR::Point m = 0.25 * (iS + iE + 2 * iP);
-        NR::Point md = 0.5 * (iS + iP);
+        Geom::Point m = 0.25 * (iS + iE + 2 * iP);
+        Geom::Point md = 0.5 * (iS + iP);
         RecBezierTo(md, iS, m, tresh, lev - 1, st, mt, piece, orig);
         AddPoint(m, piece, mt);
         md = 0.5 * (iP + iE);
@@ -1595,7 +1614,7 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool
 
                     } else {
 
-                        if ( NR::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
+                        if ( Geom::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
                             lEdge = dest->AddEdge(first + curP, first + pathEnd);
                             if ( lEdge >= 0 ) {
                                 dest->ebData[lEdge].pathID = pathID;
@@ -1609,7 +1628,7 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool
                                 }
                             }
                             pathEnd = curP;
-                            if ( NR::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
+                            if ( Geom::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
                                 closed = true;
                             } else {
                                 closed = false;
@@ -1667,10 +1686,10 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool
                         closed = false;
                         lEdge = -1;
                     } else {
-                        if ( NR::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
+                        if ( Geom::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
                             lEdge = dest->AddEdge(first+curP, first+pathEnd);
                             pathEnd = curP;
-                            if ( NR::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
+                            if ( Geom::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
                                 closed = true;
                             } else {
                                 closed = false;
@@ -1730,7 +1749,7 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool
                         closed = false;
                         lEdge = -1;
                     } else {
-                        if ( NR::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
+                        if ( Geom::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
                             lEdge = dest->AddEdge(first + pathEnd, first + curP);
                             dest->ebData[lEdge].pathID = pathID;
                             dest->ebData[lEdge].pieceID = pts[sbp].piece;
@@ -1742,7 +1761,7 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool
                                 dest->ebData[lEdge].tEn = pts[sbp].t;
                             }
                             pathEnd = curP;
-                            if ( NR::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
+                            if ( Geom::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
                                 closed = true;
                             } else {
                                 closed = false;
@@ -1799,10 +1818,10 @@ void Path::Fill(Shape* dest, int pathID, bool justAdd, bool closeIfNeeded, bool
                         closed = false;
                         lEdge = -1;
                     } else {
-                        if ( NR::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
+                        if ( Geom::LInfty(pts[sbp].p - pts[prp].p) >= 0.00001 ) {
                             lEdge = dest->AddEdge(first+pathEnd, first+curP);
                             pathEnd = curP;
-                            if ( NR::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
+                            if ( Geom::LInfty(pts[sbp].p - pts[lm].p) < 0.00001 ) {
                                 closed = true;
                             } else {
                                 closed = false;