Code

fix crash, allow combine to work transparently on groups
[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         friend std::ostream& operator<<(std::ostream& os, const VertID& vID);
63 };
66 class VertInf
67 {
68     public:
69         VertInf(Router *router, const VertID& vid, const Point& vpoint);
70         void Reset(const Point& vpoint);
71         void removeFromGraph(const bool isConnVert = true);
73         Router *_router;
74         VertID id;
75         Point  point;
76         VertInf *lstPrev;
77         VertInf *lstNext;
78         VertInf *shPrev;
79         VertInf *shNext;
80         EdgeInfList visList;
81         unsigned int visListSize;
82         EdgeInfList invisList;
83         unsigned int invisListSize;
84         VertInf *pathNext;
85         double pathDist;
86 };
89 bool directVis(VertInf *src, VertInf *dst);
92 class VertInfList
93 {
94     public:
95         VertInfList();
96         void addVertex(VertInf *vert);
97         void removeVertex(VertInf *vert);
98         VertInf *shapesBegin(void);
99         VertInf *connsBegin(void);
100         VertInf *end(void);
101         void stats(void)
102         {
103             printf("Conns %d, shapes %d\n", _connVertices, _shapeVertices);
104         }
105     private:
106         VertInf *_firstShapeVert;
107         VertInf *_firstConnVert;
108         VertInf *_lastShapeVert;
109         VertInf *_lastConnVert;
110         unsigned int _shapeVertices;
111         unsigned int _connVertices;
112 };
115 typedef std::set<unsigned int> ShapeSet;
116 typedef std::map<VertID, ShapeSet> ContainsMap;
122 #endif