41 std::unique_ptr<PCB_VIA>
via = std::make_unique<PCB_VIA>( &
m_board );
43 via->SetPosition( aCenter );
45 via->SetDrill( 400000 );
59 pad->SetPosition( aCenter );
76 const VECTOR2I viaCenter( 189190000, 46760000 );
77 auto via = MakeVia( viaCenter );
80 chain.Append( viaCenter );
87 BOOST_REQUIRE_EQUAL( chainForward.
Length(), chainBackward.
Length() );
92 BOOST_CHECK_CLOSE(
static_cast<double>( chainForward.
Length() ),
static_cast<double>( chainBackward.
Length() ),
102 const VECTOR2I arcStart( 189190000, 46760000 );
103 const VECTOR2I arcMid( 190382763, 46815467 );
104 const VECTOR2I arcEnd( 189758445, 47833301 );
107 baseChain.
Append( arcStart );
108 SHAPE_ARC arc( arcStart, arcMid, arcEnd, 0 );
111 const double fullArcLen =
static_cast<double>( baseChain.
Length() );
116 auto via = MakeVia( arcStart );
117 auto pad = MakeCircularPad( arcStart );
122 const double viaLen =
static_cast<double>( viaChain.
Length() );
123 const double padLen =
static_cast<double>( padChain.
Length() );
131 BOOST_CHECK_CLOSE( viaLen, padLen, 0.5 );
142 const VECTOR2I arcMid( 6000000, 1000000 );
143 const VECTOR2I arcEnd( 7000000, 0 );
156 auto makeItems = [&]()
158 std::vector<LENGTH_DELAY_CALCULATION_ITEM> items;
170 items.push_back( s );
171 items.push_back( c );
178 .OptimiseVias =
false, .MergeTracks =
false, .OptimiseTracesInPads =
false, .InferViaInPad =
false
181 .OptimiseVias =
false, .MergeTracks =
true, .OptimiseTracesInPads =
false, .InferViaInPad =
false
184 auto i1 = makeItems();
185 auto i2 = makeItems();
187 const double lenNoMerge =
static_cast<double>( calc.
CalculateLength( i1, noMerge,
nullptr,
nullptr ) );
188 const double lenMerge =
static_cast<double>( calc.
CalculateLength( i2, merge,
nullptr,
nullptr ) );
194 BOOST_CHECK_CLOSE( lenNoMerge,
expected, 0.01 );
195 BOOST_CHECK_CLOSE( lenMerge, lenNoMerge, 0.01 );
Information pertinent to a Pcbnew printed circuit board.
Lightweight class which holds a pad, via, or a routed trace outline.
void SetLine(const SHAPE_LINE_CHAIN &aLine)
Sets the source SHAPE_LINE_CHAIN of this item.
void SetWidth(const int aWidth)
Sets the line width.
void SetLayers(const PCB_LAYER_ID aStart, const PCB_LAYER_ID aEnd=PCB_LAYER_ID::UNDEFINED_LAYER)
Sets the first and last layers associated with this item.
Class which calculates lengths (and associated routing statistics) in a BOARD context.
int64_t CalculateLength(std::vector< LENGTH_DELAY_CALCULATION_ITEM > &aItems, PATH_OPTIMISATIONS aOptimisations, const PAD *aStartPad=nullptr, const PAD *aEndPad=nullptr) const
Calculates the electrical length of the given items.
static void OptimiseTraceInVia(SHAPE_LINE_CHAIN &aLine, const PCB_VIA *aVia, PCB_LAYER_ID aLayer)
Clips trace portions inside a VIA pad and replaces them with a straight-line segment from the VIA edg...
static void OptimiseTraceInPad(SHAPE_LINE_CHAIN &aLine, const PAD *aPad, PCB_LAYER_ID aPcbLayer)
Optimises the given trace / line to minimise the electrical path length within the given pad.
LSET is a set of PCB_LAYER_IDs.
@ NORMAL
Shape is the same on all layers.
static constexpr PCB_LAYER_ID ALL_LAYERS
! The layer identifier to use for the single defintion on normal padstacks
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
long long int Length() const
Return length of the line chain in Euclidean metric.
@ PTH
Plated through hole pad.
std::unique_ptr< PAD > MakeCircularPad(const VECTOR2I &aCenter)
std::unique_ptr< PCB_VIA > MakeVia(const VECTOR2I &aCenter)
CLIP_LINE_TO_VIA_FIXTURE()
Struct to control which optimisations the length calculation code runs on the given path objects.
BOOST_AUTO_TEST_CASE(HorizontalAlignment)
BOOST_AUTO_TEST_CASE(StraightTrace_ForwardBackwardAgree)
BOOST_AUTO_TEST_SUITE_END()
VECTOR3I expected(15, 30, 45)
const SHAPE_LINE_CHAIN chain
BOOST_TEST_MESSAGE("Polyline has "<< chain.PointCount()<< " points")
VECTOR2< int32_t > VECTOR2I