KiCad PCB EDA Suite
Loading...
Searching...
No Matches
CN_EDGE Class Reference

CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc. More...

#include <connectivity_algo.h>

Public Member Functions

 CN_EDGE ()
 
 CN_EDGE (const std::shared_ptr< CN_ANCHOR > &aSource, const std::shared_ptr< CN_ANCHOR > &aTarget, unsigned aWeight=0)
 
bool operator< (CN_EDGE aOther) const
 This sort operator provides a sort-by-weight for the ratsnest operation.
 
bool StableSortCompare (const CN_EDGE &aOther) const
 Comparison operator for std::stable_sort.
 
std::shared_ptr< const CN_ANCHORGetSourceNode () const
 
std::shared_ptr< const CN_ANCHORGetTargetNode () const
 
void SetSourceNode (const std::shared_ptr< const CN_ANCHOR > &aNode)
 
void SetTargetNode (const std::shared_ptr< const CN_ANCHOR > &aNode)
 
void RemoveInvalidRefs ()
 
void SetWeight (unsigned weight)
 
unsigned GetWeight () const
 
void SetVisible (bool aVisible)
 
bool IsVisible () const
 
const VECTOR2I GetSourcePos () const
 
const VECTOR2I GetTargetPos () const
 
unsigned GetLength () const
 

Private Attributes

std::shared_ptr< const CN_ANCHORm_source
 
std::shared_ptr< const CN_ANCHORm_target
 
unsigned m_weight
 
bool m_visible
 

Detailed Description

CN_EDGE represents a point-to-point connection, whether realized or unrealized (ie: tracks etc.

or a ratsnest line).

Definition at line 62 of file connectivity_algo.h.

Constructor & Destructor Documentation

◆ CN_EDGE() [1/2]

CN_EDGE::CN_EDGE ( )
inline

Definition at line 65 of file connectivity_algo.h.

◆ CN_EDGE() [2/2]

CN_EDGE::CN_EDGE ( const std::shared_ptr< CN_ANCHOR > &  aSource,
const std::shared_ptr< CN_ANCHOR > &  aTarget,
unsigned  aWeight = 0 
)
inline

Definition at line 70 of file connectivity_algo.h.

Member Function Documentation

◆ GetLength()

unsigned CN_EDGE::GetLength ( ) const
inline

Definition at line 148 of file connectivity_algo.h.

References m_source, and m_target.

◆ GetSourceNode()

std::shared_ptr< const CN_ANCHOR > CN_EDGE::GetSourceNode ( ) const
inline

◆ GetSourcePos()

const VECTOR2I CN_EDGE::GetSourcePos ( ) const
inline

Definition at line 146 of file connectivity_algo.h.

References m_source.

Referenced by StableSortCompare().

◆ GetTargetNode()

std::shared_ptr< const CN_ANCHOR > CN_EDGE::GetTargetNode ( ) const
inline

◆ GetTargetPos()

const VECTOR2I CN_EDGE::GetTargetPos ( ) const
inline

Definition at line 147 of file connectivity_algo.h.

References m_target.

◆ GetWeight()

unsigned CN_EDGE::GetWeight ( ) const
inline

Definition at line 141 of file connectivity_algo.h.

References m_weight.

◆ IsVisible()

bool CN_EDGE::IsVisible ( ) const
inline

Definition at line 144 of file connectivity_algo.h.

References m_visible.

◆ operator<()

bool CN_EDGE::operator< ( CN_EDGE  aOther) const
inline

This sort operator provides a sort-by-weight for the ratsnest operation.

Parameters
aOtherthe other edge to compare.
Returns
true if our weight is smaller than the other weight.

Definition at line 84 of file connectivity_algo.h.

References m_weight.

◆ RemoveInvalidRefs()

void CN_EDGE::RemoveInvalidRefs ( )
inline

Definition at line 131 of file connectivity_algo.h.

References m_source, and m_target.

◆ SetSourceNode()

void CN_EDGE::SetSourceNode ( const std::shared_ptr< const CN_ANCHOR > &  aNode)
inline

Definition at line 128 of file connectivity_algo.h.

References m_source.

◆ SetTargetNode()

void CN_EDGE::SetTargetNode ( const std::shared_ptr< const CN_ANCHOR > &  aNode)
inline

Definition at line 129 of file connectivity_algo.h.

References m_target.

◆ SetVisible()

void CN_EDGE::SetVisible ( bool  aVisible)
inline

Definition at line 143 of file connectivity_algo.h.

References m_visible.

Referenced by BOARD::UpdateRatsnestExclusions().

◆ SetWeight()

void CN_EDGE::SetWeight ( unsigned  weight)
inline

Definition at line 140 of file connectivity_algo.h.

References m_weight.

◆ StableSortCompare()

bool CN_EDGE::StableSortCompare ( const CN_EDGE aOther) const
inline

Comparison operator for std::stable_sort.

Parameters
aOtherthe other edge to compare.
Returns
true if this edge should come before aOther in the sorted order.

Comparison order:

  1. Compare source nodes by position (x, then y)
  2. Then compare by weight
  3. Then by visibility
  4. If everything is equal, return false for stable ordering

Definition at line 101 of file connectivity_algo.h.

References GetSourcePos(), m_visible, m_weight, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by RN_NET::GetEdges().

Member Data Documentation

◆ m_source

std::shared_ptr<const CN_ANCHOR> CN_EDGE::m_source
private

◆ m_target

std::shared_ptr<const CN_ANCHOR> CN_EDGE::m_target
private

◆ m_visible

bool CN_EDGE::m_visible
private

Definition at line 157 of file connectivity_algo.h.

Referenced by IsVisible(), SetVisible(), and StableSortCompare().

◆ m_weight

unsigned CN_EDGE::m_weight
private

Definition at line 156 of file connectivity_algo.h.

Referenced by GetWeight(), operator<(), SetWeight(), and StableSortCompare().


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