KiCad PCB EDA Suite
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 <hillbrand@ucdavis.edu>
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 
32 namespace PNS {
33 
34 class NODE;
35 
36 class ARC : public LINKED_ITEM
37 {
38 public:
39  ARC() :
41  {}
42 
43  ARC( const SHAPE_ARC& aArc, int aNet ) :
44  LINKED_ITEM( ARC_T ),
45  m_arc( aArc )
46  {
47  m_net = aNet;
48  }
49 
50  ARC( const ARC& aParentArc, const SHAPE_ARC& aArc ) :
51  LINKED_ITEM( ARC_T ),
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 ) :
61  LINKED_ITEM( ARC_T ),
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 
117 private:
119 };
120 
121 }
122 
123 #endif
Base class for PNS router board items.
Definition: pns_item.h:55
OPT_BOX2I ChangedArea(const ARC *aOther) const
Definition: pns_arc.cpp:46
ARC()
Definition: pns_arc.h:39
int Width() const override
Definition: pns_arc.h:87
int Rank() const override
Definition: pns_line.cpp:1053
static bool ClassOf(const ITEM *aItem)
Definition: pns_arc.h:70
LAYER_RANGE m_layers
Definition: pns_item.h:246
int m_rank
Definition: pns_item.h:251
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition: pns_line.h:60
SHAPE_ARC & Arc()
Definition: pns_arc.h:114
SHAPE_ARC m_arc
Definition: pns_arc.h:118
int m_marker
Definition: pns_item.h:250
virtual int AnchorCount() const override
Definition: pns_arc.h:107
int Net() const
Definition: pns_item.h:150
const VECTOR2I & GetP0() const
Definition: shape_arc.h:111
void SetWidth(int aWidth) override
Definition: pns_arc.h:82
An abstract shape on 2D plane.
Definition: shape.h:116
ARC * Clone() const override
Return a deep copy of the item.
Definition: pns_arc.cpp:34
ARC(const ARC &aParentArc, const SHAPE_ARC &aArc)
Definition: pns_arc.h:50
int m_net
Definition: pns_item.h:249
const SHAPE_LINE_CHAIN Hull(int aClearance, int aWalkaroundThickness, int aLayer) const override
Definition: pns_arc.cpp:28
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition: pns_arc.h:77
int GetWidth() const
Definition: shape_arc.h:156
virtual int Rank() const
Definition: pns_item.h:213
virtual int Marker() const override
Definition: pns_line.cpp:108
Represent a polyline (an zero-thickness chain of connected line segments).
const SHAPE_LINE_CHAIN CLine() const
Definition: pns_arc.h:92
OPT< BOX2I > OPT_BOX2I
Definition: box2.h:509
ARC(const SHAPE_ARC &aArc, int aNet)
Definition: pns_arc.h:43
PnsKind Kind() const
Return the type (kind) of the item.
Definition: pns_item.h:128
ARC(const LINE &aParentLine, const SHAPE_ARC &aArc)
Definition: pns_arc.h:60
void SetWidth(int aWidth)
Definition: shape_arc.h:151
Push and Shove diff pair dimensions (gap) settings dialog.
virtual VECTOR2I Anchor(int n) const override
Definition: pns_arc.h:99
const VECTOR2I & GetP1() const
Definition: shape_arc.h:112
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152
virtual int Marker() const
Definition: pns_item.h:210
const SHAPE_ARC & CArc() const
Definition: pns_arc.h:115