KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pns_arc.h
Go to the documentation of this file.
1/*
2 * KiRouter - a push-and-(sometimes-)shove PCB router
3 *
4 * Copyright (C) 2019 CERN
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 * Author: Seth Hillbrand <[email protected]>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation, either version 3 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <https://www.gnu.org/licenses/>.
20 */
21
22#ifndef __PNS_ARC_H
23#define __PNS_ARC_H
24
25#include <math/vector2d.h>
26
27#include <geometry/shape_arc.h>
29
30#include "pns_line.h"
31#include "pns_linked_item.h"
32
33namespace PNS {
34
35class NODE;
36
37class ARC : public LINKED_ITEM
38{
39public:
40 ARC() :
42 {}
43
44 ARC( const SHAPE_ARC& aArc, NET_HANDLE aNet ) :
46 m_arc( aArc )
47 {
48 m_net = aNet;
49 }
50
51 ARC( const ARC& aParentArc, const SHAPE_ARC& aArc ) :
53 m_arc( aArc )
54 {
55 m_sourceItem = aParentArc.GetSourceItem();
56 m_net = aParentArc.Net();
57 m_layers = aParentArc.Layers();
58 m_marker = aParentArc.Marker();
59 m_rank = aParentArc.Rank();
60 }
61
62 ARC( const LINE& aParentLine, const SHAPE_ARC& aArc ) :
64 m_arc( aArc.GetP0(), aArc.GetArcMid(), aArc.GetP1(), aParentLine.Width() )
65 {
66 m_sourceItem = aParentLine.GetSourceItem();
67 m_net = aParentLine.Net();
68 m_layers = aParentLine.Layers();
69 m_marker = aParentLine.Marker();
70 m_rank = aParentLine.Rank();
71 }
72
73 static inline bool ClassOf( const ITEM* aItem )
74 {
75 return aItem && ARC_T == aItem->Kind();
76 }
77
78 ARC* Clone() const override;
79
80 const SHAPE* Shape( int aLayer ) const override
81 {
82 return static_cast<const SHAPE*>( &m_arc );
83 }
84
85 void SetWidth( int aWidth ) override
86 {
87 m_arc.SetWidth(aWidth);
88 }
89
90 int Width() const override
91 {
92 return m_arc.GetWidth();
93 }
94
95 const SHAPE_LINE_CHAIN CLine() const
96 {
97 return SHAPE_LINE_CHAIN( m_arc );
98 }
99
100 const SHAPE_LINE_CHAIN Hull( int aClearance, int aWalkaroundThickness, int aLayer ) const override;
101
102 virtual VECTOR2I Anchor( int n ) const override
103 {
104 if( n == 0 )
105 return m_arc.GetP0();
106 else
107 return m_arc.GetP1();
108 }
109
110 virtual int AnchorCount() const override
111 {
112 return 2;
113 }
114
115 OPT_BOX2I ChangedArea( const ARC* aOther ) const;
116
117 SHAPE_ARC& Arc() { return m_arc; }
118 const SHAPE_ARC& CArc() const { return m_arc; }
119
120private:
122};
123
124}
125
126#endif
std::optional< BOX2I > OPT_BOX2I
Definition box2.h:921
const SHAPE_LINE_CHAIN CLine() const
Definition pns_arc.h:95
const SHAPE_LINE_CHAIN Hull(int aClearance, int aWalkaroundThickness, int aLayer) const override
Definition pns_arc.cpp:28
int Width() const override
Definition pns_arc.h:90
virtual VECTOR2I Anchor(int n) const override
Definition pns_arc.h:102
virtual int AnchorCount() const override
Definition pns_arc.h:110
ARC(const ARC &aParentArc, const SHAPE_ARC &aArc)
Definition pns_arc.h:51
OPT_BOX2I ChangedArea(const ARC *aOther) const
Definition pns_arc.cpp:51
SHAPE_ARC & Arc()
Definition pns_arc.h:117
SHAPE_ARC m_arc
Definition pns_arc.h:121
void SetWidth(int aWidth) override
Definition pns_arc.h:85
ARC(const SHAPE_ARC &aArc, NET_HANDLE aNet)
Definition pns_arc.h:44
const SHAPE * Shape(int aLayer) const override
Return the geometrical shape of the item.
Definition pns_arc.h:80
static bool ClassOf(const ITEM *aItem)
Definition pns_arc.h:73
const SHAPE_ARC & CArc() const
Definition pns_arc.h:118
ARC(const LINE &aParentLine, const SHAPE_ARC &aArc)
Definition pns_arc.h:62
ARC * Clone() const override
Return a deep copy of the item.
Definition pns_arc.cpp:34
Base class for PNS router board items.
Definition pns_item.h:98
BOARD_ITEM * m_sourceItem
Definition pns_item.h:323
virtual int Rank() const
Definition pns_item.h:270
const PNS_LAYER_RANGE & Layers() const
Definition pns_item.h:212
virtual NET_HANDLE Net() const
Definition pns_item.h:210
PNS_LAYER_RANGE m_layers
Definition pns_item.h:327
PnsKind Kind() const
Return the type (kind) of the item.
Definition pns_item.h:173
BOARD_ITEM * GetSourceItem() const
Definition pns_item.h:202
NET_HANDLE m_net
Definition pns_item.h:330
int m_marker
Definition pns_item.h:331
virtual int Marker() const
Definition pns_item.h:267
int m_rank
Definition pns_item.h:332
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:62
int Rank() const override
virtual int Marker() const override
Definition pns_line.cpp:187
LINKED_ITEM(PnsKind aKind)
Keep the router "world" - i.e.
Definition pns_node.h:274
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
An abstract shape on 2D plane.
Definition shape.h:124
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition pns_item.h:55
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708