KiCad PCB EDA Suite
Loading...
Searching...
No Matches
GEOM_TEST Namespace Reference

Utility functions for testing geometry functions. More...

Enumerations

enum class  QUADRANT { Q1 , Q2 , Q3 , Q4 }
 Geometric quadrants, from top-right, anti-clockwise. More...
 

Functions

template<typename T >
bool IsInQuadrant (const VECTOR2< T > &aPoint, QUADRANT aQuadrant)
 
bool SegmentCompletelyInQuadrant (const SEG &aSeg, QUADRANT aQuadrant)
 
bool SegmentEndsInQuadrant (const SEG &aSeg, QUADRANT aQuadrant)
 
bool SegmentCompletelyWithinRadius (const SEG &aSeg, const VECTOR2I &aPt, const int aRadius)
 
template<typename T >
bool IsPointAtDistance (const VECTOR2< T > &aPtA, const VECTOR2< T > &aPtB, T aExpDist, T aTol)
 Check that two points are the given distance apart, within the given tolerance.
 
template<typename T >
bool ArePointsNearCircle (const std::vector< VECTOR2< T > > &aPoints, const VECTOR2< T > &aCentre, T aRad, T aTol)
 Predicate for checking a set of points is within a certain tolerance of a circle.
 
template<typename T >
bool ArePerpendicular (const VECTOR2< T > &a, const VECTOR2< T > &b, const EDA_ANGLE &aTolerance)
 
SHAPE_LINE_CHAIN MakeSquarePolyLine (int aSize, const VECTOR2I &aCentre)
 construct a square polygon of given size width and centre
 
SHAPE_POLY_SET FilletPolySet (SHAPE_POLY_SET &aPolySet, int aRadius, int aError)
 
bool IsOutlineValid (const SHAPE_LINE_CHAIN &aChain)
 Verify that a SHAPE_LINE_CHAIN has been assembled correctly by ensuring that the arc start and end points match points on the chain and that any points inside the arcs actually collide with the arc segments (with an error margin of 5000 IU)
 
bool IsPolySetValid (const SHAPE_POLY_SET &aSet)
 Verify that a SHAPE_POLY_SET has been assembled correctly by verifying each of the outlines and holes contained within.
 
bool SegmentsHaveSameEndPoints (const SEG &aSeg1, const SEG &aSeg2)
 Check that two SEGs have the same end points, in either order.
 

Detailed Description

Utility functions for testing geometry functions.

Enumeration Type Documentation

◆ QUADRANT

enum class GEOM_TEST::QUADRANT
strong

Geometric quadrants, from top-right, anti-clockwise.

^ y
|

Q2 | Q1 ----—> x Q3 | Q4

Enumerator
Q1 
Q2 
Q3 
Q4 

Definition at line 51 of file geom_test_utils.h.

Function Documentation

◆ ArePerpendicular()

template<typename T >
bool GEOM_TEST::ArePerpendicular ( const VECTOR2< T > &  a,
const VECTOR2< T > &  b,
const EDA_ANGLE aTolerance 
)

◆ ArePointsNearCircle()

template<typename T >
bool GEOM_TEST::ArePointsNearCircle ( const std::vector< VECTOR2< T > > &  aPoints,
const VECTOR2< T > &  aCentre,
aRad,
aTol 
)

Predicate for checking a set of points is within a certain tolerance of a circle.

Parameters
aPointsthe points to check
aCentrethe circle centre
aRadthe circle radius
aTolEndsthe tolerance for the endpoint-centre distance
Returns
true if predicate met

Definition at line 144 of file geom_test_utils.h.

References BOOST_TEST_INFO, and IsPointAtDistance().

Referenced by ArePolylineEndPointsNearCircle(), and ArePolylineMidPointsNearCircle().

◆ FilletPolySet()

SHAPE_POLY_SET GEOM_TEST::FilletPolySet ( SHAPE_POLY_SET aPolySet,
int  aRadius,
int  aError 
)
inline

◆ IsInQuadrant()

template<typename T >
bool GEOM_TEST::IsInQuadrant ( const VECTOR2< T > &  aPoint,
QUADRANT  aQuadrant 
)

Definition at line 59 of file geom_test_utils.h.

References Q1, Q2, Q3, Q4, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by SegmentCompletelyInQuadrant(), and SegmentEndsInQuadrant().

