Commit 9f305d2b authored by Michaël Roynard's avatar Michaël Roynard
Browse files

Update mask impl

parent 4609993b
Pipeline #12863 failed with stages
in 5 minutes and 8 seconds
......@@ -3,6 +3,7 @@
#include <mln/core/image/image.hpp>
#include <mln/core/image/private/where.hpp>
#include <mln/core/image/view/adaptor.hpp>
#include <range/v3/view_facade.hpp>
#include <type_traits>
......@@ -23,26 +24,26 @@ namespace mln
using typename mask_view::image_adaptor::point_type;
using typename mask_view::image_adaptor::reference;
using typename mask_view::image_adaptor::value_type;
using domain_type = mln::ranges::where_t<M>;
using concrete_type = mask_view<image_concrete_t<I>, M>;
using domain_type = mln::ranges::where_t<M>;
template <class V>
using ch_value_type = mask_view<image_ch_value_t<I, V>, M>;
static_assert(std::is_same_v<typename M::value_type, bool>, "Image value type must be boolean.");
/// \}
/// Traits & Image Properties
/// \{
using accessible = typename I::accessible;
using indexable = typename I::indexable;
using accessible = image_accessible_t<I>;
using indexable = image_indexable_t<I>;
using view = std::true_type;
using extension_category = mln::extension::none_extension_tag; // FIXME: should be improved
/// \}
using concrete_type = mask_view<image_concrete_t<I>, M>;
// Concepts check
static_assert(std::is_same_v<typename M::value_type, bool>, "Image value type must be boolean.");
template <class V>
using ch_value_type = mask_view<image_ch_value_t<I, V>, M>;
static_assert(I::accessible::value, "Image must be pw-accessible.");
/// \}
private:
class value_range_t : public ::ranges::view_facade<value_range_t>
......@@ -173,24 +174,55 @@ namespace mln
pixel_range_t new_pixels() { return {this->base().new_pixels(), m_mask.new_values()}; }
reference operator()(point_type p)
/// Indexable-image related methods
/// \{
template <typename dummy = I>
reference operator[](image_index_t<dummy> i)
{
mln_precondition(m_mask(p));
mln_precondition(this->base().domain().has(p));
return this->base().at(p);
return this->base()[i];
}
/// \}
reference at(point_type p) { return this->base().at(p); }
/// Accessible-image related methods
/// \{
template <typename Ret = reference>
std::enable_if_t<accessible::value, Ret> operator()(point_type p)
{
mln_precondition(m_mask.domain().has(p));
mln_precondition(this->base().domain().has(p));
return this->base()(p);
}
template <typename Ret = reference>
std::enable_if_t<accessible::value, Ret> at(point_type p)
{
return this->base().at(p);
}
new_pixel_type new_pixel(point_type p)
template <typename Ret = new_pixel_type>
std::enable_if_t<accessible::value, Ret> new_pixel(point_type p)
{
mln_precondition(m_mask.has(p));
mln_precondition(m_mask.domain().has(p));
mln_precondition(this->base().domain().has(p));
return this->mask_view::image_adaptor::new_pixel_at(p);
return this->base().new_pixel(p);
}
new_pixel_type new_pixel_at(point_type p) { return this->mask_view::image_adaptor::new_pixel_at(p); }
template <typename Ret = new_pixel_type>
std::enable_if_t<accessible::value, Ret> new_pixel_at(point_type p)
{
return this->base().new_pixel_at(p);
}
/// \}
/// Raw-image related methods
/// \{
auto data() const = delete;
auto data() = delete;
auto strides(int) const = delete;
/// \}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment