modifié : include/ArrayTree/ArrayTreeBuilder.tpp

modifié :         include/Tree.hpp
	modifié :         include/TreeBuilder.hpp
	modifié :         src/testMain.cpp
This commit is contained in:
Git Merciol 2017-11-28 09:19:46 +01:00
parent e5643b9d54
commit fd2a2d4421
4 changed files with 31 additions and 20 deletions

View File

@ -50,6 +50,7 @@ template<typename WeightT, typename PixelT>
template<typename WeightFunct>
inline void
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &weightFunct) {
DEF_LOG ("ArrayTreeBuilder::buildTree", "");
initWeights (graphWalker, weightFunct);
vector<Edge<WeightT> > allEdges (graphWalker.edgeMaxCount ());
@ -131,9 +132,8 @@ ArrayTreeBuilder<WeightT, PixelT>::buildTree (Tree &tree, const WeightFunct &wei
newCompIdx = NULL;
leaders.free ();
// XXX tree.setNode
nodeCount = leafCount+compCount;
LOG ("nodeCount:" << nodeCount);
setNodeCount (tree, leafCount+compCount);
LOG ("nodeCount:" << tree.getNodeCount());
DimEdge root = compCount-1;
compParents[root] = root;
@ -162,10 +162,10 @@ inline void
ArrayTreeBuilder<WeightT, PixelT>::buildTree (Edge<WeightT> *edges, const WeightFunct &weightFunct,
const Rect &tile, DimImg &topParent) {
#ifdef SMART_LOG
DEF_LOG ("ArrayTreeBuilder::buildTree", " tile:" << tile << " topParent:" << topParent << " counting:" << countingSortFlag);
DEF_LOG ("ArrayTreeBuilder::buildTree", " tile:" << tile << " topParent:" << topParent << " counting:" << countingFlag);
#endif
DimEdge edgeCount = (sizeof (WeightT) < 3 || countingSortFlag) ?
DimEdge edgeCount = (sizeof (WeightT) < 3 || countingFlag) ?
graphWalker.getCountingSortedEdges<WeightT, WeightFunct> (tile, Surface, edges, weightFunct) :
graphWalker.getSortedEdges (tile, Surface, edges, weightFunct);
@ -381,7 +381,7 @@ ArrayTreeBuilder<WeightT, PixelT>::connectLeaf (DimImg a, DimImg b, const Weight
}
// ----------------------------------------
template<typename WeightT, PixelT>
template<typename WeightT, typename PixelT>
template<typename WeightFunct>
inline void
ArrayTreeBuilder<WeightT, PixelT>::connectComp (DimImg newComp, DimImg topA, DimImg topB, const WeightFunct &weightFunct) {
@ -482,7 +482,7 @@ ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const vector<DimImg> &compBases
}
// ----------------------------------------
template<typename WeightT, PixelT>
template<typename WeightT, typename PixelT>
inline void
ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const DimImg curComp, DimImg &compCount) {
if (newCompIdx[curComp] != DimImg_MAX)
@ -506,7 +506,7 @@ ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const DimImg curComp, DimImg &c
// XXX arbres non-connexe ?
cerr << "coucou ptop-max: " << curComp << endl;
}
const DimNodeIdx &newTopChildCountRec = childCountRec[top];
const DimNodeId &newTopChildCountRec = childCountRec[top];
const DimImg &newTopCompParent = compParents[top];
const WeightT &newTopWeight = compWeights[top]; // only in case of unnecessary comp
for (DimImg sibling = curComp; sibling != top; ) {
@ -524,7 +524,7 @@ ArrayTreeBuilder<WeightT, PixelT>::updateNewIdx (const DimImg curComp, DimImg &c
}
// ----------------------------------------
template<typename WeightT, PixelT>
template<typename WeightT, typename PixelT>
inline void
ArrayTreeBuilder<WeightT, PixelT>::compress (const DimImg &compTop) {
@ -666,8 +666,8 @@ ArrayTreeBuilder<WeightT, PixelT>::buildChildren () {
partial_sum (childCountRec, childCountRec+compCount, childCountRec);
// set
DimNodeIdx *childGetOrder = childCount+1;
for (DimNodeIdx i = 0; i < nodeCount-1; ++i) {
DimNodeId *childGetOrder = childCount+1;
for (DimNodeId i = 0; i < nodeCount-1; ++i) {
if (leafParents[i] == DimImg_MAX)
continue;
BOOST_ASSERT (leafParents[i] < compCount);
@ -699,21 +699,21 @@ inline void
ArrayTreeBuilder<WeightT, PixelT>::printTree (const Size &size, const bool &rec) {
cout << "tree weight parent " << (rec ? "countRec" : "count") << endl;
Size doubleSize (size.width, 2*size.height);
cct::merciol::printMap (cout, compWeights, size) << endl;
cct::merciol::printMap (cout, leafParents, doubleSize) << endl;
cct::merciol::printMap (cout, rec ? childCountRec : childCount, size) << endl;
triskele::printMap (cout, compWeights, size) << endl;
triskele::printMap (cout, leafParents, doubleSize) << endl;
triskele::printMap (cout, rec ? childCountRec : childCount, size) << endl;
}
template<typename WeightT, typename PixelT>
inline void
ArrayTreeBuilder<WeightT, PixelT>::printLeaders (const Size &size) {
cout << "leaders" << endl;
cct::merciol::printMap (cout, newCompIdx, size) << endl;
triskele::printMap (cout, newCompIdx, size) << endl;
}
template<typename WeightT, typename PixelT>
inline void
ArrayTreeBuilder<WeightT, PixelT>::printNewCompIdx (const Size &size) {
cout << "newCompIdx" << endl;
cct::merciol::printMap (cout, newCompIdx, size) << endl;
triskele::printMap (cout, newCompIdx, size) << endl;
}
#endif

View File

@ -28,7 +28,7 @@ namespace otb {
Size size;
/*! Number of pixels / leaf */
DimImg leafCount, nodeCount;
DimNodeId leafCount, nodeCount;
/*! Pointers on the parents of each leafs / nodes */
DimNodeId *leafParents, *compParents;
@ -69,7 +69,7 @@ namespace otb {
// 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 getCompCount () const { return nodeCount-leafCount; }
const DimNodeId &getParent (const DimNodeId &idx) const { return leafParents[idx]; }
const DimNodeId &getLeafParent (const DimNodeId &idx) const { return leafParents[idx]; }

View File

@ -24,16 +24,22 @@ namespace otb {
inline void updateAttributes (Tree &tree) {
leafCount = tree.leafCount;
nodeCount = tree.nodeCount;
leafParents = tree.leafParents;
compParents = tree.compParents;
children = tree.children;
childCount = tree.childCount;
}
DimNodeId getCompCount () const { return nodeCount-leafCount; }
inline void setNodeCount (Tree &tree, DimNodeId nodeCount) {
tree.setNodeCount (nodeCount);
this->nodeCount = nodeCount;
}
protected:
// Attributes corresponding to the tree, used to make the construction easier
DimImg leafCount;
DimImg leafCount, nodeCount;
/*! Pointers on the parents of each leafs / nodes */
DimNodeId *leafParents, *compParents;

View File

@ -8,11 +8,16 @@
#include "QuadTree/QuadTreeBuilder.hpp"
#include "XMLTree/XMLTreeBuilder.hpp"
#include "IImage.hpp"
#include "Attribute.hpp"
#include "ArrayTree/triskeleArrayTreeBase.hpp"
#include "ArrayTree/triskeleSort.hpp"
#include "ArrayTree/Border.hpp"
#include "ArrayTree/GraphWalker.hpp"
#include "ArrayTree/Leader.hpp"
#include "ArrayTree/Weight.hpp"
//#include "ArrayTree/ArrayTreeBuilder.hpp"
#include "ArrayTree/ArrayTreeBuilder.hpp"
int
main (int argc, char** argv) {