KiCad PCB EDA Suite
PNS::DP_GATEWAYS Class Reference

DP_GATEWAYS. 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

DP_GATEWAYS.

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

Definition at line 184 of file pns_diff_pair.h.

Constructor & Destructor Documentation

◆ DP_GATEWAYS()

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

Definition at line 187 of file pns_diff_pair.h.

187  :
188  m_gap( aGap ),
189  m_viaGap( aGap )
190  {
191  // Do not leave unitialized members, and keep static analyser quiet:
192  m_viaDiameter = 0;
193  m_fitVias = true;
194  }

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 580 of file pns_diff_pair.cpp.

581 {
582  DP_GATEWAY gw( aPair.AnchorP(), aPair.AnchorN(), aIsDiagonal );
583  gw.SetPriority( 100 );
584  m_gateways.push_back( gw );
585 
586  if( !aPair.Directional() )
587  return;
588 
589  DIRECTION_45 dP = aPair.DirP();
590  DIRECTION_45 dN = aPair.DirN();
591 
592  int gap = ( aPair.AnchorP() - aPair.AnchorN() ).EuclideanNorm();
593 
594  VECTOR2I vdP = aPair.AnchorP() + dP.Left().ToVector();
595  VECTOR2I vdN = aPair.AnchorN() + dN.Left().ToVector();
596 
597  SEGMENT* sP = static_cast<SEGMENT*>( aPair.PrimP() );
598 
599  VECTOR2I t1, t2;
600 
601  auto vL = makeGapVector( dP.Left().ToVector(), ( gap + 1 ) / 2 );
602  auto vR = makeGapVector( dP.Right().ToVector(), ( gap + 1 ) / 2 );
603 
604  if( sP->Seg().Side( vdP ) == sP->Seg().Side( vdN ) )
605  {
606  t1 = aPair.AnchorP() + vL;
607  t2 = aPair.AnchorN() + vR;
608  }
609  else
610  {
611  t1 = aPair.AnchorP() + vR;
612  t2 = aPair.AnchorN() + vL;
613  }
614 
615  DP_GATEWAY gwL( t2, aPair.AnchorN(), !aIsDiagonal );
616  SHAPE_LINE_CHAIN ep = dP.BuildInitialTrace( aPair.AnchorP(), t2, !aIsDiagonal );
617  gwL.SetPriority( 10 );
618  gwL.SetEntryLines( ep , SHAPE_LINE_CHAIN() );
619 
620  m_gateways.push_back( gwL );
621 
622  DP_GATEWAY gwR( aPair.AnchorP(), t1, !aIsDiagonal );
623  SHAPE_LINE_CHAIN en = dP.BuildInitialTrace( aPair.AnchorN(), t1, !aIsDiagonal );
624  gwR.SetPriority( 10) ;
625  gwR.SetEntryLines( SHAPE_LINE_CHAIN(), en );
626 
627  m_gateways.push_back( gwR );
628 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
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)
SHAPE_LINE_CHAIN.
usual segment : line with rounded ends

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 566 of file pns_diff_pair.cpp.

567 {
568  for( DP_GATEWAY &g : m_gateways )
569  {
570  if( !g.HasEntryLines() )
571  {
572  SHAPE_LINE_CHAIN lead_p = DIRECTION_45().BuildInitialTrace ( g.AnchorP(), p0_p, g.IsDiagonal() ).Reverse();
573  SHAPE_LINE_CHAIN lead_n = DIRECTION_45().BuildInitialTrace ( g.AnchorN(), p0_n, g.IsDiagonal() ).Reverse();
574  g.SetEntryLines( lead_p, lead_n );
575  }
576  }
577 }
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.
SHAPE_LINE_CHAIN.

References DIRECTION_45::BuildInitialTrace(), and m_gateways.

Referenced by BuildGeneric().

◆ BuildForCursor()

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

Definition at line 527 of file pns_diff_pair.cpp.

