HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_GasAdd.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018
3  * Side Effects Software Inc. All rights reserved.
4  *
5  * Redistribution and use of Houdini Development Kit samples in source and
6  * binary forms, with or without modification, are permitted provided that the
7  * following conditions are met:
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  * 2. The name of Side Effects Software may not be used to endorse or
11  * promote products derived from this software without specific prior
12  * written permission.
13  *
14  * THIS SOFTWARE IS PROVIDED BY SIDE EFFECTS SOFTWARE `AS IS' AND ANY EXPRESS
15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
17  * NO EVENT SHALL SIDE EFFECTS SOFTWARE BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
19  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
20  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
22  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
23  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  *----------------------------------------------------------------------------
26  */
27 
28 #ifndef __SIM_GasAdd_h__
29 #define __SIM_GasAdd_h__
30 
31 #include <GAS/GAS_SubSolver.h>
32 #include <GAS/GAS_Utils.h>
33 
34 namespace HDK_Sample {
35 
36 /// A simple field manipulation class that will add fields
37 /// together.
38 class SIM_GasAdd : public GAS_SubSolver
39 {
40 public:
41  /// These macros are used to create the accessors
42  /// getFieldDstName and getFieldSrcName functions we'll use
43  /// to access our data options.
44  GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName);
46 
47 protected:
48  explicit SIM_GasAdd(const SIM_DataFactory *factory);
49  virtual ~SIM_GasAdd();
50 
51  /// Used to determine if the field is complicated enough to justify
52  /// the overhead of multithreading.
53  bool shouldMultiThread(const SIM_RawField *field) const
54  { return field->field()->numTiles() > 1; }
55 
56  /// The overloaded callback that GAS_SubSolver will invoke to
57  /// perform our actual computation. We are giving a single object
58  /// at a time to work on.
59  virtual bool solveGasSubclass(SIM_Engine &engine,
60  SIM_Object *obj,
61  SIM_Time time,
63 
64  /// Add two raw fields together. Use UT_ThreadedAlgorithm's macros
65  /// to define the addFields method that will invoke addFieldPartial()
66  /// on each worker thread.
68  addFields,
69  SIM_RawField *, dst,
70  const SIM_RawField *, src);
71 
73 
74 private:
75  /// We define this to be a DOP_Auto node which means we do not
76  /// need to implement a DOP_Node derivative for this data. Instead,
77  /// this description is used to define the interface.
78  static const SIM_DopDescription *getDopDescription();
79 
80  /// These macros are necessary to bind our node to the factory and
81  /// ensure useful constants like BaseClass are defined.
82  DECLARE_STANDARD_GETCASTTOTYPE();
83  DECLARE_DATAFACTORY(SIM_GasAdd,
85  "Gas Add",
86  getDopDescription());
87 };
88 
89 } // End HDK_Sample namespace
90 
91 #endif
92 
THREADED_METHOD2(SIM_GasAdd, shouldMultiThread(dst), addFields, SIM_RawField *, dst, const SIM_RawField *, src)
SIM_GasAdd(const SIM_DataFactory *factory)
Definition: SIM_GasAdd.C:56
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)
Definition: SIM_GasAdd.C:91
bool shouldMultiThread(const SIM_RawField *field) const
Definition: SIM_GasAdd.h:53
int numTiles() const
#define GAS_NAME_FIELDSOURCE
Definition: GAS_Utils.h:27
#define GAS_NAME_FIELDDEST
Definition: GAS_Utils.h:26
GLenum GLenum dst
Definition: glcorearb.h:1792
GET_DATA_FUNC_S(GAS_NAME_FIELDDEST, FieldDstName)
const UT_JobInfo & info
UT_VoxelArrayF UT_VoxelArrayF & field
const GA_PointGroup SIM_Time timestep
void addFieldsPartial(SIM_RawField *dst, const SIM_RawField *src, const UT_JobInfo &info)
Definition: SIM_GasAdd.C:161
GLenum src
Definition: glcorearb.h:1792