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

587 {
588  DP_GATEWAY gw( aPair.AnchorP(), aPair.AnchorN(), aIsDiagonal );
589  gw.SetPriority( 100 );
590  m_gateways.push_back( gw );
591 
592  if( !aPair.Directional() )
593  return;
594 
595  DIRECTION_45 dP = aPair.DirP();
596  DIRECTION_45 dN = aPair.DirN();
597 
598  int gap = ( aPair.AnchorP() - aPair.AnchorN() ).EuclideanNorm();
599 
600  VECTOR2I vdP = aPair.AnchorP() + dP.Left().ToVector();
601  VECTOR2I vdN = aPair.AnchorN() + dN.Left().ToVector();
602 
603  SEGMENT* sP = static_cast<SEGMENT*>( aPair.PrimP() );
604 
605  VECTOR2I t1, t2;
606 
607  auto vL = makeGapVector( dP.Left().ToVector(), ( gap + 1 ) / 2 );
608  auto vR = makeGapVector( dP.Right().ToVector(), ( gap + 1 ) / 2 );
609 
610  if( sP->Seg().Side( vdP ) == sP->Seg().Side( vdN ) )
611  {
612  t1 = aPair.AnchorP() + vL;
613  t2 = aPair.AnchorN() + vR;
614  }
615  else
616  {
617  t1 = aPair.AnchorP() + vR;
618  t2 = aPair.AnchorN() + vL;
619  }
620 
621  DP_GATEWAY gwL( t2, aPair.AnchorN(), !aIsDiagonal );
622  SHAPE_LINE_CHAIN ep = dP.BuildInitialTrace( aPair.AnchorP(), t2, !aIsDiagonal );
623  gwL.SetPriority( 10 );
624  gwL.SetEntryLines( ep , SHAPE_LINE_CHAIN() );
625 
626  m_gateways.push_back( gwL );
627 
628  DP_GATEWAY gwR( aPair.AnchorP(), t1, !aIsDiagonal );
629  SHAPE_LINE_CHAIN en = dP.BuildInitialTrace( aPair.AnchorN(), t1, !aIsDiagonal );
630  gwR.SetPriority( 10) ;
631  gwR.SetEntryLines( SHAPE_LINE_CHAIN(), en );
632 
633  m_gateways.push_back( gwR );
634 }
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 572 of file pns_diff_pair.cpp.

References DIRECTION_45::BuildInitialTrace(), and m_gateways.

Referenced by BuildGeneric().

573 {
574  for( DP_GATEWAY &g : m_gateways )
575  {
576  if( !g.HasEntryLines() )
577  {
578  SHAPE_LINE_CHAIN lead_p = DIRECTION_45().BuildInitialTrace ( g.AnchorP(), p0_p, g.IsDiagonal() ).Reverse();
579  SHAPE_LINE_CHAIN lead_n = DIRECTION_45().BuildInitialTrace ( g.AnchorN(), p0_n, g.IsDiagonal() ).Reverse();
580  g.SetEntryLines( lead_p, lead_n );
581  }
582  }
583 }
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 533 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().

534 {
535  int gap = m_fitVias ? m_viaGap + m_viaDiameter : m_gap;
536 
537  for( int attempt = 0; attempt < 2; attempt++ )
538  {
539  for( int i = 0; i < 4; i++ )
540  {
541  VECTOR2I dir;
542 
543  if( !attempt )
544  {
545  dir = makeGapVector( VECTOR2I( gap, gap ), gap );
546 
547  if( i % 2 == 0 )
548  dir.x = -dir.x;
549 
550  if( i / 2 == 0 )
551  dir.y = -dir.y;
552  }
553  else
554  {
555  if( i /2 == 0 )
556  dir = VECTOR2I( (gap + 1) / 2 * ( ( i % 2 ) ? -1 : 1 ), 0 );
557  else
558  dir = VECTOR2I( 0, (gap + 1) / 2 * ( ( i % 2 ) ? -1 : 1) );
559  }
560 
561  if( m_fitVias )
562  BuildGeneric( aCursorPos + dir, aCursorPos - dir, true, true );
563  else
564  m_gateways.push_back( DP_GATEWAY( aCursorPos + dir,
565  aCursorPos - dir, attempt ? true : false ) );
566 
567  }
568  }
569 }
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 422 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().

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

Definition at line 637 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().

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