65 VECTOR2I( 183450000, 128360000 ), 0 );
69 VECTOR2I( 183850000, 128360000 ), 0 );
73 VECTOR2I( 183450000, 128360000 ), 0 );
77 VECTOR2I( 183500000, 129204974 ), 0 );
81 VECTOR2I( 283850000, 228360000 ), 0 );
127BOOST_FIXTURE_TEST_SUITE( TestShapeLineChain,
SLC_CASES )
135 Clipper2Lib::Path64 pathClipper2 = {
136 { { 125663951, 120099260, 24 }, { 125388111, 120170850, 25 }, { 125124975, 120280270, 26 },
137 { 124879705, 120425376, 27 }, { 124657110, 120603322, 28 }, { 124461556, 120810617, 29 },
138 { 124296876, 121043198, 30 }, { 124166301, 121296503, 31 }, { 124072391, 121565564, 32 },
139 { 124016988, 121845106, 33 }, { 124001177, 122129646, 34 }, { 124025270, 122413605, 35 },
140 { 124088794, 122691414, 36 }, { 124190502, 122957625, 37 }, { 124328401, 123207018, 38 },
141 { 124499787, 123434703, 39 }, { 124598846, 123537154, 40 }, { 127171000, 123786000, 4 },
142 { 127287862, 123704439, 5 }, { 127499716, 123513831, 6 }, { 127682866, 123295498, 7 },
143 { 127833720, 123053722, 8 }, { 127949321, 122793242, 9 }, { 128027402, 122519168, 10 },
144 { 128066430, 122236874, 11 }, { 128065642, 121951896, 12 }, { 128025053, 121669823, 13 },
145 { 127945457, 121396185, 14 }, { 127828417, 121136349, 15 }, { 127676227, 120895410, 16 },
146 { 127491873, 120678094, 17 }, { 127278968, 120488661, 18 }, { 127041689, 120330827, 19 },
147 { 126784688, 120207687, 20 }, { 126513005, 120121655, 21 }, { 126231968, 120074419, 22 },
148 { 125947087, 120066905, 23 } }
151 std::vector<CLIPPER_Z_VALUE> z_values = {
152 { { -1, -1 }, 0 }, { { -1, -1 }, 0 }, { { -1, -1 }, 0 }, { { -1, -1 }, 0 },
153 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
154 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
155 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
156 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
157 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
158 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
159 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
160 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
161 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 },
165 std::vector<SHAPE_ARC> arcs = {
166 SHAPE_ARC( { 127171000, 123786000 }, { 126231718, 120077003 }, { 124598846, 123537154 }, 0 )
211 base_chain.Replace( 0, 2, chain_insert );
234 base_chain.Insert( 9,
VECTOR2I( 250000, 0 ) );
239 base_chain.Replace( 5, 6, chain_insert );
244 base_chain.Replace( 4, 6,
VECTOR2I( 550000, 0 ) );
250 base_chain.SetClosed(
true );
251 double areaPriorToArcRemoval = base_chain.Area();
252 base_chain.ClearArcs();
267 chain.
Append(
SHAPE_ARC( { -859598, 2559876 }, { -1632771, 1022403 }, { -3170244, 249230 }, 0 ),
270 chain.
Append(
SHAPE_ARC( { -3170244, -1657832 }, { -292804, -317564 }, { 1047464, 2559876 }, 0 ),
290 Circle2Arcs.SetClosed(
false );
355 SHAPE_LINE_CHAIN outline1( { { 1316455, 913576 }, { 1316455, 901129 }, { 1321102, 901129 },
356 { 1322152, 901191 }, { 1323055, 901365 }, { 1323830, 901639 },
357 { 1324543, 902036 }, { 1325121, 902521 }, { 1325581, 903100 },
358 { 1325914, 903759 }, { 1326120, 904516 }, { 1326193, 905390 },
359 { 1326121, 906253 }, { 1325915, 907005 }, { 1325581, 907667 },
360 { 1325121, 908248 }, { 1324543, 908735 }, { 1323830, 909132 },
361 { 1323055, 909406 }, { 1322153, 909579 }, { 1321102, 909641 },
362 { 1317174, 909641 }, { 1317757, 909027 }, { 1317757, 913576 } } );
363 SHAPE_LINE_CHAIN outline2( { { 1297076, 916244 }, { 1284629, 916244 }, { 1284629, 911597 },
364 { 1284691, 910547 }, { 1284865, 909644 }, { 1285139, 908869 },
365 { 1285536, 908156 }, { 1286021, 907578 }, { 1286600, 907118 },
366 { 1287259, 906785 }, { 1288016, 906579 }, { 1288890, 906506 },
367 { 1289753, 906578 }, { 1290505, 906784 }, { 1291167, 907118 },
368 { 1291748, 907578 }, { 1292235, 908156 }, { 1292632, 908869 },
369 { 1292906, 909644 }, { 1293079, 910546 }, { 1293141, 911597 },
370 { 1293141, 915525 }, { 1292527, 914942 }, { 1297076, 914942 } } );
376 outline1.SetClosed(
true );
377 outline2.SetClosed(
true );
379 BOOST_CHECK( outline1.PointInside( point1, 0,
false ) );
380 BOOST_CHECK( outline2.PointInside( point2, 0,
false ) );
938 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP1(), tol ) );
947 for(
int i = 4; i <= 8; i++ )
950 for(
int i = 3; i <= 7; i++ )
972 expectedSliceArc0.
GetP1() );
974 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP0(), tol ) );
978 expectedSliceArc0.
GetP0() );
981 for(
int i = 1; i <= 4; i++ )
984 for(
int i = 0; i <= 3; i++ )
989 expectedSliceArc0.
GetP1() );
1016 for(
int i = 1; i <= 6; i++ )
1019 for(
int i = 0; i <= 5; i++ )
1046 for(
int i = 1; i <= 6; i++ )
1049 for(
int i = 0; i <= 5; i++ )
1108 for(
int i = 1; i <= 7; i++ )
1111 for(
int i = 0; i <= 6; i++ )
1131 expectedSliceArc0.
GetP1() );
1133 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP0(), tol ) );
1137 expectedSliceArc0.
GetP0() );
1140 for(
int i = 1; i <= 3; i++ )
1143 for(
int i = 0; i <= 2; i++ )
1148 expectedSliceArc0.
GetP1() );
1167 expectedSliceArc0.
GetP1() );
1169 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP0(), tol ) );
1173 expectedSliceArc0.
GetP0() );
1176 for(
int i = 1; i <= 3; i++ )
1179 for(
int i = 0; i <= 2; i++ )
1184 expectedSliceArc0.
GetP1() );
1208 VECTOR2I ptOnArcCloseToStart( 297553, 31697 );
1209 VECTOR2I ptOnArcCloseToEnd( 139709, 82983 );
1222 BOOST_TEST_INFO(
"8949 crash" );
1224 std::vector<VECTOR2I> linePts = {
1225 { 206000000, 140110000 }, { 192325020, 140110000 }, { 192325020, 113348216 },
1226 { 192251784, 113274980 }, { 175548216, 113274980 }, { 175474980, 113348216 },
1227 { 175474980, 136694980 }, { 160774511, 121994511 }, { 160774511, 121693501 },
1228 { 160086499, 121005489 }, { 159785489, 121005489 }, { 159594511, 120814511 },
1229 { 160086499, 120814511 }, { 160774511, 120126499 }, { 160774511, 119153501 },
1230 { 160086499, 118465489 }, { 159113501, 118465489 }, { 158425489, 119153501 },
1231 { 158425489, 119645489 }, { 157325020, 118545020 }, { 157325020, 101925020 },
1232 { 208674980, 101925020 }, { 208674980, 145474980 }, { 192325020, 145474980 },
1233 { 192325020, 140110000 }
1243 baseChain.
Replace( 1, 23, replaceChain );
constexpr int ARC_HIGH_DEF
const VECTOR2I & GetArcMid() const
SHAPE_ARC & ConstructFromStartEndCenter(const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, bool aClockwise=false, double aWidth=0)
Constructs this arc from the given start, end and center.
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
const VECTOR2I & GetCenter() const
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
bool IsPtOnArc(size_t aPtIndex) const
const SHAPE_ARC & Arc(size_t aArc) const
bool IsClosed() const override
virtual const VECTOR2I GetPoint(int aIndex) const override
int Split(const VECTOR2I &aP, bool aExact=false)
Insert the point aP belonging to one of the our segments, splitting the adjacent segment in two.
int ShapeCount() const
Return the number of shapes (line segments or arcs) in this line chain.
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.
bool IsArcEnd(size_t aIndex) const
void Replace(int aStartIndex, int aEndIndex, const VECTOR2I &aP)
Replace points with indices in range [start_index, end_index] with a single point aP.
void Simplify(int aTolerance=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const std::vector< std::pair< ssize_t, ssize_t > > & CShapes() const
const VECTOR2I NearestPoint(const VECTOR2I &aP, bool aAllowInternalShapePoints=true) const
Find a point on the line chain that is closest to point aP.
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex) const
Return a subset of this line chain containing the [start_index, end_index] range of points.
const VECTOR2I & CLastPoint() const
Return the last point in the line chain.
void RemoveShape(int aPointIndex)
Remove the shape at the given index from the line chain.
bool IsArcStart(size_t aIndex) const
void SetWidth(int aWidth)
Set the width of all segments in the chain.
bool IsSharedPt(size_t aIndex) const
Test if a point is shared between multiple shapes.
const std::vector< VECTOR2I > & CPoints() const
static constexpr EDA_ANGLE ANGLE_180
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...
Numerical test predicates.
int m_expected_point_count
int m_expected_shape_count
int m_expected_shape_count
NOTE: Collision of SHAPE_LINE_CHAIN with arcs is tested in test_shape_arc.cpp.
SHAPE_LINE_CHAIN EmptyChain
SHAPE_LINE_CHAIN Circle1Arc
SHAPE_LINE_CHAIN ArcsCoincident
SHAPE_ARC Arc1
start coincident with Arc0a end
SHAPE_ARC Arc2
Independent arc.
SHAPE_ARC Arc3
Arc with angle >180.
SHAPE_ARC Arc0a
First half of a circle.
SHAPE_LINE_CHAIN DuplicateArcs
SHAPE_LINE_CHAIN Circle2Arcs
SHAPE_LINE_CHAIN ArcsCoincidentClosed
SHAPE_LINE_CHAIN TwoPoints
SHAPE_LINE_CHAIN SegAndArcCoincident
SHAPE_LINE_CHAIN ArcsIndependent
SHAPE_ARC ArcCircle
Full Circle arc.
SHAPE_LINE_CHAIN ThreePoints
SHAPE_LINE_CHAIN ArcAndPoint
SHAPE_LINE_CHAIN ArcsAndSegMixed
SHAPE_LINE_CHAIN OnePoint
SHAPE_ARC Arc0b
Second half of a circle.
BOOST_CHECK_EQUAL(ret, c.m_exp_result)
BOOST_AUTO_TEST_SUITE_END()
SHAPE_ARC arc2(c.m_arc2.GenerateArc())
const SHAPE_LINE_CHAIN chain
BOOST_TEST_CONTEXT("Test Clearance")
static const std::vector< CLOSE_TOGGLE_SHAPE_CASE > close_toggle_shape_cases
BOOST_AUTO_TEST_CASE(ClipperConstructorCase1)
static const std::vector< REMOVE_SHAPE_CASE > remove_shape_cases
VECTOR2< int32_t > VECTOR2I