KiCad PCB EDA Suite
PNS::AREA_CONSTRAINT Class Reference

#include <pns_optimizer.h>

Inheritance diagram for PNS::AREA_CONSTRAINT:
PNS::OPT_CONSTRAINT

Public Member Functions

 AREA_CONSTRAINT (NODE *aWorld, const BOX2I &aAllowedArea, bool aAllowedAreaStrict)
 
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

BOX2I m_allowedArea
 
bool m_allowedAreaStrict
 

Detailed Description

Definition at line 263 of file pns_optimizer.h.

Constructor & Destructor Documentation

◆ AREA_CONSTRAINT()

PNS::AREA_CONSTRAINT::AREA_CONSTRAINT ( NODE aWorld,
const BOX2I aAllowedArea,
bool  aAllowedAreaStrict 
)
inline

Definition at line 266 of file pns_optimizer.h.

266  :
267  OPT_CONSTRAINT( aWorld ),
268  m_allowedArea ( aAllowedArea ),
269  m_allowedAreaStrict ( aAllowedAreaStrict )
270  {
271  };
OPT_CONSTRAINT(NODE *aWorld)

Member Function Documentation

◆ Check()

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

214 {
215  const VECTOR2I& p1 = aOriginLine->CPoint( aVertex1 );
216  const VECTOR2I& p2 = aOriginLine->CPoint( aVertex2 );
217 
218  bool p1_in = m_allowedArea.Contains( p1 );
219  bool p2_in = m_allowedArea.Contains( p2 );
220 
221  if( m_allowedAreaStrict ) // strict restriction? both points must be inside the restricted area
222  return p1_in && p2_in;
223  else // loose restriction
224  return p1_in || p2_in;
225 }
bool Contains(const Vec &aPoint) const
Definition: box2.h:134

References BOX2< Vec >::Contains(), PNS::LINE::CPoint(), m_allowedArea, and m_allowedAreaStrict.

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

BOX2I PNS::AREA_CONSTRAINT::m_allowedArea
private

Definition at line 278 of file pns_optimizer.h.

Referenced by Check().

◆ m_allowedAreaStrict

bool PNS::AREA_CONSTRAINT::m_allowedAreaStrict
private

Definition at line 279 of file pns_optimizer.h.

Referenced by Check().

◆ 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 PNS::KEEP_TOPOLOGY_CONSTRAINT::Check().


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