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