https://gitlab.opengeosys.org/ogs/ogs.git
Raw File
Tip revision: 95a5b8567f55e26c4f2cfe66d48fc1c1654390e4 authored by Tom Fischer on 21 November 2023, 10:13:20 UTC
Merge branch 'RasterParameter' into 'master'
Tip revision: 95a5b85
CreatePiecewiseLinearCurve.h
/**
 * \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
 *
 *
 * Created on November 11, 2016, 10:49 AM
 */

#pragma once

#include <memory>
#include <vector>

namespace BaseLib
{
class ConfigTree;
}

namespace MathLib
{
struct PiecewiseLinearCurveConfig
{
    std::vector<double> xs;
    std::vector<double> ys;
};

PiecewiseLinearCurveConfig parsePiecewiseLinearCurveConfig(
    BaseLib::ConfigTree const& config);

///  Create a curve
/// \param config   ConfigTree object has a tag of `<curve>`
template <typename CurveType>
std::unique_ptr<CurveType> createPiecewiseLinearCurve(
    BaseLib::ConfigTree const& config)
{
    auto [xs, ys] = parsePiecewiseLinearCurveConfig(config);
    return std::make_unique<CurveType>(std::move(xs), std::move(ys));
}
};  // namespace MathLib
back to top