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 (C) 2019-2023 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 along
19 * with this program. If not, see <http://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_net = aParentArc.Net();
56 m_layers = aParentArc.Layers();
57 m_marker = aParentArc.Marker();
58 m_rank = aParentArc.Rank();
59 }
60
61 ARC( const LINE& aParentLine, const SHAPE_ARC& aArc ) :
63 m_arc( aArc.GetP0(), aArc.GetArcMid(), aArc.GetP1(), aParentLine.Width() )
64 {
65 m_net = aParentLine.Net();
66 m_layers = aParentLine.Layers();
67 m_marker = aParentLine.Marker();
68 m_rank = aParentLine.Rank();
69 }
70
71 static inline bool ClassOf( const ITEM* aItem )
72 {
73 return aItem && ARC_T == aItem->Kind();
74 }
75
76 ARC* Clone() const override;
77
78 const SHAPE* Shape() const override
79 {
80 return static_cast<const SHAPE*>( &m_arc );
81 }
82
83 void SetWidth( int aWidth ) override
84 {
85 m_arc.SetWidth(aWidth);
86 }
87
88 int Width() const override
89 {
90 return m_arc.GetWidth();
91 }
92
93 const SHAPE_LINE_CHAIN CLine() const
94 {
95 return SHAPE_LINE_CHAIN( m_arc );
96 }
97
98 const SHAPE_LINE_CHAIN Hull( int aClearance, int aWalkaroundThickness, int aLayer ) const override;
99
100 virtual VECTOR2I Anchor( int n ) const override
101 {
102 if( n == 0 )
103 return m_arc.GetP0();
104 else
105 return m_arc.GetP1();
106 }
107
108 virtual int AnchorCount() const override
109 {
110 return 2;
111 }
112
113 OPT_BOX2I ChangedArea( const ARC* aOther ) const;
114
115 SHAPE_ARC& Arc() { return m_arc; }
116 const SHAPE_ARC& CArc() const { return m_arc; }
117
118private:
120};
121
122}
123
124#endif
std::optional< BOX2I > OPT_BOX2I
Definition: box2.h:926
const SHAPE_LINE_CHAIN CLine() const
Definition: pns_arc.h:93
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:88
virtual VECTOR2I Anchor(int n) const override
Definition: pns_arc.h:100
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_arc.h:78
virtual int AnchorCount() const override
Definition: pns_arc.h:108
ARC(const ARC &aParentArc, const SHAPE_ARC &aArc)
Definition: pns_arc.h:51
OPT_BOX2I ChangedArea(const ARC *aOther) const
Definition: pns_arc.cpp:46
SHAPE_ARC & Arc()
Definition: pns_arc.h:115
SHAPE_ARC m_arc
Definition: pns_arc.h:119
ARC()
Definition: pns_arc.h:40
void SetWidth(int aWidth) override
Definition: pns_arc.h:83
ARC(const SHAPE_ARC &aArc, NET_HANDLE aNet)
Definition: pns_arc.h:44
static bool ClassOf(const ITEM *aItem)
Definition: pns_arc.h:71
const SHAPE_ARC & CArc() const
Definition: pns_arc.h:116
ARC(const LINE &aParentLine, const SHAPE_ARC &aArc)
Definition: pns_arc.h:61
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:97
virtual int Rank() const
Definition: pns_item.h:236
const PNS_LAYER_RANGE & Layers() const
Definition: pns_item.h:197
virtual NET_HANDLE Net() const
Definition: pns_item.h:195
PNS_LAYER_RANGE m_layers
Definition: pns_item.h:289
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:168
NET_HANDLE m_net
Definition: pns_item.h:292
int m_marker
Definition: pns_item.h:293
virtual int Marker() const
Definition: pns_item.h:233
int m_rank
Definition: pns_item.h:294
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:62
int Rank() const override
Definition: pns_line.cpp:1117
virtual int Marker() const override
Definition: pns_line.cpp:142
int GetWidth() const
Definition: shape_arc.h:168
void SetWidth(int aWidth)
Definition: shape_arc.h:163
const VECTOR2I & GetP1() const
Definition: shape_arc.h:115
const VECTOR2I & GetP0() const
Definition: shape_arc.h:114
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:126
Push and Shove diff pair dimensions (gap) settings dialog.
void * NET_HANDLE
Definition: pns_item.h:54