HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  static GU_PrimPacked *packGeometry(GU_Detail &dest,
37  const GU_ConstDetailHandle &gdh);
38  /// Provide a bounding box of the gdh, compatible with gdh.getBBox()
39  /// useful if you already had to compute it while building gdh.
40  /// An invalid bounding box will generate a recompute later,
41  /// so can be used if you must delay computation, but this is
42  /// not recommended as many readers may demand it simultanesously
43  /// leading to performance problems.
44  static GU_PrimPacked *packGeometry(GU_Detail &dest,
45  const GU_ConstDetailHandle &gdh,
46  const UT_BoundingBox &bbox);
47 
48  /// Install the procedural
49  static void install(GA_PrimitiveFactory *prim);
50 
51  /// Get the type ID for the GU_PackedGeometry primitive type.
53  {
54  return theTypeId;
55  }
56 
57  /// @{
58  /// Implementation of GU_PackedImpl interface
59  virtual GU_PackedFactory *getFactory() const;
60  virtual GU_PackedImpl *copy() const;
61 
62  virtual bool isValid() const;
63  virtual void clearData();
64  virtual bool load(GU_PrimPacked *prim, const UT_Options &options, const GA_LoadMap &map)
65  { return loadFrom(options, map); }
66  virtual bool supportsJSONLoad() const { return true; }
67  virtual bool loadFromJSON(GU_PrimPacked *prim, const UT_JSONValueMap &options, const GA_LoadMap &map)
68  { return loadFrom(options, map); }
69  virtual void update(GU_PrimPacked *prim, const UT_Options &options);
70  virtual bool save(UT_Options &options, const GA_SaveMap &map) const;
71  virtual bool getBounds(UT_BoundingBox &box) const;
72  virtual bool getRenderingBounds(UT_BoundingBox &box) const;
73  virtual void getVelocityRange(UT_Vector3 &min, UT_Vector3 &max)const;
74  virtual void getWidthRange(fpreal &min, fpreal &max) const;
75 
76  virtual bool unpackWithContext(GU_Detail &destgdp, GU_PackedContext &context) const;
77  virtual bool unpack(GU_Detail &destgdp) const;
78  virtual void forceLoad() const;
79  virtual bool isLoaded() const;
80  virtual GU_ConstDetailHandle getPackedDetail(GU_PackedContext *context = 0) const;
81  virtual bool loadSharedData(int dtype, const GA_SharedLoadData *it) { UT_ASSERT(0 && "Should not be called!"); return false; }
82  virtual bool saveSharedData(UT_JSONWriter &w,
83  GA_SaveMap &map, GA_GeometryIndex* geometryIndex) const;
84 
85  /// Report memory usage (includes all shared memory)
86  virtual int64 getMemoryUsage(bool inclusive) const;
87 
88  /// Count memory usage using a UT_MemoryCounter in order to count
89  /// shared memory correctly.
90  virtual void countMemory(UT_MemoryCounter &counter, bool inclusive) const;
91 
92  /// We will be saving the contents in the same file so we don't
93  /// have to worry about them changing. This avoids having
94  /// to seek & stat to restore as bbox.
95  virtual bool saveCachedBBox() const { return true; }
96 
97  /// @}
98 
99  /// @{
100  /// Member data accessors for intrinsics
102  {
103  GU_DetailHandleAutoReadLock gdl(myDetail);
104  const GU_Detail *gdp = gdl.getGdp();
105  return gdp ? gdp->getUniqueId() : -1;
106  }
108  {
109  return geometryId();
110  }
111  /// @}
112 
113  const GU_ConstDetailHandle &detailPtr() const;
114 
115  void setDetailPtr(const GU_DetailHandle &d);
116  void setDetailPtr(const GU_ConstDetailHandle &d);
117 protected:
118  template <typename T>
119  bool loadFrom(const T &options, const GA_LoadMap &map);
120 
121  bool loadPackedGeometry(GU_PackedContext *context = 0) const;
122 
123  bool statPackedGeometry() const;
124 
129 
131 };
132 
133 #endif
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.
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & min(const T &a, const T &b)
Definition: Composite.h:128
UT_BoundingBox myStatBounds
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
3D Vector class.
Geometry Embedded procedural.
virtual bool getRenderingBounds(UT_BoundingBox &box) const =0
const hboost::disable_if_c< VecTraits< T >::IsVec, T >::type & max(const T &a, const T &b)
Definition: Composite.h:132
virtual bool isLoaded() const
long long int64
Definition: SYS_Types.h:106
virtual bool unpackWithContext(GU_Detail &destgdp, GU_PackedContext &context) const
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
virtual bool loadFromJSON(GU_PrimPacked *prim, const UT_JSONValueMap &options, const GA_LoadMap &map)
virtual void forceLoad() const
int64 exint
Definition: SYS_Types.h:115
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
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:11
GA_SharedDataHandlePtr mySharedData
exint getUniqueId() const
Definition: GA_Detail.h:117
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:269
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.
GU_ConstDetailHandle myDetail
virtual bool unpack(GU_Detail &destgdp) const =0
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:856
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.
GLenum src
Definition: glcorearb.h:1792
static GA_PrimitiveTypeId theTypeId
virtual void getWidthRange(fpreal &wmin, fpreal &wmax) const =0