Chris@16
|
1 // Boost.Geometry (aka GGL, Generic Geometry Library)
|
Chris@16
|
2
|
Chris@16
|
3 // Copyright (c) 2007-2012 Barend Gehrels, Amsterdam, the Netherlands.
|
Chris@16
|
4 // Copyright (c) 2008-2012 Bruno Lalande, Paris, France.
|
Chris@16
|
5 // Copyright (c) 2009-2012 Mateusz Loskot, London, UK.
|
Chris@16
|
6
|
Chris@16
|
7 // Parts of Boost.Geometry are redesigned from Geodan's Geographic Library
|
Chris@16
|
8 // (geolib/GGL), copyright (c) 1995-2010 Geodan, Amsterdam, the Netherlands.
|
Chris@16
|
9
|
Chris@16
|
10 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
11 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
12 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
13
|
Chris@16
|
14 #ifndef BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP
|
Chris@16
|
15 #define BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP
|
Chris@16
|
16
|
Chris@16
|
17 #include <boost/geometry/algorithms/assign.hpp>
|
Chris@16
|
18
|
Chris@16
|
19 #include <boost/geometry/geometries/concepts/check.hpp>
|
Chris@16
|
20
|
Chris@16
|
21 namespace boost { namespace geometry
|
Chris@16
|
22 {
|
Chris@16
|
23
|
Chris@16
|
24 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
25 namespace detail { namespace make
|
Chris@16
|
26 {
|
Chris@16
|
27
|
Chris@16
|
28 /*!
|
Chris@16
|
29 \brief Construct a geometry
|
Chris@16
|
30 \ingroup make
|
Chris@16
|
31 \tparam Geometry \tparam_geometry
|
Chris@16
|
32 \tparam Range \tparam_range_point
|
Chris@16
|
33 \param range \param_range_point
|
Chris@16
|
34 \return The constructed geometry, here: a linestring or a ring
|
Chris@16
|
35
|
Chris@16
|
36 \qbk{distinguish, with a range}
|
Chris@16
|
37 \qbk{
|
Chris@16
|
38 [heading Example]
|
Chris@16
|
39 [make_with_range] [make_with_range_output]
|
Chris@16
|
40
|
Chris@16
|
41 [heading See also]
|
Chris@16
|
42 \* [link geometry.reference.algorithms.assign.assign_points assign]
|
Chris@16
|
43 }
|
Chris@16
|
44 */
|
Chris@16
|
45 template <typename Geometry, typename Range>
|
Chris@16
|
46 inline Geometry make_points(Range const& range)
|
Chris@16
|
47 {
|
Chris@16
|
48 concept::check<Geometry>();
|
Chris@16
|
49
|
Chris@16
|
50 Geometry geometry;
|
Chris@16
|
51 geometry::append(geometry, range);
|
Chris@16
|
52 return geometry;
|
Chris@16
|
53 }
|
Chris@16
|
54
|
Chris@16
|
55 }} // namespace detail::make
|
Chris@16
|
56 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
57
|
Chris@16
|
58 /*!
|
Chris@16
|
59 \brief Construct a geometry
|
Chris@16
|
60 \ingroup make
|
Chris@16
|
61 \details
|
Chris@16
|
62 \note It does not work with array-point types, like int[2]
|
Chris@16
|
63 \tparam Geometry \tparam_geometry
|
Chris@16
|
64 \tparam Type \tparam_numeric to specify the coordinates
|
Chris@16
|
65 \param c1 \param_x
|
Chris@16
|
66 \param c2 \param_y
|
Chris@16
|
67 \return The constructed geometry, here: a 2D point
|
Chris@16
|
68
|
Chris@16
|
69 \qbk{distinguish, 2 coordinate values}
|
Chris@16
|
70 \qbk{
|
Chris@16
|
71 [heading Example]
|
Chris@16
|
72 [make_2d_point] [make_2d_point_output]
|
Chris@16
|
73
|
Chris@16
|
74 [heading See also]
|
Chris@16
|
75 \* [link geometry.reference.algorithms.assign.assign_values_3_2_coordinate_values assign]
|
Chris@16
|
76 }
|
Chris@16
|
77 */
|
Chris@16
|
78 template <typename Geometry, typename Type>
|
Chris@16
|
79 inline Geometry make(Type const& c1, Type const& c2)
|
Chris@16
|
80 {
|
Chris@16
|
81 concept::check<Geometry>();
|
Chris@16
|
82
|
Chris@16
|
83 Geometry geometry;
|
Chris@16
|
84 dispatch::assign
|
Chris@16
|
85 <
|
Chris@16
|
86 typename tag<Geometry>::type,
|
Chris@16
|
87 Geometry,
|
Chris@16
|
88 geometry::dimension<Geometry>::type::value
|
Chris@16
|
89 >::apply(geometry, c1, c2);
|
Chris@16
|
90 return geometry;
|
Chris@16
|
91 }
|
Chris@16
|
92
|
Chris@16
|
93 /*!
|
Chris@16
|
94 \brief Construct a geometry
|
Chris@16
|
95 \ingroup make
|
Chris@16
|
96 \tparam Geometry \tparam_geometry
|
Chris@16
|
97 \tparam Type \tparam_numeric to specify the coordinates
|
Chris@16
|
98 \param c1 \param_x
|
Chris@16
|
99 \param c2 \param_y
|
Chris@16
|
100 \param c3 \param_z
|
Chris@16
|
101 \return The constructed geometry, here: a 3D point
|
Chris@16
|
102
|
Chris@16
|
103 \qbk{distinguish, 3 coordinate values}
|
Chris@16
|
104 \qbk{
|
Chris@16
|
105 [heading Example]
|
Chris@16
|
106 [make_3d_point] [make_3d_point_output]
|
Chris@16
|
107
|
Chris@16
|
108 [heading See also]
|
Chris@16
|
109 \* [link geometry.reference.algorithms.assign.assign_values_4_3_coordinate_values assign]
|
Chris@16
|
110 }
|
Chris@16
|
111 */
|
Chris@16
|
112 template <typename Geometry, typename Type>
|
Chris@16
|
113 inline Geometry make(Type const& c1, Type const& c2, Type const& c3)
|
Chris@16
|
114 {
|
Chris@16
|
115 concept::check<Geometry>();
|
Chris@16
|
116
|
Chris@16
|
117 Geometry geometry;
|
Chris@16
|
118 dispatch::assign
|
Chris@16
|
119 <
|
Chris@16
|
120 typename tag<Geometry>::type,
|
Chris@16
|
121 Geometry,
|
Chris@16
|
122 geometry::dimension<Geometry>::type::value
|
Chris@16
|
123 >::apply(geometry, c1, c2, c3);
|
Chris@16
|
124 return geometry;
|
Chris@16
|
125 }
|
Chris@16
|
126
|
Chris@16
|
127 template <typename Geometry, typename Type>
|
Chris@16
|
128 inline Geometry make(Type const& c1, Type const& c2, Type const& c3, Type const& c4)
|
Chris@16
|
129 {
|
Chris@16
|
130 concept::check<Geometry>();
|
Chris@16
|
131
|
Chris@16
|
132 Geometry geometry;
|
Chris@16
|
133 dispatch::assign
|
Chris@16
|
134 <
|
Chris@16
|
135 typename tag<Geometry>::type,
|
Chris@16
|
136 Geometry,
|
Chris@16
|
137 geometry::dimension<Geometry>::type::value
|
Chris@16
|
138 >::apply(geometry, c1, c2, c3, c4);
|
Chris@16
|
139 return geometry;
|
Chris@16
|
140 }
|
Chris@16
|
141
|
Chris@16
|
142
|
Chris@16
|
143
|
Chris@16
|
144
|
Chris@16
|
145
|
Chris@16
|
146 /*!
|
Chris@16
|
147 \brief Construct a box with inverse infinite coordinates
|
Chris@16
|
148 \ingroup make
|
Chris@16
|
149 \details The make_inverse function initializes a 2D or 3D box with large coordinates, the
|
Chris@16
|
150 min corner is very large, the max corner is very small. This is useful e.g. in combination
|
Chris@16
|
151 with the expand function, to determine the bounding box of a series of geometries.
|
Chris@16
|
152 \tparam Geometry \tparam_geometry
|
Chris@16
|
153 \return The constructed geometry, here: a box
|
Chris@16
|
154
|
Chris@16
|
155 \qbk{
|
Chris@16
|
156 [heading Example]
|
Chris@16
|
157 [make_inverse] [make_inverse_output]
|
Chris@16
|
158
|
Chris@16
|
159 [heading See also]
|
Chris@16
|
160 \* [link geometry.reference.algorithms.assign.assign_inverse assign_inverse]
|
Chris@16
|
161 }
|
Chris@16
|
162 */
|
Chris@16
|
163 template <typename Geometry>
|
Chris@16
|
164 inline Geometry make_inverse()
|
Chris@16
|
165 {
|
Chris@16
|
166 concept::check<Geometry>();
|
Chris@16
|
167
|
Chris@16
|
168 Geometry geometry;
|
Chris@16
|
169 dispatch::assign_inverse
|
Chris@16
|
170 <
|
Chris@16
|
171 typename tag<Geometry>::type,
|
Chris@16
|
172 Geometry
|
Chris@16
|
173 >::apply(geometry);
|
Chris@16
|
174 return geometry;
|
Chris@16
|
175 }
|
Chris@16
|
176
|
Chris@16
|
177 /*!
|
Chris@16
|
178 \brief Construct a geometry with its coordinates initialized to zero
|
Chris@16
|
179 \ingroup make
|
Chris@16
|
180 \details The make_zero function initializes a 2D or 3D point or box with coordinates of zero
|
Chris@16
|
181 \tparam Geometry \tparam_geometry
|
Chris@16
|
182 \return The constructed and zero-initialized geometry
|
Chris@16
|
183 */
|
Chris@16
|
184 template <typename Geometry>
|
Chris@16
|
185 inline Geometry make_zero()
|
Chris@16
|
186 {
|
Chris@16
|
187 concept::check<Geometry>();
|
Chris@16
|
188
|
Chris@16
|
189 Geometry geometry;
|
Chris@16
|
190 dispatch::assign_zero
|
Chris@16
|
191 <
|
Chris@16
|
192 typename tag<Geometry>::type,
|
Chris@16
|
193 Geometry
|
Chris@16
|
194 >::apply(geometry);
|
Chris@16
|
195 return geometry;
|
Chris@16
|
196 }
|
Chris@16
|
197
|
Chris@16
|
198 }} // namespace boost::geometry
|
Chris@16
|
199
|
Chris@16
|
200 #endif // BOOST_GEOMETRY_ALGORITHMS_MAKE_HPP
|