Main Page
Related Pages
Namespaces
Classes
Files
File List
geomtypes.h
Go to the documentation of this file.
1
/*
2
* vim: ts=4 sw=4 et tw=0 wm=0
3
*
4
* libavoid - Fast, Incremental, Object-avoiding Line Router
5
*
6
* Copyright (C) 2004-2009 Monash University
7
*
8
* This library is free software; you can redistribute it and/or
9
* modify it under the terms of the GNU Lesser General Public
10
* License as published by the Free Software Foundation; either
11
* version 2.1 of the License, or (at your option) any later version.
12
* See the file LICENSE.LGPL distributed with the library.
13
*
14
* Licensees holding a valid commercial license may use this file in
15
* accordance with the commercial license agreement provided with the
16
* library.
17
*
18
* This library is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21
*
22
* Author(s): Michael Wybrow <mjwybrow@users.sourceforge.net>
23
*/
24
27
28
29
#ifndef AVOID_GEOMTYPES_H
30
#define AVOID_GEOMTYPES_H
31
32
#include <vector>
33
#include <utility>
34
35
using namespace
std;
36
37
namespace
Avoid
38
{
39
40
static
const
size_t
XDIM = 0;
41
static
const
size_t
YDIM = 1;
42
43
class
Polygon;
44
50
class
Point
51
{
52
public
:
55
Point
();
61
Point
(
const
double
xv,
const
double
yv);
62
68
bool
operator==(
const
Point
& rhs)
const
;
74
bool
operator!=(
const
Point
& rhs)
const
;
83
bool
operator<(
const
Point
& rhs)
const
;
84
89
double
& operator[](
const
unsigned
int
dimension);
90
const
double
& operator[](
const
unsigned
int
dimension)
const
;
91
92
Point
operator+(
const
Point
& rhs)
const
;
93
Point
operator-(
const
Point
& rhs)
const
;
94
96
double
x
;
98
double
y
;
100
unsigned
int
id
;
102
unsigned
short
vn
;
103
104
};
105
106
109
static
const
unsigned
short
kUnassignedVertexNumber = 8;
110
112
static
const
unsigned
short
kShapeConnectionPin = 9;
113
114
117
typedef
Point
Vector
;
118
119
122
class
PolygonInterface
123
{
124
public
:
126
PolygonInterface
() { }
128
virtual
~PolygonInterface
() { }
130
virtual
void
clear(
void
) = 0;
132
virtual
bool
empty(
void
)
const
= 0;
134
virtual
size_t
size(
void
)
const
= 0;
136
virtual
int
id(
void
)
const
= 0;
139
virtual
const
Point
& at(
size_t
index)
const
= 0;
149
void
getBoundingRect(
double
*minX,
double
*minY,
150
double
*maxX,
double
*maxY)
const
;
154
Polygon
boundingRect(
void
)
const
;
155
};
156
157
160
class
Edge
161
{
162
public
:
164
Point
a
;
166
Point
b
;
167
};
168
169
173
typedef
Edge
BBox
;
174
175
176
class
Router
;
177
class
ReferencingPolygon
;
178
179
185
class
Polygon
:
public
PolygonInterface
186
{
187
public
:
189
Polygon
();
201
Polygon
(
const
int
n);
206
Polygon
(
const
PolygonInterface
& poly);
208
void
clear(
void
);
210
bool
empty(
void
)
const
;
212
size_t
size(
void
)
const
;
214
int
id(
void
)
const
;
217
const
Point
& at(
size_t
index)
const
;
224
Polygon
simplify(
void
)
const
;
245
Polygon
curvedPolyline(
const
double
curve_amount,
246
const
bool
closed =
false
)
const
;
251
void
translate(
const
double
xDist,
const
double
yDist);
252
254
int
_id
;
256
std::vector<Point>
ps
;
272
std::vector<char>
ts
;
273
};
274
275
278
typedef
Polygon
PolyLine
;
279
280
286
class
ReferencingPolygon
:
public
PolygonInterface
287
{
288
public
:
289
ReferencingPolygon
();
290
ReferencingPolygon
(
const
Polygon
& poly,
const
Router
*router);
291
void
clear(
void
);
292
bool
empty(
void
)
const
;
293
size_t
size(
void
)
const
;
294
int
id(
void
)
const
;
295
const
Point
& at(
size_t
index)
const
;
296
297
int
_id;
298
std::vector<std::pair<const Polygon *, unsigned short> > psRef;
299
std::vector<Point> psPoints;
300
};
301
302
306
class
Rectangle
:
public
Polygon
307
{
308
public
:
315
Rectangle
(
const
Point
& topLeft,
const
Point
& bottomRight);
316
325
Rectangle
(
const
Point
& centre,
const
double
width,
const
double
height);
326
};
327
328
329
}
330
331
#endif
Generated on Wed Mar 6 2013 01:24:20 for libavoid by
1.8.3.1