528 {
529  int gap = m_fitVias ? m_viaGap + m_viaDiameter : m_gap;
530 
531  for( int attempt = 0; attempt < 2; attempt++ )
532  {
533  for( int i = 0; i < 4; i++ )
534  {
535  VECTOR2I dir;
536 
537  if( !attempt )
538  {
539  dir = makeGapVector( VECTOR2I( gap, gap ), gap );
540 
541  if( i % 2 == 0 )
542  dir.x = -dir.x;
543 
544  if( i / 2 == 0 )
545  dir.y = -dir.y;
546  }
547  else
548  {
549  if( i /2 == 0 )
550  dir = VECTOR2I( (gap + 1) / 2 * ( ( i % 2 ) ? -1 : 1 ), 0 );
551  else
552  dir = VECTOR2I( 0, (gap + 1) / 2 * ( ( i % 2 ) ? -1 : 1) );
553  }
554 
555  if( m_fitVias )
556  BuildGeneric( aCursorPos + dir, aCursorPos - dir, true, true );
557  else
558  m_gateways.emplace_back( aCursorPos + dir,
559  aCursorPos - dir, attempt ? true : false );
560 
561  }
562  }
563 }
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 416 of file pns_diff_pair.cpp.

417 {
418  VECTOR2I majorDirection;
419  VECTOR2I p0_p, p0_n;
420  int orthoFanDistance;
421  int diagFanDistance;
422  const SHAPE* shP = NULL;
423 
424  if( aPair.PrimP() == NULL )
425  {
426  BuildGeneric( aPair.AnchorP(), aPair.AnchorN(), true );
427  return;
428  }
429 
430  const int pvMask = ITEM::SOLID_T | ITEM::VIA_T;
431 
432  if( aPair.PrimP()->OfKind( pvMask ) && aPair.PrimN()->OfKind( pvMask ) )
433  {
434  p0_p = aPair.AnchorP();
435  p0_n = aPair.AnchorN();
436 
437  shP = aPair.PrimP()->Shape();
438  }
439  else if( aPair.PrimP()->OfKind( ITEM::SEGMENT_T ) && aPair.PrimN()->OfKind( ITEM::SEGMENT_T ) )
440  {
441  buildDpContinuation( aPair, aPreferDiagonal );
442 
443  return;
444  }
445 
446  majorDirection = ( p0_p - p0_n ).Perpendicular();
447 
448  if( shP == NULL )
449  return;
450 
451  switch( shP->Type() )
452  {
453  case SH_RECT:
454  {
455  int w = static_cast<const SHAPE_RECT*>( shP )->GetWidth();
456  int h = static_cast<const SHAPE_RECT*>( shP )->GetHeight();
457 
458  if( w < h )
459  std::swap( w, h );
460 
461  orthoFanDistance = ( w + 1 )* 3 / 2;
462  diagFanDistance = ( w - h );
463  break;
464  }
465 
466  case SH_SEGMENT:
467  {
468  int w = static_cast<const SHAPE_SEGMENT*>( shP )->GetWidth();
469  SEG s = static_cast<const SHAPE_SEGMENT*>( shP )->GetSeg();
470 
471  orthoFanDistance = w + ( s.B - s.A ).EuclideanNorm();
472  diagFanDistance = ( s.B - s.A ).EuclideanNorm();
473  break;
474  }
475 
476  default:
477  BuildGeneric ( p0_p, p0_n, true );
478  return;
479  }
480 
481  if( checkDiagonalAlignment( p0_p, p0_n ) )
482  {
483  int padDist = ( p0_p - p0_n ).EuclideanNorm();
484 
485  for( int k = 0; k < 2; k++ )
486  {
487  VECTOR2I dir, dp, dv;
488 
489  if( k == 0 )
490  {
491  dir = makeGapVector( majorDirection, orthoFanDistance );
492  int d = ( padDist - m_gap );
493  dp = makeGapVector( dir, d );
494  dv = makeGapVector( p0_n - p0_p, d );
495  }
496  else
497  {
498  dir = makeGapVector( majorDirection, diagFanDistance );
499  int d = ( padDist - m_gap );
500  dp = makeGapVector( dir, d );
501  dv = makeGapVector( p0_n - p0_p, d );
502  }
503 
504  for( int i = 0; i < 2; i++ )
505  {
506  int sign = i ? -1 : 1;
507 
508  VECTOR2I gw_p( p0_p + sign * ( dir + dp ) + dv );
509  VECTOR2I gw_n( p0_n + sign * ( dir + dp ) - dv );
510 
511  SHAPE_LINE_CHAIN entryP( { p0_p, p0_p + sign * dir, gw_p } );
512  SHAPE_LINE_CHAIN entryN( { p0_n, p0_n + sign * dir, gw_n } );
513 
514  DP_GATEWAY gw( gw_p, gw_n, false );
515 
516  gw.SetEntryLines( entryP, entryN );
517  gw.SetPriority( 100 - k );
518  m_gateways.push_back( gw );
519  }
520  }
521  }
522 
523  BuildGeneric( p0_p, p0_n, true );
524 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
int sign(T val)
Definition: util.h:101
std::vector< DP_GATEWAY > m_gateways
void buildDpContinuation(const DP_PRIMITIVE_PAIR &aPair, bool aIsDiagonal)
#define NULL
An abstract shape on 2D plane.
Definition: shape.h:116
Definition: seg.h:41
static VECTOR2I makeGapVector(VECTOR2I dir, int length)
SHAPE_LINE_CHAIN.
VECTOR2I A
Definition: seg.h:49
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:50

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(), NULL, 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 631 of file pns_diff_pair.cpp.

632 {
633  SEG st_p[2], st_n[2];
634  SEG d_n[2], d_p[2];
635 
636  const int padToGapThreshold = 3;
637  int padDist = ( p0_n - p0_p ).EuclideanNorm();
638 
639  st_p[0] = SEG(p0_p + VECTOR2I( -100, 0 ), p0_p + VECTOR2I( 100, 0 ) );
640  st_n[0] = SEG(p0_n + VECTOR2I( -100, 0 ), p0_n + VECTOR2I( 100, 0 ) );
641  st_p[1] = SEG(p0_p + VECTOR2I( 0, -100 ), p0_p + VECTOR2I( 0, 100 ) );
642  st_n[1] = SEG(p0_n + VECTOR2I( 0, -100 ), p0_n + VECTOR2I( 0, 100 ) );
643  d_p[0] = SEG( p0_p + VECTOR2I( -100, -100 ), p0_p + VECTOR2I( 100, 100 ) );
644  d_p[1] = SEG( p0_p + VECTOR2I( 100, -100 ), p0_p + VECTOR2I( -100, 100 ) );
645  d_n[0] = SEG( p0_n + VECTOR2I( -100, -100 ), p0_n + VECTOR2I( 100, 100 ) );
646  d_n[1] = SEG( p0_n + VECTOR2I( 100, -100 ), p0_n + VECTOR2I( -100, 100 ) );
647 
648  // midpoint exit & side-by exits
649  for( int i = 0; i < 2; i++ )
650  {
651  bool straightColl = st_p[i].Collinear( st_n[i] );
652  bool diagColl = d_p[i].Collinear( d_n[i] );
653 
654  if( straightColl || diagColl )
655  {
656  VECTOR2I dir = makeGapVector( p0_n - p0_p, m_gap / 2 );
657  VECTOR2I m = ( p0_p + p0_n ) / 2;
658  int prio = ( padDist > padToGapThreshold * m_gap ? 2 : 1);
659 
660  if( !aViaMode )
661  {
662  m_gateways.emplace_back( m - dir, m + dir, diagColl, DIRECTION_45::ANG_RIGHT, prio );
663 
664  dir = makeGapVector( p0_n - p0_p, 2 * m_gap );
665  m_gateways.emplace_back( p0_p - dir, p0_p - dir + dir.Perpendicular(), diagColl );
666  m_gateways.emplace_back( p0_p - dir, p0_p - dir - dir.Perpendicular(), diagColl );
667  m_gateways.emplace_back( p0_n + dir + dir.Perpendicular(), p0_n + dir, diagColl );
668  m_gateways.emplace_back( p0_n + dir - dir.Perpendicular(), p0_n + dir, diagColl );
669  }
670  }
671  }
672 
673  for( int i = 0; i < 2; i++ )
674  {
675  for( int j = 0; j < 2; j++ )
676  {
677  OPT_VECTOR2I ips[2];
678 
679  ips[0] = d_n[i].IntersectLines( d_p[j] );
680  ips[1] = st_p[i].IntersectLines( st_n[j] );
681 
682  if( d_n[i].Collinear( d_p[j] ) )
683  ips[0] = OPT_VECTOR2I();
684  if( st_p[i].Collinear( st_p[j] ) )
685  ips[1] = OPT_VECTOR2I();
686 
687  // diagonal-diagonal and straight-straight cases - the most typical case if the pads
688  // are on the same straight/diagonal line
689  for( int k = 0; k < 2; k++ )
690  {
691  if( ips[k] )
692  {
693  const VECTOR2I m( *ips[k] );
694 
695  if( m != p0_p && m != p0_n )
696  {
697  int prio = ( padDist > padToGapThreshold * m_gap ? 10 : 20 );
698  VECTOR2I g_p( ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
699  VECTOR2I g_n( ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
700 
701  m_gateways.emplace_back( m + g_p, m + g_n, k == 0 ? true : false, DIRECTION_45::ANG_OBTUSE, prio );
702  }
703  }
704  }
705 
706  ips[0] = st_n[i].IntersectLines( d_p[j] );
707  ips[1] = st_p[i].IntersectLines( d_n[j] );
708 
709 // diagonal-straight cases: 8 possibilities of "weirder" exists
710  for( int k = 0; k < 2; k++ )
711  {
712  if( ips[k] )
713  {
714  const VECTOR2I m( *ips[k] );
715 
716  if( !aViaMode && m != p0_p && m != p0_n )
717  {
718  VECTOR2I g_p, g_n;
719 
720  g_p = ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT2 ) );
721  g_n = ( p0_n - m ).Resize( ceil( (double) m_gap ) );
722 
723  if( angle( g_p, g_n ) != DIRECTION_45::ANG_ACUTE )
724  m_gateways.emplace_back( m + g_p, m + g_n, true );
725 
726  g_p = ( p0_p - m ).Resize( m_gap );
727  g_n = ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT2 ) );
728 
729  if( angle( g_p, g_n ) != DIRECTION_45::ANG_ACUTE )
730  m_gateways.emplace_back( m + g_p, m + g_n, true );
731  }
732  }
733  }
734  }
735  }
736 
737  if( aBuildEntries )
738  buildEntries( p0_p, p0_n );
739 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:148
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:208
VECTOR2< int > VECTOR2I
Definition: vector2d.h:623
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:39
bool Collinear(const SEG &aSeg) const
Check if segment aSeg lies on the same line as (this).
Definition: seg.h:273
Definition: seg.h:41
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 297 of file pns_diff_pair.cpp.

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

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 225 of file pns_diff_pair.h.

