X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Flibavoid%2Frouter.cpp;h=df0bacd0266e848fd15e7f889c85397897dc45dc;hb=e0c38bd294fd720cebbabeda1a0d87259f68bf7f;hp=6570962a9f13beaf768dc1af62b32047a186094c;hpb=b5e66c5e6adbe1f6d2adc9d5fe7ed26b66fb1bcc;p=inkscape.git diff --git a/src/libavoid/router.cpp b/src/libavoid/router.cpp index 6570962a9..df0bacd02 100644 --- a/src/libavoid/router.cpp +++ b/src/libavoid/router.cpp @@ -17,9 +17,10 @@ * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * + * */ +#include #include "libavoid/shape.h" #include "libavoid/router.h" #include "libavoid/visibility.h" @@ -59,6 +60,7 @@ class MoveInfo { Router::Router() : PartialTime(false) + , SimpleRouting(false) , segmt_penalty(0) , angle_penalty(0) , crossing_penalty(200) @@ -113,6 +115,21 @@ void Router::delShape(ShapeRef *shape) { unsigned int pid = shape->id(); + // Delete items that are queued in the movList. + for (MoveInfoList::iterator it = moveList.begin(); it != moveList.end(); ) + { + if ((*it)->shape->id() == pid) + { + MoveInfoList::iterator doomed = it; + ++it; + moveList.erase(doomed); + } + else + { + ++it; + } + } + // o Remove entries related to this shape's vertices shape->removeFromGraph(); @@ -154,9 +171,12 @@ void Router::moveShape(ShapeRef *shape, Polygn *newPoly, const bool first_move) { if ((*it)->shape->id() == id) { - fprintf(stderr, - "warning: multiple moves requested for shape %d.\n", - (int) id); + if (!SimpleRouting) + { + fprintf(stderr, + "warning: multiple moves requested for shape %d.\n", + (int) id); + } // Just update the MoveInfo with the second polygon, but // leave the firstMove setting alone. (*it)->newPoly = copyPoly(*newPoly); @@ -179,7 +199,8 @@ void Router::moveShape(ShapeRef *shape, Polygn *newPoly, const bool first_move) void Router::processMoves(void) { - if (moveList.empty()) + // If SimpleRouting, then don't update yet. + if (moveList.empty() || SimpleRouting) { return; } @@ -505,9 +526,6 @@ void Router::adjustContainsWithDel(const int p_shape) } -#define MIN(a, b) (((a) <= (b)) ? (a) : (b)) -#define MAX(a, b) (((a) >= (b)) ? (a) : (b)) - #ifdef SELECTIVE_DEBUG static double AngleAFromThreeSides(const double a, const double b, const double c) @@ -570,8 +588,8 @@ void Router::markConnectors(ShapeRef *shape) c = end.x; d = end.y - offy; - min = MIN(p1.x, p2.x); - max = MAX(p1.x, p2.x); + min = std::min(p1.x, p2.x); + max = std::max(p1.x, p2.x); } else if (p1.x == p2.x) { @@ -582,8 +600,8 @@ void Router::markConnectors(ShapeRef *shape) c = end.y; d = end.x - offy; - min = MIN(p1.y, p2.y); - max = MAX(p1.y, p2.y); + min = std::min(p1.y, p2.y); + max = std::max(p1.y, p2.y); } else { @@ -619,7 +637,7 @@ void Router::markConnectors(ShapeRef *shape) if (((int) r_p2.y) != 0) { printf("r_p2.y: %f != 0\n", r_p2.y); - abort(); + std::abort(); } // This might be slightly off. r_p2.y = 0; @@ -630,8 +648,8 @@ void Router::markConnectors(ShapeRef *shape) c = end.x; d = end.y - offy; - min = MIN(r_p1.x, r_p2.x); - max = MAX(r_p1.x, r_p2.x); + min = std::min(r_p1.x, r_p2.x); + max = std::max(r_p1.x, r_p2.x); } @@ -664,9 +682,8 @@ void Router::markConnectors(ShapeRef *shape) //printf("%.1f, %.1f, %.1f, %.1f\n", a, b, c, d); //printf("x = %.1f\n", x); - // XXX: Use MAX and MIN - x = (x < min) ? min : x; - x = (x > max) ? max : x; + x = std::max(min, x); + x = std::min(max, x); //printf("x = %.1f\n", x);