KiCad PCB EDA Suite
PNS::DP_GATEWAYS Class Reference

A set of gateways calculated for the cursor or starting/ending primitive pair. More...

#include <pns_diff_pair.h>

Classes

struct  DP_CANDIDATE
 

Public Member Functions

 DP_GATEWAYS (int aGap)
 
void Clear ()
 
void SetFitVias (bool aEnable, int aDiameter=0, int aViaGap=-1)
 
void BuildForCursor (const VECTOR2I &aCursorPos)
 
void BuildOrthoProjections (DP_GATEWAYS &aEntries, const VECTOR2I &aCursorPos, int aOrthoScore)
 
void BuildGeneric (const VECTOR2I &p0_p, const VECTOR2I &p0_n, bool aBuildEntries=false, bool aViaMode=false)
 
void BuildFromPrimitivePair (const DP_PRIMITIVE_PAIR &aPair, bool aPreferDiagonal)
 
bool FitGateways (DP_GATEWAYS &aEntry, DP_GATEWAYS &aTarget, bool aPrefDiagonal, DIFF_PAIR &aDp)
 
std::vector< DP_GATEWAY > & Gateways ()
 
const std::vector< DP_GATEWAY > & CGateways () const
 
void FilterByOrientation (int aAngleMask, DIRECTION_45 aRefOrientation)
 

Private Member Functions

bool checkDiagonalAlignment (const VECTOR2I &a, const VECTOR2I &b) const
 
void buildDpContinuation (const DP_PRIMITIVE_PAIR &aPair, bool aIsDiagonal)
 
void buildEntries (const VECTOR2I &p0_p, const VECTOR2I &p0_n)
 

Private Attributes

int m_gap
 
int m_viaGap
 
int m_viaDiameter
 
bool m_fitVias
 
std::vector< DP_GATEWAYm_gateways
 

Detailed Description

A set of gateways calculated for the cursor or starting/ending primitive pair.

Definition at line 167 of file pns_diff_pair.h.

Constructor & Destructor Documentation

◆ DP_GATEWAYS()

PNS::DP_GATEWAYS::DP_GATEWAYS ( int  aGap)
inline

Definition at line 170 of file pns_diff_pair.h.

170  :
171  m_gap( aGap ),
172  m_viaGap( aGap )
173  {
174  // Do not leave uninitialized members, and keep static analyzer quiet:
175  m_viaDiameter = 0;
176  m_fitVias = true;
177  }

References m_fitVias, and m_viaDiameter.

Member Function Documentation

◆ buildDpContinuation()

void PNS::DP_GATEWAYS::buildDpContinuation ( const DP_PRIMITIVE_PAIR aPair,
bool  aIsDiagonal 
)
private

Definition at line 591 of file pns_diff_pair.cpp.

