From 4e088d33c04329fe57ef987d577f5aa57f83b644 Mon Sep 17 00:00:00 2001 From: Alvin Penner Date: Tue, 16 Jul 2013 15:46:56 -0400 Subject: Shape calculations. re-introduce grid of a smaller size. (http://article.gmane.org/gmane.comp.graphics.inkscape.devel/40786) (bzr r12420) --- src/livarot/Shape.cpp | 8 ++++---- src/livarot/Shape.h | 12 ++++++------ src/livarot/ShapeMisc.cpp | 12 ++++++------ src/livarot/ShapeSweep.cpp | 8 ++++---- 4 files changed, 20 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index 130b1b03a..c29444a33 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -334,8 +334,8 @@ Shape::AddPoint (const Geom::Point x) pData[n].nextLinkedPoint = -1; pData[n].askForWindingS = NULL; pData[n].askForWindingB = -1; - pData[n].rx[0] = /*Round*/ (p.x[0]); - pData[n].rx[1] = /*Round*/ (p.x[1]); + pData[n].rx[0] = Round(p.x[0]); + pData[n].rx[1] = Round(p.x[1]); } if (_has_voronoi_data) { @@ -2116,8 +2116,8 @@ void Shape::initialisePointData() pData[i].pending = 0; pData[i].edgeOnLeft = -1; pData[i].nextLinkedPoint = -1; - pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); - pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); + pData[i].rx[0] = Round(getPoint(i).x[0]); + pData[i].rx[1] = Round(getPoint(i).x[1]); } _point_data_initialised = true; diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h index b999b9dca..98fc2d7bf 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -266,20 +266,20 @@ public: // be careful when using this function // the coordinate rounding function -// inline static double Round(double x) -// { -// return ldexp(rint(ldexp(x, 5)), -5); -// } + inline static double Round(double x) + { + return ldexp(rint(ldexp(x, 9)), -9); + } // 2 miscannellous variations on it, to scale to and back the rounding grid inline static double HalfRound(double x) { - return ldexp(x, -5); + return ldexp(x, -9); } inline static double IHalfRound(double x) { - return ldexp(x, 5); + return ldexp(x, 9); } // boolean operations on polygons (requests intersection-free poylygons) diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index 5bb8a25ef..6fd40790f 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -49,8 +49,8 @@ Shape::ConvertToForme (Path * dest) for (int i = 0; i < numberOfPoints(); i++) { - pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); - pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); + pData[i].rx[0] = Round (getPoint(i).x[0]); + pData[i].rx[1] = Round (getPoint(i).x[1]); } for (int i = 0; i < numberOfEdges(); i++) { @@ -199,8 +199,8 @@ Shape::ConvertToForme (Path * dest, int nbP, Path * *orig, bool splitWhenForced) for (int i = 0; i < numberOfPoints(); i++) { - pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); - pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); + pData[i].rx[0] = Round (getPoint(i).x[0]); + pData[i].rx[1] = Round (getPoint(i).x[1]); } for (int i = 0; i < numberOfEdges(); i++) { @@ -352,8 +352,8 @@ Shape::ConvertToFormeNested (Path * dest, int nbP, Path * *orig, int wildPath,in for (int i = 0; i < numberOfPoints(); i++) { - pData[i].rx[0] = /*Round*/ (getPoint(i).x[0]); - pData[i].rx[1] = /*Round*/ (getPoint(i).x[1]); + pData[i].rx[0] = Round (getPoint(i).x[0]); + pData[i].rx[1] = Round (getPoint(i).x[1]); } for (int i = 0; i < numberOfEdges(); i++) { diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index ffe5a9d73..c2fd83e31 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -250,8 +250,8 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert) } Geom::Point rPtX; - rPtX[0]= /*Round*/ (ptX[0]); - rPtX[1]= /*Round*/ (ptX[1]); + rPtX[0]= Round (ptX[0]); + rPtX[1]= Round (ptX[1]); int lastPointNo = -1; lastPointNo = AddPoint (rPtX); pData[lastPointNo].rx = rPtX; @@ -1051,8 +1051,8 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID) } Geom::Point rPtX; - rPtX[0]= /*Round*/ (ptX[0]); - rPtX[1]= /*Round*/ (ptX[1]); + rPtX[0]= Round (ptX[0]); + rPtX[1]= Round (ptX[1]); int lastPointNo = -1; lastPointNo = AddPoint (rPtX); pData[lastPointNo].rx = rPtX; -- cgit v1.2.3