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 283 of file pns_optimizer.h.

Constructor & Destructor Documentation

◆ KEEP_TOPOLOGY_CONSTRAINT()

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

Definition at line 286 of file pns_optimizer.h.

286  :
287  OPT_CONSTRAINT( aWorld )
288  {
289  };
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 361 of file pns_optimizer.cpp.

364 {
365  SHAPE_LINE_CHAIN encPoly = aOriginLine->CLine().Slice( aVertex1, aVertex2 );
366 
367  // fixme: this is a remarkably shitty implementation...
368  encPoly.Append( aReplacement.Reverse() );
369  encPoly.SetClosed( true );
370 
371  BOX2I bb = encPoly.BBox();
372  std::vector<JOINT*> joints;
373 
374  int cnt = m_world->QueryJoints( bb, joints, aOriginLine->Layers(), ITEM::SOLID_T );
375 
376  if( !cnt )
377  return true;
378 
379  for( JOINT* j : joints )
380  {
381  if( j->Net() == aOriginLine->Net() )
382  continue;
383 
384  if( pointInside2( encPoly, j->Pos() ) )
385  {
386  bool falsePositive = false;
387 
388  for( int k = 0; k < encPoly.PointCount(); k++ )
389  {
390  if( encPoly.CPoint(k) == j->Pos() )
391  {
392  falsePositive = true;
393  break;
394  }
395  }
396 
397  if( !falsePositive )
398  {
399  //dbg->AddPoint(j->Pos(), 5);
400  return false;
401  }
402  }
403  }
404 
405  return true;
406 }
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
Return a subset of this line chain containing the [start_index, end_index] range of points.
const SHAPE_LINE_CHAIN Reverse() const
Reverse point order in the line chain.
int PointCount() const
Return the number of points (vertices) in this line chain.
void Append(int aX, int aY, bool aAllowDuplication=false)
Append a new point at the end of the line chain.
const VECTOR2I & CPoint(int aIndex) const
Return a reference to a given point in the line chain.
void SetClosed(bool aClosed)
Mark the line chain as closed (i.e.
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:1535
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...

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: