#ifndef _OTB_TRISKELE_COMP_ATTRIBUTE_TPP #define _OTB_TRISKELE_COMP_ATTRIBUTE_TPP template inline CompAttribute::CompAttribute (const Tree &tree) : tree (tree), leafCount (0), values (nullptr) { updateTranscient (); } template inline CompAttribute::~CompAttribute () { free (); } template inline void CompAttribute::updateTranscient () { book (tree.getLeafCount ()); } template inline const AttrT * CompAttribute::getValues () const { return values; } template inline AttrT * CompAttribute::getValues () { return values; } template inline void CompAttribute::printValues (const string &msg) const { cout << "values: " << msg << endl; const Size doubleSize (tree.getSize().width, 2*tree.getSize ().height); printMap (cout, values, doubleSize, tree.getCompCount ()) << endl << endl; } template inline void CompAttribute::free () { if (values) delete[] values; values = nullptr; } template inline void CompAttribute::book (const DimImg &leafCount) { if (this->leafCount == leafCount) return; free (); if (!leafCount) return; this->leafCount = leafCount; values = new AttrT[leafCount]; } // ======================================== template inline CompAttributeC::CompAttributeC (const Tree &tree, const unsigned int &treeCoreCount) : CompAttribute (tree), treeCoreCount (treeCoreCount) { } template inline CompAttributeC::~CompAttributeC () { } template template inline void CompAttributeC::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) { const vector &weightBounds (CompAttribute::tree.getWeightBounds ()); if (!weightBounds.size () || CompAttribute::tree.getCompCount ()/weightBounds.size () < treeCoreCount) { CompAttribute::tree.forEachComp (cumpFunctPSE); return; } DimImg first = weightBounds [0]; for (DimImg curBound = 1; curBound < weightBounds.size (); curBound++) { DimImg next = weightBounds [curBound]; dealThreadRange (next-first, treeCoreCount, [this, &first, &cumpFunctPSE] (const DimImg &id) { const DimImg parentId = id+first; cumpFunctPSE (parentId); }); first = next; } } #endif // _OTB_TRISKELE_COMP_ATTRIBUTE_TPP