1 /*
2 * vim: ts=4 sw=4 et tw=0 wm=0
3 *
4 * libavoid - Fast, Incremental, Object-avoiding Line Router
5 * Copyright (C) 2004-2006 Michael Wybrow <mjwybrow@users.sourceforge.net>
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library 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 GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 *
21 */
23 #ifndef AVOID_GRAPH_H
24 #define AVOID_GRAPH_H
27 #include <cassert>
28 #include <list>
29 #include <utility>
30 using std::pair;
31 #include "libavoid/vertices.h"
33 namespace Avoid {
35 class ConnRef;
36 class Router;
39 typedef std::list<int> ShapeList;
40 typedef std::list<bool *> FlagList;
43 class EdgeInf
44 {
45 public:
46 EdgeInf(VertInf *v1, VertInf *v2);
47 ~EdgeInf();
48 inline double getDist(void)
49 {
50 return _dist;
51 }
52 void setDist(double dist);
53 void alertConns(void);
54 void addConn(bool *flag);
55 void addCycleBlocker(void);
56 void addBlocker(int b);
58 pair<VertID, VertID> ids(void);
59 pair<Point, Point> points(void);
60 void db_print(void);
61 void checkVis(void);
62 VertInf *otherVert(VertInf *vert);
63 static EdgeInf *checkEdgeVisibility(VertInf *i, VertInf *j,
64 bool knownNew = false);
65 static EdgeInf *existingEdge(VertInf *i, VertInf *j);
67 EdgeInf *lstPrev;
68 EdgeInf *lstNext;
69 int _blocker;
70 private:
71 Router *_router;
72 bool _added;
73 bool _visible;
74 VertInf *_v1;
75 VertInf *_v2;
76 EdgeInfList::iterator _pos1;
77 EdgeInfList::iterator _pos2;
78 FlagList _conns;
79 double _dist;
81 void makeActive(void);
82 void makeInactive(void);
83 int firstBlocker(void);
84 bool isBetween(VertInf *i, VertInf *j);
85 };
88 class EdgeList
89 {
90 public:
91 EdgeList();
92 void addEdge(EdgeInf *edge);
93 void removeEdge(EdgeInf *edge);
94 EdgeInf *begin(void);
95 EdgeInf *end(void);
96 private:
97 EdgeInf *_firstEdge;
98 EdgeInf *_lastEdge;
99 unsigned int _count;
100 };
103 }
106 #endif