coord: avoid casting errors for coord types

This commit is contained in:
Danny Robson 2015-10-19 12:05:13 +11:00
parent f6933fb87d
commit d73e86b374
2 changed files with 12 additions and 4 deletions

View File

@ -1,15 +1,21 @@
#include "./distance.hpp"
#include "../../../extent.hpp"
#include "../../../types/casts.hpp"
///////////////////////////////////////////////////////////////////////////////
template <size_t S, size_t R>
static const std::array<util::vectori<S>, util::pow(R*2+1,S)>
static const std::array<
util::vectori<S>,
util::pow(R*2+1,S)
>
generate (void)
{
using value_type = typename util::vectori<S>::value_type;
static const util::extent_range<
S,typename util::vectori<S>::value_type
> area (util::extent<S,typename util::vectori<S>::value_type> {R*2+1});
> area (util::extent<S,value_type> {R*2+1});
std::array<
util::vectori<S>,
@ -18,7 +24,9 @@ generate (void)
std::transform (area.begin (), area.end (),
out.begin (),
[] (auto i) { return i.template as<util::vector> () - R; });
[] (auto i) {
return i.template as<util::vector> () - sign_cast<value_type> (R);
});
return out;
}

View File

@ -264,7 +264,7 @@ util::region<S,T>::inset (T mag)
return {
p + mag,
e - 2 * mag
e - static_cast<T> (2 * mag)
};
}