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_I("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  fpreal getConstantVec(int comp) const
42  {
43  static constexpr UT_StringLit name("constantv");
44  return getOptions().getOptionV3(name.asRef())(comp);
45  }
46 
47 protected:
48  explicit GAS_LinearCombination(const SIM_DataFactory *factory);
49  ~GAS_LinearCombination() override;
50 
51 
52  /// The overloaded callback that GAS_SubSolver will invoke to
53  /// perform our actual computation. We are giving a single object
54  /// at a time to work on.
55  bool solveGasSubclass(SIM_Engine &engine,
56  SIM_Object *obj,
57  SIM_Time time,
58  SIM_Time timestep) override;
59 
60 
61 private:
62 
63  /// Applies the scales for timescale%s and lengthscale%s
64  fpreal applyScales(fpreal val, const char *suffix,
65  const UT_Vector3 &voxelsize,
66  SIM_Time timestep) const;
67 
68  void getCoefficientsAndConstant(fpreal coeff[3],
69  fpreal &constant,
70  bool &useconstant,
71  MIX_NAMES &mixtype,
72  fpreal &coeffpost,
73  const UT_Vector3 &voxsize,
75  bool valid[3],
76  int comp) const;
77 
78  THREADED_METHOD9(GAS_LinearCombination, dst->shouldMultiThread(),
79  linearCombine,
80  SIM_RawField *, dst,
81  int, numsrc,
82  const SIM_RawField **, src,
83  const SIM_RawField *, stencil,
84  float *, coeff,
85  bool, useconstant,
86  float , constant,
87  float , coeffpost,
88  MIX_NAMES, mixtype)
89  void linearCombinePartial(SIM_RawField *dst,
90  int numsrc,
91  const SIM_RawField **src,
92  const SIM_RawField *stencil,
93  float *coeff,
94  bool useconstant,
95  float constant,
96  float coeffpost,
97  MIX_NAMES mixtype,
98  const UT_JobInfo &info);
99 
100  THREADED_METHOD3_CONST(GAS_LinearCombination, dest->shouldMultiThread(),
101  makeConstantInActiveRegion,
102  SIM_RawField*, dest,
103  const SIM_RawField*, activity,
104  float, val);
105  void makeConstantInActiveRegionPartial(SIM_RawField* dest,
106  const SIM_RawField* activity,
107  float val,
108  const UT_JobInfo& info) const;
109 
110 
111  class linearCombineAttrParms
112  {
113  public:
114  GA_RWHandleF *dest_h;
115  int numsrc;
116  const GA_ROHandleF *src;
117  const float *coeff;
118  bool useconstant;
119  float constant;
120  float coeffpost;
121  MIX_NAMES mixtype;
122  int comp;
123  };
124 
125 
126  THREADED_METHOD2(GAS_LinearCombination, range.canMultiThread(),
127  linearCombineAttr,
128  const GA_SplittableRange &, range,
129  linearCombineAttrParms &, parms);
130  void linearCombineAttrPartial(const GA_SplittableRange &range,
131  linearCombineAttrParms &parms,
132  const UT_JobInfo &info);
133 
134  bool linearCombineCL(SIM_Object *obj,
135  SIM_RawField *dst,
136  int numsrc,
137  const SIM_RawField **src,
138  float *coeff,
139  bool useconstant,
140  float constant,
141  float coeffpost,
142  MIX_NAMES mixtype,
143  int axis);
144 
145  bool linearCombineField(SIM_RawField* dst, SIM_Object *obj,
146  SIM_Time timestep, int a1, int a2);
147 
148  bool linearCombineAttribute(GA_Detail *gdp,
149  const GA_PointGroup *ptgrp,
150  GA_RWHandleF &dest_h,
151  SIM_Object *obj,
152  SIM_Time timestep, int comp);
153 
154  /// We define this to be a DOP_Auto node which means we do not
155  /// need to implement a DOP_Node derivative for this data. Instead,
156  /// this description is used to define the interface.
157  static const SIM_DopDescription *getDopDescription();
158 
159  /// These macros are necessary to bind our node to the factory and
160  /// ensure useful constants like BaseClass are defined.
161  DECLARE_STANDARD_GETCASTTOTYPE();
162  DECLARE_DATAFACTORY(GAS_LinearCombination,
164  "Gas Linear Combination",
165  getDopDescription());
166 };
167 
168 
169 #endif
170 
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep) override
GLenum GLint * range
Definition: glcorearb.h:1925
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
GETSET_DATA_FUNCS_F("coeff1", Coeff1)
const UT_Vector3D & getOptionV3(const UT_StringRef &name) const
fpreal getConstantVec(int comp) const
GAS_LinearCombination(const SIM_DataFactory *factory)
IMATH_NAMESPACE::V2f float
#define GAS_NAME_FIELDDEST
Definition: GAS_Utils.h:28
GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName)
GET_DATA_FUNC_F(GAS_NAME_TIMESCALE, TimeScale)
const SIM_Options & getOptions() const
GLenum GLenum dst
Definition: glcorearb.h:1793
fpreal64 fpreal
Definition: SYS_Types.h:277
GLuint GLfloat * val
Definition: glcorearb.h:1608
#define SIM_NAME_OPENCL
Definition: SIM_Names.h:222
#define GAS_NAME_TIMESCALE
Definition: GAS_Utils.h:40
Container class for all geometry.
Definition: GA_Detail.h:96
GET_DATA_FUNC_B("createattrib", CreateAttrib)
GETSET_DATA_FUNCS_I("operation", Operation)
GLint GLfloat GLint stencil
Definition: glcorearb.h:1278
~GAS_LinearCombination() override
#define GAS_NAME_STENCIL
Definition: GAS_Utils.h:19
const GA_PointGroup SIM_Time timestep
GLenum src
Definition: glcorearb.h:1793