24#ifndef GEOM_TEST_UTILS_H 
   25#define GEOM_TEST_UTILS_H 
   62    bool isInQuad = 
false;
 
   67            isInQuad = aPoint.
x >= 0 && aPoint.
y >= 0;
 
   70            isInQuad = aPoint.
x <= 0 && aPoint.
y >= 0;
 
   73            isInQuad = aPoint.
x <= 0 && aPoint.
y <= 0;
 
   76            isInQuad = aPoint.
x >= 0 && aPoint.
y <= 0;
 
 
  107    return ( ( aSeg.
A - aPt ).EuclideanNorm() < aRadius )
 
  108            && ( ( aSeg.
B - aPt ).EuclideanNorm() < aRadius );
 
 
  123    const int  dist = ( aPtB - aPtA ).EuclideanNorm();
 
  128        BOOST_TEST_INFO( 
"Points not at expected distance: distance is " << dist << 
", expected " 
 
  150    for( 
unsigned i = 0; i < aPoints.size(); ++i )
 
  154            BOOST_TEST_INFO( 
"Point " << i << 
" " << aPoints[i] << 
" is not within tolerance (" 
  155                                      << aTol << 
") of radius (" << aRad << 
") from centre point " 
 
  193        const auto filleted = aPolySet.
FilletPolygon( aRadius, aError, i );
 
  198    return filletedPolySet;
 
 
  211    ssize_t           prevArcIdx = -1;
 
  212    std::set<size_t> testedArcs;
 
  217    for( 
int i = 0; i < aChain.
PointCount(); i++ )
 
  219        ssize_t arcIdx = aChain.
ArcIndex( i );
 
  226            if( prevArcIdx != arcIdx && testedArcs.count( arcIdx ) )
 
  235            testedArcs.insert( arcIdx );
 
  238        if( prevArcIdx != arcIdx )
 
  242            if( prevArcIdx >= 0 )
 
  249                    pointToTest = aChain.
CPoint( i - 1 );
 
  253                if( lastArc.
GetP1() != pointToTest )
 
  263                if( currentArc.
GetP0() != pointToTest )
 
  272    if( prevArcIdx >= 0 )
 
  276            if( aChain.
CShapes()[0].first != prevArcIdx )
 
 
  306        for( 
int j = 0; j < aSet.
HoleCount( i ); j++ )
 
 
  323    return ( aSeg1.
A == aSeg2.
A && aSeg1.
B == aSeg2.
B )
 
  324           || ( aSeg1.
A == aSeg2.
B && aSeg1.
B == aSeg2.
A );
 
 
 
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 int 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
 
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.
 
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
 
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
 
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
 
std::ostream & boost_test_print_type(std::ostream &os, const SHAPE_LINE_CHAIN &c)
 
std::ostream & operator<<(std::ostream &os, const TYPED_POINT2I &c)
 
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)
 
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.
 
VECTOR2< int32_t > VECTOR2I