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@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_ALGORITHMS_CLEAR_HPP Chris@16: #define BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP Chris@16: Chris@16: Chris@101: #include Chris@101: Chris@101: #include Chris@101: #include Chris@101: #include Chris@101: Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@16: #include Chris@101: #include Chris@16: #include Chris@16: Chris@16: Chris@16: namespace boost { namespace geometry Chris@16: { Chris@16: Chris@16: #ifndef DOXYGEN_NO_DETAIL Chris@16: namespace detail { namespace clear Chris@16: { Chris@16: Chris@16: template Chris@16: struct collection_clear Chris@16: { Chris@16: static inline void apply(Geometry& geometry) Chris@16: { Chris@16: traits::clear::apply(geometry); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct polygon_clear Chris@16: { Chris@16: static inline void apply(Polygon& polygon) Chris@16: { Chris@16: traits::clear Chris@16: < Chris@16: typename boost::remove_reference Chris@16: < Chris@16: typename traits::interior_mutable_type::type Chris@16: >::type Chris@16: >::apply(interior_rings(polygon)); Chris@16: traits::clear Chris@16: < Chris@16: typename boost::remove_reference Chris@16: < Chris@16: typename traits::ring_mutable_type::type Chris@16: >::type Chris@16: >::apply(exterior_ring(polygon)); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct no_action Chris@16: { Chris@16: static inline void apply(Geometry& ) Chris@16: { Chris@16: } Chris@16: }; Chris@16: Chris@16: Chris@16: }} // namespace detail::clear Chris@16: #endif // DOXYGEN_NO_DETAIL Chris@16: Chris@16: #ifndef DOXYGEN_NO_DISPATCH Chris@16: namespace dispatch Chris@16: { Chris@16: Chris@16: template Chris@16: < Chris@16: typename Geometry, Chris@16: typename Tag = typename tag_cast::type, multi_tag>::type Chris@16: > Chris@16: struct clear: not_implemented Chris@16: {}; Chris@16: Chris@16: // Point/box/segment do not have clear. So specialize to do nothing. Chris@16: template Chris@16: struct clear Chris@16: : detail::clear::no_action Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct clear Chris@16: : detail::clear::no_action Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct clear Chris@16: : detail::clear::no_action Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct clear Chris@16: : detail::clear::collection_clear Chris@16: {}; Chris@16: Chris@16: template Chris@16: struct clear Chris@16: : detail::clear::collection_clear Chris@16: {}; Chris@16: Chris@16: Chris@16: // Polygon can (indirectly) use std for clear Chris@16: template Chris@16: struct clear Chris@16: : detail::clear::polygon_clear Chris@16: {}; Chris@16: Chris@16: Chris@16: template Chris@101: struct clear Chris@101: : detail::clear::collection_clear Chris@101: {}; Chris@101: Chris@101: Chris@101: } // namespace dispatch Chris@101: #endif // DOXYGEN_NO_DISPATCH Chris@101: Chris@101: Chris@101: namespace resolve_variant { Chris@101: Chris@101: template Chris@101: struct clear Chris@16: { Chris@16: static inline void apply(Geometry& geometry) Chris@16: { Chris@101: dispatch::clear::apply(geometry); Chris@16: } Chris@16: }; Chris@16: Chris@16: template Chris@101: struct clear > Chris@16: { Chris@16: struct visitor: static_visitor Chris@16: { Chris@16: template Chris@16: inline void operator()(Geometry& geometry) const Chris@16: { Chris@16: clear::apply(geometry); Chris@16: } Chris@16: }; Chris@16: Chris@16: static inline void apply(variant& geometry) Chris@16: { Chris@16: apply_visitor(visitor(), geometry); Chris@16: } Chris@16: }; Chris@16: Chris@101: } // namespace resolve_variant Chris@16: Chris@16: Chris@16: /*! Chris@16: \brief Clears a linestring, ring or polygon (exterior+interiors) or multi* Chris@16: \details Generic function to clear a geometry. All points will be removed from the collection or collections Chris@16: making up the geometry. In most cases this is equivalent to the .clear() method of a std::vector<...>. In Chris@16: the case of a polygon, this clear functionality is automatically called for the exterior ring, and for the Chris@16: interior ring collection. In the case of a point, boxes and segments, nothing will happen. Chris@16: \ingroup clear Chris@16: \tparam Geometry \tparam_geometry Chris@16: \param geometry \param_geometry which will be cleared Chris@16: \note points and boxes cannot be cleared, instead they can be set to zero by "assign_zero" Chris@16: Chris@16: \qbk{[include reference/algorithms/clear.qbk]} Chris@16: */ Chris@16: template Chris@16: inline void clear(Geometry& geometry) Chris@16: { Chris@16: concept::check(); Chris@16: Chris@101: resolve_variant::clear::apply(geometry); Chris@16: } Chris@16: Chris@16: Chris@16: }} // namespace boost::geometry Chris@16: Chris@16: Chris@16: #endif // BOOST_GEOMETRY_ALGORITHMS_CLEAR_HPP