HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 
45  /// This method provides access to the internal transform so that it
46  /// can be modified. For each call to lockTransform(), there must be a
47  /// corresponding call to releaseTransform(). Calls to lockTransform()
48  /// can be nested.
49  UT_DMatrix4 &lockTransform();
50  /// This function releases the lock on our internal transform. This
51  /// function must be called once for each call to lockTransform(). Also,
52  /// once this function has been called, no more modifications should be
53  /// made to the transform returned by lockTransform() or the result will
54  /// be undefined.
55  void releaseTransform();
56 
57  /// Build a GPU backed version of the attribute that is marked
58  /// to be written back to the GU_Detail after computation completes.
59  virtual GA_CEAttribute *getWriteableCEAttribute(GA_AttributeOwner owner, const UT_StringRef &name, GA_StorageClass storage, int &tuplesize, bool isarray, bool docopy);
60 
61  virtual void flushCEWriteCaches() const;
62 
63 protected:
64  explicit SIM_GeometryCopy(const SIM_DataFactory *factory);
65  virtual ~SIM_GeometryCopy();
66 
67  /// Initializes this data by clearing our internal geometry and transform.
68  virtual void initializeSubclass();
69  /// This function creates an internal copy of any SIM_Geometry data
70  /// passed to it.
71  virtual void makeEqualSubclass(const SIM_Data *source);
72  /// Respond to setting our parameters by adjusting our transform.
73  /// The parameters will be in the standard t, r, s style which we
74  /// convert in to a matrix and multiply by our current transform.
75  virtual void setParametersSubclass(const SIM_Options &options);
76 
77 private:
78  static const SIM_DopDescription *getGeometryCopyDopDescription();
79 
80  int myDetailLockCount;
81  int myTransformLockCount;
82 
86  "Geometry Copy",
87  getGeometryCopyDopDescription());
88 };
89 
90 /// Utility class that handles creating a GU_DetailHandleAutoWriteLock and
91 /// calling releaseGeometry() when it goes out of scope.
93 {
94 public:
96  SIM_DataIdStrategy data_id_strategy = SIM_DATA_ID_BUMP)
97  : mySimGeo(simgeo),
98  myDataIdStrategy(data_id_strategy),
99  myHandle(mySimGeo->lockGeometry()),
100  myGdp(myHandle.writeLock())
101  {
102  }
103 
105  {
106  myHandle.unlock(myGdp);
107  mySimGeo->releaseGeometry(myDataIdStrategy);
108  }
109 
110  const GU_DetailHandle &handle() { return myHandle; }
111  GU_Detail &getGdp() { return *myGdp; }
112 
113 private:
114  SIM_GeometryCopy *mySimGeo;
115  const SIM_DataIdStrategy myDataIdStrategy;
116  GU_DetailHandle myHandle;
117  GU_Detail *myGdp;
118 };
119 
120 #endif
121 
#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.