summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 95d09ab)
raw | patch | inline | side by side (parent: 95d09ab)
author | mjwybrow <mjwybrow@users.sourceforge.net> | |
Wed, 1 Mar 2006 01:48:07 +0000 (01:48 +0000) | ||
committer | mjwybrow <mjwybrow@users.sourceforge.net> | |
Wed, 1 Mar 2006 01:48:07 +0000 (01:48 +0000) |
src/libavoid/shape.cpp, src/libavoid/graph.cpp, src/libavoid/shape.h,
src/libavoid/graph.h, src/libavoid/router.cpp, src/libavoid/router.h,
src/libavoid/connector.cpp, src/libavoid/debug.h:
Some speed improvements and interface cleanups to libavoid.
src/libavoid/graph.h, src/libavoid/router.cpp, src/libavoid/router.h,
src/libavoid/connector.cpp, src/libavoid/debug.h:
Some speed improvements and interface cleanups to libavoid.
diff --git a/ChangeLog b/ChangeLog
index 2c35fb7ba6e48ca210e619db5a9917a43cb2afb6..69abdd7c87e4ffdb2d8a4726758c0f1ac7412ce5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-03-01 Michael Wybrow <mjwybrow@users.sourceforge.net>
+
+ * src/conn-avoid-ref.cpp, src/libavoid/connector.h,
+ src/libavoid/shape.cpp, src/libavoid/graph.cpp, src/libavoid/shape.h,
+ src/libavoid/graph.h, src/libavoid/router.cpp, src/libavoid/router.h,
+ src/libavoid/connector.cpp, src/libavoid/debug.h:
+
+ Some speed improvements and interface cleanups to libavoid.
+
2006-02-28 Jon A. Cruz <jon@joncruz.org>
* src/dialogs/swatches.cpp:
diff --git a/src/conn-avoid-ref.cpp b/src/conn-avoid-ref.cpp
index df885d44c61717d425bbe5e3c54aeaa153512718..5de222adef48e3f4945536e02d63c6f67d88655f 100644 (file)
--- a/src/conn-avoid-ref.cpp
+++ b/src/conn-avoid-ref.cpp
Router *router = moved_item->document->router;
Avoid::Polygn poly = avoid_item_poly(moved_item);
if (poly.pn > 0) {
- // moveShape actually destroys the old shapeRef and returns a new one.
- moved_item->avoidRef->shapeRef = router->moveShape(shapeRef, &poly);
+ router->moveShape(shapeRef, &poly);
Avoid::freePoly(poly);
}
}
index d8c299ba0aab1e07b733ab4b0f7fac0fda00799e..a9f1446889cc4eff3335fa4218de2509265c6815 100644 (file)
}
-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);
index 81f79641fade8cddabfe16d6eec4eb8e8d78c924..0ec5890a1f2a89d5b3bb4d0d0d9debb919baa916 100644 (file)
--- a/src/libavoid/connector.h
+++ b/src/libavoid/connector.h
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 1a6879e85a979d085325cc04578f1be30ec20b07..1312c54586ae513bf9a1b403ea284a5c671e6a4c 100644 (file)
--- a/src/libavoid/debug.h
+++ b/src/libavoid/debug.h
#define AVOID_DEBUG_H
-
-#ifndef NDEBUG
- //#define DBPRINTF_DEBUG
-#endif
-
-
-#ifdef DBPRINTF_DEBUG
+#ifdef LIBAVOID_DEBUG
#include <stdarg.h>
#include <iostream>
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 5e41f79f548ba5702a079423681f059e69a105fc..c8f061f6a56b2ae08e03bbff8dfa5a8faad95fee 100644 (file)
--- a/src/libavoid/graph.cpp
+++ b/src/libavoid/graph.cpp
EdgeInf::EdgeInf(VertInf *v1, VertInf *v2)
: lstPrev(NULL)
, lstNext(NULL)
+ , _blocker(0)
, _router(NULL)
, _added(false)
, _visible(false)
assert(_v1->_router == _v2->_router);
_router = _v1->_router;
- _blockers.clear();
_conns.clear();
}
_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);
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;
}
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 080309d5271e779ef9f1eefa4ea70da60d67574b..92451f2054d2916ef1f8bf6c3bfeedcd7595e38f 100644 (file)
--- a/src/libavoid/graph.h
+++ b/src/libavoid/graph.h
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);
EdgeInf *lstPrev;
EdgeInf *lstNext;
+ int _blocker;
private:
Router *_router;
bool _added;
VertInf *_v2;
EdgeInfList::iterator _pos1;
EdgeInfList::iterator _pos2;
- ShapeList _blockers;
FlagList _conns;
double _dist;
index 78bfa33db1bd5c33be07db3b8ffed01ec159f20e..c4dc8961f5fb714c9ff032ff20141a3e949a13b9 100644 (file)
--- a/src/libavoid/router.cpp
+++ b/src/libavoid/router.cpp
#include "libavoid/debug.h"
#include "math.h"
+//#define ORTHOGONAL_ROUTING
namespace Avoid {
, IncludeEndpoints(true)
, UseLeesAlgorithm(false)
, InvisibilityGrph(true)
+ , ConsolidateMoves(false)
, PartialFeedback(false)
// Instrumentation:
, st_checked_edges(0)
// blocks them.
newBlockingShape(&poly, pid);
+#ifdef ORTHOGONAL_ROUTING
+ Region::addShape(shape);
+#endif
+
// o Calculate visibility for the new vertices.
if (UseLeesAlgorithm)
{
adjustContainsWithDel(pid);
+#ifdef ORTHOGONAL_ROUTING
+ Region::removeShape(shape);
+#endif
+
delete shape;
// o Check all edges that were blocked by this 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;
}
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 bcb4ea67c496c5bc90dcd31cfc1050d76b2502e2..4d25b53d4a0da11bb852a5fabc3ff4a551505370 100644 (file)
--- a/src/libavoid/router.h
+++ b/src/libavoid/router.h
#include "libavoid/shape.h"
#include "libavoid/graph.h"
#include "libavoid/timer.h"
+#include <list>
+#include <utility>
#ifdef LINEDEBUG
#include <SDL.h>
#endif
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;
bool IncludeEndpoints;
bool UseLeesAlgorithm;
bool InvisibilityGrph;
+ bool ConsolidateMoves;
bool PartialFeedback;
// Instrumentation:
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 f2fd6d6b30138e3e47a7545841671f55f1d565da..84f0312ee1d56550bcb656215871839c87bbe95e 100644 (file)
--- a/src/libavoid/shape.cpp
+++ b/src/libavoid/shape.cpp
}
+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 8989cf37532f11910ef0f6a66b9fb278c22f8248..cdcbe7839ddce3ea66aa105a83b949c8f683645c 100644 (file)
--- a/src/libavoid/shape.h
+++ b/src/libavoid/shape.h
public:
ShapeRef(Router *router, unsigned int id, Polygn& poly);
~ShapeRef();
+ void setNewPoly(Polygn& poly);
VertInf *firstVert(void);
VertInf *lastVert(void);
unsigned int id(void);