#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; /** GraphWalker */ class GraphWalker { public: const Size size; const Border &border; const Connectivity connectivity; GraphWalker (const Size &size, const Border &border, const Connectivity &connectivity = Connectivity::C4) : size (size), border (border), connectivity (connectivity) { BOOST_ASSERT (size.width >= DimImg (0)); BOOST_ASSERT (size.height >= DimImg (0)); } inline DimImg vertexMaxCount () const; inline DimImg vertexMaxCount (const Size &tileSize) const; 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, const Rect &tile, std::vector &tiles, std::vector &boundaries, std::vector &verticalBoundaries) const; template inline DimImg forEachVertexIdx (const Funct &lambda /*lambda (idx)*/) const; template DimImg forEachVertexPt (const Funct &lambda /*lambda (p)*/) const { return forEachVertexIdx ([this, &lambda] (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