
nouveau fichier : include/ArrayTree/ArrayTreeBuilder.tpp nouveau fichier : include/ArrayTree/Border.hpp nouveau fichier : include/ArrayTree/GraphWalker.hpp nouveau fichier : include/ArrayTree/Leader.hpp nouveau fichier : include/ArrayTree/Weight.hpp nouveau fichier : include/ArrayTree/Weight.tpp nouveau fichier : include/ArrayTree/triskeleArrayTreeBase.hpp nouveau fichier : include/ArrayTree/triskeleSort.hpp nouveau fichier : include/ArrayTree/triskeleSort.tpp modifié : include/Attribute.hpp modifié : include/Attributes/AreaAttribute.hpp supprimé : include/BuildTree.hpp supprimé : include/DAPTree/Border.hpp supprimé : include/DAPTree/DAPTreeBuilder.hpp supprimé : include/DAPTree/DAPTreeBuilder.tpp supprimé : include/DAPTree/GraphWalker.hpp supprimé : include/DAPTree/ParRnk.hpp supprimé : include/DAPTree/Weight.hpp supprimé : include/DAPTree/baseDAPTree.hpp supprimé : include/DAPTree/sort.hpp nouveau fichier : include/IImage.hpp nouveau fichier : include/IImage.tpp supprimé : include/ImageInterface.hpp supprimé : include/ImageInterface.tpp modifié : include/QuadTree/QuadTreeBuilder.hpp modifié : include/Tree.hpp nouveau fichier : include/TreeBuilder.hpp supprimé : include/TreeOfShapesGeraud/ToSBuilder.hpp supprimé : include/TreeOfShapesGeraud/ToSutils.hpp modifié : include/XMLTree/XMLTreeBuilder.hpp supprimé : include/baseDef.hpp supprimé : include/getType.hpp nouveau fichier : include/triskeleBase.hpp renommé : include/dealThreads.hpp -> include/triskeleDealThreads.hpp nouveau fichier : include/triskeleDealThreads.tpp renommé : include/debug.hpp -> include/triskeleDebug.hpp nouveau fichier : include/triskeleGdalGetType.hpp modifié : otb-module.cmake nouveau fichier : src/ArrayTree/triskeleArrayTreeBase.cpp modifié : src/Attribute.cpp modifié : src/Attributes/AreaAttribute.cpp modifié : src/CMakeLists.txt supprimé : src/DAPTree/GraphWalker.cpp supprimé : src/DAPTree/ParRnk.cpp supprimé : src/DAPTree/baseDAPTree.cpp supprimé : src/DAPTree/sort.cpp modifié : src/QuadTree/QuadTreeBuilder.cpp modifié : src/Tree.cpp supprimé : src/TreeOfShapesGeraud/ToSBuilder.cpp supprimé : src/TreeOfShapesGeraud/ToSutils.cpp modifié : src/XMLTree/XMLTreeBuilder.cpp supprimé : src/debug.cpp modifié : src/testMain.cpp nouveau fichier : src/triskeleDebug.cpp supprimé : tests/ToSGeraudCoord.txt supprimé : tests/ToSGeraudIdx.ods
111 lines
3.3 KiB
C++
111 lines
3.3 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,
|
|
Constructed = 1 << 1
|
|
};
|
|
|
|
class Tree {
|
|
friend class TreeBuilder;
|
|
|
|
protected:
|
|
/*! Info about the picture */
|
|
Size size;
|
|
|
|
/*! Number of pixels / leaf */
|
|
DimImg 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;
|
|
|
|
DimNodeId *newCompIndex;
|
|
|
|
/*! State of the tree */
|
|
State state;
|
|
|
|
/*! Reset the tree and allocate the memory according to the size defined */
|
|
void init ();
|
|
|
|
/*! Allocate the size according to the size previously defined */
|
|
void book ();
|
|
|
|
/*! Free all the memory and set all pointers to nullptr */
|
|
void reset ();
|
|
|
|
public:
|
|
// Constructors, destructor and resize method (does the same as the constructors)
|
|
|
|
Tree (const DimImg &leafCount, const DimSideImg &width, const DimSideImg &height);
|
|
Tree (const DimSideImg &width, const DimSideImg &height);
|
|
Tree (const DimImg &leafCount = 0);
|
|
~Tree ();
|
|
|
|
|
|
void resize (const DimImg &newLeafCount, const DimSideImg &w, const DimSideImg &h);
|
|
void resize (const DimImg &newLeafCount);
|
|
void resize (const DimSideImg &w, const DimSideImg &h);
|
|
|
|
// Setter for nodeCount and size
|
|
void setNodeCount (const DimImg &newNodeCount) { nodeCount = newNodeCount; }
|
|
void setSize (const Size &newSize) { size = newSize; }
|
|
|
|
// Get the tree state and the size
|
|
State getState () const { return state; }
|
|
Size getSize () const { return size; }
|
|
|
|
// Getters for tree structure
|
|
DimNodeId getRoot () const { return nodeCount-1; }
|
|
DimNodeId getAbsRoot () const { return nodeCount-1+leafCount; }
|
|
DimNodeId getCompCount () const { return nodeCount-leafCount; } // XXX
|
|
|
|
DimNodeId getParent (const DimNodeId &idx) const { return leafParents[idx]; }
|
|
DimNodeId getLeafParent (const DimNodeId &idx) const { return leafParents[idx]; }
|
|
DimNodeId getCompParent (const DimNodeId &idx) const { return compParents[idx]; }
|
|
|
|
std::vector<DimNodeId> getChildren (const DimImg &idx) const;
|
|
|
|
DimNodeId getChildrenCount (const DimImg &idx) const { return childCount[idx]; }
|
|
|
|
DimSideImg getLeafCount () const { return leafCount; }
|
|
|
|
DimSideImg getNodeCount () const { return nodeCount; }
|
|
|
|
// Functions to apply to specific entities
|
|
template<typename FuncToApply>
|
|
void forEachLeaf (const FuncToApply& f /* f(DimNodeId idx) */);
|
|
|
|
template<typename FuncToApply>
|
|
void forEachComp (const FuncToApply& f /* f(DimNodeId idx) */);
|
|
|
|
template<typename FuncToApply>
|
|
void forEachChild (const DimNodeId &idx, const FuncToApply& f /* f(DimNodeId idx) */);
|
|
|
|
#ifdef SMART_LOG
|
|
// Print info about the tree
|
|
void printTree (const Size &size, const bool &rec);
|
|
void printNewCompIndex (const Size &size);
|
|
#endif
|
|
};
|
|
} // triskele
|
|
} // otb
|
|
|
|
#endif // _OTB_TRISKELE_TREE_HPP
|