
modifié : include/ArrayTree/ArrayTreeBuilder.hpp modifié : include/ArrayTree/ArrayTreeBuilder.tpp modifié : include/ArrayTree/Border.hpp modifié : include/ArrayTree/Border.tpp modifié : include/ArrayTree/GraphWalker.hpp modifié : include/ArrayTree/GraphWalker.tpp modifié : include/ArrayTree/Leader.tpp modifié : include/ArrayTree/triskeleArrayTreeBase.hpp modifié : include/ArrayTree/triskeleArrayTreeBase.tpp modifié : include/AttributeProfiles.hpp modifié : include/AttributeProfiles.tpp modifié : include/Attributes/AreaAttributes.hpp modifié : include/Attributes/AverageAttributes.hpp modifié : include/Attributes/MoIAttributes.hpp modifié : include/Attributes/SDAttributes.hpp modifié : include/Attributes/WeightAttributes.hpp modifié : include/Attributes/XYAttributes.hpp modifié : include/CompAttribute.hpp modifié : include/CompAttribute.tpp modifié : include/Tree.hpp modifié : include/Tree.tpp modifié : include/TreeStats.hpp modifié : include/triskeleBase.hpp modifié : include/triskeleBase.tpp modifié : include/triskeleDebug.hpp modifié : src/Tree.cpp modifié : src/TreeStats.cpp modifié : src/apGenerator.cpp
150 lines
3.1 KiB
C++
150 lines
3.1 KiB
C++
#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 ostream &
|
|
operator << (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 ostream &
|
|
operator << (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 ostream &
|
|
operator << (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 <typename T>
|
|
inline
|
|
CPrintMap<T>::CPrintMap (const T *map, const Size &size, DimNodeId maxValues)
|
|
: map (map),
|
|
size (size),
|
|
maxValues (maxValues == 0 ? ((DimNodeId) size.width)*size.height : maxValues) {
|
|
}
|
|
|
|
template <typename T>
|
|
inline ostream &
|
|
CPrintMap<T>::print (ostream &out) const {
|
|
if (size.width > printMapMaxSide || size.height > printMapMaxSide) {
|
|
return out << "map too big to print!" << endl;
|
|
}
|
|
const T *map2 = map;
|
|
DimNodeId countDown = maxValues;
|
|
for (DimSideImg y = 0; y < size.height; ++y) {
|
|
for (DimSideImg x = 0; x < size.width; ++x, ++map2, --countDown) {
|
|
if (!countDown)
|
|
return out;
|
|
|
|
if ((DimImg (*map2)) == DimImg_MAX)
|
|
out << " M ";
|
|
else
|
|
// XXX if T == uint8_t => print char :-(
|
|
out << setw(3) << *map2 << " ";
|
|
}
|
|
out << endl;
|
|
}
|
|
return out;
|
|
}
|
|
|
|
template <typename T>
|
|
inline CPrintMap<T>
|
|
printMap (const T *map, const Size &size, DimNodeId maxValues) {
|
|
return CPrintMap<T> (map, size, maxValues);
|
|
}
|
|
|
|
#endif // _OTB_TRISKELE_BASE_TPP
|