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)
 Check value in Quadrant 1 (x and y both >= 0)
 
bool SegmentCompletelyInQuadrant (const SEG &aSeg, QUADRANT aQuadrant)
 Check if both ends of a segment are in Quadrant 1.
 
bool SegmentEndsInQuadrant (const SEG &aSeg, QUADRANT aQuadrant)
 Check if at least one end of the segment is in Quadrant 1.
 
bool SegmentCompletelyWithinRadius (const SEG &aSeg, const VECTOR2I &aPt, const int aRadius)
 Check if a segment is entirely within a certain radius of a point.
 
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)
 Check if two vectors are perpendicular.
 
SHAPE_POLY_SET FilletPolySet (SHAPE_POLY_SET &aPolySet, int aRadius, int aError)
 Fillet every polygon in a set and return a new set.
 
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.
 
double TriangleMinAngleDeg (const VECTOR2I &a, const VECTOR2I &b, const VECTOR2I &c)
 The smallest interior angle of a triangle, in degrees; near zero for a sliver.
 

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 49 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 )

Check if two vectors are perpendicular.

Template Parameters
Tthe dimension type
Parameters
avector A
bvector B
aTolerancethe allowed deviation from PI/2 (e.g. when rounding)

Definition at line 172 of file geom_test_utils.h.

References std::abs(), ANGLE_180, ANGLE_90, EDA_ANGLE::AsRadians(), and KI_TEST::IsWithin().

Referenced by TestFilletSegmentConstraints().

◆ ArePointsNearCircle()

template<typename T>
bool GEOM_TEST::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 Parameters
Tthe dimension type
Parameters
aPointsthe points to check
aCentrethe circle centre
aRadthe circle radius
aTolthe circle tolerance
Returns
true if predicate met

Definition at line 143 of file geom_test_utils.h.

References BOOST_TEST_INFO(), IsPointAtDistance(), and T.

Referenced by ArePolylineEndPointsNearCircle(), and ArePolylineMidPointsNearCircle().

◆ FilletPolySet()

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

Fillet every polygon in a set and return a new set.

Definition at line 186 of file geom_test_utils.h.

References SHAPE_POLY_SET::AddOutline(), SHAPE_POLY_SET::FilletPolygon(), and SHAPE_POLY_SET::OutlineCount().

Referenced by TestConcaveSquareFillet(), and TestSquareFillet().

◆ IsInQuadrant()

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

Check value in Quadrant 1 (x and y both >= 0)

Definition at line 57 of file geom_test_utils.h.

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

Referenced by SegmentCompletelyInQuadrant(), and SegmentEndsInQuadrant().

◆ IsOutlineValid()

◆ IsPointAtDistance()

template<typename T>
bool GEOM_TEST::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 Parameters
Tthe dimension type
Parameters
aPtAthe first point
aPtBthe second point
aExpDistthe distance to test against
aTolthe permitted tolerance

Definition at line 118 of file geom_test_utils.h.

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

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 298 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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and BOOST_AUTO_TEST_CASE().

◆ SegmentCompletelyInQuadrant()

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

Check if both ends of a segment are in Quadrant 1.

Definition at line 83 of file geom_test_utils.h.

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

Referenced by TestSquareFillet().

◆ SegmentCompletelyWithinRadius()

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

Check if a segment is entirely within a certain radius of a point.

Definition at line 101 of file geom_test_utils.h.

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

Referenced by TestConcaveSquareFillet().

◆ SegmentEndsInQuadrant()

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

Check if at least one end of the segment is in Quadrant 1.

Definition at line 92 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 320 of file geom_test_utils.h.

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

Referenced by DoChamferTestChecks(), DoDogboneTestChecks(), and if().

◆ TriangleMinAngleDeg()

double GEOM_TEST::TriangleMinAngleDeg ( const VECTOR2I & a,
const VECTOR2I & b,
const VECTOR2I & c )
inline

The smallest interior angle of a triangle, in degrees; near zero for a sliver.

Definition at line 328 of file geom_test_utils.h.

References std::abs(), M_PI, VECTOR2< T >::x, and VECTOR2< T >::y.