mirror of
https://github.com/boostorg/geometry.git
synced 2026-02-10 23:42:12 +00:00
[geometry] removed tabs in cart_intersect.hpp
[SVN r79504]
This commit is contained in:
@@ -172,28 +172,28 @@ struct relate_cartesian_segments
|
||||
>::type promoted_type;
|
||||
|
||||
// r: ratio 0-1 where intersection divides A/B
|
||||
// (only calculated for non-collinear segments)
|
||||
promoted_type r;
|
||||
if (! collinear)
|
||||
{
|
||||
// Calculate determinants - Cramers rule
|
||||
coordinate_type const wx = get<0, 0>(a) - get<0, 0>(b);
|
||||
coordinate_type const wy = get<0, 1>(a) - get<0, 1>(b);
|
||||
coordinate_type const d = geometry::detail::determinant<coordinate_type>(dx_a, dy_a, dx_b, dy_b);
|
||||
coordinate_type const da = geometry::detail::determinant<coordinate_type>(dx_b, dy_b, wx, wy);
|
||||
// (only calculated for non-collinear segments)
|
||||
promoted_type r;
|
||||
if (! collinear)
|
||||
{
|
||||
// Calculate determinants - Cramers rule
|
||||
coordinate_type const wx = get<0, 0>(a) - get<0, 0>(b);
|
||||
coordinate_type const wy = get<0, 1>(a) - get<0, 1>(b);
|
||||
coordinate_type const d = geometry::detail::determinant<coordinate_type>(dx_a, dy_a, dx_b, dy_b);
|
||||
coordinate_type const da = geometry::detail::determinant<coordinate_type>(dx_b, dy_b, wx, wy);
|
||||
|
||||
coordinate_type const zero = coordinate_type();
|
||||
if (math::equals(d, zero))
|
||||
{
|
||||
// This is still a collinear case (because of FP imprecision this can occur here)
|
||||
// sides.debug();
|
||||
sides.set<0>(0,0);
|
||||
sides.set<1>(0,0);
|
||||
collinear = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = da / d;
|
||||
coordinate_type const zero = coordinate_type();
|
||||
if (math::equals(d, zero))
|
||||
{
|
||||
// This is still a collinear case (because of FP imprecision this can occur here)
|
||||
// sides.debug();
|
||||
sides.set<0>(0,0);
|
||||
sides.set<1>(0,0);
|
||||
collinear = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
r = da / d;
|
||||
|
||||
if (! robustness_verify_r(a, b, r))
|
||||
{
|
||||
@@ -207,8 +207,8 @@ struct relate_cartesian_segments
|
||||
return Policy::disjoint();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(collinear)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ struct relate_cartesian_segments
|
||||
}
|
||||
else
|
||||
{
|
||||
// Y direction contains larger segments (maybe dx is zero)
|
||||
// Y direction contains larger segments (maybe dx is zero)
|
||||
return relate_collinear<1>(a, b);
|
||||
}
|
||||
}
|
||||
@@ -231,23 +231,23 @@ struct relate_cartesian_segments
|
||||
private :
|
||||
|
||||
|
||||
// Ratio should lie between 0 and 1
|
||||
// Also these three conditions might be of FP imprecision, the segments were actually (nearly) collinear
|
||||
// Ratio should lie between 0 and 1
|
||||
// Also these three conditions might be of FP imprecision, the segments were actually (nearly) collinear
|
||||
template <typename T>
|
||||
static inline bool robustness_verify_r(
|
||||
segment_type1 const& a, segment_type2 const& b,
|
||||
T& r)
|
||||
{
|
||||
T const zero = 0;
|
||||
T const one = 1;
|
||||
T const zero = 0;
|
||||
T const one = 1;
|
||||
if (r < zero || r > one)
|
||||
{
|
||||
if (verify_disjoint<0>(a, b) || verify_disjoint<1>(a, b))
|
||||
{
|
||||
// Can still be disjoint (even if not one is left or right from another)
|
||||
if (verify_disjoint<0>(a, b) || verify_disjoint<1>(a, b))
|
||||
{
|
||||
// Can still be disjoint (even if not one is left or right from another)
|
||||
// This is e.g. in case #snake4 of buffer test.
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//std::cout << "ROBUSTNESS: correction of r " << r << std::endl;
|
||||
// sides.debug();
|
||||
@@ -273,7 +273,7 @@ private :
|
||||
}
|
||||
else if (r < zero)
|
||||
{
|
||||
r = zero;
|
||||
r = zero;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
@@ -284,16 +284,16 @@ private :
|
||||
side_info& sides,
|
||||
bool& collinear)
|
||||
{
|
||||
if ((sides.zero<0>() && ! sides.zero<1>()) || (sides.zero<1>() && ! sides.zero<0>()))
|
||||
{
|
||||
// If one of the segments is collinear, the other must be as well.
|
||||
// So handle it as collinear.
|
||||
// (In float/double epsilon margins it can easily occur that one or two of them are -1/1)
|
||||
// sides.debug();
|
||||
if ((sides.zero<0>() && ! sides.zero<1>()) || (sides.zero<1>() && ! sides.zero<0>()))
|
||||
{
|
||||
// If one of the segments is collinear, the other must be as well.
|
||||
// So handle it as collinear.
|
||||
// (In float/double epsilon margins it can easily occur that one or two of them are -1/1)
|
||||
// sides.debug();
|
||||
sides.set<0>(0,0);
|
||||
sides.set<1>(0,0);
|
||||
collinear = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void robustness_verify_meeting(
|
||||
@@ -389,11 +389,11 @@ private :
|
||||
{
|
||||
if (sides.one_of_all_zero())
|
||||
{
|
||||
if (verify_disjoint<0>(a, b) || verify_disjoint<1>(a, b))
|
||||
{
|
||||
return true;
|
||||
if (verify_disjoint<0>(a, b) || verify_disjoint<1>(a, b))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -412,11 +412,11 @@ private :
|
||||
|
||||
T const db = geometry::detail::determinant<T>(dx_a, dy_a, wx, wy);
|
||||
|
||||
R const zero = 0;
|
||||
R const one = 1;
|
||||
R const zero = 0;
|
||||
R const one = 1;
|
||||
if (math::equals(r, zero) || math::equals(r, one))
|
||||
{
|
||||
R rb = db / d;
|
||||
R rb = db / d;
|
||||
if (rb <= 0 || rb >= 1 || math::equals(rb, 0) || math::equals(rb, 1))
|
||||
{
|
||||
if (sides.one_zero<0>() && ! sides.one_zero<1>()) // or vice versa
|
||||
@@ -432,16 +432,16 @@ private :
|
||||
}
|
||||
}
|
||||
|
||||
template <std::size_t Dimension>
|
||||
template <std::size_t Dimension>
|
||||
static inline bool verify_disjoint(segment_type1 const& a,
|
||||
segment_type2 const& b)
|
||||
{
|
||||
coordinate_type a_1, a_2, b_1, b_2;
|
||||
bool a_swapped = false, b_swapped = false;
|
||||
detail::segment_arrange<Dimension>(a, a_1, a_2, a_swapped);
|
||||
detail::segment_arrange<Dimension>(b, b_1, b_2, b_swapped);
|
||||
return math::smaller(a_2, b_1) || math::larger(a_1, b_2);
|
||||
}
|
||||
segment_type2 const& b)
|
||||
{
|
||||
coordinate_type a_1, a_2, b_1, b_2;
|
||||
bool a_swapped = false, b_swapped = false;
|
||||
detail::segment_arrange<Dimension>(a, a_1, a_2, a_swapped);
|
||||
detail::segment_arrange<Dimension>(b, b_1, b_2, b_swapped);
|
||||
return math::smaller(a_2, b_1) || math::larger(a_1, b_2);
|
||||
}
|
||||
|
||||
template <typename Segment>
|
||||
static inline typename point_type<Segment>::type select(int index, Segment const& segment)
|
||||
@@ -476,10 +476,10 @@ private :
|
||||
template <std::size_t Dimension>
|
||||
static inline bool analyse_equal(segment_type1 const& a, segment_type2 const& b)
|
||||
{
|
||||
coordinate_type const a_1 = geometry::get<0, Dimension>(a);
|
||||
coordinate_type const a_2 = geometry::get<1, Dimension>(a);
|
||||
coordinate_type const b_1 = geometry::get<0, Dimension>(b);
|
||||
coordinate_type const b_2 = geometry::get<1, Dimension>(b);
|
||||
coordinate_type const a_1 = geometry::get<0, Dimension>(a);
|
||||
coordinate_type const a_2 = geometry::get<1, Dimension>(a);
|
||||
coordinate_type const b_1 = geometry::get<0, Dimension>(b);
|
||||
coordinate_type const b_2 = geometry::get<1, Dimension>(b);
|
||||
return math::equals(a_1, b_1)
|
||||
|| math::equals(a_2, b_1)
|
||||
|| math::equals(a_1, b_2)
|
||||
@@ -487,21 +487,21 @@ private :
|
||||
;
|
||||
}
|
||||
|
||||
template <std::size_t Dimension>
|
||||
template <std::size_t Dimension>
|
||||
static inline return_type relate_collinear(segment_type1 const& a,
|
||||
segment_type2 const& b)
|
||||
{
|
||||
coordinate_type a_1, a_2, b_1, b_2;
|
||||
bool a_swapped = false, b_swapped = false;
|
||||
detail::segment_arrange<Dimension>(a, a_1, a_2, a_swapped);
|
||||
detail::segment_arrange<Dimension>(b, b_1, b_2, b_swapped);
|
||||
if (math::smaller(a_2, b_1) || math::larger(a_1, b_2))
|
||||
//if (a_2 < b_1 || a_1 > b_2)
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
segment_type2 const& b)
|
||||
{
|
||||
coordinate_type a_1, a_2, b_1, b_2;
|
||||
bool a_swapped = false, b_swapped = false;
|
||||
detail::segment_arrange<Dimension>(a, a_1, a_2, a_swapped);
|
||||
detail::segment_arrange<Dimension>(b, b_1, b_2, b_swapped);
|
||||
if (math::smaller(a_2, b_1) || math::larger(a_1, b_2))
|
||||
//if (a_2 < b_1 || a_1 > b_2)
|
||||
{
|
||||
return Policy::disjoint();
|
||||
}
|
||||
return relate_collinear(a, b, a_1, a_2, b_1, b_2, a_swapped, b_swapped);
|
||||
}
|
||||
}
|
||||
|
||||
/// Relate segments known collinear
|
||||
static inline return_type relate_collinear(segment_type1 const& a
|
||||
@@ -535,22 +535,22 @@ private :
|
||||
bool const both_swapped = a_swapped && b_swapped;
|
||||
|
||||
// Check if segments are equal or opposite equal...
|
||||
bool const swapped_a1_eq_b1 = math::equals(a_1, b_1);
|
||||
bool const swapped_a2_eq_b2 = math::equals(a_2, b_2);
|
||||
bool const swapped_a1_eq_b1 = math::equals(a_1, b_1);
|
||||
bool const swapped_a2_eq_b2 = math::equals(a_2, b_2);
|
||||
|
||||
if (swapped_a1_eq_b1 && swapped_a2_eq_b2)
|
||||
{
|
||||
return Policy::segment_equal(a, opposite);
|
||||
}
|
||||
|
||||
bool const swapped_a2_eq_b1 = math::equals(a_2, b_1);
|
||||
bool const swapped_a1_eq_b2 = math::equals(a_1, b_2);
|
||||
bool const swapped_a2_eq_b1 = math::equals(a_2, b_1);
|
||||
bool const swapped_a1_eq_b2 = math::equals(a_1, b_2);
|
||||
|
||||
bool const a1_eq_b1 = both_swapped ? swapped_a2_eq_b2 : a_swapped ? swapped_a2_eq_b1 : b_swapped ? swapped_a1_eq_b2 : swapped_a1_eq_b1;
|
||||
bool const a2_eq_b2 = both_swapped ? swapped_a1_eq_b1 : a_swapped ? swapped_a1_eq_b2 : b_swapped ? swapped_a2_eq_b1 : swapped_a2_eq_b2;
|
||||
bool const a1_eq_b1 = both_swapped ? swapped_a2_eq_b2 : a_swapped ? swapped_a2_eq_b1 : b_swapped ? swapped_a1_eq_b2 : swapped_a1_eq_b1;
|
||||
bool const a2_eq_b2 = both_swapped ? swapped_a1_eq_b1 : a_swapped ? swapped_a1_eq_b2 : b_swapped ? swapped_a2_eq_b1 : swapped_a2_eq_b2;
|
||||
|
||||
bool const a1_eq_b2 = both_swapped ? swapped_a2_eq_b1 : a_swapped ? swapped_a2_eq_b2 : b_swapped ? swapped_a1_eq_b1 : swapped_a1_eq_b2;
|
||||
bool const a2_eq_b1 = both_swapped ? swapped_a1_eq_b2 : a_swapped ? swapped_a1_eq_b1 : b_swapped ? swapped_a2_eq_b2 : swapped_a2_eq_b1;
|
||||
bool const a1_eq_b2 = both_swapped ? swapped_a2_eq_b1 : a_swapped ? swapped_a2_eq_b2 : b_swapped ? swapped_a1_eq_b1 : swapped_a1_eq_b2;
|
||||
bool const a2_eq_b1 = both_swapped ? swapped_a1_eq_b2 : a_swapped ? swapped_a1_eq_b1 : b_swapped ? swapped_a2_eq_b2 : swapped_a2_eq_b1;
|
||||
|
||||
|
||||
|
||||
@@ -722,7 +722,7 @@ private :
|
||||
;
|
||||
}
|
||||
// Nothing should goes through. If any we have made an error
|
||||
// std::cout << "Robustness issue, non-logical behaviour" << std::endl;
|
||||
// std::cout << "Robustness issue, non-logical behaviour" << std::endl;
|
||||
return Policy::error("Robustness issue, non-logical behaviour");
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user