HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
24  GET_DATA_FUNC_B("createattrib", CreateAttrib);
25  GETSET_DATA_FUNCS_I("operation", Operation);
26  GET_DATA_FUNC_S("source1", FieldSrc1Name);
27  GETSET_DATA_FUNCS_F("coeff1", Coeff1);
28  GET_DATA_FUNC_S("source2", FieldSrc2Name);
29  GETSET_DATA_FUNCS_F("coeff2", Coeff2);
30  GET_DATA_FUNC_S("source3", FieldSrc3Name);
31  GETSET_DATA_FUNCS_F("coeff3", Coeff3);
32  GETSET_DATA_FUNCS_B("useconstant", UseConstant);
33  GETSET_DATA_FUNCS_F("constant", Constant);
34  GETSET_DATA_FUNCS_F("coeffpost", CoeffPost);
35 
38  GET_DATA_FUNC_B(SIM_NAME_OPENCL, UseOpenCL);
39 
40 protected:
41  explicit GAS_LinearCombination(const SIM_DataFactory *factory);
42  virtual ~GAS_LinearCombination();
43 
44 
45  /// The overloaded callback that GAS_SubSolver will invoke to
46  /// perform our actual computation. We are giving a single object
47  /// at a time to work on.
48  virtual bool solveGasSubclass(SIM_Engine &engine,
49  SIM_Object *obj,
50  SIM_Time time,
52 
53 
54 private:
55 
56  /// Applies the scales for timescale%s and lengthscale%s
57  fpreal applyScales(fpreal val, const char *suffix,
58  const UT_Vector3 &voxelsize,
59  SIM_Time timestep) const;
60 
61  void getCoefficientsAndConstant(fpreal coeff[3],
62  fpreal &constant,
63  bool &useconstant,
64  MIX_NAMES &mixtype,
65  fpreal &coeffpost,
66  const UT_Vector3 &voxsize,
67  SIM_Time timestep,
68  bool valid[3]) const;
69 
70  THREADED_METHOD8(GAS_LinearCombination, dst->shouldMultiThread(),
71  linearCombine,
72  SIM_RawField *, dst,
73  int, numsrc,
74  const SIM_RawField **, src,
75  float *, coeff,
76  bool, useconstant,
77  float , constant,
78  float , coeffpost,
79  MIX_NAMES, mixtype)
80  void linearCombinePartial(SIM_RawField *dst,
81  int numsrc,
82  const SIM_RawField **src,
83  float *coeff,
84  bool useconstant,
85  float constant,
86  float coeffpost,
87  MIX_NAMES mixtype,
88  const UT_JobInfo &info);
89 
90 
91  class linearCombineAttrParms
92  {
93  public:
94  GA_RWHandleF *dest_h;
95  int numsrc;
96  const GA_ROHandleF *src;
97  const float *coeff;
98  bool useconstant;
99  float constant;
100  float coeffpost;
101  MIX_NAMES mixtype;
102  int comp;
103  };
104 
105 
106  THREADED_METHOD2(GAS_LinearCombination, range.canMultiThread(),
107  linearCombineAttr,
108  const GA_SplittableRange &, range,
109  linearCombineAttrParms &, parms);
110  void linearCombineAttrPartial(const GA_SplittableRange &range,
111  linearCombineAttrParms &parms,
112  const UT_JobInfo &info);
113 
114  bool linearCombineCL(SIM_Object *obj,
115  SIM_RawField *dst,
116  int numsrc,
117  const SIM_RawField **src,
118  float *coeff,
119  bool useconstant,
120  float constant,
121  float coeffpost,
122  MIX_NAMES mixtype,
123  int axis);
124 
125  bool linearCombineField(SIM_RawField* dst, SIM_Object *obj,
126  SIM_Time timestep, int a1, int a2);
127 
128  bool linearCombineAttribute(GA_Detail *gdp,
129  const GA_PointGroup *ptgrp,
130  GA_RWHandleF &dest_h,
131  SIM_Object *obj,
132  SIM_Time timestep, int comp);
133 
134  /// We define this to be a DOP_Auto node which means we do not
135  /// need to implement a DOP_Node derivative for this data. Instead,
136  /// this description is used to define the interface.
137  static const SIM_DopDescription *getDopDescription();
138 
139  /// These macros are necessary to bind our node to the factory and
140  /// ensure useful constants like BaseClass are defined.
141  DECLARE_STANDARD_GETCASTTOTYPE();
142  DECLARE_DATAFACTORY(GAS_LinearCombination,
144  "Gas Linear Combination",
145  getDopDescription());
146 };
147 
148 
149 #endif
150 
GLenum GLint * range
Definition: glcorearb.h:1924
const GA_PointGroup * ptgrp
#define GAS_NAME_GEOMETRY
Definition: GAS_Utils.h:28
#define GAS_NAME_USETIMESTEP
Definition: GAS_Utils.h:37
GETSET_DATA_FUNCS_F("coeff1", Coeff1)
GAS_LinearCombination(const SIM_DataFactory *factory)
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)
virtual ~GAS_LinearCombination()
#define GAS_NAME_FIELDDEST
Definition: GAS_Utils.h:26
GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName)
GET_DATA_FUNC_F(GAS_NAME_TIMESCALE, TimeScale)
GLenum GLenum dst
Definition: glcorearb.h:1792
double fpreal
Definition: SYS_Types.h:263
typedef int
Definition: png.h:1175
GLuint GLfloat * val
Definition: glcorearb.h:1607
#define SIM_NAME_OPENCL
Definition: SIM_Names.h:221
#define GAS_NAME_TIMESCALE
Definition: GAS_Utils.h:38
GETSET_DATA_FUNCS_B("useconstant", UseConstant)
Container class for all geometry.
Definition: GA_Detail.h:96
GET_DATA_FUNC_B("createattrib", CreateAttrib)
GETSET_DATA_FUNCS_I("operation", Operation)
const GA_PointGroup SIM_Time timestep
GLenum src
Definition: glcorearb.h:1792