226  {
227  return m_gateways;
228  }
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 381 of file pns_diff_pair.cpp.

382 {
383  VECTOR2I dir( std::abs (a.x - b.x), std::abs ( a.y - b.y ) );
384 
385  return (dir.x == 0 && dir.y != 0) || (dir.x == dir.y) || (dir.y == 0 && dir.x != 0);
386 }

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

Referenced by BuildFromPrimitivePair().

◆ Clear()

void PNS::DP_GATEWAYS::Clear ( )
inline

Definition at line 196 of file pns_diff_pair.h.

197  {
198  m_gateways.clear();
199  }
std::vector< DP_GATEWAY > m_gateways

References m_gateways.

◆ FilterByOrientation()

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

Definition at line 389 of file pns_diff_pair.cpp.

390 {
391  m_gateways.erase(
392  std::remove_if( m_gateways.begin(), m_gateways.end(), [aAngleMask, aRefOrientation]( const DP_GATEWAY& dp) {
393  DIRECTION_45 orient( dp.AnchorP() - dp.AnchorN() );
394  return ( orient.Angle( aRefOrientation ) & aAngleMask );
395  } ), m_gateways.end()
396  );
397 }
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 332 of file pns_diff_pair.cpp.

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

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 220 of file pns_diff_pair.h.

221  {
222  return m_gateways;
223  }
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 201 of file pns_diff_pair.h.

202  {
203  m_fitVias = aEnable;
204  m_viaDiameter = aDiameter;
205 
206  if( aViaGap < 0 )
207  m_viaGap = m_gap;
208  else
209  m_viaGap = aViaGap;
210  }

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 247 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 246 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 245 of file pns_diff_pair.h.

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


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