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  virtual GA_CEAttribute *getWriteableCEAttribute(GA_AttributeOwner owner, const UT_StringRef &name, GA_StorageClass storage, int &tuplesize, bool isarray, bool docopy);
61 
62  virtual void flushCEWriteCaches() const;
63 
64 protected:
65  explicit SIM_GeometryCopy(const SIM_DataFactory *factory);
66  virtual ~SIM_GeometryCopy();
67 
68  /// Initializes this data by clearing our internal geometry and transform.
69  virtual void initializeSubclass();
70  /// This function creates an internal copy of any SIM_Geometry data
71  /// passed to it.
72  virtual void makeEqualSubclass(const SIM_Data *source);
73  /// Respond to setting our parameters by adjusting our transform.
74  /// The parameters will be in the standard t, r, s style which we
75  /// convert in to a matrix and multiply by our current transform.
76  virtual void setParametersSubclass(const SIM_Options &options);
77 
78 private:
79  static const SIM_DopDescription *getGeometryCopyDopDescription();
80 
81  int myDetailLockCount;
82  int myTransformLockCount;
83 
87  "Geometry Copy",
88  getGeometryCopyDopDescription());
89 };
90 
91 /// Utility class that handles creating a GU_DetailHandleAutoWriteLock and
92 /// calling releaseGeometry() when it goes out of scope.
94 {
95 public:
97  SIM_DataIdStrategy data_id_strategy = SIM_DATA_ID_BUMP)
98  : mySimGeo(simgeo),
99  myDataIdStrategy(data_id_strategy),
100  myHandle(mySimGeo->lockGeometry()),
101  myGdp(myHandle.writeLock())
102  {
103  }
104 
106  {
107  myHandle.unlock(myGdp);
108  mySimGeo->releaseGeometry(myDataIdStrategy);
109  }
110 
111  const GU_DetailHandle &handle() { return myHandle; }
112  GU_Detail &getGdp() { return *myGdp; }
113 
114 private:
115  SIM_GeometryCopy *mySimGeo;
116  const SIM_DataIdStrategy myDataIdStrategy;
117  GU_DetailHandle myHandle;
118  GU_Detail *myGdp;
119 };
120 
121 #endif
122 
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
virtual void initializeSubclass()
Set initial values on all the geometry attributes.
GA_StorageClass
Definition: GA_Types.h:68
virtual void makeEqualSubclass(const SIM_Data *source)
Makes this geometry equal to some other SIM_Geometry.
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
const GU_DetailHandle & handle()
int strategy
Definition: png.h:2009
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
SIM_GeometryAutoWriteLock(SIM_GeometryCopy *simgeo, SIM_DataIdStrategy data_id_strategy=SIM_DATA_ID_BUMP)
SIM_DataIdStrategy
GLuint const GLchar * name
Definition: glcorearb.h:785
virtual void flushCEWriteCaches() const
Clear any pending writes from the GPU.
GA_AttributeOwner
Definition: GA_Types.h:33
#define SIM_API
Definition: SIM_API.h:10
getOption("OpenEXR.storage") storage
Definition: HDK_Image.dox:276
virtual void setParametersSubclass(const SIM_Options &parms)
This implements a SIM_Geometry that copies the source geometry.