|
KiCad PCB EDA Suite
|
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. | |
Utility functions for testing geometry functions.
|
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.
| bool GEOM_TEST::ArePerpendicular | ( | const VECTOR2< T > & | a, |
| const VECTOR2< T > & | b, | ||
| const EDA_ANGLE & | aTolerance ) |
Check if two vectors are perpendicular.
| T | the dimension type |
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().
| 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.
| T | the dimension type |
| aPoints | the points to check |
| aCentre | the circle centre |
| aRad | the circle radius |
| aTol | the circle tolerance |
Definition at line 143 of file geom_test_utils.h.
References BOOST_TEST_INFO(), IsPointAtDistance(), and T.
Referenced by ArePolylineEndPointsNearCircle(), and ArePolylineMidPointsNearCircle().
|
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().
| 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().
|
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)
| aChain | to test |
Definition at line 208 of file geom_test_utils.h.
References SHAPE_LINE_CHAIN::Arc(), SHAPE_LINE_CHAIN::ArcIndex(), SHAPE_LINE_CHAIN::CLastPoint(), 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(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), BOOST_AUTO_TEST_CASE(), and IsPolySetValid().
| 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.
| T | the dimension type |
| aPtA | the first point |
| aPtB | the second point |
| aExpDist | the distance to test against |
| aTol | the permitted tolerance |
Definition at line 118 of file geom_test_utils.h.
References BOOST_TEST_INFO(), KI_TEST::IsWithin(), and T.
Referenced by ArePointsNearCircle().
|
inline |
Verify that a SHAPE_POLY_SET has been assembled correctly by verifying each of the outlines and holes contained within.
| aSet | to test |
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().
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().
|
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().
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().
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().
|
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.