KiCad PCB EDA Suite
PNS::KEEP_TOPOLOGY_CONSTRAINT Class Reference

#include <pns_optimizer.h>

Inheritance diagram for PNS::KEEP_TOPOLOGY_CONSTRAINT:
PNS::OPT_CONSTRAINT

Public Member Functions

 KEEP_TOPOLOGY_CONSTRAINT (NODE *aWorld)
 
bool Check (int aVertex1, int aVertex2, const LINE *aOriginLine, const SHAPE_LINE_CHAIN &aCurrentPath, const SHAPE_LINE_CHAIN &aReplacement) override
 
int GetPriority () const
 
void SetPriority (int aPriority)
 

Protected Attributes

NODEm_world
 
int m_priority
 

Detailed Description

Definition at line 281 of file pns_optimizer.h.

Constructor & Destructor Documentation

◆ KEEP_TOPOLOGY_CONSTRAINT()

PNS::KEEP_TOPOLOGY_CONSTRAINT::KEEP_TOPOLOGY_CONSTRAINT ( NODE aWorld)
inline

Definition at line 284 of file pns_optimizer.h.

284  :
285  OPT_CONSTRAINT( aWorld )
286  {
287  };
OPT_CONSTRAINT(NODE *aWorld)

Member Function Documentation

◆ Check()

bool PNS::KEEP_TOPOLOGY_CONSTRAINT::Check ( int  aVertex1,
int  aVertex2,
const LINE aOriginLine,
const SHAPE_LINE_CHAIN aCurrentPath,
const SHAPE_LINE_CHAIN aReplacement 
)
overridevirtual

Implements PNS::OPT_CONSTRAINT.

Definition at line 364 of file pns_optimizer.cpp.

367 {
368  SHAPE_LINE_CHAIN encPoly = aOriginLine->CLine().Slice( aVertex1, aVertex2 );
369 
370  // fixme: this is a remarkably shitty implementation...
371  encPoly.Append( aReplacement.Reverse() );
372  encPoly.SetClosed( true );
373 
374  BOX2I bb = encPoly.BBox();
375  std::vector<JOINT*> joints;
376 
377  int cnt = m_world->QueryJoints( bb, joints, aOriginLine->Layers(), ITEM::SOLID_T );
378 
379  if( !cnt )
380  return true;
381 
382  for( JOINT* j : joints )
383  {
384  if( j->Net() == aOriginLine->Net() )
385  continue;
386 
387  if( pointInside2( encPoly, j->Pos() ) )
388  {
389  bool falsePositive = false;
390 
391  for( int k = 0; k < encPoly.PointCount(); k++ )
392  {
393  if( encPoly.CPoint(k) == j->Pos() )
394  {
395  falsePositive = true;
396  break;
397  }
398  }
399 
400  if( !falsePositive )
401  {
402  //dbg->AddPoint(j->Pos(), 5);
403  return false;
404  }
405  }
406  }
407 
408  return true;
409 }
static bool pointInside2(const SHAPE_LINE_CHAIN &aL, const VECTOR2I &aP)
Determine if a point is located within a given polygon.
const SHAPE_LINE_CHAIN Slice(int aStartIndex, int aEndIndex=-1) const
Function Slice()
const SHAPE_LINE_CHAIN Reverse() const
Function Reverse()
int PointCount() const
Function PointCount()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void SetClosed(bool aClosed)
Function SetClosed()
const BOX2I BBox(int aClearance=0) const override
Compute a bounding box of the shape, with a margin of aClearance a collision.
int QueryJoints(const BOX2I &aBox, std::vector< JOINT * > &aJoints, LAYER_RANGE aLayerMask=LAYER_RANGE::All(), int aKindMask=ITEM::ANY_T)
Definition: pns_node.cpp:1436
SHAPE_LINE_CHAIN.

References SHAPE_LINE_CHAIN::Append(), SHAPE_LINE_CHAIN::BBox(), PNS::LINE::CLine(), SHAPE_LINE_CHAIN::CPoint(), PNS::ITEM::Layers(), PNS::OPT_CONSTRAINT::m_world, PNS::ITEM::Net(), SHAPE_LINE_CHAIN::PointCount(), PNS::pointInside2(), PNS::NODE::QueryJoints(), SHAPE_LINE_CHAIN::Reverse(), SHAPE_LINE_CHAIN::SetClosed(), SHAPE_LINE_CHAIN::Slice(), and PNS::ITEM::SOLID_T.

◆ GetPriority()

int PNS::OPT_CONSTRAINT::GetPriority ( ) const
inlineinherited

Definition at line 233 of file pns_optimizer.h.

233 { return m_priority; }

References PNS::OPT_CONSTRAINT::m_priority.

◆ SetPriority()

void PNS::OPT_CONSTRAINT::SetPriority ( int  aPriority)
inlineinherited

Definition at line 234 of file pns_optimizer.h.

234 { m_priority = aPriority; }

References PNS::OPT_CONSTRAINT::m_priority.

Member Data Documentation

◆ m_priority

int PNS::OPT_CONSTRAINT::m_priority
protectedinherited

◆ m_world

NODE* PNS::OPT_CONSTRAINT::m_world
protectedinherited

Definition at line 237 of file pns_optimizer.h.

Referenced by Check().


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