From d272af0f7f981cea9d1024b6a730be73dd22276a Mon Sep 17 00:00:00 2001 From: David Gow Date: Wed, 27 Aug 2014 23:13:47 +0800 Subject: [PATCH] =?utf8?q?Infinite=20Quadtree=20precision=20now=20works=20?= =?utf8?q?with=20some=20B=C3=A9ziers?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit You can zoom in a long way on some, others exhibit precision problems after quite a long way. Probably the curve cannot be further simplified or something? --- src/bezier.h | 4 ++-- src/document.cpp | 32 +++++++------------------------- 2 files changed, 9 insertions(+), 27 deletions(-) diff --git a/src/bezier.h b/src/bezier.h index 99530b3..03e789c 100644 --- a/src/bezier.h +++ b/src/bezier.h @@ -291,7 +291,7 @@ namespace IPDF Debug("Found %d intersections.\n", x_intersection.size()); std::vector all_beziers; - if (x_intersection.empty()) + if (x_intersection.size() <= 2) { all_beziers.push_back(*this); return all_beziers; @@ -304,7 +304,7 @@ namespace IPDF Debug(" -- t0: %f to t1: %f", t0, t1); Real ptx, pty; Evaluate(ptx, pty, ((t1 + t0) / Real(2))); - if (r.PointIn(ptx, pty)) + if (true || r.PointIn(ptx, pty)) { all_beziers.push_back(this->ReParametrise(t0, t1)); } diff --git a/src/document.cpp b/src/document.cpp index 0428aa9..37f15e2 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -132,34 +132,16 @@ int Document::ClipObjectToQuadChild(int object_id, QuadTreeNodeChildren type) } case BEZIER: { - Rect obj_bounds = TransformToQuadChild(m_objects.bounds[object_id], type); - if (obj_bounds.x < 0) - { - obj_bounds.w += obj_bounds.x; - obj_bounds.x = 0; - } - if (obj_bounds.y < 0) - { - obj_bounds.h += obj_bounds.y; - obj_bounds.y = 0; - } - if (obj_bounds.x + obj_bounds.w > 1) - { - obj_bounds.w += (1 - (obj_bounds.x + obj_bounds.w)); - } - if (obj_bounds.y + obj_bounds.h > 1) - { - obj_bounds.h += (1 - (obj_bounds.y + obj_bounds.h)); - } - Rect child_node_bounds = TransformFromQuadChild(obj_bounds, type); - Rect clip_bezier_bounds = TransformRectCoordinates(m_objects.bounds[object_id], child_node_bounds); - std::vector new_curves = Bezier(m_objects.beziers[m_objects.data_indices[object_id]], child_node_bounds).ClipToRectangle(clip_bezier_bounds); +// Rect child_node_bounds = m_objects.bounds[object_id]; + Rect clip_bezier_bounds = TransformRectCoordinates(m_objects.bounds[object_id], TransformFromQuadChild(Rect{0,0,1,1}, type)); + std::vector new_curves = m_objects.beziers[m_objects.data_indices[object_id]].ClipToRectangle(clip_bezier_bounds); for (size_t i = 0; i < new_curves.size(); ++i) { Rect new_bounds = TransformToQuadChild(m_objects.bounds[object_id], type); - //new_bounds = TransformToQuadChild(new_curves[i].SolveBounds(), type); - //Bezier new_curve_data = new_curves[i].ToRelative(new_bounds); - unsigned index = AddBezierData(new_curves[i]); + Bezier new_curve_data = new_curves[i].ToAbsolute(TransformToQuadChild(m_objects.bounds[object_id],type)); + new_bounds = new_curve_data.SolveBounds(); + new_curve_data = new_curve_data.ToRelative(new_bounds); + unsigned index = AddBezierData(new_curve_data); m_objects.bounds.push_back(new_bounds); m_objects.types.push_back(BEZIER); m_objects.data_indices.push_back(index); -- 2.20.1