KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_creepage_utils.h
Go to the documentation of this file.
1
2/*
3 * Copyright (C) 2024 KiCad Developers.
4 * Copyright (C) 2024 Fabien Corona f.corona<at>laposte.net
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24
25#ifndef _DRC_CREEPAGE_UTILS_H
26#define _DRC_CREEPAGE_UTILS_H
27
28#include <common.h>
29#include <macros.h>
31#include <footprint.h>
32#include <pad.h>
33#include <pcb_track.h>
34#include <pcb_shape.h>
35#include <zone.h>
36#include <advanced_config.h>
37#include <geometry/shape_rect.h>
38#include <geometry/seg.h>
40#include <drc/drc_item.h>
41#include <drc/drc_rule.h>
42#include <board.h>
43
44
46
47
48extern bool SegmentIntersectsBoard( const VECTOR2I& aP1, const VECTOR2I& aP2,
49 const std::vector<BOARD_ITEM*>& aBe,
50 const std::vector<const BOARD_ITEM*>& aDontTestAgainst,
51 int aMinGrooveWidth );
52
54{
57 double weight = -1;
58 bool m_show = true;
59
62
63
68 bool isValid( const BOARD& aBoard, PCB_LAYER_ID aLayer,
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 )
72 {
73 if( !aOutline )
74 return true; // We keep the segment if there is a problem
75
76 if( !SegmentIntersectsBoard( a1, a2, aBoardEdges, aIgnoreForTest, aMinGrooveWidth ) )
77 return false;
78
79 // The mid point should be inside the board.
80 // Tolerance of 100nm.
81
82 VECTOR2I midPoint = ( a1 + a2 ) / 2;
83 int tolerance = 100;
84
85 if( !( aOutline->Contains( midPoint, -1, tolerance )
86 || aOutline->PointOnEdge( midPoint, tolerance ) ) )
87 return false;
88
89 if( false && ( aTestLocalConcavity.first || aTestLocalConcavity.second ) )
90 {
91 // Test for local concavity. If it is localy convex, then it will not be a path of interest.
92
93 double extendLine = 1000; // extend line by 1000nm
94 // In some cases, the projected point could be on the board edge
95 // In such cases, we wan to keep the line.
96 // We inflate the polygon to get a small margin for computation/rounding error.
97 // We might keep some unnecessary lines, but it's better than loosing the important ones.
98 double extendPoly = 100; // extend polygon by 10 nm
99
100 VECTOR2D a( double( a1.x ), double( a1.y ) );
101 VECTOR2D b( double( a2.x ), double( a2.y ) );
102
103 VECTOR2D dir( b - a );
104 dir = dir * ( extendLine / dir.SquaredEuclideanNorm() );
105
106 SHAPE_POLY_SET outline2 = *aOutline;
107 outline2.Inflate( extendPoly, CORNER_STRATEGY::ROUND_ALL_CORNERS, 3 );
108
109 if( aTestLocalConcavity.first && !aOutline->Contains( a - dir, -1, 0 ) )
110 return false;
111
112 if( aTestLocalConcavity.second && !aOutline->Contains( b + dir, -1, 0 ) )
113 return false;
114 }
115
116 SEG segPath( a1, a2 );
117
118 if( aLayer != Edge_Cuts )
119 {
120 for( PCB_TRACK* track : aBoard.Tracks() )
121 {
122 if( !track )
123 continue;
124
125 if( track->Type() == KICAD_T::PCB_TRACE_T && track->IsOnLayer( aLayer ) )
126 {
127 std::shared_ptr<SHAPE> sh = track->GetEffectiveShape();
128
129 if( sh && sh->Type() == SHAPE_TYPE::SH_SEGMENT )
130 {
131 SEG segTrack( track->GetStart(), track->GetEnd() );
132
133 if( segPath.Intersects( segTrack ) )
134 return false;
135 }
136 }
137 }
138 }
139 return true;
140 }
141};
142
143
144class GraphConnection;
145class GraphNode;
146class CreepageGraph;
147class CREEP_SHAPE;
148class BE_SHAPE;
149class BE_SHAPE_POINT;
150class BE_SHAPE_ARC;
151class BE_SHAPE_CIRCLE;
152class CU_SHAPE;
153class CU_SHAPE_SEGMENT;
154class CU_SHAPE_CIRCLE;
155class CU_SHAPE_ARC;
156
162{
163public:
164 enum class TYPE
165 {
166 UNDEFINED = 0,
167 POINT,
168 CIRCLE,
169 ARC
170 };
172
173 virtual ~CREEP_SHAPE() {}
174
175
176 virtual int GetRadius() const { return 0; };
177 virtual EDA_ANGLE GetStartAngle() const { return EDA_ANGLE( 0 ); };
178 virtual EDA_ANGLE GetEndAngle() const { return EDA_ANGLE( 0 ); };
179 virtual VECTOR2I GetStartPoint() const { return VECTOR2I( 0, 0 ); };
180 virtual VECTOR2I GetEndPoint() const { return VECTOR2I( 0, 0 ); };
181 VECTOR2I GetPos() const { return m_pos; };
182 CREEP_SHAPE::TYPE GetType() const { return m_type; };
183 const BOARD_ITEM* GetParent() const { return m_parent; };
184 void SetParent( BOARD_ITEM* aParent ) { m_parent = aParent; };
185
186 virtual void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
187 CreepageGraph& aG ) const;
188
189 std::vector<PATH_CONNECTION> ReversePaths( const std::vector<PATH_CONNECTION>& aV ) const
190 {
191 std::vector<PATH_CONNECTION> r;
192 r.reserve( aV.size() );
193
194 for( const auto& pc : aV )
195 {
196 r.emplace_back( pc );
197 std::swap( r.back().a1, r.back().a2 );
198 }
199
200 return r;
201 }
202
203 std::vector<PATH_CONNECTION> Paths( const CREEP_SHAPE& aS2, double aMaxWeight,
204 double aMaxSquaredWeight ) const
205 {
206 std::vector<PATH_CONNECTION> a;
207 return a;
208 };
209 virtual std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_POINT& aS2, double aMaxWeight,
210 double aMaxSquaredWeight ) const
211 {
212 std::vector<PATH_CONNECTION> a;
213 return a;
214 };
215 virtual std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_CIRCLE& aS2, double aMaxWeight,
216 double aMaxSquaredWeight ) const
217 {
218 std::vector<PATH_CONNECTION> a;
219 return a;
220 };
221 virtual std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_ARC& aS2, double aMaxWeight,
222 double aMaxSquaredWeight ) const
223 {
224 std::vector<PATH_CONNECTION> a;
225 return a;
226 };
227 virtual std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_SEGMENT& aS2, double aMaxWeight,
228 double aMaxSquaredWeight ) const
229 {
230 std::vector<PATH_CONNECTION> a;
231 return a;
232 };
233 virtual std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_CIRCLE& aS2, double aMaxWeight,
234 double aMaxSquaredWeight ) const
235 {
236 std::vector<PATH_CONNECTION> a;
237 return a;
238 };
239 virtual std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_ARC& aS2, double aMaxWeight,
240 double aMaxSquaredWeight ) const
241 {
242 std::vector<PATH_CONNECTION> a;
243 return a;
244 };
245
246 //virtual std::vector<PATH_CONNECTION> GetPathsCuToBe( CREEP_SHAPE* aShape ) const{ std::vector<PATH_CONNECTION> a; return a;};
247 bool IsConductive() { return m_conductive; };
248
249
250protected:
251 bool m_conductive = false;
254 CREEP_SHAPE::TYPE m_type = CREEP_SHAPE::TYPE::UNDEFINED;
255};
256
257
262class CU_SHAPE : public CREEP_SHAPE
263{
264public:
266};
267
272class BE_SHAPE : public CREEP_SHAPE
273{
274public:
276};
277
283{
284public:
285 CU_SHAPE_SEGMENT( VECTOR2I aStart, VECTOR2I aEnd, double aWidth = 0 ) : CU_SHAPE()
286 {
287 m_start = aStart;
288 m_end = aEnd;
289 m_width = aWidth;
290 }
291
292 VECTOR2I GetStart() const { return m_start; };
293 VECTOR2I GetEnd() const { return m_end; };
294 double GetWidth() const { return m_width; };
295
296 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_POINT& aS2, double aMaxWeight,
297 double aMaxSquaredWeight ) const override;
298 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_CIRCLE& aS2, double aMaxWeight,
299 double aMaxSquaredWeight ) const override;
300 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_ARC& aS2, double aMaxWeight,
301 double aMaxSquaredWeight ) const override;
302 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_SEGMENT& aS2, double aMaxWeight,
303 double aMaxSquaredWeight ) const override;
304 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_CIRCLE& aS2, double aMaxWeight,
305 double aMaxSquaredWeight ) const override;
306 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_ARC& aS2, double aMaxWeight,
307 double aMaxSquaredWeight ) const override;
308
309
310private:
313 double m_width = 0;
314};
315
321{
322public:
323 CU_SHAPE_CIRCLE( VECTOR2I aPos, double aRadius = 0 ) : CU_SHAPE()
324 {
325 m_pos = aPos;
326 m_radius = aRadius;
327 }
328
329 VECTOR2I GetPos() const { return m_pos; };
330 int GetRadius() const override { return m_radius; };
331
332 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_POINT& aS2, double aMaxWeight,
333 double aMaxSquaredWeight ) const override;
334 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_CIRCLE& aS2, double aMaxWeight,
335 double aMaxSquaredWeight ) const override;
336 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_ARC& aS2, double aMaxWeight,
337 double aMaxSquaredWeight ) const override;
338 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_SEGMENT& aS2, double aMaxWeight,
339 double aMaxSquaredWeight ) const override
340 {
341 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
342 };
343
344 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_CIRCLE& aS2, double aMaxWeight,
345 double aMaxSquaredWeight ) const override;
346 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_ARC& aS2, double aMaxWeight,
347 double aMaxSquaredWeight ) const override;
348
349private:
351 double m_radius = 1;
352};
353
359{
360public:
361 CU_SHAPE_ARC( VECTOR2I aPos, double aRadius, EDA_ANGLE aStartAngle, EDA_ANGLE aEndAngle,
362 VECTOR2D aStartPoint, VECTOR2D aEndPoint ) : CU_SHAPE_CIRCLE( aPos, aRadius )
363 {
364 m_pos = aPos;
365 m_type = CREEP_SHAPE::TYPE::ARC;
366 m_startAngle = aStartAngle;
367 m_endAngle = aEndAngle;
368 m_startPoint = aStartPoint;
369 m_endPoint = aEndPoint;
370 m_radius = aRadius;
371 }
372
373 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_POINT& aS2, double aMaxWeight,
374 double aMaxSquaredWeight ) const override;
375 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_CIRCLE& aS2, double aMaxWeight,
376 double aMaxSquaredWeight ) const override;
377 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_ARC& aS2, double aMaxWeight,
378 double aMaxSquaredWeight ) const override;
379 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_SEGMENT& aS2, double aMaxWeight,
380 double aMaxSquaredWeight ) const override
381 {
382 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
383 };
384 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_CIRCLE& aS2, double aMaxWeight,
385 double aMaxSquaredWeight ) const override
386 {
387 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
388 };
389 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_ARC& aS2, double aMaxWeight,
390 double aMaxSquaredWeight ) const override;
391
392
393 EDA_ANGLE GetStartAngle() const override { return m_startAngle; }
394 EDA_ANGLE GetEndAngle() const override { return m_endAngle; }
395 int GetRadius() const override { return m_radius; }
396
397
398 VECTOR2I GetStartPoint() const override { return m_startPoint; }
399 VECTOR2I GetEndPoint() const override { return m_endPoint; }
401 {
402 EDA_ANGLE angle( aPoint - m_pos );
403 while( angle < GetStartAngle() )
404 angle += ANGLE_360;
405 while( angle > GetEndAngle() + ANGLE_360 )
406 angle -= ANGLE_360;
407
408 return angle;
409 }
410 double GetWidth() const { return m_width; };
411 void SetWidth( double aW ) { m_width = aW; };
412
413private:
414 int m_width = 0;
416 double m_radius = 1;
421};
422
428{
429public:
430 enum TYPE
431 {
432
433 POINT = 0,
437 VIRTUAL
438 };
439
441 {
442 m_parent = aParent;
443 m_pos = aPos;
444 m_type = aType;
445 m_connectDirectly = true;
446 m_connections = {};
447 };
448
450
451
453 std::vector<std::shared_ptr<GraphConnection>> m_connections = {};
455 // Virtual nodes are connected with a 0 weight connection to equivalent net ( same net or netclass )
456 bool m_virtual = false;
457 bool m_connectDirectly = true;
458 int m_net = -1;
459
461};
462
468{
469public:
470 GraphConnection( std::shared_ptr<GraphNode>& aN1, std::shared_ptr<GraphNode>& aN2,
471 const PATH_CONNECTION& aPc ) : n1( aN1 ), n2( aN2 )
472 {
473 m_path = aPc;
474 };
475
476 std::shared_ptr<GraphNode> n1 = nullptr;
477 std::shared_ptr<GraphNode> n2 = nullptr;
479
480 std::vector<PCB_SHAPE> GetShapes();
481 bool forceStraightLigne = false;
482};
483
484
490{
491public:
493 {
494 m_pos = aPos;
495 m_type = CREEP_SHAPE::TYPE::POINT;
496 }
497
498 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_POINT& aS2, double aMaxWeight,
499 double aMaxSquaredWeight ) const override;
500 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_CIRCLE& aS2, double aMaxWeight,
501 double aMaxSquaredWeight ) const override;
502 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_ARC& aS2, double aMaxWeight,
503 double aMaxSquaredWeight ) const override;
504 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_SEGMENT& aS2, double aMaxWeight,
505 double aMaxSquaredWeight ) const override
506 {
507 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
508 };
509 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_CIRCLE& aS2, double aMaxWeight,
510 double aMaxSquaredWeight ) const override
511 {
512 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
513 }
514 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_ARC& aS2, double aMaxWeight,
515 double aMaxSquaredWeight ) const override
516 {
517 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
518 };
519
520
521 void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
522 CreepageGraph& aG ) const override;
523};
524
530{
531public:
532 BE_SHAPE_CIRCLE( VECTOR2I aPos = VECTOR2I( 0, 0 ), int aRadius = 0 ) : BE_SHAPE()
533 {
534 m_pos = aPos;
535 m_radius = aRadius;
536 m_type = CREEP_SHAPE::TYPE::CIRCLE;
537 }
538
539 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_POINT& aS2, double aMaxWeight,
540 double aMaxSquaredWeight ) const override
541 {
542 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
543 };
544 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_CIRCLE& aS2, double aMaxWeight,
545 double aMaxSquaredWeight ) const override;
546 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_ARC& aS2, double aMaxWeight,
547 double aMaxSquaredWeight ) const override;
548 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_SEGMENT& aS2, double aMaxWeight,
549 double aMaxSquaredWeight ) const override
550 {
551 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
552 };
553 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_CIRCLE& aS2, double aMaxWeight,
554 double aMaxSquaredWeight ) const override
555 {
556 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
557 };
558
559
560 int GetRadius() const override { return m_radius; }
561 void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
562 CreepageGraph& aG ) const override;
563 void ShortenChildDueToGV( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
564 CreepageGraph& aG, double aNormalWeight ) const;
565
566
567protected:
569};
570
576{
577public:
578 BE_SHAPE_ARC( VECTOR2I aPos, int aRadius, EDA_ANGLE aStartAngle, EDA_ANGLE aEndAngle,
579 VECTOR2D aStartPoint, VECTOR2D aEndPoint ) : BE_SHAPE_CIRCLE( aPos, aRadius )
580 {
581 m_type = CREEP_SHAPE::TYPE::ARC;
582 m_startAngle = aStartAngle;
583 m_endAngle = aEndAngle;
584 m_startPoint = aStartPoint;
585 m_endPoint = aEndPoint;
586 m_radius = aRadius;
587 }
588
589 void ConnectChildren( std::shared_ptr<GraphNode>& a1, std::shared_ptr<GraphNode>& a2,
590 CreepageGraph& aG ) const override;
591
592
593 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_POINT& aS2, double aMaxWeight,
594 double aMaxSquaredWeight ) const override
595 {
596 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
597 };
598 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_CIRCLE& aS2, double aMaxWeight,
599 double aMaxSquaredWeight ) const override
600 {
601 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
602 };
603 std::vector<PATH_CONNECTION> Paths( const BE_SHAPE_ARC& aS2, double aMaxWeight,
604 double aMaxSquaredWeight ) const override;
605
606 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_SEGMENT& aS2, double aMaxWeight,
607 double aMaxSquaredWeight ) const override
608 {
609 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
610 };
611 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_CIRCLE& aS2, double aMaxWeight,
612 double aMaxSquaredWeight ) const override
613 {
614 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
615 };
616 std::vector<PATH_CONNECTION> Paths( const CU_SHAPE_ARC& aS2, double aMaxWeight,
617 double aMaxSquaredWeight ) const override
618 {
619 return ReversePaths( aS2.Paths( *this, aMaxWeight, aMaxSquaredWeight ) );
620 };
621
622
623 EDA_ANGLE GetStartAngle() const override { return m_startAngle; }
624 EDA_ANGLE GetEndAngle() const override { return m_endAngle; }
625 int GetRadius() const override { return m_radius; }
626
627
628 VECTOR2I GetStartPoint() const override { return m_startPoint; }
629 VECTOR2I GetEndPoint() const override { return m_endPoint; }
631 {
632 EDA_ANGLE angle( aPoint - m_pos );
633
634 while( angle < m_startAngle )
635 angle += ANGLE_360;
636 while( angle > m_endAngle + ANGLE_360 )
637 angle -= ANGLE_360;
638
639 return angle;
640 }
641
642 std::pair<bool, bool> IsThereATangentPassingThroughPoint( const BE_SHAPE_POINT aPoint ) const;
643
644protected:
650};
651
652
658{
659public:
660 CreepageGraph( BOARD& aBoard ) : m_board( aBoard )
661 {
662 m_boardOutline = nullptr;
663 m_creepageTarget = -1;
665 };
667 {
668 for( CREEP_SHAPE* cs : m_shapeCollection )
669 if( cs )
670 {
671 delete cs;
672 cs = nullptr;
673 }
674 };
675
677 std::vector<BOARD_ITEM*> m_boardEdge;
679
680 std::vector<std::shared_ptr<GraphNode>> m_nodes;
681 std::vector<std::shared_ptr<GraphConnection>> m_connections;
682
683
685 void TransformCreepShapesToNodes( std::vector<CREEP_SHAPE*>& aShapes );
687 // Add a node to the graph. If an equivalent node exists, returns the pointer of the existing node instead
688 std::shared_ptr<GraphNode> AddNode( GraphNode::TYPE aType, CREEP_SHAPE* aParent = nullptr,
689 VECTOR2I aPos = VECTOR2I() );
690 std::shared_ptr<GraphNode> AddNodeVirtual();
691 std::shared_ptr<GraphConnection> AddConnection( std::shared_ptr<GraphNode>& aN1,
692 std::shared_ptr<GraphNode>& aN2,
693 const PATH_CONNECTION& aPc );
694 std::shared_ptr<GraphConnection> AddConnection( std::shared_ptr<GraphNode>& aN1,
695 std::shared_ptr<GraphNode>& aN2 );
696 std::shared_ptr<GraphNode> FindNode( GraphNode::TYPE aType, CREEP_SHAPE* aParent,
697 VECTOR2I aPos );
698
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,
702 BOARD_ITEM* aParent = nullptr );
703
704 double Solve( std::shared_ptr<GraphNode>& aFrom, std::shared_ptr<GraphNode>& aTo,
705 std::vector<std::shared_ptr<GraphConnection>>& aResult );
706
707 void GeneratePaths( double aMaxWeight, PCB_LAYER_ID aLayer, bool aGenerateBoardEdges = true );
708 std::shared_ptr<GraphNode> AddNetElements( int aNetCode, PCB_LAYER_ID aLayer,
709 int aMaxCreepage );
710
711 void SetTarget( double aTarget );
712 double GetTarget() { return m_creepageTarget; };
714
715 std::vector<CREEP_SHAPE*> m_shapeCollection;
716
717private:
720};
721
722
723#endif
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
EDA_ANGLE m_endAngle
VECTOR2I GetStartPoint() const override
EDA_ANGLE m_startAngle
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...
Definition: board_item.h:79
Information pertinent to a Pcbnew printed circuit board.
Definition: board.h:290
const TRACKS & Tracks() const
Definition: board.h:329
A class used to represent the shapes for creepage calculation.
VECTOR2I GetPos() const
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)
CREEP_SHAPE::TYPE m_type
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 ~CREEP_SHAPE()
virtual int GetRadius() const
const BOARD_ITEM * GetParent() const
BOARD_ITEM * m_parent
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 m_startAngle
void SetWidth(double aW)
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
EDA_ANGLE m_endAngle
double GetWidth() const
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
VECTOR2I GetPos() const
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
double GetWidth() const
VECTOR2I GetEnd() 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
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)
a connection in a
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)
PATH_CONNECTION m_path
CREEP_SHAPE * m_parent
GraphNode(GraphNode::TYPE aType, CREEP_SHAPE *aParent, VECTOR2I aPos=VECTOR2I())
std::vector< std::shared_ptr< GraphConnection > > m_connections
GraphNode::TYPE m_type
Definition: seg.h:42
bool Intersects(const SEG &aSeg) const
Definition: seg.cpp:248
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.
Definition: shape.h:126
constexpr extended_type SquaredEuclideanNorm() const
Compute the squared euclidean norm of the vector, which is defined as (x ** 2 + y ** 2).
Definition: vector2d.h:307
The common library.
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
Definition: eda_angle.h:407
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:60
@ Edge_Cuts
Definition: layer_ids.h:112
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.
VECTOR2< int32_t > VECTOR2I
Definition: vector2d.h:691