1965 {
1967 return;
1968
1969
1970 double x = expr_x.as_d();
1971 assert(! std::isnan(x));
1972 bool evaluated = false;
1973 for (
size_t i = 1; i <
table.table.size(); ++i) {
1974 double x0 =
table.table[i - 1].x;
1975 double x1 =
table.table[i].x;
1976 if (x0 > x1)
1977 boost::throw_exception(qi::expectation_failure(
1978 table.table[i - 1].it_range_x.begin(),
table.table[i].it_range_x.end(), spirit::info(std::string(
"*") +
L(
"X coordinates of the table must be increasing"))));
1979 if (! evaluated && x >= x0 && x <= x1) {
1980 double y0 =
table.table[i - 1].y;
1981 double y1 =
table.table[i].y;
1982 if (x == x0)
1983 out.set_d(y0);
1984 else if (x == x1)
1985 out.set_d(y1);
1987 out.set_d(0.5 * (y0 + y1));
1988 else
1990 evaluated = true;
1991 }
1992 }
1993 if (! evaluated) {
1994
1995 if (
double x0 =
table.table.front().x; x > x0 -
EPSILON && x < x0)
1996 out.set_d(
table.table.front().y);
1997 else if (
double x1 =
table.table.back().x; x > x1 && x < x1 +
EPSILON)
1998 out.set_d(
table.table.back().y);
1999 else
2000
2001 expr_x.throw_exception(
L(
"Interpolation value is outside the table range"));
2002 }
2003 }
#define EPSILON
Definition ColorUtils.cpp:64
ColorRGB lerp(const ColorRGB &a, const ColorRGB &b, float t)
Definition Color.cpp:244
constexpr bool is_approx(Number value, Number test_value, Number precision=EPSILON)
Definition libslic3r.h:320