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

A graph with nodes and connections for creepage calculation. More...

#include <drc_creepage_utils.h>

Classes

struct  GraphNodeEqual
 
struct  GraphNodeHash
 

Public Member Functions

 CREEPAGE_GRAPH (BOARD &aBoard)
 
 ~CREEPAGE_GRAPH ()
 
void TransformEdgeToCreepShapes ()
 
void TransformCreepShapesToNodes (std::vector< CREEP_SHAPE * > &aShapes)
 
void RemoveDuplicatedShapes ()
 
std::shared_ptr< GRAPH_NODEAddNode (GRAPH_NODE::TYPE aType, CREEP_SHAPE *aParent=nullptr, const VECTOR2I &aPos=VECTOR2I())
 
std::shared_ptr< GRAPH_NODEAddNodeVirtual ()
 
std::shared_ptr< GRAPH_CONNECTIONAddConnection (std::shared_ptr< GRAPH_NODE > &aN1, std::shared_ptr< GRAPH_NODE > &aN2, const PATH_CONNECTION &aPc)
 
std::shared_ptr< GRAPH_CONNECTIONAddConnection (std::shared_ptr< GRAPH_NODE > &aN1, std::shared_ptr< GRAPH_NODE > &aN2)
 
std::shared_ptr< GRAPH_NODEFindNode (GRAPH_NODE::TYPE aType, CREEP_SHAPE *aParent, const VECTOR2I &aPos)
 
void RemoveConnection (const std::shared_ptr< GRAPH_CONNECTION > &, bool aDelete=false)
 
void Trim (double aWeightLimit)
 
void Addshape (const SHAPE &aShape, std::shared_ptr< GRAPH_NODE > &aConnectTo, BOARD_ITEM *aParent=nullptr)
 
double Solve (std::shared_ptr< GRAPH_NODE > &aFrom, std::shared_ptr< GRAPH_NODE > &aTo, std::vector< std::shared_ptr< GRAPH_CONNECTION > > &aResult)
 
void GeneratePaths (double aMaxWeight, PCB_LAYER_ID aLayer, const std::set< int > *aRelevantNets=nullptr)
 Generate creepage paths between graph nodes.
 
void TruncateToPrefix (size_t aNodeCount, size_t aConnectionCount)
 Remove every node and connection added after the given prefix sizes, then rebuild the node lookup set from the surviving prefix.
 
std::shared_ptr< GRAPH_NODEAddNetElements (int aNetCode, PCB_LAYER_ID aLayer, int aMaxCreepage)
 
void SetTarget (double aTarget)
 
double GetTarget ()
 

Public Attributes

BOARDm_board
 
std::vector< BOARD_ITEM * > m_boardEdge
 
std::vector< std::unique_ptr< PCB_SHAPE > > m_ownedBoardEdges
 
SHAPE_POLY_SETm_boardOutline
 
std::vector< std::shared_ptr< GRAPH_NODE > > m_nodes
 
std::vector< std::shared_ptr< GRAPH_CONNECTION > > m_connections
 
std::vector< CREEP_SHAPE * > m_shapeCollection
 
std::unordered_set< std::shared_ptr< GRAPH_NODE >, GraphNodeHash, GraphNodeEqualm_nodeset
 
int m_minGrooveWidth
 

Private Attributes

double m_creepageTarget
 
double m_creepageTargetSquared
 

Detailed Description

A graph with nodes and connections for creepage calculation.

Definition at line 800 of file drc_creepage_utils.h.

Constructor & Destructor Documentation

◆ CREEPAGE_GRAPH()

CREEPAGE_GRAPH::CREEPAGE_GRAPH ( BOARD & aBoard)
inline

◆ ~CREEPAGE_GRAPH()

CREEPAGE_GRAPH::~CREEPAGE_GRAPH ( )
inline

Definition at line 812 of file drc_creepage_utils.h.

References m_connections, m_nodes, and m_shapeCollection.

Member Function Documentation

◆ AddConnection() [1/2]

std::shared_ptr< GRAPH_CONNECTION > CREEPAGE_GRAPH::AddConnection ( std::shared_ptr< GRAPH_NODE > & aN1,
std::shared_ptr< GRAPH_NODE > & aN2 )

◆ AddConnection() [2/2]

std::shared_ptr< GRAPH_CONNECTION > CREEPAGE_GRAPH::AddConnection ( std::shared_ptr< GRAPH_NODE > & aN1,
std::shared_ptr< GRAPH_NODE > & aN2,
const PATH_CONNECTION & aPc )

◆ AddNetElements()

std::shared_ptr< GRAPH_NODE > CREEPAGE_GRAPH::AddNetElements ( int aNetCode,
PCB_LAYER_ID aLayer,
int aMaxCreepage )

◆ AddNode()

std::shared_ptr< GRAPH_NODE > CREEPAGE_GRAPH::AddNode ( GRAPH_NODE::TYPE aType,
CREEP_SHAPE * aParent = nullptr,
const VECTOR2I & aPos = VECTOR2I() )

◆ AddNodeVirtual()

std::shared_ptr< GRAPH_NODE > CREEPAGE_GRAPH::AddNodeVirtual ( )

Definition at line 3048 of file drc_creepage_utils.cpp.

References m_nodes, and m_nodeset.

Referenced by AddNetElements().

◆ Addshape()

◆ FindNode()

std::shared_ptr< GRAPH_NODE > CREEPAGE_GRAPH::FindNode ( GRAPH_NODE::TYPE aType,
CREEP_SHAPE * aParent,
const VECTOR2I & aPos )

