#ifndef _OTB_TRISKELE_XY_ATTRIBUTES_TPP #define _OTB_TRISKELE_XY_ATTRIBUTES_TPP using namespace boost::chrono; inline XYAttributes::XYAttributes (const Tree &tree, const AreaAttributes &areaAttributes) : CompAttribute (tree) { compute (areaAttributes); } inline XYAttributes::~XYAttributes () { } inline void XYAttributes::compute (const AreaAttributes &areaAttributes) { auto start = high_resolution_clock::now (); DimImg const width = CompAttribute::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::values[childId].x*areas[childId]; tmpXY.y += CompAttribute::values[childId].y*areas[childId]; }); CompAttribute::values[parentId].x = tmpXY.x/areas[parentId]; CompAttribute::values[parentId].y = tmpXY.y/areas[parentId]; }); globalTreeStats.addTime (xyStats, duration_cast > (high_resolution_clock::now ()-start).count ()); } #endif // _OTB_TRISKELE_XY_ATTRIBUTES_TPP