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 #include "libavoid/connector.h"
24 #include "libavoid/graph.h"
25 #include "libavoid/visibility.h"
27 namespace Avoid {
30 void addShape(ShapeRef *shape)
31 {
32 unsigned int pid = shape->id();
33 Polygn poly = shape->poly();
35 adjustContainsWithAdd(poly, pid);
37 // o Check all visibility edges to see if this one shape
38 // blocks them.
39 newBlockingShape(&poly, pid);
41 // o Calculate visibility for the new vertices.
42 if (UseLeesAlgorithm)
43 {
44 shapeVisSweep(shape);
45 }
46 else
47 {
48 shapeVis(shape);
49 }
50 callbackAllInvalidConnectors();
51 }
54 void delShape(ShapeRef *shape)
55 {
56 unsigned int pid = shape->id();
58 // o Remove entries related to this shape's vertices
59 shape->removeFromGraph();
61 if (SelectiveReroute)
62 {
63 markConnectors(shape);
64 }
66 adjustContainsWithDel(pid);
68 delete shape;
70 // o Check all edges that were blocked by this shape.
71 if (InvisibilityGrph)
72 {
73 checkAllBlockedEdges(pid);
74 }
75 else
76 {
77 // check all edges not in graph
78 checkAllMissingEdges();
79 }
80 callbackAllInvalidConnectors();
81 }
84 ShapeRef *moveShape(ShapeRef *oldShape, Polygn *newPoly, const bool first_move)
85 {
86 unsigned int pid = oldShape->id();
88 // o Remove entries related to this shape's vertices
89 oldShape->removeFromGraph();
91 if (SelectiveReroute && (!(PartialFeedback && PartialTime) || first_move))
92 {
93 markConnectors(oldShape);
94 }
96 adjustContainsWithDel(pid);
98 delete oldShape;
99 oldShape = NULL;
101 adjustContainsWithAdd(*newPoly, pid);
103 // o Check all edges that were blocked by this shape.
104 if (InvisibilityGrph)
105 {
106 checkAllBlockedEdges(pid);
107 }
108 else
109 {
110 // check all edges not in graph
111 checkAllMissingEdges();
112 }
114 ShapeRef *newShape = new ShapeRef(pid, *newPoly);
116 // o Check all visibility edges to see if this one shape
117 // blocks them.
118 if (!(PartialFeedback && PartialTime))
119 {
120 newBlockingShape(newPoly, pid);
121 }
123 // o Calculate visibility for the new vertices.
124 if (UseLeesAlgorithm)
125 {
126 shapeVisSweep(newShape);
127 }
128 else
129 {
130 shapeVis(newShape);
131 }
132 callbackAllInvalidConnectors();
134 return newShape;
135 }
138 }