Definition at line 3091 of file drc_creepage_utils.cpp.

References m_nodeset.

Referenced by AddNode().

◆ GeneratePaths()

void CREEPAGE_GRAPH::GeneratePaths ( double aMaxWeight,
PCB_LAYER_ID aLayer,
const std::set< int > * aRelevantNets = nullptr )

Generate creepage paths between graph nodes.

When aRelevantNets is non-null, paths between two conductors that both belong to non-relevant nets are skipped: such an edge can never lie on a shortest path that starts or ends on a relevant net (a third net's copper is an obstacle, not a routing medium). Board edges are never conductors, so board-edge paths are always generated. Passing nullptr generates every pair (the batch / whole-board behaviour).

Definition at line 2552 of file drc_creepage_utils.cpp.

References KIRTREE::PACKED_RTREE< DATATYPE, ELEMTYPE, NUMDIMS, FANOUT >::Builder::Add(), AddConnection(), AddNode(), KIRTREE::PACKED_RTREE< DATATYPE, ELEMTYPE, NUMDIMS, FANOUT >::Builder::Build(), Edge_Cuts, empty(), BOX2< Vec >::GetBottom(), EDA_ITEM::GetBoundingBox(), GetKiCadThreadPool(), BOX2< Vec >::GetLeft(), CREEP_SHAPE::GetParent(), GetPaths(), BOX2< Vec >::GetRight(), BOX2< Vec >::GetTop(), CREEP_SHAPE::GetType(), BOX2< Vec >::GetX(), BOX2< Vec >::GetY(), CREEPAGE_TRACK_ENTRY::halfWidth, CREEP_SHAPE::IsConductive(), CREEPAGE_TRACK_ENTRY::layer, m_board, m_boardEdge, m_boardOutline, m_minGrooveWidth, m_nodes, PCB_TRACE_T, GRAPH_NODE::POINT, CREEPAGE_TRACK_ENTRY::segment, SH_SEGMENT, tp, and CREEPAGE_TRACK_ENTRY::track.

Referenced by CREEPAGE_ENGINE::SolveNetPairWholeBoard(), DRC_TEST_PROVIDER_CREEPAGE::testCreepage(), and DRC_TEST_PROVIDER_CREEPAGE::testCreepage().

◆ GetTarget()

double CREEPAGE_GRAPH::GetTarget ( )
inline

◆ RemoveConnection()

void CREEPAGE_GRAPH::RemoveConnection ( const std::shared_ptr< GRAPH_CONNECTION > & aGc,
bool aDelete = false )

Definition at line 2975 of file drc_creepage_utils.cpp.

References m_connections, m_nodes, and m_nodeset.

Referenced by Trim(), and TruncateToPrefix().

◆ RemoveDuplicatedShapes()

void CREEPAGE_GRAPH::RemoveDuplicatedShapes ( )

◆ SetTarget()

void CREEPAGE_GRAPH::SetTarget ( double aTarget)

◆ Solve()

double CREEPAGE_GRAPH::Solve ( std::shared_ptr< GRAPH_NODE > & aFrom,
std::shared_ptr< GRAPH_NODE > & aTo,
std::vector< std::shared_ptr< GRAPH_CONNECTION > > & aResult )

◆ TransformCreepShapesToNodes()

void CREEPAGE_GRAPH::TransformCreepShapesToNodes ( std::vector< CREEP_SHAPE * > & aShapes)

◆ TransformEdgeToCreepShapes()

◆ Trim()

void CREEPAGE_GRAPH::Trim ( double aWeightLimit)

Definition at line 2958 of file drc_creepage_utils.cpp.

References m_connections, and RemoveConnection().

◆ TruncateToPrefix()

void CREEPAGE_GRAPH::TruncateToPrefix ( size_t aNodeCount,
size_t aConnectionCount )

Remove every node and connection added after the given prefix sizes, then rebuild the node lookup set from the surviving prefix.

Used to reuse a graph across solves without leaking stale per-solve nodes into FindNode/AddNode lookups.

Definition at line 3011 of file drc_creepage_utils.cpp.

References m_connections, m_nodes, m_nodeset, and RemoveConnection().

Member Data Documentation

◆ m_board

BOARD& CREEPAGE_GRAPH::m_board

Definition at line 911 of file drc_creepage_utils.h.

Referenced by AddNetElements(), CREEPAGE_GRAPH(), and GeneratePaths().

◆ m_boardEdge

◆ m_boardOutline

◆ m_connections

std::vector<std::shared_ptr<GRAPH_CONNECTION> > CREEPAGE_GRAPH::m_connections

◆ m_creepageTarget

double CREEPAGE_GRAPH::m_creepageTarget
private

Definition at line 925 of file drc_creepage_utils.h.

Referenced by CREEPAGE_GRAPH(), GetTarget(), and SetTarget().

◆ m_creepageTargetSquared

double CREEPAGE_GRAPH::m_creepageTargetSquared
private

Definition at line 926 of file drc_creepage_utils.h.

Referenced by CREEPAGE_GRAPH(), and SetTarget().

◆ m_minGrooveWidth

◆ m_nodes

◆ m_nodeset

std::unordered_set<std::shared_ptr<GRAPH_NODE>, GraphNodeHash, GraphNodeEqual> CREEPAGE_GRAPH::m_nodeset

◆ m_ownedBoardEdges

std::vector<std::unique_ptr<PCB_SHAPE> > CREEPAGE_GRAPH::m_ownedBoardEdges

◆ m_shapeCollection


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