KiCad PCB EDA Suite
PNS::DP_GATEWAYS Class Reference

Class DP_GATEWAYS. More...

#include <pns_diff_pair.h>

Classes

struct  DP_CANDIDATE
 

Public Member Functions

 DP_GATEWAYS (int aGap)
 
void SetGap (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 (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 (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

Class DP_GATEWAYS.

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

Definition at line 186 of file pns_diff_pair.h.

Constructor & Destructor Documentation

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

Definition at line 189 of file pns_diff_pair.h.

References m_fitVias, and m_viaDiameter.

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

Member Function Documentation

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

Definition at line 590 of file pns_diff_pair.cpp.

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().

591 {
592  DP_GATEWAY gw( aPair.AnchorP(), aPair.AnchorN(), aIsDiagonal );
593  gw.SetPriority( 100 );
594  m_gateways.push_back( gw );
595 
596  if( !aPair.Directional() )
597  return;
598 
599  DIRECTION_45 dP = aPair.DirP();
600  DIRECTION_45 dN = aPair.DirN();
601 
602  int gap = ( aPair.AnchorP() - aPair.AnchorN() ).EuclideanNorm();
603 
604  VECTOR2I vdP = aPair.AnchorP() + dP.Left().ToVector();
605  VECTOR2I vdN = aPair.AnchorN() + dN.Left().ToVector();
606 
607  SEGMENT* sP = static_cast<SEGMENT*>( aPair.PrimP() );
608 
609  VECTOR2I t1, t2;
610 
611  auto vL = makeGapVector( dP.Left().ToVector(), ( gap + 1 ) / 2 );
612  auto vR = makeGapVector( dP.Right().ToVector(), ( gap + 1 ) / 2 );
613 
614  if( sP->Seg().Side( vdP ) == sP->Seg().Side( vdN ) )
615  {
616  t1 = aPair.AnchorP() + vL;
617  t2 = aPair.AnchorN() + vR;
618  }
619  else
620  {
621  t1 = aPair.AnchorP() + vR;
622  t2 = aPair.AnchorN() + vL;
623  }
624 
625  DP_GATEWAY gwL( t2, aPair.AnchorN(), !aIsDiagonal );
626  SHAPE_LINE_CHAIN ep = dP.BuildInitialTrace( aPair.AnchorP(), t2, !aIsDiagonal );
627  gwL.SetPriority( 10 );
628  gwL.SetEntryLines( ep , SHAPE_LINE_CHAIN() );
629 
630  m_gateways.push_back( gwL );
631 
632  DP_GATEWAY gwR( aPair.AnchorP(), t1, !aIsDiagonal );
633  SHAPE_LINE_CHAIN en = dP.BuildInitialTrace( aPair.AnchorN(), t1, !aIsDiagonal );
634  gwR.SetPriority( 10) ;
635  gwR.SetEntryLines( SHAPE_LINE_CHAIN(), en );
636 
637  m_gateways.push_back( gwR );
638 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:104
const VECTOR2I ToVector() const
Function ToVector()
Definition: direction45.h:295
std::vector< DP_GATEWAY > m_gateways
const DIRECTION_45 Left() const
Function Left()
Definition: direction45.h:275
Class DIRECTION_45.
Definition: direction45.h:33
static VECTOR2I makeGapVector(VECTOR2I dir, int length)
Class SHAPE_LINE_CHAIN.
const DIRECTION_45 Right() const
Function Right()
Definition: direction45.h:259
Struct SEGMENT is a simple container used when filling areas with segments.
Definition: class_zone.h:57
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false) const
Function BuildInitialTrace()
Definition: direction45.h:199
void PNS::DP_GATEWAYS::buildEntries ( const VECTOR2I p0_p,
const VECTOR2I p0_n 
)
private

Definition at line 576 of file pns_diff_pair.cpp.

References DIRECTION_45::BuildInitialTrace(), and m_gateways.

Referenced by BuildGeneric().

577 {
578  for( DP_GATEWAY &g : m_gateways )
579  {
580  if( !g.HasEntryLines() )
581  {
582  SHAPE_LINE_CHAIN lead_p = DIRECTION_45().BuildInitialTrace ( g.AnchorP(), p0_p, g.IsDiagonal() ).Reverse();
583  SHAPE_LINE_CHAIN lead_n = DIRECTION_45().BuildInitialTrace ( g.AnchorN(), p0_n, g.IsDiagonal() ).Reverse();
584  g.SetEntryLines( lead_p, lead_n );
585  }
586  }
587 }
std::vector< DP_GATEWAY > m_gateways
Class DIRECTION_45.
Definition: direction45.h:33
Class SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN BuildInitialTrace(const VECTOR2I &aP0, const VECTOR2I &aP1, bool aStartDiagonal=false) const
Function BuildInitialTrace()
Definition: direction45.h:199
void PNS::DP_GATEWAYS::BuildForCursor ( const VECTOR2I aCursorPos)

Definition at line 537 of file pns_diff_pair.cpp.

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().

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

Definition at line 426 of file pns_diff_pair.cpp.

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, PNS::DP_GATEWAY::SetEntryLines(), PNS::DP_GATEWAY::SetPriority(), SH_RECT, SH_SEGMENT, PNS::ITEM::Shape(), sign(), PNS::ITEM::SOLID_T, SHAPE::Type(), and PNS::ITEM::VIA_T.

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

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

Definition at line 641 of file pns_diff_pair.cpp.

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().

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

Definition at line 309 of file pns_diff_pair.cpp.

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

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

Definition at line 231 of file pns_diff_pair.h.

References m_gateways.

232  {
233  return m_gateways;
234  }
std::vector< DP_GATEWAY > m_gateways
bool PNS::DP_GATEWAYS::checkDiagonalAlignment ( const VECTOR2I a,
const VECTOR2I b 
) const
private

Definition at line 393 of file pns_diff_pair.cpp.

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

Referenced by BuildFromPrimitivePair().

394 {
395  VECTOR2I dir ( std::abs (a.x - b.x), std::abs ( a.y - b.y ));
396 
397  return (dir.x == 0 && dir.y != 0) || (dir.x == dir.y) || (dir.y == 0 && dir.x != 0);
398 }
#define abs(a)
Definition: auxiliary.h:84
void PNS::DP_GATEWAYS::Clear ( )
inline

Definition at line 203 of file pns_diff_pair.h.

References m_gateways.

204  {
205  m_gateways.clear();
206  }
std::vector< DP_GATEWAY > m_gateways
void PNS::DP_GATEWAYS::FilterByOrientation ( int  aAngleMask,
DIRECTION_45  aRefOrientation 
)

Definition at line 401 of file pns_diff_pair.cpp.

References m_gateways.

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

402 {
403  std::remove_if( m_gateways.begin(), m_gateways.end(), [aAngleMask, aRefOrientation]( const DP_GATEWAY& dp) {
404  DIRECTION_45 orient( dp.AnchorP() - dp.AnchorN() );
405  return !( orient.Angle( aRefOrientation ) & aAngleMask );
406  } );
407 }
std::vector< DP_GATEWAY > m_gateways
Class DIRECTION_45.
Definition: direction45.h:33
bool PNS::DP_GATEWAYS::FitGateways ( DP_GATEWAYS aEntry,
DP_GATEWAYS aTarget,
bool  aPrefDiagonal,
DIFF_PAIR aDp 
)

Definition at line 344 of file pns_diff_pair.cpp.

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().

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

Definition at line 226 of file pns_diff_pair.h.

References m_gateways.

Referenced by BuildOrthoProjections(), and FitGateways().

227  {
228  return m_gateways;
229  }
std::vector< DP_GATEWAY > m_gateways
void PNS::DP_GATEWAYS::SetFitVias ( bool  aEnable,
int  aDiameter = 0,
int  aViaGap = -1 
)
inline

Definition at line 208 of file pns_diff_pair.h.

References m_fitVias, m_gap, m_viaDiameter, and m_viaGap.

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

209  {
210  m_fitVias = aEnable;
211  m_viaDiameter = aDiameter;
212  if(aViaGap < 0)
213  m_viaGap = m_gap;
214  else
215  m_viaGap = aViaGap;
216  }
void PNS::DP_GATEWAYS::SetGap ( int  aGap)
inline

Definition at line 197 of file pns_diff_pair.h.

References m_gap, and m_viaGap.

198  {
199  m_gap = aGap;
200  m_viaGap = aGap;
201  }

Member Data Documentation

bool PNS::DP_GATEWAYS::m_fitVias
private

Definition at line 253 of file pns_diff_pair.h.

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

int PNS::DP_GATEWAYS::m_gap
private
int PNS::DP_GATEWAYS::m_viaDiameter
private

Definition at line 252 of file pns_diff_pair.h.

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

int PNS::DP_GATEWAYS::m_viaGap
private

Definition at line 251 of file pns_diff_pair.h.

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


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