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>
27 #include <geometry/shape_segment.h>
29 
30 #include "pns_line.h"
31 #include "pns_linked_item.h"
32 
33 namespace PNS {
34 
35 class NODE;
36 
37 class ARC : public LINKED_ITEM
38 {
39 public:
40  ARC() :
42  {}
43 
44  ARC( const SHAPE_ARC& aArc, int aNet ) :
45  LINKED_ITEM( ARC_T ),
46  m_arc( aArc )
47  {
48  m_net = aNet;
49  }
50 
51  ARC( const ARC& aParentArc, const SHAPE_ARC& aArc ) :
52  LINKED_ITEM( ARC_T ),
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 ) :
62  LINKED_ITEM( ARC_T ),
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 private:
117 };
118 
119 }
120 
121 #endif
ITEM.
Definition: pns_item.h:54
ARC()
Definition: pns_arc.h:40
int Width() const override
Definition: pns_arc.h:88
int Rank() const override
Definition: pns_line.cpp:848
const SHAPE_LINE_CHAIN Hull(int aClearance, int aWalkaroundThickness, int aLayer) const override
Definition: pns_arc.cpp:32
static bool ClassOf(const ITEM *aItem)
Definition: pns_arc.h:71
LAYER_RANGE m_layers
Definition: pns_item.h:259
int m_rank
Definition: pns_item.h:264
SHAPE_ARC m_arc
Definition: pns_arc.h:116
int m_marker
Definition: pns_item.h:263
OPT_BOX2I ChangedArea(const ARC *aOther) const
Definition: pns_arc.cpp:50
virtual int AnchorCount() const override
Definition: pns_arc.h:108
int Net() const
Definition: pns_item.h:150
const VECTOR2I & GetP0() const
Definition: shape_arc.h:85
void SetWidth(int aWidth) override
Definition: pns_arc.h:83
SHAPE.
Definition: shape.h:122
ARC(const ARC &aParentArc, const SHAPE_ARC &aArc)
Definition: pns_arc.h:51
int m_net
Definition: pns_item.h:262
const SHAPE * Shape() const override
Function Shape()
Definition: pns_arc.h:78
int GetWidth() const
Definition: shape_arc.h:102
virtual int Rank() const
Definition: pns_item.h:230
virtual int Marker() const override
Definition: pns_line.cpp:107
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN CLine() const
Definition: pns_arc.h:93
ARC * Clone() const override
Function Clone()
Definition: pns_arc.cpp:38
OPT< BOX2I > OPT_BOX2I
Definition: box2.h:525
ARC(const SHAPE_ARC &aArc, int aNet)
Definition: pns_arc.h:44
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:124
ARC(const LINE &aParentLine, const SHAPE_ARC &aArc)
Definition: pns_arc.h:61
void SetWidth(int aWidth)
Definition: shape_arc.h:97
Push and Shove diff pair dimensions (gap) settings dialog.
virtual VECTOR2I Anchor(int n) const override
Definition: pns_arc.h:100
const VECTOR2I & GetP1() const
Definition: shape_arc.h:86
const LAYER_RANGE & Layers() const
Definition: pns_item.h:152
virtual int Marker() const
Definition: pns_item.h:227