KiCad PCB EDA Suite
Loading...
Searching...
No Matches
test_shape_arc.cpp File Reference

Go to the source code of this file.

Classes

struct  ARC_PROPERTIES
 All properties of an arc (depending on how it's constructed, some of these might be the same as the constructor params) More...
 
struct  ARC_CENTRE_PT_ANGLE
 Info to set up an arc by centre, start point and angle. More...
 
struct  ARC_CPA_CASE
 
struct  ARC_TAN_TAN_RADIUS
 Info to set up an arc by tangent to two segments and a radius. More...
 
struct  ARC_TTR_CASE
 
struct  ARC_START_END_CENTER
 Info to set up an arc start, end and center. More...
 
struct  ARC_SEC_CASE
 
struct  ARC_PT_COLLIDE_CASE
 
struct  ARC_SEG_COLLIDE_CASE
 
struct  ARC_DATA_MM
 
struct  ARC_ARC_COLLIDE_CASE
 
struct  ARC_TO_POLYLINE_CASE
 

Functions

static void CheckArcGeom (const SHAPE_ARC &aArc, const ARC_PROPERTIES &aProps, const int aSynErrIU=1)
 Check a SHAPE_ARC against a given set of geometric properties.
 
static void CheckArc (const SHAPE_ARC &aArc, const ARC_PROPERTIES &aProps, const int aSynErrIU=1)
 Check an arcs geometry and other class functions.
 
 BOOST_AUTO_TEST_CASE (NullCtor)
 Check correct handling of filter strings (as used by WX)
 
 BOOST_AUTO_TEST_CASE (BasicCPAGeom)
 
 BOOST_AUTO_TEST_CASE (BasicTTRGeom)
 
 BOOST_AUTO_TEST_CASE (BasicSECGeom)
 
 BOOST_AUTO_TEST_CASE (CollidePt)
 
 BOOST_AUTO_TEST_CASE (CollideSeg)
 
 BOOST_AUTO_TEST_CASE (CollideArc)
 
 BOOST_AUTO_TEST_CASE (CollideArcToShapeLineChain)
 
 BOOST_AUTO_TEST_CASE (CollideArcToPolygonApproximation)
 
bool ArePolylineEndPointsNearCircle (const SHAPE_LINE_CHAIN &aPolyline, const VECTOR2I &aCentre, int aRad, int aTolerance)
 Predicate for checking a polyline has all the points on (near) a circle of given centre and radius.
 
bool ArePolylineMidPointsNearCircle (const SHAPE_LINE_CHAIN &aPolyline, const VECTOR2I &aCentre, int aRad, int aTolerance)
 Predicate for checking a polyline has all the segment mid points on (near) a circle of given centre and radius.
 
 BOOST_AUTO_TEST_CASE (ArcToPolyline)
 

Variables

static const std::vector< ARC_CPA_CASEarc_cases
 
static const std::vector< ARC_TTR_CASEarc_ttr_cases
 
static const std::vector< ARC_SEC_CASEarc_sec_cases
 
static const std::vector< ARC_PT_COLLIDE_CASEarc_pt_collide_cases
 
static const std::vector< ARC_SEG_COLLIDE_CASEarc_seg_collide_cases
 
static const std::vector< ARC_ARC_COLLIDE_CASEarc_arc_collide_cases
 

Function Documentation

◆ ArePolylineEndPointsNearCircle()

bool ArePolylineEndPointsNearCircle ( const SHAPE_LINE_CHAIN aPolyline,
const VECTOR2I aCentre,
int  aRad,
int  aTolerance 
)

Predicate for checking a polyline has all the points on (near) a circle of given centre and radius.

Parameters
aPolylinethe polyline to check
aCentrethe circle centre
aRadthe circle radius
aTolerancethe tolerance for the endpoint-centre distance
Returns
true if predicate met

Definition at line 950 of file test_shape_arc.cpp.

References GEOM_TEST::ArePointsNearCircle(), SHAPE_LINE_CHAIN::CPoint(), and SHAPE_LINE_CHAIN::PointCount().

Referenced by BOOST_AUTO_TEST_CASE().

◆ ArePolylineMidPointsNearCircle()

bool ArePolylineMidPointsNearCircle ( const SHAPE_LINE_CHAIN aPolyline,
const VECTOR2I aCentre,
int  aRad,
int  aTolerance 
)

Predicate for checking a polyline has all the segment mid points on (near) a circle of given centre and radius.

Parameters
aPolylinethe polyline to check
aCentrethe circle centre
aRadthe circle radius
aTolEndsthe tolerance for the midpoint-centre distance
Returns
true if predicate met

Definition at line 973 of file test_shape_arc.cpp.

References GEOM_TEST::ArePointsNearCircle(), SHAPE_LINE_CHAIN::CPoint(), and SHAPE_LINE_CHAIN::PointCount().

Referenced by BOOST_AUTO_TEST_CASE().

◆ BOOST_AUTO_TEST_CASE() [1/10]

◆ BOOST_AUTO_TEST_CASE() [2/10]

BOOST_AUTO_TEST_CASE ( BasicCPAGeom  )

Definition at line 329 of file test_shape_arc.cpp.

References arc_cases, BOOST_TEST_CONTEXT, CheckArc(), and DEGREES_T.

◆ BOOST_AUTO_TEST_CASE() [3/10]

BOOST_AUTO_TEST_CASE ( BasicSECGeom  )

◆ BOOST_AUTO_TEST_CASE() [4/10]

◆ BOOST_AUTO_TEST_CASE() [5/10]

◆ BOOST_AUTO_TEST_CASE() [6/10]

◆ BOOST_AUTO_TEST_CASE() [7/10]

BOOST_AUTO_TEST_CASE ( CollideArcToShapeLineChain  )

Definition at line 866 of file test_shape_arc.cpp.

References SHAPE_ARC::Collide(), and SHAPE::Collide().

◆ BOOST_AUTO_TEST_CASE() [8/10]

BOOST_AUTO_TEST_CASE ( CollidePt  )

◆ BOOST_AUTO_TEST_CASE() [9/10]

BOOST_AUTO_TEST_CASE ( CollideSeg  )

◆ BOOST_AUTO_TEST_CASE() [10/10]

BOOST_AUTO_TEST_CASE ( NullCtor  )

Check correct handling of filter strings (as used by WX)

Definition at line 135 of file test_shape_arc.cpp.

References CheckArc().

◆ CheckArc()

static void CheckArc ( const SHAPE_ARC aArc,
const ARC_PROPERTIES aProps,
const int  aSynErrIU = 1 
)
static

Check an arcs geometry and other class functions.

Parameters
aArcArc to test
aPropsProperties to test against
aSynErrIUPermitted error for synthetic points and dimensions (currently radius and center)

Should have identical geom props

Definition at line 114 of file test_shape_arc.cpp.

References CheckArcGeom(), SHAPE_ARC::Clone(), and SH_ARC.

Referenced by BOOST_AUTO_TEST_CASE().

◆ CheckArcGeom()

static void CheckArcGeom ( const SHAPE_ARC aArc,
const ARC_PROPERTIES aProps,
const int  aSynErrIU = 1 
)
static

Check a SHAPE_ARC against a given set of geometric properties.

Parameters
aArcArc to test
aPropsProperties to test against
aSynErrIUPermitted error for synthetic points and dimensions (currently radius and center)

Check the chord agrees

All arcs are solid

Collisions will be checked elsewhere.

Definition at line 59 of file test_shape_arc.cpp.

References EDA_ANGLE::AsDegrees(), SHAPE_ARC::BBox(), SHAPE_ARC::GetCenter(), SHAPE_ARC::GetCentralAngle(), SHAPE_ARC::GetChord(), SHAPE_ARC::GetEndAngle(), SHAPE_ARC::GetP1(), SHAPE_ARC::GetRadius(), SHAPE_ARC::GetStartAngle(), SHAPE_ARC::IsSolid(), ARC_PROPERTIES::m_bbox, ARC_PROPERTIES::m_center_angle, ARC_PROPERTIES::m_center_point, ARC_PROPERTIES::m_end_angle, ARC_PROPERTIES::m_end_point, ARC_PROPERTIES::m_radius, ARC_PROPERTIES::m_start_angle, and ARC_PROPERTIES::m_start_point.

Referenced by CheckArc().

Variable Documentation

◆ arc_arc_collide_cases

const std::vector<ARC_ARC_COLLIDE_CASE> arc_arc_collide_cases
static

Definition at line 741 of file test_shape_arc.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ arc_cases

const std::vector<ARC_CPA_CASE> arc_cases
static

Definition at line 184 of file test_shape_arc.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ arc_pt_collide_cases

const std::vector<ARC_PT_COLLIDE_CASE> arc_pt_collide_cases
static

Definition at line 560 of file test_shape_arc.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ arc_sec_cases

const std::vector<ARC_SEC_CASE> arc_sec_cases
static
Initial value:
= {
{ "180 deg, clockwise", { { 100, 0 }, { 0, 0 }, { 50, 0 } }, true, { 50, -50 } },
{ "180 deg, anticlockwise", { { 100, 0 }, { 0, 0 }, { 50, 0 } }, false, { 50, 50 } },
{ "180 deg flipped, clockwise", { { 0, 0 }, { 100, 0 }, { 50, 0 } }, true, { 50, 50 } },
{ "180 deg flipped, anticlockwise", { { 0, 0 }, { 100, 0 }, { 50, 0 } }, false, { 50, -50 } },
{ "90 deg, clockwise", { { -100, 0 }, { 0, 100 }, { 0, 0 } }, true, { -71, 71 } },
{ "90 deg, anticlockwise", { { -100, 0 }, { 0, 100 }, { 0, 0 } }, false, { 71, -71 } },
}

Definition at line 519 of file test_shape_arc.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ arc_seg_collide_cases

const std::vector<ARC_SEG_COLLIDE_CASE> arc_seg_collide_cases
static
Initial value:
= {
{ "0 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 100, 0 }, { 50, 0 } }, true, 0 },
{ "90 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 0, 100 }, { 0, 50 } }, true, 0 },
{ "180 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { -100, 0 }, { -50, 0 } }, true, 0 },
{ "270 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 0, -100 }, { 0, -50 } }, true, 0 },
{ "45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, 71 }, { 35, 35 } }, true, 0 },
{ "-45 deg ", { { 0, 0 }, { 100, 0 }, 270.0 }, 0, { { 71, -71 }, { 35, -35 } }, false, -1 },
{ "seg inside arc start", { { 0, 0 }, { 71, -71 }, 90.0 },
10, { { 90, 0 }, { -35, 0 } }, true, 10 },
{ "seg inside arc end", { { 0, 0 }, { 71, -71 }, 90.0 },
10, { { -35, 0 }, { 90, 0 } }, true, 10 },
{ "large diameter arc", { { 172367922, 82282076 }, { 162530000, 92120000 }, -45.0 },
433300, { { 162096732, 92331236 }, { 162096732, 78253268 } }, true, 433268 },
}

Definition at line 658 of file test_shape_arc.cpp.

Referenced by BOOST_AUTO_TEST_CASE().

◆ arc_ttr_cases

const std::vector<ARC_TTR_CASE> arc_ttr_cases
static

Definition at line 374 of file test_shape_arc.cpp.

Referenced by BOOST_AUTO_TEST_CASE().