File indexing completed on 2025-01-18 09:35:28
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP
0016 #define BOOST_GEOMETRY_GEOMETRIES_POLYGON_HPP
0017
0018 #include <memory>
0019 #include <vector>
0020
0021 #include <boost/concept/assert.hpp>
0022
0023 #include <boost/geometry/core/exterior_ring.hpp>
0024 #include <boost/geometry/core/interior_rings.hpp>
0025 #include <boost/geometry/core/point_type.hpp>
0026 #include <boost/geometry/core/ring_type.hpp>
0027 #include <boost/geometry/geometries/concepts/point_concept.hpp>
0028 #include <boost/geometry/geometries/ring.hpp>
0029
0030 #include <boost/config.hpp>
0031
0032 #include <initializer_list>
0033
0034
0035 namespace boost { namespace geometry
0036 {
0037
0038 namespace model
0039 {
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066 template
0067 <
0068 typename Point,
0069 bool ClockWise = true,
0070 bool Closed = true,
0071 template<typename, typename> class PointList = std::vector,
0072 template<typename, typename> class RingList = std::vector,
0073 template<typename> class PointAlloc = std::allocator,
0074 template<typename> class RingAlloc = std::allocator
0075 >
0076 class polygon
0077 {
0078 BOOST_CONCEPT_ASSERT( (concepts::Point<Point>) );
0079
0080 public:
0081
0082
0083 typedef Point point_type;
0084 typedef ring<Point, ClockWise, Closed, PointList, PointAlloc> ring_type;
0085 typedef RingList<ring_type , RingAlloc<ring_type > > inner_container_type;
0086
0087 inline ring_type const& outer() const { return m_outer; }
0088 inline inner_container_type const& inners() const { return m_inners; }
0089
0090 inline ring_type& outer() { return m_outer; }
0091 inline inner_container_type & inners() { return m_inners; }
0092
0093
0094
0095
0096
0097 inline polygon()
0098 : m_outer()
0099 , m_inners()
0100 {}
0101
0102
0103 inline polygon(std::initializer_list<ring_type> l)
0104 : m_outer(l.size() > 0 ? *l.begin() : ring_type())
0105 , m_inners(l.size() > 0 ? l.begin() + 1 : l.begin(), l.end())
0106 {}
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131 inline void clear()
0132 {
0133 m_outer.clear();
0134 m_inners.clear();
0135 }
0136
0137 private:
0138
0139 ring_type m_outer;
0140 inner_container_type m_inners;
0141 };
0142
0143
0144 }
0145
0146
0147 #ifndef DOXYGEN_NO_TRAITS_SPECIALIZATIONS
0148 namespace traits
0149 {
0150
0151 template
0152 <
0153 typename Point,
0154 bool ClockWise, bool Closed,
0155 template<typename, typename> class PointList,
0156 template<typename, typename> class RingList,
0157 template<typename> class PointAlloc,
0158 template<typename> class RingAlloc
0159 >
0160 struct tag
0161 <
0162 model::polygon
0163 <
0164 Point, ClockWise, Closed,
0165 PointList, RingList, PointAlloc, RingAlloc
0166 >
0167 >
0168 {
0169 typedef polygon_tag type;
0170 };
0171
0172 template
0173 <
0174 typename Point,
0175 bool ClockWise, bool Closed,
0176 template<typename, typename> class PointList,
0177 template<typename, typename> class RingList,
0178 template<typename> class PointAlloc,
0179 template<typename> class RingAlloc
0180 >
0181 struct ring_const_type
0182 <
0183 model::polygon
0184 <
0185 Point, ClockWise, Closed,
0186 PointList, RingList, PointAlloc, RingAlloc
0187 >
0188 >
0189 {
0190 typedef typename model::polygon
0191 <
0192 Point, ClockWise, Closed,
0193 PointList, RingList,
0194 PointAlloc, RingAlloc
0195 >::ring_type const& type;
0196 };
0197
0198
0199 template
0200 <
0201 typename Point,
0202 bool ClockWise, bool Closed,
0203 template<typename, typename> class PointList,
0204 template<typename, typename> class RingList,
0205 template<typename> class PointAlloc,
0206 template<typename> class RingAlloc
0207 >
0208 struct ring_mutable_type
0209 <
0210 model::polygon
0211 <
0212 Point, ClockWise, Closed,
0213 PointList, RingList, PointAlloc, RingAlloc
0214 >
0215 >
0216 {
0217 typedef typename model::polygon
0218 <
0219 Point, ClockWise, Closed,
0220 PointList, RingList,
0221 PointAlloc, RingAlloc
0222 >::ring_type& type;
0223 };
0224
0225 template
0226 <
0227 typename Point,
0228 bool ClockWise, bool Closed,
0229 template<typename, typename> class PointList,
0230 template<typename, typename> class RingList,
0231 template<typename> class PointAlloc,
0232 template<typename> class RingAlloc
0233 >
0234 struct interior_const_type
0235 <
0236 model::polygon
0237 <
0238 Point, ClockWise, Closed,
0239 PointList, RingList,
0240 PointAlloc, RingAlloc
0241 >
0242 >
0243 {
0244 typedef typename model::polygon
0245 <
0246 Point, ClockWise, Closed,
0247 PointList, RingList,
0248 PointAlloc, RingAlloc
0249 >::inner_container_type const& type;
0250 };
0251
0252
0253 template
0254 <
0255 typename Point,
0256 bool ClockWise, bool Closed,
0257 template<typename, typename> class PointList,
0258 template<typename, typename> class RingList,
0259 template<typename> class PointAlloc,
0260 template<typename> class RingAlloc
0261 >
0262 struct interior_mutable_type
0263 <
0264 model::polygon
0265 <
0266 Point, ClockWise, Closed,
0267 PointList, RingList,
0268 PointAlloc, RingAlloc
0269 >
0270 >
0271 {
0272 typedef typename model::polygon
0273 <
0274 Point, ClockWise, Closed,
0275 PointList, RingList,
0276 PointAlloc, RingAlloc
0277 >::inner_container_type& type;
0278 };
0279
0280
0281 template
0282 <
0283 typename Point,
0284 bool ClockWise, bool Closed,
0285 template<typename, typename> class PointList,
0286 template<typename, typename> class RingList,
0287 template<typename> class PointAlloc,
0288 template<typename> class RingAlloc
0289 >
0290 struct exterior_ring
0291 <
0292 model::polygon
0293 <
0294 Point, ClockWise, Closed,
0295 PointList, RingList, PointAlloc, RingAlloc
0296 >
0297 >
0298 {
0299 typedef model::polygon
0300 <
0301 Point, ClockWise, Closed,
0302 PointList, RingList,
0303 PointAlloc, RingAlloc
0304 > polygon_type;
0305
0306 static inline typename polygon_type::ring_type& get(polygon_type& p)
0307 {
0308 return p.outer();
0309 }
0310
0311 static inline typename polygon_type::ring_type const& get(
0312 polygon_type const& p)
0313 {
0314 return p.outer();
0315 }
0316 };
0317
0318 template
0319 <
0320 typename Point,
0321 bool ClockWise, bool Closed,
0322 template<typename, typename> class PointList,
0323 template<typename, typename> class RingList,
0324 template<typename> class PointAlloc,
0325 template<typename> class RingAlloc
0326 >
0327 struct interior_rings
0328 <
0329 model::polygon
0330 <
0331 Point, ClockWise, Closed,
0332 PointList, RingList,
0333 PointAlloc, RingAlloc
0334 >
0335 >
0336 {
0337 typedef model::polygon
0338 <
0339 Point, ClockWise, Closed, PointList, RingList,
0340 PointAlloc, RingAlloc
0341 > polygon_type;
0342
0343 static inline typename polygon_type::inner_container_type& get(
0344 polygon_type& p)
0345 {
0346 return p.inners();
0347 }
0348
0349 static inline typename polygon_type::inner_container_type const& get(
0350 polygon_type const& p)
0351 {
0352 return p.inners();
0353 }
0354 };
0355
0356 }
0357 #endif
0358
0359
0360
0361 }}
0362
0363 #endif