summaryrefslogtreecommitdiff
path: root/boost/geometry/strategies/cartesian/intersection.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/geometry/strategies/cartesian/intersection.hpp')
-rw-r--r--boost/geometry/strategies/cartesian/intersection.hpp47
1 files changed, 43 insertions, 4 deletions
diff --git a/boost/geometry/strategies/cartesian/intersection.hpp b/boost/geometry/strategies/cartesian/intersection.hpp
index 233bb50b64..10fd73ba54 100644
--- a/boost/geometry/strategies/cartesian/intersection.hpp
+++ b/boost/geometry/strategies/cartesian/intersection.hpp
@@ -1,7 +1,7 @@
// Boost.Geometry (aka GGL, Generic Geometry Library)
// Copyright (c) 2007-2014 Barend Gehrels, Amsterdam, the Netherlands.
-// Copyright (c) 2013-2014 Adam Wulkiewicz, Lodz, Poland.
+// Copyright (c) 2013-2017 Adam Wulkiewicz, Lodz, Poland.
// This file was modified by Oracle on 2014, 2016, 2017.
// Modifications copyright (c) 2014-2017, Oracle and/or its affiliates.
@@ -33,7 +33,7 @@
#include <boost/geometry/util/promote_integral.hpp>
#include <boost/geometry/util/select_calculation_type.hpp>
-#include <boost/geometry/strategies/cartesian/area_surveyor.hpp>
+#include <boost/geometry/strategies/cartesian/area.hpp>
#include <boost/geometry/strategies/cartesian/distance_pythagoras.hpp>
#include <boost/geometry/strategies/cartesian/envelope_segment.hpp>
#include <boost/geometry/strategies/cartesian/point_in_poly_winding.hpp>
@@ -103,9 +103,8 @@ struct cartesian_segments
template <typename Geometry>
struct area_strategy
{
- typedef area::surveyor
+ typedef area::cartesian
<
- typename point_type<Geometry>::type,
CalculationType
> type;
};
@@ -144,6 +143,7 @@ struct cartesian_segments
template <typename CoordinateType, typename SegmentRatio>
struct segment_intersection_info
{
+ private :
typedef typename select_most_precise
<
CoordinateType, double
@@ -198,6 +198,45 @@ struct cartesian_segments
>(numerator * dy_promoted / denominator));
}
+ public :
+ template <typename Point, typename Segment1, typename Segment2>
+ void calculate(Point& point, Segment1 const& a, Segment2 const& b) const
+ {
+ bool use_a = true;
+
+ // Prefer one segment if one is on or near an endpoint
+ bool const a_near_end = robust_ra.near_end();
+ bool const b_near_end = robust_rb.near_end();
+ if (a_near_end && ! b_near_end)
+ {
+ use_a = true;
+ }
+ else if (b_near_end && ! a_near_end)
+ {
+ use_a = false;
+ }
+ else
+ {
+ // Prefer shorter segment
+ promoted_type const len_a = comparable_length_a();
+ promoted_type const len_b = comparable_length_b();
+ if (len_b < len_a)
+ {
+ use_a = false;
+ }
+ // else use_a is true but was already assigned like that
+ }
+
+ if (use_a)
+ {
+ assign_a(point, a, b);
+ }
+ else
+ {
+ assign_b(point, a, b);
+ }
+ }
+
CoordinateType dx_a, dy_a;
CoordinateType dx_b, dy_b;
SegmentRatio robust_ra;