KiCad PCB EDA Suite
shape_simple.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2015 Kicad Developers, see change_log.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef __SHAPE_SIMPLE_H
25 #define __SHAPE_SIMPLE_H
26 
27 #include <geometry/seg.h>
28 #include <geometry/shape.h>
30 #include <math/box2.h>
31 #include <math/vector2d.h>
32 
42 class SHAPE_SIMPLE : public SHAPE
43 {
44 public:
50  SHAPE( SH_SIMPLE )
51  {
52  m_points.SetClosed( true );
53  }
54 
55  SHAPE_SIMPLE( const SHAPE_SIMPLE& aOther ) :
56  SHAPE( SH_SIMPLE ), m_points( aOther.m_points )
57  {}
58 
59  SHAPE* Clone() const override
60  {
61  return new SHAPE_SIMPLE( *this );
62  }
63 
68  void Clear()
69  {
70  m_points.Clear();
71  }
72 
74  const BOX2I BBox( int aClearance = 0 ) const override
75  {
76  return m_points.BBox( aClearance );
77  }
78 
85  int PointCount() const
86  {
87  return m_points.PointCount();
88  }
89 
99  const VECTOR2I& CPoint( int aIndex ) const
100  {
101  return m_points.CPoint( aIndex );
102  }
103 
112  const VECTOR2D CDPoint( int aIndex ) const
113  {
114  const VECTOR2I& v = CPoint( aIndex );
115  return VECTOR2D( v.x, v.y );
116  }
117 
125  const SHAPE_LINE_CHAIN& Vertices() const
126  {
127  return m_points;
128  }
129 
137  void Append( int aX, int aY )
138  {
139  VECTOR2I v( aX, aY );
140  Append( v );
141  }
142 
149  void Append( const VECTOR2I& aP )
150  {
151  m_points.Append( aP );
152  }
153 
155  bool Collide( const SEG& aSeg, int aClearance = 0 ) const override
156  {
157  return m_points.Collide( aSeg, aClearance );
158  }
159 
160  void Move( const VECTOR2I& aVector ) override
161  {
162  m_points.Move( aVector );
163  }
164 
165  bool IsSolid() const override
166  {
167  return true;
168  }
169 
170 private:
171  // vertices
173 };
174 
175 #endif // __SHAPE_SIMPLE_H
SHAPE_SIMPLE.
Definition: shape_simple.h:42
const VECTOR2I & CPoint(int aIndex) const
Function Point()
Definition: shape_simple.h:99
void Move(const VECTOR2I &aVector) override
const BOX2I BBox(int aClearance=0) const override
Function BBox()
Definition: shape_simple.h:74
int PointCount() const
Function PointCount()
void Append(const VECTOR2I &aP)
Function Append()
Definition: shape_simple.h:149
SHAPE * Clone() const override
Function Clone()
Definition: shape_simple.h:59
bool Collide(const VECTOR2I &aP, int aClearance=0) const override
Function Collide()
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
bool Collide(const SEG &aSeg, int aClearance=0) const override
Function Collide()
Definition: shape_simple.h:155
const VECTOR2I & CPoint(int aIndex) const
Function Point()
void SetClosed(bool aClosed)
Function SetClosed()
const VECTOR2D CDPoint(int aIndex) const
Function CDPoint()
Definition: shape_simple.h:112
const BOX2I BBox(int aClearance=0) const override
Function BBox()
VECTOR2< double > VECTOR2D
Definition: vector2d.h:593
SHAPE_SIMPLE(const SHAPE_SIMPLE &aOther)
Definition: shape_simple.h:55
const SHAPE_LINE_CHAIN & Vertices() const
Function Vertices()
Definition: shape_simple.h:125
SHAPE_SIMPLE()
Constructor Creates an empty polygon.
Definition: shape_simple.h:49
SHAPE.
Definition: shape.h:60
bool IsSolid() const override
Definition: shape_simple.h:165
void Clear()
Function Clear() Removes all points from the polygon.
Definition: shape_simple.h:68
Definition: seg.h:39
SHAPE_LINE_CHAIN m_points
Definition: shape_simple.h:172
SHAPE_LINE_CHAIN.
int PointCount() const
Function PointCount()
Definition: shape_simple.h:85
void Clear()
Function Clear() Removes all points from the line chain.
circle
Definition: shape.h:49
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:137
void Move(const VECTOR2I &aVector) override
Definition: shape_simple.h:160