HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_SopMergeField.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  * COMMENTS:
7  */
8 
9 #ifndef __SIM_SopMergeField__
10 #define __SIM_SopMergeField__
11 
12 #include "SIMZ_API.h"
13 
15 
16 #include <SIM/SIM_RawField.h>
17 
18 #include <GAS/GAS_Calculate.h>
19 #include <GAS/GAS_Utils.h>
20 
22 {
23 public:
24  GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName);
25  GET_DATA_FUNC_S(GAS_NAME_STENCIL, StencilName);
26 
27  GET_DATA_FUNC_S("soppath", SopPath);
28  GET_DATA_FUNC_S("srcname", VolumeName);
29  GET_DATA_FUNC_S("dopmask", DopMask);
30  GET_DATA_FUNC_B("dabsolutemask", DAbsoluteMask);
31  GET_DATA_FUNC_B("dsdfmask", DSDFMask);
32  GET_DATA_FUNC_S("sopmask", SopMask);
33  GET_DATA_FUNC_B("sabsolutemask", SAbsoluteMask);
34  GET_DATA_FUNC_B("ssdfmask", SSDFMask);
35 
36  GET_DATA_FUNC_I("srctimescale", SrcTimeScale);
37  GET_DATA_FUNC_I("dsttimescale", DstTimeScale);
38  GET_DATA_FUNC_I("posttimescale", PostTimeScale);
39 
40  GET_DATA_FUNC_B("clamped", Clamped);
41  GET_DATA_FUNC_B("usevectornorm", UseVectorNorm);
42 
43  GET_DATA_FUNC_I("xformtype", TransformType);
44  GET_DATA_FUNC_S("xformpath", TransformObjPath);
45 
46  GET_DATA_FUNC_I("calculationtype", CalculationType);
47  GET_DATA_FUNC_B("guidedir", GuideDir);
48  GET_DATA_FUNC_F("mastrength", AccGuideStrength);
49  GET_DATA_FUNC_F("mdstrength", DecGuideStrength);
50  GET_DATA_FUNC_F("dirstrength", DirGuideStrength);
51 
52  GET_DATA_FUNC_F("dstpreadd", DstPreAdd);
53  GET_DATA_FUNC_F("dstpremul", DstPreMul);
54  GET_DATA_FUNC_I("dstconvert", DstConvert);
55  GET_DATA_FUNC_I("dstscale", DstScale);
56  GET_DATA_FUNC_F("srcpreadd", SrcPreAdd);
57  GET_DATA_FUNC_F("srcpremul", SrcPreMul);
58  GET_DATA_FUNC_I("srcconvert", SrcConvert);
59  GET_DATA_FUNC_I("srcscale", SrcScale);
60  GET_DATA_FUNC_F("postadd", PostAdd);
61  GET_DATA_FUNC_F("postmul", PostMul);
62  GET_DATA_FUNC_I("postconvert", PostConvert);
63  GET_DATA_FUNC_I("postscale", PostScale);
64 
65  GET_DATA_FUNC_B("warnmissing", WarnMissing);
68 
70  {
71  float accstr, decstr, dirstr;
72  bool clamped;
73  bool s_op, d_op, p_op;
74  bool sop_mask, sop_absolutemask,
76  bool dop_mask, dop_absolutemask,
78  float d_preadd, d_premul;
79  float s_preadd, s_premul;
80  float postadd, postmul;
82  LENGTHSCALE_NAMES srcscale, dstscale, postscale;
84  postconvert;
85  float d_width;
86  float s_width;
87 
89  };
90 
91 protected:
92  explicit SIM_SopMergeField(const SIM_DataFactory *factory);
93  ~SIM_SopMergeField() override;
94 
95  /// Calculates the desired procedure with dest and src, result going into
96  /// dest.
97  bool solveGasSubclass(SIM_Engine &engine,
98  SIM_Object *obj,
99  SIM_Time time,
100  SIM_Time timestep) override;
101 
102 private:
103  /// This function determines which ops (source, destination, post) actually
104  /// need to be performed (are not no ops).
105  void decideOps(SIM_SopMergeParms& parms)
106  {
107  parms.s_op = (parms.s_preadd != 0) ||
108  (parms.s_premul != 1) ||
109  (parms.srcscale != LENGTHSCALE_NONE) ||
110  (parms.srcconvert !=
111  GAS_Calculate::CONVERT_NAMES::CONVERT_NONE);
112  parms.d_op = (parms.calctype != MIX_COPY) &&
113  ((parms.d_preadd != 0) ||
114  (parms.d_premul != 1) ||
115  (parms.dstscale != LENGTHSCALE_NONE) ||
116  (parms.dstconvert !=
117  GAS_Calculate::CONVERT_NAMES::CONVERT_NONE));
118  parms.p_op = (parms.postadd != 0) ||
119  (parms.postmul != 1) ||
120  (parms.srcscale != LENGTHSCALE_NONE) ||
121  (parms.srcconvert !=
122  GAS_Calculate::CONVERT_NAMES::CONVERT_NONE);
123  }
124 
125  /// Mixes a single raw field with a single primitive (volume or VDB).
126  THREADED_METHOD7(SIM_SopMergeField, dst->shouldMultiThread(),
127  mixEachVoxelVolume,
128  SIM_RawField*, dst,
129  const SIM_RawField*, stencil,
130  const GEO_Primitive*, src,
131  const SIM_RawField*, mask,
132  const GEO_Primitive*, sopmask,
133  const UT_DMatrix4&, xform,
134  const SIM_SopMergeParms&, parms)
135  void mixEachVoxelVolumePartial(SIM_RawField* dst,
136  const SIM_RawField* stencil,
137  const GEO_Primitive* src,
138  const SIM_RawField* mask,
139  const GEO_Primitive* sopmask,
140  const UT_DMatrix4& xform,
141  const SIM_SopMergeParms& parms,
142  const UT_JobInfo& info);
143 
144  /// Mixes a triplet of raw fields with a triplet of volume or VDB
145  /// primitives, when calculation type is set to min or max and comparison
146  /// is performed using vector norms. Stores the result in the aligned fin
147  /// fields. The result is the difference between calculated and destination
148  /// values when storediff is set to true. In all cases, inactive regions
149  /// are left untouched in clamped mode; thus, fin fields should probably be
150  /// initialized to 0 when storediff is true.
151  /// Also works with a vector VDB, which should be in src[0]; in this case,
152  /// src[1] must be NULL.
154  fin[0]->shouldMultiThread() && fin[1]->shouldMultiThread()
155  && fin[2]->shouldMultiThread(),
156  mixEachVoxelVolumeNormed,
157  SIM_RawField**, fin,
158  SIM_RawField**, dst,
159  const SIM_RawField*, stencil,
160  const GEO_Primitive**, src,
161  const SIM_RawField*, mask,
162  const GEO_Primitive*, sopmask,
163  const UT_DMatrix4&, xform,
164  const SIM_SopMergeParms&, parms,
165  bool, storediff)
166  void mixEachVoxelVolumeNormedPartial(SIM_RawField* fin[3],
167  SIM_RawField* dst[3],
168  const SIM_RawField* stencil,
169  const GEO_Primitive* src[3],
170  const SIM_RawField* mask,
171  const GEO_Primitive* sopmask,
172  const UT_DMatrix4& xform,
173  const SIM_SopMergeParms& parms,
174  bool storediff,
175  const UT_JobInfo& info);
176 
177  /// Mixes a triplet of raw fields with a single vector VDB primitive. This
178  /// function uses component-wise comparison if calculation is set to min or
179  /// max.
180  /// The destination fields are assumed to be aligned. Non-aligned
181  /// components should be set to NULL.
183  (dst[0] == NULL || dst[0]->shouldMultiThread())
184  && (dst[1] == NULL || dst[1]->shouldMultiThread())
185  && (dst[2] == NULL || dst[2]->shouldMultiThread()),
186  mixEachVoxelVDBV,
187  SIM_RawField**, dst,
188  const SIM_RawField*, stencil,
189  const GEO_PrimVDB*, src,
190  const SIM_RawField*, mask,
191  const GEO_Primitive*, sopmask,
192  const UT_DMatrix4&, xform,
193  const SIM_SopMergeParms&, parms)
194  void mixEachVoxelVDBVPartial(SIM_RawField* dst[3],
195  const SIM_RawField* stencil,
196  const GEO_PrimVDB* src,
197  const SIM_RawField* mask,
198  const GEO_Primitive* sopmask,
199  const UT_DMatrix4& xform,
200  const SIM_SopMergeParms& parms,
201  const UT_JobInfo& info);
202 
203  /// This function adds contents of src to dst. If clamped is set to true,
204  /// voxels outside of the src bounding box can be skipped.
205  /// By the way this function is used by this class, we don't even bother
206  /// checking if src is aligned with dst (we know it's not).
207  THREADED_METHOD4(SIM_SopMergeField,
208  dst->shouldMultiThread(),
209  addEachVoxel,
210  SIM_RawField*, dst,
211  SIM_RawField*, src,
212  const SIM_RawField*, stencil,
213  bool, clamped)
214  void addEachVoxelPartial(SIM_RawField* dst,
215  SIM_RawField* src,
216  const SIM_RawField* stencil,
217  bool clamped,
218  const UT_JobInfo& info);
219 
220  /// These helper functions take care of merging the given field with the n-th
221  /// set of SOP sources volumes and masks. volumes and sopmasks contain the
222  /// parsed source volume and SOP mask names, respectively. Return value is
223  /// true if work was done and, thus, there might be more work to do.
224  /// If n is 0 (and generation of errors is enabled), an error will be thrown
225  /// if one occurs. The vector variant will also generate an error if the
226  /// source names correspond to VDBs that are a mix of scalar and vector.
227  inline bool mergeNthScalarField(SIM_Object* obj, SIM_ScalarField* dstscalar,
228  int n, const GU_Detail* newgdp,
229  const UT_WorkArgs& volumes,
230  const UT_WorkArgs& sopmasks,
231  const SIM_RawField* mask,
232  const UT_DMatrix4& sopxform,
233  SIM_SopMergeParms& parms);
234  inline bool mergeNthVectorField(SIM_Object* obj, SIM_VectorField* dstvector,
235  int n, const GU_Detail* newgdp,
236  const UT_WorkArgs& volumes,
237  const UT_WorkArgs& sopmasks,
238  const SIM_RawField* mask,
239  const UT_DMatrix4& sopxform,
240  SIM_SopMergeParms& parms);
241  inline bool mergeNthMatrixField(SIM_Object* obj, SIM_MatrixField* dstmatrix,
242  int n, const GU_Detail* newgdp,
243  const UT_WorkArgs& volumes,
244  const UT_WorkArgs& sopmasks,
245  const SIM_RawField* mask,
246  const UT_DMatrix4& sopxform,
247  SIM_SopMergeParms& parms);
248 
249  static const SIM_DopDescription *getDopDescription();
250 
252  DECLARE_DATAFACTORY(SIM_SopMergeField,
254  "SOP Merge Field",
255  getDopDescription());
256 
257  float myTimeStep;
258 };
259 
260 #endif
261 
#define SIMZ_API
Definition: SIMZ_API.h:10
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#define THREADED_METHOD7(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6, PARMTYPE7, PARMNAME7)
void
Definition: png.h:1083
GT_API const UT_StringHolder time
#define GAS_NAME_USETIMESTEP
Definition: GAS_Utils.h:39
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)=0
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
GLdouble n
Definition: glcorearb.h:2008
#define GET_DATA_FUNC_I(DataName, FuncName)
GLint GLuint mask
Definition: glcorearb.h:124
#define GAS_NAME_FIELDDEST
Definition: GAS_Utils.h:28
GAS_Calculate::CONVERT_NAMES srcconvert
GAS_Calculate::CONVERT_NAMES dstconvert
#define THREADED_METHOD4(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4)
This class holds a three dimensional tensor field.
GLenum GLenum dst
Definition: glcorearb.h:1793
#define GET_DATA_FUNC_B(DataName, FuncName)
#define GET_DATA_FUNC_F(DataName, FuncName)
This class holds a three dimensional scalar field.
#define GAS_NAME_TIMESCALE
Definition: GAS_Utils.h:40
#define THREADED_METHOD9(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5, PARMTYPE6, PARMNAME6, PARMTYPE7, PARMNAME7, PARMTYPE8, PARMNAME8, PARMTYPE9, PARMNAME9)
GLint GLfloat GLint stencil
Definition: glcorearb.h:1278
This class holds a three dimensional vector field.
#define GET_DATA_FUNC_S(DataName, FuncName)
#define GAS_NAME_STENCIL
Definition: GAS_Utils.h:19
GLenum src
Definition: glcorearb.h:1793