Added thirdparty: boost library

This commit is contained in:
Viacheslav Demydiuk
2024-01-06 19:55:56 +02:00
parent bf49f439e1
commit bccd1e7051
15683 changed files with 3239840 additions and 0 deletions
+75
View File
@@ -0,0 +1,75 @@
// Boost.Geometry
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ANY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ANY_HPP
#include <utility>
#include <boost/any.hpp>
#include <boost/geometry/geometries/adapted/detail/any.hpp>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/visit.hpp>
namespace boost { namespace geometry
{
namespace detail
{
struct boost_any_cast_policy
{
template <typename T, typename Any>
static inline T * apply(Any * any_ptr)
{
return boost::any_cast<T>(any_ptr);
}
};
} // namespace detail
namespace traits
{
template <>
struct tag<boost::any>
{
using type = dynamic_geometry_tag;
};
template <>
struct visit<boost::any>
{
template <typename Function, typename Any>
static void apply(Function && function, Any && any)
{
using types_t = typename geometry_types<util::remove_cref_t<Any>>::type;
geometry::detail::visit_any
<
geometry::detail::boost_any_cast_policy, types_t
>::template apply<0>(std::forward<Function>(function), std::forward<Any>(any));
}
};
} // namespace traits
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ANY_HPP
+125
View File
@@ -0,0 +1,125 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010 Alfredo Correa
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
#ifdef BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED
#error Include either "boost_array_as_point" or \
"boost_array_as_linestring" or "boost_array_as_ring" \
or "boost_array_as_multi_point" to adapt a boost_array
#endif
#define BOOST_GEOMETRY_ADAPTED_BOOST_ARRAY_TAG_DEFINED
#include <cstddef>
#include <type_traits>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/array.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
// Create class and specialization to indicate the tag
// for normal cases and the case that the type of the c-array is arithmetic
template <bool>
struct boost_array_tag
{
typedef geometry_not_recognized_tag type;
};
template <>
struct boost_array_tag<true>
{
typedef point_tag type;
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
// Assign the point-tag, preventing arrays of points getting a point-tag
template <typename CoordinateType, std::size_t DimensionCount>
struct tag<boost::array<CoordinateType, DimensionCount> >
: detail::boost_array_tag<std::is_arithmetic<CoordinateType>::value> {};
template <typename CoordinateType, std::size_t DimensionCount>
struct coordinate_type<boost::array<CoordinateType, DimensionCount> >
{
typedef CoordinateType type;
};
template <typename CoordinateType, std::size_t DimensionCount>
struct dimension<boost::array<CoordinateType, DimensionCount> >
: std::integral_constant<std::size_t, DimensionCount>
{};
template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
struct access<boost::array<CoordinateType, DimensionCount>, Dimension>
{
static inline CoordinateType get(boost::array<CoordinateType, DimensionCount> const& a)
{
return a[Dimension];
}
static inline void set(boost::array<CoordinateType, DimensionCount>& a,
CoordinateType const& value)
{
a[Dimension] = value;
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
#define BOOST_GEOMETRY_REGISTER_BOOST_ARRAY_CS(CoordinateSystem) \
namespace boost { namespace geometry { namespace traits { \
template <class T, std::size_t N> \
struct coordinate_system<boost::array<T, N> > \
{ \
typedef CoordinateSystem type; \
}; \
}}}
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_ARRAY_HPP
+196
View File
@@ -0,0 +1,196 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2011-2015 Akira Takahashi
// Copyright (c) 2011-2015 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2015-2020.
// Modifications copyright (c) 2015-2020, Oracle and/or its affiliates.
// Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP
#include <cstddef>
#include <type_traits>
#include <boost/fusion/include/is_sequence.hpp>
#include <boost/fusion/include/size.hpp>
#include <boost/fusion/include/tag_of.hpp>
#include <boost/fusion/include/front.hpp>
#include <boost/fusion/include/at.hpp>
#include <boost/fusion/mpl.hpp>
#include <boost/mpl/and.hpp>
#include <boost/mpl/count_if.hpp>
#include <boost/mpl/front.hpp>
#include <boost/mpl/placeholders.hpp>
#include <boost/mpl/pop_front.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_system.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
namespace fusion_adapt_detail
{
template <class Sequence>
struct all_same :
std::integral_constant
<
bool,
boost::mpl::count_if<
Sequence,
boost::is_same<
typename boost::mpl::front<Sequence>::type,
boost::mpl::_
>
>::value == boost::mpl::size<Sequence>::value
>
{};
template <class Sequence>
struct is_coordinate_size
: std::integral_constant
<
bool,
(boost::fusion::result_of::size<Sequence>::value == 2
|| boost::fusion::result_of::size<Sequence>::value == 3)
>
{};
template
<
typename Sequence,
bool IsSequence = boost::fusion::traits::is_sequence<Sequence>::value
>
struct is_fusion_sequence
: std::integral_constant
<
bool,
(fusion_adapt_detail::is_coordinate_size<Sequence>::value
&& fusion_adapt_detail::all_same<Sequence>::value)
>
{};
template<typename Sequence>
struct is_fusion_sequence<Sequence, false>
: std::false_type
{};
} // namespace fusion_adapt_detail
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
// Boost Fusion Sequence, 2D or 3D
template <typename Sequence>
struct coordinate_type
<
Sequence,
std::enable_if_t
<
fusion_adapt_detail::is_fusion_sequence<Sequence>::value
>
>
{
typedef typename boost::mpl::front<Sequence>::type type;
};
template <typename Sequence>
struct dimension
<
Sequence,
std::enable_if_t
<
fusion_adapt_detail::is_fusion_sequence<Sequence>::value
>
> : boost::mpl::size<Sequence>
{};
template <typename Sequence, std::size_t Dimension>
struct access
<
Sequence,
Dimension,
std::enable_if_t
<
fusion_adapt_detail::is_fusion_sequence<Sequence>::value
>
>
{
typedef typename coordinate_type<Sequence>::type ctype;
static inline ctype get(Sequence const& point)
{
return boost::fusion::at_c<Dimension>(point);
}
template <class CoordinateType>
static inline void set(Sequence& point, CoordinateType const& value)
{
boost::fusion::at_c<Dimension>(point) = value;
}
};
template <typename Sequence>
struct tag
<
Sequence,
std::enable_if_t
<
fusion_adapt_detail::is_fusion_sequence<Sequence>::value
>
>
{
typedef point_tag type;
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
// Convenience registration macro to bind a Fusion sequence to a CS
#define BOOST_GEOMETRY_REGISTER_BOOST_FUSION_CS(CoordinateSystem) \
namespace boost { namespace geometry { namespace traits { \
template <typename Sequence> \
struct coordinate_system \
< \
Sequence, \
std::enable_if_t \
< \
fusion_adapt_detail::is_fusion_sequence<Sequence>::value \
> \
> \
{ typedef CoordinateSystem type; }; \
}}}
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_FUSION_HPP
+18
View File
@@ -0,0 +1,18 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HPP
#include <boost/geometry/geometries/adapted/boost_polygon/point.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/box.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/ring.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/polygon.hpp>
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HPP
@@ -0,0 +1,141 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
// boost::polygon::rectangle_data -> boost::geometry::box
#include <boost/polygon/polygon.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
template <typename CoordinateType>
struct tag<boost::polygon::rectangle_data<CoordinateType> >
{
typedef box_tag type;
};
template <typename CoordinateType>
struct point_type<boost::polygon::rectangle_data<CoordinateType> >
{
// Not sure what to do here. Boost.Polygon's rectangle does NOT define its
// point_type (but uses it...)
typedef boost::polygon::point_data<CoordinateType> type;
};
template <typename CoordinateType>
struct indexed_access
<
boost::polygon::rectangle_data<CoordinateType>,
min_corner, 0
>
{
typedef boost::polygon::rectangle_data<CoordinateType> box_type;
static inline CoordinateType get(box_type const& b)
{
return boost::polygon::xl(b);
}
static inline void set(box_type& b, CoordinateType const& value)
{
boost::polygon::xl(b, value);
}
};
template <typename CoordinateType>
struct indexed_access
<
boost::polygon::rectangle_data<CoordinateType>,
min_corner, 1
>
{
typedef boost::polygon::rectangle_data<CoordinateType> box_type;
static inline CoordinateType get(box_type const& b)
{
return boost::polygon::yl(b);
}
static inline void set(box_type& b, CoordinateType const& value)
{
boost::polygon::yl(b, value);
}
};
template <typename CoordinateType>
struct indexed_access
<
boost::polygon::rectangle_data<CoordinateType>,
max_corner, 0
>
{
typedef boost::polygon::rectangle_data<CoordinateType> box_type;
static inline CoordinateType get(box_type const& b)
{
return boost::polygon::xh(b);
}
static inline void set(box_type& b, CoordinateType const& value)
{
boost::polygon::xh(b, value);
}
};
template <typename CoordinateType>
struct indexed_access
<
boost::polygon::rectangle_data<CoordinateType>,
max_corner, 1
>
{
typedef boost::polygon::rectangle_data<CoordinateType> box_type;
static inline CoordinateType get(box_type const& b)
{
return boost::polygon::yh(b);
}
static inline void set(box_type& b, CoordinateType const& value)
{
boost::polygon::yh(b, value);
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_BOX_HPP
@@ -0,0 +1,83 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
// hole_iterator -> returning ring_proxy's instead of normal polygon_data
#include <boost/polygon/polygon.hpp>
#include <boost/iterator/iterator_facade.hpp>
namespace boost { namespace geometry
{
namespace adapt { namespace bp
{
template <typename Polygon, typename RingProxy>
class hole_iterator
: public ::boost::iterator_facade
<
hole_iterator<Polygon, RingProxy>,
RingProxy, // value type
boost::forward_traversal_tag,
RingProxy // reference type
>
{
public :
typedef typename boost::polygon::polygon_with_holes_traits
<
Polygon
>::iterator_holes_type ith_type;
explicit inline hole_iterator(Polygon& polygon, ith_type const it)
: m_polygon(polygon)
, m_base(it)
{
}
typedef std::ptrdiff_t difference_type;
private:
friend class boost::iterator_core_access;
inline RingProxy dereference() const
{
return RingProxy(m_polygon, this->m_base);
}
inline void increment() { ++m_base; }
inline void decrement() { --m_base; }
inline void advance(difference_type n)
{
for (int i = 0; i < n; i++)
{
++m_base;
}
}
inline bool equal(hole_iterator<Polygon, RingProxy> const& other) const
{
return this->m_base == other.m_base;
}
Polygon& m_polygon;
ith_type m_base;
};
}}}}
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLE_ITERATOR_HPP
@@ -0,0 +1,208 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
// pair{begin_holes, begin_holes} -> interior_proxy
#include <boost/polygon/polygon.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp>
namespace boost { namespace geometry
{
namespace adapt { namespace bp
{
// Polygon should implement the boost::polygon::polygon_with_holes_concept
// Specify constness in the template parameter if necessary
template<typename Polygon>
struct holes_proxy
{
typedef ring_proxy
<
std::conditional_t
<
std::is_const<Polygon>::value,
Polygon const,
Polygon
>
> proxy_type;
typedef hole_iterator<Polygon, proxy_type> iterator_type;
// The next line does not work probably because coordinate_type is part of the
// polygon_traits, but not of the polygon_with_holes_traits
// typedef typename boost::polygon::polygon_traits<Polygon>::coordinate_type coordinate_type;
// So we use:
typedef typename Polygon::coordinate_type coordinate_type;
inline holes_proxy(Polygon& p)
: polygon(p)
{}
inline void clear()
{
Polygon empty;
// Clear the holes
polygon.set_holes
(
boost::polygon::begin_holes(empty),
boost::polygon::end_holes(empty)
);
}
inline void resize(std::size_t new_size)
{
std::vector<boost::polygon::polygon_data<coordinate_type> > temporary_copy
(
boost::polygon::begin_holes(polygon),
boost::polygon::end_holes(polygon)
);
temporary_copy.resize(new_size);
polygon.set_holes(temporary_copy.begin(), temporary_copy.end());
}
template <typename Ring>
inline void push_back(Ring const& ring)
{
std::vector<boost::polygon::polygon_data<coordinate_type> > temporary_copy
(
boost::polygon::begin_holes(polygon),
boost::polygon::end_holes(polygon)
);
boost::polygon::polygon_data<coordinate_type> added;
boost::polygon::set_points(added, ring.begin(), ring.end());
temporary_copy.push_back(added);
polygon.set_holes(temporary_copy.begin(), temporary_copy.end());
}
Polygon& polygon;
};
// Support holes_proxy for Boost.Range ADP
// Const versions
template<typename Polygon>
inline typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
range_begin(boost::geometry::adapt::bp::holes_proxy<Polygon const> const& proxy)
{
typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
begin(proxy.polygon, boost::polygon::begin_holes(proxy.polygon));
return begin;
}
template<typename Polygon>
inline typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
range_end(boost::geometry::adapt::bp::holes_proxy<Polygon const> const& proxy)
{
typename boost::geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type
end(proxy.polygon, boost::polygon::end_holes(proxy.polygon));
return end;
}
// Mutable versions
template<typename Polygon>
inline typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
range_begin(boost::geometry::adapt::bp::holes_proxy<Polygon>& proxy)
{
typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
begin(proxy.polygon, boost::polygon::begin_holes(proxy.polygon));
return begin;
}
template<typename Polygon>
inline typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
range_end(boost::geometry::adapt::bp::holes_proxy<Polygon>& proxy)
{
typename boost::geometry::adapt::bp::holes_proxy<Polygon>::iterator_type
end(proxy.polygon, boost::polygon::end_holes(proxy.polygon));
return end;
}
}}
namespace traits
{
template <typename Polygon>
struct rvalue_type<adapt::bp::holes_proxy<Polygon> >
{
typedef adapt::bp::holes_proxy<Polygon> type;
};
template <typename Polygon>
struct clear<adapt::bp::holes_proxy<Polygon> >
{
static inline void apply(adapt::bp::holes_proxy<Polygon> proxy)
{
proxy.clear();
}
};
template <typename Polygon>
struct resize<adapt::bp::holes_proxy<Polygon> >
{
static inline void apply(adapt::bp::holes_proxy<Polygon> proxy, std::size_t new_size)
{
proxy.resize(new_size);
}
};
template <typename Polygon>
struct push_back<adapt::bp::holes_proxy<Polygon> >
{
template <typename Ring>
static inline void apply(adapt::bp::holes_proxy<Polygon> proxy, Ring const& ring)
{
proxy.push_back(ring);
}
};
} // namespace traits
}}
// Specialize holes_proxy for Boost.Range
namespace boost
{
template<typename Polygon>
struct range_mutable_iterator<geometry::adapt::bp::holes_proxy<Polygon> >
{
typedef typename geometry::adapt::bp::holes_proxy<Polygon>::iterator_type type;
};
template<typename Polygon>
struct range_const_iterator<geometry::adapt::bp::holes_proxy<Polygon> >
{
typedef typename geometry::adapt::bp::holes_proxy<Polygon const>::iterator_type type;
};
} // namespace boost
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_HOLES_PROXY_HPP
@@ -0,0 +1,108 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
// boost::polygon::point_data -> boost::geometry::point
#include <type_traits>
#include <boost/polygon/polygon.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
template <typename CoordinateType>
struct tag<boost::polygon::point_data<CoordinateType> >
{
typedef point_tag type;
};
template <typename CoordinateType>
struct coordinate_type<boost::polygon::point_data<CoordinateType> >
{
typedef CoordinateType type;
};
template <typename CoordinateType>
struct coordinate_system<boost::polygon::point_data<CoordinateType> >
{
typedef cs::cartesian type;
};
template <typename CoordinateType>
struct dimension<boost::polygon::point_data<CoordinateType> >
: std::integral_constant<std::size_t, 2>
{};
template <typename CoordinateType>
struct access<boost::polygon::point_data<CoordinateType>, 0>
{
typedef boost::polygon::point_data<CoordinateType> point_type;
static inline CoordinateType get(point_type const& p)
{
return p.x();
}
static inline void set(point_type& p, CoordinateType const& value)
{
p.x(value);
}
};
template <typename CoordinateType>
struct access<boost::polygon::point_data<CoordinateType>, 1>
{
typedef boost::polygon::point_data<CoordinateType> point_type;
static inline CoordinateType get(point_type const& p)
{
return p.y();
}
static inline void set(point_type& p, CoordinateType const& value)
{
p.y(value);
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POINT_HPP
@@ -0,0 +1,111 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
#include <boost/polygon/polygon.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/ring_type.hpp>
#include <boost/geometry/core/exterior_ring.hpp>
#include <boost/geometry/core/interior_rings.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/ring_proxy.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/hole_iterator.hpp>
#include <boost/geometry/geometries/adapted/boost_polygon/holes_proxy.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
template <typename CoordinateType>
struct tag<boost::polygon::polygon_with_holes_data<CoordinateType> >
{
typedef polygon_tag type;
};
template <typename CoordinateType>
struct ring_const_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
{
typedef adapt::bp::ring_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> const> type;
};
template <typename CoordinateType>
struct ring_mutable_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
{
typedef adapt::bp::ring_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> > type;
};
template <typename CoordinateType>
struct interior_const_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
{
typedef adapt::bp::holes_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> const> type;
};
template <typename CoordinateType>
struct interior_mutable_type<boost::polygon::polygon_with_holes_data<CoordinateType> >
{
typedef adapt::bp::holes_proxy<boost::polygon::polygon_with_holes_data<CoordinateType> > type;
};
template <typename CoordinateType>
struct exterior_ring<boost::polygon::polygon_with_holes_data<CoordinateType> >
{
typedef boost::polygon::polygon_with_holes_data<CoordinateType> polygon_type;
typedef adapt::bp::ring_proxy<polygon_type> proxy;
typedef adapt::bp::ring_proxy<polygon_type const> const_proxy;
static inline proxy get(polygon_type& p)
{
return proxy(p);
}
static inline const_proxy get(polygon_type const& p)
{
return const_proxy(p);
}
};
template <typename CoordinateType>
struct interior_rings<boost::polygon::polygon_with_holes_data<CoordinateType> >
{
typedef boost::polygon::polygon_with_holes_data<CoordinateType> polygon_type;
typedef adapt::bp::holes_proxy<polygon_type> proxy;
typedef adapt::bp::holes_proxy<polygon_type const> const_proxy;
static inline proxy get(polygon_type& p)
{
return proxy(p);
}
static inline const_proxy get(polygon_type const& p)
{
return const_proxy(p);
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_POLYGON_HPP
@@ -0,0 +1,182 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
// boost::polygon::polygon_data -> boost::geometry::ring
#include <cstddef>
#include <boost/polygon/polygon.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/mutable_range.hpp>
#include <boost/geometry/core/tags.hpp>
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace boost { namespace geometry
{
namespace traits
{
template <typename CoordinateType>
struct tag<boost::polygon::polygon_data<CoordinateType> >
{
typedef ring_tag type;
};
template <typename CoordinateType>
struct clear<boost::polygon::polygon_data<CoordinateType> >
{
static inline void apply(boost::polygon::polygon_data<CoordinateType>& data)
{
// There is no "clear" function but we can assign
// a newly (and therefore empty) constructed polygon
boost::polygon::assign(data, boost::polygon::polygon_data<CoordinateType>());
}
};
template <typename CoordinateType>
struct push_back<boost::polygon::polygon_data<CoordinateType> >
{
typedef boost::polygon::point_data<CoordinateType> point_type;
static inline void apply(boost::polygon::polygon_data<CoordinateType>& data,
point_type const& point)
{
// Boost.Polygon's polygons are not appendable. So create a temporary vector,
// add a record and set it to the original. Of course: this is not efficient.
// But there seems no other way (without using a wrapper)
std::vector<point_type> temporary_vector
(
boost::polygon::begin_points(data),
boost::polygon::end_points(data)
);
temporary_vector.push_back(point);
data.set(temporary_vector.begin(), temporary_vector.end());
}
};
template <typename CoordinateType>
struct resize<boost::polygon::polygon_data<CoordinateType> >
{
typedef boost::polygon::point_data<CoordinateType> point_type;
static inline void apply(boost::polygon::polygon_data<CoordinateType>& data,
std::size_t new_size)
{
// Boost.Polygon's polygons are not resizable. So create a temporary vector,
// resize it and set it to the original. Of course: this is not efficient.
// But there seems no other way (without using a wrapper)
std::vector<point_type> temporary_vector
(
boost::polygon::begin_points(data),
boost::polygon::end_points(data)
);
temporary_vector.resize(new_size);
data.set(temporary_vector.begin(), temporary_vector.end());
}
};
} // namespace traits
}} // namespace boost::geometry
// Adapt Boost.Polygon's polygon_data to Boost.Range
// This just translates to
// polygon_data.begin() and polygon_data.end()
namespace boost
{
template<typename CoordinateType>
struct range_mutable_iterator<boost::polygon::polygon_data<CoordinateType> >
{
typedef typename boost::polygon::polygon_traits
<
boost::polygon::polygon_data<CoordinateType>
>::iterator_type type;
};
template<typename CoordinateType>
struct range_const_iterator<boost::polygon::polygon_data<CoordinateType> >
{
typedef typename boost::polygon::polygon_traits
<
boost::polygon::polygon_data<CoordinateType>
>::iterator_type type;
};
template<typename CoordinateType>
struct range_size<boost::polygon::polygon_data<CoordinateType> >
{
typedef std::size_t type;
};
} // namespace boost
// Support Boost.Polygon's polygon_data for Boost.Range ADP
namespace boost { namespace polygon
{
template<typename CoordinateType>
inline typename polygon_traits
<
polygon_data<CoordinateType>
>::iterator_type range_begin(polygon_data<CoordinateType>& polygon)
{
return polygon.begin();
}
template<typename CoordinateType>
inline typename polygon_traits
<
polygon_data<CoordinateType>
>::iterator_type range_begin(polygon_data<CoordinateType> const& polygon)
{
return polygon.begin();
}
template<typename CoordinateType>
inline typename polygon_traits
<
polygon_data<CoordinateType>
>::iterator_type range_end(polygon_data<CoordinateType>& polygon)
{
return polygon.end();
}
template<typename CoordinateType>
inline typename polygon_traits
<
polygon_data<CoordinateType>
>::iterator_type range_end(polygon_data<CoordinateType> const& polygon)
{
return polygon.end();
}
template<typename CoordinateType>
inline std::size_t range_calculate_size(polygon_data<CoordinateType> const& polygon)
{
return polygon.size();
}
}}
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_HPP
@@ -0,0 +1,308 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// This file was modified by Oracle on 2018.
// Modifications copyright (c) 2018, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP
// Adapts Geometries from Boost.Polygon for usage in Boost.Geometry
// boost::polygon::polygon_with_holes_data -> boost::geometry::polygon
// pair{begin_points, end_points} -> ring_proxy
#include <boost/polygon/polygon.hpp>
#include <boost/range/const_iterator.hpp>
#include <boost/range/mutable_iterator.hpp>
#include <boost/geometry/core/mutable_range.hpp>
#include <boost/geometry/core/tag.hpp>
namespace boost { namespace geometry
{
namespace adapt { namespace bp
{
namespace detail
{
template <bool Mutable>
struct modify
{};
template <>
struct modify<true>
{
template <typename Ring, typename Point>
static inline void push_back(Ring& ring, Point const& point)
{
// Boost.Polygon's polygons are not appendable. So create a temporary vector,
// add a record and set it to the original. Of course: this is not efficient.
// But there seems no other way (without using a wrapper)
std::vector<Point> temporary_vector
(
boost::polygon::begin_points(ring),
boost::polygon::end_points(ring)
);
temporary_vector.push_back(point);
boost::polygon::set_points(ring, temporary_vector.begin(), temporary_vector.end());
}
};
template <>
struct modify<false>
{
template <typename Ring, typename Point>
static inline void push_back(Ring& /*ring*/, Point const& /*point*/)
{
}
};
}
// Polygon should implement the boost::polygon::polygon_with_holes_concept
// Specify constness in the template parameter if necessary
template<typename Polygon>
class ring_proxy
{
public :
typedef typename boost::polygon::polygon_traits
<
typename boost::remove_const<Polygon>::type
>::iterator_type iterator_type;
typedef typename boost::polygon::polygon_with_holes_traits
<
typename boost::remove_const<Polygon>::type
>::iterator_holes_type hole_iterator_type;
static const bool is_mutable = !boost::is_const<Polygon>::type::value;
inline ring_proxy(Polygon& p)
: m_polygon_pointer(&p)
, m_do_hole(false)
{}
// Constructor used from hole_iterator
inline ring_proxy(Polygon& p, hole_iterator_type hole_it)
: m_polygon_pointer(&p)
, m_do_hole(true)
, m_hole_it(hole_it)
{}
// Default constructor, for mutable polygons / appending (interior) rings
inline ring_proxy()
: m_polygon_pointer(&m_polygon_for_default_constructor)
, m_do_hole(false)
{}
iterator_type begin() const
{
return m_do_hole
? boost::polygon::begin_points(*m_hole_it)
: boost::polygon::begin_points(*m_polygon_pointer)
;
}
iterator_type begin()
{
return m_do_hole
? boost::polygon::begin_points(*m_hole_it)
: boost::polygon::begin_points(*m_polygon_pointer)
;
}
iterator_type end() const
{
return m_do_hole
? boost::polygon::end_points(*m_hole_it)
: boost::polygon::end_points(*m_polygon_pointer)
;
}
iterator_type end()
{
return m_do_hole
? boost::polygon::end_points(*m_hole_it)
: boost::polygon::end_points(*m_polygon_pointer)
;
}
// Mutable
void clear()
{
Polygon p;
if (m_do_hole)
{
// Does NOT work see comment above
}
else
{
boost::polygon::set_points(*m_polygon_pointer,
boost::polygon::begin_points(p),
boost::polygon::end_points(p));
}
}
void resize(std::size_t /*new_size*/)
{
if (m_do_hole)
{
// Does NOT work see comment above
}
else
{
// TODO: implement this by resizing the container
}
}
template <typename Point>
void push_back(Point const& point)
{
if (m_do_hole)
{
//detail::modify<is_mutable>::push_back(*m_hole_it, point);
//std::cout << "HOLE: " << typeid(*m_hole_it).name() << std::endl;
//std::cout << "HOLE: " << typeid(m_hole_it).name() << std::endl;
//std::cout << "HOLE: " << typeid(hole_iterator_type).name() << std::endl;
// Note, ths does NOT work because hole_iterator_type is defined
// as a const_iterator by Boost.Polygon
}
else
{
detail::modify<is_mutable>::push_back(*m_polygon_pointer, point);
}
}
private :
Polygon* m_polygon_pointer;
bool m_do_hole;
hole_iterator_type m_hole_it;
Polygon m_polygon_for_default_constructor;
};
// Support geometry::adapt::bp::ring_proxy for Boost.Range ADP
template<typename Polygon>
inline typename boost::geometry::adapt::bp::ring_proxy<Polygon>::iterator_type
range_begin(boost::geometry::adapt::bp::ring_proxy<Polygon>& proxy)
{
return proxy.begin();
}
template<typename Polygon>
inline typename boost::geometry::adapt::bp::ring_proxy<Polygon const>::iterator_type
range_begin(boost::geometry::adapt::bp::ring_proxy<Polygon const> const& proxy)
{
return proxy.begin();
}
template<typename Polygon>
inline typename boost::geometry::adapt::bp::ring_proxy<Polygon>::iterator_type
range_end(boost::geometry::adapt::bp::ring_proxy<Polygon>& proxy)
{
return proxy.end();
}
template<typename Polygon>
inline typename boost::geometry::adapt::bp::ring_proxy<Polygon const>::iterator_type
range_end(boost::geometry::adapt::bp::ring_proxy<Polygon const> const& proxy)
{
return proxy.end();
}
}} // namespace adapt::bp
namespace traits
{
template <typename Polygon>
struct tag<adapt::bp::ring_proxy<Polygon> >
{
typedef ring_tag type;
};
template <typename Polygon>
struct rvalue_type<adapt::bp::ring_proxy<Polygon> >
{
typedef adapt::bp::ring_proxy<Polygon> type;
};
template <typename Polygon>
struct clear<adapt::bp::ring_proxy<Polygon> >
{
static inline void apply(adapt::bp::ring_proxy<Polygon> proxy)
{
proxy.clear();
}
};
template <typename Polygon>
struct resize<adapt::bp::ring_proxy<Polygon> >
{
static inline void apply(adapt::bp::ring_proxy<Polygon> proxy, std::size_t new_size)
{
proxy.resize(new_size);
}
};
template <typename Polygon>
struct push_back<adapt::bp::ring_proxy<Polygon> >
{
static inline void apply(adapt::bp::ring_proxy<Polygon> proxy,
typename boost::polygon::polygon_traits<Polygon>::point_type const& point)
{
proxy.push_back(point);
}
};
} // namespace traits
}} // namespace boost::geometry
// Specialize ring_proxy for Boost.Range
namespace boost
{
template<typename Polygon>
struct range_mutable_iterator<geometry::adapt::bp::ring_proxy<Polygon> >
{
typedef typename geometry::adapt::bp::ring_proxy<Polygon>::iterator_type type;
};
template<typename Polygon>
struct range_const_iterator<geometry::adapt::bp::ring_proxy<Polygon> >
{
typedef typename geometry::adapt::bp::ring_proxy<Polygon const>::iterator_type type;
};
} // namespace boost
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_POLYGON_RING_PROXY_HPP
@@ -0,0 +1,40 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP
#include <boost/range/adaptor/adjacent_filtered.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template<typename Filter, typename Geometry, bool DefaultPass>
#if BOOST_VERSION > 104500
struct tag<boost::adjacent_filtered_range<Filter, Geometry, DefaultPass> >
#else
struct tag<boost::range_detail::adjacent_filter_range<Filter, Geometry, DefaultPass> >
#endif
{
typedef typename geometry::tag<Geometry>::type type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_ADJACENT_FILTERED_HPP
@@ -0,0 +1,40 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP
#include <boost/range/adaptor/filtered.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template<typename Filter, typename Geometry>
#if BOOST_VERSION > 104500
struct tag<boost::filtered_range<Filter, Geometry> >
#else
struct tag<boost::range_detail::filter_range<Filter, Geometry> >
#endif
{
typedef typename geometry::tag<Geometry>::type type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_FILTERED_HPP
@@ -0,0 +1,40 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP
#include <boost/range/adaptor/reversed.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template<typename Geometry>
#if BOOST_VERSION > 104500
struct tag<boost::reversed_range<Geometry> >
#else
struct tag<boost::range_detail::reverse_range<Geometry> >
#endif
{
typedef typename geometry::tag<Geometry>::type type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_REVERSED_HPP
@@ -0,0 +1,36 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP
#include <boost/range/adaptor/sliced.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template<typename Geometry>
struct tag<boost::adaptors::sliced_range<Geometry> >
{
typedef typename geometry::tag<Geometry>::type type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_SLICED_HPP
@@ -0,0 +1,36 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP
#include <boost/range/adaptor/strided.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template<typename Geometry>
struct tag<boost::strided_range<Geometry> >
{
typedef typename geometry::tag<Geometry>::type type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_STRIDED_HPP
@@ -0,0 +1,40 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP
#include <boost/range/adaptor/uniqued.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template<typename Geometry>
#if BOOST_VERSION > 104500
struct tag<boost::uniqued_range<Geometry> >
#else
struct tag<boost::range_detail::unique_range<Geometry> >
#endif
{
typedef typename geometry::tag<Geometry>::type type;
};
}
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_RANGE_UNIQUED_HPP
+117
View File
@@ -0,0 +1,117 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2018-2020.
// Modifications copyright (c) 2018-2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_TUPLE_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_TUPLE_HPP
#include <cstddef>
#include <type_traits>
#include <boost/tuple/tuple.hpp>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
struct tag<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
{
typedef point_tag type;
};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
struct coordinate_type<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
{
typedef T1 type;
};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10>
struct dimension<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> >
: std::integral_constant
<
std::size_t,
boost::tuples::length
<
boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>
>::value
>
{};
template <typename T1, typename T2, typename T3, typename T4, typename T5,
typename T6, typename T7, typename T8, typename T9, typename T10,
std::size_t Dimension>
struct access
<
boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>,
Dimension
>
{
static inline T1 get(
boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> const& point)
{
return point.template get<Dimension>();
}
static inline void set(
boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10>& point,
T1 const& value)
{
point.template get<Dimension>() = value;
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
// Convenience registration macro to bind boost::tuple to a CS
#define BOOST_GEOMETRY_REGISTER_BOOST_TUPLE_CS(CoordinateSystem) \
namespace boost { namespace geometry { namespace traits { \
template <typename T1, typename T2, typename T3, typename T4, typename T5, \
typename T6, typename T7, typename T8, typename T9, typename T10> \
struct coordinate_system<boost::tuple<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10> > \
{ \
typedef CoordinateSystem type; \
}; \
}}}
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_TUPLE_HPP
+175
View File
@@ -0,0 +1,175 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2018-2021.
// Modifications copyright (c) 2018-2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT_HPP
#include <boost/variant/apply_visitor.hpp>
#include <boost/variant/static_visitor.hpp>
#include <boost/variant/variant.hpp>
//#include <boost/variant/variant_fwd.hpp>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/point_type.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/visit.hpp>
#include <boost/geometry/util/sequence.hpp>
namespace boost { namespace geometry
{
namespace detail
{
template <typename Seq, typename ResultSeq = util::type_sequence<>>
struct boost_variant_types;
template <typename T, typename ...Ts, typename ...Rs>
struct boost_variant_types<util::type_sequence<T, Ts...>, util::type_sequence<Rs...>>
{
using type = typename boost_variant_types<util::type_sequence<Ts...>, util::type_sequence<Rs..., T>>::type;
};
template <typename ...Ts, typename ...Rs>
struct boost_variant_types<util::type_sequence<boost::detail::variant::void_, Ts...>, util::type_sequence<Rs...>>
{
using type = util::type_sequence<Rs...>;
};
template <typename ...Rs>
struct boost_variant_types<util::type_sequence<>, util::type_sequence<Rs...>>
{
using type = util::type_sequence<Rs...>;
};
} // namespace detail
// TODO: This is not used anywhere in the header files. Only in tests.
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct point_type<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)> >
: point_type
<
typename util::pack_front
<
BOOST_VARIANT_ENUM_PARAMS(T)
>::type
>
{};
namespace traits
{
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct tag<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
{
using type = dynamic_geometry_tag;
};
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct visit<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
{
template <typename Function>
struct visitor
: boost::static_visitor<>
{
visitor(Function function)
: m_function(function)
{}
template <typename Geometry>
void operator()(Geometry && geometry)
{
m_function(std::forward<Geometry>(geometry));
}
Function m_function;
};
template <typename Function, typename Variant>
static void apply(Function function, Variant && variant)
{
visitor<Function> visitor(function);
boost::apply_visitor(visitor, std::forward<Variant>(variant));
}
};
template <BOOST_VARIANT_ENUM_PARAMS(typename T), BOOST_VARIANT_ENUM_PARAMS(typename U)>
struct visit<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>, boost::variant<BOOST_VARIANT_ENUM_PARAMS(U)>>
{
template <typename Function>
struct visitor
: boost::static_visitor<>
{
visitor(Function function)
: m_function(function)
{}
template <typename Geometry1, typename Geometry2>
void operator()(Geometry1 && geometry1, Geometry2 && geometry2)
{
m_function(std::forward<Geometry1>(geometry1),
std::forward<Geometry2>(geometry2));
}
Function m_function;
};
template <typename Function, typename Variant1, typename Variant2>
static void apply(Function function, Variant1 && variant1, Variant2 && variant2)
{
visitor<Function> visitor(function);
boost::apply_visitor(visitor,
std::forward<Variant1>(variant1),
std::forward<Variant2>(variant2));
}
};
#ifdef BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct geometry_types<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
{
using type = typename geometry::detail::boost_variant_types
<
util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>
>::type;
};
#else // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
struct geometry_types<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
{
using type = util::type_sequence<BOOST_VARIANT_ENUM_PARAMS(T)>;
};
#endif // BOOST_VARIANT_DO_NOT_USE_VARIADIC_TEMPLATES
} // namespace traits
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT_HPP
+73
View File
@@ -0,0 +1,73 @@
// Boost.Geometry
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT2_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT2_HPP
#include <utility>
#include <boost/variant2/variant.hpp>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/visit.hpp>
#include <boost/geometry/util/sequence.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template <typename ...Ts>
struct tag<boost::variant2::variant<Ts...>>
{
using type = dynamic_geometry_tag;
};
template <typename ...Ts>
struct visit<boost::variant2::variant<Ts...>>
{
template <typename Function, typename Variant>
static void apply(Function && function, Variant && variant)
{
boost::variant2::visit(std::forward<Function>(function),
std::forward<Variant>(variant));
}
};
template <typename ...Ts, typename ...Us>
struct visit<boost::variant2::variant<Ts...>, boost::variant2::variant<Us...>>
{
template <typename Function, typename Variant1, typename Variant2>
static void apply(Function && function, Variant1 && variant1, Variant2 && variant2)
{
boost::variant2::visit(std::forward<Function>(function),
std::forward<Variant1>(variant1),
std::forward<Variant2>(variant2));
}
};
template <typename ...Ts>
struct geometry_types<boost::variant2::variant<Ts...>>
{
using type = util::type_sequence<Ts...>;
};
} // namespace traits
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_BOOST_VARIANT2_HPP
+116
View File
@@ -0,0 +1,116 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020 Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
#include <cstddef>
#include <type_traits>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
// Create class and specialization to indicate the tag
// for normal cases and the case that the type of the c-array is arithmetic
template <bool>
struct c_array_tag
{
typedef geometry_not_recognized_tag type;
};
template <>
struct c_array_tag<true>
{
typedef point_tag type;
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
// Assign the point-tag, preventing arrays of points getting a point-tag
template <typename CoordinateType, std::size_t DimensionCount>
struct tag<CoordinateType[DimensionCount]>
: detail::c_array_tag<std::is_arithmetic<CoordinateType>::value> {};
template <typename CoordinateType, std::size_t DimensionCount>
struct coordinate_type<CoordinateType[DimensionCount]>
{
typedef CoordinateType type;
};
template <typename CoordinateType, std::size_t DimensionCount>
struct dimension<CoordinateType[DimensionCount]>
: std::integral_constant<std::size_t, DimensionCount>
{};
template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
struct access<CoordinateType[DimensionCount], Dimension>
{
static inline CoordinateType get(CoordinateType const p[DimensionCount])
{
return p[Dimension];
}
static inline void set(CoordinateType p[DimensionCount],
CoordinateType const& value)
{
p[Dimension] = value;
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
#define BOOST_GEOMETRY_REGISTER_C_ARRAY_CS(CoordinateSystem) \
namespace boost { namespace geometry { namespace traits { \
template <typename T, std::size_t N> \
struct coordinate_system<T[N]> \
{ \
typedef CoordinateSystem type; \
}; \
}}}
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_C_ARRAY_HPP
+87
View File
@@ -0,0 +1,87 @@
// Boost.Geometry
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_DETAIL_ANY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_DETAIL_ANY_HPP
#include <utility>
#include <boost/geometry/util/sequence.hpp>
#include <boost/geometry/util/type_traits_std.hpp>
namespace boost { namespace geometry
{
namespace detail
{
template
<
typename CastPolicy,
typename TypeSequence,
std::size_t N = util::sequence_size<TypeSequence>::value
>
struct visit_any
{
static const std::size_t M = N / 2;
template <std::size_t Offset, typename Function, typename Any>
static bool apply(Function && function, Any && any)
{
return visit_any<CastPolicy, TypeSequence, M>::template apply<Offset>(
std::forward<Function>(function), std::forward<Any>(any))
|| visit_any<CastPolicy, TypeSequence, N - M>::template apply<Offset + M>(
std::forward<Function>(function), std::forward<Any>(any));
}
};
template <typename CastPolicy, typename TypeSequence>
struct visit_any<CastPolicy, TypeSequence, 1>
{
template <std::size_t Offset, typename Function, typename Any>
static bool apply(Function && function, Any && any)
{
using elem_t = typename util::sequence_element<Offset, TypeSequence>::type;
using geom_t = util::transcribe_const_t<std::remove_reference_t<Any>, elem_t>;
geom_t * g = CastPolicy::template apply<geom_t>(&any);
if (g != nullptr)
{
using geom_ref_t = std::conditional_t
<
std::is_rvalue_reference<decltype(any)>::value,
geom_t&&, geom_t&
>;
function(static_cast<geom_ref_t>(*g));
return true;
}
else
{
return false;
}
}
};
template <typename CastPolicy, typename TypeSequence>
struct visit_any<CastPolicy, TypeSequence, 0>
{
template <std::size_t Offset, typename Function, typename Any>
static bool apply(Function &&, Any &&)
{
return false;
}
};
} // namespace detail
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_DETAIL_ANY_HPP
+82
View File
@@ -0,0 +1,82 @@
// Boost.Geometry
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ANY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ANY_HPP
#include <boost/config.hpp>
#ifndef BOOST_NO_CXX17_HDR_ANY
#include <any>
#include <utility>
#include <boost/geometry/geometries/adapted/detail/any.hpp>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/visit.hpp>
namespace boost { namespace geometry
{
namespace detail
{
struct std_any_cast_policy
{
template <typename T, typename Any>
static inline T * apply(Any * any_ptr)
{
return std::any_cast<T>(any_ptr);
}
};
} // namespace detail
namespace traits
{
template <>
struct tag<std::any>
{
using type = dynamic_geometry_tag;
};
template <>
struct visit<std::any>
{
template <typename Function, typename Any>
static void apply(Function && function, Any && any)
{
using types_t = typename geometry_types<util::remove_cref_t<Any>>::type;
geometry::detail::visit_any
<
geometry::detail::std_any_cast_policy, types_t
>::template apply<0>(std::forward<Function>(function), std::forward<Any>(any));
}
};
} // namespace traits
}} // namespace boost::geometry
#endif // BOOST_NO_CXX17_HDR_ANY
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ANY_HPP
+121
View File
@@ -0,0 +1,121 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2010 Alfredo Correa
// Copyright (c) 2010-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2016 Norbert Wenzel
// This file was modified by Oracle on 2020.
// Modifications copyright (c) 2020, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
#include <boost/config.hpp>
#define BOOST_GEOMETRY_ADAPTED_STD_ARRAY_TAG_DEFINED
#include <array>
#include <cstddef>
#include <type_traits>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/cs.hpp>
#include <boost/geometry/core/coordinate_dimension.hpp>
#include <boost/geometry/core/coordinate_type.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
#ifndef DOXYGEN_NO_DETAIL
namespace detail
{
// Create class and specialization to indicate the tag
// for normal cases and the case that the type of the std-array is arithmetic
template <bool>
struct std_array_tag
{
typedef geometry_not_recognized_tag type;
};
template <>
struct std_array_tag<true>
{
typedef point_tag type;
};
} // namespace detail
#endif // DOXYGEN_NO_DETAIL
// Assign the point-tag, preventing arrays of points getting a point-tag
template <typename CoordinateType, std::size_t DimensionCount>
struct tag<std::array<CoordinateType, DimensionCount> >
: detail::std_array_tag<std::is_arithmetic<CoordinateType>::value> {};
template <typename CoordinateType, std::size_t DimensionCount>
struct coordinate_type<std::array<CoordinateType, DimensionCount> >
{
typedef CoordinateType type;
};
template <typename CoordinateType, std::size_t DimensionCount>
struct dimension<std::array<CoordinateType, DimensionCount> >
: std::integral_constant<std::size_t, DimensionCount>
{};
template <typename CoordinateType, std::size_t DimensionCount, std::size_t Dimension>
struct access<std::array<CoordinateType, DimensionCount>, Dimension>
{
static inline CoordinateType get(std::array<CoordinateType, DimensionCount> const& a)
{
return a[Dimension];
}
static inline void set(std::array<CoordinateType, DimensionCount>& a,
CoordinateType const& value)
{
a[Dimension] = value;
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
#define BOOST_GEOMETRY_REGISTER_STD_ARRAY_CS(CoordinateSystem) \
namespace boost { namespace geometry { namespace traits { \
template <class T, std::size_t N> \
struct coordinate_system<std::array<T, N> > \
{ \
typedef CoordinateSystem type; \
}; \
}}}
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_ARRAY_HPP
@@ -0,0 +1,98 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
// Copyright (c) 2008-2012 Barend Gehrels, Amsterdam, the Netherlands.
// Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
// Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
// (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
// Use, modification and distribution is subject to the Boost Software License,
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
// Only possible if the std::pair is not used for iterator/pair
// (maybe it is possible to avoid that by detecting in the other file
// if an iterator was used in the pair)
#ifdef BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED
#error Include only one headerfile to register tag for adapted std:: containers or iterator pair
#endif
#define BOOST_GEOMETRY_ADAPTED_STD_RANGE_TAG_DEFINED
#include <cstddef>
#include <boost/geometry/core/access.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
namespace boost { namespace geometry
{
#ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
namespace traits
{
template <typename Point>
struct tag<std::pair<Point, Point> >
{
typedef segment_tag type;
};
template <typename Point>
struct point_type<std::pair<Point, Point> >
{
typedef Point type;
};
template <typename Point, std::size_t Dimension>
struct indexed_access<std::pair<Point, Point>, 0, Dimension>
{
typedef typename geometry::coordinate_type<Point>::type coordinate_type;
static inline coordinate_type get(std::pair<Point, Point> const& s)
{
return geometry::get<Dimension>(s.first);
}
static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
{
geometry::set<Dimension>(s.first, value);
}
};
template <typename Point, std::size_t Dimension>
struct indexed_access<std::pair<Point, Point>, 1, Dimension>
{
typedef typename geometry::coordinate_type<Point>::type coordinate_type;
static inline coordinate_type get(std::pair<Point, Point> const& s)
{
return geometry::get<Dimension>(s.second);
}
static inline void set(std::pair<Point, Point>& s, coordinate_type const& value)
{
geometry::set<Dimension>(s.second, value);
}
};
} // namespace traits
#endif // DOXYGEN_NO_TRAITS_SPECIALIZATIONS
}} // namespace boost::geometry
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_PAIR_AS_SEGMENT_HPP
+80
View File
@@ -0,0 +1,80 @@
// Boost.Geometry
// Copyright (c) 2021, Oracle and/or its affiliates.
// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle
// Licensed under the Boost Software License version 1.0.
// http://www.boost.org/users/license.html
#ifndef BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_VARIANT_HPP
#define BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_VARIANT_HPP
#include <boost/config.hpp>
#ifndef BOOST_NO_CXX17_HDR_VARIANT
#include <utility>
#include <variant>
#include <boost/geometry/core/geometry_types.hpp>
#include <boost/geometry/core/tag.hpp>
#include <boost/geometry/core/tags.hpp>
#include <boost/geometry/core/visit.hpp>
#include <boost/geometry/util/sequence.hpp>
namespace boost { namespace geometry
{
namespace traits
{
template <typename ...Ts>
struct tag<std::variant<Ts...>>
{
using type = dynamic_geometry_tag;
};
template <typename ...Ts>
struct visit<std::variant<Ts...>>
{
template <typename Function, typename Variant>
static void apply(Function && function, Variant && variant)
{
std::visit(std::forward<Function>(function),
std::forward<Variant>(variant));
}
};
template <typename ...Ts, typename ...Us>
struct visit<std::variant<Ts...>, std::variant<Us...>>
{
template <typename Function, typename Variant1, typename Variant2>
static void apply(Function && function, Variant1 && variant1, Variant2 && variant2)
{
std::visit(std::forward<Function>(function),
std::forward<Variant1>(variant1),
std::forward<Variant2>(variant2));
}
};
template <typename ...Ts>
struct geometry_types<std::variant<Ts...>>
{
using type = util::type_sequence<Ts...>;
};
} // namespace traits
}} // namespace boost::geometry
#endif // BOOST_NO_CXX17_HDR_VARIANT
#endif // BOOST_GEOMETRY_GEOMETRIES_ADAPTED_STD_VARIANT_HPP