/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file Bresenham.cpp14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Fri, 07 Jun 200217///18// A class to realise a uniform n:m - relationship using the19/****************************************************************************/20#include <config.h>2122#include <iostream>23#include <utils/common/StdDefs.h>24#include "Bresenham.h"252627// ===========================================================================28// method definitions29// ===========================================================================30void31Bresenham::compute(BresenhamCallBack* callBack, const int val1, const int val2) {32const int smaller = MIN2(val1, val2);33const int greater = MAX2(val1, val2);34int pos = 0;35int c = smaller;36for (int i = 0; i < greater; i++) {37if (smaller == val1) {38callBack->execute(pos, i);39} else {40callBack->execute(i, pos);41}42c += 2 * smaller;43if (c >= 2 * greater) {44pos++;45c -= 2 * greater;46}47}48}495051/****************************************************************************/525354