summaryrefslogtreecommitdiffstats
path: root/src/libavoid
diff options
context:
space:
mode:
Diffstat (limited to 'src/libavoid')
-rw-r--r--src/libavoid/connector.cpp10
-rw-r--r--src/libavoid/connector.h1
-rw-r--r--src/libavoid/debug.h10
-rw-r--r--src/libavoid/graph.cpp39
-rw-r--r--src/libavoid/graph.h9
-rw-r--r--src/libavoid/router.cpp51
-rw-r--r--src/libavoid/router.h6
-rw-r--r--src/libavoid/shape.cpp25
-rw-r--r--src/libavoid/shape.h1
9 files changed, 80 insertions, 72 deletions
diff --git a/src/libavoid/connector.cpp b/src/libavoid/connector.cpp
index d8c299ba0..a9f144688 100644
--- a/src/libavoid/connector.cpp
+++ b/src/libavoid/connector.cpp
@@ -235,16 +235,6 @@ bool ConnRef::needsReroute(void)
}
-void ConnRef::moveRoute(const int& diff_x, const int& diff_y)
-{
- for (int i = 0; i < _route.pn; i++)
- {
- _route.ps[i].x += diff_x;
- _route.ps[i].y += diff_y;
- }
-}
-
-
void ConnRef::lateSetup(const Point& src, const Point& dst)
{
assert(!_initialised);
diff --git a/src/libavoid/connector.h b/src/libavoid/connector.h
index 81f79641f..0ec5890a1 100644
--- a/src/libavoid/connector.h
+++ b/src/libavoid/connector.h
@@ -47,7 +47,6 @@ class ConnRef
void setType(unsigned int type);
PolyLine& route(void);
bool needsReroute(void);
- void moveRoute(const int& diff_x, const int& diff_y);
void freeRoute(void);
void calcRouteDist(void);
void updateEndPoint(const unsigned int type, const Point& point);
diff --git a/src/libavoid/debug.h b/src/libavoid/debug.h
index 1a6879e85..1312c5458 100644
--- a/src/libavoid/debug.h
+++ b/src/libavoid/debug.h
@@ -24,13 +24,7 @@
#define AVOID_DEBUG_H
-
-#ifndef NDEBUG
- //#define DBPRINTF_DEBUG
-#endif
-
-
-#ifdef DBPRINTF_DEBUG
+#ifdef LIBAVOID_DEBUG
#include <stdarg.h>
#include <iostream>
@@ -39,7 +33,7 @@
namespace Avoid {
-#ifdef DBPRINTF_DEBUG
+#ifdef LIBAVOID_DEBUG
inline void db_printf(const char *fmt, ...)
{
va_list ap;
diff --git a/src/libavoid/graph.cpp b/src/libavoid/graph.cpp
index 5e41f79f5..c8f061f6a 100644
--- a/src/libavoid/graph.cpp
+++ b/src/libavoid/graph.cpp
@@ -37,6 +37,7 @@ namespace Avoid {
EdgeInf::EdgeInf(VertInf *v1, VertInf *v2)
: lstPrev(NULL)
, lstNext(NULL)
+ , _blocker(0)
, _router(NULL)
, _added(false)
, _visible(false)
@@ -51,7 +52,6 @@ EdgeInf::EdgeInf(VertInf *v1, VertInf *v2)
assert(_v1->_router == _v2->_router);
_router = _v1->_router;
- _blockers.clear();
_conns.clear();
}
@@ -109,18 +109,12 @@ void EdgeInf::makeInactive(void)
_v2->invisList.erase(_pos2);
_v2->invisListSize--;
}
- _blockers.clear();
+ _blocker = 0;
_conns.clear();
_added = false;
}
-double EdgeInf::getDist(void)
-{
- return _dist;
-}
-
-
void EdgeInf::setDist(double dist)
{
//assert(dist != 0);
@@ -135,13 +129,14 @@ void EdgeInf::setDist(double dist)
makeActive();
}
_dist = dist;
- _blockers.clear();
+ _blocker = 0;
}
void EdgeInf::alertConns(void)
{
- for (FlagList::iterator i = _conns.begin(); i != _conns.end(); ++i)
+ FlagList::iterator finish = _conns.end();
+ for (FlagList::iterator i = _conns.begin(); i != finish; ++i)
{
*(*i) = true;
}
@@ -176,29 +171,7 @@ void EdgeInf::addBlocker(int b)
makeActive();
}
_dist = 0;
- _blockers.clear();
- _blockers.push_back(b);
-}
-
-
-bool EdgeInf::hasBlocker(int b)
-{
- assert(_router->InvisibilityGrph);
-
- ShapeList::iterator finish = _blockers.end();
- for (ShapeList::iterator it = _blockers.begin(); it != finish; ++it)
- {
- if ((*it) == -1)
- {
- alertConns();
- return true;
- }
- else if ((*it) == b)
- {
- return true;
- }
- }
- return false;
+ _blocker = b;
}
diff --git a/src/libavoid/graph.h b/src/libavoid/graph.h
index 080309d52..92451f205 100644
--- a/src/libavoid/graph.h
+++ b/src/libavoid/graph.h
@@ -45,13 +45,16 @@ class EdgeInf
public:
EdgeInf(VertInf *v1, VertInf *v2);
~EdgeInf();
- double getDist(void);
+ inline double getDist(void)
+ {
+ return _dist;
+ }
void setDist(double dist);
void alertConns(void);
void addConn(bool *flag);
void addCycleBlocker(void);
void addBlocker(int b);
- bool hasBlocker(int b);
+
pair<VertID, VertID> ids(void);
pair<Point, Point> points(void);
void db_print(void);
@@ -63,6 +66,7 @@ class EdgeInf
EdgeInf *lstPrev;
EdgeInf *lstNext;
+ int _blocker;
private:
Router *_router;
bool _added;
@@ -71,7 +75,6 @@ class EdgeInf
VertInf *_v2;
EdgeInfList::iterator _pos1;
EdgeInfList::iterator _pos2;
- ShapeList _blockers;
FlagList _conns;
double _dist;
diff --git a/src/libavoid/router.cpp b/src/libavoid/router.cpp
index 78bfa33db..c4dc8961f 100644
--- a/src/libavoid/router.cpp
+++ b/src/libavoid/router.cpp
@@ -28,6 +28,7 @@
#include "libavoid/debug.h"
#include "math.h"
+//#define ORTHOGONAL_ROUTING
namespace Avoid {
@@ -41,6 +42,7 @@ Router::Router()
, IncludeEndpoints(true)
, UseLeesAlgorithm(false)
, InvisibilityGrph(true)
+ , ConsolidateMoves(false)
, PartialFeedback(false)
// Instrumentation:
, st_checked_edges(0)
@@ -63,6 +65,10 @@ void Router::addShape(ShapeRef *shape)
// blocks them.
newBlockingShape(&poly, pid);
+#ifdef ORTHOGONAL_ROUTING
+ Region::addShape(shape);
+#endif
+
// o Calculate visibility for the new vertices.
if (UseLeesAlgorithm)
{
@@ -90,6 +96,10 @@ void Router::delShape(ShapeRef *shape)
adjustContainsWithDel(pid);
+#ifdef ORTHOGONAL_ROUTING
+ Region::removeShape(shape);
+#endif
+
delete shape;
// o Check all edges that were blocked by this shape.
@@ -106,22 +116,26 @@ void Router::delShape(ShapeRef *shape)
}
-ShapeRef *Router::moveShape(ShapeRef *oldShape, Polygn *newPoly, const bool first_move)
+void Router::moveShape(ShapeRef *shape, Polygn *newPoly, const bool first_move)
{
- unsigned int pid = oldShape->id();
-
+ unsigned int pid = shape->id();
+ bool notPartialTime = !(PartialFeedback && PartialTime);
+
// o Remove entries related to this shape's vertices
- oldShape->removeFromGraph();
+ shape->removeFromGraph();
- if (SelectiveReroute && (!(PartialFeedback && PartialTime) || first_move))
+ if (SelectiveReroute && (notPartialTime || first_move))
{
- markConnectors(oldShape);
+ markConnectors(shape);
}
adjustContainsWithDel(pid);
- delete oldShape;
- oldShape = NULL;
+#ifdef ORTHOGONAL_ROUTING
+ Region::removeShape(shape);
+#endif
+
+ shape->setNewPoly(*newPoly);
adjustContainsWithAdd(*newPoly, pid);
@@ -135,12 +149,14 @@ ShapeRef *Router::moveShape(ShapeRef *oldShape, Polygn *newPoly, const bool firs
// check all edges not in graph
checkAllMissingEdges();
}
-
- ShapeRef *newShape = new ShapeRef(this, pid, *newPoly);
+
+#ifdef ORTHOGONAL_ROUTING
+ Region::addShape(shape);
+#endif
// o Check all visibility edges to see if this one shape
// blocks them.
- if (!(PartialFeedback && PartialTime))
+ if (notPartialTime)
{
newBlockingShape(newPoly, pid);
}
@@ -148,15 +164,13 @@ ShapeRef *Router::moveShape(ShapeRef *oldShape, Polygn *newPoly, const bool firs
// o Calculate visibility for the new vertices.
if (UseLeesAlgorithm)
{
- shapeVisSweep(newShape);
+ shapeVisSweep(shape);
}
else
{
- shapeVis(newShape);
+ shapeVis(shape);
}
callbackAllInvalidConnectors();
-
- return newShape;
}
@@ -289,7 +303,12 @@ void Router::checkAllBlockedEdges(int pid)
EdgeInf *tmp = iter;
iter = iter->lstNext;
- if (tmp->hasBlocker(pid))
+ if (tmp->_blocker == -1)
+ {
+ tmp->alertConns();
+ tmp->checkVis();
+ }
+ else if (tmp->_blocker == pid)
{
tmp->checkVis();
}
diff --git a/src/libavoid/router.h b/src/libavoid/router.h
index bcb4ea67c..4d25b53d4 100644
--- a/src/libavoid/router.h
+++ b/src/libavoid/router.h
@@ -29,6 +29,8 @@
#include "libavoid/shape.h"
#include "libavoid/graph.h"
#include "libavoid/timer.h"
+#include <list>
+#include <utility>
#ifdef LINEDEBUG
#include <SDL.h>
#endif
@@ -39,6 +41,7 @@ namespace Avoid {
class ConnRef;
typedef std::list<ConnRef *> ConnRefList;
typedef std::list<unsigned int> IntList;
+typedef std::pair<ShapeRef *, Polygn *> MoveInfo;
static const unsigned int runningTo = 1;
@@ -67,6 +70,7 @@ class Router {
bool IncludeEndpoints;
bool UseLeesAlgorithm;
bool InvisibilityGrph;
+ bool ConsolidateMoves;
bool PartialFeedback;
// Instrumentation:
@@ -78,7 +82,7 @@ class Router {
void addShape(ShapeRef *shape);
void delShape(ShapeRef *shape);
- ShapeRef *moveShape(ShapeRef *oldShape, Polygn *newPoly,
+ void moveShape(ShapeRef *shape, Polygn *newPoly,
const bool first_move = false);
void attachedConns(IntList &conns, const unsigned int shapeId,
diff --git a/src/libavoid/shape.cpp b/src/libavoid/shape.cpp
index f2fd6d6b3..84f0312ee 100644
--- a/src/libavoid/shape.cpp
+++ b/src/libavoid/shape.cpp
@@ -100,6 +100,31 @@ ShapeRef::~ShapeRef()
}
+void ShapeRef::setNewPoly(Polygn& poly)
+{
+ assert(_firstVert != NULL);
+ assert(_poly.pn == poly.pn);
+
+ VertInf *curr = _firstVert;
+ for (int pt_i = 0; pt_i < _poly.pn; pt_i++)
+ {
+ assert(curr->visListSize == 0);
+ assert(curr->invisListSize == 0);
+
+ // Reset with the new polygon point.
+ curr->Reset(poly.ps[pt_i]);
+ curr->pathNext = NULL;
+ curr->pathDist = 0;
+
+ curr = curr->shNext;
+ }
+ assert(curr == _firstVert);
+
+ freePoly(_poly);
+ _poly = copyPoly(poly);
+}
+
+
void ShapeRef::makeActive(void)
{
assert(!_active);
diff --git a/src/libavoid/shape.h b/src/libavoid/shape.h
index 8989cf375..cdcbe7839 100644
--- a/src/libavoid/shape.h
+++ b/src/libavoid/shape.h
@@ -40,6 +40,7 @@ class ShapeRef
public:
ShapeRef(Router *router, unsigned int id, Polygn& poly);
~ShapeRef();
+ void setNewPoly(Polygn& poly);
VertInf *firstVert(void);
VertInf *lastVert(void);
unsigned int id(void);