#ifndef _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP #define _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP // ======================================== template inline AttributeProfiles::AttributeProfiles (const Tree &tree) : tree (tree), leafCount (0), values () { updateTranscient (); } template inline AttributeProfiles::~AttributeProfiles () { free (); } template inline void AttributeProfiles::updateTranscient () { book (tree.getLeafCount ()); } template inline PixelT * AttributeProfiles::getValues () { return &values[0]; } template inline const PixelT * AttributeProfiles::getValues () const { return &values[0]; } // ======================================== template template inline void AttributeProfiles::setValues (const PixelT defaultValue, const WeightT *weights) { updateTranscient (); fill_n (&values[0], tree.getLeafCount (), defaultValue); PixelT *compAP = &values[tree.getLeafCount ()]; dealThreadBound (tree.getCompCount (), tree.getCoreCount (), [&compAP, &weights] (const DimImg &minVal, const DimImg &maxVal) { for (DimImg compIdx = minVal; compIdx < maxVal; ++compIdx) compAP[compIdx] = weights[compIdx]; }); } template template inline void AttributeProfiles::setValues (const PixelT *pixels, const WeightT *weights) { updateTranscient (); PixelT *leafAP = &values[0]; dealThreadBound (tree.getLeafCount (), tree.getCoreCount (), [&leafAP, &pixels] (const DimImg &minVal, const DimImg &maxVal) { for (DimImg i = minVal; i < maxVal; ++i) leafAP[i] = pixels [i]; }); PixelT *compAP = leafAP+tree.getLeafCount (); dealThreadBound (tree.getCompCount (), tree.getCoreCount (), [&compAP, &weights] (const DimImg &minVal, const DimImg &maxVal) { for (DimImg compIdx = minVal; compIdx < maxVal; ++compIdx) compAP[compIdx] = weights[compIdx]; }); } template inline void AttributeProfiles::free () { values = vector (); } template inline void AttributeProfiles::book (const DimImg &leafCount) { this->leafCount = leafCount; // XXX max : leafCount*2-1 values.resize (leafCount*2); } // ======================================== template ostream & AttributeProfiles::print (ostream &out) const { const Size doubleSize (tree.getSize().width, 2*tree.getSize ().height); out << "AP" << endl << printMap (&values[0], doubleSize, tree.getNodeCount ()) << endl << endl; return out; } // ======================================== #endif // _OTB_TRISKELE_ATTRIBUTE_PROFILES_TPP