Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r78809 - trunk/boost/geometry/algorithms
From: bruno.lalande_at_[hidden]
Date: 2012-06-04 15:13:34


Author: bruno.lalande
Date: 2012-06-04 15:13:34 EDT (Mon, 04 Jun 2012)
New Revision: 78809
URL: http://svn.boost.org/trac/boost/changeset/78809

Log:
Made dispatch::disjoint more self-contained.
Text files modified:
   trunk/boost/geometry/algorithms/disjoint.hpp | 93 ++++++++++++++++-----------------------
   1 files changed, 39 insertions(+), 54 deletions(-)

Modified: trunk/boost/geometry/algorithms/disjoint.hpp
==============================================================================
--- trunk/boost/geometry/algorithms/disjoint.hpp (original)
+++ trunk/boost/geometry/algorithms/disjoint.hpp 2012-06-04 15:13:34 EDT (Mon, 04 Jun 2012)
@@ -184,68 +184,72 @@
 
 template
 <
- typename GeometryTag1, typename GeometryTag2,
     typename Geometry1, typename Geometry2,
- std::size_t DimensionCount
+ std::size_t DimensionCount = dimension<Geometry1>::type::value,
+ typename Tag1 = typename tag<Geometry1>::type,
+ typename Tag2 = typename tag<Geometry2>::type,
+ bool Reverse = reverse_dispatch<Geometry1, Geometry2>::type::value
>
 struct disjoint
     : detail::disjoint::general_areal<Geometry1, Geometry2>
 {};
 
 
-template <typename Point1, typename Point2, std::size_t DimensionCount>
-struct disjoint<point_tag, point_tag, Point1, Point2, DimensionCount>
+// If reversal is needed, perform it
+template
+<
+ typename Geometry1, typename Geometry2,
+ std::size_t DimensionCount,
+ typename Tag1, typename Tag2
+>
+struct disjoint<Geometry1, Geometry2, DimensionCount, Tag1, Tag2, true>
+ : disjoint<Geometry2, Geometry1, DimensionCount, Tag2, Tag1, false>
+{
+ static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
+ {
+ return disjoint
+ <
+ Geometry2, Geometry1,
+ DimensionCount,
+ Tag2, Tag1
+ >::apply(g2, g1);
+ }
+};
+
+
+template <typename Point1, typename Point2, std::size_t DimensionCount, bool Reverse>
+struct disjoint<Point1, Point2, DimensionCount, point_tag, point_tag, Reverse>
     : detail::disjoint::point_point<Point1, Point2, 0, DimensionCount>
 {};
 
 
-template <typename Box1, typename Box2, std::size_t DimensionCount>
-struct disjoint<box_tag, box_tag, Box1, Box2, DimensionCount>
+template <typename Box1, typename Box2, std::size_t DimensionCount, bool Reverse>
+struct disjoint<Box1, Box2, DimensionCount, box_tag, box_tag, Reverse>
     : detail::disjoint::box_box<Box1, Box2, 0, DimensionCount>
 {};
 
 
-template <typename Point, typename Box, std::size_t DimensionCount>
-struct disjoint<point_tag, box_tag, Point, Box, DimensionCount>
+template <typename Point, typename Box, std::size_t DimensionCount, bool Reverse>
+struct disjoint<Point, Box, DimensionCount, point_tag, box_tag, Reverse>
     : detail::disjoint::point_box<Point, Box, 0, DimensionCount>
 {};
 
-template <typename Linestring1, typename Linestring2>
-struct disjoint<linestring_tag, linestring_tag, Linestring1, Linestring2, 2>
+template <typename Linestring1, typename Linestring2, bool Reverse>
+struct disjoint<Linestring1, Linestring2, 2, linestring_tag, linestring_tag, Reverse>
     : detail::disjoint::disjoint_linear<Linestring1, Linestring2>
 {};
 
-template <typename Linestring1, typename Linestring2>
-struct disjoint<segment_tag, segment_tag, Linestring1, Linestring2, 2>
+template <typename Linestring1, typename Linestring2, bool Reverse>
+struct disjoint<Linestring1, Linestring2, 2, segment_tag, segment_tag, Reverse>
     : detail::disjoint::disjoint_segment<Linestring1, Linestring2>
 {};
 
-template <typename Linestring, typename Segment>
-struct disjoint<linestring_tag, segment_tag, Linestring, Segment, 2>
+template <typename Linestring, typename Segment, bool Reverse>
+struct disjoint<Linestring, Segment, 2, linestring_tag, segment_tag, Reverse>
     : detail::disjoint::disjoint_linear<Linestring, Segment>
 {};
 
 
-template
-<
- typename GeometryTag1, typename GeometryTag2,
- typename Geometry1, typename Geometry2,
- std::size_t DimensionCount
->
-struct disjoint_reversed
-{
- static inline bool apply(Geometry1 const& g1, Geometry2 const& g2)
- {
- return disjoint
- <
- GeometryTag2, GeometryTag1,
- Geometry2, Geometry1,
- DimensionCount
- >::apply(g2, g1);
- }
-};
-
-
 } // namespace dispatch
 #endif // DOXYGEN_NO_DISPATCH
 
@@ -272,26 +276,7 @@
             Geometry2 const
>();
 
- return boost::mpl::if_c
- <
- reverse_dispatch<Geometry1, Geometry2>::type::value,
- dispatch::disjoint_reversed
- <
- typename tag<Geometry1>::type,
- typename tag<Geometry2>::type,
- Geometry1,
- Geometry2,
- dimension<Geometry1>::type::value
- >,
- dispatch::disjoint
- <
- typename tag<Geometry1>::type,
- typename tag<Geometry2>::type,
- Geometry1,
- Geometry2,
- dimension<Geometry1>::type::value
- >
- >::type::apply(geometry1, geometry2);
+ return dispatch::disjoint<Geometry1, Geometry2>::apply(geometry1, geometry2);
 }
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk