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
|
Chris@16
|
5 // Use, modification and distribution is subject to the Boost Software License,
|
Chris@16
|
6 // Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
7 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
8
|
Chris@16
|
9 #ifndef BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP
|
Chris@16
|
10 #define BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP
|
Chris@16
|
11
|
Chris@16
|
12 #include <algorithm>
|
Chris@16
|
13
|
Chris@16
|
14 #include <boost/geometry/algorithms/detail/overlay/intersection_insert.hpp>
|
Chris@16
|
15
|
Chris@16
|
16 namespace boost { namespace geometry
|
Chris@16
|
17 {
|
Chris@16
|
18
|
Chris@16
|
19 #ifndef DOXYGEN_NO_DETAIL
|
Chris@16
|
20 namespace detail { namespace difference
|
Chris@16
|
21 {
|
Chris@16
|
22
|
Chris@16
|
23 /*!
|
Chris@16
|
24 \brief_calc2{difference} \brief_strategy
|
Chris@16
|
25 \ingroup difference
|
Chris@16
|
26 \details \details_calc2{difference_insert, spatial set theoretic difference}
|
Chris@16
|
27 \brief_strategy. \details_inserter{difference}
|
Chris@16
|
28 \tparam GeometryOut output geometry type, must be specified
|
Chris@16
|
29 \tparam Geometry1 \tparam_geometry
|
Chris@16
|
30 \tparam Geometry2 \tparam_geometry
|
Chris@16
|
31 \tparam OutputIterator output iterator
|
Chris@16
|
32 \tparam Strategy \tparam_strategy_overlay
|
Chris@16
|
33 \param geometry1 \param_geometry
|
Chris@16
|
34 \param geometry2 \param_geometry
|
Chris@16
|
35 \param out \param_out{difference}
|
Chris@16
|
36 \param strategy \param_strategy{difference}
|
Chris@16
|
37 \return \return_out
|
Chris@16
|
38
|
Chris@16
|
39 \qbk{distinguish,with strategy}
|
Chris@16
|
40 */
|
Chris@16
|
41 template
|
Chris@16
|
42 <
|
Chris@16
|
43 typename GeometryOut,
|
Chris@16
|
44 typename Geometry1,
|
Chris@16
|
45 typename Geometry2,
|
Chris@16
|
46 typename OutputIterator,
|
Chris@16
|
47 typename Strategy
|
Chris@16
|
48 >
|
Chris@16
|
49 inline OutputIterator difference_insert(Geometry1 const& geometry1,
|
Chris@16
|
50 Geometry2 const& geometry2, OutputIterator out,
|
Chris@16
|
51 Strategy const& strategy)
|
Chris@16
|
52 {
|
Chris@16
|
53 concept::check<Geometry1 const>();
|
Chris@16
|
54 concept::check<Geometry2 const>();
|
Chris@16
|
55 concept::check<GeometryOut>();
|
Chris@16
|
56
|
Chris@16
|
57 return geometry::dispatch::intersection_insert
|
Chris@16
|
58 <
|
Chris@16
|
59 Geometry1, Geometry2,
|
Chris@16
|
60 GeometryOut,
|
Chris@16
|
61 overlay_difference,
|
Chris@16
|
62 geometry::detail::overlay::do_reverse<geometry::point_order<Geometry1>::value>::value,
|
Chris@16
|
63 geometry::detail::overlay::do_reverse<geometry::point_order<Geometry2>::value, true>::value
|
Chris@16
|
64 >::apply(geometry1, geometry2, out, strategy);
|
Chris@16
|
65 }
|
Chris@16
|
66
|
Chris@16
|
67 /*!
|
Chris@16
|
68 \brief_calc2{difference}
|
Chris@16
|
69 \ingroup difference
|
Chris@16
|
70 \details \details_calc2{difference_insert, spatial set theoretic difference}.
|
Chris@16
|
71 \details_insert{difference}
|
Chris@16
|
72 \tparam GeometryOut output geometry type, must be specified
|
Chris@16
|
73 \tparam Geometry1 \tparam_geometry
|
Chris@16
|
74 \tparam Geometry2 \tparam_geometry
|
Chris@16
|
75 \tparam OutputIterator output iterator
|
Chris@16
|
76 \param geometry1 \param_geometry
|
Chris@16
|
77 \param geometry2 \param_geometry
|
Chris@16
|
78 \param out \param_out{difference}
|
Chris@16
|
79 \return \return_out
|
Chris@16
|
80
|
Chris@16
|
81 \qbk{[include reference/algorithms/difference_insert.qbk]}
|
Chris@16
|
82 */
|
Chris@16
|
83 template
|
Chris@16
|
84 <
|
Chris@16
|
85 typename GeometryOut,
|
Chris@16
|
86 typename Geometry1,
|
Chris@16
|
87 typename Geometry2,
|
Chris@16
|
88 typename OutputIterator
|
Chris@16
|
89 >
|
Chris@16
|
90 inline OutputIterator difference_insert(Geometry1 const& geometry1,
|
Chris@16
|
91 Geometry2 const& geometry2, OutputIterator out)
|
Chris@16
|
92 {
|
Chris@16
|
93 concept::check<Geometry1 const>();
|
Chris@16
|
94 concept::check<Geometry2 const>();
|
Chris@16
|
95 concept::check<GeometryOut>();
|
Chris@16
|
96
|
Chris@16
|
97 typedef strategy_intersection
|
Chris@16
|
98 <
|
Chris@16
|
99 typename cs_tag<GeometryOut>::type,
|
Chris@16
|
100 Geometry1,
|
Chris@16
|
101 Geometry2,
|
Chris@16
|
102 typename geometry::point_type<GeometryOut>::type
|
Chris@16
|
103 > strategy;
|
Chris@16
|
104
|
Chris@16
|
105 return difference_insert<GeometryOut>(geometry1, geometry2,
|
Chris@16
|
106 out, strategy());
|
Chris@16
|
107 }
|
Chris@16
|
108
|
Chris@16
|
109
|
Chris@16
|
110 }} // namespace detail::difference
|
Chris@16
|
111 #endif // DOXYGEN_NO_DETAIL
|
Chris@16
|
112
|
Chris@16
|
113
|
Chris@16
|
114
|
Chris@16
|
115 /*!
|
Chris@16
|
116 \brief_calc2{difference}
|
Chris@16
|
117 \ingroup difference
|
Chris@16
|
118 \details \details_calc2{difference, spatial set theoretic difference}.
|
Chris@16
|
119 \tparam Geometry1 \tparam_geometry
|
Chris@16
|
120 \tparam Geometry2 \tparam_geometry
|
Chris@16
|
121 \tparam Collection \tparam_output_collection
|
Chris@16
|
122 \param geometry1 \param_geometry
|
Chris@16
|
123 \param geometry2 \param_geometry
|
Chris@16
|
124 \param output_collection the output collection
|
Chris@16
|
125
|
Chris@16
|
126 \qbk{[include reference/algorithms/difference.qbk]}
|
Chris@16
|
127 */
|
Chris@16
|
128 template
|
Chris@16
|
129 <
|
Chris@16
|
130 typename Geometry1,
|
Chris@16
|
131 typename Geometry2,
|
Chris@16
|
132 typename Collection
|
Chris@16
|
133 >
|
Chris@16
|
134 inline void difference(Geometry1 const& geometry1,
|
Chris@16
|
135 Geometry2 const& geometry2, Collection& output_collection)
|
Chris@16
|
136 {
|
Chris@16
|
137 concept::check<Geometry1 const>();
|
Chris@16
|
138 concept::check<Geometry2 const>();
|
Chris@16
|
139
|
Chris@16
|
140 typedef typename boost::range_value<Collection>::type geometry_out;
|
Chris@16
|
141 concept::check<geometry_out>();
|
Chris@16
|
142
|
Chris@16
|
143 detail::difference::difference_insert<geometry_out>(
|
Chris@16
|
144 geometry1, geometry2,
|
Chris@16
|
145 std::back_inserter(output_collection));
|
Chris@16
|
146 }
|
Chris@16
|
147
|
Chris@16
|
148
|
Chris@16
|
149 }} // namespace boost::geometry
|
Chris@16
|
150
|
Chris@16
|
151
|
Chris@16
|
152 #endif // BOOST_GEOMETRY_ALGORITHMS_DIFFERENCE_HPP
|