[geometry] Fixed unit test for collinear intersections w.r.t new parameters

This commit is contained in:
Barend Gehrels 2014-01-19 22:33:58 +01:00
parent ecd0cd8499
commit 41f9c94e31
4 changed files with 63 additions and 32 deletions

View File

@ -127,6 +127,16 @@ public :
return result;
}
#if defined(BOOST_GEOMETRY_DEFINE_STREAM_OPERATOR_SEGMENT_RATIO)
friend std::ostream& operator<<(std::ostream &os, segment_ratio const& ratio)
{
os << ratio.m_numerator << "/" << ratio.m_denominator;
return os;
}
#endif
private :
Type m_numerator;
Type m_denominator;

View File

@ -15,6 +15,7 @@ test-suite boost-geometry-strategies
[ run projected_point.cpp ]
[ run pythagoras.cpp ]
[ run spherical_side.cpp ]
[ run segment_intersection_collinear.cpp ]
[ run transform_cs.cpp ]
[ run transformer.cpp ]
[ run within.cpp ]

View File

@ -103,16 +103,23 @@ static void test_segment_intersection(int caseno,
segment_type s34(p3,p4);
// Get the intersection point (or two points)
segment_intersection_points<P> is
= strategy::intersection::relate_cartesian_segments
typedef bg::detail::no_rescale_policy rescale_policy_type;
rescale_policy_type rescale_policy;
typedef bg::segment_intersection_points
<
P,
typename bg::segment_ratio_type
<
policies::relate::segments_intersection_points
<
segment_type,
segment_type,
segment_intersection_points<P>
>
>::apply(s12, s34);
P,
rescale_policy_type
>::type
> result_type;
result_type is = strategy::intersection::relate_cartesian_segments
<
bg::policies::relate::segments_intersection_points<result_type>
>::apply(s12, s34, rescale_policy);
// Get the Dimension Extended 9 Intersection Matrix (de9im) for Segments
// (this one is extended by GGL having opposite)
@ -127,8 +134,8 @@ static void test_segment_intersection(int caseno,
// Get just a character for Left/Right/intersects/etc, purpose is more for debugging
policies::relate::direction_type dir = strategy::intersection::relate_cartesian_segments
<
policies::relate::segments_direction<segment_type, segment_type>
>::apply(s12, s34);
policies::relate::segments_direction
>::apply(s12, s34, rescale_policy);
int expected_count = 0;

View File

@ -12,6 +12,7 @@
// Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#define BOOST_GEOMETRY_DEFINE_STREAM_OPERATOR_SEGMENT_RATIO
#include <geometry_test_common.hpp>
@ -75,28 +76,32 @@ static void test_segment_intersection(std::string const& case_id,
segment_type s12(p1,p2);
segment_type s34(p3,p4);
typedef bg::detail::no_rescale_policy rescale_policy_type;
rescale_policy_type rescale_policy;
typedef bg::segment_intersection_points
<
P,
typename bg::segment_ratio_type
<
P,
rescale_policy_type
>::type
> result_type;
// Get the intersection point (or two points)
bg::segment_intersection_points<P> is
result_type is
= bg::strategy::intersection::relate_cartesian_segments
<
bg::policies::relate::segments_intersection_points
<
segment_type,
segment_type,
bg::segment_intersection_points<P>
>
>::apply(s12, s34, p1, p2, p3, p4);
bg::policies::relate::segments_intersection_points<result_type>
>::apply(s12, s34, rescale_policy, p1, p2, p3, p4);
// Get just a character for Left/Right/intersects/etc, purpose is more for debugging
bg::policies::relate::direction_type dir
= bg::strategy::intersection::relate_cartesian_segments
<
bg::policies::relate::segments_direction
<
segment_type,
segment_type
>
>::apply(s12, s34, p1, p2, p3, p4);
>::apply(s12, s34, rescale_policy, p1, p2, p3, p4);
std::size_t expected_count =
check(is, 0, expected_x1, expected_y1)
@ -132,17 +137,25 @@ static void test_segment_ratio(std::string const& case_id,
segment_type s12(p1, p2);
segment_type s34(p3, p4);
typedef bg::detail::no_rescale_policy rescale_policy_type;
rescale_policy_type rescale_policy;
typedef bg::segment_intersection_points
<
P,
typename bg::segment_ratio_type
<
P,
rescale_policy_type
>::type
> result_type;
// Get the intersection point (or two points)
bg::segment_intersection_points<P> is
result_type is
= bg::strategy::intersection::relate_cartesian_segments
<
bg::policies::relate::segments_intersection_points
<
segment_type,
segment_type,
bg::segment_intersection_points<P>
>
>::apply(s12, s34, p1, p2, p3, p4);
bg::policies::relate::segments_intersection_points<result_type>
>::apply(s12, s34, rescale_policy, p1, p2, p3, p4);
BOOST_CHECK_EQUAL(is.count, 2u);
BOOST_CHECK_EQUAL(is.fractions[0].robust_ra, expected_a1);