Code

de2e30ae36f0ed7904f5ac2d47cb5795f2225c20
[inkscape.git] / src / libavoid / vertices.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_VERTICES_H
24 #define AVOID_VERTICES_H
26 #include <list>
27 #include <set>
28 #include <map>
29 #include <iostream>
30 #include "libavoid/geomtypes.h"
32 namespace Avoid {
34 class EdgeInf;
35 class Router;
37 typedef std::list<EdgeInf *> EdgeInfList;
40 class VertID
41 {
42     public:
43         unsigned int objID;
44         bool isShape;
45         int vn;
47         static const int src;
48         static const int tar;
50         VertID();
51         VertID(unsigned int id, bool s, int n);
52         VertID(const VertID& other);
53         VertID& operator= (const VertID& rhs);
54         bool operator==(const VertID& rhs) const;
55         bool operator!=(const VertID& rhs) const;
56         bool operator<(const VertID& rhs) const;
57         VertID operator+(const int& rhs) const;
58         VertID operator-(const int& rhs) const;
59         VertID& operator++(int);
60         void print(FILE *file = stdout) const;
61         void db_print(void) const;
62 };
65 class VertInf
66 {
67     public:
68         VertInf(Router *router, const VertID& vid, const Point& vpoint);
69         void Reset(const Point& vpoint);
70         void removeFromGraph(const bool isConnVert = true);
72         Router *_router;
73         VertID id;
74         Point  point;
75         VertInf *lstPrev;
76         VertInf *lstNext;
77         VertInf *shPrev;
78         VertInf *shNext;
79         EdgeInfList visList;
80         unsigned int visListSize;
81         EdgeInfList invisList;
82         unsigned int invisListSize;
83         VertInf *pathNext;
84         double pathDist;
85 };
88 bool directVis(VertInf *src, VertInf *dst);
91 class VertInfList
92 {
93     public:
94         VertInfList();
95         void addVertex(VertInf *vert);
96         void removeVertex(VertInf *vert);
97         VertInf *shapesBegin(void);
98         VertInf *connsBegin(void);
99         VertInf *end(void);
100         void stats(void)
101         {
102             printf("Conns %d, shapes %d\n", _connVertices, _shapeVertices);
103         }
104     private:
105         VertInf *_firstShapeVert;
106         VertInf *_firstConnVert;
107         VertInf *_lastShapeVert;
108         VertInf *_lastConnVert;
109         unsigned int _shapeVertices;
110         unsigned int _connVertices;
111 };
114 typedef std::set<unsigned int> ShapeSet;
115 typedef std::map<VertID, ShapeSet> ContainsMap;
121 #endif