38 outline.
Append( aSize, 0 );
39 outline.
Append( aSize, aSize );
40 outline.
Append( 0, aSize );
48std::vector<VECTOR2I> generateRandomPoints(
const BOX2I& aBBox,
int aCount, uint32_t aSeed )
50 std::mt19937 gen( aSeed );
51 std::vector<VECTOR2I> points;
52 points.reserve( aCount );
54 std::uniform_int_distribution<int> distX( aBBox.
GetLeft(), aBBox.
GetRight() );
55 std::uniform_int_distribution<int> distY( aBBox.
GetTop(), aBBox.
GetBottom() );
57 for(
int i = 0; i < aCount; i++ )
58 points.emplace_back( distX( gen ), distY( gen ) );
73 constexpr int SIZE = 1000000;
74 constexpr int MARGIN = 1000;
86 auto nearEdge = [](
int v,
int lo,
int hi )
91 for(
const VECTOR2I& pt : generateRandomPoints( sampleArea, 10000, 42 ) )
94 if( nearEdge( pt.x, 0,
SIZE ) || nearEdge( pt.y, 0,
SIZE ) )
110 BOOST_CHECK_GT( tested, 5000 );
111 BOOST_CHECK_GT( inside, 0 );
112 BOOST_CHECK_LT( inside, tested );
130 const std::vector<TEST_POINT> cases = {
131 { { 500000, 500000 },
true,
"center" },
132 { { 100000, 100000 },
true,
"inside near corner" },
133 { { 900000, 900000 },
true,
"inside far corner" },
134 { { -100000, 500000 },
false,
"outside left" },
135 { { 500000, -100000 },
false,
"outside above" },
136 { { 1500000, 500000 },
false,
"outside right" },
137 { { 500000, 1500000 },
false,
"outside below" },
138 { { 500000, -1000000 },
false,
"outside Y range above" },
139 { { 500000, 3000000 },
false,
"outside Y range below" },
142 for(
const TEST_POINT& tc : cases )
159 outline.
Append( 1000, 0 );
160 outline.
Append( 1000, 1000 );
161 outline.
Append( 0, 1000 );
174 ystripes.
Build( poly );
176 const std::vector<std::pair<VECTOR2I, bool>> cases = {
177 { { 100, 100 },
true },
178 { { 500, 500 },
false },
179 { { 1500, 500 },
false },
180 { { 800, 200 },
true },
183 for(
const auto& [pt,
expected] : cases )
203 for(
const VECTOR2I& pt : generateRandomPoints( bbox, 10000, 42 ) )
constexpr coord_type GetLeft() const
constexpr coord_type GetRight() const
constexpr coord_type GetTop() const
constexpr coord_type GetBottom() const
Y-stripe spatial index for efficient point-in-polygon containment testing.
bool Contains(const VECTOR2I &aPt, int aAccuracy=0) const
Test whether a point is inside the indexed polygon set.
void Build(const SHAPE_POLY_SET &aPolySet)
Build the spatial index from a SHAPE_POLY_SET's outlines and holes.
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
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 AddHole(const SHAPE_LINE_CHAIN &aHole, int aOutline=-1)
Adds a new hole to the given outline (default: last) and returns its index.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
EDA_ANGLE abs(const EDA_ANGLE &aAngle)
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_SUITE(CadstarPartParser)
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
BOOST_AUTO_TEST_CASE(CorrectnessAllStrategiesAgree)
BOOST_TEST_CONTEXT("Test Clearance")
BOOST_CHECK_EQUAL(result, "25.4")
VECTOR2< int32_t > VECTOR2I