triskele/include/CompAttribute.tpp
Git Merciol e09d2793e2 nouveau fichier : MakefileNoOTB
nouveau fichier : include/Attributes/AverageAttributes.hpp
	nouveau fichier : include/Attributes/AverageAttributes.tpp
	nouveau fichier : include/Attributes/SDAttributes.hpp
	nouveau fichier : include/Attributes/SDAttributes.tpp
	nouveau fichier : include/Attributes/XYAttributes.hpp
	nouveau fichier : include/Attributes/XYAttributes.tpp
	nouveau fichier : include/CompAttribute.hpp
	nouveau fichier : include/CompAttribute.tpp
2018-02-19 16:58:11 +01:00

100 lines
2.4 KiB
C++

#ifndef _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
#define _OTB_TRISKELE_COMP_ATTRIBUTE_TPP
template<typename AttrT>
inline
CompAttribute<AttrT>::CompAttribute (const Tree &tree)
: tree (tree),
leafCount (0),
values (nullptr) {
updateTranscient ();
}
template<typename AttrT>
inline
CompAttribute<AttrT>::~CompAttribute () {
free ();
}
template<typename AttrT>
inline void
CompAttribute<AttrT>::updateTranscient () {
book (tree.getLeafCount ());
}
template<typename AttrT>
inline const AttrT *
CompAttribute<AttrT>::getValues () const {
return values;
}
template<typename AttrT>
inline AttrT *
CompAttribute<AttrT>::getValues () {
return values;
}
template<typename AttrT>
inline void
CompAttribute<AttrT>::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<typename AttrT>
inline void
CompAttribute<AttrT>::free () {
if (values)
delete[] values;
values = nullptr;
}
template<typename AttrT>
inline void
CompAttribute<AttrT>::book (const DimImg &leafCount) {
if (this->leafCount == leafCount)
return;
free ();
if (!leafCount)
return;
this->leafCount = leafCount;
values = new AttrT[leafCount];
}
// ========================================
template<typename AttrT>
inline
CompAttributeC<AttrT>::CompAttributeC (const Tree &tree, const unsigned int &treeCoreCount)
: CompAttribute<AttrT> (tree),
treeCoreCount (treeCoreCount) {
}
template<typename AttrT>
inline
CompAttributeC<AttrT>::~CompAttributeC () {
}
template<typename AttrT>
template<typename CumpFunctPSE>
inline void
CompAttributeC<AttrT>::computeSameCompLevel (const CumpFunctPSE &cumpFunctPSE) {
const vector<DimImg> &weightBounds (CompAttribute<AttrT>::tree.getWeightBounds ());
if (!weightBounds.size () || CompAttribute<AttrT>::tree.getCompCount ()/weightBounds.size () < treeCoreCount) {
CompAttribute<AttrT>::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