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  virtual ~GU_PackedGeometry();
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  virtual GU_PackedFactory *getFactory() const;
73  virtual GU_PackedImpl *copy() const;
74 
75  virtual bool isValid() const;
76  virtual void clearData();
77  virtual bool load(GU_PrimPacked *prim, const UT_Options &options, const GA_LoadMap &map)
78  { return loadFrom(options, map); }
79  virtual bool supportsJSONLoad() const { return true; }
80  virtual bool loadFromJSON(GU_PrimPacked *prim, const UT_JSONValueMap &options, const GA_LoadMap &map)
81  { return loadFrom(options, map); }
82  virtual void update(GU_PrimPacked *prim, const UT_Options &options);
83  virtual bool save(UT_Options &options, const GA_SaveMap &map) const;
84  virtual bool getBounds(UT_BoundingBox &box) const;
85  virtual bool getRenderingBounds(UT_BoundingBox &box) const;
86  virtual void getVelocityRange(UT_Vector3 &min, UT_Vector3 &max)const;
87  virtual void getWidthRange(fpreal &min, fpreal &max) const;
88 
89  virtual bool unpackWithContext(GU_Detail &destgdp, GU_PackedContext &context, const GU_PrimPacked *prim) const;
90  virtual bool unpack(GU_Detail &destgdp, const UT_Matrix4D *transform) const;
91  virtual void forceLoad() const;
92  virtual bool isLoaded() const;
94  virtual bool loadSharedData(int dtype, const GA_SharedLoadData *it) { UT_ASSERT(0 && "Should not be called!"); return false; }
95  virtual bool saveSharedData(UT_JSONWriter &w,
96  GA_SaveMap &map, GA_GeometryIndex* geometryIndex) const;
97 
98  /// Report memory usage (includes all shared memory)
99  virtual int64 getMemoryUsage(bool inclusive) const;
100 
101  /// Count memory usage using a UT_MemoryCounter in order to count
102  /// shared memory correctly.
103  virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const;
104 
105  /// We will be saving the contents in the same file so we don't
106  /// have to worry about them changing. This avoids having
107  /// to seek & stat to restore as bbox.
108  virtual bool saveCachedBBox() const { return true; }
109 
110  /// @}
111 
112  /// @{
113  /// Member data accessors for intrinsics
115  {
116  loadPackedGeometry();
117  GU_DetailHandleAutoReadLock gdl(myDetail);
118  const GU_Detail *gdp = gdl.getGdp();
119  return gdp ? gdp->getUniqueId() : -1;
120  }
122  {
123  return geometryId();
124  }
125  /// @}
126 
127  const GU_ConstDetailHandle &detailPtr() const;
128 
129  void setDetailPtr(const GU_DetailHandle &d);
130  void setDetailPtr(const GU_ConstDetailHandle &d);
131 protected:
132  template <typename T>
133  bool loadFrom(const T &options, const GA_LoadMap &map);
134 
135  bool loadPackedGeometry(GU_PackedContext *context = 0) const;
136 
137  bool statPackedGeometry() const;
138 
143 
145 };
146 
147 #endif
vint4 max(const vint4 &a, const vint4 &b)
Definition: simd.h:4703
virtual void getVelocityRange(UT_Vector3 &min, UT_Vector3 &max) const =0
virtual bool saveSharedData(UT_JSONWriter &w, GA_SaveMap &map, GA_GeometryIndex *geometryIndex) const
UT_JSONValueMap stores a map/dictionary of UT_JSONValue objects.
GLenum src
Definition: glew.h:2410
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
UT_BoundingBox myStatBounds
GLuint GLenum GLenum transform
Definition: glew.h:14742
virtual bool unpackWithContext(GU_Detail &destgdp, GU_PackedContext &context, const GU_PrimPacked *prim) const
exint geometryId() const
virtual bool loadSharedData(int dtype, const GA_SharedLoadData *it)
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:32
UT_SharedPtr< GA_SharedDataHandle > GA_SharedDataHandlePtr
Geometry Embedded procedural.
virtual bool getRenderingBounds(UT_BoundingBox &box) const =0
virtual bool isLoaded() const
GA_Size GA_Offset
Definition: GA_Types.h:637
long long int64
Definition: SYS_Types.h:111
virtual bool loadFromJSON(GU_PrimPacked *prim, const UT_JSONValueMap &options, const GA_LoadMap &map)
virtual void forceLoad() const
int64 exint
Definition: SYS_Types.h:120
virtual void clearData()=0
virtual bool supportsJSONLoad() const
virtual int64 getMemoryUsage(bool inclusive) const =0
Report memory usage (includes all shared memory)
virtual bool saveCachedBBox() const
GLubyte GLubyte GLubyte GLubyte w
Definition: glew.h:1890
virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const =0
virtual GU_PackedFactory * getFactory() const =0
Get the factory associated with this procedural.
virtual GU_ConstDetailHandle getPackedDetail(GU_PackedContext *context=0) const
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
double fpreal
Definition: SYS_Types.h:276
A map of string to various well defined value types.
Definition: UT_Options.h:42
virtual GU_PackedImpl * copy() const =0
Create a copy of this resolver.
GLuint counter
Definition: glew.h:2740
bool unpack(GU_Detail &destgdp, const GU_PrimPacked *prim) const
GU_ConstDetailHandle myDetail
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:135
vint4 min(const vint4 &a, const vint4 &b)
Definition: simd.h:4694
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
virtual bool load(GU_PrimPacked *prim, const UT_Options &options, const GA_LoadMap &map)
const GU_Detail * getGdp() const
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