46 DP_GATEWAY(
const VECTOR2I& aAnchorP,
const VECTOR2I& aAnchorN,
bool aIsDiagonal,
47 int aAllowedEntryAngles = DIRECTION_45::ANG_OBTUSE,
int aPriority = 0 ) :
48 m_anchorP( aAnchorP ),
49 m_anchorN( aAnchorN ), m_isDiagonal( aIsDiagonal ),
50 m_allowedEntryAngles( aAllowedEntryAngles ), m_priority( aPriority )
52 m_hasEntryLines =
false;
67 const VECTOR2I& AnchorP()
const {
return m_anchorP; }
69 const VECTOR2I& AnchorN()
const {
return m_anchorN; }
84 void SetPriority(
int aPriority)
86 m_priority = aPriority;
93 m_hasEntryLines =
true;
96 const SHAPE_LINE_CHAIN& EntryP()
const {
return m_entryP; }
97 const SHAPE_LINE_CHAIN& EntryN()
const {
return m_entryN; }
98 const DIFF_PAIR Entry()
const ;
102 bool HasEntryLines ()
const
104 return m_hasEntryLines;
108 SHAPE_LINE_CHAIN m_entryP, m_entryN;
109 bool m_hasEntryLines;
110 VECTOR2I m_anchorP, m_anchorN;
112 int m_allowedEntryAngles;
119class DP_PRIMITIVE_PAIR
123 m_primP(
nullptr ), m_primN(
nullptr ) {};
125 DP_PRIMITIVE_PAIR(
const DP_PRIMITIVE_PAIR& aOther );
126 DP_PRIMITIVE_PAIR(
ITEM* aPrimP,
ITEM* aPrimN );
127 DP_PRIMITIVE_PAIR(
const VECTOR2I& aAnchorP,
const VECTOR2I& aAnchorN );
129 ~DP_PRIMITIVE_PAIR();
131 void SetAnchors(
const VECTOR2I& aAnchorP,
const VECTOR2I& aAnchorN );
133 const VECTOR2I& AnchorP()
const {
return m_anchorP; }
134 const VECTOR2I& AnchorN()
const {
return m_anchorN; }
136 DP_PRIMITIVE_PAIR& operator=(
const DP_PRIMITIVE_PAIR& aOther );
138 ITEM* PrimP()
const {
return m_primP; }
139 ITEM* PrimN()
const {
return m_primN; }
141 bool Directional()
const;
147 void CursorOrientation(
const VECTOR2I& aCursorPos, VECTOR2I& aMidpoint,
148 VECTOR2I& aDirection )
const;
152 printf(
"-- Prim-P %p anchor [%d, %d]\n", m_primP, m_anchorP.x, m_anchorP.y );
153 printf(
"-- Prim-N %p anchor [%d, %d]\n", m_primN, m_anchorN.x, m_anchorN.y );
157 DIRECTION_45 anchorDirection(
const ITEM* aItem,
const VECTOR2I& aP )
const;
161 VECTOR2I m_anchorP, m_anchorN;
170 DP_GATEWAYS(
int aGap ):
179 void Clear() { m_gateways.clear(); }
181 void SetFitVias(
bool aEnable,
int aDiameter = 0,
int aViaGap = -1 )
184 m_viaDiameter = aDiameter;
193 void BuildForCursor(
const VECTOR2I& aCursorPos );
194 void BuildOrthoProjections( DP_GATEWAYS& aEntries,
const VECTOR2I& aCursorPos,
196 void BuildGeneric(
const VECTOR2I& p0_p,
const VECTOR2I& p0_n,
bool aBuildEntries =
false,
197 bool aViaMode =
false );
198 void BuildFromPrimitivePair(
const DP_PRIMITIVE_PAIR& aPair,
bool aPreferDiagonal );
200 bool FitGateways( DP_GATEWAYS& aEntry, DP_GATEWAYS& aTarget,
bool aPrefDiagonal,
203 std::vector<DP_GATEWAY>& Gateways() {
return m_gateways; }
205 const std::vector<DP_GATEWAY>& CGateways()
const {
return m_gateways; }
207 void FilterByOrientation(
int aAngleMask,
DIRECTION_45 aRefOrientation );
217 bool checkDiagonalAlignment(
const VECTOR2I& a,
const VECTOR2I& b )
const;
219 void buildEntries(
const VECTOR2I& p0_p,
const VECTOR2I& p0_n );
226 std::vector<DP_GATEWAY> m_gateways;
237 struct COUPLED_SEGMENTS
239 COUPLED_SEGMENTS (
const SEG& aCoupledP,
const SEG& aParentP,
int aIndexP,
240 const SEG& aCoupledN,
const SEG& aParentN,
int aIndexN ) :
241 coupledP( aCoupledP ),
242 coupledN( aCoupledN ),
257 typedef std::vector<COUPLED_SEGMENTS> COUPLED_SEGMENTS_VEC;
269 m_maxUncoupledLength = 0;
277 m_gapConstraint = aGap;
285 m_maxUncoupledLength = 0;
295 m_gapConstraint = aGap;
303 m_maxUncoupledLength = 0;
307 DIFF_PAIR(
const LINE &aLineP,
const LINE &aLineN,
int aGap = 0 ) :
313 m_gapConstraint = aGap;
314 m_net_p = aLineP.Net();
315 m_net_n = aLineN.Net();
316 m_p = aLineP.CLine();
317 m_n = aLineN.CLine();
323 m_maxUncoupledLength = 0;
327 static inline bool ClassOf(
const ITEM* aItem )
329 return aItem && ITEM::DIFF_PAIR_T == aItem->Kind();
341 m_line_p.ClearLinks();
342 m_line_n.ClearLinks();
361 void SetShape(
const DIFF_PAIR& aPair )
367 void SetNets(
int aP,
int aN )
373 void SetWidth(
int aWidth )
376 m_n.SetWidth( aWidth );
377 m_p.SetWidth( aWidth );
380 int Width()
const {
return m_width; }
382 void SetGap(
int aGap )
385 m_gapConstraint = RANGED_NUM<int>( m_gap, 10000, 10000 );
393 void AppendVias(
const VIA &aViaP,
const VIA& aViaN )
405 bool EndsWithVias()
const
410 void SetViaDiameter(
int aDiameter )
412 m_via_p.SetDiameter( aDiameter );
413 m_via_n.SetDiameter( aDiameter );
416 void SetViaDrill(
int aDrill )
418 m_via_p.SetDrill( aDrill );
419 m_via_n.SetDrill( aDrill );
434 if( !m_line_p.IsLinked() )
435 updateLine( m_line_p, m_p, m_net_p, m_via_p );
442 if( !m_line_n.IsLinked() )
443 updateLine( m_line_n, m_n, m_net_n, m_via_n );
448 DP_PRIMITIVE_PAIR EndingPrimitives();
450 double CoupledLength()
const;
451 double TotalLength()
const;
452 double CoupledLengthFactor()
const;
455 void CoupledSegmentPairs( COUPLED_SEGMENTS_VEC& aPairs )
const;
463 void Append(
const DIFF_PAIR& aOther )
465 m_n.Append( aOther.m_n );
466 m_p.Append( aOther.m_p );
471 return ( m_n.SegmentCount() == 0 ) || ( m_p.SegmentCount() == 0 );
474 const SHAPE_LINE_CHAIN& CP()
const {
return m_p; }
475 const SHAPE_LINE_CHAIN& CN()
const {
return m_n; }
477 bool BuildInitial(
const DP_GATEWAY& aEntry,
const DP_GATEWAY& aTarget,
bool aPrefDiagonal );
478 bool CheckConnectionAngle(
const DIFF_PAIR &aOther,
int allowedAngles )
const;
479 int CoupledLength(
const SEG& aP,
const SEG& aN )
const;
481 int64_t CoupledLength(
const SHAPE_LINE_CHAIN& aP,
const SHAPE_LINE_CHAIN& aN )
const;
483 const RANGED_NUM<int> GapConstraint()
const
485 return m_gapConstraint;
489 void updateLine( LINE &aLine,
const SHAPE_LINE_CHAIN& aShape,
int aNet,
const VIA& aVia )
491 aLine.SetShape( aShape );
492 aLine.SetWidth( m_width );
493 aLine.SetNet( aNet );
494 aLine.SetLayer( Layers().Start() );
497 aLine.AppendVia( aVia );
502 SHAPE_LINE_CHAIN m_n, m_p;
503 LINE m_line_p, m_line_n;
504 VIA m_via_p, m_via_n;
507 int m_net_p, m_net_n;
511 int m_maxUncoupledLength;
513 RANGED_NUM<int> m_gapConstraint;
virtual void ClearLinks() override
Return the number of segments that were assembled together to form this line.
Definition pns_diff_pair.h:338
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:61
LINK_HOLDER(PnsKind aKind)
Add a reference to an item registered in a NODE that is a part of this line.
Definition pns_link_holder.h:38