22#include <boost/test/data/test_case.hpp>
95 { { 100, 100 }, 200 },
101 { { 100, 100 }, 200 },
106 "0 deg, allowed tolerance pos",
107 { { 100, 100 }, 200 },
112 "0 deg, allowed tolerance neg",
113 { { 100, 100 }, 200 },
118 "0 deg, allowed tolerance pos + 1",
119 { { 100, 100 }, 200 },
124 "0 deg, allowed tolerance neg - 1",
125 { { 100, 100 }, 200 },
131 { { 100, 100 }, 200 },
136 "45 deg, allowed tolerance pos",
137 { { 100, 100 }, 200 },
142 "45 deg, allowed tolerance pos + 1",
143 { { 100, 100 }, 200 },
149 { { 100, 100 }, 200 },
155 { { 100, 100 }, 200 },
161 { { 100, 100 }, 200 },
171 bool ret = c.m_circle.Contains( c.m_point );
221 VECTOR2I ret = c.m_circle.NearestPoint( c.m_point );
260 "tangent aligned, external",
268 "tangent aligned, internal",
284 "KiROUND overflow 1",
285 { { 44798001, -94001999 }, 200001 },
286 { { 44797999, -94001999 }, 650001 },
292 "KiROUND overflow 2",
293 { { 50747999, -92402001 }, 650001 },
294 { { 50748001, -92402001 }, 200001 },
300 "KiROUND overflow 3",
301 { { 43947999, -92402001 }, 650001 },
302 { { 43948001, -92402001 }, 200001 },
308 "KiROUND overflow 4",
309 { { 46497999, -94001999 }, 200001 },
310 { { 46498001, -94001999 }, 650001 },
316 "Co-centered, same radius",
317 { { 205999999, 136367974 }, 3742026 },
318 { { 205999999, 136367974 }, 3742026 },
331 std::vector<VECTOR2I> ret1 = c.m_circle1.Intersect( c.m_circle2 );
339 std::vector<VECTOR2I> ret2 = c.m_circle2.Intersect( c.m_circle1 );
353 std::vector<VECTOR2I> m_exp_result;
364 { { 10, -40 }, {10, 40} },
373 { { -20, -40 }, {20, 40} },
382 { { 20, 0 }, {20, 40} },
390 { { 25, 0 }, {25, 40} },
396 "no intersection: seg end points inside circle",
398 { { 0, 10 }, {0, -10} },
409 std::vector<VECTOR2I> ret = c.m_circle.Intersect( c.m_seg );
423 { { 10, 45 }, {10, 40} },
432 { { -20, -40 }, {20, 40} },
441 { { 20, 0 }, {20, 40} },
449 { { 25, 0 }, {25, 40} },
455 "intersection, seg end points inside circle",
457 { { 0, 10 }, {0, -10} },
469 std::vector<VECTOR2I> ret = c.m_circle.IntersectLine( c.m_seg );
493 "90 degree segs, point on seg",
494 { { 0, 0 }, { 0, 1000 } },
495 { { 0, 0 }, { 1000, 0 } },
497 { { 400, 400} , 400 },
500 "90 degree segs, point floating",
501 { { 0, 0 }, { 0, 1000 } },
502 { { 0, 0 }, { 1000, 0 } },
504 { { 500, 500} , 500 },
507 "45 degree segs, point on seg",
508 { { 0, 0 }, { 1000, 0 } },
509 { { 0, 0 }, { 1000, 1000 } },
511 { { 400, 166} , 166 },
514 "45 degree segs, point floating",
515 { { 0, 0 }, { 1000000, 0 } },
516 { { 0, 0 }, { 1000000, 1000000 } },
518 { { 332439, 137701} , 137701 },
521 "135 degree segs, point on seg",
522 { { 0, 0 }, { 1000000, 0 } },
523 { { 0, 0 }, { -1000000, 1000000 } },
525 { { 400009, 965709 } , 965709 },
529 "135 degree segs, point floating",
530 { { 0, 0 }, { 1000, 0 } },
531 { { 0, 0 }, { -1000, 1000 } },
533 { { 814, 1964} , 1964 },
537 "point on intersection",
538 { { 10, 0 }, { 1000, 0 } },
539 { { 10, 0 }, { -1000, 1000 } },
553 "\nCenter point mismatch: " <<
"\n Got: " << circle.
Center
555 << c.m_exp_result.Center );
558 "\nRadius mismatch: " <<
"\n Got: " << circle.
Radius
559 <<
"\n Expected: " << c.m_exp_result.Radius );
constexpr BOX2I KiROUND(const BOX2D &aBoxD)
Represent basic circle geometry with utility geometry functions.
VECTOR2I Center
Public to make access simpler.
int Radius
Public to make access simpler.
CIRCLE & ConstructFromTanTanPt(const SEG &aLineA, const SEG &aLineB, const VECTOR2I &aP)
Construct this circle such that it is tangent to the given segments and passes through the given poin...
static const int MIN_PRECISION_IU
This is the minimum precision for all the points in a shape.
void CheckUnorderedMatches(const EXP_CONT &aExpected, const FOUND_CONT &aFound, MATCH_PRED aMatchPredicate)
Check that a container of "found" objects matches a container of "expected" objects.
Struct to hold test cases for two circles, and an vector of points.
std::vector< VECTOR2I > m_exp_result
Struct to hold test cases for a given circle, a point and an expected return boolean.
Struct to hold test cases for a given circle, a point and an expected return point.
Struct to hold test cases for two lines, a point and an expected returned circle.
A named data-driven test case.
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
bool CompareLength(int aLengthA, int aLengthB)
static const std::vector< CIR_SEG_VECPT_CASE > construct_tan_tan_pt_cases
Test cases for #CIRCLE::Intersect( const SEG& aSeg )
BOOST_AUTO_TEST_CASE(ParameterCtorMod)
Checks whether the construction of a circle referencing external parameters works and that the parame...
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
bool CompareVector2I(const VECTOR2I &aVecA, const VECTOR2I &aVecB)
static const std::vector< CIR_PT_PT_CASE > nearest_point_cases
Test cases for CIRCLE::NearestPoint.
static const std::vector< CIR_CIR_VECPT_CASE > intersect_circle_cases
Test cases for #CIRCLE::Intersect( const CIRCLE& aCircle )
static const std::vector< SEG_SEG_VECPT_CASE > intersect_line_cases
Test cases for #CIRCLE::IntersectLine( const SEG& aSeg )
static const std::vector< SEG_SEG_VECPT_CASE > intersect_seg_cases
Test cases for #CIRCLE::Intersect( const SEG& aSeg )
BOOST_DATA_TEST_CASE(ConstructFromTanTanPt, boost::unit_test::data::make(construct_tan_tan_pt_cases), c)
const int MIN_PRECISION_45DEG
static const std::vector< CIR_PT_BOOL_CASE > contains_cases
Test cases for CIRCLE::Contains.
BOOST_AUTO_TEST_SUITE_END()
BOOST_TEST_CONTEXT("Test Clearance")
VECTOR2< int32_t > VECTOR2I