Code

* src/document.cpp, src/document.h, src/sp-conn-end-pair.cpp,
[inkscape.git] / src / libavoid / graph.h
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         double getDist(void);
49         void setDist(double dist);
50         void alertConns(void);
51         void addConn(bool *flag);
52         void addCycleBlocker(void);
53         void addBlocker(int b);
54         bool hasBlocker(int b);
55         pair<VertID, VertID> ids(void);
56         pair<Point, Point> points(void);
57         void db_print(void);
58         void checkVis(void);
59         VertInf *otherVert(VertInf *vert);
60         static EdgeInf *checkEdgeVisibility(VertInf *i, VertInf *j,
61                 bool knownNew = false);
62         static EdgeInf *existingEdge(VertInf *i, VertInf *j);
64         EdgeInf *lstPrev;
65         EdgeInf *lstNext;
66     private:
67         Router *_router;
68         bool _added;
69         bool _visible;
70         VertInf *_v1;
71         VertInf *_v2;
72         EdgeInfList::iterator _pos1;
73         EdgeInfList::iterator _pos2;
74         ShapeList _blockers;
75         FlagList  _conns;
76         double  _dist;
78         void makeActive(void);
79         void makeInactive(void);
80         int firstBlocker(void);
81         bool isBetween(VertInf *i, VertInf *j);
82 };
85 class EdgeList
86 {
87     public:
88         EdgeList();
89         void addEdge(EdgeInf *edge);
90         void removeEdge(EdgeInf *edge);
91         EdgeInf *begin(void);
92         EdgeInf *end(void);
93     private:
94         EdgeInf *_firstEdge;
95         EdgeInf *_lastEdge;
96         unsigned int _count;
97 };
103 #endif