25#ifndef _DRC_CREEPAGE_UTILS_H
26#define _DRC_CREEPAGE_UTILS_H
49 const std::vector<BOARD_ITEM*>& aBe,
50 const std::vector<const BOARD_ITEM*>& aDontTestAgainst,
51 int aMinGrooveWidth );
69 const std::vector<BOARD_ITEM*>& aBoardEdges,
70 const std::vector<const BOARD_ITEM*>& aIgnoreForTest,
SHAPE_POLY_SET* aOutline,
71 const std::pair<bool, bool>& aTestLocalConcavity,
int aMinGrooveWidth )
85 if( !( aOutline->
Contains( midPoint, -1, tolerance )
89 if(
false && ( aTestLocalConcavity.first || aTestLocalConcavity.second ) )
93 double extendLine = 1000;
98 double extendPoly = 100;
107 outline2.
Inflate( extendPoly, CORNER_STRATEGY::ROUND_ALL_CORNERS, 3 );
109 if( aTestLocalConcavity.first && !aOutline->
Contains( a - dir, -1, 0 ) )
112 if( aTestLocalConcavity.second && !aOutline->
Contains( b + dir, -1, 0 ) )
125 if( track->Type() == KICAD_T::PCB_TRACE_T && track->IsOnLayer( aLayer ) )
127 std::shared_ptr<SHAPE> sh = track->GetEffectiveShape();
129 if( sh && sh->Type() == SHAPE_TYPE::SH_SEGMENT )
131 SEG segTrack( track->GetStart(), track->GetEnd() );
186 virtual void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
189 std::vector<PATH_CONNECTION>
ReversePaths(
const std::vector<PATH_CONNECTION>& aV )
const
191 std::vector<PATH_CONNECTION> r;
192 r.reserve( aV.size() );
194 for(
const auto& pc : aV )
196 r.emplace_back( pc );
197 std::swap( r.back().a1, r.back().a2 );
204 double aMaxSquaredWeight )
const
206 std::vector<PATH_CONNECTION> a;
210 double aMaxSquaredWeight )
const
212 std::vector<PATH_CONNECTION> a;
216 double aMaxSquaredWeight )
const
218 std::vector<PATH_CONNECTION> a;
222 double aMaxSquaredWeight )
const
224 std::vector<PATH_CONNECTION> a;
228 double aMaxSquaredWeight )
const
230 std::vector<PATH_CONNECTION> a;
234 double aMaxSquaredWeight )
const
236 std::vector<PATH_CONNECTION> a;
240 double aMaxSquaredWeight )
const
242 std::vector<PATH_CONNECTION> a;
297 double aMaxSquaredWeight )
const override;
299 double aMaxSquaredWeight )
const override;
301 double aMaxSquaredWeight )
const override;
303 double aMaxSquaredWeight )
const override;
305 double aMaxSquaredWeight )
const override;
307 double aMaxSquaredWeight )
const override;
333 double aMaxSquaredWeight )
const override;
335 double aMaxSquaredWeight )
const override;
337 double aMaxSquaredWeight )
const override;
339 double aMaxSquaredWeight )
const override
345 double aMaxSquaredWeight )
const override;
347 double aMaxSquaredWeight )
const override;
365 m_type = CREEP_SHAPE::TYPE::ARC;
374 double aMaxSquaredWeight )
const override;
376 double aMaxSquaredWeight )
const override;
378 double aMaxSquaredWeight )
const override;
380 double aMaxSquaredWeight )
const override
385 double aMaxSquaredWeight )
const override
390 double aMaxSquaredWeight )
const override;
476 std::shared_ptr<GraphNode>
n1 =
nullptr;
477 std::shared_ptr<GraphNode>
n2 =
nullptr;
495 m_type = CREEP_SHAPE::TYPE::POINT;
499 double aMaxSquaredWeight )
const override;
501 double aMaxSquaredWeight )
const override;
503 double aMaxSquaredWeight )
const override;
505 double aMaxSquaredWeight )
const override
510 double aMaxSquaredWeight )
const override
515 double aMaxSquaredWeight )
const override
521 void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
536 m_type = CREEP_SHAPE::TYPE::CIRCLE;
540 double aMaxSquaredWeight )
const override
545 double aMaxSquaredWeight )
const override;
547 double aMaxSquaredWeight )
const override;
549 double aMaxSquaredWeight )
const override
554 double aMaxSquaredWeight )
const override
561 void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
581 m_type = CREEP_SHAPE::TYPE::ARC;
589 void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
594 double aMaxSquaredWeight )
const override
599 double aMaxSquaredWeight )
const override
604 double aMaxSquaredWeight )
const override;
607 double aMaxSquaredWeight )
const override
612 double aMaxSquaredWeight )
const override
617 double aMaxSquaredWeight )
const override
680 std::vector<std::shared_ptr<GraphNode>>
m_nodes;
691 std::shared_ptr<GraphConnection>
AddConnection( std::shared_ptr<GraphNode>& aN1,
692 std::shared_ptr<GraphNode>& aN2,
694 std::shared_ptr<GraphConnection>
AddConnection( std::shared_ptr<GraphNode>& aN1,
695 std::shared_ptr<GraphNode>& aN2 );
699 void RemoveConnection( std::shared_ptr<GraphConnection>,
bool aDelete =
false );
700 void Trim(
double aWeightLimit );
701 void Addshape(
const SHAPE& aShape, std::shared_ptr<GraphNode>& aConnectTo,
704 double Solve( std::shared_ptr<GraphNode>& aFrom, std::shared_ptr<GraphNode>& aTo,
705 std::vector<std::shared_ptr<GraphConnection>>& aResult );
Creepage: a board edge arc.
std::pair< bool, bool > IsThereATangentPassingThroughPoint(const BE_SHAPE_POINT aPoint) const
EDA_ANGLE GetStartAngle() const override
int GetRadius() const override
BE_SHAPE_ARC(VECTOR2I aPos, int aRadius, EDA_ANGLE aStartAngle, EDA_ANGLE aEndAngle, VECTOR2D aStartPoint, VECTOR2D aEndPoint)
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_ARC &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
VECTOR2I GetStartPoint() const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
EDA_ANGLE GetEndAngle() const override
void ConnectChildren(std::shared_ptr< GraphNode > &a1, std::shared_ptr< GraphNode > &a2, CreepageGraph &aG) const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_SEGMENT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_CIRCLE &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_CIRCLE &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
VECTOR2I GetEndPoint() const override
EDA_ANGLE AngleBetweenStartAndEnd(const VECTOR2I aPoint) const
Creepage: a board edge circle.
void ShortenChildDueToGV(std::shared_ptr< GraphNode > &a1, std::shared_ptr< GraphNode > &a2, CreepageGraph &aG, double aNormalWeight) const
int GetRadius() const override
BE_SHAPE_CIRCLE(VECTOR2I aPos=VECTOR2I(0, 0), int aRadius=0)
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_CIRCLE &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_SEGMENT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
void ConnectChildren(std::shared_ptr< GraphNode > &a1, std::shared_ptr< GraphNode > &a2, CreepageGraph &aG) const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
Creepage: a board edge point.
void ConnectChildren(std::shared_ptr< GraphNode > &a1, std::shared_ptr< GraphNode > &a2, CreepageGraph &aG) const override
BE_SHAPE_POINT(VECTOR2I aPos)
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_ARC &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_SEGMENT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_CIRCLE &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
Creepage: a board edge shape.
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Information pertinent to a Pcbnew printed circuit board.
const TRACKS & Tracks() const
A class used to represent the shapes for creepage calculation.
virtual VECTOR2I GetStartPoint() const
virtual std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const
virtual std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_ARC &aS2, double aMaxWeight, double aMaxSquaredWeight) const
CREEP_SHAPE::TYPE GetType() const
std::vector< PATH_CONNECTION > Paths(const CREEP_SHAPE &aS2, double aMaxWeight, double aMaxSquaredWeight) const
virtual EDA_ANGLE GetEndAngle() const
void SetParent(BOARD_ITEM *aParent)
virtual void ConnectChildren(std::shared_ptr< GraphNode > &a1, std::shared_ptr< GraphNode > &a2, CreepageGraph &aG) const
virtual std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_ARC &aS2, double aMaxWeight, double aMaxSquaredWeight) const
virtual std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_CIRCLE &aS2, double aMaxWeight, double aMaxSquaredWeight) const
virtual int GetRadius() const
const BOARD_ITEM * GetParent() const
virtual std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_CIRCLE &aS2, double aMaxWeight, double aMaxSquaredWeight) const
virtual EDA_ANGLE GetStartAngle() const
virtual VECTOR2I GetEndPoint() const
virtual std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_SEGMENT &aS2, double aMaxWeight, double aMaxSquaredWeight) const
std::vector< PATH_CONNECTION > ReversePaths(const std::vector< PATH_CONNECTION > &aV) const
Creepage: a conductive arc.
VECTOR2I GetStartPoint() const override
EDA_ANGLE AngleBetweenStartAndEnd(const VECTOR2I aPoint) const
VECTOR2I GetEndPoint() const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_CIRCLE &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
EDA_ANGLE GetStartAngle() const override
CU_SHAPE_ARC(VECTOR2I aPos, double aRadius, EDA_ANGLE aStartAngle, EDA_ANGLE aEndAngle, VECTOR2D aStartPoint, VECTOR2D aEndPoint)
int GetRadius() const override
EDA_ANGLE GetEndAngle() const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_SEGMENT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
Creepage: a conductive circle.
int GetRadius() const override
std::vector< PATH_CONNECTION > Paths(const CU_SHAPE_SEGMENT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
CU_SHAPE_CIRCLE(VECTOR2I aPos, double aRadius=0)
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
Creepage: a conductive segment.
std::vector< PATH_CONNECTION > Paths(const BE_SHAPE_POINT &aS2, double aMaxWeight, double aMaxSquaredWeight) const override
VECTOR2I GetStart() const
CU_SHAPE_SEGMENT(VECTOR2I aStart, VECTOR2I aEnd, double aWidth=0)
Creepage: a conductive shape.
A graph with nodes and connections for creepage calculation.
std::vector< CREEP_SHAPE * > m_shapeCollection
void RemoveDuplicatedShapes()
std::vector< std::shared_ptr< GraphNode > > m_nodes
std::shared_ptr< GraphNode > FindNode(GraphNode::TYPE aType, CREEP_SHAPE *aParent, VECTOR2I aPos)
double m_creepageTargetSquared
std::shared_ptr< GraphNode > AddNodeVirtual()
std::shared_ptr< GraphNode > AddNode(GraphNode::TYPE aType, CREEP_SHAPE *aParent=nullptr, VECTOR2I aPos=VECTOR2I())
std::shared_ptr< GraphNode > AddNetElements(int aNetCode, PCB_LAYER_ID aLayer, int aMaxCreepage)
std::vector< std::shared_ptr< GraphConnection > > m_connections
void SetTarget(double aTarget)
void TransformCreepShapesToNodes(std::vector< CREEP_SHAPE * > &aShapes)
double Solve(std::shared_ptr< GraphNode > &aFrom, std::shared_ptr< GraphNode > &aTo, std::vector< std::shared_ptr< GraphConnection > > &aResult)
std::vector< BOARD_ITEM * > m_boardEdge
void TransformEdgeToCreepShapes()
CreepageGraph(BOARD &aBoard)
void Addshape(const SHAPE &aShape, std::shared_ptr< GraphNode > &aConnectTo, BOARD_ITEM *aParent=nullptr)
void GeneratePaths(double aMaxWeight, PCB_LAYER_ID aLayer, bool aGenerateBoardEdges=true)
SHAPE_POLY_SET * m_boardOutline
std::shared_ptr< GraphConnection > AddConnection(std::shared_ptr< GraphNode > &aN1, std::shared_ptr< GraphNode > &aN2, const PATH_CONNECTION &aPc)
void Trim(double aWeightLimit)
void RemoveConnection(std::shared_ptr< GraphConnection >, bool aDelete=false)
std::shared_ptr< GraphNode > n1
std::vector< PCB_SHAPE > GetShapes()
std::shared_ptr< GraphNode > n2
GraphConnection(std::shared_ptr< GraphNode > &aN1, std::shared_ptr< GraphNode > &aN2, const PATH_CONNECTION &aPc)
GraphNode(GraphNode::TYPE aType, CREEP_SHAPE *aParent, VECTOR2I aPos=VECTOR2I())
std::vector< std::shared_ptr< GraphConnection > > m_connections
bool Intersects(const SEG &aSeg) const
Represent a set of closed polygons.
void Inflate(int aAmount, CORNER_STRATEGY aCornerStrategy, int aMaxError, bool aSimplify=false)
Perform outline inflation/deflation.
bool PointOnEdge(const VECTOR2I &aP, int aAccuracy=0) const
Check if point aP lies on an edge or vertex of some of the outlines or holes.
bool Contains(const VECTOR2I &aP, int aSubpolyIndex=-1, int aAccuracy=0, bool aUseBBoxCaches=false) const
Return true if a given subpolygon contains the point aP.
An abstract shape on 2D plane.
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
bool SegmentIntersectsBoard(const VECTOR2I &aP1, const VECTOR2I &aP2, const std::vector< BOARD_ITEM * > &aBe, const std::vector< const BOARD_ITEM * > &aDontTestAgainst, int aMinGrooveWidth)
static constexpr EDA_ANGLE ANGLE_360
PCB_LAYER_ID
A quick note on layer IDs:
This file contains miscellaneous commonly used macros and functions.
bool isValid(const BOARD &aBoard, PCB_LAYER_ID aLayer, const std::vector< BOARD_ITEM * > &aBoardEdges, const std::vector< const BOARD_ITEM * > &aIgnoreForTest, SHAPE_POLY_SET *aOutline, const std::pair< bool, bool > &aTestLocalConcavity, int aMinGrooveWidth)
Test if a path is valid.
bool m_forceA2concavityCheck
bool m_forceA1concavityCheck
VECTOR2< int32_t > VECTOR2I