diff --git a/src/libavoid/shape.cpp b/src/libavoid/shape.cpp
index 84f0312ee1d56550bcb656215871839c87bbe95e..2b241b7283e255db6dd30e15e8b9f1cacbd18f16 100644 (file)
--- a/src/libavoid/shape.cpp
+++ b/src/libavoid/shape.cpp
, _id(id)
, _poly(copyPoly(ply))
, _active(false)
+ , _inMoveList(false)
, _firstVert(NULL)
, _lastVert(NULL)
{
//node->lstPrev = last;
//last->lstNext = node;
}
- _router->vertices.addVertex(node);
last = node;
i++;
- // Increase total vertices count ++;
}
_lastVert = node;
_lastVert->shNext = _firstVert;
_firstVert->shPrev = _lastVert;
- // Increase total shape count ++;
makeActive();
}
{
assert(_firstVert != NULL);
+ makeInactive();
+
VertInf *it = _firstVert;
do
{
VertInf *tmp = it;
it = it->shNext;
- // XXX: This could possibly be done less
- // safely but faster, all at once.
- _router->vertices.removeVertex(tmp);
delete tmp;
}
while (it != _firstVert);
_firstVert = _lastVert = NULL;
freePoly(_poly);
-
- makeInactive();
}
// Add to connRefs list.
_pos = _router->shapeRefs.insert(_router->shapeRefs.begin(), this);
+
+ // Add points to vertex list.
+ VertInf *it = _firstVert;
+ do
+ {
+ VertInf *tmp = it;
+ it = it->shNext;
+
+ _router->vertices.addVertex(tmp);
+ }
+ while (it != _firstVert);
+
_active = true;
}
// Remove from connRefs list.
_router->shapeRefs.erase(_pos);
+
+ // Remove points from vertex list.
+ VertInf *it = _firstVert;
+ do
+ {
+ VertInf *tmp = it;
+ it = it->shNext;
+
+ _router->vertices.removeVertex(tmp);
+ }
+ while (it != _firstVert);
+
_active = false;
}
}
+void ShapeRef::markForMove(void)
+{
+ if (!_inMoveList)
+ {
+ _inMoveList = true;
+ }
+ else
+ {
+ fprintf(stderr, "WARNING: two moves queued for same shape prior to "
+ "rerouting.\n This is not safe.\n");
+ }
+}
+
+
+void ShapeRef::clearMoveMark(void)
+{
+ _inMoveList = false;
+}
+
+
+VertInf *ShapeRef::getPointVertex(const Point& point)
+{
+ VertInf *curr = _firstVert;
+ do
+ {
+ if (curr->point == point)
+ {
+ return curr;
+ }
+ curr = curr->shNext;
+ }
+ while (curr != _firstVert);
+
+ return NULL;
+}
+
+
}