592 {
593  DP_GATEWAY gw( aPair.AnchorP(), aPair.AnchorN(), aIsDiagonal );
594  gw.SetPriority( 100 );
595  m_gateways.push_back( gw );
596 
597  if( !aPair.Directional() )
598  return;
599 
600  DIRECTION_45 dP = aPair.DirP();
601  DIRECTION_45 dN = aPair.DirN();
602 
603  int gap = ( aPair.AnchorP() - aPair.AnchorN() ).EuclideanNorm();
604 
605  VECTOR2I vdP = aPair.AnchorP() + dP.Left().ToVector();
606  VECTOR2I vdN = aPair.AnchorN() + dN.Left().ToVector();
607 
608  SEGMENT* sP = static_cast<SEGMENT*>( aPair.PrimP() );
609 
610  VECTOR2I t1, t2;
611 
612  auto vL = makeGapVector( dP.Left().ToVector(), ( gap + 1 ) / 2 );
613  auto vR = makeGapVector( dP.Right().ToVector(), ( gap + 1 ) / 2 );
614 
615  if( sP->Seg().Side( vdP ) == sP->Seg().Side( vdN ) )
616  {
617  t1 = aPair.AnchorP() + vL;
618  t2 = aPair.AnchorN() + vR;
619  }
620  else
621  {
622  t1 = aPair.AnchorP() + vR;
623  t2 = aPair.AnchorN() + vL;
624  }
625 
626  DP_GATEWAY gwL( t2, aPair.AnchorN(), !aIsDiagonal );
627  SHAPE_LINE_CHAIN ep = dP.BuildInitialTrace( aPair.AnchorP(), t2, !aIsDiagonal );
628  gwL.SetPriority( 10 );
629  gwL.SetEntryLines( ep , SHAPE_LINE_CHAIN() );
630 
631  m_gateways.push_back( gwL );
632 
633  DP_GATEWAY gwR( aPair.AnchorP(), t1, !aIsDiagonal );
634  SHAPE_LINE_CHAIN en = dP.BuildInitialTrace( aPair.AnchorN(), t1, !aIsDiagonal );
635  gwR.SetPriority( 10) ;
636  gwR.SetEntryLines( SHAPE_LINE_CHAIN(), en );
637 
638  m_gateways.push_back( gwR );
639 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
const VECTOR2I ToVector() const
Definition: direction45.h:274
std::vector< DP_GATEWAY > m_gateways
const DIRECTION_45 Left() const
Return the direction on the left side of this (i.e.
Definition: direction45.h:256
const DIRECTION_45 Right() const
Return the direction on the right side of this (i.e.
Definition: direction45.h:238
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false, bool aFillet=false) const
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime.
static VECTOR2I makeGapVector(VECTOR2I dir, int length)
Represent a polyline (an zero-thickness chain of connected line segments).

References PNS::DP_PRIMITIVE_PAIR::AnchorN(), PNS::DP_PRIMITIVE_PAIR::AnchorP(), DIRECTION_45::BuildInitialTrace(), PNS::DP_PRIMITIVE_PAIR::Directional(), PNS::DP_PRIMITIVE_PAIR::DirN(), PNS::DP_PRIMITIVE_PAIR::DirP(), EuclideanNorm(), DIRECTION_45::Left(), m_gateways, PNS::makeGapVector(), PNS::DP_PRIMITIVE_PAIR::PrimP(), DIRECTION_45::Right(), PNS::SEGMENT::Seg(), PNS::DP_GATEWAY::SetPriority(), SEG::Side(), and DIRECTION_45::ToVector().

Referenced by BuildFromPrimitivePair().

◆ buildEntries()

void PNS::DP_GATEWAYS::buildEntries ( const VECTOR2I p0_p,
const VECTOR2I p0_n 
)
private

Definition at line 575 of file pns_diff_pair.cpp.

576 {
577  for( DP_GATEWAY &g : m_gateways )
578  {
579  if( !g.HasEntryLines() )
580  {
581  SHAPE_LINE_CHAIN lead_p = DIRECTION_45().BuildInitialTrace ( g.AnchorP(), p0_p,
582  g.IsDiagonal() ).Reverse();
583  SHAPE_LINE_CHAIN lead_n = DIRECTION_45().BuildInitialTrace ( g.AnchorN(), p0_n,
584  g.IsDiagonal() ).Reverse();
585  g.SetEntryLines( lead_p, lead_n );
586  }
587  }
588 }
std::vector< DP_GATEWAY > m_gateways
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false, bool aFillet=false) const
Build a 2-segment line chain between points aP0 and aP1 and following 45-degree routing regime.
Represent a polyline (an zero-thickness chain of connected line segments).

References DIRECTION_45::BuildInitialTrace(), and m_gateways.

Referenced by BuildGeneric().

◆ BuildForCursor()

void PNS::DP_GATEWAYS::BuildForCursor ( const VECTOR2I aCursorPos)

Definition at line 536 of file pns_diff_pair.cpp.

537 {
538  int gap = m_fitVias ? m_viaGap + m_viaDiameter : m_gap;
539 
540  for( int attempt = 0; attempt < 2; attempt++ )
541  {
542  for( int i = 0; i < 4; i++ )
543  {
544  VECTOR2I dir;
545 
546  if( !attempt )
547  {
548  dir = makeGapVector( VECTOR2I( gap, gap ), gap );
549 
550  if( i % 2 == 0 )
551  dir.x = -dir.x;
552 
553  if( i / 2 == 0 )
554  dir.y = -dir.y;
555  }
556  else
557  {
558  if( i /2 == 0 )
559  dir = VECTOR2I( (gap + 1) / 2 * ( ( i % 2 ) ? -1 : 1 ), 0 );
560  else
561  dir = VECTOR2I( 0, (gap + 1) / 2 * ( ( i % 2 ) ? -1 : 1) );
562  }
563 
564  if( m_fitVias )
565  BuildGeneric( aCursorPos + dir, aCursorPos - dir, true, true );
566  else
567  m_gateways.emplace_back( aCursorPos + dir, aCursorPos - dir,
568  attempt ? true : false );
569 
570  }
571  }
572 }
std::vector< DP_GATEWAY > m_gateways
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
static VECTOR2I makeGapVector(VECTOR2I dir, int length)
void BuildGeneric(const VECTOR2I &p0_p, const VECTOR2I &p0_n, bool aBuildEntries=false, bool aViaMode=false)

References BuildGeneric(), m_fitVias, m_gap, m_gateways, m_viaDiameter, m_viaGap, PNS::makeGapVector(), VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BuildOrthoProjections(), and PNS::DIFF_PAIR_PLACER::routeHead().

◆ BuildFromPrimitivePair()

void PNS::DP_GATEWAYS::BuildFromPrimitivePair ( const DP_PRIMITIVE_PAIR aPair,
bool  aPreferDiagonal 
)

Definition at line 425 of file pns_diff_pair.cpp.

426 {
427  VECTOR2I majorDirection;
428  VECTOR2I p0_p, p0_n;
429  int orthoFanDistance;
430  int diagFanDistance;
431  const SHAPE* shP = nullptr;
432 
433  if( aPair.PrimP() == nullptr )
434  {
435  BuildGeneric( aPair.AnchorP(), aPair.AnchorN(), true );
436  return;
437  }
438 
439  const int pvMask = ITEM::SOLID_T | ITEM::VIA_T;
440 
441  if( aPair.PrimP()->OfKind( pvMask ) && aPair.PrimN()->OfKind( pvMask ) )
442  {
443  p0_p = aPair.AnchorP();
444  p0_n = aPair.AnchorN();
445 
446  shP = aPair.PrimP()->Shape();
447  }
448  else if( aPair.PrimP()->OfKind( ITEM::SEGMENT_T ) && aPair.PrimN()->OfKind( ITEM::SEGMENT_T ) )
449  {
450  buildDpContinuation( aPair, aPreferDiagonal );
451 
452  return;
453  }
454 
455  majorDirection = ( p0_p - p0_n ).Perpendicular();
456 
457  if( shP == nullptr )
458  return;
459 
460  switch( shP->Type() )
461  {
462  case SH_RECT:
463  {
464  int w = static_cast<const SHAPE_RECT*>( shP )->GetWidth();
465  int h = static_cast<const SHAPE_RECT*>( shP )->GetHeight();
466 
467  if( w < h )
468  std::swap( w, h );
469 
470  orthoFanDistance = ( w + 1 )* 3 / 2;
471  diagFanDistance = ( w - h );
472  break;
473  }
474 
475  case SH_SEGMENT:
476  {
477  int w = static_cast<const SHAPE_SEGMENT*>( shP )->GetWidth();
478  SEG s = static_cast<const SHAPE_SEGMENT*>( shP )->GetSeg();
479 
480  orthoFanDistance = w + ( s.B - s.A ).EuclideanNorm();
481  diagFanDistance = ( s.B - s.A ).EuclideanNorm();
482  break;
483  }
484 
485  default:
486  BuildGeneric ( p0_p, p0_n, true );
487  return;
488  }
489 
490  if( checkDiagonalAlignment( p0_p, p0_n ) )
491  {
492  int padDist = ( p0_p - p0_n ).EuclideanNorm();
493 
494  for( int k = 0; k < 2; k++ )
495  {
496  VECTOR2I dir, dp, dv;
497 
498  if( k == 0 )
499  {
500  dir = makeGapVector( majorDirection, orthoFanDistance );
501  int d = ( padDist - m_gap );
502  dp = makeGapVector( dir, d );
503  dv = makeGapVector( p0_n - p0_p, d );
504  }
505  else
506  {
507  dir = makeGapVector( majorDirection, diagFanDistance );
508  int d = ( padDist - m_gap );
509  dp = makeGapVector( dir, d );
510  dv = makeGapVector( p0_n - p0_p, d );
511  }
512 
513  for( int i = 0; i < 2; i++ )
514  {
515  int sign = i ? -1 : 1;
516 
517  VECTOR2I gw_p( p0_p + sign * ( dir + dp ) + dv );
518  VECTOR2I gw_n( p0_n + sign * ( dir + dp ) - dv );
519 
520  SHAPE_LINE_CHAIN entryP( { p0_p, p0_p + sign * dir, gw_p } );
521  SHAPE_LINE_CHAIN entryN( { p0_n, p0_n + sign * dir, gw_n } );
522 
523  DP_GATEWAY gw( gw_p, gw_n, false );
524 
525  gw.SetEntryLines( entryP, entryN );
526  gw.SetPriority( 100 - k );
527  m_gateways.push_back( gw );
528  }
529  }
530  }
531 
532  BuildGeneric( p0_p, p0_n, true );
533 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
int sign(T val)
Definition: util.h:104
std::vector< DP_GATEWAY > m_gateways
void buildDpContinuation(const DP_PRIMITIVE_PAIR &aPair, bool aIsDiagonal)
An abstract shape on 2D plane.
Definition: shape.h:116
Definition: seg.h:40
static VECTOR2I makeGapVector(VECTOR2I dir, int length)
Represent a polyline (an zero-thickness chain of connected line segments).
VECTOR2I A
Definition: seg.h:48
axis-aligned rectangle
Definition: shape.h:43
void BuildGeneric(const VECTOR2I &p0_p, const VECTOR2I &p0_n, bool aBuildEntries=false, bool aViaMode=false)
SHAPE_TYPE Type() const
Return the type of the shape.
Definition: shape.h:94
bool checkDiagonalAlignment(const VECTOR2I &a, const VECTOR2I &b) const
line segment
Definition: shape.h:44
VECTOR2I B
Definition: seg.h:49

References SEG::A, PNS::DP_PRIMITIVE_PAIR::AnchorN(), PNS::DP_PRIMITIVE_PAIR::AnchorP(), SEG::B, buildDpContinuation(), BuildGeneric(), checkDiagonalAlignment(), EuclideanNorm(), m_gap, m_gateways, PNS::makeGapVector(), PNS::ITEM::OfKind(), PNS::DP_PRIMITIVE_PAIR::PrimN(), PNS::DP_PRIMITIVE_PAIR::PrimP(), PNS::ITEM::SEGMENT_T, SH_RECT, SH_SEGMENT, PNS::ITEM::Shape(), sign(), PNS::ITEM::SOLID_T, SHAPE_BASE::Type(), and PNS::ITEM::VIA_T.

Referenced by PNS::DIFF_PAIR_PLACER::routeHead().

◆ BuildGeneric()

void PNS::DP_GATEWAYS::BuildGeneric ( const VECTOR2I p0_p,
const VECTOR2I p0_n,
bool  aBuildEntries = false,
bool  aViaMode = false 
)

Definition at line 642 of file pns_diff_pair.cpp.

644 {
645  SEG st_p[2], st_n[2];
646  SEG d_n[2], d_p[2];
647 
648  const int padToGapThreshold = 3;
649  int padDist = ( p0_n - p0_p ).EuclideanNorm();
650 
651  st_p[0] = SEG(p0_p + VECTOR2I( -100, 0 ), p0_p + VECTOR2I( 100, 0 ) );
652  st_n[0] = SEG(p0_n + VECTOR2I( -100, 0 ), p0_n + VECTOR2I( 100, 0 ) );
653  st_p[1] = SEG(p0_p + VECTOR2I( 0, -100 ), p0_p + VECTOR2I( 0, 100 ) );
654  st_n[1] = SEG(p0_n + VECTOR2I( 0, -100 ), p0_n + VECTOR2I( 0, 100 ) );
655  d_p[0] = SEG( p0_p + VECTOR2I( -100, -100 ), p0_p + VECTOR2I( 100, 100 ) );
656  d_p[1] = SEG( p0_p + VECTOR2I( 100, -100 ), p0_p + VECTOR2I( -100, 100 ) );
657  d_n[0] = SEG( p0_n + VECTOR2I( -100, -100 ), p0_n + VECTOR2I( 100, 100 ) );
658  d_n[1] = SEG( p0_n + VECTOR2I( 100, -100 ), p0_n + VECTOR2I( -100, 100 ) );
659 
660  // midpoint exit & side-by exits
661  for( int i = 0; i < 2; i++ )
662  {
663  bool straightColl = st_p[i].Collinear( st_n[i] );
664  bool diagColl = d_p[i].Collinear( d_n[i] );
665 
666  if( straightColl || diagColl )
667  {
668  VECTOR2I dir = makeGapVector( p0_n - p0_p, m_gap / 2 );
669  VECTOR2I m = ( p0_p + p0_n ) / 2;
670  int prio = ( padDist > padToGapThreshold * m_gap ? 2 : 1);
671 
672  if( !aViaMode )
673  {
674  m_gateways.emplace_back( m - dir, m + dir, diagColl, DIRECTION_45::ANG_RIGHT,
675  prio );
676 
677  dir = makeGapVector( p0_n - p0_p, 2 * m_gap );
678  m_gateways.emplace_back( p0_p - dir, p0_p - dir + dir.Perpendicular(), diagColl );
679  m_gateways.emplace_back( p0_p - dir, p0_p - dir - dir.Perpendicular(), diagColl );
680  m_gateways.emplace_back( p0_n + dir + dir.Perpendicular(), p0_n + dir, diagColl );
681  m_gateways.emplace_back( p0_n + dir - dir.Perpendicular(), p0_n + dir, diagColl );
682  }
683  }
684  }
685 
686  for( int i = 0; i < 2; i++ )
687  {
688  for( int j = 0; j < 2; j++ )
689  {
690  OPT_VECTOR2I ips[2];
691 
692  ips[0] = d_n[i].IntersectLines( d_p[j] );
693  ips[1] = st_p[i].IntersectLines( st_n[j] );
694 
695  if( d_n[i].Collinear( d_p[j] ) )
696  ips[0] = OPT_VECTOR2I();
697 
698  if( st_p[i].Collinear( st_p[j] ) )
699  ips[1] = OPT_VECTOR2I();
700 
701  // diagonal-diagonal and straight-straight cases - the most typical case if the pads
702  // are on the same straight/diagonal line
703  for( int k = 0; k < 2; k++ )
704  {
705  if( ips[k] )
706  {
707  const VECTOR2I m( *ips[k] );
708 
709  if( m != p0_p && m != p0_n )
710  {
711  int prio = ( padDist > padToGapThreshold * m_gap ? 10 : 20 );
712  VECTOR2I g_p( ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
713  VECTOR2I g_n( ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
714 
715  m_gateways.emplace_back( m + g_p, m + g_n, k == 0 ? true : false,
716  DIRECTION_45::ANG_OBTUSE, prio );
717  }
718  }
719  }
720 
721  ips[0] = st_n[i].IntersectLines( d_p[j] );
722  ips[1] = st_p[i].IntersectLines( d_n[j] );
723 
724 // diagonal-straight cases: 8 possibilities of "weirder" exists
725  for( int k = 0; k < 2; k++ )
726  {
727  if( ips[k] )
728  {
729  const VECTOR2I m( *ips[k] );
730 
731  if( !aViaMode && m != p0_p && m != p0_n )
732  {
733  VECTOR2I g_p, g_n;
734 
735  g_p = ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT2 ) );
736  g_n = ( p0_n - m ).Resize( ceil( (double) m_gap ) );
737 
738  if( angle( g_p, g_n ) != DIRECTION_45::ANG_ACUTE )
739  m_gateways.emplace_back( m + g_p, m + g_n, true );
740 
741  g_p = ( p0_p - m ).Resize( m_gap );
742  g_n = ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT2 ) );
743 
744  if( angle( g_p, g_n ) != DIRECTION_45::ANG_ACUTE )
745  m_gateways.emplace_back( m + g_p, m + g_n, true );
746  }
747  }
748  }
749  }
750  }
751 
752  if( aBuildEntries )
753  buildEntries( p0_p, p0_n );
754 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
void buildEntries(const VECTOR2I &p0_p, const VECTOR2I &p0_n)
VECTOR2< T > Perpendicular() const
Compute the perpendicular vector.
Definition: vector2d.h:314
std::vector< DP_GATEWAY > m_gateways
OPT_VECTOR2I IntersectLines(const SEG &aSeg) const
Compute the intersection point of lines passing through ends of (this) and aSeg.
Definition: seg.h:209
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:38
bool Collinear(const SEG &aSeg) const
Check if segment aSeg lies on the same line as (this).
Definition: seg.h:268
Definition: seg.h:40
static VECTOR2I makeGapVector(VECTOR2I dir, int length)
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)

