23 #ifndef __PNS_DIFF_PAIR_H
24 #define __PNS_DIFF_PAIR_H
28 #include <geometry/shape.h>
29 #include <geometry/shape_line_chain.h>
34 #include "ranged_num.h"
52 int aAllowedEntryAngles = DIRECTION_45::ANG_OBTUSE,
54 : m_anchorP( aAnchorP ),
55 m_anchorN( aAnchorN ),
56 m_isDiagonal( aIsDiagonal ),
57 m_allowedEntryAngles( aAllowedEntryAngles ),
58 m_priority( aPriority )
60 m_hasEntryLines =
false;
77 const VECTOR2I& AnchorP()
const {
return m_anchorP; }
79 const VECTOR2I& AnchorN()
const {
return m_anchorN; }
99 void SetPriority(
int aPriority)
101 m_priority = aPriority;
108 m_hasEntryLines =
true;
113 const DIFF_PAIR Entry()
const ;
117 bool HasEntryLines ()
const
119 return m_hasEntryLines;
124 bool m_hasEntryLines;
127 int m_allowedEntryAngles;
140 m_primP( NULL ), m_primN( NULL ) {};
150 const VECTOR2I& AnchorP()
const {
return m_anchorP; }
151 const VECTOR2I& AnchorN()
const {
return m_anchorN; }
155 ITEM* PrimP()
const {
return m_primP; }
156 ITEM* PrimN()
const {
return m_primN; }
158 bool Directional()
const;
168 printf(
"-- Prim-P %p anchor [%d, %d]\n", m_primP, m_anchorP.x, m_anchorP.y );
169 printf(
"-- Prim-N %p anchor [%d, %d]\n", m_primN, m_anchorN.x, m_anchorN.y );
190 m_gap( aGap ), m_viaGap( aGap )
197 void SetGap(
int aGap )
208 void SetFitVias(
bool aEnable,
int aDiameter = 0,
int aViaGap = -1 )
211 m_viaDiameter = aDiameter;
219 void BuildForCursor(
const VECTOR2I& aCursorPos );
220 void BuildOrthoProjections(
DP_GATEWAYS &aEntries,
const VECTOR2I& aCursorPos,
int aOrthoScore );
221 void BuildGeneric(
const VECTOR2I& p0_p,
const VECTOR2I& p0_n,
bool aBuildEntries =
false,
bool aViaMode =
false );
222 void BuildFromPrimitivePair(
const DP_PRIMITIVE_PAIR& aPair,
bool aPreferDiagonal );
226 std::vector<DP_GATEWAY>& Gateways()
231 const std::vector<DP_GATEWAY>& CGateways()
const
236 void FilterByOrientation(
int aAngleMask,
DIRECTION_45 aRefOrientation );
255 std::vector<DP_GATEWAY> m_gateways;
270 const SEG& aCoupledN,
const SEG& aParentN,
int aIndexN ) :
271 coupledP( aCoupledP ),
272 coupledN( aCoupledN ),
287 typedef std::vector<COUPLED_SEGMENTS> COUPLED_SEGMENTS_VEC;
297 m_maxUncoupledLength = 0;
305 m_gapConstraint = aGap;
313 m_maxUncoupledLength = 0;
323 m_gapConstraint = aGap;
331 m_maxUncoupledLength = 0;
335 DIFF_PAIR(
const LINE &aLineP,
const LINE &aLineN,
int aGap = 0 ):
341 m_gapConstraint = aGap;
342 m_net_p = aLineP.Net();
343 m_net_n = aLineN.Net();
344 m_p = aLineP.CLine();
345 m_n = aLineN.CLine();
351 m_maxUncoupledLength = 0;
355 static inline bool ClassOf(
const ITEM* aItem )
357 return aItem && DIFF_PAIR_T == aItem->Kind();
378 void SetShape(
const DIFF_PAIR& aPair )
384 void SetNets(
int aP,
int aN )
390 void SetWidth(
int aWidth )
395 int Width()
const {
return m_width; }
397 void SetGap(
int aGap )
408 void AppendVias(
const VIA &aViaP,
const VIA& aViaN )
420 bool EndsWithVias()
const
437 if( !m_line_p.IsLinked() )
438 updateLine( m_line_p, m_p, m_net_p, m_via_p );
445 if( !m_line_n.IsLinked() )
446 updateLine( m_line_n, m_n, m_net_n, m_via_n );
451 DP_PRIMITIVE_PAIR EndingPrimitives();
453 double CoupledLength()
const;
454 double TotalLength()
const;
455 double CoupledLengthFactor()
const;
458 void CoupledSegmentPairs( COUPLED_SEGMENTS_VEC& aPairs )
const;
466 void Append(
const DIFF_PAIR& aOther )
480 bool BuildInitial(
const DP_GATEWAY& aEntry,
const DP_GATEWAY& aTarget,
bool aPrefDiagonal );
481 bool CheckConnectionAngle(
const DIFF_PAIR &aOther,
int allowedAngles )
const;
482 int CoupledLength(
const SEG& aP,
const SEG& aN )
const;
488 return m_gapConstraint;
492 void updateLine( LINE &aLine,
const SHAPE_LINE_CHAIN& aShape,
int aNet, VIA& aVia )
494 aLine.SetShape( aShape );
495 aLine.SetWidth( m_width );
496 aLine.SetNet( aNet );
497 aLine.SetLayer(
Layers().Start() );
500 aLine.AppendVia( aVia );
504 LINE m_line_p, m_line_n;
505 VIA m_via_p, m_via_n;
508 int m_net_p, m_net_n;
512 int m_maxUncoupledLength;