Code

GSoC C++-ificiation merge and cleanup.
[inkscape.git] / src / livarot / ShapeSweep.cpp
index cc5f3f93feb14275fe9f4db7c6bbf14f3983eba6..00a0dd9a03efa9e680f1f2c2651560d3991e1f7a 100644 (file)
@@ -6,6 +6,9 @@
  *
  */
 
+#include <cstdio>
+#include <cstdlib>
+#include <cstring>
 #include <glib/gmem.h>
 #include "Shape.h"
 #include "livarot/sweep-event-queue.h"
@@ -171,7 +174,8 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert)
     }
     
     if ( directed != fill_justDont && directedEulerian(a) == false ) {
-       return shape_input_err;
+                       g_warning ("Shape error in ConvertToShape: directedEulerian(a) == false\n");
+                               return shape_input_err;
     }
   
     a->ResetSweep();
@@ -206,7 +210,7 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert)
     int curAPt = 0;
 
     while (curAPt < a->numberOfPoints() || sEvts->size() > 0) {
-       NR::Point ptX;
+       Geom::Point ptX;
       double ptL, ptR;
       SweepTree *intersL = NULL;
       SweepTree *intersR = NULL;
@@ -246,7 +250,7 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert)
            continue;
        }
 
-      NR::Point rPtX;
+      Geom::Point rPtX;
       rPtX[0]= Round (ptX[0]);
       rPtX[1]= Round (ptX[1]);
       int lastPointNo = -1;
@@ -912,7 +916,7 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID)
                }
                printf("\n");*/
 
-    NR::Point ptX;
+    Geom::Point ptX;
       double ptL, ptR;
       SweepTree *intersL = NULL;
       SweepTree *intersR = NULL;
@@ -1047,7 +1051,7 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID)
            continue;
        }
 
-      NR::Point rPtX;
+      Geom::Point rPtX;
       rPtX[0]= Round (ptX[0]);
       rPtX[1]= Round (ptX[1]);
       int lastPointNo = -1;
@@ -1662,7 +1666,7 @@ void Shape::TesteIntersection(SweepTree *t, Side s, bool onlyDiff)
     SweepTree *a = (s == LEFT) ? tt : t;
     SweepTree *b = (s == LEFT) ? t : tt;
 
