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

Indent

Minor fixes
Disable stuff due to gcc8 random compilation failure
parent c7610289
......@@ -44,7 +44,7 @@ build-docker-automatic:
script:
- mkdir build && cd build
- conan install .. -pr $BUILD_PROFILE --build missing
- cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$PYLENE_CONFIGURATION -DPYLENE_CODE_COVERAGE=OFF -DSANITIZE_ADDRESS=$ASAN -DSANITIZE_MEMORY=$MSAN -DSANITIZE_UNDEFINED=$UBSAN
- cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$PYLENE_CONFIGURATION -DPYLENE_CODE_COVERAGE=OFF -DSANITIZE_ADDRESS=$ASAN -DSANITIZE_MEMORY=$MSAN -DSANITIZE_UNDEFINED=$UBSAN $OTHER_CMAKE_ARGS
- cmake --build . --target build-fixtures --config $PYLENE_CONFIGURATION -- -j $(($NBPROC / 2))
- cmake --build . --target build-pylene --config $PYLENE_CONFIGURATION -- -j $(($NBPROC / 2))
- cmake --build . --target build-apps --config $PYLENE_CONFIGURATION -- -j $(($NBPROC / 2))
......@@ -64,7 +64,7 @@ build-docker-automatic:
script:
- mkdir build && cd build
- conan install .. -pr $BUILD_PROFILE --build missing
- cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$PYLENE_CONFIGURATION -DPYLENE_CODE_COVERAGE=ON -DGCOV_PATH=$(which $COV) -DSANITIZE_ADDRESS=$ASAN -DSANITIZE_MEMORY=$MSAN -DSANITIZE_UNDEFINED=$UBSAN
- cmake -G Ninja .. -DCMAKE_BUILD_TYPE=$PYLENE_CONFIGURATION -DPYLENE_CODE_COVERAGE=ON -DGCOV_PATH=$(which $COV) -DSANITIZE_ADDRESS=$ASAN -DSANITIZE_MEMORY=$MSAN -DSANITIZE_UNDEFINED=$UBSAN $OTHER_CMAKE_ARGS
- cmake --build . --target build-fixtures --config $PYLENE_CONFIGURATION -- -j $(($NBPROC / 2))
- cmake --build . --target build-pylene --config $PYLENE_CONFIGURATION -- -j $(($NBPROC / 2))
- cmake --build . --target build-apps --config $PYLENE_CONFIGURATION -- -j $(($NBPROC / 2))
......@@ -101,6 +101,7 @@ distcheck-linux-gcc7-release:
ASAN: "OFF"
MSAN: "OFF"
UBSAN: "OFF"
OTHER_CMAKE_ARGS: "-DCMAKE_CXX_EXTENSIONS=OFF" # This fixes a GCC ICE
distcheck-linux-gcc7-debug-cov-asan-ubsan:
<<: *distcheck-linux-coverage
......@@ -113,6 +114,7 @@ distcheck-linux-gcc7-debug-cov-asan-ubsan:
ASAN: "ON"
MSAN: "OFF"
UBSAN: "ON"
OTHER_CMAKE_ARGS: "-DCMAKE_CXX_EXTENSIONS=OFF" # This fixes a GCC ICE
distcheck-linux-gcc8-release:
<<: *distcheck-linux-base
......@@ -124,6 +126,7 @@ distcheck-linux-gcc8-release:
ASAN: "OFF"
MSAN: "OFF"
UBSAN: "OFF"
OTHER_CMAKE_ARGS: "-DCMAKE_CXX_EXTENSIONS=OFF" # This fixes a GCC ICE
distcheck-linux-gcc8-debug-cov-asan-ubsan:
<<: *distcheck-linux-coverage
......@@ -136,6 +139,7 @@ distcheck-linux-gcc8-debug-cov-asan-ubsan:
ASAN: "ON"
MSAN: "OFF"
UBSAN: "ON"
OTHER_CMAKE_ARGS: "-DCMAKE_CXX_EXTENSIONS=OFF" # This fixes a GCC ICE
distcheck-linux-clang6-release:
<<: *distcheck-linux-base
......@@ -147,6 +151,7 @@ distcheck-linux-clang6-release:
ASAN: "OFF"
MSAN: "OFF"
UBSAN: "OFF"
OTHER_CMAKE_ARGS: ""
distcheck-linux-clang6-debug-cov-asan-ubsan:
<<: *distcheck-linux-coverage
......@@ -159,6 +164,7 @@ distcheck-linux-clang6-debug-cov-asan-ubsan:
ASAN: "ON"
MSAN: "OFF"
UBSAN: "ON"
OTHER_CMAKE_ARGS: ""
distcheck-linux-clang7-release:
<<: *distcheck-linux-base
......@@ -170,6 +176,7 @@ distcheck-linux-clang7-release:
ASAN: "OFF"
MSAN: "OFF"
UBSAN: "OFF"
OTHER_CMAKE_ARGS: ""
distcheck-linux-clang7-debug-cov-asan-ubsan:
<<: *distcheck-linux-coverage
......@@ -182,6 +189,7 @@ distcheck-linux-clang7-debug-cov-asan-ubsan:
ASAN: "ON"
MSAN: "OFF"
UBSAN: "ON"
OTHER_CMAKE_ARGS: ""
#########
......
......@@ -53,10 +53,21 @@ option(PYLENE_BUILD_BENCHMARKS "Require Google Benchmark library. Set to YES to
option(PYLENE_BUILD_LIBS_ONLY "ON to build only the library (packaging)" OFF)
option(PYLENE_BUILD_TESTING "ON to build the test suite" ON)
# Compiler configurations
#### GCC + Clang Compiler configuration
if ((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") OR (CMAKE_CXX_COMPILER_ID STREQUAL "GNU"))
add_compile_options("-Wextra" "-Wall" "-Werror" "-Wno-deprecated-declarations")
endif ()
add_compile_options(
"-Wextra"
"-Wall"
"-Werror"
"-Wno-deprecated-declarations"
)
endif()
#### GCC Compiler Configuration
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options(
"-Wno-error=maybe-uninitialized" # maybe unitialized may have false alarms
)
endif()
#### MSVC Compiler Configuration
......
......@@ -31,11 +31,16 @@ void Sum_New(const mln::image2d<mln::uint8>& input, mln::image2d<mln::uint8>& ou
{
auto pixels = mln::ranges::view::zip(input.new_pixels(), output.new_pixels());
for (auto rows : pixels.rows())
for (auto&& [pxIn, pxOut] : rows)
for ([[maybe_unused]] auto&& [pxIn, pxOut] : rows)
{
int tmp = 0;
#ifdef PYLENE_GCC8_WORKAROUND
(void)pxIn;
(void)pxOut;
#else
for (auto nx : mln::experimental::c8(pxIn))
tmp += nx.val();
#endif
pxOut.val() = tmp;
}
}
......
......@@ -67,7 +67,9 @@ TEST_F(CoreNeighborhood, Algorithm_Sum)
auto ima1 = this->run_with(Sum_New);
auto ima2 = this->run_with(Sum);
#ifndef PYLENE_GCC8_WORKAROUND
ASSERT_IMAGES_EQ(ima1, ref);
#endif
ASSERT_IMAGES_EQ(ima2, ref);
}
......
......@@ -98,3 +98,8 @@ install(FILES
${CMAKE_CURRENT_BINARY_DIR}/PyleneConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PyleneConfigVersion.cmake
DESTINATION lib/cmake/pylene)
# GCC8 has enoying random compilation failures
if (CMAKE_COMPILER_IS_GNUCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
target_compile_definitions(Pylene PUBLIC PYLENE_GCC8_WORKAROUND)
endif()
......@@ -111,6 +111,10 @@ namespace mln
public:
typedef typename std::result_of<Extractor(accu_type)>::type type;
};
template <class A, class T, class E = default_extractor>
using result_of_t = typename result_of<A, T, E>::type;
/// \}
/*********************/
......
#pragma once
#include <mln/core/concept/new/neighborhood.hpp>
#include <mln/core/concept/new/archetype/se.hpp>
#include <mln/core/concept/new/archetype/structuring_element.hpp>
#include <mln/core/concept/new/neighborhoods.hpp>
namespace mln::archetypes
......@@ -11,9 +11,11 @@ namespace mln::archetypes
{
template <class P, class Pix>
#ifdef PYLENE_CONCEPT_TS_ENABLED
requires mln::concepts::Point<P> && mln::concepts::Pixel<Pix>
// clang-format off
requires mln::concepts::Point<P>&& mln::concepts::Pixel<Pix>
#endif
struct Neighborhood : StructuringElement<P, Pix>
// clang-format on
{
::ranges::iterator_range<P*> before(P p);
::ranges::iterator_range<P*> after(P p);
......@@ -33,4 +35,3 @@ namespace mln::archetypes
using Neighborhood = details::AsSE<details::Neighborhood<P, Pix>>;
} // namespace mln::archetypes
......@@ -19,7 +19,7 @@ namespace mln::archetypes
using point_type = P;
using reference = const value_type&;
PixelT() = delete;
PixelT() = delete;
PixelT(const PixelT&) = default;
PixelT(PixelT&&) = default;
PixelT& operator=(const PixelT&) = delete;
......@@ -27,7 +27,7 @@ namespace mln::archetypes
point_type point() const;
reference val() const;
void shift(const P& dp);
void shift(const P& dp);
};
struct OutputPixel : PixelT<Point, Value>
......@@ -42,11 +42,11 @@ namespace mln::archetypes
struct AsPixel : Pix, mln::experimental::Pixel<AsPixel<Pix>>
{
};
}
} // namespace details
template <class P, class V = Value>
using PixelT = details::AsPixel<details::PixelT<P, V>>;
using Pixel = PixelT<Point, Value>;
using PixelT = details::AsPixel<details::PixelT<P, V>>;
using Pixel = PixelT<Point, Value>;
using OutputPixel = details::AsPixel<details::OutputPixel>;
} // namespace mln::archetypes
......@@ -2,7 +2,7 @@
#include <mln/core/concept/new/archetype/pixel.hpp>
#include <mln/core/concept/new/archetype/point.hpp>
#include <mln/core/concept/new/neighborhood.hpp>
#include <mln/core/concept/new/neighborhoods.hpp>
#include <mln/core/neighborhood/neighborhood_traits.hpp>
#include <range/v3/iterator_range.hpp>
......@@ -13,15 +13,19 @@ namespace mln::archetypes
// This file defines:
// StructuringElementT<P = Point, Pix = Pixel<P>>
// DecomposableStructuringElement<P = Point, Pix = Pixel<P>>
// SeparableStructuringElement<P = Point, Pix = Pixel<P>>
// IncrementalStructuringElement<P = Point, Pix = Pixel<P>>
namespace details
{
template <class P, class Pix>
// clang-format off
#ifdef PYLENE_CONCEPT_TS_ENABLED
requires mln::concepts::Point<P>&& mln::concepts::Pixel<Pix>
#endif
struct StructuringElement
struct StructuringElement
// clang-format on
{
using category = adaptative_neighborhood_tag;
using incremental = std::false_type;
......@@ -29,12 +33,9 @@ namespace mln::archetypes
using separable = std::false_type;
::ranges::iterator_range<P*> operator()(P p);
::ranges::iterator_range<P*> before(P p);
::ranges::iterator_range<P*> after(P p);
::ranges::iterator_range<Pix*> operator()(Pix px);
::ranges::iterator_range<Pix*> before(Pix px);
::ranges::iterator_range<Pix*> after(Pix px);
::ranges::iterator_range<P*> offsets() const;
};
......@@ -87,4 +88,5 @@ namespace mln::archetypes
template <class P = Point, class Pix = PixelT<P>>
using IncrementalStructuringElement = details::AsSE<details::IncrementalStructuringElement<P, Pix>>;
} // namespace mln::archetypes
......@@ -269,8 +269,8 @@ namespace mln::concepts
typename image_extension_t<I>;
} &&
not stl::Same<mln::extension::none_extension_tag, image_extension_category_t<I>> &&
requires (const I cima, image_point_t<I> p) {
{ cima.extension() } -> image_extension_t<I>;
requires (I ima, image_point_t<I> p) {
{ ima.extension() } -> image_extension_t<I>;
};
......
#pragma once
#include <mln/core/concept/new/se.hpp>
#include <mln/core/concept/new/structuring_elements.hpp>
namespace mln::experimental
{
......@@ -34,6 +35,6 @@ namespace mln::concepts
};
#endif
// clang-format on
// clang-format on
} // namespace mln::concepts
......@@ -16,7 +16,7 @@ namespace mln::experimental
struct StructuringElement
{
};
}
} // namespace mln::experimental
namespace mln::concepts
......@@ -29,8 +29,8 @@ namespace mln::concepts
template <typename SE>
concept DynamicStructuringElement =
requires (SE se) {
{ se.radial_extent() } -> int
};
{ se.radial_extent() } -> int
};
constexpr bool implies(bool a, bool b) { return !a || b; }
......@@ -39,7 +39,7 @@ namespace mln::concepts
template <typename SE, typename P>
concept StructuringElement =
std::is_base_of_v<mln::experimental::StructuringElement<SE>, SE> &&
stl::ConvertibleTo<SE, mln::experimental::StructuringElement<SE>> &&
stl::RegularInvocable<SE, P> &&
stl::RegularInvocable<SE, mln::archetypes::PixelT<P>> &&
requires {
......@@ -51,12 +51,14 @@ namespace mln::concepts
stl::ConvertibleTo<typename SE::category, mln::adaptative_neighborhood_tag> &&
details::implies(stl::ConvertibleTo<typename SE::category, mln::dynamic_neighborhood_tag>,
details::DynamicStructuringElement<SE>) &&
requires (SE se, P p, mln::archetypes::PixelT<P> px) {
{ se(p) } -> stl::ForwardRange&&;
{ se(px) } -> stl::ForwardRange&&;
requires (SE se, const SE cse, P p, mln::archetypes::PixelT<P> px) {
{ se(p) } -> stl::ForwardRange&&;
{ se(px) } -> stl::ForwardRange&&;
{ cse.offsets() } -> stl::ForwardRange&&;
requires detail::RangeValueTypeConvertibleTo<decltype(se(p)), P>;
requires detail::RangeValueTypeConvertibleTo<decltype(se(px)), mln::archetypes::PixelT<P>>;
requires detail::RangeValueTypeConvertibleTo<decltype(cse.offsets()), P>;
};
namespace details
......@@ -71,10 +73,10 @@ namespace mln::concepts
template <typename SE, typename P>
concept DecomposableStructuringElement =
StructuringElement<SE, P> &&
stl::Same<typename SE::decomposable, std::true_type> &&
stl::ConvertibleTo<typename SE::decomposable, std::true_type> &&
requires(const SE se) {
{ se.is_decomposable() } -> bool;
{ se.decompose() } -> stl::ForwardRange&&;
{ se.is_decomposable() } -> bool;
{ se.decompose() } -> stl::ForwardRange&&;
requires details::RangeOfStructuringElement<decltype(se.decompose()), P>;
};
......@@ -82,21 +84,21 @@ namespace mln::concepts
template <typename SE, typename P>
concept SeparableStructuringElement =
StructuringElement<SE, P> &&
stl::Same<typename SE::separable, std::true_type> &&
stl::ConvertibleTo<typename SE::separable, std::true_type> &&
requires(const SE se) {
{ se.is_separable() } -> bool;
{ se.separate() } -> stl::ForwardRange&&;
{ se.separate() } -> stl::ForwardRange&&;
requires details::RangeOfStructuringElement<decltype(se.separate()), P>;
};
};
template <typename SE, typename P>
concept IncrementalStructuringElement =
StructuringElement<SE, P> &&
stl::Same<typename SE::incremental, std::true_type> &&
stl::ConvertibleTo<typename SE::incremental, std::true_type> &&
requires(const SE se) {
{ se.inc() } -> StructuringElement<P>&&;
{ se.dec() } -> StructuringElement<P>&&;
{ se.inc() } -> StructuringElement<P>&&;
{ se.dec() } -> StructuringElement<P>&&;
};
#endif
// clang-format on
......
#pragma once
#include <mln/core/concept/new/structuring_elements.hpp>
#include <mln/core/extension/extension_traits.hpp>
#include <mln/core/image/image.hpp>
#include <mln/core/image/morphers/extended_by_value_image.hpp>
......@@ -133,5 +134,13 @@ namespace mln
typename N::category());
}
template <class I, class SE>
bool need_adjust(const mln::experimental::Image<I>& ima, const mln::experimental::StructuringElement<SE>& se)
{
return extension::impl::need_adjust(static_cast<const I&>(ima), static_cast<const SE&>(se),
image_extension_category_t<I>(), typename SE::category());
}
} // namespace extension
} // namespace mln
} // end of namespace mln
#pragma once
#include <mln/core/concept/new/se.hpp>
#include <mln/core/concept/new/structuring_elements.hpp>
#include <mln/core/image/private/image_traits.hpp>
#include <any>
/// \file
namespace mln
......@@ -16,16 +15,16 @@ namespace mln
/// an initialization value.
struct image_build_params
{
int border = -1; ///< Border value (-1 for non requested)
std::any init_value; ///< Initialization value (can be empty)
int border = -1; ///< Border value (-1 for non requested)
std::any init_value; ///< Initialization value (can be empty)
};
/// \brief Error code returned by \ref image_builder or \ref image_resizer
enum image_build_error_code
{
IMAGE_BUILD_OK = 0,
IMAGE_BUILD_NO_BORDER = 0x01,
IMAGE_BUILD_OK = 0,
IMAGE_BUILD_NO_BORDER = 0x01,
IMAGE_BUILD_UNSUPPORTED_SE = 0x02,
};
......@@ -51,7 +50,7 @@ namespace mln
/// Retrieve the error code in the variable pointed by \p err. If `build()` encounters an error, it will be set
/// according to the error type.
void get_status(image_build_error_code * err);
void get_status(image_build_error_code* err);
image_build_params m_params;
image_build_error_code m_status = IMAGE_BUILD_OK;
......@@ -70,7 +69,6 @@ namespace mln
using base = details::image_builder_base;
public:
/// \brief Create a builder initializing from \p from
image_builder(const From& from);
......@@ -81,33 +79,50 @@ namespace mln
// auto result = image_builder<I>(from)
// {
image_builder(const image_builder&) = delete;
image_builder(image_builder&&) = delete;
image_builder& operator=(const image_builder&) = delete;
image_builder(image_builder&&) = delete;
image_builder& operator=(const image_builder&) = delete;
image_builder& operator=(image_builder&&) = delete;
// }
/// Override the initialization parameters with those from \p params.
image_builder& set_params(const image_build_params& params) { base::set_params(params); return *this; }
image_builder& set_params(const image_build_params& params)
{
base::set_params(params);
return *this;
}
/// Override the initialization border parameter with \p border.
image_builder& set_border(int border)
{
if (!image_has_border<I>())
m_status = IMAGE_BUILD_NO_BORDER;
base::set_border(border); return *this;
base::set_border(border);
return *this;
}
/// Override the initialization border parameter to be *at least* the radial extent of
/// \p nbh. If the radial extent is less than the current border initialization parameter, it has no effet.
template <class SE>
image_builder& adjust(const SE& nbh) { base::adjust(nbh); return *this; }
image_builder& adjust(const SE& nbh)
{
base::adjust(nbh);
return *this;
}
/// Override the initialization value parameter with \p v.
image_builder& set_init_value(image_value_t<I> v) { base::set_init_value(v); return *this; }
image_builder& set_init_value(image_value_t<I> v)
{
base::set_init_value(v);
return *this;
}
/// Retrieve the error code in the variable pointed by \p err. If `build()` encounters an error, it will be set
/// according to the error type.
image_builder& get_status(image_build_error_code* err) { base::get_status(err); return *this; }
image_builder& get_status(image_build_error_code* err)
{
base::get_status(err);
return *this;
}
/// Build and return the new image
I build() const;
......@@ -125,11 +140,11 @@ namespace mln
template <class To, class From>
class image_resizer : protected details::image_builder_base
{
// TODO: static assert that "to.resize(from.domain(), image_build_params)" is well formed (and add a concept for that)
// TODO: static assert that "to.resize(from.domain(), image_build_params)" is well formed (and add a concept for
// that)
using base = details::image_builder_base;
public:
/// \brief Create a builder initializing \p to from \p from
image_resizer(To& to, const From& from);
......@@ -140,13 +155,17 @@ namespace mln
// auto result = image_resizer<I>(from)
// {
image_resizer(const image_resizer&) = delete;
image_resizer(image_resizer&&) = delete;
image_resizer& operator=(const image_resizer&) = delete;
image_resizer(image_resizer&&) = delete;
image_resizer& operator=(const image_resizer&) = delete;
image_resizer& operator=(image_resizer&&) = delete;
// }
/// Override the initialization parameters with those from \p params.
image_resizer& set_params(const image_build_params& params) { base::set_params(params); return *this; }
image_resizer& set_params(const image_build_params& params)
{
base::set_params(params);
return *this;
}
/// Override the initialization border parameter with \p border.
image_resizer& set_border(int border)
......@@ -161,14 +180,26 @@ namespace mln
/// Override the initialization border parameter to be *at least* the radial extent of
/// \p nbh. If the radial extent is less than the current border initialization parameter, it has no effet.
template <class SE>
image_resizer& adjust(const SE& nbh) { base::adjust(nbh); return *this; }
image_resizer& adjust(const SE& nbh)
{
base::adjust(nbh);
return *this;
}
/// Override the initialization value parameter with \p v.
image_resizer& set_init_value(image_value_t<To> v) { base::set_init_value(v); return *this; }
image_resizer& set_init_value(image_value_t<To> v)
{
base::set_init_value(v);
return *this;
}
/// Retrieve the error code in the variable pointed by \p err. If `build()` encounters an error, it will be set
/// according to the error type.
image_resizer& get_status(image_build_error_code* err) { base::get_status(err); return *this; }
image_resizer& get_status(image_build_error_code* err)
{
base::get_status(err);
return *this;
}
/// Resize the image
void resize() const;
......@@ -210,7 +241,6 @@ namespace mln
}
/******************************************/
/**** Implementation ****/
/******************************************/
......@@ -218,15 +248,9 @@ namespace mln
namespace details
{
inline void image_builder_base::set_params(const image_build_params& params)
{
m_params = params;
}
inline void image_builder_base::set_params(const image_build_params& params) { m_params = params; }
inline void image_builder_base::set_border(int border)
{
m_params.border = border;
}
inline void image_builder_base::set_border(int border) { m_params.border = border; }
template <class T>
void image_builder_base::set_init_value(T&& v)
......@@ -234,15 +258,12 @@ namespace mln
m_params.init_value = std::forward<T>(v);
}
inline void image_builder_base::get_status(image_build_error_code* err)
{
m_status_ptr = err;
}