Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:35:21

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 // Copyright (c) 2020-2023, Oracle and/or its affiliates.
0008 // Contributed and/or modified by Vissarion Fysikopoulos, on behalf of Oracle
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_ALGORITHMS_MAKE_HPP
0019 #define BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP
0020 
0021 #include <type_traits>
0022 
0023 #include "boost/geometry/algorithms/detail/assign_values.hpp"
0024 
0025 #include <boost/geometry/core/make.hpp>
0026 
0027 #include <boost/geometry/geometries/concepts/check.hpp>
0028 
0029 namespace boost { namespace geometry
0030 {
0031 
0032 #ifndef DOXYGEN_NO_DETAIL
0033 namespace detail { namespace make
0034 {
0035 
0036 /*!
0037 \brief Construct a geometry
0038 \ingroup make
0039 \tparam Geometry \tparam_geometry
0040 \tparam Range \tparam_range_point
0041 \param range \param_range_point
0042 \return The constructed geometry, here: a linestring or a ring
0043 \qbk{distinguish, with a range}
0044 \qbk{
0045 [heading Example]
0046 [make_with_range] [make_with_range_output]
0047 [heading See also]
0048 \* [link geometry.reference.algorithms.assign.assign_points assign]
0049 }
0050  */
0051 template <typename Geometry, typename Range>
0052 inline Geometry make_points(Range const& range)
0053 {
0054     concepts::check<Geometry>();
0055 
0056     Geometry geometry;
0057     geometry::append(geometry, range);
0058     return geometry;
0059 }
0060 
0061 }} // namespace detail::make
0062 #endif // DOXYGEN_NO_DETAIL
0063 
0064 /*!
0065 \brief Construct a geometry
0066 \ingroup make
0067 \details
0068 \note It does not work with array-point types, like int[2]
0069 \tparam Geometry \tparam_geometry
0070 \tparam Type \tparam_numeric to specify the coordinates
0071 \param c1 \param_x
0072 \param c2 \param_y
0073 \return The constructed geometry, here: a 2D point
0074 
0075 \qbk{distinguish, 2 coordinate values}
0076 \qbk{
0077 [heading Example]
0078 [make_2d_point] [make_2d_point_output]
0079 
0080 [heading See also]
0081 \* [link geometry.reference.algorithms.assign.assign_values_3_2_coordinate_values assign]
0082 }
0083 */
0084 template
0085 <
0086     typename Geometry,
0087     typename Type,
0088     std::enable_if_t<! traits::make<Geometry>::is_specialized, int> = 0
0089 >
0090 inline Geometry make(Type const& c1, Type const& c2)
0091 {
0092     concepts::check<Geometry>();
0093 
0094     Geometry geometry;
0095     dispatch::assign
0096         <
0097             typename tag<Geometry>::type,
0098             Geometry,
0099             geometry::dimension<Geometry>::type::value
0100         >::apply(geometry, c1, c2);
0101     return geometry;
0102 }
0103 
0104 
0105 template
0106 <
0107     typename Geometry,
0108     typename Type,
0109     std::enable_if_t<traits::make<Geometry>::is_specialized, int> = 0
0110 >
0111 constexpr inline Geometry make(Type const& c1, Type const& c2)
0112 {
0113     concepts::check<Geometry>();
0114 
0115     // NOTE: This is not fully equivalent to the above because assign uses
0116     //       numeric_cast which can't be used here since it's not constexpr.
0117     return traits::make<Geometry>::apply(c1, c2);
0118 }
0119 
0120 
0121 /*!
0122 \brief Construct a geometry
0123 \ingroup make
0124 \tparam Geometry \tparam_geometry
0125 \tparam Type \tparam_numeric to specify the coordinates
0126 \param c1 \param_x
0127 \param c2 \param_y
0128 \param c3 \param_z
0129 \return The constructed geometry, here: a 3D point
0130 
0131 \qbk{distinguish, 3 coordinate values}
0132 \qbk{
0133 [heading Example]
0134 [make_3d_point] [make_3d_point_output]
0135 
0136 [heading See also]
0137 \* [link geometry.reference.algorithms.assign.assign_values_4_3_coordinate_values assign]
0138 }
0139  */
0140 template
0141 <
0142     typename Geometry,
0143     typename Type,
0144     std::enable_if_t<! traits::make<Geometry>::is_specialized, int> = 0
0145 >
0146 inline Geometry make(Type const& c1, Type const& c2, Type const& c3)
0147 {
0148     concepts::check<Geometry>();
0149 
0150     Geometry geometry;
0151     dispatch::assign
0152         <
0153             typename tag<Geometry>::type,
0154             Geometry,
0155             geometry::dimension<Geometry>::type::value
0156         >::apply(geometry, c1, c2, c3);
0157     return geometry;
0158 }
0159 
0160 template
0161 <
0162     typename Geometry,
0163     typename Type,
0164     std::enable_if_t<traits::make<Geometry>::is_specialized, int> = 0
0165 >
0166 constexpr inline Geometry make(Type const& c1, Type const& c2, Type const& c3)
0167 {
0168     concepts::check<Geometry>();
0169 
0170     // NOTE: This is not fully equivalent to the above because assign uses
0171     //       numeric_cast which can't be used here since it's not constexpr.
0172     return traits::make<Geometry>::apply(c1, c2, c3);
0173 }
0174 
0175 
0176 template <typename Geometry, typename Type>
0177 inline Geometry make(Type const& c1, Type const& c2, Type const& c3, Type const& c4)
0178 {
0179     concepts::check<Geometry>();
0180 
0181     Geometry geometry;
0182     dispatch::assign
0183         <
0184             typename tag<Geometry>::type,
0185             Geometry,
0186             geometry::dimension<Geometry>::type::value
0187         >::apply(geometry, c1, c2, c3, c4);
0188     return geometry;
0189 }
0190 
0191 
0192 
0193 
0194 
0195 /*!
0196 \brief Construct a box with inverse infinite coordinates
0197 \ingroup make
0198 \details The make_inverse function initializes a 2D or 3D box with large coordinates, the
0199     min corner is very large, the max corner is very small. This is useful e.g. in combination
0200     with the expand function, to determine the bounding box of a series of geometries.
0201 \tparam Geometry \tparam_geometry
0202 \return The constructed geometry, here: a box
0203 
0204 \qbk{
0205 [heading Example]
0206 [make_inverse] [make_inverse_output]
0207 
0208 [heading See also]
0209 \* [link geometry.reference.algorithms.assign.assign_inverse assign_inverse]
0210 }
0211  */
0212 template <typename Geometry>
0213 inline Geometry make_inverse()
0214 {
0215     concepts::check<Geometry>();
0216 
0217     Geometry geometry;
0218     dispatch::assign_inverse
0219         <
0220             typename tag<Geometry>::type,
0221             Geometry
0222         >::apply(geometry);
0223     return geometry;
0224 }
0225 
0226 /*!
0227 \brief Construct a geometry with its coordinates initialized to zero
0228 \ingroup make
0229 \details The make_zero function initializes a 2D or 3D point or box with coordinates of zero
0230 \tparam Geometry \tparam_geometry
0231 \return The constructed and zero-initialized geometry
0232  */
0233 template <typename Geometry>
0234 inline Geometry make_zero()
0235 {
0236     concepts::check<Geometry>();
0237 
0238     Geometry geometry;
0239     dispatch::assign_zero
0240         <
0241             typename tag<Geometry>::type,
0242             Geometry
0243         >::apply(geometry);
0244     return geometry;
0245 }
0246 
0247 }} // namespace boost::geometry
0248 
0249 #endif // BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP