24#ifndef GEOM_TEST_UTILS_H
25#define GEOM_TEST_UTILS_H
61 bool isInQuad =
false;
66 isInQuad = aPoint.
x >= 0 && aPoint.
y >= 0;
69 isInQuad = aPoint.
x <= 0 && aPoint.
y >= 0;
72 isInQuad = aPoint.
x <= 0 && aPoint.
y <= 0;
75 isInQuad = aPoint.
x >= 0 && aPoint.
y <= 0;
106 return ( ( aSeg.
A - aPt ).EuclideanNorm() < aRadius )
127 BOOST_TEST_INFO(
"Points not at expected distance: distance is " << dist <<
", expected "
149 for(
unsigned i = 0; i < aPoints.size(); ++i )
153 BOOST_TEST_INFO(
"Point " << i <<
" " << aPoints[i] <<
" is not within tolerance ("
154 << aTol <<
") of radius (" << aRad <<
") from centre point "
193 const VECTOR2I corner = aCentre + aSize / 2;
214 const auto filleted = aPolySet.
FilletPolygon( aRadius, aError, i );
219 return filletedPolySet;
232 ssize_t prevArcIdx = -1;
233 std::set<size_t> testedArcs;
238 for(
int i = 0; i < aChain.
PointCount(); i++ )
240 ssize_t arcIdx = aChain.
ArcIndex( i );
247 if( prevArcIdx != arcIdx && testedArcs.count( arcIdx ) )
256 testedArcs.insert( arcIdx );
259 if( prevArcIdx != arcIdx )
263 if( prevArcIdx >= 0 )
270 pointToTest = aChain.
CPoint( i - 1 );
274 if( lastArc.
GetP1() != pointToTest )
284 if( currentArc.
GetP0() != pointToTest )
293 if( prevArcIdx >= 0 )
297 if( aChain.
CShapes()[0].first != prevArcIdx )
327 for(
int j = 0; j < aSet.
HoleCount( i ); j++ )
344 return ( aSeg1.
A == aSeg2.
A && aSeg1.
B == aSeg2.
B )
345 || ( aSeg1.
A == aSeg2.
B && aSeg1.
B == aSeg2.
A );
357 os <<
"SHAPE_LINE_CHAIN: " << c.
PointCount() <<
" points: [\n";
361 os <<
" " << i <<
": " << c.
CPoint( i ) <<
"\n";
const VECTOR2I & GetP1() const
bool Collide(const SEG &aSeg, int aClearance=0, int *aActual=nullptr, VECTOR2I *aLocation=nullptr) const override
Check if the boundary of shape (this) lies closer to the segment aSeg than aClearance,...
static double DefaultAccuracyForPCB()
const VECTOR2I & GetP0() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_ARC & Arc(size_t aArc) const
bool IsClosed() const override
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
int PointCount() const
Return the number of points (vertices) in this line chain.
ssize_t ArcIndex(size_t aSegment) const
Return the arc index for the given segment index.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
const std::vector< std::pair< ssize_t, ssize_t > > & CShapes() const
bool IsSharedPt(size_t aIndex) const
Test if a point is shared between multiple shapes.
Represent a set of closed polygons.
int AddOutline(const SHAPE_LINE_CHAIN &aOutline)
Adds a new outline to the set and returns its index.
int HoleCount(int aOutline) const
Returns the number of holes in a given outline.
SHAPE_LINE_CHAIN & Outline(int aIndex)
Return the reference to aIndex-th outline in the set.
const SHAPE_LINE_CHAIN & CHole(int aOutline, int aHole) const
POLYGON FilletPolygon(unsigned int aRadius, int aErrorMax, int aIndex)
Return a filleted version of the aIndex-th polygon.
int OutlineCount() const
Return the number of outlines in the set.
Define a general 2D-vector/point.
static constexpr EDA_ANGLE ANGLE_90
static constexpr EDA_ANGLE ANGLE_180
Before Boost 1.64, nullptr_t wasn't handled.
Utility functions for testing geometry functions.
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.
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 po...
bool SegmentCompletelyWithinRadius(const SEG &aSeg, const VECTOR2I &aPt, const int aRadius)
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.
bool SegmentEndsInQuadrant(const SEG &aSeg, QUADRANT aQuadrant)
SHAPE_POLY_SET FilletPolySet(SHAPE_POLY_SET &aPolySet, int aRadius, int aError)
SHAPE_LINE_CHAIN MakeSquarePolyLine(int aSize, const VECTOR2I &aCentre)
construct a square polygon of given size width and centre
bool IsInQuadrant(const VECTOR2< T > &aPoint, QUADRANT aQuadrant)
bool SegmentCompletelyInQuadrant(const SEG &aSeg, QUADRANT aQuadrant)
bool ArePerpendicular(const VECTOR2< T > &a, const VECTOR2< T > &b, const EDA_ANGLE &aTolerance)
QUADRANT
Geometric quadrants, from top-right, anti-clockwise.
bool SegmentsHaveSameEndPoints(const SEG &aSeg1, const SEG &aSeg2)
Check that two SEGs have the same end points, in either order.
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...
bool IsWithin(T aValue, T aNominal, T aError)
Check if a value is within a tolerance of a nominal value.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
Numerical test predicates.
void operator()(std::ostream &os, const SHAPE_LINE_CHAIN &c)
double EuclideanNorm(const VECTOR2I &vector)
#define BOOST_TEST_PRINT_NAMESPACE_CLOSE
#define BOOST_TEST_INFO(A)
If HAVE_EXPECTED_FAILURES is defined, this means that boost::unit_test::expected_failures is availabl...