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 */
24 #ifndef AVOID_ROUTER_H
25 #define AVOID_ROUTER_H
27 //#define LINEDEBUG
29 #include "libavoid/shape.h"
30 #include "libavoid/graph.h"
31 #include "libavoid/timer.h"
32 #include <list>
33 #include <utility>
34 #ifdef LINEDEBUG
35 #include <SDL.h>
36 #endif
39 namespace Avoid {
41 class ConnRef;
42 typedef std::list<ConnRef *> ConnRefList;
43 typedef std::list<unsigned int> IntList;
44 class MoveInfo;
45 typedef std::list<MoveInfo *> MoveInfoList;
48 static const unsigned int runningTo = 1;
49 static const unsigned int runningFrom = 2;
50 static const unsigned int runningToAndFrom = runningTo | runningFrom;
53 class Router {
54 public:
55 Router();
57 ShapeRefList shapeRefs;
58 ConnRefList connRefs;
59 EdgeList visGraph;
60 EdgeList invisGraph;
61 ContainsMap contains;
62 VertInfList vertices;
64 bool PartialTime;
65 bool SimpleRouting;
66 double segmt_penalty;
67 double angle_penalty;
68 double crossing_penalty;
71 bool UseAStarSearch;
72 bool IgnoreRegions;
73 bool SelectiveReroute;
74 bool IncludeEndpoints;
75 bool UseLeesAlgorithm;
76 bool InvisibilityGrph;
77 bool ConsolidateMoves;
78 bool PartialFeedback;
80 // Instrumentation:
81 Timer timers;
82 int st_checked_edges;
83 #ifdef LINEDEBUG
84 SDL_Surface *avoid_screen;
85 #endif
87 void addShape(ShapeRef *shape);
88 void delShape(ShapeRef *shape);
89 void moveShape(ShapeRef *shape, Polygn *newPoly,
90 const bool first_move = false);
91 void processMoves(void);
93 void attachedConns(IntList &conns, const unsigned int shapeId,
94 const unsigned int type);
95 void attachedShapes(IntList &shapes, const unsigned int shapeId,
96 const unsigned int type);
98 void markConnectors(ShapeRef *shape);
99 void generateContains(VertInf *pt);
100 void printInfo(void);
101 private:
102 void newBlockingShape(Polygn *poly, int pid);
103 void checkAllBlockedEdges(int pid);
104 void checkAllMissingEdges(void);
105 void adjustContainsWithAdd(const Polygn& poly, const int p_shape);
106 void adjustContainsWithDel(const int p_shape);
107 void callbackAllInvalidConnectors(void);
109 MoveInfoList moveList;
110 };
112 }
116 #endif