HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GAS_LinearCombination.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GAS_LinearCombination.h ( GAS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GAS_LinearCombination_h__
12 #define __GAS_LinearCombination_h__
13 
14 #include "GAS_SubSolver.h"
15 #include "GAS_Utils.h"
16 #include <GA/GA_SplittableRange.h>
17 
19 {
20 public:
21  GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName);
22  GET_DATA_FUNC_S(GAS_NAME_GEOMETRY, GeometryName);
23  GET_DATA_FUNC_S(GAS_NAME_STENCIL, StencilName);
24 
25  GET_DATA_FUNC_B("createattrib", CreateAttrib);
26  GETSET_DATA_FUNCS_I("operation", Operation);
27  GET_DATA_FUNC_S("source1", FieldSrc1Name);
28  GETSET_DATA_FUNCS_F("coeff1", Coeff1);
29  GET_DATA_FUNC_S("source2", FieldSrc2Name);
30  GETSET_DATA_FUNCS_F("coeff2", Coeff2);
31  GET_DATA_FUNC_S("source3", FieldSrc3Name);
32  GETSET_DATA_FUNCS_F("coeff3", Coeff3);
33  GETSET_DATA_FUNCS_B("useconstant", UseConstant);
34  GETSET_DATA_FUNCS_F("constant", Constant);
35  GETSET_DATA_FUNCS_F("coeffpost", CoeffPost);
36 
39  GET_DATA_FUNC_B(SIM_NAME_OPENCL, UseOpenCL);
40 
41 protected:
42  explicit GAS_LinearCombination(const SIM_DataFactory *factory);
43  virtual ~GAS_LinearCombination();
44 
45 
46  /// The overloaded callback that GAS_SubSolver will invoke to
47  /// perform our actual computation. We are giving a single object
48  /// at a time to work on.
49  virtual bool solveGasSubclass(SIM_Engine &engine,
50  SIM_Object *obj,
51  SIM_Time time,
53 
54 
55 private:
56 
57  /// Applies the scales for timescale%s and lengthscale%s
58  fpreal applyScales(fpreal val, const char *suffix,
59  const UT_Vector3 &voxelsize,
60  SIM_Time timestep) const;
61 
62  void getCoefficientsAndConstant(fpreal coeff[3],
63  fpreal &constant,
64  bool &useconstant,
65  MIX_NAMES &mixtype,
66  fpreal &coeffpost,
67  const UT_Vector3 &voxsize,
68  SIM_Time timestep,
69  bool valid[3]) const;
70 
71  THREADED_METHOD9(GAS_LinearCombination, dst->shouldMultiThread(),
72  linearCombine,
73  SIM_RawField *, dst,
74  int, numsrc,
75  const SIM_RawField **, src,
76  const SIM_RawField *, stencil,
77  float *, coeff,
78  bool, useconstant,
79  float , constant,
80  float , coeffpost,
81  MIX_NAMES, mixtype)
82  void linearCombinePartial(SIM_RawField *dst,
83  int numsrc,
84  const SIM_RawField **src,
85  const SIM_RawField *stencil,
86  float *coeff,
87  bool useconstant,
88  float constant,
89  float coeffpost,
90  MIX_NAMES mixtype,
91  const UT_JobInfo &info);
92 
93  THREADED_METHOD3_CONST(GAS_LinearCombination, dest->shouldMultiThread(),
94  makeConstantInActiveRegion,
95  SIM_RawField*, dest,
96  const SIM_RawField*, activity,
97  float, val);
98  void makeConstantInActiveRegionPartial(SIM_RawField* dest,
99  const SIM_RawField* activity,
100  float val,
101  const UT_JobInfo& info) const;
102 
103 
104  class linearCombineAttrParms
105  {
106  public:
107  GA_RWHandleF *dest_h;
108  int numsrc;
109  const GA_ROHandleF *src;
110  const float *coeff;
111  bool useconstant;
112  float constant;
113  float coeffpost;
114  MIX_NAMES mixtype;
115  int comp;
116  };
117 
118 
119  THREADED_METHOD2(GAS_LinearCombination, range.canMultiThread(),
120  linearCombineAttr,
121  const GA_SplittableRange &, range,
122  linearCombineAttrParms &, parms);
123  void linearCombineAttrPartial(const GA_SplittableRange &range,
124  linearCombineAttrParms &parms,
125  const UT_JobInfo &info);
126 
127  bool linearCombineCL(SIM_Object *obj,
128  SIM_RawField *dst,
129  int numsrc,
130  const SIM_RawField **src,
131  float *coeff,
132  bool useconstant,
133  float constant,
134  float coeffpost,
135  MIX_NAMES mixtype,
136  int axis);
137 
138  bool linearCombineField(SIM_RawField* dst, SIM_Object *obj,
139  SIM_Time timestep, int a1, int a2);
140 
141  bool linearCombineAttribute(GA_Detail *gdp,
142  const GA_PointGroup *ptgrp,
143  GA_RWHandleF &dest_h,
144  SIM_Object *obj,
145  SIM_Time timestep, int comp);
146 
147  /// We define this to be a DOP_Auto node which means we do not
148  /// need to implement a DOP_Node derivative for this data. Instead,
149  /// this description is used to define the interface.
150  static const SIM_DopDescription *getDopDescription();
151 
152  /// These macros are necessary to bind our node to the factory and
153  /// ensure useful constants like BaseClass are defined.
154  DECLARE_STANDARD_GETCASTTOTYPE();
155  DECLARE_DATAFACTORY(GAS_LinearCombination,
157  "Gas Linear Combination",
158  getDopDescription());
159 };
160 
161 
162 #endif
163 
GLenum GLint * range
Definition: glew.h:3500
GLenum src
Definition: glew.h:2410
const GA_PointGroup * ptgrp
#define GAS_NAME_GEOMETRY
Definition: GAS_Utils.h:30
GT_API const UT_StringHolder time
#define GAS_NAME_USETIMESTEP
Definition: GAS_Utils.h:39
GLuint const GLfloat * val
Definition: glew.h:2794
GETSET_DATA_FUNCS_F("coeff1", Coeff1)
GLhandleARB obj
Definition: glew.h:6236
GLint GLfloat GLint stencil
Definition: glew.h:2167
GAS_LinearCombination(const SIM_DataFactory *factory)
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)
virtual ~GAS_LinearCombination()
GLenum GLenum dst
Definition: glew.h:2410
#define GAS_NAME_FIELDDEST
Definition: GAS_Utils.h:28
typedef int(WINAPI *PFNWGLRELEASEPBUFFERDCARBPROC)(HPBUFFERARB hPbuffer
GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName)
GET_DATA_FUNC_F(GAS_NAME_TIMESCALE, TimeScale)
double fpreal
Definition: SYS_Types.h:276
#define SIM_NAME_OPENCL
Definition: SIM_Names.h:222
#define GAS_NAME_TIMESCALE
Definition: GAS_Utils.h:40
GETSET_DATA_FUNCS_B("useconstant", UseConstant)
Container class for all geometry.
Definition: GA_Detail.h:95
GET_DATA_FUNC_B("createattrib", CreateAttrib)
GETSET_DATA_FUNCS_I("operation", Operation)
#define GAS_NAME_STENCIL
Definition: GAS_Utils.h:19
const GA_PointGroup SIM_Time timestep