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