index 6570962a9f13beaf768dc1af62b32047a186094c..df0bacd0266e848fd15e7f889c85397897dc45dc 100644 (file)
--- a/src/libavoid/router.cpp
+++ b/src/libavoid/router.cpp
* 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 <cstdlib>
#include "libavoid/shape.h"
#include "libavoid/router.h"
#include "libavoid/visibility.h"
Router::Router()
: PartialTime(false)
+ , SimpleRouting(false)
, segmt_penalty(0)
, angle_penalty(0)
, crossing_penalty(200)
{
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);
void Router::processMoves(void)
{
- if (moveList.empty())
+ // If SimpleRouting, then don't update yet.
+ if (moveList.empty() || SimpleRouting)
{
return;
}
}
-#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)
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)
{
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
{
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;
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);
}
//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);