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 * Author: Seth Hillbrand <[email protected]>
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __PNS_ARC_H
22#define __PNS_ARC_H
23
24#include <math/vector2d.h>
25
26#include <geometry/shape_arc.h>
28
29#include "pns_line.h"
30#include "pns_linked_item.h"
31
32namespace PNS {
33
34class NODE;
35
36class ARC : public LINKED_ITEM
37{
38public:
39 ARC() :
41 {}
42
43 ARC( const SHAPE_ARC& aArc, int aNet ) :
45 m_arc( aArc )
46 {
47 m_net = aNet;
48 }
49
50 ARC( const ARC& aParentArc, const SHAPE_ARC& aArc ) :
52 m_arc( aArc )
53 {
54 m_net = aParentArc.Net();
55 m_layers = aParentArc.Layers();
56 m_marker = aParentArc.Marker();
57 m_rank = aParentArc.Rank();
58 }
59
60 ARC( const LINE& aParentLine, const SHAPE_ARC& aArc ) :
62 m_arc( aArc.GetP0(), aArc.GetArcMid(), aArc.GetP1(), aParentLine.Width() )
63 {
64 m_net = aParentLine.Net();
65 m_layers = aParentLine.Layers();
66 m_marker = aParentLine.Marker();
67 m_rank = aParentLine.Rank();
68 }
69
70 static inline bool ClassOf( const ITEM* aItem )
71 {
72 return aItem && ARC_T == aItem->Kind();
73 }
74
75 ARC* Clone() const override;
76
77 const SHAPE* Shape() const override
78 {
79 return static_cast<const SHAPE*>( &m_arc );
80 }
81
82 void SetWidth( int aWidth ) override
83 {
84 m_arc.SetWidth(aWidth);
85 }
86
87 int Width() const override
88 {
89 return m_arc.GetWidth();
90 }
91
92 const SHAPE_LINE_CHAIN CLine() const
93 {
94 return SHAPE_LINE_CHAIN( m_arc );
95 }
96
97 const SHAPE_LINE_CHAIN Hull( int aClearance, int aWalkaroundThickness, int aLayer ) const override;
98
99 virtual VECTOR2I Anchor( int n ) const override
100 {
101 if( n == 0 )
102 return m_arc.GetP0();
103 else
104 return m_arc.GetP1();
105 }
106
107 virtual int AnchorCount() const override
108 {
109 return 2;
110 }
111
112 OPT_BOX2I ChangedArea( const ARC* aOther ) const;
113
114 SHAPE_ARC& Arc() { return m_arc; }
115 const SHAPE_ARC& CArc() const { return m_arc; }
116
117private:
119};
120
121}
122
123#endif
std::optional< BOX2I > OPT_BOX2I
Definition: box2.h:850
const SHAPE_LINE_CHAIN CLine() const
Definition: pns_arc.h:92
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:87
virtual VECTOR2I Anchor(int n) const override
Definition: pns_arc.h:99
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_arc.h:77
virtual int AnchorCount() const override
Definition: pns_arc.h:107
ARC(const ARC &aParentArc, const SHAPE_ARC &aArc)
Definition: pns_arc.h:50
OPT_BOX2I ChangedArea(const ARC *aOther) const
Definition: pns_arc.cpp:46
SHAPE_ARC & Arc()
Definition: pns_arc.h:114
SHAPE_ARC m_arc
Definition: pns_arc.h:118
ARC()
Definition: pns_arc.h:39
void SetWidth(int aWidth) override
Definition: pns_arc.h:82
static bool ClassOf(const ITEM *aItem)
Definition: pns_arc.h:70
const SHAPE_ARC & CArc() const
Definition: pns_arc.h:115
ARC(const LINE &aParentLine, const SHAPE_ARC &aArc)
Definition: pns_arc.h:60
ARC(const SHAPE_ARC &aArc, int aNet)
Definition: pns_arc.h:43
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:91
virtual int Rank() const
Definition: pns_item.h:230
int m_net
Definition: pns_item.h:285
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:162
LAYER_RANGE m_layers
Definition: pns_item.h:282
virtual int Net() const
Definition: pns_item.h:189
const LAYER_RANGE & Layers() const
Definition: pns_item.h:191
int m_marker
Definition: pns_item.h:286
virtual int Marker() const
Definition: pns_item.h:227
int m_rank
Definition: pns_item.h:287
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:61
virtual int Marker() const override
Definition: pns_line.cpp:128
int Rank() const override
Definition: pns_line.cpp:1080
int GetWidth() const
Definition: shape_arc.h:157
void SetWidth(int aWidth)
Definition: shape_arc.h:152
const VECTOR2I & GetP1() const
Definition: shape_arc.h:113
const VECTOR2I & GetP0() const
Definition: shape_arc.h:112
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.