Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2024-11-15 09:10:41

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 // This file was modified by Oracle on 2014-2021.
0008 // Modifications copyright (c) 2014-2021 Oracle and/or its affiliates.
0009 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0010 
0011 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0012 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0013 
0014 // Use, modification and distribution is subject to the Boost Software License,
0015 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0016 // http://www.boost.org/LICENSE_1_0.txt)
0017 
0018 #ifndef BOOST_GEOMETRY_CORE_CLOSURE_HPP
0019 #define BOOST_GEOMETRY_CORE_CLOSURE_HPP
0020 
0021 #include <boost/range/value_type.hpp>
0022 
0023 #include <boost/geometry/core/ring_type.hpp>
0024 #include <boost/geometry/core/static_assert.hpp>
0025 #include <boost/geometry/core/tag.hpp>
0026 #include <boost/geometry/core/tags.hpp>
0027 #include <boost/geometry/util/type_traits_std.hpp>
0028 
0029 namespace boost { namespace geometry
0030 {
0031 
0032 
0033 /*!
0034 \brief Enumerates options for defining if polygons are open or closed
0035 \ingroup enum
0036 \details The enumeration closure_selector describes options for if a polygon is
0037     open or closed. In a closed polygon the very first point (per ring) should
0038     be equal to the very last point.
0039     The specific closing property of a polygon type is defined by the closure
0040     metafunction. The closure metafunction defines a value, which is one of the
0041     values enumerated in the closure_selector
0042 
0043 \qbk{
0044 [heading See also]
0045 [link geometry.reference.core.closure The closure metafunction]
0046 }
0047 */
0048 enum closure_selector
0049 {
0050     /// Rings are open: first point and last point are different, algorithms
0051     /// close them explicitly on the fly
0052     open = 0,
0053     /// Rings are closed: first point and last point must be the same
0054     closed = 1,
0055     /// (Not yet implemented): algorithms first figure out if ring must be
0056     /// closed on the fly
0057     closure_undertermined = -1
0058 };
0059 
0060 namespace traits
0061 {
0062 
0063 /*!
0064     \brief Traits class indicating if points within a
0065         ring or (multi)polygon are closed (last point == first point),
0066         open or not known.
0067     \ingroup traits
0068     \par Geometries:
0069         - ring
0070     \tparam G geometry
0071 */
0072 template <typename G>
0073 struct closure
0074 {
0075     static const closure_selector value = closed;
0076 };
0077 
0078 
0079 } // namespace traits
0080 
0081 
0082 #ifndef DOXYGEN_NO_DETAIL
0083 namespace core_detail { namespace closure
0084 {
0085 
0086 struct closed
0087 {
0088     static const closure_selector value = geometry::closed;
0089 };
0090 
0091 
0092 /// Metafunction to define the minimum size of a ring:
0093 /// 3 for open rings, 4 for closed rings
0094 template <closure_selector Closure>
0095 struct minimum_ring_size {};
0096 
0097 template <>
0098 struct minimum_ring_size<geometry::closed>
0099     : std::integral_constant<std::size_t, 4>
0100 {};
0101 
0102 template <>
0103 struct minimum_ring_size<geometry::open>
0104     : std::integral_constant<std::size_t, 3>
0105 {};
0106 
0107 
0108 }} // namespace core_detail::closure
0109 #endif // DOXYGEN_NO_DETAIL
0110 
0111 
0112 
0113 #ifndef DOXYGEN_NO_DISPATCH
0114 namespace core_dispatch
0115 {
0116 
0117 template <typename Tag, typename Geometry>
0118 struct closure
0119 {
0120     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0121         "Not implemented for this Geometry type.",
0122         Geometry);
0123 };
0124 
0125 template <typename Box>
0126 struct closure<point_tag, Box> : public core_detail::closure::closed {};
0127 
0128 template <typename Box>
0129 struct closure<box_tag, Box> : public core_detail::closure::closed {};
0130 
0131 template <typename Box>
0132 struct closure<segment_tag, Box> : public core_detail::closure::closed {};
0133 
0134 template <typename LineString>
0135 struct closure<linestring_tag, LineString>
0136     : public core_detail::closure::closed {};
0137 
0138 
0139 template <typename Ring>
0140 struct closure<ring_tag, Ring>
0141 {
0142     static const closure_selector value
0143         = geometry::traits::closure<Ring>::value;
0144 };
0145 
0146 // Specialization for Polygon: the closure is the closure of its rings
0147 template <typename Polygon>
0148 struct closure<polygon_tag, Polygon>
0149 {
0150     static const closure_selector value = core_dispatch::closure
0151         <
0152             ring_tag,
0153             typename ring_type<polygon_tag, Polygon>::type
0154         >::value ;
0155 };
0156 
0157 template <typename MultiPoint>
0158 struct closure<multi_point_tag, MultiPoint>
0159     : public core_detail::closure::closed {};
0160 
0161 template <typename MultiLinestring>
0162 struct closure<multi_linestring_tag, MultiLinestring>
0163     : public core_detail::closure::closed {};
0164 
0165 // Specialization for MultiPolygon: the closure is the closure of Polygon's rings
0166 template <typename MultiPolygon>
0167 struct closure<multi_polygon_tag, MultiPolygon>
0168 {
0169     static const closure_selector value = core_dispatch::closure
0170         <
0171             polygon_tag,
0172             typename boost::range_value<MultiPolygon>::type
0173         >::value ;
0174 };
0175 
0176 } // namespace core_dispatch
0177 #endif // DOXYGEN_NO_DISPATCH
0178 
0179 
0180 /*!
0181 \brief \brief_meta{value, closure (clockwise\, counterclockwise),
0182     \meta_geometry_type}
0183 \tparam Geometry \tparam_geometry
0184 \ingroup core
0185 
0186 \qbk{[include reference/core/closure.qbk]}
0187 */
0188 template <typename Geometry>
0189 struct closure
0190 {
0191     static const closure_selector value = core_dispatch::closure
0192         <
0193             typename tag<Geometry>::type,
0194             typename util::remove_cptrref<Geometry>::type
0195         >::value;
0196 };
0197 
0198 
0199 #ifndef DOXYGEN_NO_DETAIL
0200 namespace detail
0201 {
0202 
0203 template
0204 <
0205     typename Geometry,
0206     closure_selector Closure = geometry::closure<Geometry>::value
0207 >
0208 using minimum_ring_size = core_detail::closure::minimum_ring_size<Closure>;
0209 
0210 } // namespace detail
0211 #endif // DOXYGEN_NO_DETAIL
0212 
0213 
0214 }} // namespace boost::geometry
0215 
0216 
0217 #endif // BOOST_GEOMETRY_CORE_CLOSURE_HPP