Code

Patch from Diedrik for 296778
[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 <cstdio>
31 #include "libavoid/geomtypes.h"
33 namespace Avoid {
35 class EdgeInf;
36 class Router;
38 typedef std::list<EdgeInf *> EdgeInfList;
41 class VertID
42 {
43     public:
44         unsigned int objID;
45         bool isShape;
46         int vn;
48         static const int src;
49         static const int tar;
51         VertID();
52         VertID(unsigned int id, bool s, int n);
53         VertID(const VertID& other);
54         VertID& operator= (const VertID& rhs);
55         bool operator==(const VertID& rhs) const;
56         bool operator!=(const VertID& rhs) const;
57         bool operator<(const VertID& rhs) const;
58         VertID operator+(const int& rhs) const;
59         VertID operator-(const int& rhs) const;
60         VertID& operator++(int);
61         void print(FILE *file = stdout) const;
62         void db_print(void) const;
63         friend std::ostream& operator<<(std::ostream& os, const VertID& vID);
64 };
67 class VertInf
68 {
69     public:
70         VertInf(Router *router, const VertID& vid, const Point& vpoint);
71         void Reset(const Point& vpoint);
72         void removeFromGraph(const bool isConnVert = true);
74         Router *_router;
75         VertID id;
76         Point  point;
77         VertInf *lstPrev;
78         VertInf *lstNext;
79         VertInf *shPrev;
80         VertInf *shNext;
81         EdgeInfList visList;
82         unsigned int visListSize;
83         EdgeInfList invisList;
84         unsigned int invisListSize;
85         VertInf *pathNext;
86         double pathDist;
87 };
90 bool directVis(VertInf *src, VertInf *dst);
93 class VertInfList
94 {
95     public:
96         VertInfList();
97         void addVertex(VertInf *vert);
98         void removeVertex(VertInf *vert);
99         VertInf *shapesBegin(void);
100         VertInf *connsBegin(void);
101         VertInf *end(void);
102         void stats(void)
103         {
104             printf("Conns %d, shapes %d\n", _connVertices, _shapeVertices);
105         }
106     private:
107         VertInf *_firstShapeVert;
108         VertInf *_firstConnVert;
109         VertInf *_lastShapeVert;
110         VertInf *_lastConnVert;
111         unsigned int _shapeVertices;
112         unsigned int _connVertices;
113 };
116 typedef std::set<unsigned int> ShapeSet;
117 typedef std::map<VertID, ShapeSet> ContainsMap;
123 #endif