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-2005 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;
36 typedef std::list<EdgeInf *> EdgeInfList;
39 class VertID
40 {
41 public:
42 unsigned int objID;
43 bool isShape;
44 int vn;
46 static const int src;
47 static const int tar;
49 VertID();
50 VertID(unsigned int id, bool s, int n);
51 VertID(const VertID& other);
52 VertID& operator= (const VertID& rhs);
53 bool operator==(const VertID& rhs) const;
54 bool operator!=(const VertID& rhs) const;
55 bool operator<(const VertID& rhs) const;
56 VertID operator+(const int& rhs) const;
57 VertID operator-(const int& rhs) const;
58 VertID& operator++(int);
59 void print(FILE *file = stdout) const;
60 void db_print(void) const;
61 };
64 class VertInf
65 {
66 public:
67 VertInf(const VertID& vid, const Point& vpoint);
68 void Reset(const Point& vpoint);
69 void removeFromGraph(const bool isConnVert = true);
71 VertID id;
72 Point point;
73 VertInf *lstPrev;
74 VertInf *lstNext;
75 VertInf *shPrev;
76 VertInf *shNext;
77 EdgeInfList visList;
78 unsigned int visListSize;
79 EdgeInfList invisList;
80 unsigned int invisListSize;
81 VertInf *pathNext;
82 double pathDist;
83 };
86 bool directVis(VertInf *src, VertInf *dst);
89 class VertInfList
90 {
91 public:
92 VertInfList();
93 void addVertex(VertInf *vert);
94 void removeVertex(VertInf *vert);
95 VertInf *shapesBegin(void);
96 VertInf *connsBegin(void);
97 VertInf *end(void);
98 void stats(void)
99 {
100 printf("Conns %d, shapes %d\n", _connVertices, _shapeVertices);
101 }
102 private:
103 VertInf *_firstShapeVert;
104 VertInf *_firstConnVert;
105 VertInf *_lastShapeVert;
106 VertInf *_lastConnVert;
107 unsigned int _shapeVertices;
108 unsigned int _connVertices;
109 };
112 typedef std::set<unsigned int> ShapeSet;
113 typedef std::map<VertID, ShapeSet> ContainsMap;
115 extern ContainsMap contains;
116 extern VertInfList vertices;
119 }
122 #endif