Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-05 08:33:07

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 // This file was modified by Oracle on 2018-2021.
0011 // Modifications copyright (c) 2018-2021, Oracle and/or its affiliates.
0012 
0013 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
0014 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0015 
0016 // Use, modification and distribution is subject to the Boost Software License,
0017 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0018 // http://www.boost.org/LICENSE_1_0.txt)
0019 
0020 #ifndef BOOST_GEOMETRY_ALGORITHMS_ASSIGN_VALUES_HPP
0021 #define BOOST_GEOMETRY_ALGORITHMS_ASSIGN_VALUES_HPP
0022 
0023 
0024 #include <cstddef>
0025 #include <type_traits>
0026 
0027 #include <boost/concept/requires.hpp>
0028 #include <boost/concept_check.hpp>
0029 
0030 #include <boost/geometry/algorithms/append.hpp>
0031 #include <boost/geometry/algorithms/clear.hpp>
0032 #include <boost/geometry/core/access.hpp>
0033 #include <boost/geometry/core/exterior_ring.hpp>
0034 #include <boost/geometry/core/static_assert.hpp>
0035 #include <boost/geometry/core/tags.hpp>
0036 
0037 #include <boost/geometry/geometries/concepts/check.hpp>
0038 
0039 #include <boost/geometry/util/algorithm.hpp>
0040 #include <boost/geometry/util/bounds.hpp>
0041 #include <boost/geometry/util/numeric_cast.hpp>
0042 
0043 
0044 namespace boost { namespace geometry
0045 {
0046 
0047 #ifndef DOXYGEN_NO_DETAIL
0048 namespace detail { namespace assign
0049 {
0050 
0051 
0052 struct assign_zero_point
0053 {
0054     template <typename Point>
0055     static inline void apply(Point& point)
0056     {
0057         typedef typename coordinate_type<Point>::type coordinate_type;
0058 
0059         coordinate_type const zero = 0;
0060         detail::for_each_dimension<Point>([&](auto dimension)
0061         {
0062             set<dimension>(point, zero);
0063         });
0064     }
0065 };
0066 
0067 
0068 struct assign_inverse_box_or_segment
0069 {
0070 
0071     template <typename BoxOrSegment>
0072     static inline void apply(BoxOrSegment& geometry)
0073     {
0074         typedef typename coordinate_type<BoxOrSegment>::type coordinate_type;
0075 
0076         coordinate_type const highest = util::bounds<coordinate_type>::highest();
0077         coordinate_type const lowest = util::bounds<coordinate_type>::lowest();
0078         detail::for_each_dimension<BoxOrSegment>([&](auto dimension)
0079         {
0080             set<0, dimension>(geometry, highest);
0081             set<1, dimension>(geometry, lowest);
0082         });
0083     }
0084 
0085 };
0086 
0087 
0088 struct assign_zero_box_or_segment
0089 {
0090     template <typename BoxOrSegment>
0091     static inline void apply(BoxOrSegment& geometry)
0092     {
0093         typedef typename coordinate_type<BoxOrSegment>::type coordinate_type;
0094 
0095         coordinate_type const zero = 0;
0096         detail::for_each_dimension<BoxOrSegment>([&](auto dimension)
0097         {
0098             set<0, dimension>(geometry, zero);
0099             set<1, dimension>(geometry, zero);
0100         });
0101     }
0102 };
0103 
0104 
0105 template
0106 <
0107     std::size_t Corner1, std::size_t Corner2,
0108     typename Box, typename Point
0109 >
0110 inline void assign_box_2d_corner(Box const& box, Point& point)
0111 {
0112     // Be sure both are 2-Dimensional
0113     assert_dimension<Box, 2>();
0114     assert_dimension<Point, 2>();
0115 
0116     // Copy coordinates
0117     typedef typename coordinate_type<Point>::type coordinate_type;
0118 
0119     geometry::set<0>(point, util::numeric_cast<coordinate_type>(get<Corner1, 0>(box)));
0120     geometry::set<1>(point, util::numeric_cast<coordinate_type>(get<Corner2, 1>(box)));
0121 }
0122 
0123 
0124 
0125 template <typename Geometry>
0126 struct assign_2d_box_or_segment
0127 {
0128     typedef typename coordinate_type<Geometry>::type coordinate_type;
0129 
0130     // Here we assign 4 coordinates to a box of segment
0131     // -> Most logical is: x1,y1,x2,y2
0132     // In case the user reverses x1/x2 or y1/y2, for a box, we could reverse them (THAT IS NOT IMPLEMENTED)
0133 
0134     template <typename Type>
0135     static inline void apply(Geometry& geometry,
0136                 Type const& x1, Type const& y1, Type const& x2, Type const& y2)
0137     {
0138         geometry::set<0, 0>(geometry, util::numeric_cast<coordinate_type>(x1));
0139         geometry::set<0, 1>(geometry, util::numeric_cast<coordinate_type>(y1));
0140         geometry::set<1, 0>(geometry, util::numeric_cast<coordinate_type>(x2));
0141         geometry::set<1, 1>(geometry, util::numeric_cast<coordinate_type>(y2));
0142     }
0143 };
0144 
0145 
0146 }} // namespace detail::assign
0147 #endif // DOXYGEN_NO_DETAIL
0148 
0149 #ifndef DOXYGEN_NO_DISPATCH
0150 namespace dispatch
0151 {
0152 
0153 template <typename GeometryTag, typename Geometry, std::size_t DimensionCount>
0154 struct assign
0155 {
0156     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0157         "Not or not yet implemented for this Geometry type.",
0158         GeometryTag, Geometry, std::integral_constant<std::size_t, DimensionCount>);
0159 };
0160 
0161 template <typename Point>
0162 struct assign<point_tag, Point, 2>
0163 {
0164     typedef typename coordinate_type<Point>::type coordinate_type;
0165 
0166     template <typename T>
0167     static inline void apply(Point& point, T const& c1, T const& c2)
0168     {
0169         set<0>(point, util::numeric_cast<coordinate_type>(c1));
0170         set<1>(point, util::numeric_cast<coordinate_type>(c2));
0171     }
0172 };
0173 
0174 template <typename Point>
0175 struct assign<point_tag, Point, 3>
0176 {
0177     typedef typename coordinate_type<Point>::type coordinate_type;
0178 
0179     template <typename T>
0180     static inline void apply(Point& point, T const& c1, T const& c2, T const& c3)
0181     {
0182         set<0>(point, util::numeric_cast<coordinate_type>(c1));
0183         set<1>(point, util::numeric_cast<coordinate_type>(c2));
0184         set<2>(point, util::numeric_cast<coordinate_type>(c3));
0185     }
0186 };
0187 
0188 template <typename Box>
0189 struct assign<box_tag, Box, 2>
0190     : detail::assign::assign_2d_box_or_segment<Box>
0191 {};
0192 
0193 template <typename Segment>
0194 struct assign<segment_tag, Segment, 2>
0195     : detail::assign::assign_2d_box_or_segment<Segment>
0196 {};
0197 
0198 
0199 
0200 template <typename GeometryTag, typename Geometry>
0201 struct assign_zero {};
0202 
0203 
0204 template <typename Point>
0205 struct assign_zero<point_tag, Point>
0206     : detail::assign::assign_zero_point
0207 {};
0208 
0209 template <typename Box>
0210 struct assign_zero<box_tag, Box>
0211     : detail::assign::assign_zero_box_or_segment
0212 {};
0213 
0214 template <typename Segment>
0215 struct assign_zero<segment_tag, Segment>
0216     : detail::assign::assign_zero_box_or_segment
0217 {};
0218 
0219 
0220 template <typename GeometryTag, typename Geometry>
0221 struct assign_inverse {};
0222 
0223 template <typename Box>
0224 struct assign_inverse<box_tag, Box>
0225     : detail::assign::assign_inverse_box_or_segment
0226 {};
0227 
0228 template <typename Segment>
0229 struct assign_inverse<segment_tag, Segment>
0230     : detail::assign::assign_inverse_box_or_segment
0231 {};
0232 
0233 
0234 } // namespace dispatch
0235 #endif // DOXYGEN_NO_DISPATCH
0236 
0237 }} // namespace boost::geometry
0238 
0239 
0240 #endif // BOOST_GEOMETRY_ALGORITHMS_ASSIGN_VALUES_HPP