KiCad PCB EDA Suite
PNS::PRESERVE_VERTEX_CONSTRAINT Class Reference

#include <pns_optimizer.h>

Inheritance diagram for PNS::PRESERVE_VERTEX_CONSTRAINT:
PNS::OPT_CONSTRAINT

Public Member Functions

 PRESERVE_VERTEX_CONSTRAINT (NODE *aWorld, const VECTOR2I &aV)
 
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
 

Private Attributes

VECTOR2I m_v
 

Detailed Description

Definition at line 297 of file pns_optimizer.h.

Constructor & Destructor Documentation

◆ PRESERVE_VERTEX_CONSTRAINT()

PNS::PRESERVE_VERTEX_CONSTRAINT::PRESERVE_VERTEX_CONSTRAINT ( NODE aWorld,
const VECTOR2I aV 
)
inline

Definition at line 300 of file pns_optimizer.h.

300  :
301  OPT_CONSTRAINT( aWorld ),
302  m_v( aV )
303  {
304  };
OPT_CONSTRAINT(NODE *aWorld)

Member Function Documentation

◆ Check()

bool PNS::PRESERVE_VERTEX_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 228 of file pns_optimizer.cpp.

231 {
232  bool cv = false;
233 
234  for( int i = aVertex1; i < aVertex2; i++ )
235  {
236  SEG::ecoord dist = aCurrentPath.CSegment(i).SquaredDistance( m_v );
237 
238  if ( dist <= 1 )
239  {
240  cv = true;
241  break;
242  }
243  }
244 
245  if( !cv )
246  return true;
247 
248  for( int i = 0; i < aReplacement.SegmentCount(); i++ )
249  {
250  SEG::ecoord dist = aReplacement.CSegment(i).SquaredDistance( m_v );
251 
252  if ( dist <= 1 )
253  return true;
254  }
255 
256  return false;
257 }
VECTOR2I::extended_type ecoord
Definition: seg.h:43
ecoord SquaredDistance(const SEG &aSeg) const
Definition: seg.cpp:39
int SegmentCount() const
Return the number of segments in this line chain.
const SEG CSegment(int aIndex) const
Return a constant copy of the aIndex segment in the line chain.

References SHAPE_LINE_CHAIN::CSegment(), m_v, SHAPE_LINE_CHAIN::SegmentCount(), and SEG::SquaredDistance().

◆ 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_v

VECTOR2I PNS::PRESERVE_VERTEX_CONSTRAINT::m_v
private

Definition at line 310 of file pns_optimizer.h.

Referenced by Check().

◆ m_world

NODE* PNS::OPT_CONSTRAINT::m_world
protectedinherited

Definition at line 237 of file pns_optimizer.h.

Referenced by PNS::KEEP_TOPOLOGY_CONSTRAINT::Check().


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