79 lines
1.9 KiB
C++
79 lines
1.9 KiB
C++
#ifndef _OTB_TRISKELE_ARRAY_TREE_BASE_TPP
|
|
#define _OTB_TRISKELE_ARRAY_TREE_BASE_TPP
|
|
|
|
inline bool
|
|
getDecrFromTreetype (TreeType treeType) {
|
|
switch (treeType) {
|
|
case MIN: return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
inline ostream &
|
|
operator << (ostream &out, const Connectivity &c) {
|
|
BOOST_ASSERT (c >= 0 && c < 4);
|
|
return out << connectivityName[c];
|
|
}
|
|
|
|
inline ostream &
|
|
operator << (ostream &out, const TileItem &t) {
|
|
BOOST_ASSERT (t >= 0 && t < 3);
|
|
return out << tileItemName[t];
|
|
}
|
|
|
|
template <typename WeightT>
|
|
inline void
|
|
swapEdge (Edge<WeightT> &a, Edge<WeightT> &b) {
|
|
Edge<WeightT> c = a;
|
|
a = b;
|
|
b = c;
|
|
}
|
|
|
|
// ========================================
|
|
template <typename WeightT>
|
|
inline
|
|
CPrintEdge<WeightT>::CPrintEdge (const Edge<WeightT> &edge, const Size &size)
|
|
: edge (edge),
|
|
size (size) {
|
|
}
|
|
|
|
template <typename WeightT>
|
|
inline ostream &
|
|
CPrintEdge<WeightT>::print (ostream &out) const {
|
|
// XXX if WeightT == uint8_t => print char :-(
|
|
return out << edge.points[0] << ":" << edge.points[1] << ":" << edge.weight << ":"
|
|
<< point2idx (size, edge.points[0]) << ":" << point2idx (size, edge.points[1]);
|
|
}
|
|
|
|
template <typename WeightT>
|
|
inline CPrintEdge<WeightT>
|
|
printEdge (const Edge<WeightT> &edge, const Size &size) {
|
|
return CPrintEdge<WeightT> (edge, size);
|
|
}
|
|
|
|
// ========================================
|
|
template <typename WeightT>
|
|
inline
|
|
CPrintEdges<WeightT>::CPrintEdges (const Edge<WeightT> edges[], const Size &size, const DimEdge edgesCount)
|
|
: edges (edges),
|
|
size (size),
|
|
edgesCount (edgesCount) {
|
|
}
|
|
|
|
template <typename WeightT>
|
|
inline
|
|
ostream &
|
|
CPrintEdges<WeightT>::print (ostream &out) const {
|
|
for (int i = 0; i < edgesCount; ++i)
|
|
out << printEdge (edges[i], size) << endl;
|
|
return out;
|
|
}
|
|
|
|
template <typename WeightT>
|
|
inline CPrintEdges<WeightT>
|
|
printEdges (const Edge<WeightT> edges[], const Size &size, const DimEdge edgesCount) {
|
|
return CPrintEdges<WeightT> (edges, size, edgesCount);
|
|
}
|
|
|
|
#endif // _OTB_TRISKELE_ARRAY_TREE_BASE_TPP
|