[geometry] Removed (need for) arrangment and moved disjoint.

Disjoint is now based on ratios too. All is now based on ratios, greatly
simplifying the original code with many lines and conditions.
This commit is contained in:
Barend Gehrels
2013-12-20 19:06:05 +01:00
parent e0d9036aef
commit b00311f502
2 changed files with 14 additions and 21 deletions

View File

@@ -76,7 +76,6 @@ inline typename geometry::point_type<Segment>::type get_from_index(
>::apply(segment, point);
return point;
}
#endif
// this will go too
template <std::size_t Dimension, typename Point, typename T>
@@ -90,6 +89,7 @@ static inline void point_arrange(Point const& p1, Point const& p2, T& s_1, T& s_
swapped = true;
}
}
#endif
}
#endif // DOXYGEN_NO_DETAIL
@@ -764,24 +764,6 @@ all this stuff can be removed completely
RobustPoint const& robust_a1, RobustPoint const& robust_a2,
RobustPoint const& robust_b1, RobustPoint const& robust_b2)
{
typedef typename geometry::coordinate_type
<
RobustPoint
>::type robust_coordinate_type;
// TEMP this will be removed, we will use only originals
robust_coordinate_type a_1, a_2, b_1, b_2;
bool a_swapped = false, b_swapped = false;
detail::point_arrange<Dimension>(robust_a1, robust_a2, a_1, a_2, a_swapped);
detail::point_arrange<Dimension>(robust_b1, robust_b2, b_1, b_2, b_swapped);
if (a_2 < b_1 || a_1 > b_2)
{
// This will then be done below in relate_collinear
// As soon as we refactor rational to segment_ratio
return Policy::disjoint();
}
// END TEMP
return relate_collinear(a, b,
get<Dimension>(robust_a1),
get<Dimension>(robust_a2),
@@ -836,6 +818,16 @@ all this stuff can be removed completely
ratio_type const rb_from(ob_1 - oa_1, length_a);
ratio_type const rb_to(ob_2 - oa_1, length_a);
static ratio_type const zero(0, 1);
static ratio_type const one(1, 1);
bool const sanity_check_b_disjoint = ((rb_from < zero && rb_to < zero) || (rb_from > one && rb_to > one));
if ((ra_from < zero && ra_to < zero) || (ra_from > one && ra_to > one))
{
assert(sanity_check_b_disjoint); // this will go
return Policy::disjoint();
}
assert(! sanity_check_b_disjoint);
return Policy::segments_collinear(a, b, ra_from, ra_to, rb_from, rb_to);
}
};

View File

@@ -290,8 +290,9 @@ void test_all()
'e', true, 0, 0,
2, 0, 6, 0);
// a1---------->a2
// b2<----------b1
// Disjoint (in vertical direction, picture still horizontal)
// a2<---a1
// b2<---b1
test_segment_intersection<P>("case_recursive_boxes_1",
10, 7, 10, 6,
10, 10, 10, 9,