File indexing completed on 2025-01-18 09:35:13
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #ifndef BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_DE9IM_HPP
0016 #define BOOST_GEOMETRY_ALGORITHMS_DETAIL_RELATE_DE9IM_HPP
0017
0018 #include <tuple>
0019
0020 #include <boost/geometry/algorithms/detail/relate/result.hpp>
0021 #include <boost/geometry/core/topological_dimension.hpp>
0022 #include <boost/geometry/core/tag.hpp>
0023
0024 #include <boost/geometry/util/sequence.hpp>
0025 #include <boost/geometry/util/tuples.hpp>
0026
0027 namespace boost { namespace geometry
0028 {
0029
0030 namespace de9im
0031 {
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042 class matrix
0043 : public detail::relate::matrix<3, 3>
0044 {
0045 #ifdef DOXYGEN_INVOKED
0046 public:
0047
0048
0049
0050 matrix();
0051
0052
0053
0054
0055
0056 char operator[](std::size_t index) const;
0057
0058
0059
0060
0061 const_iterator begin() const;
0062
0063
0064
0065
0066 const_iterator end() const;
0067
0068
0069
0070
0071 static std::size_t size();
0072
0073
0074
0075
0076 inline const char * data() const;
0077
0078
0079
0080
0081 inline std::string str() const;
0082 #endif
0083 };
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094 class mask
0095 : public detail::relate::mask<3, 3>
0096 {
0097 typedef detail::relate::mask<3, 3> base_type;
0098
0099 public:
0100
0101
0102
0103
0104 inline explicit mask(const char* code)
0105 : base_type(code)
0106 {}
0107
0108
0109
0110
0111
0112 inline explicit mask(std::string const& code)
0113 : base_type(code.c_str(), code.size())
0114 {}
0115 };
0116
0117
0118
0119
0120
0121
0122
0123
0124
0125
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137 template
0138 <
0139 char II = '*', char IB = '*', char IE = '*',
0140 char BI = '*', char BB = '*', char BE = '*',
0141 char EI = '*', char EB = '*', char EE = '*'
0142 >
0143 class static_mask
0144 : public detail::relate::static_mask
0145 <
0146 std::integer_sequence
0147 <
0148 char, II, IB, IE, BI, BB, BE, EI, EB, EE
0149 >,
0150 3, 3
0151 >
0152 {};
0153
0154
0155 inline
0156 std::tuple<mask, mask>
0157 operator||(mask const& m1, mask const& m2)
0158 {
0159 return std::tuple<mask, mask>(m1, m2);
0160 }
0161
0162 template <typename ...Masks>
0163 inline
0164 std::tuple<Masks..., mask>
0165 operator||(std::tuple<Masks...> const& t, mask const& m)
0166 {
0167 return geometry::tuples::push_back
0168 <
0169 std::tuple<Masks...>,
0170 mask
0171 >::apply(t, m);
0172 }
0173
0174 template
0175 <
0176 char II1, char IB1, char IE1,
0177 char BI1, char BB1, char BE1,
0178 char EI1, char EB1, char EE1,
0179 char II2, char IB2, char IE2,
0180 char BI2, char BB2, char BE2,
0181 char EI2, char EB2, char EE2
0182 >
0183 inline
0184 util::type_sequence
0185 <
0186 static_mask<II1, IB1, IE1, BI1, BB1, BE1, EI1, EB1, EE1>,
0187 static_mask<II2, IB2, IE2, BI2, BB2, BE2, EI2, EB2, EE2>
0188 >
0189 operator||(static_mask<II1, IB1, IE1, BI1, BB1, BE1, EI1, EB1, EE1> const& ,
0190 static_mask<II2, IB2, IE2, BI2, BB2, BE2, EI2, EB2, EE2> const& )
0191 {
0192 return util::type_sequence
0193 <
0194 static_mask<II1, IB1, IE1, BI1, BB1, BE1, EI1, EB1, EE1>,
0195 static_mask<II2, IB2, IE2, BI2, BB2, BE2, EI2, EB2, EE2>
0196 >();
0197 }
0198
0199 template
0200 <
0201 typename ...StaticMasks,
0202 char II, char IB, char IE,
0203 char BI, char BB, char BE,
0204 char EI, char EB, char EE
0205 >
0206 inline
0207 util::type_sequence
0208 <
0209 StaticMasks...,
0210 static_mask<II, IB, IE, BI, BB, BE, EI, EB, EE>
0211 >
0212 operator||(util::type_sequence<StaticMasks...> const& ,
0213 static_mask<II, IB, IE, BI, BB, BE, EI, EB, EE> const& )
0214 {
0215 return util::type_sequence
0216 <
0217 StaticMasks...,
0218 static_mask<II, IB, IE, BI, BB, BE, EI, EB, EE>
0219 >();
0220 }
0221
0222 }
0223
0224
0225 #ifndef DOXYGEN_NO_DETAIL
0226 namespace detail { namespace de9im
0227 {
0228
0229
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239 template <typename Geometry1, typename Geometry2>
0240 struct static_mask_equals_type
0241 {
0242 typedef geometry::de9im::static_mask<'T', '*', 'F', '*', '*', 'F', 'F', 'F', '*'> type;
0243
0244 };
0245
0246
0247 template <typename Geometry1, typename Geometry2>
0248 struct static_mask_disjoint_type
0249 {
0250 typedef geometry::de9im::static_mask<'F', 'F', '*', 'F', 'F', '*', '*', '*', '*'> type;
0251 };
0252
0253
0254 template
0255 <
0256 typename Geometry1,
0257 typename Geometry2,
0258 std::size_t Dim1 = geometry::topological_dimension<Geometry1>::value,
0259 std::size_t Dim2 = geometry::topological_dimension<Geometry2>::value
0260 >
0261 struct static_mask_touches_impl
0262 {
0263 typedef util::type_sequence
0264 <
0265 geometry::de9im::static_mask<'F', 'T', '*', '*', '*', '*', '*', '*', '*'>,
0266 geometry::de9im::static_mask<'F', '*', '*', 'T', '*', '*', '*', '*', '*'>,
0267 geometry::de9im::static_mask<'F', '*', '*', '*', 'T', '*', '*', '*', '*'>
0268 > type;
0269 };
0270
0271
0272 template <typename Geometry1, typename Geometry2>
0273 struct static_mask_touches_impl<Geometry1, Geometry2, 0, 0>
0274 {
0275 typedef geometry::detail::relate::false_mask type;
0276 };
0277
0278 template <typename Geometry1, typename Geometry2>
0279 struct static_mask_touches_not_pp_type
0280 : static_mask_touches_impl<Geometry1, Geometry2, 2, 2>
0281 {};
0282
0283 template <typename Geometry1, typename Geometry2>
0284 struct static_mask_touches_type
0285 : static_mask_touches_impl<Geometry1, Geometry2>
0286 {};
0287
0288
0289 template <typename Geometry1, typename Geometry2>
0290 struct static_mask_within_type
0291 {
0292 typedef geometry::de9im::static_mask<'T', '*', 'F', '*', '*', 'F', '*', '*', '*'> type;
0293 };
0294
0295
0296 template <typename Geometry1, typename Geometry2>
0297 struct static_mask_covered_by_type
0298 {
0299 typedef util::type_sequence
0300 <
0301 geometry::de9im::static_mask<'T', '*', 'F', '*', '*', 'F', '*', '*', '*'>,
0302 geometry::de9im::static_mask<'*', 'T', 'F', '*', '*', 'F', '*', '*', '*'>,
0303 geometry::de9im::static_mask<'*', '*', 'F', 'T', '*', 'F', '*', '*', '*'>,
0304 geometry::de9im::static_mask<'*', '*', 'F', '*', 'T', 'F', '*', '*', '*'>
0305 > type;
0306 };
0307
0308
0309
0310 template
0311 <
0312 typename Geometry1,
0313 typename Geometry2,
0314 std::size_t Dim1 = geometry::topological_dimension<Geometry1>::value,
0315 std::size_t Dim2 = geometry::topological_dimension<Geometry2>::value,
0316 bool D1LessD2 = (Dim1 < Dim2)
0317 >
0318 struct static_mask_crosses_impl
0319 {
0320 typedef geometry::de9im::static_mask<'T', '*', 'T', '*', '*', '*', '*', '*', '*'> type;
0321 };
0322
0323
0324 template
0325 <
0326 typename Geometry1, typename Geometry2, std::size_t Dim1, std::size_t Dim2
0327 >
0328 struct static_mask_crosses_impl<Geometry1, Geometry2, Dim1, Dim2, false>
0329 {
0330 typedef geometry::de9im::static_mask<'T', '*', '*', '*', '*', '*', 'T', '*', '*'> type;
0331 };
0332
0333 template
0334 <
0335 typename Geometry1, typename Geometry2, std::size_t Dim
0336 >
0337 struct static_mask_crosses_impl<Geometry1, Geometry2, Dim, Dim, false>
0338 {
0339 typedef geometry::detail::relate::false_mask type;
0340 };
0341
0342 template <typename Geometry1, typename Geometry2>
0343 struct static_mask_crosses_impl<Geometry1, Geometry2, 1, 1, false>
0344 {
0345 typedef geometry::de9im::static_mask<'0', '*', '*', '*', '*', '*', '*', '*', '*'> type;
0346 };
0347
0348 template <typename Geometry1, typename Geometry2>
0349 struct static_mask_crosses_type
0350 : static_mask_crosses_impl<Geometry1, Geometry2>
0351 {};
0352
0353 template <typename Geometry1, typename Geometry2>
0354 struct static_mask_crosses_d1_le_d2_type
0355 : static_mask_crosses_impl<Geometry1, Geometry2, 0, 1>
0356 {};
0357
0358 template <typename Geometry1, typename Geometry2>
0359 struct static_mask_crosses_d2_le_d1_type
0360 : static_mask_crosses_impl<Geometry1, Geometry2, 1, 0>
0361 {};
0362
0363 template <typename Geometry1, typename Geometry2>
0364 struct static_mask_crosses_d1_1_d2_1_type
0365 : static_mask_crosses_impl<Geometry1, Geometry2, 1, 1>
0366 {};
0367
0368
0369
0370
0371 template
0372 <
0373 typename Geometry1,
0374 typename Geometry2,
0375 std::size_t Dim1 = geometry::topological_dimension<Geometry1>::value,
0376 std::size_t Dim2 = geometry::topological_dimension<Geometry2>::value
0377 >
0378 struct static_mask_overlaps_impl
0379 {
0380 typedef geometry::detail::relate::false_mask type;
0381 };
0382
0383 template <typename Geometry1, typename Geometry2, std::size_t Dim>
0384 struct static_mask_overlaps_impl<Geometry1, Geometry2, Dim, Dim>
0385 {
0386 typedef geometry::de9im::static_mask<'T', '*', 'T', '*', '*', '*', 'T', '*', '*'> type;
0387 };
0388
0389 template <typename Geometry1, typename Geometry2>
0390 struct static_mask_overlaps_impl<Geometry1, Geometry2, 1, 1>
0391 {
0392 typedef geometry::de9im::static_mask<'1', '*', 'T', '*', '*', '*', 'T', '*', '*'> type;
0393 };
0394
0395 template <typename Geometry1, typename Geometry2>
0396 struct static_mask_overlaps_type
0397 : static_mask_overlaps_impl<Geometry1, Geometry2>
0398 {};
0399
0400 template <typename Geometry1, typename Geometry2>
0401 struct static_mask_overlaps_d1_eq_d2_type
0402 : static_mask_overlaps_impl<Geometry1, Geometry2, 2, 2>
0403 {};
0404
0405 template <typename Geometry1, typename Geometry2>
0406 struct static_mask_overlaps_d1_1_d2_1_type
0407 : static_mask_overlaps_impl<Geometry1, Geometry2, 1, 1>
0408 {};
0409
0410 }}
0411 #endif
0412
0413
0414 }}
0415
0416 #endif