
modifié : include/AttributeProfiles.hpp modifié : include/AttributeProfiles.tpp modifié : include/Attributes/AreaAttributes.hpp modifié : include/Attributes/AreaAttributes.tpp modifié : include/Attributes/WeightAttributes.hpp modifié : include/Attributes/WeightAttributes.tpp modifié : include/Tree.hpp modifié : include/Tree.tpp modifié : include/triskeleBase.tpp modifié : src/Tree.cpp modifié : src/XMLTree/XMLTreeBuilder.cpp modifié : src/testMain.cpp
117 lines
3.4 KiB
C++
117 lines
3.4 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;
|
|
private:
|
|
inline DimNodeId *getChildCount ();
|
|
|
|
protected:
|
|
/*! Info about the picture */
|
|
Size size;
|
|
|
|
/*! Number of pixels / leaf */
|
|
DimImg leafCount;
|
|
/*! number of node */
|
|
DimNodeId nodeCount; /* nodeCount = leafCount+compCount */
|
|
|
|
/*! Pointers on the parents of each leafs / nodes */
|
|
DimImg *leafParents, *compParents;
|
|
|
|
/*! Pointers on the children and count how many children a parents have */
|
|
DimImg *childCount;
|
|
DimNodeId *children;
|
|
|
|
/*! Pointers of same weight in parents (+1 : last is root)*/
|
|
vector<DimImg> weightBounds;
|
|
|
|
/*! 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 ();
|
|
~Tree ();
|
|
|
|
/*! clear values according to the size defined */
|
|
void clear ();
|
|
|
|
void resize (const DimSideImg &width, const DimSideImg &height);
|
|
|
|
// 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 const DimImg &getLeafCount () const;
|
|
inline const DimNodeId &getNodeCount () const;
|
|
inline DimImg getCompCount () const;
|
|
inline DimNodeId getNodeRoot () const;
|
|
inline DimImg getCompRoot () const;
|
|
|
|
inline const DimImg &getParent (const DimNodeId &nodeId) const;
|
|
inline const DimImg &getLeafParent (const DimImg &leafId) const;
|
|
inline const DimImg &getCompParent (const DimImg &compId) const;
|
|
|
|
inline const DimImg &getChildrenCount (const DimImg &CompId) const;
|
|
inline const DimNodeId &getChildren (const DimImg &childId) const;
|
|
inline const DimNodeId *getChildren () const; // XXX a virer ?
|
|
|
|
inline const vector<DimImg> &getWeightBounds () const;
|
|
inline vector<DimImg> &getWeightBounds ();
|
|
|
|
// Functions to apply to specific entities
|
|
template<typename FuncToApply>
|
|
void forEachLeaf (const FuncToApply &f /* f (DimImg leafId) */) const;
|
|
|
|
template<typename FuncToApply>
|
|
inline void forEachComp (const FuncToApply &f /* f (DimImg compId) */) const;
|
|
|
|
template<typename FuncToApply>
|
|
inline void forEachChild (const DimNodeId &parentId, const FuncToApply &f /* f (DimNodeId childId) */) const;
|
|
template<typename FuncToApply>
|
|
inline void forEachChildTI (const DimNodeId &parentId, const FuncToApply &f /* f (bool isLeaf, DimImg childId) */) const;
|
|
|
|
#ifdef ENABLE_LOG
|
|
// Print info about the tree
|
|
void printTree () const;
|
|
#endif
|
|
};
|
|
|
|
#include "Tree.tpp"
|
|
} // triskele
|
|
} // otb
|
|
|
|
#endif // _OTB_TRISKELE_TREE_HPP
|