-    NR::Point atx;
+    Geom::Point atx;
     double atl;
     double atr;
     if (TesteIntersection(a, b, atx, atl, atr, onlyDiff)) {
@@ -1672,11 +1676,11 @@ void Shape::TesteIntersection(SweepTree *t, Side s, bool onlyDiff)
 
 // a crucial piece of code: computing intersections between segments
 bool
-Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, NR::Point &atx, double &atL, double &atR, bool onlyDiff)
+Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, Geom::Point &atx, double &atL, double &atR, bool onlyDiff)
 {
   int lSt = iL->src->getEdge(iL->bord).st, lEn = iL->src->getEdge(iL->bord).en;
   int rSt = iR->src->getEdge(iR->bord).st, rEn = iR->src->getEdge(iR->bord).en;
-  NR::Point ldir, rdir;
+  Geom::Point ldir, rdir;
   ldir = iL->src->eData[iL->bord].rdx;
   rdir = iR->src->eData[iR->bord].rdx;
   // first, a round of checks to quickly dismiss edge which obviously dont intersect,
@@ -1770,7 +1774,7 @@ Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, NR::Point &atx, double
   // Boissonat anr Preparata said in one paper that double precision floats were sufficient for get single precision
   // coordinates for the intersection, if the endpoints are single precision. i hope they're right...
   {
-    NR::Point sDiff, eDiff;
+    Geom::Point sDiff, eDiff;
     double slDot, elDot;
     double srDot, erDot;
     sDiff = iL->src->pData[lSt].rx - iR->src->pData[rSt].rx;
@@ -1997,7 +2001,7 @@ Shape::PushIncidence (Shape * a, int cb, int pt, double theta)
 int
 Shape::CreateIncidence (Shape * a, int no, int nPt)
 {
-  NR::Point adir, diff;
+  Geom::Point adir, diff;
   adir = a->eData[no].rdx;
   diff = getPoint(nPt).x - a->pData[a->getEdge(no).st].rx;
   double t = dot (diff, adir);
@@ -2023,13 +2027,13 @@ Shape::Winding (int nPt) const
 }
 
 int
-Shape::Winding (const NR::Point px) const 
+Shape::Winding (const Geom::Point px) const 
 {
   int lr = 0, ll = 0, rr = 0;
 
   for (int i = 0; i < numberOfEdges(); i++)
     {
-      NR::Point adir, diff, ast, aen;
+      Geom::Point adir, diff, ast, aen;
       adir = eData[i].rdx;
 
       ast = pData[getEdge(i).st].rx;
@@ -2348,7 +2352,7 @@ Shape::AssembleAretes (FillRule directed)
   }
 }
 void
-Shape::GetWindings (Shape * a, Shape * b, BooleanOp mod, bool brutal)
+Shape::GetWindings (Shape * /*a*/, Shape * /*b*/, BooleanOp /*mod*/, bool brutal)
 {
   // preparation du parcours
   for (int i = 0; i < numberOfEdges(); i++)
@@ -2505,8 +2509,8 @@ Shape::GetWindings (Shape * a, Shape * b, BooleanOp mod, bool brutal)
 
 bool
 Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb,
-                          NR::Point &atx, double &atL, double &atR,
-                         bool onlyDiff)
+                          Geom::Point &atx, double &atL, double &atR,
+                         bool /*onlyDiff*/)
 {
   int lSt = ils->getEdge(ilb).st, lEn = ils->getEdge(ilb).en;
   int rSt = irs->getEdge(irb).st, rEn = irs->getEdge(irb).en;
@@ -2519,7 +2523,7 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb,
       return false;
     }
 
-  NR::Point ldir, rdir;
+  Geom::Point ldir, rdir;
   ldir = ils->eData[ilb].rdx;
   rdir = irs->eData[irb].rdx;
 
@@ -2557,7 +2561,7 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb,
 
   // pre-test
   {
-    NR::Point sDiff, eDiff;
+    Geom::Point sDiff, eDiff;
     double slDot, elDot;
     double srDot, erDot;
     sDiff = ils->pData[lSt].rx - irs->pData[rSt].rx;
@@ -2597,11 +2601,11 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb,
   }
 
   // a mettre en double precision pour des resultats exacts
-  NR::Point usvs;
+  Geom::Point usvs;
   usvs = irs->pData[rSt].rx - ils->pData[lSt].rx;
 
   // pas sur de l'ordre des coefs de m
-  NR::Matrix m(ldir[0], ldir[1],
+  Geom::Matrix m(ldir[0], ldir[1],
               rdir[0], rdir[1],
               0, 0);
   double det = m.det();
@@ -2610,7 +2614,7 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb,
 
   if (tdet > -0.0001 && tdet < 0.0001)
     {                          // ces couillons de vecteurs sont colineaires
-      NR::Point sDiff, eDiff;
+      Geom::Point sDiff, eDiff;
       double sDot, eDot;
       sDiff = ils->pData[lSt].rx - irs->pData[rSt].rx;
       eDiff = ils->pData[lEn].rx - irs->pData[rSt].rx;
@@ -2650,13 +2654,13 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb,
 }
 
 bool
-Shape::TesteAdjacency (Shape * a, int no, const NR::Point atx, int nPt,
+Shape::TesteAdjacency (Shape * a, int no, const Geom::Point atx, int nPt,
                       bool push)
 {
   if (nPt == a->swsData[no].stPt || nPt == a->swsData[no].enPt)
     return false;
 
-  NR::Point adir, diff, ast, aen, diff1, diff2, diff3, diff4;
+  Geom::Point adir, diff, ast, aen, diff1, diff2, diff3, diff4;
 
   ast = a->pData[a->getEdge(no).st].rx;
   aen = a->pData[a->getEdge(no).en].rx;
@@ -2716,8 +2720,8 @@ Shape::TesteAdjacency (Shape * a, int no, const NR::Point atx, int nPt,
 }
 
 void
-Shape::CheckAdjacencies (int lastPointNo, int lastChgtPt, Shape * shapeHead,
-                        int edgeHead)
+Shape::CheckAdjacencies (int lastPointNo, int lastChgtPt, Shape * /*shapeHead*/,
+                        int /*edgeHead*/)
 {
   for (unsigned int cCh = 0; cCh < chgts.size(); cCh++)
     {
@@ -3022,7 +3026,7 @@ Shape::Validate (void)
     {
       for (int j = i + 1; j < numberOfEdges(); j++)
        {
-        NR::Point atx;
+        Geom::Point atx;
         double   atL, atR;
          if (TesteIntersection (this, this, i, j, atx, atL, atR, false))
            {
@@ -3107,7 +3111,7 @@ Shape::CheckEdges (int lastPointNo, int lastChgtPt, Shape * a, Shape * b,
 }
 
 void
-Shape::Avance (int lastPointNo, int lastChgtPt, Shape * lS, int lB, Shape * a,
+Shape::Avance (int lastPointNo, int lastChgtPt, Shape * lS, int lB, Shape * /*a*/,
               Shape * b, BooleanOp mod)
 {
   double dd = HalfRound (1);
@@ -3285,12 +3289,12 @@ Shape::DoEdgeTo (Shape * iS, int iB, int iTo, bool direct, bool sens)
       else
        {
          double bdl = iS->eData[iB].ilength;
-    NR::Point bpx = iS->pData[iS->getEdge(iB).st].rx;
-         NR::Point bdx = iS->eData[iB].rdx;
-         NR::Point psx = getPoint(getEdge(ne).st).x;
-         NR::Point pex = getPoint(getEdge(ne).en).x;
-        NR::Point psbx=psx-bpx;
-        NR::Point pebx=pex-bpx;
+    Geom::Point bpx = iS->pData[iS->getEdge(iB).st].rx;
+         Geom::Point bdx = iS->eData[iB].rdx;
+         Geom::Point psx = getPoint(getEdge(ne).st).x;
+         Geom::Point pex = getPoint(getEdge(ne).en).x;
+        Geom::Point psbx=psx-bpx;
+        Geom::Point pebx=pex-bpx;
          double pst = dot(psbx,bdx) * bdl;
          double pet = dot(pebx,bdx) * bdl;
          pst = iS->ebData[iB].tSt * (1 - pst) + iS->ebData[iB].tEn * pst;