X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fpath.cpp;h=0516e5bc03334ea84aa5ab4ff621f44345af8ea9;hp=f12e2a7829c0bc941d740da1ae5b800b7a47dd44;hb=326f04a375ce3120f7e8957e3d7cd5f296f513e3;hpb=5f600e9c0d22c09bd60ef3c7245dbecc8d35d576 diff --git a/src/path.cpp b/src/path.cpp index f12e2a7..0516e5b 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; @@ -53,6 +53,16 @@ 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(); + + m_bounds = SolveBounds(objects).Convert(); + #ifdef TRANSFORM_BEZIERS_TO_PATH + 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(m_bounds.Convert(), objects.bounds[i]); + //Debug("-> %s", objects.bounds[i].Str().c_str()); + } + #endif } @@ -181,9 +191,15 @@ 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) +{ + return Rect(m_left.x, m_top.y, m_right.x-m_left.x, m_bottom.y-m_top.y); +} + +Rect & Path::GetBounds(Objects & objects) { - return Rect(m_left.x, m_top.y, m_right.x-m_left.x, m_bottom.y-m_top.y); + objects.bounds[m_index] = m_bounds.Convert(); + return objects.bounds[m_index]; } }