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 double segmt_penalty;
66 double angle_penalty;
67 double crossing_penalty;
70 bool UseAStarSearch;
71 bool IgnoreRegions;
72 bool SelectiveReroute;
73 bool IncludeEndpoints;
74 bool UseLeesAlgorithm;
75 bool InvisibilityGrph;
76 bool ConsolidateMoves;
77 bool PartialFeedback;
79 // Instrumentation:
80 Timer timers;
81 int st_checked_edges;
82 #ifdef LINEDEBUG
83 SDL_Surface *avoid_screen;
84 #endif
86 void addShape(ShapeRef *shape);
87 void delShape(ShapeRef *shape);
88 void moveShape(ShapeRef *shape, Polygn *newPoly,
89 const bool first_move = false);
90 void processMoves(void);
92 void attachedConns(IntList &conns, const unsigned int shapeId,
93 const unsigned int type);
94 void attachedShapes(IntList &shapes, const unsigned int shapeId,
95 const unsigned int type);
97 void markConnectors(ShapeRef *shape);
98 void generateContains(VertInf *pt);
99 void printInfo(void);
100 private:
101 void newBlockingShape(Polygn *poly, int pid);
102 void checkAllBlockedEdges(int pid);
103 void checkAllMissingEdges(void);
104 void adjustContainsWithAdd(const Polygn& poly, const int p_shape);
105 void adjustContainsWithDel(const int p_shape);
106 void callbackAllInvalidConnectors(void);
108 MoveInfoList moveList;
109 };
111 }
115 #endif