diff options
| author | Krzysztof Kosi??ski <tweenk.pl@gmail.com> | 2015-04-28 23:02:19 +0000 |
|---|---|---|
| committer | Krzysztof KosiĆski <tweenk.pl@gmail.com> | 2015-04-28 23:02:19 +0000 |
| commit | cfa7054c950050095e596edd18fedad53e7ed636 (patch) | |
| tree | 2142ac03239c40a4af6b367754ddf3421e337577 | |
| parent | 2Geom sync - initial commit (diff) | |
| download | inkscape-cfa7054c950050095e596edd18fedad53e7ed636.tar.gz inkscape-cfa7054c950050095e596edd18fedad53e7ed636.zip | |
Fix calls to Geom::cross() - sign change.
(bzr r14059.2.2)
| -rw-r--r-- | src/2geom/path.cpp | 10 | ||||
| -rw-r--r-- | src/2geom/path.h | 4 | ||||
| -rw-r--r-- | src/2geom/pathvector.cpp | 9 | ||||
| -rw-r--r-- | src/2geom/pathvector.h | 2 | ||||
| -rw-r--r-- | src/helper/geom-pathstroke.cpp | 12 | ||||
| -rw-r--r-- | src/livarot/PathConversion.cpp | 6 | ||||
| -rw-r--r-- | src/livarot/PathCutting.cpp | 4 | ||||
| -rw-r--r-- | src/livarot/PathOutline.cpp | 8 | ||||
| -rw-r--r-- | src/livarot/PathSimplify.cpp | 2 | ||||
| -rw-r--r-- | src/livarot/PathStroke.cpp | 16 | ||||
| -rw-r--r-- | src/livarot/Shape.cpp | 4 | ||||
| -rw-r--r-- | src/livarot/ShapeSweep.cpp | 38 | ||||
| -rw-r--r-- | src/livarot/sweep-tree.cpp | 10 | ||||
| -rw-r--r-- | src/live_effects/lpe-fillet-chamfer.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-knot.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-powerstroke.cpp | 4 | ||||
| -rw-r--r-- | src/live_effects/lpe-sketch.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/parameter/filletchamferpointarray.cpp | 2 | ||||
| -rw-r--r-- | src/sp-offset.cpp | 2 | ||||
| -rw-r--r-- | src/splivarot.cpp | 40 |
20 files changed, 111 insertions, 68 deletions
diff --git a/src/2geom/path.cpp b/src/2geom/path.cpp index cf8b15d60..8eb5c7fcb 100644 --- a/src/2geom/path.cpp +++ b/src/2geom/path.cpp @@ -760,6 +760,16 @@ void Path::replace(iterator first, iterator last, Path const &path) replace(first, last, path.begin(), path.end()); } +void Path::snapEnds(Coord precision) +{ + if (!_closed) return; + if (_curves->size() > 1 && are_near(_closing_seg->length(precision), 0, precision)) { + _unshare(); + _closing_seg->setInitial(_closing_seg->finalPoint()); + (_curves->end() - 1)->setFinal(_closing_seg->finalPoint()); + } +} + // replace curves between first and last with contents of source, // void Path::do_update(Sequence::iterator first, Sequence::iterator last, Sequence &source) diff --git a/src/2geom/path.h b/src/2geom/path.h index 1940aa580..8d585cd57 100644 --- a/src/2geom/path.h +++ b/src/2geom/path.h @@ -749,6 +749,10 @@ public: do_append(new CurveType(finalPoint(), a, b, c, d, e, f, g, h, i)); } + /** @brief Reduce the closing segment to a point if it's shorter than precision. + * Do this by moving the final point. */ + void snapEnds(Coord precision = EPSILON); + /// Append a stitching segment ending at the specified point. void stitchTo(Point const &p); diff --git a/src/2geom/pathvector.cpp b/src/2geom/pathvector.cpp index 36364de9b..d2dc468c6 100644 --- a/src/2geom/pathvector.cpp +++ b/src/2geom/pathvector.cpp @@ -126,13 +126,20 @@ OptRect PathVector::boundsExact() const return bound; } +void PathVector::snapEnds(Coord precision) +{ + for (std::size_t i = 0; i < size(); ++i) { + (*this)[i].snapEnds(precision); + } +} + std::vector<PVIntersection> PathVector::intersect(PathVector const &other, Coord precision) const { typedef PathVectorPosition PVPos; std::vector<PVIntersection> result; for (std::size_t i = 0; i < size(); ++i) { for (std::size_t j = 0; j < other.size(); ++j) { - std::vector<PathIntersection> xs = (*this)[i].intersect(other[j]); + std::vector<PathIntersection> xs = (*this)[i].intersect(other[j], precision); for (std::size_t k = 0; k < xs.size(); ++k) { PVIntersection pvx(PVPos(i, xs[k].first), PVPos(j, xs[k].second), xs[k].point()); result.push_back(pvx); diff --git a/src/2geom/pathvector.h b/src/2geom/pathvector.h index 6765d6bc0..9140e3872 100644 --- a/src/2geom/pathvector.h +++ b/src/2geom/pathvector.h @@ -257,6 +257,8 @@ public: return boost::range::equal(_data, other._data); } + void snapEnds(Coord precision = EPSILON); + std::vector<PVIntersection> intersect(PathVector const &other, Coord precision = EPSILON) const; /** @brief Determine the winding number at the specified point. diff --git a/src/helper/geom-pathstroke.cpp b/src/helper/geom-pathstroke.cpp index df5e5a82b..97e3c6806 100644 --- a/src/helper/geom-pathstroke.cpp +++ b/src/helper/geom-pathstroke.cpp @@ -90,9 +90,9 @@ static int circle_line_intersection(Circle C0, Point X0, Point X1, Point &p0, Po static Point intersection_point(Point origin_a, Point vector_a, Point origin_b, Point vector_b) { - Coord denom = cross(vector_b, vector_a); + Coord denom = cross(vector_a, vector_b); if (!are_near(denom,0.)) { - Coord t = (cross(origin_a,vector_b) + cross(vector_b,origin_b)) / denom; + Coord t = (cross(vector_b, origin_a) + cross(origin_b, vector_b)) / denom; return origin_a + vector_a*t; } return Point(infinity(), infinity()); @@ -322,7 +322,7 @@ void extrapolate_join(Geom::Path& res, Geom::Curve const& outgoing, double miter Geom::Ray end_ray(center, sol); Geom::Line limit_line(center, 0); // Angle set below - if (Geom::cross(start_ray.versor(), end_ray.versor()) > 0) { + if (Geom::cross(start_ray.versor(), end_ray.versor()) < 0) { limit_line.setAngle(start_ray.angle() - limit_angle); } else { limit_line.setAngle(start_ray.angle() + limit_angle); @@ -412,7 +412,7 @@ bool decide(Geom::Curve const& incoming, Geom::Curve const& outgoing) { Geom::Point tang1 = Geom::unitTangentAt(reverse(incoming.toSBasis()), 0.); Geom::Point tang2 = outgoing.unitTangentAt(0.); - return (Geom::cross(tang1, tang2) < 0); + return (Geom::cross(tang1, tang2) > 0); } void outline_helper(Geom::Path& res, Geom::Path const& to_add, double width, bool on_outside, double miter, Inkscape::LineJoinType join) @@ -488,10 +488,10 @@ void get_cubic_data(Geom::CubicBezier const& bez, double time, double& len, doub } rad = 1e8; } else { - rad = -l * (Geom::dot(der2, der2) / Geom::cross(der3, der2)); + rad = -l * (Geom::dot(der2, der2) / Geom::cross(der2, der3)); } } else { - rad = -l * (Geom::dot(der1, der1) / Geom::cross(der2, der1)); + rad = -l * (Geom::dot(der1, der1) / Geom::cross(der1, der2)); } len = l; } diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp index 42df898e6..30e21d546 100644 --- a/src/livarot/PathConversion.cpp +++ b/src/livarot/PathConversion.cpp @@ -716,7 +716,7 @@ static void ArcAnglesAndCenter(Geom::Point const &iS, Geom::Point const &iE, { Geom::Point se = iE - iS; Geom::Point ca(cos(angle), sin(angle)); - Geom::Point cse(dot(se, ca), cross(se, ca)); + Geom::Point cse(dot(ca, se), cross(ca, se)); cse[0] /= rx; cse[1] /= ry; double const lensq = dot(cse,cse); @@ -753,8 +753,8 @@ static void ArcAnglesAndCenter(Geom::Point const &iS, Geom::Point const &iE, csd[1] *= ry; ca[1] = -ca[1]; // because it's the inverse rotation - dr[0] = dot(csd, ca); - dr[1] = cross(csd, ca); + dr[0] = dot(ca, csd); + dr[1] = cross(ca, csd); ca[1] = -ca[1]; diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 49b2c5a78..12f2386b0 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -513,10 +513,10 @@ double Path::Surface() for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); ++i) { if ( i->isMoveTo == polyline_moveto ) { - surf += Geom::cross(lastM - lastP, lastM); + surf += Geom::cross(lastM, lastM - lastP); lastP = lastM = i->p; } else { - surf += Geom::cross(i->p - lastP, i->p); + surf += Geom::cross(i->p, i->p - lastP); lastP = i->p; } diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index 211ee31e2..e146bb908 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -1108,7 +1108,7 @@ Path::TangentOnCubAt (double at, Geom::Point const &iS, PathDescrCubicTo const & } return; } - rad = -l * (dot(dder,dder)) / (cross(ddder,dder)); + rad = -l * (dot(dder,dder)) / (cross(dder, ddder)); tgt = dder / l; if (before) { tgt = -tgt; @@ -1117,7 +1117,7 @@ Path::TangentOnCubAt (double at, Geom::Point const &iS, PathDescrCubicTo const & } len = l; - rad = -l * (dot(der,der)) / (cross(dder,der)); + rad = -l * (dot(der,der)) / (cross(der, dder)); tgt = der / l; } @@ -1156,7 +1156,7 @@ Path::TangentOnBezAt (double at, Geom::Point const &iS, return; } len = l; - rad = -l * (dot(der,der)) / (cross(dder,der)); + rad = -l * (dot(der,der)) / (cross(der, dder)); tgt = der / l; } @@ -1180,7 +1180,7 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point TurnInside ^= PrevPos == pos; PrevPos = pos; - const double angSi = cross (enNor,stNor); + const double angSi = cross (stNor, enNor); const double angCo = dot (stNor, enNor); if ((fabs(angSi) < .0000001) && angCo > 0) { // The join is straight -> nothing to do. diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index 7d9f3f57d..81ddcd049 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -128,7 +128,7 @@ static double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Ge } Geom::Point seg = res.p - start; - nnle = Geom::cross(seg, sp); + nnle = Geom::cross(sp, seg); nnle *= nnle; nnle /= Geom::dot(seg, seg); if ( nnle < nle ) { diff --git a/src/livarot/PathStroke.cpp b/src/livarot/PathStroke.cpp index 6ec7fa209..4cfeb887a 100644 --- a/src/livarot/PathStroke.cpp +++ b/src/livarot/PathStroke.cpp @@ -292,7 +292,7 @@ void Path::DoJoin (Shape *dest, double width, JoinType join, Geom::Point pos, Ge { Geom::Point pnor = prev.ccw(); Geom::Point nnor = next.ccw(); - double angSi = cross(next, prev); + double angSi = cross(prev, next); /* FIXED: this special case caused bug 1028953 */ if (angSi > -0.0001 && angSi < 0.0001) { @@ -416,7 +416,7 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, Geom::Point pos, { Geom::Point pnor=prev.ccw(); Geom::Point nnor=next.ccw(); - double angSi = cross (next, prev); + double angSi = cross(prev, next); if (angSi > -0.0001 && angSi < 0.0001) { double angCo = dot (prev, next); @@ -444,7 +444,7 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, Geom::Point pos, /* Geom::Point biss; biss.x=next.x-prev.x; biss.y=next.y-prev.y; - double c2=cross(biss,next); + double c2=cross(next, biss); double l=width/c2; double projn=l*(dot(biss,next)); double projp=-l*(dot(biss,prev)); @@ -503,7 +503,7 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, Geom::Point pos, } else { - double s2 = cross (biss, nnor); + double s2 = cross(nnor, biss); double dec = (l - emiter) * c2 / s2; const Geom::Point tbiss=biss.ccw(); @@ -560,7 +560,7 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, Geom::Point pos, { const Geom::Point pnor=prev.ccw(); const Geom::Point nnor=next.ccw(); - double angSi = cross (next,prev); + double angSi = cross(prev, next); if (angSi > -0.0001 && angSi < 0.0001) { double angCo = dot (prev, next); @@ -614,7 +614,7 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, Geom::Point pos, } else { - double s2 = cross (biss, nnor); + double s2 = cross(nnor, biss); double dec = (l - emiter) * c2 / s2; const Geom::Point tbiss=biss.ccw(); @@ -667,7 +667,7 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, Geom::Point pos, /* Geom::Point biss; biss=next.x-prev.x; biss.y=next.y-prev.y; - double c2=cross(next,biss); + double c2=cross(biss, next); double l=width/c2; double projn=l*(dot(biss,next)); double projp=-l*(dot(biss,prev)); @@ -719,7 +719,7 @@ void Path::RecRound(Shape *dest, int sNo, int eNo, // start and end index sia = 1; } else { double coa = dot(nS, nE); - sia = cross(nS, nE); + sia = cross(nE, nS); ang = acos(coa); if ( coa >= 1 ) { ang = 0; diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp index ac6c72342..0bb3390e8 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -1683,7 +1683,7 @@ Shape::CmpToVert (Geom::Point ax, Geom::Point bx,bool as,bool bs) Geom::Point av, bv; av = ax; bv = bx; - double si = cross (bv, av); + double si = cross(av, bv); int tstSi = 0; if (si > 0.000001) tstSi = 1; if (si < -0.000001) tstSi = -1; @@ -2104,7 +2104,7 @@ Shape::PtWinding (const Geom::Point px) const } Geom::Point const diff = px - ast; - double const cote = cross(diff, adir); + double const cote = cross(adir, diff); if (cote == 0) continue; if (cote < 0) { if (ast[0] > px[0]) lr += nWeight; diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index b04b36bfd..1e6273964 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -1738,7 +1738,7 @@ Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, Geom::Point &atx, doub } } - double ang = cross (rdir, ldir); + double ang = cross (ldir, rdir); // ang*=iL->src->eData[iL->bord].isqlength; // ang*=iR->src->eData[iR->bord].isqlength; if (ang <= 0) return false; // edges in opposite directions: <-left ... right -> @@ -1776,12 +1776,12 @@ Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, Geom::Point &atx, doub double srDot, erDot; sDiff = iL->src->pData[lSt].rx - iR->src->pData[rSt].rx; eDiff = iL->src->pData[lEn].rx - iR->src->pData[rSt].rx; - srDot = cross (sDiff,rdir); - erDot = cross (eDiff,rdir); + srDot = cross(rdir, sDiff); + erDot = cross(rdir, eDiff); sDiff = iR->src->pData[rSt].rx - iL->src->pData[lSt].rx; eDiff = iR->src->pData[rEn].rx - iL->src->pData[lSt].rx; - slDot = cross (sDiff,ldir); - elDot = cross (eDiff,ldir); + slDot = cross(ldir, sDiff); + elDot = cross(ldir, eDiff); if ((srDot >= 0 && erDot >= 0) || (srDot <= 0 && erDot <= 0)) { @@ -2089,7 +2089,7 @@ Shape::Winding (const Geom::Point px) const } diff = px - ast; - double cote = cross (diff,adir); + double cote = cross(adir, diff); if (cote == 0) continue; if (cote < 0) @@ -2563,15 +2563,15 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, double srDot, erDot; sDiff = ils->pData[lSt].rx - irs->pData[rSt].rx; eDiff = ils->pData[lEn].rx - irs->pData[rSt].rx; - srDot = cross (sDiff,rdir ); - erDot = cross (eDiff,rdir ); + srDot = cross(rdir, sDiff); + erDot = cross(rdir, eDiff); if ((srDot >= 0 && erDot >= 0) || (srDot <= 0 && erDot <= 0)) return false; sDiff = irs->pData[rSt].rx - ils->pData[lSt].rx; eDiff = irs->pData[rEn].rx - ils->pData[lSt].rx; - slDot = cross (sDiff,ldir ); - elDot = cross (eDiff,ldir); + slDot = cross(ldir, sDiff); + elDot = cross(ldir, eDiff); if ((slDot >= 0 && elDot >= 0) || (slDot <= 0 && elDot <= 0)) return false; @@ -2615,8 +2615,8 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, double sDot, eDot; sDiff = ils->pData[lSt].rx - irs->pData[rSt].rx; eDiff = ils->pData[lEn].rx - irs->pData[rSt].rx; - sDot = cross (sDiff,rdir ); - eDot = cross (eDiff,rdir); + sDot = cross(rdir, sDiff); + eDot = cross(rdir, eDiff); atx = (sDot * irs->pData[lEn].rx - eDot * irs->pData[lSt].rx) / (sDot - @@ -2625,8 +2625,8 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, sDiff = irs->pData[rSt].rx - ils->pData[lSt].rx; eDiff = irs->pData[rEn].rx - ils->pData[lSt].rx; - sDot = cross (sDiff,ldir ); - eDot = cross (eDiff,ldir ); + sDot = cross(ldir, sDiff); + eDot = cross(ldir, eDiff); atR = sDot / (sDot - eDot); @@ -2669,7 +2669,7 @@ Shape::TesteAdjacency (Shape * a, int no, const Geom::Point atx, int nPt, diff = atx - ast; - double e = IHalfRound ((cross (diff,adir)) * a->eData[no].isqlength); + double e = IHalfRound(cross(adir, diff) * a->eData[no].isqlength); if (-3 < e && e < 3) { double rad = HalfRound (0.501); // when using single precision, 0.505 is better (0.5 would be the correct value, @@ -2684,16 +2684,16 @@ Shape::TesteAdjacency (Shape * a, int no, const Geom::Point atx, int nPt, diff4[1] = diff[1] + rad; double di1, di2; bool adjacent = false; - di1 = cross (diff1,adir); - di2 = cross (diff3,adir); + di1 = cross(adir, diff1); + di2 = cross(adir, diff3); if ((di1 < 0 && di2 > 0) || (di1 > 0 && di2 < 0)) { adjacent = true; } else { - di1 = cross ( diff2,adir); - di2 = cross (diff4,adir); + di1 = cross(adir, diff2); + di2 = cross(adir, diff4); if ((di1 < 0 && di2 > 0) || (di1 > 0 && di2 < 0)) { adjacent = true; diff --git a/src/livarot/sweep-tree.cpp b/src/livarot/sweep-tree.cpp index 7a016a2ee..1b9868f2e 100644 --- a/src/livarot/sweep-tree.cpp +++ b/src/livarot/sweep-tree.cpp @@ -117,9 +117,9 @@ SweepTree::Find(Geom::Point const &px, SweepTree *newOne, SweepTree *&insertL, nNorm=nNorm.ccw(); if (sweepSens) { - y = cross(nNorm, bNorm); - } else { y = cross(bNorm, nNorm); + } else { + y = cross(nNorm, bNorm); } if (y == 0) { y = dot(bNorm, nNorm); @@ -345,7 +345,7 @@ SweepTree::InsertAt(SweepTreeList &list, SweepEventQueue &queue, SweepTree *insertL = NULL; SweepTree *insertR = NULL; - double ang = cross(nNorm, bNorm); + double ang = cross(bNorm, nNorm); if (ang == 0) { insertL = insNode; @@ -384,7 +384,7 @@ SweepTree::InsertAt(SweepTreeList &list, SweepEventQueue &queue, { bNorm = -bNorm; } - ang = cross(nNorm, bNorm); + ang = cross(bNorm, nNorm); if (ang <= 0) { break; @@ -426,7 +426,7 @@ SweepTree::InsertAt(SweepTreeList &list, SweepEventQueue &queue, { bNorm = -bNorm; } - ang = cross(nNorm, bNorm); + ang = cross(bNorm, nNorm); if (ang > 0) { break; diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index c03312ce2..fe03781d4 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -548,7 +548,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) ray2.setPoints(endArcPoint, (*cubic2)[1]); } Point handle2 = endArcPoint - Point::polar(ray2.angle(),k2); - bool ccwToggle = cross(curve_it1->finalPoint() - startArcPoint, endArcPoint - startArcPoint) < 0; + bool ccwToggle = cross(curve_it1->finalPoint() - startArcPoint, endArcPoint - startArcPoint) > 0; double angle = angle_between(ray1, ray2, ccwToggle); double handleAngle = ray1.angle() - angle; if (ccwToggle) { diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 84e4deda7..a730d7403 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -433,7 +433,7 @@ LPEKnot::doEffect_path (Geom::PathVector const &path_in) std::vector<Point> flag_j = gpaths[j][curveidx].pointAndDerivatives(t,1); - int geom_sign = ( cross(flag_i[1],flag_j[1]) > 0 ? 1 : -1); + int geom_sign = ( cross(flag_i[1], flag_j[1]) < 0 ? 1 : -1); bool i0_is_under = false; if ( crossing_points[p].sign * geom_sign > 0 ){ diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp index e6644c7e9..6a823e943 100644 --- a/src/live_effects/lpe-powerstroke.cpp +++ b/src/live_effects/lpe-powerstroke.cpp @@ -46,9 +46,9 @@ namespace Geom { static boost::optional<Point> intersection_point( Point const & origin_a, Point const & vector_a, Point const & origin_b, Point const & vector_b) { - Coord denom = cross(vector_b, vector_a); + Coord denom = cross(vector_a, vector_b); if (!are_near(denom,0.)){ - Coord t = (cross(origin_a,vector_b) + cross(vector_b,origin_b)) / denom; + Coord t = (cross(origin_b, vector_a) + cross(origin_b, vector_b)) / denom; return origin_a + t * vector_a; } return boost::none; diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index 551dbe16a..82d343f6e 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -346,7 +346,7 @@ LPESketch::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis> > const & pwd2_ //TODO: put this 4 as a parameter in the UI... //TODO: what if with v=0? double l = tgtlength*(1-tgtlength_rdm)/v_t.length(); - double r = std::pow(v_t.length(),3)/cross(a_t,v_t); + double r = std::pow(v_t.length(), 3) / cross(v_t, a_t); r = sqrt((2*fabs(r)-tgtscale)*tgtscale)/v_t.length(); l=(r<l)?r:l; //collect the tgt segment into output. diff --git a/src/live_effects/parameter/filletchamferpointarray.cpp b/src/live_effects/parameter/filletchamferpointarray.cpp index fb6cb8e07..6e70e7e65 100644 --- a/src/live_effects/parameter/filletchamferpointarray.cpp +++ b/src/live_effects/parameter/filletchamferpointarray.cpp @@ -485,7 +485,7 @@ double FilletChamferPointArrayParam::len_to_rad(int index, double len) if (cubic2) { ray2.setPoints(endArcPoint, (*cubic2)[1]); } - bool ccwToggle = cross(A->finalPoint() - startArcPoint, endArcPoint - startArcPoint) < 0; + bool ccwToggle = cross(A->finalPoint() - startArcPoint, endArcPoint - startArcPoint) > 0; double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint)); double angleBetween = angle_between(ray1, ray2, ccwToggle); rad = distanceArc/sin(angleBetween/2.0); diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp index 15d3821c7..c5336955c 100644 --- a/src/sp-offset.cpp +++ b/src/sp-offset.cpp @@ -890,7 +890,7 @@ sp_offset_distance_to_original (SPOffset * offset, Geom::Point px) if (ab > 0 && ab < len * len) { // we're in the zone of influence of the segment - double ndist = (cross(pxsx,nx)) / len; + double ndist = (cross(nx, pxsx)) / len; if (arSet == false || fabs (ndist) < fabs (arDist)) { diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 95bd179f9..0c62cfe8a 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -47,6 +47,7 @@ #include "xml/repr.h" #include "xml/repr-sorting.h" #include <2geom/pathvector.h> +#include <2geom/svg-path-writer.h> #include "helper/geom.h" #include "livarot/Path.h" @@ -305,7 +306,9 @@ sp_pathvector_boolop(Geom::PathVector const &pathva, Geom::PathVector const &pat delete originaux[0]; delete originaux[1]; - Geom::PathVector outres = Geom::parse_svg_path(res->svg_dump_path()); + gchar *result_str = res->svg_dump_path(); + Geom::PathVector outres = Geom::parse_svg_path(result_str); + g_free(result_str); delete res; return outres; @@ -447,8 +450,9 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool // reverse if needed // note that the selection list keeps its order if ( reverseOrderForOp ) { - Path* swap=originaux[0];originaux[0]=originaux[1];originaux[1]=swap; - FillRule swai=origWind[0]; origWind[0]=origWind[1]; origWind[1]=swai; + using std::swap; + swap(originaux[0], originaux[1]); + swap(origWind[0], origWind[1]); } // and work @@ -2275,10 +2279,14 @@ Ancetre(Inkscape::XML::Node *a, Inkscape::XML::Node *who) Path * Path_for_pathvector(Geom::PathVector const &epathv) { + /*std::cout << "converting to Livarot path" << std::endl; + + Geom::SVGPathWriter wr; + wr.feed(epathv); + std::cout << wr.str() << std::endl;*/ + Path *dest = new Path; - dest->LoadPathVector(epathv); - delete pathv; - + dest->LoadPathVector(epathv); return dest; } @@ -2289,14 +2297,26 @@ Path_for_item(SPItem *item, bool doTransformation, bool transformFull) if (curve == NULL) return NULL; - + Geom::PathVector *pathv = pathvector_for_curve(item, curve, doTransformation, transformFull, Geom::identity(), Geom::identity()); curve->unref(); - + + /*std::cout << "converting to Livarot path" << std::endl; + + Geom::SVGPathWriter wr; + if (pathv) { + wr.feed(*pathv); + } + std::cout << wr.str() << std::endl;*/ + Path *dest = new Path; dest->LoadPathVector(*pathv); delete pathv; - + + /*gchar *str = dest->svg_dump_path(); + std::cout << "After conversion:\n" << str << std::endl; + g_free(str);*/ + return dest; } @@ -2343,7 +2363,7 @@ pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool t } else { *dest *= extraPreAffine * extraPostAffine; } - + return dest; } |
