Revision 652ad60247b0023bd9837db6a29f8d47413bfee1 authored by Christoph Lehmann on 24 August 2023, 07:23:25 UTC, committed by Christoph Lehmann on 24 August 2023, 07:23:25 UTC
Draft: RTP acceleration: assemble only once

See merge request ogs/ogs!4713
2 parent s 30ff596 + 741dc88
Raw File
Utils.cpp
/**
 * \file
 *
 * \copyright
 * Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org)
 *            Distributed under a Modified BSD License.
 *              See accompanying file LICENSE.txt or
 *              http://www.opengeosys.org/project/license
 *
 */

#include "Utils.h"

#include "BaseLib/Error.h"

namespace GeoLib
{
std::vector<GeoLib::Point*> generateEquidistantPoints(
    MathLib::Point3d const& begin, MathLib::Point3d const& end,
    int const number_of_subdivisions)
{
    if (number_of_subdivisions < 0)
    {
        OGS_FATAL(
            "generateEquidistantPoints: number of subdivisions is required to "
            "be non-negative.");
    }

    auto const& start = begin.asEigenVector3d();
    auto const& stop = end.asEigenVector3d();
    auto const delta = (stop - start) / (number_of_subdivisions + 1);

    std::vector<GeoLib::Point*> points;

    for (int i = 0; i <= number_of_subdivisions; ++i)
    {
        auto const p = start + i * delta;
        points.push_back(new GeoLib::Point{p[0], p[1], p[2]});
    }
    points.push_back(new GeoLib::Point{stop[0], stop[1], stop[2]});

    return points;
}

}  // namespace GeoLib
back to top