GemaCoreLib
The GeMA Core library
gmInterpolator.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_INTERPOLATOR_H_
25 #define _GEMA_INTERPOLATOR_H_
26 
27 #include "gmCoreConfig.h"
28 #include "gmVector.h"
29 #include "gmMatrix.h"
30 
31 #include <QVariant>
32 
33 class GmValueAccessor;
34 class GmElement;
35 class GmMesh;
36 class GmPluginLoader;
37 
44 
45 
48 {
54 };
55 
63 {
77 
90 
103 
113 
124 
125  // IMPORTANT: When adding new enum values, please remember to also update
126  // GmInterpolator::interpolatorTypeToStr(),
127  // GmInterpolator::strToInterpolatorType() and
128  // GmInterpolator::interpolatorObjectFromType()
129 
130  //-------- NO INSERTION BELOW THIS LINE ----------
134 };
135 
140 {
141 public:
143  virtual GmInterpolatorType type() const = 0;
144 
146  virtual bool typeParamIsValid(const QVariant& v) const { return !v.isValid(); }
147 
149  virtual QString typeParamToStr(const QVariant& v) const { Q_UNUSED(v); return ""; }
150 
152  virtual bool supportsInterpolatorKind(GmInterpolatorKind kind) const = 0;
153 
158  virtual bool requiresElement() const { return false; }
159 
164  virtual bool requiresMesh() const { return false; }
165 
170  virtual bool requiresNaturalCoordinates() const { return false; }
171 
172  virtual bool interpolationWeights(GmInterpolatorCoordinateSetBinding* pointSet, const GmVector& coord,
173  const QVariant& typeParam, GmVector& weights) const;
174 
186  const GmVector& squaredDistances, const QVariant& typeParam,
187  GmVector& weights) const
188  {
189  Q_UNUSED(pointSet); Q_UNUSED(coord); Q_UNUSED(squaredDistances); Q_UNUSED(typeParam); Q_UNUSED(weights);
190  // This function should be reimplemented if interpolationWeights() was not reimplemented
191  assert(0);
192  return false;
193  }
194 
211  QVariant& typeParam, GmMatrix& weights) const
212  {
213  Q_UNUSED(pointSet); Q_UNUSED(typeParam);
214  assert(0);
215  return weights;
216  }
217 
218 protected:
219  friend class GmInterpolator;
220 
223 };
224 
229 {
230 public:
232  virtual ~GmInterpolator() {}
233 
238  bool isValid() const { return _interp; }
239 
241  const GmInterpolatorObject* interpolatorObject() const { return _interp; }
242 
244  const GmMesh* mesh() const { return _mesh; }
245 
247  QString interpolatorTypeToStr() const { return _interp ? interpolatorTypeToStr(_interp->type(), _interpParam) : QObject::tr("invalid"); }
248 
249  static bool initInterpolators();
250 
251  static QString interpolatorTypeToStr(GmInterpolatorType type, const QVariant& typeParam);
252  static int strToInterpolatorType(QString str, bool acceptsNo = false);
253 
254  static bool validInterpolatorForKind(GmInterpolatorType type, const QVariant& typeParam, GmInterpolatorKind kind);
255 
256 protected:
257  GmInterpolator(GmInterpolatorKind kind, GmInterpolatorType type, const QVariant& typeParam,
258  const GmValueAccessor* coordAccessor, const GmMesh* mesh, bool skipTests = false);
259 
260  bool interpolate(GmInterpolatorCoordinateSetBinding* pointSet, GmInterpolatorInputDataBinding* inData,
262 
263  void gaussToNodesInterpolate(GmInterpolatorGaussCoordinateSetBinding* pointSet, GmInterpolatorInputDataBinding* inData,
264  GmInterpolatorOutputMultiDataBinding* outData) const;
265 
266  static void scalarVectorListToVector(const QList<GmVector>& vectorList, GmVector& scalarVector);
267 
268  static const GmInterpolatorObject* interpolatorObjectFromType(GmInterpolatorType type);
269 
270 #ifdef ENABLE_TESTS
271  // Allows test function to call interpolatorObjectFromType()
272  friend Q_DECL_EXPORT void TEST_InterpolatorCoordinateBindings(GmPluginLoader*, const GmLogCategory&, GmLogLevel);
273 #endif
274 
278  const GmMesh* _mesh;
279 
280 private:
281  static const GmInterpolatorObject* _iObjects[GM_NUM_INTERPOLATORS];
282 };
283 
284 #endif
Base interface for FEM (finite element) mesh elements.
Definition: gmElement.h:37
Interpolated value is equal to the value of the closest known value from the interpolation point....
Definition: gmInterpolator.h:76
Interpolated value is based on the moving least squares method. A method parameter specifies the RBF ...
Definition: gmInterpolator.h:102
Binding class used to host the data structure where calculated interpolated values will be stored for...
Definition: gmInterpolatorOutputBindings.h:262
const GmInterpolatorObject * _interp
The interpolator object for the requested interpolation type. NULL if this interpolator is invalid.
Definition: gmInterpolator.h:275
Declaration of usefull configuration definitions for the Core library.
Binding class used to provide the coordinate of the interpolated point, either in cartesian or natura...
Definition: gmInterpolatorCoordinateBindings.h:520
virtual const GmMatrix & gaussToNodesExtrapolationMatrix(GmInterpolatorGaussCoordinateSetBinding *pointSet, const QVariant &typeParam, GmMatrix &weights) const
Basic function for returning the extrapolation matrix used by the GM_GAUSS_TO_NODE_INTERPOLATOR inter...
Definition: gmInterpolator.h:210
Interpolated value is the average of the known values weighted by inverse distance from the interpola...
Definition: gmInterpolator.h:89
Declaration of the GmMatrix class.
virtual bool requiresMesh() const
Does this interpolator object requires that the coordinate set provided to interpolationWeights() con...
Definition: gmInterpolator.h:164
Interpolation should be done using the default method for the interpolator object.
Definition: gmInterpolator.h:133
QString tr(const char *sourceText, const char *disambiguation, int n)
Interface class for accessing and setting values from an "indexable" collection of values.
Definition: gmValueAccessor.h:59
Interpolator class used for managing available interpolator algorithms and providing basic support fu...
Definition: gmInterpolator.h:228
Classes for interpolating values in Gauss points to hierarchical element nodes.
Definition: gmInterpolator.h:53
GmInterpolatorKind
Enum identifying the types of available interpolation classes.
Definition: gmInterpolator.h:47
No interpolation needed. Not valid to construct an interpolator object but usefull when defining user...
Definition: gmInterpolator.h:132
Classes for interpolating values in cell nodes to points inside the cell.
Definition: gmInterpolator.h:49
const GmMesh * _mesh
The mesh containing the source data points. Can be NULL since it is required by only some interpolato...
Definition: gmInterpolator.h:278
GmInterpolatorType
Available interpolation methods. Not every method is suitable for every kind of interpolator class....
Definition: gmInterpolator.h:62
Class responsible for managing discovery and loading of plugins.
Definition: gmPluginLoader.h:42
Binding class used to host the data structure where calculated interpolated values will be stored....
Definition: gmInterpolatorOutputBindings.h:42
Classes for interpolating values in Gauss points to element points.
Definition: gmInterpolator.h:51
Interface class for the implementation of each of the possible interpolation algorithms available in ...
Definition: gmInterpolator.h:139
Declaration of the GmVector class.
virtual bool distanceBasedWeights(GmInterpolatorCoordinateSetBinding *pointSet, const GmVector &coord, const GmVector &squaredDistances, const QVariant &typeParam, GmVector &weights) const
Worker function for the default implementation of interpolationWeights(). This is the function that n...
Definition: gmInterpolator.h:185
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
Binding class used to store the set of known values associated with the points used in the interpolat...
Definition: gmInterpolatorInputBindings.h:41
GmLogLevel
Available log levels list.
Definition: gmLog.h:36
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
Interface for a coordinate set that stores Gauss point coordinates. Besides returning coordinates,...
Definition: gmInterpolatorCoordinateBindings.h:166
QString interpolatorTypeToStr() const
Returns a string representing the interpolator object.
Definition: gmInterpolator.h:247
const GmMesh * mesh() const
Returns the mesh associated with this interpolator. Can be NULL.
Definition: gmInterpolator.h:244
Interpolated value is found by using the elements equivalent linear shape function....
Definition: gmInterpolator.h:123
bool isValid() const const
Basic interface for a set storing point cartesian coordinates. This set can be filled with points fro...
Definition: gmInterpolatorCoordinateBindings.h:71
virtual ~GmInterpolator()
Virtual destructor.
Definition: gmInterpolator.h:232
Interpolated value is found by using the elements shape function.
Definition: gmInterpolator.h:112
Classes for interpolating values in Gauss points to element nodes.
Definition: gmInterpolator.h:50
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition: gmVector.h:34
virtual bool requiresElement() const
Does this interpolator object requires that the coordinate set provided to interpolationWeights() con...
Definition: gmInterpolator.h:158
QVariant _interpParam
The interpolator parameter received on the constructor.
Definition: gmInterpolator.h:276
const GmValueAccessor * _coordAc
The accessor for node coordinates.
Definition: gmInterpolator.h:277
const GmInterpolatorObject * interpolatorObject() const
Returns the interpolator object used by this interpolator.
Definition: gmInterpolator.h:241
Base interface class for Mesh type plugins.
Definition: gmMesh.h:44
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition: gmMatrix.h:38
GmInterpolatorObject()
Protected default constructor to make sure that Interpolator objects are created only by the GmInterp...
Definition: gmInterpolator.h:222
virtual bool requiresNaturalCoordinates() const
Does this interpolator object requires that the coordinate passed as parameter to interpolationWeight...
Definition: gmInterpolator.h:170
virtual QString typeParamToStr(const QVariant &v) const
Converts an interpolator type parameter to a string.
Definition: gmInterpolator.h:149
bool isValid() const
Is this a valid object? Invalid objects can arise, for example, if the interpolator type given in the...
Definition: gmInterpolator.h:238
virtual bool typeParamIsValid(const QVariant &v) const
Is the given interpolator type parameter valid? The default implementation accepts only empty variant...
Definition: gmInterpolator.h:146
Classes for interpolating values in a point cloud to another point.
Definition: gmInterpolator.h:52
The number of available interpolators.
Definition: gmInterpolator.h:131