Code

Remove INKSCAPE_VERSION from menus-skeleton.h
[inkscape.git] / src / livarot / ShapeMisc.cpp
index 12b8d84910226ea145069b48e6396e097e5629a6..d6ca8c5333861da6117494c56aa34d62a8322b07 100644 (file)
@@ -7,10 +7,14 @@
  */
 
 #include "livarot/Shape.h"
+#include <libnr/nr-matrix-fns.h>
 #include <libnr/nr-point-fns.h>
 #include "livarot/Path.h"
 #include "livarot/path-description.h"
 #include <glib.h>
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 
 /*
  * polygon offset and polyline to path reassembling (when using back data)
@@ -524,7 +528,7 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in
 
 
 int
-Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, bool do_profile, NR::Point c, NR::Point vector, double radius, NR::Matrix *i2doc)
+Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter, bool do_profile, Geom::Point c, Geom::Point vector, double radius, Geom::Matrix *i2doc)
 {
   Reset (0, 0);
   MakeBackData(a->_has_back_data);
@@ -580,7 +584,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
       enB = a->CyclePrevAt (a->getEdge(i).en, i);
     }
     
-    NR::Point stD, seD, enD;
+    Geom::Point stD, seD, enD;
     double stL, seL, enL;
     stD = a->getEdge(stB).dx;
     seD = a->getEdge(i).dx;
@@ -593,21 +597,21 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
     MiscNormalize (enD);
     MiscNormalize (seD);
     
-    NR::Point ptP;
+    Geom::Point ptP;
     int stNo, enNo;
     ptP = a->getPoint(a->getEdge(i).st).x;
 
-       NR::Point to_center = ptP * (*i2doc) - c;
-       NR::Point to_center_normalized = (1/NR::L2(to_center)) * to_center;
+       Geom::Point to_center = ptP * (*i2doc) - c;
+       Geom::Point to_center_normalized = (1/Geom::L2(to_center)) * to_center;
 
                double this_power;
                if (do_profile && i2doc) {
                        double alpha = 1;
                        double x;
                if (mode == tweak_mode_repel) {
-                               x = (NR::L2(to_center)/radius);
+                               x = (Geom::L2(to_center)/radius);
                        } else {
-                               x = (NR::L2(ptP * (*i2doc) - c)/radius);
+                               x = (Geom::L2(ptP * (*i2doc) - c)/radius);
                        }
                        if (x > 1) {
                                this_power = 0;
@@ -631,11 +635,11 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
                if (this_power != 0)
                        done_something = true;
 
-               double scaler = 1 / (*i2doc).expansion();
+               double scaler = 1 / (*i2doc).descrim();
 
-               NR::Point this_vec(0,0);
+               Geom::Point this_vec(0,0);
     if (mode == tweak_mode_push) {
-                       NR::Matrix tovec (*i2doc);
+                       Geom::Matrix tovec (*i2doc);
                        tovec[4] = tovec[5] = 0;
                        tovec = tovec.inverse();
                        this_vec = this_power * (vector * tovec) ;
@@ -643,7 +647,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
                        this_vec = this_power * scaler * to_center_normalized;
                } else if (mode == tweak_mode_roughen) {
                double angle = g_random_double_range(0, 2*M_PI);
-               this_vec = g_random_double_range(0, 1) * this_power * scaler * NR::Point(sin(angle), cos(angle));
+               this_vec = g_random_double_range(0, 1) * this_power * scaler * Geom::Point(sin(angle), cos(angle));
                }
 
     int   usePathID=-1;
@@ -714,7 +718,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
 // you gotta be very careful with the join, as anything but the right one will fuck everything up
 // see PathStroke.cpp for the "right" joins
 int
-Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_profile, double cx, double cy, double radius, NR::Matrix *i2doc)
+Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_profile, double cx, double cy, double radius, Geom::Matrix *i2doc)
 {
   Reset (0, 0);
   MakeBackData(a->_has_back_data);
@@ -774,7 +778,7 @@ Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_p
       enB = a->CycleNextAt (a->getEdge(i).en, i);
     }
     
-    NR::Point stD, seD, enD;
+    Geom::Point stD, seD, enD;
     double stL, seL, enL;
     stD = a->getEdge(stB).dx;
     seD = a->getEdge(i).dx;
@@ -787,14 +791,14 @@ Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_p
     MiscNormalize (enD);
     MiscNormalize (seD);
     
-    NR::Point ptP;
+    Geom::Point ptP;
     int stNo, enNo;
     ptP = a->getPoint(a->getEdge(i).st).x;
 
                double this_dec;
                if (do_profile && i2doc) {
                        double alpha = 1;
-                       double x = (NR::L2(ptP * (*i2doc) - NR::Point(cx,cy))/radius);
+                       double x = (Geom::L2(ptP * (*i2doc) - Geom::Point(cx,cy))/radius);
                        if (x > 1) {
                                this_dec = 0;
                        } else if (x <= 0) {
@@ -978,12 +982,12 @@ Shape::AddContour (Path * dest, int nbP, Path * *orig, int startBord, int curBor
 }
 
 int
-Shape::ReFormeLineTo (int bord, int curBord, Path * dest, Path * orig)
+Shape::ReFormeLineTo (int bord, int /*curBord*/, Path * dest, Path * /*orig*/)
 {
   int nPiece = ebData[bord].pieceID;
   int nPath = ebData[bord].pathID;
   double /*ts=ebData[bord].tSt, */ te = ebData[bord].tEn;
-  NR::Point nx = getPoint(getEdge(bord).en).x;
+  Geom::Point nx = getPoint(getEdge(bord).en).x;
   bord = swdData[bord].suivParc;
   while (bord >= 0)
   {
@@ -1012,13 +1016,13 @@ Shape::ReFormeLineTo (int bord, int curBord, Path * dest, Path * orig)
 }
 
 int
-Shape::ReFormeArcTo (int bord, int curBord, Path * dest, Path * from)
+Shape::ReFormeArcTo (int bord, int /*curBord*/, Path * dest, Path * from)
 {
   int nPiece = ebData[bord].pieceID;
   int nPath = ebData[bord].pathID;
   double ts = ebData[bord].tSt, te = ebData[bord].tEn;
   //      double  px=pts[getEdge(bord).st].x,py=pts[getEdge(bord).st].y;
-  NR::Point nx = getPoint(getEdge(bord).en).x;
+  Geom::Point nx = getPoint(getEdge(bord).en).x;
   bord = swdData[bord].suivParc;
   while (bord >= 0)
   {
@@ -1090,12 +1094,12 @@ Shape::ReFormeArcTo (int bord, int curBord, Path * dest, Path * from)
 }
 
 int
-Shape::ReFormeCubicTo (int bord, int curBord, Path * dest, Path * from)
+Shape::ReFormeCubicTo (int bord, int /*curBord*/, Path * dest, Path * from)
 {
   int nPiece = ebData[bord].pieceID;
   int nPath = ebData[bord].pathID;
   double ts = ebData[bord].tSt, te = ebData[bord].tEn;
-  NR::Point nx = getPoint(getEdge(bord).en).x;
+  Geom::Point nx = getPoint(getEdge(bord).en).x;
   bord = swdData[bord].suivParc;
   while (bord >= 0)
   {
@@ -1119,9 +1123,9 @@ Shape::ReFormeCubicTo (int bord, int curBord, Path * dest, Path * from)
     }
     bord = swdData[bord].suivParc;
   }
-  NR::Point prevx = from->PrevPoint (nPiece - 1);
+  Geom::Point prevx = from->PrevPoint (nPiece - 1);
   
-  NR::Point sDx, eDx;
+  Geom::Point sDx, eDx;
   {
     PathDescrCubicTo *nData = dynamic_cast<PathDescrCubicTo *>(from->descr_cmd[nPiece]);
     Path::CubicTangent (ts, sDx, prevx,nData->start,nData->p,nData->end);
@@ -1136,14 +1140,14 @@ Shape::ReFormeCubicTo (int bord, int curBord, Path * dest, Path * from)
 }
 
 int
-Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
+Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from)
 {
   int nPiece = ebData[bord].pieceID;
   int nPath = ebData[bord].pathID;
   double ts = ebData[bord].tSt, te = ebData[bord].tEn;
   int ps = nPiece, pe = nPiece;
-  NR::Point px = getPoint(getEdge(bord).st).x;
-  NR::Point nx = getPoint(getEdge(bord).en).x;
+  Geom::Point px = getPoint(getEdge(bord).st).x;
+  Geom::Point nx = getPoint(getEdge(bord).en).x;
   int inBezier = -1, nbInterm = -1;
   int typ;
   typ = from->descr_cmd[nPiece]->getType();
@@ -1231,7 +1235,7 @@ Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
       }
       else
       {
-        NR::Point tx;
+        Geom::Point tx;
         {
           PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe]);
           PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe+1]);
