
modifié : include/ArrayTree/ArrayTreeBuilder.tpp modifié : include/ArrayTree/Border.hpp modifié : include/ArrayTree/GraphWalker.tpp modifié : include/ArrayTree/Leader.hpp modifié : include/ArrayTree/Leader.tpp modifié : include/ArrayTree/Weight.hpp modifié : include/ArrayTree/Weight.tpp modifié : include/ArrayTree/triskeleArrayTreeBase.hpp modifié : include/ArrayTree/triskeleArrayTreeBase.tpp modifié : include/IImage.hpp modifié : include/IImage.tpp modifié : include/Tree.hpp modifié : include/Tree.tpp modifié : include/TreeBuilder.hpp modifié : include/XMLTree/XMLTreeBuilder.hpp modifié : include/triskeleBase.hpp modifié : include/triskeleDealThreads.hpp modifié : include/triskeleDealThreads.tpp modifié : include/triskeleDebug.hpp modifié : include/triskeleGdalGetType.hpp nouveau fichier : src/IImage.cpp modifié : src/QuadTree/QuadTreeBuilder.cpp modifié : src/Tree.cpp modifié : src/testMain.cpp modifié : src/triskeleDebug.cpp
102 lines
2.9 KiB
C++
102 lines
2.9 KiB
C++
#ifndef _OTB_TRISKELE_TREE_HPP
|
|
#define _OTB_TRISKELE_TREE_HPP
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
#include <string>
|
|
#include <numeric>
|
|
|
|
#include "triskeleBase.hpp"
|
|
#include "triskeleDebug.hpp"
|
|
|
|
namespace otb {
|
|
namespace triskele {
|
|
|
|
using namespace ::triskele;
|
|
|
|
enum State {
|
|
Void = 0,
|
|
Initialized = 1 << 0,
|
|
Constructed = 1 << 1
|
|
};
|
|
|
|
class Tree {
|
|
friend class TreeBuilder;
|
|
|
|
protected:
|
|
/*! Info about the picture */
|
|
Size size;
|
|
|
|
/*! Number of pixels / leaf */
|
|
DimNodeId leafCount, nodeCount;
|
|
|
|
/*! Pointers on the parents of each leafs / nodes */
|
|
DimNodeId *leafParents, *compParents;
|
|
|
|
/*! Pointers on the children and count how many children a parents have */
|
|
DimNodeId *children, *childCount;
|
|
|
|
/*! State of the tree */
|
|
State state;
|
|
|
|
/*! Allocate the size according to the size previously defined */
|
|
void book (const DimImg &leafCount);
|
|
|
|
/*! Free all the memory and set all pointers to nullptr */
|
|
void free ();
|
|
|
|
public:
|
|
// Constructors, destructor and resize method (does the same as the constructors)
|
|
|
|
Tree (const DimSideImg &width, const DimSideImg &height);
|
|
Tree (const DimImg &leafCount = 0); // XXX
|
|
~Tree ();
|
|
|
|
/*! clear values according to the size defined */
|
|
void clear ();
|
|
|
|
void resize (const DimSideImg &width, const DimSideImg &height);
|
|
void resize (const DimImg &leafCount); // XXX
|
|
|
|
// Setter for nodeCount and size
|
|
inline void setNodeCount (const DimImg &newNodeCount);
|
|
inline void setSize (const Size &newSize);
|
|
|
|
// Get the tree state and the size
|
|
inline State getState () const;
|
|
inline Size getSize () const;
|
|
|
|
// Getters for tree structure
|
|
inline DimNodeId getRoot () const;
|
|
inline DimNodeId getAbsRoot () const;
|
|
inline DimNodeId getCompCount () const;
|
|
|
|
inline const DimNodeId &getParent (const DimNodeId &idx) const;
|
|
inline const DimNodeId &getLeafParent (const DimNodeId &idx) const;
|
|
inline const DimNodeId &getCompParent (const DimNodeId &idx) const;
|
|
inline const DimNodeId &getChildrenCount (const DimImg &idx) const;
|
|
inline const DimSideImg &getLeafCount () const;
|
|
inline const DimSideImg &getNodeCount () const;
|
|
|
|
// Functions to apply to specific entities
|
|
template<typename FuncToApply>
|
|
void forEachLeaf (const FuncToApply &f /* f (DimNodeId leafId) */) const;
|
|
|
|
template<typename FuncToApply>
|
|
inline void forEachComp (const FuncToApply &f /* f (DimNodeId compId) */) const;
|
|
|
|
template<typename FuncToApply>
|
|
inline void forEachChild (const DimNodeId &parentId, const FuncToApply &f /* f (DimNodeId childId) */) const;
|
|
|
|
#ifdef ENABLE_LOG
|
|
// Print info about the tree
|
|
void printTree () const;
|
|
#endif
|
|
};
|
|
|
|
#include "Tree.tpp"
|
|
} // triskele
|
|
} // otb
|
|
|
|
#endif // _OTB_TRISKELE_TREE_HPP
|