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 #include "libavoid/vertices.h"
32 namespace Avoid {
34 class ConnRef;
35 class Router;
38 typedef std::list<int> ShapeList;
39 typedef std::list<bool *> FlagList;
42 class EdgeInf
43 {
44 public:
45 EdgeInf(VertInf *v1, VertInf *v2);
46 ~EdgeInf();
47 inline double getDist(void)
48 {
49 return _dist;
50 }
51 void setDist(double dist);
52 void alertConns(void);
53 void addConn(bool *flag);
54 void addCycleBlocker(void);
55 void addBlocker(int b);
57 std::pair<VertID, VertID> ids(void);
58 std::pair<Point, Point> points(void);
59 void db_print(void);
60 void checkVis(void);
61 VertInf *otherVert(VertInf *vert);
62 static EdgeInf *checkEdgeVisibility(VertInf *i, VertInf *j,
63 bool knownNew = false);
64 static EdgeInf *existingEdge(VertInf *i, VertInf *j);
66 EdgeInf *lstPrev;
67 EdgeInf *lstNext;
68 int _blocker;
69 private:
70 Router *_router;
71 bool _added;
72 bool _visible;
73 VertInf *_v1;
74 VertInf *_v2;
75 EdgeInfList::iterator _pos1;
76 EdgeInfList::iterator _pos2;
77 FlagList _conns;
78 double _dist;
80 void makeActive(void);
81 void makeInactive(void);
82 int firstBlocker(void);
83 bool isBetween(VertInf *i, VertInf *j);
84 };
87 class EdgeList
88 {
89 public:
90 EdgeList();
91 void addEdge(EdgeInf *edge);
92 void removeEdge(EdgeInf *edge);
93 EdgeInf *begin(void);
94 EdgeInf *end(void);
95 private:
96 EdgeInf *_firstEdge;
97 EdgeInf *_lastEdge;
98 unsigned int _count;
99 };
102 }
105 #endif