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
35 lines
1.2 KiB
C++
35 lines
1.2 KiB
C++
#ifndef _OTB_TRISKELE_XY_ATTRIBUTES_TPP
|
|
#define _OTB_TRISKELE_XY_ATTRIBUTES_TPP
|
|
|
|
inline
|
|
XYAttributes::XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes, const unsigned int &treeCoreCount)
|
|
: CompAttributeC<AverageXY> (tree, treeCoreCount) {
|
|
compute (areaAttributes);
|
|
}
|
|
|
|
inline
|
|
XYAttributes::~XYAttributes () {
|
|
}
|
|
|
|
inline void
|
|
XYAttributes::compute (const AreaAttributes &areaAttributes) {
|
|
DimImg const width = CompAttribute<AverageXY>::tree.getSize ().width;
|
|
const DimImg *areas = areaAttributes.getValues ();
|
|
computeSameCompLevel ([this, &width, &areas] (const DimImg &parentId) {
|
|
AverageXY tmpXY;
|
|
tree.forEachChildTI (parentId, [this, &tmpXY, &width, &areas, &parentId] (const bool &isLeaf, const DimImg &childId) {
|
|
if (isLeaf) {
|
|
tmpXY.x += childId % width;
|
|
tmpXY.y += childId / width;
|
|
return;
|
|
}
|
|
tmpXY.x += CompAttribute<AverageXY>::values[childId].x*areas[childId];
|
|
tmpXY.y += CompAttribute<AverageXY>::values[childId].y*areas[childId];
|
|
});
|
|
CompAttribute<AverageXY>::values[parentId].x = tmpXY.x/areas[parentId];
|
|
CompAttribute<AverageXY>::values[parentId].y = tmpXY.y/areas[parentId];
|
|
});
|
|
}
|
|
|
|
#endif // _OTB_TRISKELE_XY_ATTRIBUTES_TPP
|