References DIRECTION_45::ANG_ACUTE, DIRECTION_45::ANG_OBTUSE, DIRECTION_45::ANG_RIGHT, PNS::angle(), buildEntries(), SEG::Collinear(), EuclideanNorm(), SEG::IntersectLines(), m_gap, m_gateways, PNS::makeGapVector(), and VECTOR2< T >::Perpendicular().

Referenced by BuildForCursor(), and BuildFromPrimitivePair().

◆ BuildOrthoProjections()

void PNS::DP_GATEWAYS::BuildOrthoProjections ( DP_GATEWAYS aEntries,
const VECTOR2I aCursorPos,
int  aOrthoScore 
)

Definition at line 304 of file pns_diff_pair.cpp.

306 {
307  for( const DP_GATEWAY& g : aEntries.Gateways() )
308  {
309  VECTOR2I midpoint( ( g.AnchorP() + g.AnchorN() ) / 2 );
310  SEG guide_s( midpoint, midpoint + VECTOR2I( 1, 0 ) );
311  SEG guide_d( midpoint, midpoint + VECTOR2I( 1, 1 ) );
312 
313  VECTOR2I proj_s = guide_s.LineProject( aCursorPos );
314  VECTOR2I proj_d = guide_d.LineProject( aCursorPos );
315 
316  int dist_s = ( proj_s - aCursorPos ).EuclideanNorm();
317  int dist_d = ( proj_d - aCursorPos ).EuclideanNorm();
318 
319  VECTOR2I proj = ( dist_s < dist_d ? proj_s : proj_d );
320 
321  DP_GATEWAYS targets( m_gap );
322 
323  targets.m_viaGap = m_viaGap;
324  targets.m_viaDiameter = m_viaDiameter;
325  targets.m_fitVias = m_fitVias;
326 
327  targets.BuildForCursor( proj );
328 
329  for( DP_GATEWAY t : targets.Gateways() )
330  {
331  t.SetPriority( aOrthoScore );
332  m_gateways.push_back( t );
333  }
334  }
335 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:146
std::vector< DP_GATEWAY > m_gateways
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
DP_GATEWAYS(int aGap)
Definition: seg.h:40

References BuildForCursor(), EuclideanNorm(), Gateways(), SEG::LineProject(), m_fitVias, m_gap, m_gateways, m_viaDiameter, and m_viaGap.

◆ CGateways()

const std::vector<DP_GATEWAY>& PNS::DP_GATEWAYS::CGateways ( ) const
inline

Definition at line 205 of file pns_diff_pair.h.

205 { return m_gateways; }
std::vector< DP_GATEWAY > m_gateways

References m_gateways.

◆ checkDiagonalAlignment()

bool PNS::DP_GATEWAYS::checkDiagonalAlignment ( const VECTOR2I a,
const VECTOR2I b 
) const
private

Definition at line 388 of file pns_diff_pair.cpp.

389 {
390  VECTOR2I dir( std::abs (a.x - b.x), std::abs ( a.y - b.y ) );
391 
392  return (dir.x == 0 && dir.y != 0) || (dir.x == dir.y) || (dir.y == 0 && dir.x != 0);
393 }

References VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by BuildFromPrimitivePair().

◆ Clear()

void PNS::DP_GATEWAYS::Clear ( )
inline

Definition at line 179 of file pns_diff_pair.h.

179 { m_gateways.clear(); }
std::vector< DP_GATEWAY > m_gateways

References m_gateways.

◆ FilterByOrientation()

void PNS::DP_GATEWAYS::FilterByOrientation ( int  aAngleMask,
DIRECTION_45  aRefOrientation 
)

Definition at line 396 of file pns_diff_pair.cpp.

397 {
398  m_gateways.erase(
399  std::remove_if( m_gateways.begin(), m_gateways.end(),
400  [aAngleMask, aRefOrientation]( const DP_GATEWAY& dp)
401  {
402  DIRECTION_45 orient( dp.AnchorP() - dp.AnchorN() );
403  return ( orient.Angle( aRefOrientation ) & aAngleMask );
404  } ), m_gateways.end()
405  );
406 }
std::vector< DP_GATEWAY > m_gateways
Represent route directions & corner angles in a 45-degree metric.
Definition: direction45.h:36

References m_gateways.

Referenced by PNS::DIFF_PAIR_PLACER::routeHead().

◆ FitGateways()

bool PNS::DP_GATEWAYS::FitGateways ( DP_GATEWAYS aEntry,
DP_GATEWAYS aTarget,
bool  aPrefDiagonal,
DIFF_PAIR aDp 
)

Definition at line 338 of file pns_diff_pair.cpp.

340 {
341  DP_CANDIDATE best;
342 
343  int n = 0;
344  int bestScore = -1000;
345  bool found = false;
346 
347  for( const DP_GATEWAY& g_entry : aEntry.Gateways() )
348  {
349  for( const DP_GATEWAY& g_target : aTarget.Gateways() )
350  {
351  n++;
352 
353  for( int attempt = 0; attempt < 2; attempt++ )
354  {
355  int score = ( attempt == 1 ? -3 : 0 );
356  score += g_entry.Priority();
357  score += g_target.Priority();
358 
359  if( score < bestScore )
360  continue;
361 
362  DIFF_PAIR l( m_gap );
363 
364  if( l.BuildInitial( g_entry, g_target,
365  aPrefDiagonal ^ ( attempt ? true : false ) ) )
366  {
367  best.p = l.CP();
368  best.n = l.CN();
369  bestScore = score;
370  found = true;
371  }
372  }
373  }
374  }
375 
376 
377  if( found )
378  {
379  aDp.SetGap( m_gap );
380  aDp.SetShape( best.p, best.n );
381  return true;
382  }
383 
384  return false;
385 }

References PNS::DIFF_PAIR::BuildInitial(), PNS::DIFF_PAIR::CN(), PNS::DIFF_PAIR::CP(), Gateways(), m_gap, PNS::DP_GATEWAYS::DP_CANDIDATE::n, PNS::DP_GATEWAYS::DP_CANDIDATE::p, PNS::DIFF_PAIR::SetGap(), and PNS::DIFF_PAIR::SetShape().

Referenced by PNS::DIFF_PAIR_PLACER::routeHead().

◆ Gateways()

std::vector<DP_GATEWAY>& PNS::DP_GATEWAYS::Gateways ( )
inline

Definition at line 203 of file pns_diff_pair.h.

203 { return m_gateways; }
std::vector< DP_GATEWAY > m_gateways

References m_gateways.

Referenced by BuildOrthoProjections(), and FitGateways().

◆ SetFitVias()

void PNS::DP_GATEWAYS::SetFitVias ( bool  aEnable,
int  aDiameter = 0,
int  aViaGap = -1 
)
inline

Definition at line 181 of file pns_diff_pair.h.

182  {
183  m_fitVias = aEnable;
184  m_viaDiameter = aDiameter;
185 
186  if( aViaGap < 0 )
187  m_viaGap = m_gap;
188  else
189  m_viaGap = aViaGap;
190  }

References m_fitVias, m_gap, m_viaDiameter, and m_viaGap.

Referenced by PNS::DIFF_PAIR_PLACER::routeHead().

Member Data Documentation

◆ m_fitVias

bool PNS::DP_GATEWAYS::m_fitVias
private

Definition at line 224 of file pns_diff_pair.h.

Referenced by BuildForCursor(), BuildOrthoProjections(), DP_GATEWAYS(), and SetFitVias().

◆ m_gap

int PNS::DP_GATEWAYS::m_gap
private

◆ m_gateways

◆ m_viaDiameter

int PNS::DP_GATEWAYS::m_viaDiameter
private

Definition at line 223 of file pns_diff_pair.h.

Referenced by BuildForCursor(), BuildOrthoProjections(), DP_GATEWAYS(), and SetFitVias().

◆ m_viaGap

int PNS::DP_GATEWAYS::m_viaGap
private

Definition at line 222 of file pns_diff_pair.h.

Referenced by BuildForCursor(), BuildOrthoProjections(), and SetFitVias().


The documentation for this class was generated from the following files: