Horizon
horizon-eda-1.3.0
3rd_party
router
include
geometry
shape.h
1
/*
2
* This program source code file is part of KiCad, a free EDA CAD application.
3
*
4
* Copyright (C) 2013 CERN
5
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, you may find one here:
19
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20
* or you may search the http://www.gnu.org website for the version 2 license,
21
* or you may write to the Free Software Foundation, Inc.,
22
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23
*/
24
25
#ifndef __SHAPE_H
26
#define __SHAPE_H
27
28
#include <string>
29
#include <sstream>
30
31
#include <math/vector2d.h>
32
#include <math/box2.h>
33
34
#include <geometry/seg.h>
35
41
enum
SHAPE_TYPE
42
{
43
SH_RECT = 0,
44
SH_SEGMENT,
45
SH_LINE_CHAIN,
46
SH_CIRCLE,
47
SH_SIMPLE,
48
SH_POLY_SET,
49
SH_COMPOUND,
50
SH_ARC
51
};
52
58
class
SHAPE
59
{
60
protected
:
61
typedef
VECTOR2I::extended_type ecoord;
62
63
public
:
70
SHAPE
( SHAPE_TYPE aType ) :
m_type
( aType )
71
{}
72
73
// Destructor
74
virtual
~
SHAPE
()
75
{}
76
83
SHAPE_TYPE
Type
()
const
84
{
85
return
m_type
;
86
}
87
94
virtual
SHAPE
*
Clone
()
const
95
{
96
assert(
false
);
97
return
NULL;
98
};
99
107
virtual
bool
Collide
(
const
VECTOR2I
& aP,
int
aClearance = 0 )
const
108
{
109
return
Collide
(
SEG
( aP, aP ), aClearance );
110
}
111
122
virtual
bool
Collide
(
const
SHAPE
* aShape,
int
aClearance,
VECTOR2I
& aMTV )
const
;
123
virtual
bool
Collide
(
const
SHAPE
* aShape,
int
aClearance = 0 )
const
;
124
132
virtual
bool
Collide
(
const
SEG
& aSeg,
int
aClearance = 0 )
const
= 0;
133
143
virtual
const
BOX2I
BBox
(
int
aClearance = 0 )
const
= 0;
144
151
virtual
VECTOR2I
Centre
()
const
152
{
153
return
BBox
( 0 ).Centre();
// if nothing better is available....
154
}
155
156
virtual
void
Move (
const
VECTOR2I
& aVector ) = 0;
157
158
virtual
bool
IsSolid()
const
= 0;
159
160
virtual
bool
Parse( std::stringstream& aStream );
161
162
virtual
const
std::string Format( )
const
;
163
164
protected
:
166
SHAPE_TYPE
m_type
;
167
};
168
169
bool
CollideShapes(
const
SHAPE
* aA,
const
SHAPE
* aB,
int
aClearance,
170
bool
aNeedMTV,
VECTOR2I
& aMTV );
171
172
#endif // __SHAPE_H
SHAPE::SHAPE
SHAPE(SHAPE_TYPE aType)
Constructor.
Definition:
shape.h:70
SHAPE::Collide
virtual bool Collide(const SHAPE *aShape, int aClearance, VECTOR2I &aMTV) const
Function Collide()
SHAPE::Collide
virtual bool Collide(const VECTOR2I &aP, int aClearance=0) const
Function Collide()
Definition:
shape.h:107
VECTOR2< int >
SHAPE::Type
SHAPE_TYPE Type() const
Function Type()
Definition:
shape.h:83
SHAPE::Centre
virtual VECTOR2I Centre() const
Function Centre()
Definition:
shape.h:151
SHAPE::BBox
virtual const BOX2I BBox(int aClearance=0) const =0
Function BBox()
SHAPE::Clone
virtual SHAPE * Clone() const
Function Clone()
Definition:
shape.h:94
SHAPE::Collide
virtual bool Collide(const SEG &aSeg, int aClearance=0) const =0
Function Collide()
SHAPE::m_type
SHAPE_TYPE m_type
type of our shape
Definition:
shape.h:166
BOX2< VECTOR2I >
SEG
Definition:
seg.h:37
SHAPE
Class SHAPE.
Definition:
shape.h:59
Generated by
1.8.20