From 5eb9b4815a12cc0dafd07905f7715a7e15a92b41 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Mon, 13 Jan 2014 00:25:39 +0100 Subject: update 2geom's copy to r2142 (bzr r12921) --- src/2geom/recursive-bezier-intersection.cpp | 36 +++++++++++------------------ 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'src/2geom/recursive-bezier-intersection.cpp') diff --git a/src/2geom/recursive-bezier-intersection.cpp b/src/2geom/recursive-bezier-intersection.cpp index 7db0438a7..0c7977970 100644 --- a/src/2geom/recursive-bezier-intersection.cpp +++ b/src/2geom/recursive-bezier-intersection.cpp @@ -81,14 +81,13 @@ const double INV_EPS = (1L<<14); */ void OldBezier::split(double t, OldBezier &left, OldBezier &right) const { const unsigned sz = p.size(); - - Geom::Point **Vtemp = new Geom::Point* [sz]; - - for (unsigned int i = 0; i < sz; ++i) - Vtemp[i] = new Geom::Point[sz]; + //Geom::Point Vtemp[sz][sz]; + std::vector< std::vector< Geom::Point > > Vtemp; + for (size_t i = 0; i < sz; ++i ) + Vtemp[i].reserve(sz); /* Copy control points */ - std::copy(p.begin(), p.end(), Vtemp[0]); + std::copy(p.begin(), p.end(), Vtemp[0].begin()); /* Triangle computation */ for (unsigned i = 1; i < sz; i++) { @@ -103,11 +102,6 @@ void OldBezier::split(double t, OldBezier &left, OldBezier &right) const { left.p[j] = Vtemp[j][0]; for (unsigned j = 0; j < sz; j++) right.p[j] = Vtemp[sz-1-j][j]; - - for (unsigned int i = 0; i < sz; ++i) - delete[] Vtemp[i]; - - delete[] Vtemp; } #if 0 @@ -134,17 +128,15 @@ Point OldBezier::operator()(double t) const { #endif // suggested by Sederberg. -Point OldBezier::operator()(double t) const { - int n = p.size()-1; - double u, bc, tn, tmp; - int i; +Point OldBezier::operator()(double const t) const { + size_t const n = p.size()-1; Point r; for(int dim = 0; dim < 2; dim++) { - u = 1.0 - t; - bc = 1; - tn = 1; - tmp = p[0][dim]*u; - for(i=1; i= : need boundary case - return not( ( minax > maxbx ) || ( minay > maxby ) - || ( minbx > maxax ) || ( minby > maxay ) ); + return !( ( minax > maxbx ) || ( minay > maxby ) + || ( minbx > maxax ) || ( minby > maxay ) ); } /* -- cgit v1.2.3 From 3394f340295af7b454b27250cdce1d845ad4b64d Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 1 Apr 2014 01:09:09 +0200 Subject: partial 2geom update (fixes warning) (bzr r13246) --- src/2geom/recursive-bezier-intersection.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/2geom/recursive-bezier-intersection.cpp') diff --git a/src/2geom/recursive-bezier-intersection.cpp b/src/2geom/recursive-bezier-intersection.cpp index 0c7977970..548065196 100644 --- a/src/2geom/recursive-bezier-intersection.cpp +++ b/src/2geom/recursive-bezier-intersection.cpp @@ -13,6 +13,8 @@ unsigned intersect_steps = 0; using std::vector; +using std::swap; + namespace Geom { class OldBezier { @@ -31,7 +33,7 @@ public: minax = p[0][X]; // These are the most likely to be extremal maxax = p.back()[X]; if( minax > maxax ) - std::swap(minax, maxax); + swap(minax, maxax); for(unsigned i = 1; i < p.size()-1; i++) { if( p[i][X] < minax ) minax = p[i][X]; @@ -42,7 +44,7 @@ public: minay = p[0][Y]; // These are the most likely to be extremal maxay = p.back()[Y]; if( minay > maxay ) - std::swap(minay, maxay); + swap(minay, maxay); for(unsigned i = 1; i < p.size()-1; i++) { if( p[i][Y] < minay ) minay = p[i][Y]; @@ -71,9 +73,6 @@ find_intersections_bezier_recursive( std::vector > &xs } -/* The value of 1.0 / (1L<<14) is enough for most applications */ -const double INV_EPS = (1L<<14); - /* * split the curve at the midpoint, returning an array with the two parts * Temporary storage is minimized by using part of the storage for the result @@ -318,9 +317,14 @@ double Lmax(Point p) { return std::max(fabs(p[X]), fabs(p[Y])); } + unsigned wangs_theorem(OldBezier /*a*/) { return 6; // seems a good approximation! - /*double la1 = Lmax( ( a.p[2] - a.p[1] ) - (a.p[1] - a.p[0]) ); + + /* + const double INV_EPS = (1L<<14); // The value of 1.0 / (1L<<14) is enough for most applications + + double la1 = Lmax( ( a.p[2] - a.p[1] ) - (a.p[1] - a.p[0]) ); double la2 = Lmax( ( a.p[3] - a.p[2] ) - (a.p[2] - a.p[1]) ); double l0 = std::max(la1, la2); unsigned ra; -- cgit v1.2.3