HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GU_PackedGeometry.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  * NAME: GU_PackedGeometry.h (GU Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GU_PackedGeometry__
12 #define __GU_PackedGeometry__
13 
14 #include "GU_PackedImpl.h"
15 #include "GU_DetailHandle.h"
16 #include <GA/GA_Stat.h>
17 
19 
20 /// Geometry Embedded procedural
22 {
23 public:
26  ~GU_PackedGeometry() override;
27 
28  /// Convenience method to create a packed primitive in the destination
29  /// detail which embeds the source detail. The source detail will be
30  /// copied into the embedded detail.
31  /// The source detail's bounding box will be computed. (But then
32  /// cached in the source detail, so multple packs should only
33  /// compute the first time)
34  ///
35  /// Returns a NULL pointer if the process fails.
36  /// @{
37  static GU_PrimPacked *packGeometry(GU_Detail &dest,
38  const GU_ConstDetailHandle &gdh);
39  static GU_PrimPacked *packGeometry(
40  GU_Detail &dest,
41  const GU_ConstDetailHandle &gdh,
42  GA_Offset ptoff);
43  /// @}
44 
45  /// Provide a bounding box of the gdh, compatible with gdh.getBBox()
46  /// useful if you already had to compute it while building gdh.
47  /// An invalid bounding box will generate a recompute later,
48  /// so can be used if you must delay computation, but this is
49  /// not recommended as many readers may demand it simultanesously
50  /// leading to performance problems.
51  /// @{
52  static GU_PrimPacked *packGeometry(GU_Detail &dest,
53  const GU_ConstDetailHandle &gdh,
54  const UT_BoundingBox &bbox);
55  static GU_PrimPacked *packGeometry(GU_Detail &dest,
56  const GU_ConstDetailHandle &gdh,
57  const UT_BoundingBox &bbox,
58  GA_Offset ptoff);
59  /// @}
60 
61  /// Install the procedural
62  static void install(GA_PrimitiveFactory *prim);
63 
64  /// Get the type ID for the GU_PackedGeometry primitive type.
66  {
67  return theTypeId;
68  }
69 
70  /// @{
71  /// Implementation of GU_PackedImpl interface
72  GU_PackedFactory *getFactory() const override;
73  GU_PackedImpl *copy() const override;
74 
75  bool isValid() const override;
76  void clearData() override;
77  bool load(GU_PrimPacked *prim, const UT_Options &options,
78  const GA_LoadMap &map) override
79  { return loadFrom(options, map); }
80  bool supportsJSONLoad() const override { return true; }
82  GU_PrimPacked *prim,
83  const UT_JSONValueMap &options,
84  const GA_LoadMap &map) override
85  { return loadFrom(options, map); }
86  void update(GU_PrimPacked *prim,
87  const UT_Options &options) override;
88  bool save(UT_Options &options,
89  const GA_SaveMap &map) const override;
90  bool getBounds(UT_BoundingBox &box) const override;
91  bool getRenderingBounds(UT_BoundingBox &box) const override;
93  UT_Vector3 &max) const override;
94  void getWidthRange(fpreal &min,
95  fpreal &max) const override;
96 
97  bool unpackWithContext(
98  GU_Detail &destgdp,
99  GU_PackedContext &context,
100  const GU_PrimPacked *prim) const override;
101  bool unpack(GU_Detail &destgdp,
102  const UT_Matrix4D *transform) const override;
103  void forceLoad() const override;
104  bool isLoaded() const override;
106  GU_PackedContext *context = 0) const override;
108  int dtype,
109  const GA_SharedLoadData *it) override
110  {
111  UT_ASSERT(0 && "Should not be called!");
112  return false;
113  }
114  bool saveSharedData(
115  UT_JSONWriter &w,
116  GA_SaveMap &map,
117  GA_GeometryIndex *geo_index) const override;
118 
119  /// Report memory usage (includes all shared memory)
120  int64 getMemoryUsage(bool inclusive) const override;
121 
122  /// Count memory usage using a UT_MemoryCounter in order to count
123  /// shared memory correctly.
125  bool inclusive) const override;
126 
127  /// We will be saving the contents in the same file so we don't
128  /// have to worry about them changing. This avoids having
129  /// to seek & stat to restore as bbox.
130  bool saveCachedBBox() const override { return true; }
131 
132  /// @}
133 
134  /// @{
135  /// Member data accessors for intrinsics
137  {
138  loadPackedGeometry();
139  GU_DetailHandleAutoReadLock gdl(myDetail);
140  const GU_Detail *gdp = gdl.getGdp();
141  return gdp ? gdp->getUniqueId() : -1;
142  }
144  {
145  return geometryId();
146  }
147  /// @}
148 
149  const GU_ConstDetailHandle &detailPtr() const;
150 
151  void setDetailPtr(const GU_DetailHandle &d);
152  void setDetailPtr(const GU_ConstDetailHandle &d);
153 protected:
154  template <typename T>
155  bool loadFrom(const T &options, const GA_LoadMap &map);
156 
157  bool loadPackedGeometry(GU_PackedContext *context = 0) const;
158 
159  bool statPackedGeometry() const;
160 
165 
167 };
168 
169 #endif
virtual void getVelocityRange(UT_Vector3 &min, UT_Vector3 &max) const =0
GLuint counter
Definition: glew.h:2745
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
UT_BoundingBox myStatBounds
bool supportsJSONLoad() const override
virtual bool unpackWithContext(GU_Detail &destgdp, GU_PackedContext &context, const GU_PrimPacked *prim) const
int64 exint
Definition: SYS_Types.h:125
exint geometryId() const
virtual bool getBounds(UT_BoundingBox &box) const =0
Get the bounding box for the geometry (not including transforms)
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
GLenum src
Definition: glcorearb.h:1792
3D Vector class.
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
Geometry Embedded procedural.
virtual bool getRenderingBounds(UT_BoundingBox &box) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
GLuint GLenum GLenum transform
Definition: glew.h:15055
virtual bool isLoaded() const
GA_Size GA_Offset
Definition: GA_Types.h:640
bool loadFromJSON(GU_PrimPacked *prim, const UT_JSONValueMap &options, const GA_LoadMap &map) override
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
virtual void forceLoad() const
virtual void clearData()=0
virtual int64 getMemoryUsage(bool inclusive) const =0
Report memory usage (includes all shared memory)
virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const =0
bool loadSharedData(int dtype, const GA_SharedLoadData *it) override
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
virtual GU_PackedFactory * getFactory() const =0
Get the factory associated with this procedural.
virtual GU_ConstDetailHandle getPackedDetail(GU_PackedContext *context=0) const
long long int64
Definition: SYS_Types.h:116
Options during loading.
Definition: GA_LoadMap.h:42
#define GU_API
Definition: GU_API.h:14
GA_SharedDataHandlePtr mySharedData
exint getUniqueId() const
Definition: GA_Detail.h:116
virtual bool isValid() const =0
Test whether the deferred load primitive data is valid.
virtual void update(GU_PrimPacked *prim, const UT_Options &options)=0
A map of string to various well defined value types.
Definition: UT_Options.h:84
GLsizei const GLint box[]
Definition: glew.h:11654
virtual GU_PackedImpl * copy() const =0
Create a copy of this resolver.
fpreal64 fpreal
Definition: SYS_Types.h:277
bool unpack(GU_Detail &destgdp, const GU_PrimPacked *prim) const
GU_ConstDetailHandle myDetail
virtual bool saveSharedData(UT_JSONWriter &w, GA_SaveMap &map, GA_GeometryIndex *geo_index) const
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:171
virtual bool save(UT_Options &options, const GA_SaveMap &map) const =0
Copy the resolver data into the UT_Options for saving.
exint intrinsicGeometryId(const GU_PrimPacked *prim) const
bool saveCachedBBox() const override
const GU_Detail * getGdp() const
bool load(GU_PrimPacked *prim, const UT_Options &options, const GA_LoadMap &map) override
static GA_PrimitiveTypeId typeId()
Get the type ID for the GU_PackedGeometry primitive type.
static GA_PrimitiveTypeId theTypeId
virtual void getWidthRange(fpreal &wmin, fpreal &wmax) const =0