triskele/include/Attributes/WeightAttributes.tpp
Git Merciol 869eda6449 modifié : include/ArrayTree/ArrayTreeBuilder.tpp
modifié :         include/AttributeProfiles.hpp
	modifié :         include/AttributeProfiles.tpp
	modifié :         include/Attributes/AreaAttributes.hpp
	modifié :         include/Attributes/AreaAttributes.tpp
	modifié :         include/Attributes/WeightAttributes.hpp
	modifié :         include/Attributes/WeightAttributes.tpp
	modifié :         include/Tree.hpp
	modifié :         include/Tree.tpp
	modifié :         include/triskeleBase.tpp
	modifié :         src/Tree.cpp
	modifié :         src/XMLTree/XMLTreeBuilder.cpp
	modifié :         src/testMain.cpp
2018-02-19 16:56:30 +01:00

43 lines
1.2 KiB
C++

#ifndef _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
#define _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP
template<typename WeightT>
inline
WeightAttributes<WeightT>::WeightAttributes (const Tree &tree)
: CompAttribute<WeightT> (tree) {
}
template<typename WeightT>
inline
WeightAttributes<WeightT>::~WeightAttributes () {
}
template<typename WeightT>
inline void
WeightAttributes<WeightT>::setWeightBounds (Tree &tree) {
vector<DimImg> &weightBounds (tree.getWeightBounds ());
DimImg rootId = tree.getCompRoot ();
DimImg stepsCard = 0;
WeightT curLevel = CompAttribute<WeightT>::values [0];
for (DimImg compId = 1; compId <= rootId; ++compId) {
if (CompAttribute<WeightT>::values [compId] == curLevel)
continue;
++stepsCard;
curLevel = CompAttribute<WeightT>::values [compId];
}
weightBounds.clear ();
weightBounds.reserve (stepsCard+1);
weightBounds.push_back (0);
curLevel = CompAttribute<WeightT>::values [0];
for (DimImg compId = 1; compId <= rootId; ++compId) {
if (CompAttribute<WeightT>::values [compId] == curLevel)
continue;
weightBounds.push_back (compId);
curLevel = CompAttribute<WeightT>::values [compId];
}
weightBounds.push_back (rootId+1);
}
#endif // _OTB_TRISKELE_WEIGHT_ATTRIBUTES_TPP