HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GT_PackedGeoCache.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: GT_Primitive.h ( GT Library, C++)
7  *
8  * COMMENTS:
9  */
10 #ifndef GT_PackedGeoCache_h
11 #define GT_PackedGeoCache_h
12 
13 #include "GT_Primitive.h"
14 #include <GEO/GEO_PackedTypes.h>
15 #include <UT/UT_StringMap.h>
16 #include <UT/UT_Cache.h>
17 #include "GT_API.h"
18 
20 {
21 public:
22  static bool isCachingAvailable();
23 
24  /// Find a GT prim in the cache under 'name'. The version and extra_flags
25  /// must match. If 'return_anim' is specified, the animation type will be
26  /// assigned to that pointer. version and extra_flags can be anything that
27  /// makes sense to the primitive being cached; the cache only tests them
28  /// for inequality.
29  static GT_PrimitiveHandle findInstance(const UT_StringHolder &name,
30  int64 version,
31  int64 extra_flags,
32  GEO_AnimationType *return_anim= 0);
33 
34  /// Cache the instance geometry along with its version, and animation type.
35  /// 'version' and 'extra_flags' can be anything, but a mismatch during
36  /// findInstance() will cause a cache miss.
37  static void cacheInstance(const UT_StringHolder &name,
38  const GT_PrimitiveHandle &instance,
39  int64 version,
40  int64 extra_flags,
42 
43  /// Recache the geometry (possibly due to modification like convexing)
44  /// The geometry should already exist in the cache, otherwise this fails.
45  static bool recacheInstance(const UT_StringHolder &name,
46  const GT_PrimitiveHandle &instance);
47 
48  /// Remove the geometry with the given name, returning true if removed.
49  static bool removeInstance(const UT_StringHolder &name);
50 
51  /// Find the animation type of the instance without fetching the geometry.
52  static bool findAnimation(const UT_StringHolder &name,
53  int64 version,
54  GEO_AnimationType &type);
55 
56 
57  // Convenience methods for building various cache keys
58 
59  // Alembic object
60  static void buildAlembicName(UT_StringHolder &name,
61  const char *object,
62  const char *archive,
63  fpreal frame);
64  /// Clear a specified alembic, or all alembics.
65  static void clearAlembics(const char *filename);
66  static int64 getAlembicVersion(const char *filename);
67  static bool hasAlembicFile(const char *filename);
68 
69 
70  // Disk File (filename is the disk file, index is the GT prim within the
71  // refined disk file geometry as it may have multiple GT prim types)
72  static void buildFileRefName(UT_StringHolder &name,
73  const char *filename,
74  exint index);
75 
76  // Returns the number of cached GTs primitives that resulted from a disk
77  // file
78  static int getNumDiskFilePrims(const UT_StringHolder &name);
79  static void setNumDiskFilePrims(const UT_StringHolder &name, int count);
80 
81 
82  // UT_Cache interface
83  virtual const char *utGetCacheName() const { return "Packed Geometry"; }
84  virtual int64 utGetCurrentSize() const { return myGeoCacheSize; }
85  virtual int64 utReduceCacheSizeBy(int64 amount);
86  virtual int64 utGetMinSize() const;
87  virtual int64 utGetMaxSize() const;
88 
89  static void initialize();
90 
91 private:
92 
95  void privClearAlembics(const char *filename);
96 
97  class gt_CachedGeometry
98  {
99  public:
100  gt_CachedGeometry() : lru(0), mem(0), version(0), locked(false) {}
101  gt_CachedGeometry(const GT_PrimitiveHandle &h, int64 L, int64 M,
102  int64 v, int64 e, GEO_AnimationType anim, bool lock)
103  : geometry(h), lru(L), mem(M), locked(lock), version(v),
104  extra_flags(e), animation(anim) {}
105  GT_PrimitiveHandle geometry;
106  int64 lru;
107  int64 mem;
108  int64 version;
109  int64 extra_flags;
110  GEO_AnimationType animation;
111  bool locked;
112  };
113 
114  // Caching
116  int64 myLRUCount;
117  int64 myGeoCacheSize;
118 
119  // File cache
120  UT_StringMap<int64> myFileVersion;
121  UT_StringMap<int64> myDiskFileCount;
122 };
123 
124 #endif
const GLdouble * v
Definition: glcorearb.h:836
#define GT_API
Definition: GT_API.h:11
virtual int64 utGetCurrentSize() const
required - return the current cache size, in bytes
virtual int64 utGetMaxSize() const
Definition: UT_Cache.h:44
virtual int64 utGetMinSize() const
Definition: UT_Cache.h:50
long long int64
Definition: SYS_Types.h:100
virtual int64 utReduceCacheSizeBy(int64 amount)=0
int64 exint
Definition: SYS_Types.h:109
GEO_AnimationType
OPENVDB_API void initialize()
Global registration of basic types.
Definition: logging.h:316
GLuint const GLchar * name
Definition: glcorearb.h:785
Common base class for various caches.
Definition: UT_Cache.h:21
virtual const char * utGetCacheName() const
required - return the english name for this cache.
GLint GLsizei count
Definition: glcorearb.h:404
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2001
double fpreal
Definition: SYS_Types.h:263
GLuint index
Definition: glcorearb.h:785
GLint GLint GLsizei GLint GLenum GLenum type
Definition: glcorearb.h:107