Chris@16: // Boost.Geometry (aka GGL, Generic Geometry Library) Chris@16: Chris@16: // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands. Chris@16: // Copyright (c) 2008-2012 Bruno Lalande, Paris, France. Chris@16: // Copyright (c) 2009-2012 Mateusz Loskot, London, UK. Chris@16: Chris@101: // This file was modified by Oracle on 2014. Chris@101: // Modifications copyright (c) 2014 Oracle and/or its affiliates. Chris@101: Chris@101: // Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle Chris@101: Chris@16: // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library Chris@16: // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands. Chris@16: Chris@16: // Use, modification and distribution is subject to the Boost Software License, Chris@16: // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at Chris@16: // http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GEOMETRY_CORE_CLOSURE_HPP Chris@16: #define BOOST_GEOMETRY_CORE_CLOSURE_HPP Chris@16: Chris@16: #include Chris@101: #include Chris@101: #include Chris@16: #include Chris@16: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Enumerates options for defining if polygons are open or closed Chris@16: \ingroup enum Chris@16: \details The enumeration closure_selector describes options for if a polygon is Chris@101: open or closed. In a closed polygon the very first point (per ring) should Chris@16: be equal to the very last point. Chris@101: The specific closing property of a polygon type is defined by the closure Chris@101: metafunction. The closure metafunction defines a value, which is one of the Chris@16: values enumerated in the closure_selector Chris@16: Chris@16: \qbk{ Chris@16: [heading See also] Chris@16: [link geometry.reference.core.closure The closure metafunction] Chris@16: } Chris@16: */ Chris@16: enum closure_selector Chris@16: { Chris@101: /// Rings are open: first point and last point are different, algorithms Chris@16: /// close them explicitly on the fly Chris@16: open = 0, Chris@16: /// Rings are closed: first point and last point must be the same Chris@16: closed = 1, Chris@101: /// (Not yet implemented): algorithms first figure out if ring must be Chris@16: /// closed on the fly Chris@16: closure_undertermined = -1 Chris@16: }; Chris@16: Chris@16: namespace traits Chris@16: { Chris@16: Chris@16: /*! Chris@16: \brief Traits class indicating if points within a Chris@16: ring or (multi)polygon are closed (last point == first point), Chris@16: open or not known. Chris@16: \ingroup traits Chris@16: \par Geometries: Chris@16: - ring Chris@16: \tparam G geometry Chris@16: */ Chris@16: template Chris@16: struct closure Chris@16: { Chris@16: static const closure_selector value = closed; Chris@16: }; Chris@16: Chris@16: Chris@16: } // namespace traits Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_DETAIL Chris@16: namespace core_detail { namespace closure Chris@16: { Chris@16: Chris@16: struct closed Chris@16: { Chris@16: static const closure_selector value = geometry::closed; Chris@16: }; Chris@16: Chris@16: Chris@16: /// Metafunction to define the minimum size of a ring: Chris@16: /// 3 for open rings, 4 for closed rings Chris@16: template Chris@16: struct minimum_ring_size {}; Chris@16: Chris@16: template <> Chris@101: struct minimum_ring_size : boost::mpl::size_t<4> {}; Chris@16: Chris@16: template <> Chris@101: struct minimum_ring_size : boost::mpl::size_t<3> {}; Chris@16: Chris@16: Chris@16: }} // namespace detail::point_order Chris@16: #endif // DOXYGEN_NO_DETAIL Chris@16: Chris@16: Chris@16: Chris@16: #ifndef DOXYGEN_NO_DISPATCH Chris@16: namespace core_dispatch Chris@16: { Chris@16: Chris@16: template Chris@16: struct closure Chris@16: { Chris@16: BOOST_MPL_ASSERT_MSG Chris@16: ( Chris@16: false, NOT_IMPLEMENTED_FOR_THIS_GEOMETRY_TYPE Chris@16: , (types) Chris@16: ); Chris@16: }; Chris@16: Chris@16: template Chris@16: struct closure : public core_detail::closure::closed {}; Chris@16: Chris@16: template Chris@16: struct closure : public core_detail::closure::closed {}; Chris@16: Chris@16: template Chris@16: struct closure : public core_detail::closure::closed {}; Chris@16: Chris@16: template Chris@101: struct closure Chris@16: : public core_detail::closure::closed {}; Chris@16: Chris@16: Chris@16: template Chris@16: struct closure Chris@16: { Chris@101: static const closure_selector value Chris@16: = geometry::traits::closure::value; Chris@16: }; Chris@16: Chris@101: // Specialization for Polygon: the closure is the closure of its rings Chris@16: template Chris@16: struct closure Chris@16: { Chris@16: static const closure_selector value = core_dispatch::closure Chris@16: < Chris@16: ring_tag, Chris@16: typename ring_type::type Chris@16: >::value ; Chris@16: }; Chris@16: Chris@101: template Chris@101: struct closure Chris@101: : public core_detail::closure::closed {}; Chris@101: Chris@101: template Chris@101: struct closure Chris@101: : public core_detail::closure::closed {}; Chris@101: Chris@101: // Specialization for MultiPolygon: the closure is the closure of Polygon's rings Chris@101: template Chris@101: struct closure Chris@101: { Chris@101: static const closure_selector value = core_dispatch::closure Chris@101: < Chris@101: polygon_tag, Chris@101: typename boost::range_value::type Chris@101: >::value ; Chris@101: }; Chris@16: Chris@16: } // namespace core_dispatch Chris@16: #endif // DOXYGEN_NO_DISPATCH Chris@16: Chris@16: Chris@16: /*! Chris@101: \brief \brief_meta{value, closure (clockwise\, counterclockwise), Chris@16: \meta_geometry_type} Chris@16: \tparam Geometry \tparam_geometry Chris@16: \ingroup core Chris@16: Chris@16: \qbk{[include reference/core/closure.qbk]} Chris@16: */ Chris@16: template Chris@16: struct closure Chris@16: { Chris@16: static const closure_selector value = core_dispatch::closure Chris@16: < Chris@16: typename tag::type, Chris@101: typename util::bare_type::type Chris@16: >::value; Chris@16: }; Chris@16: Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: Chris@16: #endif // BOOST_GEOMETRY_CORE_CLOSURE_HPP