Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // Boost.Geometry (aka GGL, Generic Geometry Library)
0002 
0003 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
0004 
0005 // This file was modified by Oracle on 2018-2020.
0006 // Modifications copyright (c) 2018-2020, Oracle and/or its affiliates.
0007 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0008 
0009 // Use, modification and distribution is subject to the Boost Software License,
0010 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0011 // http://www.boost.org/LICENSE_1_0.txt)
0012 
0013 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
0014 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP
0015 
0016 #include <boost/range/algorithm/reverse.hpp>
0017 
0018 #include <boost/geometry/algorithms/convert.hpp>
0019 #include <boost/geometry/algorithms/num_points.hpp>
0020 
0021 #include <boost/geometry/core/exterior_ring.hpp>
0022 #include <boost/geometry/core/interior_rings.hpp>
0023 #include <boost/geometry/core/static_assert.hpp>
0024 #include <boost/geometry/core/tags.hpp>
0025 
0026 namespace boost { namespace geometry
0027 {
0028 
0029 
0030 #ifndef DOXYGEN_NO_DETAIL
0031 namespace detail { namespace overlay
0032 {
0033 
0034 
0035 template<typename Tag>
0036 struct convert_ring
0037 {
0038     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0039         "Not or not yet implemented for this geometry Tag.",
0040         Tag);
0041 };
0042 
0043 template<>
0044 struct convert_ring<ring_tag>
0045 {
0046     template<typename Destination, typename Source>
0047     static inline void apply(Destination& destination, Source const& source,
0048                 bool append, bool reverse)
0049     {
0050         if (! append)
0051         {
0052             geometry::convert(source, destination);
0053             if (reverse)
0054             {
0055                 boost::reverse(destination);
0056             }
0057         }
0058     }
0059 };
0060 
0061 
0062 template<>
0063 struct convert_ring<polygon_tag>
0064 {
0065     template<typename Destination, typename Source>
0066     static inline void apply(Destination& destination, Source const& source,
0067                 bool append, bool reverse)
0068     {
0069         if (! append)
0070         {
0071             geometry::convert(source, exterior_ring(destination));
0072             if (reverse)
0073             {
0074                 boost::reverse(exterior_ring(destination));
0075             }
0076         }
0077         else
0078         {
0079             // Avoid adding interior rings which are invalid
0080             // because of its number of points:
0081             std::size_t const min_num_points
0082                     = core_detail::closure::minimum_ring_size
0083                             <
0084                                 geometry::closure<Destination>::value
0085                             >::value;
0086 
0087             if (geometry::num_points(source) >= min_num_points)
0088             {
0089                 // TODO: resize and .size() and .back() should not be called here
0090                 interior_rings(destination).resize(
0091                             interior_rings(destination).size() + 1);
0092                 geometry::convert(source, interior_rings(destination).back());
0093                 if (reverse)
0094                 {
0095                     boost::reverse(interior_rings(destination).back());
0096                 }
0097             }
0098         }
0099     }
0100 };
0101 
0102 
0103 }} // namespace detail::overlay
0104 #endif // DOXYGEN_NO_DETAIL
0105 
0106 
0107 }} // namespace boost::geometry
0108 
0109 
0110 #endif // BOOST_GEOMETRY_ALGORITHMS_DETAIL_OVERLAY_CONVERT_RING_HPP