
nouveau fichier : CMakeListsOTB.txt nouveau fichier : Readme.html nouveau fichier : include/Attribute.hpp nouveau fichier : include/Attributes/AreaAttribute.hpp nouveau fichier : include/BuildTree.hpp nouveau fichier : include/DAPTree/Border.hpp nouveau fichier : include/DAPTree/DAPTreeBuilder.hpp nouveau fichier : include/DAPTree/DAPTreeBuilder.tpp nouveau fichier : include/DAPTree/GraphWalker.hpp nouveau fichier : include/DAPTree/ParRnk.hpp nouveau fichier : include/DAPTree/Weight.hpp nouveau fichier : include/DAPTree/baseDAPTree.hpp nouveau fichier : include/DAPTree/sort.hpp nouveau fichier : include/ImageInterface.hpp nouveau fichier : include/ImageInterface.tpp nouveau fichier : include/QuadTree/QuadTreeBuilder.hpp nouveau fichier : include/Tree.hpp nouveau fichier : include/TreeOfShapesGeraud/ToSBuilder.hpp nouveau fichier : include/TreeOfShapesGeraud/ToSutils.hpp nouveau fichier : include/XMLTree/XMLTreeBuilder.hpp nouveau fichier : include/baseDef.hpp nouveau fichier : include/dealThreads.hpp nouveau fichier : include/debug.hpp nouveau fichier : include/getType.hpp nouveau fichier : otb-module.cmake nouveau fichier : src/Attribute.cpp nouveau fichier : src/Attributes/AreaAttribute.cpp nouveau fichier : src/CMakeLists.txt nouveau fichier : src/DAPTree/GraphWalker.cpp nouveau fichier : src/DAPTree/ParRnk.cpp nouveau fichier : src/DAPTree/baseDAPTree.cpp nouveau fichier : src/DAPTree/sort.cpp nouveau fichier : src/QuadTree/QuadTreeBuilder.cpp nouveau fichier : src/Tree.cpp nouveau fichier : src/TreeOfShapesGeraud/ToSBuilder.cpp nouveau fichier : src/TreeOfShapesGeraud/ToSutils.cpp nouveau fichier : src/XMLTree/XMLTreeBuilder.cpp nouveau fichier : src/debug.cpp nouveau fichier : src/testMain.cpp nouveau fichier : tests/ToSGeraudCoord.txt nouveau fichier : tests/ToSGeraudIdx.ods
120 lines
3.1 KiB
C++
120 lines
3.1 KiB
C++
#ifndef OTREE_HPP
|
|
#define OTREE_HPP
|
|
|
|
#include <vector>
|
|
#include <map>
|
|
#include <string>
|
|
#include <numeric>
|
|
|
|
#include "baseDef.hpp"
|
|
#include "debug.hpp"
|
|
|
|
|
|
namespace otb {
|
|
enum State {
|
|
Void = 0,
|
|
Initialized = 1,
|
|
Constructed = 1 << 1
|
|
};
|
|
|
|
class Tree {
|
|
friend class BuildTree;
|
|
|
|
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; }
|
|
|
|
// 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) */);
|
|
|
|
// Get the tree state and the size
|
|
|
|
State getState() const { return state; }
|
|
|
|
Size getSize() const { return size; }
|
|
|
|
|
|
#ifdef SMART_LOG
|
|
// Print info about the tree
|
|
|
|
void printTree (const Size &size, const bool &rec);
|
|
void printNewCompIndex (const Size &size);
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
} // otb
|
|
|
|
#endif // OTREE_HPP
|