@@ -1252,7 +1256,7 @@ Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
     {
       if (te > 0.9999)
       {
-        NR::Point tx;
+        Geom::Point tx;
         {
           PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
           PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+2]);
@@ -1270,7 +1274,7 @@ Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
       }
       else
       {
-        NR::Point tx;
+        Geom::Point tx;
         {
           PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
           PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+2]);
@@ -1311,7 +1315,7 @@ Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
       }
       else
       {
-        NR::Point tx;
+        Geom::Point tx;
         {
           PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe+1]);
           PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe+2]);
@@ -1332,7 +1336,7 @@ Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
     {
       if (te < 0.0001)
       {
-        NR::Point tx;
+        Geom::Point tx;
         {
           PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps]);
           PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
@@ -1350,7 +1354,7 @@ Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
       }
       else
       {
-        NR::Point tx;
+        Geom::Point tx;
         {
           PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps]);
           PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
@@ -1379,15 +1383,15 @@ Shape::ReFormeBezierTo (int bord, int curBord, Path * dest, Path * from)
 }
 
 void
-Shape::ReFormeBezierChunk (NR::Point px, NR::Point nx,
+Shape::ReFormeBezierChunk (Geom::Point px, Geom::Point nx,
                            Path * dest, int inBezier, int nbInterm,
                            Path * from, int p, double ts, double te)
 {
   PathDescrBezierTo* nBData = dynamic_cast<PathDescrBezierTo*>(from->descr_cmd[inBezier]);
-  NR::Point bstx = from->PrevPoint (inBezier - 1);
-  NR::Point benx = nBData->p;
+  Geom::Point bstx = from->PrevPoint (inBezier - 1);
+  Geom::Point benx = nBData->p;
   
-  NR::Point mx;
+  Geom::Point mx;
   if (p == inBezier)
   {
     // premier bout
@@ -1426,7 +1430,7 @@ Shape::ReFormeBezierChunk (NR::Point px, NR::Point nx,
     nData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[p+2]);
     benx = (nData->p + mx) / 2;
   }
-  NR::Point cx;
+  Geom::Point cx;
   {
     Path::QuadraticPoint ((ts + te) / 2, cx, bstx, mx, benx);
   }