Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 09:50:10

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 // Copyright (c) 2024 Adam Wulkiewicz, Lodz, Poland.
0007 
0008 // This file was modified by Oracle on 2014-2020.
0009 // Modifications copyright (c) 2014-2020 Oracle and/or its affiliates.
0010 // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
0011 
0012 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
0013 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
0014 
0015 // Use, modification and distribution is subject to the Boost Software License,
0016 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0017 // http://www.boost.org/LICENSE_1_0.txt)
0018 
0019 #ifndef BOOST_GEOMETRY_CORE_POINT_ORDER_HPP
0020 #define BOOST_GEOMETRY_CORE_POINT_ORDER_HPP
0021 
0022 
0023 #include <boost/range/value_type.hpp>
0024 
0025 #include <boost/geometry/core/ring_type.hpp>
0026 #include <boost/geometry/core/static_assert.hpp>
0027 #include <boost/geometry/core/tag.hpp>
0028 #include <boost/geometry/core/tags.hpp>
0029 #include <boost/geometry/util/type_traits_std.hpp>
0030 
0031 namespace boost { namespace geometry
0032 {
0033 
0034 /*!
0035 \brief Enumerates options for the order of points within polygons
0036 \ingroup enum
0037 \details The enumeration order_selector describes options for the order of
0038     points within a polygon. Polygons can be ordered either clockwise or
0039     counterclockwise. The specific order of a polygon type is defined by the
0040     point_order metafunction. The point_order metafunction defines a value,
0041     which is one of the values enumerated in the order_selector
0042 
0043 \qbk{
0044 [heading See also]
0045 [link geometry.reference.core.point_order The point_order metafunction]
0046 }
0047 */
0048 enum order_selector
0049 {
0050     /// Points are ordered clockwise
0051     clockwise = 1,
0052     /// Points are ordered counter clockwise
0053     counterclockwise = 2,
0054     /// Points might be stored in any order, algorithms will determine it on the
0055     /// fly (not yet supported)
0056     order_undetermined = 0
0057 };
0058 
0059 namespace traits
0060 {
0061 
0062 /*!
0063 \brief Traits class indicating the order of contained points within a
0064     ring or (multi)polygon, clockwise, counter clockwise or not known.
0065 \ingroup traits
0066 \tparam Ring ring
0067 */
0068 template <typename Ring>
0069 struct point_order
0070 {
0071     static const order_selector value = clockwise;
0072 };
0073 
0074 
0075 } // namespace traits
0076 
0077 
0078 #ifndef DOXYGEN_NO_DETAIL
0079 namespace detail { namespace point_order
0080 {
0081 
0082 struct clockwise
0083 {
0084     static const order_selector value = geometry::clockwise;
0085 };
0086 
0087 
0088 }} // namespace detail::point_order
0089 #endif // DOXYGEN_NO_DETAIL
0090 
0091 
0092 
0093 #ifndef DOXYGEN_NO_DISPATCH
0094 namespace core_dispatch
0095 {
0096 
0097 template <typename Tag, typename Geometry>
0098 struct point_order
0099 {
0100     BOOST_GEOMETRY_STATIC_ASSERT_FALSE(
0101         "Not implemented for this Geometry type.",
0102         Geometry);
0103 };
0104 
0105 template <typename Point>
0106 struct point_order<point_tag, Point>
0107     : public detail::point_order::clockwise {};
0108 
0109 template <typename Segment>
0110 struct point_order<segment_tag, Segment>
0111     : public detail::point_order::clockwise {};
0112 
0113 
0114 template <typename Box>
0115 struct point_order<box_tag, Box>
0116     : public detail::point_order::clockwise {};
0117 
0118 template <typename LineString>
0119 struct point_order<linestring_tag, LineString>
0120     : public detail::point_order::clockwise {};
0121 
0122 
0123 template <typename Ring>
0124 struct point_order<ring_tag, Ring>
0125 {
0126     static const order_selector value
0127         = geometry::traits::point_order<Ring>::value;
0128 };
0129 
0130 // Specialization for polygon: the order is the order of its rings
0131 template <typename Polygon>
0132 struct point_order<polygon_tag, Polygon>
0133 {
0134     static const order_selector value = core_dispatch::point_order
0135         <
0136             ring_tag,
0137             typename ring_type<polygon_tag, Polygon>::type
0138         >::value ;
0139 };
0140 
0141 template <typename MultiPoint>
0142 struct point_order<multi_point_tag, MultiPoint>
0143     : public detail::point_order::clockwise {};
0144 
0145 template <typename MultiLinestring>
0146 struct point_order<multi_linestring_tag, MultiLinestring>
0147     : public detail::point_order::clockwise {};
0148 
0149 
0150 // Specialization for multi_polygon: the order is the order of its polygons
0151 template <typename MultiPolygon>
0152 struct point_order<multi_polygon_tag, MultiPolygon>
0153 {
0154     static const order_selector value = core_dispatch::point_order
0155         <
0156             polygon_tag,
0157             typename boost::range_value<MultiPolygon>::type
0158         >::value ;
0159 };
0160 
0161 } // namespace core_dispatch
0162 #endif // DOXYGEN_NO_DISPATCH
0163 
0164 
0165 /*!
0166 \brief \brief_meta{value, point order (clockwise\, counterclockwise),
0167     \meta_geometry_type}
0168 \tparam Geometry \tparam_geometry
0169 \ingroup core
0170 
0171 \qbk{[include reference/core/point_order.qbk]}
0172 */
0173 template <typename Geometry>
0174 struct point_order
0175     : std::integral_constant
0176         <
0177             order_selector,
0178             core_dispatch::point_order
0179                 <
0180                     tag_t<Geometry>,
0181                     util::remove_cptrref_t<Geometry>
0182                 >::value
0183         >
0184 {};
0185 
0186 
0187 #ifndef BOOST_NO_CXX17_INLINE_VARIABLES
0188 template <typename Geometry>
0189 inline constexpr order_selector point_order_v = point_order<Geometry>::value;
0190 #endif
0191 
0192 
0193 }} // namespace boost::geometry
0194 
0195 #endif // BOOST_GEOMETRY_CORE_POINT_ORDER_HPP