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

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.

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 ( const DP_PRIMITIVE_PAIR aPair,
bool  aIsDiagonal 
)
private

Definition at line 592 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(), PNS::makeGapVector(), PNS::DP_PRIMITIVE_PAIR::PrimP(), DIRECTION_45::Right(), PNS::SEGMENT::Seg(), PNS::DP_GATEWAY::SetPriority(), SEG::Side(), and DIRECTION_45::ToVector().

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

Definition at line 578 of file pns_diff_pair.cpp.

References DIRECTION_45::BuildInitialTrace().

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

Definition at line 539 of file pns_diff_pair.cpp.

References i, PNS::makeGapVector(), VECTOR2< T >::x, and VECTOR2< T >::y.

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

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

Definition at line 428 of file pns_diff_pair.cpp.

References SEG::A, PNS::DP_PRIMITIVE_PAIR::AnchorN(), PNS::DP_PRIMITIVE_PAIR::AnchorP(), SEG::B, EuclideanNorm(), i, 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().

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

Definition at line 643 of file pns_diff_pair.cpp.

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

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.push_back( DP_GATEWAY( m - dir, m + dir, diagColl, DIRECTION_45::ANG_RIGHT, prio ) );
675 
676  dir = makeGapVector( p0_n - p0_p, 2 * m_gap );
677  m_gateways.push_back( DP_GATEWAY( p0_p - dir, p0_p - dir + dir.Perpendicular(), diagColl ) );
678  m_gateways.push_back( DP_GATEWAY( p0_p - dir, p0_p - dir - dir.Perpendicular(), diagColl ) );
679  m_gateways.push_back( DP_GATEWAY( p0_n + dir + dir.Perpendicular(), p0_n + dir, diagColl ) );
680  m_gateways.push_back( DP_GATEWAY( p0_n + dir - dir.Perpendicular(), p0_n + dir, diagColl ) );
681  }
682  }
683  }
684 
685  for( int i = 0; i < 2; i++ )
686  {
687  for( int j = 0; j < 2; j++ )
688  {
689  OPT_VECTOR2I ips[2];
690 
691  ips[0] = d_n[i].IntersectLines( d_p[j] );
692  ips[1] = st_p[i].IntersectLines( st_n[j] );
693 
694  if( d_n[i].Collinear( d_p[j] ) )
695  ips[0] = OPT_VECTOR2I();
696  if( st_p[i].Collinear( st_p[j] ) )
697  ips[1] = OPT_VECTOR2I();
698 
699  // diagonal-diagonal and straight-straight cases - the most typical case if the pads
700  // are on the same straight/diagonal line
701  for( int k = 0; k < 2; k++ )
702  {
703  if( ips[k] )
704  {
705  const VECTOR2I m( *ips[k] );
706 
707  if( m != p0_p && m != p0_n )
708  {
709  int prio = ( padDist > padToGapThreshold * m_gap ? 10 : 20 );
710  VECTOR2I g_p( ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
711  VECTOR2I g_n( ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT1_2 ) ) );
712 
713  m_gateways.push_back( DP_GATEWAY( m + g_p, m + g_n, k == 0 ? true : false, DIRECTION_45::ANG_OBTUSE, prio ) );
714  }
715  }
716  }
717 
718  ips[0] = st_n[i].IntersectLines( d_p[j] );
719  ips[1] = st_p[i].IntersectLines( d_n[j] );
720 
721 // diagonal-straight cases: 8 possibilities of "weirder" exists
722  for( int k = 0; k < 2; k++ )
723  {
724  if( ips[k] )
725  {
726  const VECTOR2I m( *ips[k] );
727 
728  if( !aViaMode && m != p0_p && m != p0_n )
729  {
730  VECTOR2I g_p, g_n;
731 
732  g_p = ( p0_p - m ).Resize( ceil( (double) m_gap * M_SQRT2 ) );
733  g_n = ( p0_n - m ).Resize( ceil( (double) m_gap ) );
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  g_p = ( p0_p - m ).Resize( m_gap );
739  g_n = ( p0_n - m ).Resize( ceil( (double) m_gap * M_SQRT2 ) );
740 
741  if( angle( g_p, g_n ) != DIRECTION_45::ANG_ACUTE )
742  m_gateways.push_back( DP_GATEWAY( m + g_p, m + g_n, true ) );
743  }
744  }
745  }
746  }
747  }
748 
749  if( aBuildEntries )
750  buildEntries( p0_p, p0_n );
751 }
double EuclideanNorm(const wxPoint &vector)
Euclidean norm of a 2D vector.
Definition: trigo.h:112
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:179
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
OPT< VECTOR2I > OPT_VECTOR2I
Definition: seg.h:34
Definition: seg.h:36
static VECTOR2I makeGapVector(VECTOR2I dir, int length)
static DIRECTION_45::AngleType angle(const VECTOR2I &a, const VECTOR2I &b)
size_t i
Definition: json11.cpp:597
VECTOR2< T > Perpendicular() const
Function Perpendicular computes the perpendicular vector.
Definition: vector2d.h:313
bool Collinear(const SEG &aSeg) const
Function Collinear()
Definition: seg.h:231
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_viaDiameter, and m_viaGap.

311 {
312  for( const 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:112
std::vector< DP_GATEWAY > m_gateways
VECTOR2< int > VECTOR2I
Definition: vector2d.h:587
DP_GATEWAYS(int aGap)
Definition: seg.h:36
const std::vector<DP_GATEWAY>& PNS::DP_GATEWAYS::CGateways ( ) const
inline

Definition at line 231 of file pns_diff_pair.h.

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.

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.

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.

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

402 {
403  m_gateways.erase(
404  std::remove_if( m_gateways.begin(), m_gateways.end(), [aAngleMask, aRefOrientation]( const DP_GATEWAY& dp) {
405  DIRECTION_45 orient( dp.AnchorP() - dp.AnchorN() );
406  return !( orient.Angle( aRefOrientation ) & aAngleMask );
407  } ), m_gateways.end()
408  );
409 }
std::vector< DP_GATEWAY > m_gateways
Class DIRECTION_45.
Definition: direction45.h:36
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(), 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.

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.

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.

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

int PNS::DP_GATEWAYS::m_gap
private

Definition at line 250 of file pns_diff_pair.h.

std::vector<DP_GATEWAY> PNS::DP_GATEWAYS::m_gateways
private

Definition at line 255 of file pns_diff_pair.h.

int PNS::DP_GATEWAYS::m_viaDiameter
private

Definition at line 252 of file pns_diff_pair.h.

Referenced by BuildOrthoProjections().

int PNS::DP_GATEWAYS::m_viaGap
private

Definition at line 251 of file pns_diff_pair.h.

Referenced by BuildOrthoProjections().


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