#ifndef _OTB_TRISKELE_BASE_TPP #define _OTB_TRISKELE_BASE_TPP inline Point::Point () : x (0), y (0) { } inline Point::Point (const DimSideImg &abs, const DimSideImg &ord) : x (abs), y (ord) { } inline bool operator== (const Point &p1, const Point &p2) { return p1.x == p2.x && p1.y == p2.y; } inline std::ostream & operator << (std::ostream &out, const Point &p) { return out << "(" << p.x << "," << p.y << ")"; } inline Size::Size () : width (0), height (0) { } inline Size::Size (const DimSideImg &w, const DimSideImg &h) : width (w), height (h) { } inline bool operator== (const Size &s1, const Size &s2) { return s1.width == s2.width && s1.height == s2.height; } inline std::ostream & operator << (std::ostream &out, const Size &s) { return out << "[" << s.width << "," << s.height << "]"; } inline DimImg pointToId (const Size &size, const Point &p) { return (DimImg)p.x + (DimImg)p.y * size.width; } inline Point idToPoint (const Size &size, const DimImg &id) { return Point(id % size.width, id / size.width); } inline Rect::Rect () : x (0), y (0), width (0), height (0) { } inline Rect::Rect (const Rect &rect) : x (rect.x), y (rect.y), width (rect.width), height (rect.height) { } inline Rect::Rect (const Point &orig, const Size &size) : x (orig.x), y (orig.y), width (size.width), height (size.height) { } inline Rect::Rect (const DimSideImg &abs, const DimSideImg &ord, const DimSideImg &w, const DimSideImg &h) : x (abs), y (ord), width (w), height (h) { } inline bool operator== (const Rect &r1, const Rect &r2) { return r1.x == r2.x && r1.y == r2.y && r1.width == r2.width && r1.height == r2.height; } inline std::ostream & operator << (std::ostream &out, const Rect &r) { return out << "[" << r.x << "," << r.y << " " << r.width << "x" << r.height << "]"; } inline DimImg point2idx (const Size &size, const Point &p) { return DimImg (p.x) + DimImg (p.y)*DimImg (size.width); } inline Point idx2point (const Size &size, const DimImg &idx) { return Point (idx % size.width, idx / size.width); } template inline std::ostream & printMap (std::ostream &out, const DimImg *map, const Size &size, DimNodeId maxValues) { if (size.width > printMapMaxSide || size.height > printMapMaxSide) { return out << "map too big to print!" << std::endl; } if (maxValues == 0) maxValues = ((DimNodeId) size.width)*size.height; for (DimSideImg y = 0; y < size.height; ++y) { for (DimSideImg x = 0; x < size.width; ++x, ++map, --maxValues) { if (!maxValues) return out; if (*map == DimImg_MAX) out << " M"; else out << std::setw(3) << *map; } out << std::endl; } return out; } #endif // _OTB_TRISKELE_BASE_TPP