#ifndef _OTB_TRISKELE_ARRAY_TREE_GRAPHWALKER_HPP #define _OTB_TRISKELE_ARRAY_TREE_GRAPHWALKER_HPP #include #include #include #include #include "triskeleDebug.hpp" #include "triskeleBase.hpp" #include "triskeleArrayTreeBase.hpp" #include "Border.hpp" #ifdef GRAPHWALKER_NO_BORDER #define GRAPHWALKER_CALL_LAMBDA_IDX(idx, count, lambda) lambda, count++ #define GRAPHWALKER_CALL_LAMBDA_PTS(p1, p2, count, lambda) lambda, count++ #else #define GRAPHWALKER_CALL_LAMBDA_IDX(idx, count, lambda) if (!border.isBorder (idx)) lambda, count++ #define GRAPHWALKER_CALL_LAMBDA_PTS(p1, p2, count, lambda) if (!(border.isBorder (p1) || border.isBorder (p2))) lambda, count++ #endif namespace otb { namespace triskele { namespace arrayTree { using namespace ::triskele; using namespace std; /** GraphWalker */ class GraphWalker { public: const Border &border; const Connectivity connectivity; inline const Size &getSize () const; inline GraphWalker (const Border &border, const Connectivity &connectivity = Connectivity::C4); inline DimImg vertexMaxCount () const; static inline DimImg vertexMaxCount (const Size &tileSize); inline DimEdge edgeMaxCount () const; inline DimEdge edgeMaxCount (const Size &tileSize) const; inline DimEdge edgeBoundaryMaxCount (const DimSideImg &side) const; inline void setTiles (const unsigned int &coreCount, vector &tiles, vector &boundaries, vector &verticalBoundaries) const { setTiles (coreCount, Rect (NullPoint, border.getSize ()), tiles, boundaries, verticalBoundaries); } static inline void setTiles (const unsigned int &coreCount, const Rect &rect, vector &tiles, vector &boundaries, vector &verticalBoundaries); inline void setMaxBounds (const vector &tiles, vector &vertexMaxBounds, vector &edgesMaxBounds) const; template inline DimImg forEachVertexIdx (const Funct &lambda /*lambda (idx)*/) const; template DimImg forEachVertexPt (const Funct &lambda /*lambda (p)*/) const { const Size &size (border.getSize ()); return forEachVertexIdx ([&lambda, &size] (const Point &p) { lambda (point2idx (size, p)); }); } template inline DimImg forEachVertexIdx (const Rect &rect, const Funct &lambda /*lambda (idx)*/) const; template inline DimImg forEachVertexPt (const Rect &rect, const Funct &lambda /*lambda (p)*/) const; template inline DimEdge forEachEdgePt (const Rect &rect, TileItem tileItem, const Funct &lambda /*lambda (p0, p1)*/) const; template inline WeightT getMedian (const EdgeWeightFunction &ef /*ef.getValue (idx)*/) const; template inline DimEdge getEdges (const Rect &rect, TileItem tileItem, Edge *edges, const EdgeWeightFunction &ef /*ef.getWeight (p0, p1)*/) const; template inline DimEdge getSortedEdges (const Rect &rect, TileItem tileItem, Edge *edges, const EdgeWeightFunction &ef /*ef.getWeight (p0, p1) ef.sort ()*/) const; template inline DimEdge getCountingSortedEdges (const Rect &rect, TileItem tileItem, Edge *edges, const EdgeWeightFunction &ef /*ef.getWeight (p0, p1)*/) const; }; #include "GraphWalker.tpp" } // arrayTree } // triskele } // otb #endif // _OTB_TRISKELE_ARRAY_TREE_GRAPHWALKER_HPP