From b7054cffc2db9bc9be5a463cac80558602fb746f Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Mon, 3 Feb 2014 18:38:04 +0100 Subject: [PATCH] front() and back() helper functions moved to separate file, updated copyright info --- .../algorithms/detail/range_helpers.hpp | 62 +++++++++++++++++++ .../detail/relate/linear_linear.hpp | 48 +++----------- .../algorithms/detail/relate/relate.hpp | 6 +- 3 files changed, 74 insertions(+), 42 deletions(-) create mode 100644 include/boost/geometry/algorithms/detail/range_helpers.hpp diff --git a/include/boost/geometry/algorithms/detail/range_helpers.hpp b/include/boost/geometry/algorithms/detail/range_helpers.hpp new file mode 100644 index 000000000..75cddcb78 --- /dev/null +++ b/include/boost/geometry/algorithms/detail/range_helpers.hpp @@ -0,0 +1,62 @@ +// Boost.Geometry (aka GGL, Generic Geometry Library) + +// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. + +// This file was modified by Oracle on 2013, 2014. +// Modifications copyright (c) 2013-2014 Oracle and/or its affiliates. + +// Use, modification and distribution is subject to the Boost Software License, +// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + +#ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RANGE_HELPERS_HPP +#define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RANGE_HELPERS_HPP + +#include + +namespace boost { namespace geometry +{ + +#ifndef DOXYGEN_NO_DETAIL +namespace detail { namespace range { + +template +inline typename boost::range_value::type const& +front(Range const& rng) +{ + BOOST_ASSERT(!boost::empty(rng)); + return *boost::begin(rng); +} + +template +inline typename boost::range_value::type & +front(Range & rng) +{ + BOOST_ASSERT(!boost::empty(rng)); + return *boost::begin(rng); +} + +template +inline typename boost::range_value::type const& +back(Range const& rng) +{ + BOOST_ASSERT(!boost::empty(rng)); + return *(--boost::end(rng)); +} + +template +inline typename boost::range_value::type & +back(Range & rng) +{ + BOOST_ASSERT(!boost::empty(rng)); + return *(--boost::end(rng)); +} + +}} // namespace detail::range +#endif // DOXYGEN_NO_DETAIL + +}} // namespace boost::geometry + +#endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_RANGE_HELPERS_HPP diff --git a/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp b/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp index 7f265ac33..a60d96d7e 100644 --- a/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp +++ b/include/boost/geometry/algorithms/detail/relate/linear_linear.hpp @@ -2,8 +2,8 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013. -// Modifications copyright (c) 2013, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014. +// Modifications copyright (c) 2013-2014 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at @@ -17,7 +17,7 @@ #include #include -#include +#include namespace boost { namespace geometry { @@ -25,38 +25,6 @@ namespace boost { namespace geometry #ifndef DOXYGEN_NO_DETAIL namespace detail { namespace relate { -template -inline typename boost::range_value::type const& -front(Range const& rng) -{ - BOOST_ASSERT(!boost::empty(rng)); - return *boost::begin(rng); -} - -template -inline typename boost::range_value::type & -front(Range & rng) -{ - BOOST_ASSERT(!boost::empty(rng)); - return *boost::begin(rng); -} - -template -inline typename boost::range_value::type const& -back(Range const& rng) -{ - BOOST_ASSERT(!boost::empty(rng)); - return *(--boost::end(rng)); -} - -template -inline typename boost::range_value::type & -back(Range & rng) -{ - BOOST_ASSERT(!boost::empty(rng)); - return *(--boost::end(rng)); -} - // currently works only for linestrings template struct linear_linear @@ -76,15 +44,15 @@ struct linear_linear } else if ( s1 == 1 && s2 == 1 ) { - return point_point::apply(front(geometry1), front(geometry2)); + return point_point::apply(range::front(geometry1), range::front(geometry2)); } else if ( s1 == 1 /*&& s2 > 1*/ ) { - return point_geometry::apply(front(geometry1), geometry2); + return point_geometry::apply(range::front(geometry1), geometry2); } else if ( s2 == 1 /*&& s1 > 1*/ ) { - return geometry_point::apply(geometry1, front(geometry2)); + return geometry_point::apply(geometry1, range::front(geometry2)); } // TODO: handle also linestrings with points_num == 2 and equals(front, back) - treat like point? @@ -95,8 +63,8 @@ struct linear_linear res.template set(); // TODO: implement generic function working also for multilinestrings, also use it in point_in_geometry - bool has_boundary1 = ! detail::equals::equals_point_point(front(geometry1), back(geometry1)); - bool has_boundary2 = ! detail::equals::equals_point_point(front(geometry2), back(geometry2)); + bool has_boundary1 = ! detail::equals::equals_point_point(range::front(geometry1), range::back(geometry1)); + bool has_boundary2 = ! detail::equals::equals_point_point(range::front(geometry2), range::back(geometry2)); handle_boundaries(res, geometry1, geometry2, has_boundary1, has_boundary2); diff --git a/include/boost/geometry/algorithms/detail/relate/relate.hpp b/include/boost/geometry/algorithms/detail/relate/relate.hpp index 04d595670..22740feb6 100644 --- a/include/boost/geometry/algorithms/detail/relate/relate.hpp +++ b/include/boost/geometry/algorithms/detail/relate/relate.hpp @@ -2,13 +2,15 @@ // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. -// This file was modified by Oracle on 2013. -// Modifications copyright (c) 2013, Oracle and/or its affiliates. +// This file was modified by Oracle on 2013, 2014. +// Modifications copyright (c) 2013-2014 Oracle and/or its affiliates. // Use, modification and distribution is subject to the Boost Software License, // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle + #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_RELATE_HPP #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_RELATE_HPP