GemaLuaCoreLib
The GeMA Lua Core library
gmLuaInterpolator.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 _GEMALUA_INTERPOLATOR_H_
25 #define _GEMALUA_INTERPOLATOR_H_
26 
27 #include "gmLuaObject.h"
28 
29 #include <gmVector.h>
30 
31 class GmInterpolator;
32 class GmValueAccessor;
33 class GmGaussAccessor;
34 class GmSpatialIndex;
35 class GmNumSolver;
36 
41 class GML_API_EXPORT GmLuaNodeToPointInterpolator : public GmLuaObject
42 {
43 public:
45 
46  // See comments on the base class
47  virtual const char* typeName() const { return "nodeToPointInterpolator"; }
48 
49  virtual QString toString() const;
50 
51  virtual void fillMetatable(lua_State* L, int index);
52 
54  virtual void* getClassMetatableID() { static int classID = 0; return &classID; }
55 
56  static GmLuaNodeToPointInterpolator* createInterpolator(lua_State* L, bool element, const GmLogCategory& logger);
57 
58 private:
59  GmLuaNodeToPointInterpolator(GmInterpolator* interp, bool element, bool multi, bool result, const GmLogCategory& logger);
60 
61  int interpolate(lua_State* L);
62 
63 protected:
66  bool _multi;
67  bool _resultAc;
68 };
69 
70 
74 class GML_API_EXPORT GmLuaGaussToPointInterpolator : public GmLuaObject
75 {
76 public:
78 
79  // See comments on the base class
80  virtual const char* typeName() const { return "gaussToPointInterpolator"; }
81 
82  virtual QString toString() const;
83 
84  virtual void fillMetatable(lua_State* L, int index);
85 
87  virtual void* getClassMetatableID() { static int classID = 0; return &classID; }
88 
89  static GmLuaGaussToPointInterpolator* createInterpolator(lua_State* L, const GmLogCategory& logger);
90 
91 private:
92  GmLuaGaussToPointInterpolator(GmInterpolator* interp, bool multi, const GmLogCategory& logger);
93 
94  int interpolate(lua_State* L);
95 
96 protected:
98  bool _multi;
99 };
100 
104 class GML_API_EXPORT GmLuaGaussToNodeInterpolator : public GmLuaObject
105 {
106 public:
107  virtual ~GmLuaGaussToNodeInterpolator();
108 
109  // See comments on the base class
110  virtual const char* typeName() const { return "gaussToNodeInterpolator"; }
111 
112  virtual QString toString() const;
113 
114  virtual void fillMetatable(lua_State* L, int index);
115 
117  virtual void* getClassMetatableID() { static int classID = 0; return &classID; }
118 
119  static GmLuaGaussToNodeInterpolator* createInterpolator(lua_State* L, const GmLogCategory& logger);
120 
121 private:
122  GmLuaGaussToNodeInterpolator(GmInterpolator* interp, bool multi, const GmLogCategory& logger);
123 
124  int interpolate(lua_State* L);
125 
126 protected:
128  bool _multi;
129 };
130 
135 {
136 public:
138 
139  // See comments on the base class
140  virtual const char* typeName() const { return "gaussNeighborsToNodeInterpolator"; }
141 
142  virtual QString toString() const;
143 
144  virtual void fillMetatable(lua_State* L, int index);
145 
147  virtual void* getClassMetatableID() { static int classID = 0; return &classID; }
148 
149  static GmLuaGaussNeighborsToNodeInterpolator* createInterpolator(lua_State* L, const GmLogCategory& logger);
150 
151 private:
152  GmLuaGaussNeighborsToNodeInterpolator(GmInterpolator* interp, bool multi, bool result, const GmLogCategory& logger);
153 
154  int interpolate(lua_State* L);
155 
156 protected:
158  bool _multi;
159  bool _resultAc;
160 };
161 
165 class GML_API_EXPORT GmLuaNodeCloudToPointInterpolator : public GmLuaObject
166 {
167 public:
169 
170  // See comments on the base class
171  virtual const char* typeName() const { return "nodeCloudToPointInterpolator"; }
172 
173  virtual QString toString() const;
174 
175  virtual void fillMetatable(lua_State* L, int index);
176 
178  virtual void* getClassMetatableID() { static int classID = 0; return &classID; }
179 
180  static GmLuaNodeCloudToPointInterpolator* createInterpolator(lua_State* L, const GmLogCategory& logger);
181 
182 private:
183  GmLuaNodeCloudToPointInterpolator(GmInterpolator* interp, bool multi, const GmLogCategory& logger);
184 
185  int interpolate(lua_State* L);
186 
187 protected:
189  bool _multi;
190 };
191 
192 
196 class GML_API_EXPORT GmLuaGaussCloudToPointInterpolator : public GmLuaObject
197 {
198 public:
200 
201  // See comments on the base class
202  virtual const char* typeName() const { return "gaussCloudToPointInterpolator"; }
203 
204  virtual QString toString() const;
205 
206  virtual void fillMetatable(lua_State* L, int index);
207 
209  virtual void* getClassMetatableID() { static int classID = 0; return &classID; }
210 
211  static GmLuaGaussCloudToPointInterpolator* createInterpolator(lua_State* L, const GmLogCategory& logger);
212 
213 private:
214  GmLuaGaussCloudToPointInterpolator(GmInterpolator* interp, bool multi, const GmLogCategory& logger);
215 
216  int interpolate(lua_State* L);
217 
218 protected:
220  bool _multi;
221 };
222 
223 
226 {
227  int pushResults(lua_State* L, const GmVector& result, const QList<GmVector>& resultList,
228  const GmLogCategory& logger, bool resultsCanBeEmpty = false);
229 
230  template<class T, class P> void parseValueAccessors(lua_State* L, int vIndex, int cIndex, const T*& valueAc, QList<const T*>& valueAcList,
231  const GmValueAccessor*& coordAc, const char* acType);
232 
233  template<class T, class P, class V> void parseResultAccessors(lua_State* L, int index, T*& resultAc, QList<T*>& resultAcList,
234  const V* valueAc, const QList<const V*>& valueAcList, const char* acType);
235 
236  void parseCommonParams(lua_State* L, bool nodeBased, const char* fname, const GmLogCategory** logger,
237  int* interpType, QVariant* interpParam, int* searchMode, double* searchDomain,
238  GmSpatialIndex** spIndex);
239 
240  void parseCommonSplineParams(lua_State* L, bool nodeBased, int solverIndex, const char* fname,
241  const GmLogCategory** logger, int* searchMode, double* searchDomain,
242  GmSpatialIndex** spIndex, GmNumSolver** solver);
243 
244  void checkRuleSets(lua_State* L, const QList<GmGaussAccessor*>& list, const GmLogCategory& logger, bool warn);
245  void checkRuleSets(lua_State* L, const QList<const GmGaussAccessor*>& list, const GmLogCategory& logger, bool warn);
246 }
247 
248 
249 #endif
virtual const char * typeName() const
Returns the object type as will be stored in the object metatable.
Definition: gmLuaInterpolator.h:47
void parseCommonSplineParams(lua_State *L, bool nodeBased, int solverIndex, const char *fname, const GmLogCategory **logger, int *searchMode, double *searchDomain, GmSpatialIndex **spIndex, GmNumSolver **solver)
Parses the set of common parameters used by all types of LuaSplineMeshXxxToMeshXxxInterpolation() imp...
Definition: gmLuaInterpolator.cpp:1643
Declaration of the GmLuaObject class.
A proxy class to export GmNodeToCellPointInterpolator, GmNodeToCellPointMInterpolator,...
Definition: gmLuaInterpolator.h:41
virtual void * getClassMetatableID()
Returns an unique identifier to identify an user object as a GmLuaMesh object.
Definition: gmLuaInterpolator.h:54
bool _multi
Is the interpolator a multi attribute interpolator or for a single one?
Definition: gmLuaInterpolator.h:128
void checkRuleSets(lua_State *L, const QList< GmGaussAccessor * > &list, const GmLogCategory &logger, bool warn)
Overload for non constant accessors.
Definition: gmLuaInterpolator.cpp:1715
GmInterpolator * _interp
The interpolator, owned by this proxy object.
Definition: gmLuaInterpolator.h:64
int pushResults(lua_State *L, const GmVector &result, const QList< GmVector > &resultList, const GmLogCategory &logger, bool resultsCanBeEmpty=false)
Auxiliary function that given the results filing either result or resultLIst, pushes in the lua stack...
Definition: gmLuaInterpolator.cpp:1429
bool _multi
Is the interpolator a multi attribute interpolator or for a single one?
Definition: gmLuaInterpolator.h:158
bool _multi
Is the interpolator a multi attribute interpolator or for a single one?
Definition: gmLuaInterpolator.h:66
bool _multi
Is the interpolator a multi attribute interpolator or for a single one?
Definition: gmLuaInterpolator.h:189
virtual const char * typeName() const
Returns the object type as will be stored in the object metatable.
Definition: gmLuaInterpolator.h:80
A proxy class to export GmGaussCloudToPointInterpolator and GmGaussCloudToPointMInterpolator methods ...
Definition: gmLuaInterpolator.h:196
GmInterpolator * _interp
The interpolator, owned by this proxy object.
Definition: gmLuaInterpolator.h:219
A proxy class to export GmNodeCloudToPointInterpolator and GmNodeCloudToPointMInterpolator methods to...
Definition: gmLuaInterpolator.h:165
bool _resultAc
Does the interpolator stores result accessors?
Definition: gmLuaInterpolator.h:67
virtual void fillMetatable(lua_State *L, int index)=0
Function called by populateMetatable() to fill the metatable with exported methods by derived classes...
void parseValueAccessors(lua_State *L, int vIndex, int cIndex, const T *&valueAc, QList< const T * > &valueAcList, const GmValueAccessor *&coordAc, const char *acType)
Loads from the Lua stack the set of value accessors and the coordinate accessor, filling either value...
Definition: gmLuaInterpolator.cpp:1486
virtual void * getClassMetatableID()
Returns an unique identifier to identify an user object as a GmLuaMesh object.
Definition: gmLuaInterpolator.h:209
bool _multi
Is the interpolator a multi attribute interpolator or for a single one?
Definition: gmLuaInterpolator.h:220
GmInterpolator * _interp
The interpolator, owned by this proxy object.
Definition: gmLuaInterpolator.h:188
GmInterpolator * _interp
The interpolator, owned by this proxy object.
Definition: gmLuaInterpolator.h:97
virtual const char * typeName() const
Returns the object type as will be stored in the object metatable.
Definition: gmLuaInterpolator.h:140
A proxy class to export GmGaussNeighborsToNodeInterpolator and GmGaussNeighborsToNodeMInterpolator me...
Definition: gmLuaInterpolator.h:134
virtual const char * typeName() const
Returns the object type as will be stored in the object metatable.
Definition: gmLuaInterpolator.h:202
bool _elementBased
Is the interpolator element based (true) or cell based (false)?
Definition: gmLuaInterpolator.h:65
Aux functions used by several of the interpolator proxy classes.
Definition: gmLuaInterpolator.h:225
virtual QString toString() const
Default method used by the __tostring metamethod to capture the result of tostring() over an object.
Definition: gmLuaObject.h:55
GmInterpolator * _interp
The interpolator, owned by this proxy object.
Definition: gmLuaInterpolator.h:157
virtual const char * typeName() const
Returns the object type as will be stored in the object metatable.
Definition: gmLuaInterpolator.h:110
virtual void * getClassMetatableID()
Returns an unique identifier to identify an user object as a GmLuaMesh object.
Definition: gmLuaInterpolator.h:117
virtual void * getClassMetatableID()
Returns an unique identifier to identify an user object as a GmLuaMesh object.
Definition: gmLuaInterpolator.h:147
bool _resultAc
Does the interpolator stores result accessors?
Definition: gmLuaInterpolator.h:159
A proxy class to export object methods to the Lua environment.
Definition: gmLuaObject.h:35
void parseResultAccessors(lua_State *L, int index, T *&resultAc, QList< T * > &resultAcList, const V *valueAc, const QList< const V * > &valueAcList, const char *acType)
Loads from the Lua stack the set of result accessors, if any, filling either resultAc or resultAcList...
Definition: gmLuaInterpolator.cpp:1520
arma::vec GmVector
A proxy class to export GmGaussToElementNodeInterpolator and GmGaussToElementNodeMInterpolator method...
Definition: gmLuaInterpolator.h:104
A proxy class to export GmGaussToElementPointInterpolator and GmGaussToElementPointMInterpolator meth...
Definition: gmLuaInterpolator.h:74
virtual void * getClassMetatableID()
Returns an unique identifier to identify an user object as a GmLuaMesh object.
Definition: gmLuaInterpolator.h:87
GmInterpolator * _interp
The interpolator, owned by this proxy object.
Definition: gmLuaInterpolator.h:127
virtual const char * typeName() const
Returns the object type as will be stored in the object metatable.
Definition: gmLuaInterpolator.h:171
bool _multi
Is the interpolator a multi attribute interpolator or for a single one?
Definition: gmLuaInterpolator.h:98
void parseCommonParams(lua_State *L, bool nodeBased, const char *fname, const GmLogCategory **logger, int *interpType, QVariant *interpParam, int *searchMode, double *searchDomain, GmSpatialIndex **spIndex)
Parses the set of common parameters used by all types of LuaMeshXxxToMeshXxxInterpolation() implement...
Definition: gmLuaInterpolator.cpp:1583
virtual void * getClassMetatableID()
Returns an unique identifier to identify an user object as a GmLuaMesh object.
Definition: gmLuaInterpolator.h:178