23#ifndef __PNS_DIFF_PAIR_H
24#define __PNS_DIFF_PAIR_H
30#include "pns_link_holder.h"
32#include "ranged_num.h"
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;
98 const DIFF_PAIR Entry()
const ;
102 bool HasEntryLines ()
const
104 return m_hasEntryLines;
109 bool m_hasEntryLines;
112 int m_allowedEntryAngles;
123 m_primP(
nullptr ), m_primN(
nullptr ) {};
133 const VECTOR2I& AnchorP()
const {
return m_anchorP; }
134 const VECTOR2I& AnchorN()
const {
return m_anchorN; }
138 ITEM* PrimP()
const {
return m_primP; }
139 ITEM* PrimN()
const {
return m_primN; }
141 bool Directional()
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 );
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 );
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 );
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 );
226 std::vector<DP_GATEWAY> m_gateways;
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;
290 LINK_HOLDER( ITEM::DIFF_PAIR_T ),
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();
361 void SetShape(
const DIFF_PAIR& aPair )
367 void SetNets(
int aP,
int aN )
373 void SetWidth(
int aWidth )
380 int Width()
const {
return m_width; }
382 void SetGap(
int aGap )
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 );
435 updateLine( m_line_p, m_p, m_net_p, m_via_p );
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 )
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;
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 );
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;
Represent route directions & corner angles in a 45-degree metric.
Definition direction45.h:37
Basic class for a differential pair.
Definition pns_diff_pair.h:235
virtual void ClearLinks() override
Return the number of segments that were assembled together to form this line.
Definition pns_diff_pair.h:338
DIFF_PAIR * Clone() const override
Return a deep copy of the item.
Definition pns_diff_pair.h:332
A set of gateways calculated for the cursor or starting/ending primitive pair.
Definition pns_diff_pair.h:168
Define a "gateway" for routing a differential pair - e.g.
Definition pns_diff_pair.h:44
bool IsDiagonal() const
Definition pns_diff_pair.h:62
int AllowedAngles() const
Definition pns_diff_pair.h:74
int Priority() const
Definition pns_diff_pair.h:79
Store starting/ending primitives (pads, vias or segments) for a differential pair.
Definition pns_diff_pair.h:120
Base class for PNS router board items.
Definition pns_item.h:57
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:61
Definition pns_link_holder.h:34
bool IsLinked() const
Check if the segment aLink is a part of the line.
Definition pns_link_holder.h:52
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
virtual void ClearLinks()
Return the number of segments that were assembled together to form this line.
Definition pns_link_holder.h:69
Definition ranged_num.h:24
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Definition shape_line_chain.h:81
void Clear()
Remove all points from the line chain.
Definition shape_line_chain.h:242
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
Definition shape_line_chain.h:495
int SegmentCount() const
Return the number of segments in this line chain.
Definition shape_line_chain.h:295
void SetWidth(int aWidth)
Set the width of all segments in the chain.
Definition shape_line_chain.h:275
Definition pns_diff_pair.h:238