X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=src%2Fpath.cpp;h=251de1eeb21f450c833ea3ce156a5113440f5dc0;hb=ef0af5fd0129161a9e079bd3cd1298b53f1fe11a;hp=af9fb74181e4038d075346462bad377d2a0f2039;hpb=03cc1b0a0d0705e0b1d92e13fdb18608c7a00272;p=ipdf%2Fcode.git diff --git a/src/path.cpp b/src/path.cpp index af9fb74..251de1e 100644 --- a/src/path.cpp +++ b/src/path.cpp @@ -5,7 +5,7 @@ using namespace std; namespace IPDF { -Path::Path(const Objects & objects, unsigned start, unsigned end, const Colour & fill, const Colour & stroke) +Path::Path(Objects & objects, unsigned start, unsigned end, const Colour & fill, const Colour & stroke) : m_start(start), m_end(end), m_fill(fill), m_stroke(stroke) { Real xmin = 0; Real ymin = 0; @@ -21,6 +21,8 @@ Path::Path(const Objects & objects, unsigned start, unsigned end, const Colour & for (unsigned i = m_start; i <= m_end; ++i) { + if (i >= objects.bounds.size()) + break; const Rect & objb = objects.bounds[i]; if (i == m_start || objb.x < xmin) @@ -51,6 +53,21 @@ Path::Path(const Objects & objects, unsigned start, unsigned end, const Colour & m_bottom = objects.beziers[objects.data_indices[bottom]].ToAbsolute(objects.bounds[bottom]).GetBottom(); m_left = objects.beziers[objects.data_indices[left]].ToAbsolute(objects.bounds[left]).GetLeft(); m_right = objects.beziers[objects.data_indices[right]].ToAbsolute(objects.bounds[right]).GetRight(); + + #ifdef TRANSFORM_BEZIERS_TO_PATH + x = m_left.x; + y = m_top.y; + w = m_right.x - m_left.x; + h = m_bottom.y - m_top.y; + + Rect bounds = SolveBounds(objects); + for (unsigned i = m_start; i <= m_end; ++i) + { + //Debug("Transform %s -> %s", objects.bounds[i].Str().c_str(), bounds.Str().c_str()); + objects.bounds[i] = TransformRectCoordinates(bounds, objects.bounds[i]); + //Debug("-> %s", objects.bounds[i].Str().c_str()); + } + #endif } @@ -179,9 +196,21 @@ vector & Path::FillPoints(const Objects & objects, const View & view) return m_fill_points; } -Rect Path::SolveBounds(const Objects & objects) const +Rect Path::SolveBounds(const Objects & objects) { + #ifdef TRANSFORM_BEZIERS_TO_PATH + return Rect(Real(x.ToDouble()), Real(y.ToDouble()), Real(w.ToDouble()), Real(h.ToDouble())); + #else return Rect(m_left.x, m_top.y, m_right.x-m_left.x, m_bottom.y-m_top.y); + #endif +} + +Rect & Path::GetBounds(Objects & objects) +{ + #ifdef TRANSFORM_BEZIERS_TO_PATH + objects.bounds[m_index] = Rect(Real(x.ToDouble()), Real(y.ToDouble()), Real(w.ToDouble()), Real(h.ToDouble())); + #endif + return objects.bounds[m_index]; } }