◆ IsOutlineValid()

bool GEOM_TEST::IsOutlineValid ( const SHAPE_LINE_CHAIN aChain)
inline

Verify that a SHAPE_LINE_CHAIN has been assembled correctly by ensuring that the arc start and end points match points on the chain and that any points inside the arcs actually collide with the arc segments (with an error margin of 5000 IU)

Parameters
aChainto test
Returns
true if outline is valid

Definition at line 230 of file geom_test_utils.h.

References SHAPE_LINE_CHAIN::Arc(), SHAPE_LINE_CHAIN::ArcIndex(), SHAPE_ARC::Collide(), SHAPE_LINE_CHAIN::CPoint(), SHAPE_LINE_CHAIN::CShapes(), SHAPE_ARC::DefaultAccuracyForPCB(), SHAPE_ARC::GetP0(), SHAPE_ARC::GetP1(), SHAPE_LINE_CHAIN::IsClosed(), SHAPE_LINE_CHAIN::IsSharedPt(), and SHAPE_LINE_CHAIN::PointCount().

Referenced by BOOST_AUTO_TEST_CASE(), and IsPolySetValid().

◆ IsPointAtDistance()

template<typename T >
bool GEOM_TEST::IsPointAtDistance ( const VECTOR2< T > &  aPtA,
const VECTOR2< T > &  aPtB,
aExpDist,
aTol 
)

Check that two points are the given distance apart, within the given tolerance.

Template Parameters
Tthe dimension type
Parameters
aPtAthe first point
aPtBthe second point
aExpDistthe expected distance
aTolthe permitted tolerance

Definition at line 120 of file geom_test_utils.h.

References BOOST_TEST_INFO, EuclideanNorm(), and KI_TEST::IsWithin().

Referenced by ArePointsNearCircle().

◆ IsPolySetValid()

bool GEOM_TEST::IsPolySetValid ( const SHAPE_POLY_SET aSet)
inline

Verify that a SHAPE_POLY_SET has been assembled correctly by verifying each of the outlines and holes contained within.

Parameters
aSetto test
Returns
true if the poly set is valid

Definition at line 320 of file geom_test_utils.h.

References SHAPE_POLY_SET::CHole(), SHAPE_POLY_SET::HoleCount(), IsOutlineValid(), SHAPE_POLY_SET::Outline(), and SHAPE_POLY_SET::OutlineCount().

Referenced by BOOST_AUTO_TEST_CASE().

◆ MakeSquarePolyLine()

SHAPE_LINE_CHAIN GEOM_TEST::MakeSquarePolyLine ( int  aSize,
const VECTOR2I aCentre 
)
inline

construct a square polygon of given size width and centre

Parameters
aSizethe side width (must be divisible by 2 if want to avoid rounding)
aCentrethe centre of the square

Definition at line 189 of file geom_test_utils.h.

References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::SetClosed(), VECTOR2< T >::x, and VECTOR2< T >::y.

◆ SegmentCompletelyInQuadrant()

bool GEOM_TEST::SegmentCompletelyInQuadrant ( const SEG aSeg,
QUADRANT  aQuadrant 
)
inline

Definition at line 85 of file geom_test_utils.h.

References SEG::A, SEG::B, and IsInQuadrant().

◆ SegmentCompletelyWithinRadius()

bool GEOM_TEST::SegmentCompletelyWithinRadius ( const SEG aSeg,
const VECTOR2I aPt,
const int  aRadius 
)
inline

Definition at line 103 of file geom_test_utils.h.

References SEG::A, SEG::B, and EuclideanNorm().

◆ SegmentEndsInQuadrant()

bool GEOM_TEST::SegmentEndsInQuadrant ( const SEG aSeg,
QUADRANT  aQuadrant 
)
inline

Definition at line 94 of file geom_test_utils.h.

References SEG::A, SEG::B, and IsInQuadrant().

◆ SegmentsHaveSameEndPoints()

bool GEOM_TEST::SegmentsHaveSameEndPoints ( const SEG aSeg1,
const SEG aSeg2 
)
inline

Check that two SEGs have the same end points, in either order.

That is to say SEG(A, B) == SEG(A, B), but also SEG(A, B) == SEG(B, A)

Definition at line 342 of file geom_test_utils.h.

References SEG::A, and SEG::B.

Referenced by DoChamferTestChecks().