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:
41  {}
42 
43  ARC( const SHAPE_ARC& aArc, int aNet ) : LINKED_ITEM( ARC_T ), m_arc( aArc )
44  {
45  m_net = aNet;
46  }
47 
48  ARC( const ARC& aParentArc, const SHAPE_ARC& aArc )
49  : LINKED_ITEM( ARC_T ),
50  m_arc( aArc )
51  {
52  m_net = aParentArc.Net();
53  m_layers = aParentArc.Layers();
54  m_marker = aParentArc.Marker();
55  m_rank = aParentArc.Rank();
56  }
57 
58  ARC( const LINE& aParentLine, const SHAPE_ARC& aArc ) :
59  LINKED_ITEM( ARC_T ),
60  m_arc( aArc.GetP0(), aArc.GetArcMid(), aArc.GetP1(), aParentLine.Width() )
61  {
62  m_net = aParentLine.Net();
63  m_layers = aParentLine.Layers();
64  m_marker = aParentLine.Marker();
65  m_rank = aParentLine.Rank();
66  }
67 
68  static inline bool ClassOf( const ITEM* aItem )
69  {
70  return aItem && ARC_T == aItem->Kind();
71  }
72 
73  ARC* Clone() const override;
74 
75  const SHAPE* Shape() const override
76  {
77  return static_cast<const SHAPE*>( &m_arc );
78  }
79 
80  void SetWidth( int aWidth ) override
81  {
82  m_arc.SetWidth(aWidth);
83  }
84 
85  int Width() const override
86  {
87  return m_arc.GetWidth();
88  }
89 
90  const SHAPE_LINE_CHAIN CLine() const
91  {
92  return SHAPE_LINE_CHAIN( m_arc );
93  }
94 
95  const SHAPE_LINE_CHAIN Hull( int aClearance, int aWalkaroundThickness, int aLayer ) const override;
96 
97  virtual VECTOR2I Anchor( int n ) const override
98  {
99  if( n == 0 )
100  return m_arc.GetP0();
101  else
102  return m_arc.GetP1();
103  }
104 
105  virtual int AnchorCount() const override
106  {
107  return 2;
108  }
109 
110  OPT_BOX2I ChangedArea( const ARC* aOther ) const;
111 
112 private:
114 };
115 
116 }
117 
118 #endif
ITEM.
Definition: pns_item.h:53
ARC()
Definition: pns_arc.h:40
int Width() const override
Definition: pns_arc.h:85
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:68
LAYER_RANGE m_layers
Definition: pns_item.h:258
int m_rank
Definition: pns_item.h:263
SHAPE_ARC m_arc
Definition: pns_arc.h:113
int m_marker
Definition: pns_item.h:262
OPT_BOX2I ChangedArea(const ARC *aOther) const
Definition: pns_arc.cpp:46
virtual int AnchorCount() const override
Definition: pns_arc.h:105
int Net() const
Definition: pns_item.h:149
const VECTOR2I & GetP0() const
Definition: shape_arc.h:69
void SetWidth(int aWidth) override
Definition: pns_arc.h:80
SHAPE.
Definition: shape.h:120
ARC(const ARC &aParentArc, const SHAPE_ARC &aArc)
Definition: pns_arc.h:48
int m_net
Definition: pns_item.h:261
const SHAPE * Shape() const override
Function Shape()
Definition: pns_arc.h:75
int GetWidth() const
Definition: shape_arc.h:84
virtual int Rank() const
Definition: pns_item.h:229
virtual int Marker() const override
Definition: pns_line.cpp:107
SHAPE_LINE_CHAIN.
const SHAPE_LINE_CHAIN CLine() const
Definition: pns_arc.h:90
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:43
PnsKind Kind() const
Function Kind()
Definition: pns_item.h:123
ARC(const LINE &aParentLine, const SHAPE_ARC &aArc)
Definition: pns_arc.h:58
void SetWidth(int aWidth)
Definition: shape_arc.h:79
Push and Shove diff pair dimensions (gap) settings dialog.
virtual VECTOR2I Anchor(int n) const override
Definition: pns_arc.h:97
const VECTOR2I & GetP1() const
Definition: shape_arc.h:70
const LAYER_RANGE & Layers() const
Definition: pns_item.h:151
virtual int Marker() const
Definition: pns_item.h:226