Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:17

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
0005 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
0006 
0007 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0008 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0009 
0010 // Use, modification and distribution is subject to the Boost Software License,
0011 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0012 // http://www.boost.org/LICENSE_1_0.txt)
0013 
0014 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_BOX_CORNERS_HPP
0015 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_BOX_CORNERS_HPP
0016 
0017 
0018 #include <cstddef>
0019 
0020 #include <boost/geometry/geometries/concepts/check.hpp>
0021 #include <boost/geometry/algorithms/detail/assign_values.hpp>
0022 #include <boost/geometry/util/range.hpp>
0023 
0024 
0025 namespace boost { namespace geometry
0026 {
0027 
0028 #ifndef DOXYGEN_NO_DETAIL
0029 namespace detail
0030 {
0031 // Note: this is moved to namespace detail because the names and parameter orders
0032 // are not yet 100% clear.
0033 
0034 /*!
0035 \brief Assign the four points of a 2D box
0036 \ingroup assign
0037 \note The order is crucial. Most logical is LOWER, UPPER and sub-order LEFT, RIGHT
0038     so this is how it is implemented.
0039 \tparam Box \tparam_box
0040 \tparam Point \tparam_point
0041 \param box \param_box
0042 \param lower_left point being assigned to lower left coordinates of the box
0043 \param lower_right point being assigned to lower right coordinates of the box
0044 \param upper_left point being assigned to upper left coordinates of the box
0045 \param upper_right point being assigned to upper right coordinates of the box
0046 
0047 \qbk{
0048 [heading Example]
0049 [assign_box_corners] [assign_box_corners_output]
0050 }
0051 */
0052 template <typename Box, typename Point>
0053 inline void assign_box_corners(Box const& box,
0054         Point& lower_left, Point& lower_right,
0055         Point& upper_left, Point& upper_right)
0056 {
0057     concepts::check<Box const>();
0058     concepts::check<Point>();
0059 
0060     detail::assign::assign_box_2d_corner
0061             <min_corner, min_corner>(box, lower_left);
0062     detail::assign::assign_box_2d_corner
0063             <max_corner, min_corner>(box, lower_right);
0064     detail::assign::assign_box_2d_corner
0065             <min_corner, max_corner>(box, upper_left);
0066     detail::assign::assign_box_2d_corner
0067             <max_corner, max_corner>(box, upper_right);
0068 }
0069 
0070 // Silence warning C4127: conditional expression is constant
0071 #if defined(_MSC_VER)
0072 #pragma warning(push)
0073 #pragma warning(disable : 4127)
0074 #endif
0075 
0076 
0077 template <bool Reverse, typename Box, typename Range>
0078 inline void assign_box_corners_oriented(Box const& box, Range& corners)
0079 {
0080     if (Reverse)
0081     {
0082         // make counterclockwise ll,lr,ur,ul
0083         assign_box_corners(box,
0084                            range::at(corners, 0), range::at(corners, 1),
0085                            range::at(corners, 3), range::at(corners, 2));
0086     }
0087     else
0088     {
0089         // make clockwise ll,ul,ur,lr
0090         assign_box_corners(box,
0091                            range::at(corners, 0), range::at(corners, 3),
0092                            range::at(corners, 1), range::at(corners, 2));
0093     }
0094 }
0095 #if defined(_MSC_VER)
0096 #pragma warning(pop)
0097 #endif
0098 
0099 
0100 } // namespace detail
0101 #endif // DOXYGEN_NO_DETAIL
0102 
0103 
0104 }} // namespace boost::geometry
0105 
0106 
0107 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_ASSIGN_BOX_CORNERS_HPP