Horizon
Loading...
Searching...
No Matches
pns_arc.h
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_line_chain.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() :
40 LINKED_ITEM( ARC_T )
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
117private:
118 SHAPE_ARC m_arc;
119};
120
121}
122
123#endif
Definition pns_arc.h:37
const SHAPE * Shape() const override
Return the geometrical shape of the item.
Definition pns_arc.h:77
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:57
PnsKind Kind() const
Return the type (kind) of the item.
Definition pns_item.h:131
Represents a track on a PCB, connecting two non-trivial joints (that is, vias, pads,...
Definition pns_line.h:61
int Width() const
Return true if the line is geometrically identical as line aOther.
Definition pns_line.h:156
Definition pns_linked_item.h:30
Definition shape_arc.h:36
Represent a polyline containing arcs as well as line segments: A chain of connected line and/or arc s...
Definition shape_line_chain.h:81
An abstract shape on 2D plane.
Definition shape.h:117