X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=blobdiff_plain;f=src%2Fquadtree.cpp;fp=src%2Fquadtree.cpp;h=a4e0df2d62699cb4704e25c5a4cb26a2eee10771;hp=0000000000000000000000000000000000000000;hb=ffd290c0bc1da5aa2397fc88af9ad594f104b192;hpb=836513d7874d20bec7247c6dfa8b3d2c426a71d4 diff --git a/src/quadtree.cpp b/src/quadtree.cpp new file mode 100644 index 0000000..a4e0df2 --- /dev/null +++ b/src/quadtree.cpp @@ -0,0 +1,44 @@ +#ifndef QUADTREE_REMOVED +#include "quadtree.h" + +namespace IPDF { + +Rect TransformToQuadChild(const Rect& src, QuadTreeNodeChildren child_type) +{ + Rect dst; + dst.x *= 2; + dst.y *= 2; + dst.w *= 2; + dst.h *= 2; + if (child_type == QTC_BOTTOM_LEFT || child_type == QTC_BOTTOM_RIGHT) + { + dst.x -= 2; + } + if (child_type == QTC_TOP_RIGHT || child_type == QTC_BOTTOM_RIGHT) + { + dst.y -= 2; + } + return dst; +} + +Rect TransformFromQuadChild(const Rect& src, QuadTreeNodeChildren child_type) +{ + Rect dst; + dst.x *= 0.5; + dst.y *= 0.5; + dst.w *= 0.5; + dst.h *= 0.5; + if (child_type == QTC_BOTTOM_LEFT || child_type == QTC_BOTTOM_RIGHT) + { + dst.x += 0.5; + } + if (child_type == QTC_TOP_RIGHT || child_type == QTC_BOTTOM_RIGHT) + { + dst.y += 0.5; + } + return dst; +} + +} + +#endif