1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| template <typename Type, typename Flag, typename AxisFlag>
struct BipointSizeCalculator;
template <typename Type, typename Flag>
struct BipointSizeCalculator<Type,Flag,XAxisFlag>
{
typedef TPoint<Type, Flag> point_type;
typedef TBiPoint<Type, Flag> bipoint_type;
/* je sais (parce que je l'ai décidé :D ) que j'obtiendrai
* assez facilement un bipoint, mais il me faut les positions des deux
* point sur l'axe concerné (laxe des x, ici)...
* je crée donc un opérateur() par étape logique permettant de
* passer d'un bipoint à ces deux valeurs :D
*/
Type operator() (Type x1, Type x2) const
{
return abs(x1 - x2);
}
Type operator()(point_type const & first, point_type const & second) const
{
return this->operator()(first.x(),second.x());
}
Type operator()(bipoint_type const & bipoint) const
{
return this->operator()(bipoint.first(),bipoint.second());
}
};
template <typename Type, typename Flag>
struct BipointSizeCalculator<Type,Flag,YAxisFlag>
{
typedef TPoint<Type, Flag> point_type;
typedef TBiPoint<Type, Flag> bipoint_type;
Type operator() (Type y1, Type y2) const
{
return abs(y1 - y2);
}
Type operator()(point_type const & first, point_type const & second) const
{
return this->operator()(first.y(),second.y());
}
Type operator()(bipoint_type const & bipoint) const
{
return this->operator()(bipoint.first(),bipoint.second());
}
};
template <typename Type, typename Flag>
struct BipointSizeCalculator<Type,Flag,ZAxisFlag>
{
Type operator() (Type z1, Type z2) const
{
return abs(z1 - z2);
}
Type operator()(point_type const & first, point_type const & second) const
{
return this->operator()(first.z(),second.z());
}
Type operator()(bipoint_type const & bipoint) const
{
return this->operator()(bipoint.first(),bipoint.second());
}
}; |
Partager