diff options
Diffstat (limited to 'boost/geometry/algorithms/detail/is_valid/box.hpp')
-rw-r--r-- | boost/geometry/algorithms/detail/is_valid/box.hpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/boost/geometry/algorithms/detail/is_valid/box.hpp b/boost/geometry/algorithms/detail/is_valid/box.hpp index f82b3f9bf1..139502af78 100644 --- a/boost/geometry/algorithms/detail/is_valid/box.hpp +++ b/boost/geometry/algorithms/detail/is_valid/box.hpp @@ -1,6 +1,6 @@ // Boost.Geometry (aka GGL, Generic Geometry Library) -// Copyright (c) 2014, Oracle and/or its affiliates. +// Copyright (c) 2014-2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle @@ -16,6 +16,7 @@ #include <boost/geometry/core/tags.hpp> #include <boost/geometry/core/coordinate_dimension.hpp> +#include <boost/geometry/algorithms/validity_failure_type.hpp> #include <boost/geometry/algorithms/dispatch/is_valid.hpp> @@ -30,15 +31,22 @@ namespace detail { namespace is_valid template <typename Box, std::size_t I> struct has_valid_corners { - static inline bool apply(Box const& box) + template <typename VisitPolicy> + static inline bool apply(Box const& box, VisitPolicy& visitor) { - if ( geometry::get<geometry::max_corner, I-1>(box) - <= - geometry::get<geometry::min_corner, I-1>(box) ) + if (math::equals(geometry::get<geometry::min_corner, I-1>(box), + geometry::get<geometry::max_corner, I-1>(box))) { - return false; + return + visitor.template apply<failure_wrong_topological_dimension>(); } - return has_valid_corners<Box, I-1>::apply(box); + else if (geometry::get<geometry::min_corner, I-1>(box) + > + geometry::get<geometry::max_corner, I-1>(box)) + { + return visitor.template apply<failure_wrong_corner_order>(); + } + return has_valid_corners<Box, I-1>::apply(box, visitor); } }; @@ -46,9 +54,10 @@ struct has_valid_corners template <typename Box> struct has_valid_corners<Box, 0> { - static inline bool apply(Box const&) + template <typename VisitPolicy> + static inline bool apply(Box const&, VisitPolicy& visitor) { - return true; + return visitor.template apply<no_failure>(); } }; |