File indexing completed on 2024-12-22 04:10:01
0001 /* 0002 * SPDX-FileCopyrightText: 2014 Dmitry Kazakov <dimula73@gmail.com> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #ifndef __KIS_BSPLINE_1D_H 0008 #define __KIS_BSPLINE_1D_H 0009 0010 #include <kritaimage_export.h> 0011 0012 #include <QScopedPointer> 0013 #include <QVector> 0014 0015 #include "kis_bspline.h" 0016 0017 0018 namespace KisBSplines { 0019 0020 class KRITAIMAGE_EXPORT KisBSpline1D 0021 { 0022 public: 0023 KisBSpline1D(float gridStart, float gridEnd, int numSamples, BorderCondition bc); 0024 ~KisBSpline1D(); 0025 0026 template <class FunctionOp> 0027 inline void initializeSpline() { 0028 0029 FunctionOp op; 0030 float step = (m_gridEnd - m_gridStart) / (m_numSamples - 1); 0031 QVector<float> values(m_numSamples); 0032 0033 for (int i = 0; i < m_numSamples; i++) { 0034 float x = m_gridStart + i * step; 0035 float y = op(x); 0036 0037 values[i] = y; 0038 } 0039 0040 initializeSplineImpl(values); 0041 } 0042 0043 float value(float x) const; 0044 0045 inline float gridStart() const { 0046 return m_gridStart; 0047 } 0048 0049 inline float gridEnd() const { 0050 return m_gridEnd; 0051 } 0052 0053 private: 0054 void initializeSplineImpl(const QVector<float> &values); 0055 0056 private: 0057 struct Private; 0058 const QScopedPointer<Private> m_d; 0059 0060 /** 0061 * We need to store them separately, because they should 0062 * be accessible from the templated part 0063 */ 0064 float m_gridStart; 0065 float m_gridEnd; 0066 int m_numSamples; 0067 }; 0068 0069 } 0070 0071 #endif /* __KIS_BSPLINE_1D_H */