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 );
126BOOST_FIXTURE_TEST_SUITE( TestShapeLineChain,
SLC_CASES )
134 Clipper2Lib::Path64 pathClipper2 = {
135 { { 125663951, 120099260, 24 }, { 125388111, 120170850, 25 }, { 125124975, 120280270, 26 },
136 { 124879705, 120425376, 27 }, { 124657110, 120603322, 28 }, { 124461556, 120810617, 29 },
137 { 124296876, 121043198, 30 }, { 124166301, 121296503, 31 }, { 124072391, 121565564, 32 },
138 { 124016988, 121845106, 33 }, { 124001177, 122129646, 34 }, { 124025270, 122413605, 35 },
139 { 124088794, 122691414, 36 }, { 124190502, 122957625, 37 }, { 124328401, 123207018, 38 },
140 { 124499787, 123434703, 39 }, { 124598846, 123537154, 40 }, { 127171000, 123786000, 4 },
141 { 127287862, 123704439, 5 }, { 127499716, 123513831, 6 }, { 127682866, 123295498, 7 },
142 { 127833720, 123053722, 8 }, { 127949321, 122793242, 9 }, { 128027402, 122519168, 10 },
143 { 128066430, 122236874, 11 }, { 128065642, 121951896, 12 }, { 128025053, 121669823, 13 },
144 { 127945457, 121396185, 14 }, { 127828417, 121136349, 15 }, { 127676227, 120895410, 16 },
145 { 127491873, 120678094, 17 }, { 127278968, 120488661, 18 }, { 127041689, 120330827, 19 },
146 { 126784688, 120207687, 20 }, { 126513005, 120121655, 21 }, { 126231968, 120074419, 22 },
147 { 125947087, 120066905, 23 } }
150 std::vector<CLIPPER_Z_VALUE> z_values = {
151 { { -1, -1 }, 0 }, { { -1, -1 }, 0 }, { { -1, -1 }, 0 }, { { -1, -1 }, 0 },
152 { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -1 }, 0 }, { { 0, -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 },
164 std::vector<SHAPE_ARC> arcs = {
165 SHAPE_ARC( { 127171000, 123786000 }, { 126231718, 120077003 }, { 124598846, 123537154 }, 0 )
208 base_chain.Replace( 0, 2, chain_insert );
230 base_chain.Insert( 9,
VECTOR2I( 250000, 0 ) );
235 base_chain.Replace( 5, 6, chain_insert );
240 base_chain.Replace( 4, 6,
VECTOR2I( 550000, 0 ) );
246 base_chain.SetClosed(
true );
247 double areaPriorToArcRemoval = base_chain.Area();
248 base_chain.ClearArcs();
264 SHAPE_ARC( { -859598, 2559876 }, { -1632771, 1022403 }, { -3170244, 249230 }, 0 ) );
267 SHAPE_ARC( { -3170244, -1657832 }, { -292804, -317564 }, { 1047464, 2559876 }, 0 ) );
286 Circle2Arcs.SetClosed(
false );
351 SHAPE_LINE_CHAIN outline1( { { 1316455, 913576 }, { 1316455, 901129 }, { 1321102, 901129 },
352 { 1322152, 901191 }, { 1323055, 901365 }, { 1323830, 901639 },
353 { 1324543, 902036 }, { 1325121, 902521 }, { 1325581, 903100 },
354 { 1325914, 903759 }, { 1326120, 904516 }, { 1326193, 905390 },
355 { 1326121, 906253 }, { 1325915, 907005 }, { 1325581, 907667 },
356 { 1325121, 908248 }, { 1324543, 908735 }, { 1323830, 909132 },
357 { 1323055, 909406 }, { 1322153, 909579 }, { 1321102, 909641 },
358 { 1317174, 909641 }, { 1317757, 909027 }, { 1317757, 913576 } } );
359 SHAPE_LINE_CHAIN outline2( { { 1297076, 916244 }, { 1284629, 916244 }, { 1284629, 911597 },
360 { 1284691, 910547 }, { 1284865, 909644 }, { 1285139, 908869 },
361 { 1285536, 908156 }, { 1286021, 907578 }, { 1286600, 907118 },
362 { 1287259, 906785 }, { 1288016, 906579 }, { 1288890, 906506 },
363 { 1289753, 906578 }, { 1290505, 906784 }, { 1291167, 907118 },
364 { 1291748, 907578 }, { 1292235, 908156 }, { 1292632, 908869 },
365 { 1292906, 909644 }, { 1293079, 910546 }, { 1293141, 911597 },
366 { 1293141, 915525 }, { 1292527, 914942 }, { 1297076, 914942 } } );
372 outline1.SetClosed(
true );
373 outline2.SetClosed(
true );
375 BOOST_CHECK( outline1.PointInside( point1, 0,
false ) );
376 BOOST_CHECK( outline2.PointInside( point2, 0,
false ) );
934 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP1(), tol ) );
943 for(
int i = 4; i <= 8; i++ )
946 for(
int i = 3; i <= 7; i++ )
968 expectedSliceArc0.
GetP1() );
970 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP0(), tol ) );
974 expectedSliceArc0.
GetP0() );
977 for(
int i = 1; i <= 4; i++ )
980 for(
int i = 0; i <= 3; i++ )
985 expectedSliceArc0.
GetP1() );
1012 for(
int i = 1; i <= 6; i++ )
1015 for(
int i = 0; i <= 5; i++ )
1042 for(
int i = 1; i <= 6; i++ )
1045 for(
int i = 0; i <= 5; i++ )
1104 for(
int i = 1; i <= 7; i++ )
1107 for(
int i = 0; i <= 6; i++ )
1127 expectedSliceArc0.
GetP1() );
1129 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP0(), tol ) );
1133 expectedSliceArc0.
GetP0() );
1136 for(
int i = 1; i <= 3; i++ )
1139 for(
int i = 0; i <= 2; i++ )
1144 expectedSliceArc0.
GetP1() );
1150 chain10.
Append( firstArc );
1163 expectedSliceArc0.
GetP1() );
1165 BOOST_CHECK( sliceResult.
Arc( 0 ).
Collide( expectedSliceArc0.
GetP0(), tol ) );
1169 expectedSliceArc0.
GetP0() );
1172 for(
int i = 1; i <= 3; i++ )
1175 for(
int i = 0; i <= 2; i++ )
1180 expectedSliceArc0.
GetP1() );
1204 VECTOR2I ptOnArcCloseToStart( 297553, 31697 );
1205 VECTOR2I ptOnArcCloseToEnd( 139709, 82983 );
1218 BOOST_TEST_INFO(
"8949 crash" );
1220 std::vector<VECTOR2I> linePts = {
1221 { 206000000, 140110000 }, { 192325020, 140110000 }, { 192325020, 113348216 },
1222 { 192251784, 113274980 }, { 175548216, 113274980 }, { 175474980, 113348216 },
1223 { 175474980, 136694980 }, { 160774511, 121994511 }, { 160774511, 121693501 },
1224 { 160086499, 121005489 }, { 159785489, 121005489 }, { 159594511, 120814511 },
1225 { 160086499, 120814511 }, { 160774511, 120126499 }, { 160774511, 119153501 },
1226 { 160086499, 118465489 }, { 159113501, 118465489 }, { 158425489, 119153501 },
1227 { 158425489, 119645489 }, { 157325020, 118545020 }, { 157325020, 101925020 },
1228 { 208674980, 101925020 }, { 208674980, 145474980 }, { 192325020, 145474980 },
1229 { 192325020, 140110000 }
1239 baseChain.
Replace( 1, 23, replaceChain );
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 double 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.
void Simplify(int aMaxError=0)
Simplify the line chain by removing colinear adjacent segments and duplicate vertices.
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.
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Return a subset of this line chain containing the [start_index, end_index] range of points.
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 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