Horizon
shape_simple.h
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 <vector>
28
29#include <geometry/shape.h>
30#include <geometry/seg.h>
31#include <geometry/shape_line_chain.h>
32
42class SHAPE_SIMPLE : public SHAPE
43{
44public:
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 VECTOR2I& Point( int aIndex )
100 {
101 return m_points.Point( aIndex );
102 }
103
113 const VECTOR2I& CPoint( int aIndex ) const
114 {
115 return m_points.CPoint( aIndex );
116 }
117
126 const VECTOR2D CDPoint( int aIndex ) const
127 {
128 const VECTOR2I& v = CPoint( aIndex );
129 return VECTOR2D( v.x, v.y );
130 }
131
140 {
141 return m_points;
142 }
143
151 void Append( int aX, int aY )
152 {
153 VECTOR2I v( aX, aY );
154 Append( v );
155 }
156
163 void Append( const VECTOR2I& aP )
164 {
165 m_points.Append( aP );
166 }
167
169 bool Collide( const SEG& aSeg, int aClearance = 0 ) const override
170 {
171 return m_points.Collide( aSeg, aClearance );
172 }
173
174 void Move( const VECTOR2I& aVector ) override
175 {
176 m_points.Move( aVector );
177 }
178
179 bool IsSolid() const override
180 {
181 return true;
182 }
183
184private:
185 // vertices
186 SHAPE_LINE_CHAIN m_points;
187};
188
189#endif // __SHAPE_SIMPLE_H
Definition: seg.h:37
Class SHAPE_LINE_CHAIN.
Definition: shape_line_chain.h:50
void SetClosed(bool aClosed)
Function SetClosed()
Definition: shape_line_chain.h:164
int PointCount() const
Function PointCount()
Definition: shape_line_chain.h:218
void Clear()
Function Clear() Removes all points from the line chain.
Definition: shape_line_chain.h:151
void Append(int aX, int aY, bool aAllowDuplication=false)
Function Append()
Definition: shape_line_chain.h:383
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
Definition: shape_line_chain.h:285
VECTOR2I & Point(int aIndex)
Function Point()
Definition: shape_line_chain.h:270
bool Collide(const VECTOR2I &aP, int aClearance=0) const override
Function Collide()
Definition: shape_line_chain.cpp:49
const BOX2I BBox(int aClearance=0) const override
Function BBox()
Definition: shape_line_chain.h:317
Class SHAPE_SIMPLE.
Definition: shape_simple.h:43
void Clear()
Function Clear() Removes all points from the polygon.
Definition: shape_simple.h:68
const SHAPE_LINE_CHAIN & Vertices() const
Function Vertices()
Definition: shape_simple.h:139
void Append(int aX, int aY)
Function Append()
Definition: shape_simple.h:151
SHAPE * Clone() const override
Function Clone()
Definition: shape_simple.h:59
bool Collide(const SEG &aSeg, int aClearance=0) const override
Function Collide()
Definition: shape_simple.h:169
const VECTOR2I & CPoint(int aIndex) const
Function CPoint()
Definition: shape_simple.h:113
int PointCount() const
Function PointCount()
Definition: shape_simple.h:85
void Append(const VECTOR2I &aP)
Function Append()
Definition: shape_simple.h:163
const BOX2I BBox(int aClearance=0) const override
Function BBox()
Definition: shape_simple.h:74
const VECTOR2D CDPoint(int aIndex) const
Function CDPoint()
Definition: shape_simple.h:126
SHAPE_SIMPLE()
Constructor Creates an empty polygon.
Definition: shape_simple.h:49
VECTOR2I & Point(int aIndex)
Function Point()
Definition: shape_simple.h:99
Class SHAPE.
Definition: shape.h:59