HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_GeometryCopy.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  */
7 
8 #ifndef __SIM_GeometryCopy_h__
9 #define __SIM_GeometryCopy_h__
10 
11 #include "SIM_API.h"
12 #include <UT/UT_DMatrix4.h>
13 #include "SIM_Geometry.h"
14 
16 {
17  /// The default strategy is to bump all data ids after releasing the lock
18  /// on the SIM_GeometryCopy's internal geometry.
20 
21  /// The data ids will not be automatically bumped, and the caller is
22  /// responsible for bumping data ids on any modified attributes.
24 };
25 
26 /// This implements a SIM_Geometry that copies the source geometry.
28 {
29 public:
30  /// This method provides access to the internal geometry so that it
31  /// can be modified. For each call to lockGeometry(), there must be a
32  /// corresponding call to releaseGeometry(). Calls to lockGeomtry()
33  /// can be nested.
34  GU_DetailHandle lockGeometry();
35  /// This function releases the lock on our internal geometry. This
36  /// function must be called once for each call to lockGeometry(). Also,
37  /// once this function has been called, no more modifications should be
38  /// made to the geometry returned by lockGeometry() or the result will
39  /// be undefined.
40  void releaseGeometry(SIM_DataIdStrategy strategy = SIM_DATA_ID_BUMP);
41 
42  /// Swaps the internal geometry with the provided one.
43  GU_DetailHandle swapGeometry(GU_DetailHandle replacement);
44  GU_DetailHandle swapGeometryWithoutCEFlush(GU_DetailHandle replacement, bool &hascedata);
45 
46  /// This method provides access to the internal transform so that it
47  /// can be modified. For each call to lockTransform(), there must be a
48  /// corresponding call to releaseTransform(). Calls to lockTransform()
49  /// can be nested.
50  UT_DMatrix4 &lockTransform();
51  /// This function releases the lock on our internal transform. This
52  /// function must be called once for each call to lockTransform(). Also,
53  /// once this function has been called, no more modifications should be
54  /// made to the transform returned by lockTransform() or the result will
55  /// be undefined.
56  void releaseTransform();
57 
58  /// Build a GPU backed version of the attribute that is marked
59  /// to be written back to the GU_Detail after computation completes.
60  GA_CEAttribute *getWriteableCEAttribute(GA_AttributeOwner owner, const UT_StringRef &name, GA_StorageClass storage, int &tuplesize, bool isarray, bool docopy) { return getWriteableCEAttributePrec(owner, name, storage, GA_PRECISION_32, tuplesize, isarray, docopy); }
61  virtual GA_CEAttribute *getWriteableCEAttributePrec(GA_AttributeOwner owner, const UT_StringRef &name, GA_StorageClass storage, GA_Precision precision, int &tuplesize, bool isarray, bool docopy);
62 
63  void flushCEWriteCaches() const override;
64 
65  void makeMemberDataUniqueSubclass() override;
66 
67 protected:
68  explicit SIM_GeometryCopy(const SIM_DataFactory *factory);
69  ~SIM_GeometryCopy() override;
70 
71  /// Initializes this data by clearing our internal geometry and transform.
72  void initializeSubclass() override;
73  /// This function creates an internal copy of any SIM_Geometry data
74  /// passed to it.
75  void makeEqualSubclass(const SIM_Data *source) override;
76  /// Respond to setting our parameters by adjusting our transform.
77  /// The parameters will be in the standard t, r, s style which we
78  /// convert in to a matrix and multiply by our current transform.
80  const SIM_Options &options) override;
81 
82 private:
83  static const SIM_DopDescription *getGeometryCopyDopDescription();
84 
85  int myDetailLockCount;
86  int myTransformLockCount;
87 
91  "Geometry Copy",
92  getGeometryCopyDopDescription());
93 };
94 
95 /// Utility class that handles creating a GU_DetailHandleAutoWriteLock and
96 /// calling releaseGeometry() when it goes out of scope.
98 {
99 public:
101  SIM_DataIdStrategy data_id_strategy = SIM_DATA_ID_BUMP)
102  : mySimGeo(simgeo),
103  myDataIdStrategy(data_id_strategy),
104  myHandle(mySimGeo->lockGeometry()),
105  myGdp(myHandle.writeLock())
106  {
107  }
108 
110  {
111  myHandle.unlock(myGdp);
112  mySimGeo->releaseGeometry(myDataIdStrategy);
113  }
114 
115  const GU_DetailHandle &handle() { return myHandle; }
116  GU_Detail &getGdp() { return *myGdp; }
117 
118 private:
119  SIM_GeometryCopy *mySimGeo;
120  const SIM_DataIdStrategy myDataIdStrategy;
121  GU_DetailHandle myHandle;
122  GU_Detail *myGdp;
123 };
124 
125 #endif
126 
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
GA_StorageClass
Definition: GA_Types.h:73
getFileOption("OpenEXR:storage") storage
Definition: HDK_Image.dox:276
GA_Precision
Definition: GA_Types.h:88
void initializeSubclass() override
Set initial values on all the geometry attributes.
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
const GU_DetailHandle & handle()
GA_CEAttribute * getWriteableCEAttribute(GA_AttributeOwner owner, const UT_StringRef &name, GA_StorageClass storage, int &tuplesize, bool isarray, bool docopy)
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
SIM_GeometryAutoWriteLock(SIM_GeometryCopy *simgeo, SIM_DataIdStrategy data_id_strategy=SIM_DATA_ID_BUMP)
SIM_DataIdStrategy
GLuint const GLchar * name
Definition: glcorearb.h:786
virtual void makeMemberDataUniqueSubclass()
Definition: SIM_Data.h:508
virtual void flushCEWriteCaches() const
Clear any pending writes from the GPU.
GLenum GLint GLint * precision
Definition: glcorearb.h:1925
GA_AttributeOwner
Definition: GA_Types.h:35
#define SIM_API
Definition: SIM_API.h:12
void makeEqualSubclass(const SIM_Data *source) override
Makes this geometry equal to some other SIM_Geometry.
virtual void setParametersSubclass(const SIM_Options &parms)
This implements a SIM_Geometry that copies the source geometry.