db776b80b139c98286725538652590d36d38a9ca
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 */
26 #ifndef AVOID_GRAPH_H
27 #define AVOID_GRAPH_H
30 #include <cassert>
31 #include <list>
32 #include <utility>
33 #include "libavoid/vertices.h"
35 namespace Avoid {
38 class ConnRef;
39 class Router;
42 typedef std::list<int> ShapeList;
43 typedef std::list<bool *> FlagList;
46 class EdgeInf
47 {
48 public:
49 EdgeInf(VertInf *v1, VertInf *v2, const bool orthogonal = false);
50 ~EdgeInf();
51 inline double getDist(void)
52 {
53 return _dist;
54 }
55 void setDist(double dist);
56 void alertConns(void);
57 void addConn(bool *flag);
58 void addCycleBlocker(void);
59 void addBlocker(int b);
60 bool added(void);
61 bool isOrthogonal(void) const;
62 bool rotationLessThan(const VertInf* last, const EdgeInf *rhs) const;
64 std::pair<VertID, VertID> ids(void);
65 std::pair<Point, Point> points(void);
66 void db_print(void);
67 void checkVis(void);
68 VertInf *otherVert(VertInf *vert);
69 static EdgeInf *checkEdgeVisibility(VertInf *i, VertInf *j,
70 bool knownNew = false);
71 static EdgeInf *existingEdge(VertInf *i, VertInf *j);
73 EdgeInf *lstPrev;
74 EdgeInf *lstNext;
75 int _blocker;
76 private:
77 Router *_router;
78 bool _added;
79 bool _visible;
80 bool _orthogonal;
81 VertInf *_v1;
82 VertInf *_v2;
83 EdgeInfList::iterator _pos1;
84 EdgeInfList::iterator _pos2;
85 FlagList _conns;
86 double _dist;
88 void makeActive(void);
89 void makeInactive(void);
90 int firstBlocker(void);
91 bool isBetween(VertInf *i, VertInf *j);
92 };
95 class EdgeList
96 {
97 public:
98 friend class EdgeInf;
99 EdgeList(bool orthogonal = false);
100 ~EdgeList();
101 void clear(void);
102 EdgeInf *begin(void);
103 EdgeInf *end(void);
104 int size(void) const;
105 private:
106 void addEdge(EdgeInf *edge);
107 void removeEdge(EdgeInf *edge);
108 bool _orthogonal;
109 EdgeInf *_firstEdge;
110 EdgeInf *_lastEdge;
111 unsigned int _count;
112 };
115 }
118 #endif