HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GEO_PrimVDB.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: GEO_PrimVDB.h ( GEO Library, C++)
7  *
8  * COMMENTS: Custom VDB primitive.
9  */
10 
11 #ifndef __GEO_PrimVDB__
12 #define __GEO_PrimVDB__
13 
14 #include "GEO_API.h"
15 #include "GEO_Primitive.h"
16 #include "GEO_VolumeOptions.h"
17 
18 #include <GA/GA_Defines.h>
19 
20 #include <SYS/SYS_AtomicInt.h> // for SYS_AtomicCounter
21 
22 #include <UT/UT_BoundingBox.h>
23 #include <UT/UT_VDBUtils.h>
24 
25 #include <openvdb/Platform.h>
26 #include <openvdb/openvdb.h>
27 
28 
29 class GEO_Detail;
30 class GEO_PrimVolume;
32 class UT_MemoryCounter;
33 
34 class CE_VDBGrid;
35 
37 {
38 public:
39  typedef uint64 UniqueId;
40 
41 protected:
42  /// NOTE: The constructor should only be called from subclass
43  /// constructors.
45 
46  ~GEO_PrimVDB() override;
47 public:
49  { return GA_FAMILY_NONE; }
50 
51  /// @{
52  /// Required interface methods
53  bool isDegenerate() const override;
54  bool getBBox(UT_BoundingBox *bbox) const override;
55  void reverse() override;
56  UT_Vector3 computeNormal() const override;
57  UT_Vector3D computeNormalD() const override;
58  void copyPrimitive(const GEO_Primitive *src) override;
59  void copySubclassData(const GA_Primitive *source) override;
60 
61  /// Acquire a CE grid and cache it on the GPU. If marked for
62  /// writing, the CPU version will be overwritten.
63  /// Note that the getVoxelHandle does *NOT* auto-flush these!
64  /// NOTE: If someone else fetches a non-read grid, and you fetch it
65  /// as a read grid, you will not get any copied data.
66  CE_VDBGrid *getCEGrid(bool read, bool write) const;
67 
68  /// Any modified CE cache on the GPU will be copied back to the
69  /// CPU. Will leave result on GPU.
70  void flushCEWriteCaches() override;
71 
72  /// Remove all CE caches from the GPU, possibly writing back
73  /// if necessary.
74  void flushCECaches() override;
75 
76  /// Steal the underlying CE buffer from the source.
77  void stealCEBuffers(const GA_Primitive *src) override;
78 
86  { return getVertexOffset(0); }
89  { return getPointOffset(0); }
92  { setPointOffset(0, pt); }
95  { return getPos3(0); }
97  void setPos3(const UT_Vector3 &pos)
98  { setPos3(0, pos); }
99 
100  /// Convert an index in the voxel array into the corresponding worldspace
101  /// location
102  void indexToPos(int x, int y, int z, UT_Vector3 &pos) const;
103  void findexToPos(UT_Vector3 index, UT_Vector3 &pos) const;
104  void indexToPos(exint x, exint y, exint z, UT_Vector3D &pos) const;
105  void findexToPos(UT_Vector3D index, UT_Vector3D &pos) const;
106 
107  /// Convert a 3d position into the closest index value.
108  void posToIndex(UT_Vector3 pos, int &x, int &y, int &z) const;
109  void posToIndex(UT_Vector3 pos, UT_Vector3 &index) const;
110  void posToIndex(UT_Vector3D pos, exint &x, exint &y, exint &z) const;
111  void posToIndex(UT_Vector3D pos, UT_Vector3D &index) const;
112 
113  /// Evaluate the voxel value at the given world space position.
114  /// Note that depending on the underlying VDB type, this may not
115  /// be sensible, in which case a zero will silently be returned
116  fpreal getValueF(const UT_Vector3 &pos) const;
117  fpreal getValueAtIndexF(int ix, int iy, int iz) const;
118  UT_Vector3D getValueV3(const UT_Vector3 &pos) const;
119  UT_Vector3D getValueAtIndexV3(int ix, int iy, int iz) const;
120 
121  void getValues(float *f, int stride, const UT_Vector3 *pos, int num) const;
122  void getValues(int *f, int stride, const UT_Vector3 *pos, int num) const;
123  void getValuesAtIndices(float *f, int stride, const int *ix, const int *iy, const int *iz, int num) const;
124  void getValuesAtIndices(int *f, int stride, const int *ix, const int *iy, const int *iz, int num) const;
125 
126  /// Vector grid variants.
127  void getValues(UT_Vector3 *f, int stride, const UT_Vector3 *pos, int num) const;
128  void getValuesAtIndices(UT_Vector3 *f, int stride, const int *ix, const int *iy, const int *iz, int num) const;
129 
130  void getValues(double *f, int stride, const UT_Vector3D *pos, int num) const;
131  void getValues(exint *f, int stride, const UT_Vector3D *pos, int num) const;
132  void getValuesAtIndices(double *f, int stride, const exint *ix, const exint *iy, const exint *iz, int num) const;
133  void getValuesAtIndices(exint *f, int stride, const exint *ix, const exint *iy, const exint *iz, int num) const;
134 
135  /// Vector grid variants.
136  void getValues(UT_Vector3D *f, int stride, const UT_Vector3D *pos, int num) const;
137  void getValuesAtIndices(UT_Vector3D *f, int stride, const exint *ix, const exint *iy, const exint *iz, int num) const;
138 
139  // Worldspace gradient at the given position
140  UT_Vector3 getGradient(const UT_Vector3 &pos) const;
141 
142  /// Evaluate this grid's gradients at the given world space positions.
143  /// Does nothing and returns false if grid is non-scalar.
144  /// If normalize is true, then the gradients will be normalized to be unit
145  /// length.
146  bool evalGradients(
147  UT_Vector3 *gradients,
148  int gradients_stride,
149  const UT_Vector3 *positions,
150  int num_positions,
151  bool normalize = false) const;
152 
153  /// Get the storage type of the grid
156  { return myGridAccessor.getStorageType(); }
157  /// Get the tuple size, usually 1 or 3
159  int getTupleSize() const
160  { return UTvdbGetGridTupleSize(getStorageType()); }
161 
162  bool isSDF() const;
163 
164  /// True if the two volumes map the same indices to the same positions.
165  bool isAligned(const GEO_PrimVDB *vdb) const;
166  /// True if the two volumes have the same active regions
167  bool isActiveRegionMatched(const GEO_PrimVDB *vdb) const;
168 
169  /// True if we are aligned with the world axes. Ie, all our
170  /// off diagonals are zero and our diagonal is positive.
171  bool isWorldAxisAligned() const;
172 
173  // Transform the matrix associated with this primitive. Translate is
174  // ignored.
175  void transform(const UT_Matrix4 &mat) override;
176 
177 
178  /// True if the underlying grid has no voxels.
179  bool isEmpty() const { return getGridPtr()->empty(); }
180 
181  /// Background value of the grid as a scalar or vector.
182  fpreal backgroundF() const;
183  UT_Vector3D backgroundV3() const;
184 
185  /// Accessors for the 4x4 matrix representing the affine transform that
186  /// converts from index space voxel coordinates to world space. For frustum
187  /// maps, this will be transform as if the taper value is set to 1.
188  /// @{
189  void setTransform4(const UT_DMatrix4 &xform4);
190  void setTransform4(const UT_Matrix4 &xform4);
191  UT_Matrix4D getTransform4() const;
192  /// @}
193 
194  // Take the whole set of points into consideration when applying the
195  // point removal operation to this primitive. The method returns 0 if
196  // successful, -1 if it failed because it would have become degenerate,
197  // and -2 if it failed because it would have had to remove the primitive
198  // altogether.
199  int detachPoints(GA_PointGroup &grp) override;
200  /// Before a point is deleted, all primitives using the point will be
201  /// notified. The method should return "false" if it's impossible to
202  /// delete the point. Otherwise, the vertices should be removed.
203  GA_DereferenceStatus dereferencePoint(GA_Offset point,
204  bool dry_run=false) override;
205  GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q,
206  bool dry_run=false) override;
207  const GA_PrimitiveJSON *getJSON() const override;
208 
209  /// This method assigns a preallocated vertex to the quadric, optionally
210  /// creating the topological link between the primitive and new vertex.
211  void assignVertex(GA_Offset new_vtx, bool update_topology);
212 
213  /// Evalaute a point given a u,v coordinate (with derivatives)
214  bool evaluatePointRefMap(
215  GA_Offset result_vtx,
216  GA_AttributeRefMap &hlist,
217  fpreal u, fpreal v,
218  uint du, uint dv) const override;
219  /// Evalaute position given a u,v coordinate (with derivatives)
221  UT_Vector4 &pos,
222  float u, float v = 0,
223  unsigned du=0, unsigned dv=0) const override
224  {
225  return GEO_Primitive::evaluatePointV4(pos, u, v,
226  du, dv);
227  }
228  /// @}
229 
230  /// Convert transforms between native volumes and VDBs
231  /// @{
232 
233  /// Get a GEO_PrimVolumeXform which represent's the grid's full transform.
234  /// The returned space's fromVoxelSpace() method will convert index space
235  /// voxel coordinates to world space positions (and the vice versa for
236  /// toVoxelSpace()).
237  /// Note: The transformation is not the same as `posToIndex`
238  /// getIndexSpaceTransform().toVoxelSpace(pos) == posToIndex(pos) + {0.5, 0.5, 0.5}
239  GEO_PrimVolumeXform getIndexSpaceTransform() const;
240 
241  /// Equivalent to getSpaceTransform(getGrid().evalActiveVoxelBoundingBox()).
242  /// The returned space's fromVoxelSpace() method will convert 0-1
243  /// coordinates over the active voxel bounding box to world space (and vice
244  /// versa for toVoxelSpace()).
245  GEO_PrimVolumeXform getSpaceTransform() const;
246 
247  /// Gives the equivalent to GEO_PrimVolume's getSpaceTransform() by using
248  /// the given bounding box to determine the bounds of the transform.
249  /// The resulting world space sample points will be offset by half a voxel
250  /// so that they match GEO_PrimVolume.
251  /// The returned space's fromVoxelSpace() method will convert 0-1
252  /// coordinates over the bbox extents to world space (and vice versa for
253  /// toVoxelSpace()).
254  GEO_PrimVolumeXform getSpaceTransform(const UT_BoundingBoxD &bbox) const;
255 
256  /// Sets the transform from a GEO_PrimVolume's getSpaceTransform() by using
257  /// the index space [(0,0,0), resolution] bbox. If force_taper is true,
258  /// then the resulting transform will always be a NonlinearFrustumMap even
259  /// if there is no tapering.
260  void setSpaceTransform(const GEO_PrimVolumeXform &space,
261  const UT_Vector3R &resolution,
262  bool force_taper = false);
263 
264  /// @}
265 
266  fpreal getTaper() const;
267 
268  /// Returns the resolution of the active voxel array.
269  /// Does *not* mean the indices go from 0..rx, however!
270  void getRes(int &rx, int &ry, int &rz) const;
271  void getRes(int64 &rx, int64 &ry, int64 &rz) const;
272 
273  /// Computes the voxel diameter by taking a step in x, y, and z
274  /// converting to world space and taking the length of that vector.
275  fpreal getVoxelDiameter() const;
276 
277  /// Returns the length of the voxel when you take an x, y, and z step
278  UT_Vector3 getVoxelSize() const;
279 
280  /// Compute useful aggregate properties of the volume.
281  fpreal calcMinimum() const;
282  fpreal calcMaximum() const;
283  fpreal calcAverage() const;
284 
285  /// VDBs may either be unbounded, or created with a specific frustum
286  /// range. The latter is important for tapered VDBs that otherwise
287  /// have a singularity at the camera location. Tools can use the
288  /// presence of an idxbox as a clipping box in index space.
289  /// This does *NOT* relate to getRes - it may be much larger or
290  /// even in some cases smaller.
291  bool getFrustumBounds(UT_BoundingBox &idxbox) const;
292 
294  {
295  ACTIVATE_UNION, // Activate anything in source
296  ACTIVATE_INTERSECT, // Deactivate anything not in source
297  ACTIVATE_SUBTRACT, // Deactivate anything in source
298  ACTIVATE_COPY // Set our activation to match source
299  };
300 
301  /// Activates voxels given an *index* space bounding box. This
302  /// is an inclusive box.
303  /// If this is Frustum VDB, the activation will be clipped by that.
304  /// Setting the value only takes effect if the voxels are activated,
305  /// deactivated voxels are set to the background.
307  const openvdb::CoordBBox& bbox,
308  ActivateOperation operation,
309  bool setvalue, fpreal value)
310  {
311  activateIndexBBoxAdapter(
312  &bbox, operation, setvalue, value);
313  }
314 
315  /// Activates all of the voxels in this VDB that are touched
316  /// by active voxels in the source.
317  /// If ignore_transform is true, voxels will be activated
318  /// by grid index instead of world space position.
319  void activateByVDB(const GEO_PrimVDB *vdb,
320  ActivateOperation operation,
321  bool setvalue, fpreal value,
322  bool ignore_transform=false);
323 
324  /// @{
325  /// Though not strictly required (i.e. not pure virtual), these methods
326  /// should be implemented for proper behaviour.
327  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
328 
329  // Have we been deactivated and stashed?
330  void stashed(bool beingstashed,
332 
333  /// @}
334 
335  /// @{
336  /// Optional interface methods. Though not required, implementing these
337  /// will give better behaviour for the new primitive.
338  UT_Vector3 baryCenter() const override;
339  fpreal calcVolume(const UT_Vector3 &refpt) const override;
340  /// Calculate the surface area of the active voxels where
341  /// a voxel face contributes if it borders an inactive voxel.
342  fpreal calcArea() const override;
343  /// @}
344 
345  /// @{
346  /// Enlarge a bounding box by the bounding box of the primitive. A
347  /// return value of false indicates an error in the operation, most
348  /// likely an invalid P. For any attribute other than the position
349  /// these methods simply enlarge the bounding box based on the vertex.
350  bool enlargeBoundingBox(
352  const GA_Attribute *P) const override;
353  bool enlargeBoundingBox(
354  UT_BoundingBox &b,
355  const GA_Attribute *P) const override;
356  void enlargePointBounds(UT_BoundingBox &e) const override;
357  /// @}
358  /// Enlarge a bounding sphere to encompass the primitive. A return value
359  /// of false indicates an error in the operation, most likely an invalid
360  /// P. For any attribute other than the position this method simply
361  /// enlarges the sphere based on the vertex.
364  const GA_Attribute *P) const override;
365 
366  /// Accessor for the local 3x3 affine transform matrix for the primitive.
367  /// For frustum maps, this will be transform as if the taper value is set
368  /// to 1.
369  /// @{
370  void getLocalTransform(UT_Matrix3D &result) const override;
371  void setLocalTransform(const UT_Matrix3D &new_mat3) override;
372  /// @}
373 
374  /// @internal Hack to condition 4x4 matrices that we avoid creating what
375  /// OpenVDB erroneously thinks are singular matrices. Returns true if mat4
376  /// was modified.
377  static bool conditionMatrix(UT_Matrix4D &mat4);
378 
379  /// Visualization accessors
380  /// @{
381  const GEO_VolumeOptions &getVisOptions() const { return myVis; }
383  { setVisualization(vis.myMode, vis.myIso, vis.myDensity, vis.myLod); }
384 
386  GEO_VolumeVis vismode,
387  fpreal iso,
388  fpreal density,
390  {
391  myVis.myMode = vismode;
392  myVis.myIso = iso;
393  myVis.myDensity = density;
394  myVis.myLod = lod;
395  }
396  GEO_VolumeVis getVisualization() const { return myVis.myMode; }
397  fpreal getVisIso() const { return myVis.myIso; }
398  fpreal getVisDensity() const { return myVis.myDensity; }
399  GEO_VolumeVisLod getVisLod() const { return myVis.myLod; }
400  /// @}
401 
402  /// Load the order from a JSON value
403  bool loadOrder(const UT_JSONValue &p);
404 
405  /// @{
406  /// Save/Load vdb to a JSON stream
407  bool saveVDB(UT_JSONWriter &w, const GA_SaveMap &sm,
408  bool as_shmem = false) const;
409  bool loadVDB(UT_JSONParser &p,
410  bool as_shmem = false);
411  /// @}
412 
413  bool saveVisualization(
414  UT_JSONWriter &w,
415  const GA_SaveMap &map) const;
416  bool loadVisualization(
417  UT_JSONParser &p,
418  const GA_LoadMap &map);
419 
420  /// Method to perform quick lookup of vertex without the virtual call
422  {
423  UT_ASSERT_P(index < 1);
424  return getVertexOffset();
425  }
426 
427  void setVertexPoint(int i, GA_Offset pt)
428  {
429  if (i == 0)
430  setPointOffset(pt);
431  }
432 
433  /// @brief Computes the total density of the volume, scaled by
434  /// the volume's size. Negative values will be ignored.
435  fpreal calcPositiveDensity() const;
436 
438  bool hasGrid() const { return myGridAccessor.hasGrid(); }
439 
440  /// @brief If this primitive's grid's voxel data (i.e., its tree)
441  /// is shared, replace the tree with a deep copy of itself that is
442  /// not shared with anyone else.
445  { myGridAccessor.makeGridUnique(); }
446 
447  /// @brief Returns true if the tree is not shared. If it is not shared,
448  /// one can make destructive edits without makeGridUnique.
449  bool isGridUnique() const
450  { return myGridAccessor.isGridUnique(); }
451 
452  /// @brief Return a reference to this primitive's grid.
453  /// @note Calling setGrid() invalidates all references previously returned.
455  const openvdb::GridBase & getConstGrid() const
456  { return myGridAccessor.getConstGrid(*this); }
457  /// @brief Return a reference to this primitive's grid.
458  /// @note Calling setGrid() invalidates all references previously returned.
460  const openvdb::GridBase & getGrid() const
461  { return getConstGrid(); }
462  /// @brief Return a reference to this primitive's grid.
463  /// @note Calling setGrid() invalidates all references previously returned.
464  /// @warning Call makeGridUnique() before modifying the grid's voxel data.
466  openvdb::GridBase & getGrid()
467  {
468  incrGridUniqueIds();
469  return myGridAccessor.getGrid(*this);
470  }
471 
472  /// @brief Return a shared pointer to this primitive's grid.
473  /// @note Calling setGrid() causes the grid to which the shared pointer
474  /// refers to be disassociated with this primitive.
476  openvdb::GridBase::ConstPtr getConstGridPtr() const
477  { return myGridAccessor.getConstGridPtr(*this); }
478  /// @brief Return a shared pointer to this primitive's grid.
479  /// @note Calling setGrid() causes the grid to which the shared pointer
480  /// refers to be disassociated with this primitive.
482  openvdb::GridBase::ConstPtr getGridPtr() const
483  { return getConstGridPtr(); }
484  /// @brief Return a shared pointer to this primitive's grid.
485  /// @note Calling setGrid() causes the grid to which the shared pointer
486  /// refers to be disassociated with this primitive.
487  /// @warning Call makeGridUnique() before modifying the grid's voxel data.
489  openvdb::GridBase::Ptr getGridPtr()
490  {
491  incrGridUniqueIds();
492  return myGridAccessor.getGridPtr(*this);
493  }
494 
495  /// @brief Set this primitive's grid to a shallow copy of the given grid.
496  /// @note Invalidates all previous getGrid() and getConstGrid() references
498  void setGrid(const openvdb::GridBase &grid, bool copyPosition=true)
499  {
500  incrGridUniqueIds();
501  myGridAccessor.setGrid(grid, *this, copyPosition);
502  }
503 
504  /// @brief Return a reference to this primitive's grid metadata.
505  /// @note Calling setGrid() invalidates all references previously returned.
506  const openvdb::MetaMap& getConstMetadata() const
507  { return getConstGrid(); }
508  /// @brief Return a reference to this primitive's grid metadata.
509  /// @note Calling setGrid() invalidates all references previously returned.
510  const openvdb::MetaMap& getMetadata() const
511  { return getConstGrid(); }
512  /// @brief Return a reference to this primitive's grid metadata.
513  /// @note Calling setGrid() invalidates all references previously returned.
515  openvdb::MetaMap& getMetadata()
516  {
517  incrMetadataUniqueId();
518  return myGridAccessor.getGrid(*this);
519  }
520 
521  /// @brief Return the value of this primitive's "name" attribute
522  /// in the given detail.
523  const char * getGridName() const;
524 
525  /// @brief Return this primitive's serial number.
526  /// @details A primitive's serial number never changes.
528  { return static_cast<UniqueId>(myUniqueId.relaxedLoad()); }
529 
530  /// @brief Return the serial number of this primitive's voxel data.
531  /// @details The serial number is incremented whenever a non-const
532  /// reference or pointer to this primitive's grid is requested
533  /// (whether or not the voxel data is ultimately modified).
535  { return static_cast<UniqueId>(myTreeUniqueId.relaxedLoad()); }
536  /// @brief Return the serial number of this primitive's grid metadata.
537  /// @details The serial number is incremented whenever a non-const
538  /// reference to the metadata or non-const access to the grid is requested
539  /// (whether or not the metadata is ultimately modified).
541  { return static_cast<UniqueId>(myMetadataUniqueId.relaxedLoad()); }
542  /// @brief Return the serial number of this primitive's transform.
543  /// @details The serial number is incremented whenever the transform
544  /// is modified or non-const access to this primitive's grid is requested
545  /// (whether or not the transform is ultimately modified).
547  { return static_cast<UniqueId>(myTransformUniqueId.relaxedLoad()); }
548 
549 
550  /// @brief If this primitive's grid resolves to one of the listed grid types,
551  /// invoke the functor @a op on the resolved grid.
552  /// @return @c true if the functor was invoked, @c false otherwise
553  ///
554  /// @par Example:
555  /// @code
556  /// auto printOp = [](const openvdb::GridBase& grid) { grid.print(); };
557  /// const GEO_PrimVDB* prim = ...;
558  /// using RealGridTypes = openvdb::TypeList<openvdb::FloatGrid, openvdb::DoubleGrid>;
559  /// // Print info about the primitive's grid if it is a floating-point grid.
560  /// prim->apply<RealGridTypes>(printOp);
561  /// @endcode
562  template<typename GridTypeListT, typename OpT>
563  bool apply(OpT& op) const
564  { return hasGrid() ? getConstGrid().apply<GridTypeListT>(op) : false; }
565 
566  /// @brief If this primitive's grid resolves to one of the listed grid types,
567  /// invoke the functor @a op on the resolved grid.
568  /// @return @c true if the functor was invoked, @c false otherwise
569  /// @details If @a makeUnique is true, deep copy the grid's tree before
570  /// invoking the functor if the tree is shared with other grids.
571  ///
572  /// @par Example:
573  /// @code
574  /// auto fillOp = [](const auto& grid) { // C++14
575  /// // Convert voxels in the given bounding box into background voxels.
576  /// grid.fill(openvdb::CoordBBox(openvdb::Coord(0), openvdb::Coord(99)),
577  /// grid.background(), /*active=*/false);
578  /// };
579  /// GEO_PrimVDB* prim = ...;
580  /// // Set background voxels in the primitive's grid if it is a floating-point grid.
581  /// using RealGridTypes = openvdb::TypeList<openvdb::FloatGrid, openvdb::DoubleGrid>;
582  /// prim->apply<RealGridTypes>(fillOp);
583  /// @endcode
584  template<typename GridTypeListT, typename OpT>
585  bool apply(OpT& op, bool makeUnique = true)
586  {
587  if (hasGrid()) {
588  auto& grid = myGridAccessor.getGrid(*this);
589  if (makeUnique) {
590  auto treePtr = grid.baseTreePtr();
591  if (treePtr.use_count() > 2) { // grid + treePtr = 2
592  // If the grid resolves to one of the listed types and its tree
593  // is shared with other grids, replace the tree with a deep copy.
594  grid.apply<GridTypeListT>([this](openvdb::GridBase& baseGrid) {
595  baseGrid.setTree(baseGrid.constBaseTree().copy());
596  this->incrTreeUniqueId();
597  });
598  }
599  }
600  if (grid.apply<GridTypeListT>(op)) {
601  incrGridUniqueIds();
602  return true;
603  }
604  }
605  return false;
606  }
607 
608 protected:
610 
611  /// Register intrinsic attributes
612  GA_DECLARE_INTRINSICS(override)
613 
614  /// Return true if the given metadata token is an intrinsic
615  static bool isIntrinsicMetadata(const char *name);
616 
617  /// @warning vertexPoint() doesn't check the bounds. Use with caution.
618  GA_Offset vertexPoint(GA_Size) const
619  { return getPointOffset(); }
620 
621  /// Report approximate memory usage, excluding sizeof(*this),
622  /// because the subclass doesn't have access to myGridAccessor.
623  int64 getBaseMemoryUsage() const;
624 
625  // This is called by the subclasses to count the
626  // memory used by this, excluding sizeof(*this).
627  void countBaseMemory(UT_MemoryCounter &counter) const;
628 
629  /// @brief Return an ID number that is guaranteed to be unique across
630  /// all VDB primitives.
631  static UniqueId nextUniqueId();
632 
634  { myTreeUniqueId.maximum(nextUniqueId()); }
636  { myMetadataUniqueId.maximum(nextUniqueId()); }
638  { myTransformUniqueId.maximum(nextUniqueId()); }
640  {
641  incrTreeUniqueId();
642  incrMetadataUniqueId();
643  incrTransformUniqueId();
644  }
645 
646  /// @brief Replace this primitive's grid with a shallow copy
647  /// of another primitive's grid.
648  void copyGridFrom(const GEO_PrimVDB&, bool copyPosition=true);
649 
650  /// @brief GridAccessor manages access to a GEO_PrimVDB's grid.
651  /// @details In keeping with OpenVDB library conventions, the grid
652  /// is stored internally by shared pointer. However, grid objects
653  /// are never shared among primitives, though their voxel data
654  /// (i.e., their trees) may be shared.
655  /// <p>Among other things, GridAccessor
656  /// - ensures that each primitive's transform and metadata are unique
657  /// (i.e., not shared with anyone else)
658  /// - allows primitives to share voxel data but, via makeGridUnique(),
659  /// provides a way to break the connection
660  /// - ensures that the primitive's transform and the grid's transform
661  /// are in sync (specifically, the translation component, which is
662  /// stored independently as a vertex offset).
664  {
665  public:
667  GridAccessor() : myStorageType(UT_VDB_INVALID)
668  { }
669 
671  void clear()
672  {
673  myGrid.reset();
674  myStorageType = UT_VDB_INVALID;
675  }
676 
678  openvdb::GridBase &
679  getGrid(const GEO_PrimVDB &prim)
680  { updateGridTranslates(prim); return *myGrid; }
681 
683  const openvdb::GridBase &
684  getConstGrid(const GEO_PrimVDB &prim) const
685  { updateGridTranslates(prim); return *myGrid; }
686 
688  openvdb::GridBase::Ptr
689  getGridPtr(const GEO_PrimVDB &prim)
690  { updateGridTranslates(prim); return myGrid; }
691 
693  openvdb::GridBase::ConstPtr
694  getConstGridPtr(const GEO_PrimVDB &prim) const
695  { updateGridTranslates(prim); return myGrid; }
696 
697  // These accessors will ensure the transform's translate is set into
698  // the vertex position.
700  void setGrid(const openvdb::GridBase& grid, GEO_PrimVDB& prim, bool copyPosition=true)
701  { setGridAdapter(&grid, prim, copyPosition); }
704  const openvdb::math::Transform &xform,
705  GEO_PrimVDB &prim)
706  { setTransformAdapter(&xform, prim); }
707 
708  void makeGridUnique();
709  bool isGridUnique() const;
710 
712  UT_VDBType getStorageType() const { return myStorageType; }
713 
715  bool hasGrid() const { return myGrid != 0; }
716 
717  private:
718  void updateGridTranslates(const GEO_PrimVDB &prim) const;
719 
721  void setVertexPosition(
722  const openvdb::math::Transform &xform,
723  GEO_PrimVDB &prim)
724  { setVertexPositionAdapter(&xform, prim); }
725 
726  void setGridAdapter(const void* grid, GEO_PrimVDB&, bool copyPosition);
727  void setTransformAdapter(const void* xform, GEO_PrimVDB&);
728  void setVertexPositionAdapter(const void* xform, GEO_PrimVDB&);
729 
730  private:
731  openvdb::GridBase::Ptr myGrid;
732  UT_VDBType myStorageType;
733  };
734 
735 private:
736  void activateIndexBBoxAdapter(
737  const void* bbox,
738  ActivateOperation,
739  bool setvalue, fpreal value);
740 
741 
742  GridAccessor myGridAccessor;
743 
744  GEO_VolumeOptions myVis;
745 
746  mutable CE_VDBGrid *myCEGrid;
747  mutable bool myCEGridAuthorative;
748  mutable bool myCEGridIsOwned;
749 
750  AtomicUniqueId myUniqueId;
751  AtomicUniqueId myTreeUniqueId;
752  AtomicUniqueId myMetadataUniqueId;
753  AtomicUniqueId myTransformUniqueId;
754 
755 }; // class GEO_PrimVDB
756 
757 
758 #if 0 // ndef SESI_OPENVDB
759 namespace openvdb_houdini {
760 using ::GEO_VolumeOptions;
761 using ::GEO_PrimVDB;
762 }
763 #endif
764 
765 
766 ////////////////////////////////////////
767 
768 
769 namespace UT_VDBUtils {
770 
771 // This overload of UT_VDBUtils::callTypedGrid(), for GridBaseType = GEO_PrimVDB,
772 // calls makeGridUnique() on the primitive just before instantiating and
773 // invoking the functor on the primitive's grid. This delays the call
774 // to makeGridUnique() until it is known to be necessary and thus avoids
775 // making deep copies of grids of types that won't be processed.
776 template<typename GridType, typename OpType>
777 inline void
778 callTypedGrid(GEO_PrimVDB& prim, OpType& op)
779 {
780  prim.makeGridUnique();
781  op.template operator()<GridType>(*(UTverify_cast<GridType*>(&prim.getGrid())));
782 }
783 
784 // Overload of callTypedGrid() for GridBaseType = const GEO_PrimVDB
785 template<typename GridType, typename OpType>
786 inline void
787 callTypedGrid(const GEO_PrimVDB& prim, OpType& op)
788 {
789  op.template operator()<GridType>(*(UTverify_cast<const GridType*>(&prim.getConstGrid())));
790 }
791 
792 } // namespace UT_VDBUtils
793 
794 // Define UTvdbProcessTypedGrid*() (see UT_VDBUtils.h) for grids
795 // belonging to primitives, for various subsets of grid types.
798 
799 
800 ////////////////////////////////////////
801 
802 
803 /// @brief Utility function to process the grid of a const primitive using functor @a op.
804 /// @details It will invoke @code op.operator()<GridT>(const GridT &grid) @endcode
805 /// @{
806 template <typename OpT>
807 inline bool GEOvdbProcessTypedGrid(const GEO_PrimVDB &vdb, OpT &op)
808 {
809  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
810 }
811 
812 template <typename OpT>
813 inline bool GEOvdbProcessTypedGridReal(const GEO_PrimVDB &vdb, OpT &op)
814 {
815  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
816 }
817 
818 template <typename OpT>
819 inline bool GEOvdbProcessTypedGridScalar(const GEO_PrimVDB &vdb, OpT &op)
820 {
821  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
822 }
823 
824 template <typename OpT>
825 inline bool GEOvdbProcessTypedGridTopology(const GEO_PrimVDB &vdb, OpT &op)
826 {
827  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
828 }
829 
830 template <typename OpT>
831 inline bool GEOvdbProcessTypedGridVec3(const GEO_PrimVDB &vdb, OpT &op)
832 {
833  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
834 }
835 
836 template <typename OpT>
837 inline bool GEOvdbProcessTypedGridPoint(const GEO_PrimVDB &vdb, OpT &op)
838 {
839  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
840 }
841 /// @}
842 
843 /// @brief Utility function to process the grid of a primitive using functor @a op.
844 /// @param vdb the primitive whose grid is to be processed
845 /// @param op a functor with a call operator of the form
846 /// @code op.operator()<GridT>(GridT &grid) @endcode
847 /// @param makeUnique if @c true, call <tt>vdb.makeGridUnique()</tt> before
848 /// invoking the functor
849 /// @{
850 template <typename OpT>
851 inline bool GEOvdbProcessTypedGrid(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
852 {
853  if (makeUnique) return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb, op);
854  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
855 }
856 
857 template <typename OpT>
858 inline bool GEOvdbProcessTypedGridReal(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
859 {
860  if (makeUnique) return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb, op);
861  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
862 }
863 
864 template <typename OpT>
865 inline bool GEOvdbProcessTypedGridScalar(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
866 {
867  if (makeUnique) return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb, op);
868  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
869 }
870 
871 template <typename OpT>
872 inline bool GEOvdbProcessTypedGridTopology(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
873 {
874  if (makeUnique) return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb, op);
875  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
876 }
877 
878 template <typename OpT>
879 inline bool GEOvdbProcessTypedGridVec3(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
880 {
881  if (makeUnique) return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb, op);
882  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
883 }
884 
885 template <typename OpT>
886 inline bool GEOvdbProcessTypedGridPoint(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
887 {
888  if (makeUnique) return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb, op);
889  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
890 }
891 /// @}
892 
893 #endif // __GEO_PrimVDB__
virtual void flushCEWriteCaches()
Copy any modified caches from the GPU back to CPU cache.
Definition: GA_Primitive.h:807
virtual void flushCECaches()
Definition: GA_Primitive.h:811
Definition of a geometry attribute.
Definition: GA_Attribute.h:198
GridAccessor manages access to a GEO_PrimVDB's grid.
Definition: GEO_PrimVDB.h:663
virtual GEO_Primitive * copy(int preserve_shared_pts=0) const
SYS_FORCE_INLINE GA_Offset getPointOffset(GA_Size i) const
Definition: GA_Primitive.h:254
virtual UT_Vector3 baryCenter() const
GA_Offset fastVertexOffset(GA_Size UT_IF_ASSERT_P(index)) const
Method to perform quick lookup of vertex without the virtual call.
Definition: GEO_PrimVDB.h:421
virtual void copyPrimitive(const GEO_Primitive *src)=0
SYS_FORCE_INLINE UT_VDBType getStorageType() const
Get the storage type of the grid.
Definition: GEO_PrimVDB.h:155
bool GEOvdbProcessTypedGridTopology(const GEO_PrimVDB &vdb, OpT &op)
Utility function to process the grid of a const primitive using functor op.
Definition: GEO_PrimVDB.h:825
SYS_FORCE_INLINE void setPos3(const UT_Vector3 &pos)
Definition: GEO_PrimVDB.h:97
Used to pass options and map offset values during saving.
Definition: GA_SaveMap.h:48
SYS_FORCE_INLINE openvdb::MetaMap & getMetadata()
Return a reference to this primitive's grid metadata.
Definition: GEO_PrimVDB.h:515
SYS_FORCE_INLINE GridAccessor()
Definition: GEO_PrimVDB.h:667
virtual UT_Vector3D computeNormalD() const =0
SYS_FORCE_INLINE void clear()
Definition: GEO_PrimVDB.h:671
const GLdouble * v
Definition: glcorearb.h:837
SYS_FORCE_INLINE openvdb::GridBase::ConstPtr getConstGridPtr() const
Return a shared pointer to this primitive's grid.
Definition: GEO_PrimVDB.h:476
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:508
bool enlargeBoundingBox(UT_BoundingRect &b, const GA_Attribute *p) const override
SYS_AtomicCounter AtomicUniqueId
Definition: GEO_PrimVDB.h:609
const openvdb::MetaMap & getMetadata() const
Return a reference to this primitive's grid metadata.
Definition: GEO_PrimVDB.h:510
fpreal calcVolume(const UT_Vector3 &) const override
SYS_FORCE_INLINE const openvdb::GridBase & getConstGrid() const
Return a reference to this primitive's grid.
Definition: GEO_PrimVDB.h:455
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
SYS_FORCE_INLINE void setPointOffset(GA_Size i, GA_Offset ptoff)
Definition: GA_Primitive.h:260
int64 exint
Definition: SYS_Types.h:125
UniqueId getUniqueId() const
Return this primitive's serial number.
Definition: GEO_PrimVDB.h:527
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
void incrTransformUniqueId()
Definition: GEO_PrimVDB.h:637
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:87
void reverse() override=0
Reverse the order of vertices.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
Definition: GA_Primitive.h:80
GEO_VolumeVis myMode
GLint y
Definition: glcorearb.h:103
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:37
Abstract base class for a range membership query object.
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:229
**But if you need a result
Definition: thread.h:613
UT_VDBType
Definition: UT_VDBUtils.h:11
const GEO_VolumeOptions & getVisOptions() const
Definition: GEO_PrimVDB.h:381
unsigned long long uint64
Definition: SYS_Types.h:117
#define UT_IF_ASSERT_P(ZZ)
Definition: UT_Assert.h:182
fpreal calcArea() const override
bool GEOvdbProcessTypedGridPoint(const GEO_PrimVDB &vdb, OpT &op)
Utility function to process the grid of a const primitive using functor op.
Definition: GEO_PrimVDB.h:837
SYS_FORCE_INLINE openvdb::GridBase::ConstPtr getConstGridPtr(const GEO_PrimVDB &prim) const
Definition: GEO_PrimVDB.h:694
void read(T &in, bool &v)
Definition: ImfXdr.h:502
UniqueId getMetadataUniqueId() const
Return the serial number of this primitive's grid metadata.
Definition: GEO_PrimVDB.h:540
void incrGridUniqueIds()
Definition: GEO_PrimVDB.h:639
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:235
SYS_FORCE_INLINE int64 getBaseMemoryUsage() const
Report approximate memory usage for myVertexList for subclasses.
Definition: GA_Primitive.h:840
bool apply(OpT &op) const
If this primitive's grid resolves to one of the listed grid types, invoke the functor op on the resol...
Definition: GEO_PrimVDB.h:563
GA_PrimitiveFamilyMask
void setVisualization(GEO_VolumeVis vismode, fpreal iso, fpreal density, GEO_VolumeVisLod lod=GEO_VOLUMEVISLOD_FULL)
Definition: GEO_PrimVDB.h:385
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:678
SYS_FORCE_INLINE UT_Vector3 getPos3() const
Definition: GEO_PrimVDB.h:94
bool GEOvdbProcessTypedGridReal(const GEO_PrimVDB &vdb, OpT &op)
Utility function to process the grid of a const primitive using functor op.
Definition: GEO_PrimVDB.h:813
bool GEOvdbProcessTypedGridVec3(const GEO_PrimVDB &vdb, OpT &op)
Utility function to process the grid of a const primitive using functor op.
Definition: GEO_PrimVDB.h:831
uint64 UniqueId
Definition: GEO_PrimVDB.h:39
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:641
SYS_FORCE_INLINE bool hasGrid() const
Definition: GEO_PrimVDB.h:715
virtual bool enlargeBoundingSphere(UT_BoundingSphere &b, const GA_Attribute *P) const
SYS_FORCE_INLINE GA_Offset getPointOffset() const
Definition: GEO_PrimVDB.h:88
#define UT_VDB_DECL_PROCESS_TYPED_GRID(GRID_BASE_T)
Utility function that, given a generic grid pointer, calls a functor on the fully-resolved grid...
Definition: UT_VDBUtils.h:237
SYS_FORCE_INLINE UT_VDBType getStorageType() const
Definition: GEO_PrimVDB.h:712
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Definition: GA_Primitive.h:274
GLfloat f
Definition: glcorearb.h:1926
virtual void setLocalTransform(const UT_Matrix3D &matrix)
Set the local transform. The default implementation does nothing.
GLintptr offset
Definition: glcorearb.h:665
SYS_FORCE_INLINE openvdb::GridBase::Ptr getGridPtr()
Return a shared pointer to this primitive's grid.
Definition: GEO_PrimVDB.h:489
bool GEOvdbProcessTypedGridScalar(const GEO_PrimVDB &vdb, OpT &op)
Utility function to process the grid of a const primitive using functor op.
Definition: GEO_PrimVDB.h:819
GEO_VolumeVisLod myLod
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:155
void incrMetadataUniqueId()
Definition: GEO_PrimVDB.h:635
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
virtual const GA_PrimitiveJSON * getJSON() const =0
void setVertexPoint(int i, GA_Offset pt)
Definition: GEO_PrimVDB.h:427
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
Provide a JSON interface to a primitive.
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
#define GEO_API
Definition: GEO_API.h:14
void activateIndexBBox(const openvdb::CoordBBox &bbox, ActivateOperation operation, bool setvalue, fpreal value)
Definition: GEO_PrimVDB.h:306
SYS_FORCE_INLINE void setTransform(const openvdb::math::Transform &xform, GEO_PrimVDB &prim)
Definition: GEO_PrimVDB.h:703
GEO_VolumeVis
SYS_FORCE_INLINE int getTupleSize() const
Get the tuple size, usually 1 or 3.
Definition: GEO_PrimVDB.h:159
long long int64
Definition: SYS_Types.h:116
A handle to simplify manipulation of multiple attributes.
UniqueId getTreeUniqueId() const
Return the serial number of this primitive's voxel data.
Definition: GEO_PrimVDB.h:534
SYS_FORCE_INLINE bool hasGrid() const
Definition: GEO_PrimVDB.h:438
Options during loading.
Definition: GA_LoadMap.h:42
HUSD_API const char * resolution()
GLuint const GLchar * name
Definition: glcorearb.h:786
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
SYS_FORCE_INLINE void setGrid(const openvdb::GridBase &grid, GEO_PrimVDB &prim, bool copyPosition=true)
Definition: GEO_PrimVDB.h:700
SYS_FORCE_INLINE openvdb::GridBase & getGrid(const GEO_PrimVDB &prim)
Definition: GEO_PrimVDB.h:679
GLint GLenum GLint x
Definition: glcorearb.h:409
SYS_FORCE_INLINE openvdb::GridBase::Ptr getGridPtr(const GEO_PrimVDB &prim)
Definition: GEO_PrimVDB.h:689
int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const override
Evalaute position given a u,v coordinate (with derivatives)
Definition: GEO_PrimVDB.h:220
virtual GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q, bool dry_run=false)=0
SYS_FORCE_INLINE GA_Offset getVertexOffset() const
Definition: GEO_PrimVDB.h:85
SYS_FORCE_INLINE void setGrid(const openvdb::GridBase &grid, bool copyPosition=true)
Set this primitive's grid to a shallow copy of the given grid.
Definition: GEO_PrimVDB.h:498
SYS_FORCE_INLINE void setPos3(GA_Size i, const UT_Vector3 &pos) const
Definition: GA_Primitive.h:286
UniqueId getTransformUniqueId() const
Return the serial number of this primitive's transform.
Definition: GEO_PrimVDB.h:546
virtual void transform(const UT_Matrix4 &)
virtual void enlargePointBounds(UT_BoundingBox &box) const
SYS_FORCE_INLINE const openvdb::GridBase & getConstGrid(const GEO_PrimVDB &prim) const
Definition: GEO_PrimVDB.h:684
virtual void getLocalTransform(UT_Matrix3D &matrix) const
virtual int detachPoints(GA_PointGroup &grp)=0
fpreal getVisDensity() const
Definition: GEO_PrimVDB.h:398
SYS_FORCE_INLINE void makeGridUnique()
If this primitive's grid's voxel data (i.e., its tree) is shared, replace the tree with a deep copy o...
Definition: GEO_PrimVDB.h:444
bool isGridUnique() const
Returns true if the tree is not shared. If it is not shared, one can make destructive edits without m...
Definition: GEO_PrimVDB.h:449
int UTvdbGetGridTupleSize(UT_VDBType type)
Returns the tuple size of a grid given its value type.
Definition: UT_VDBUtils.h:108
fpreal64 fpreal
Definition: SYS_Types.h:277
virtual bool getBBox(UT_BoundingBox *bbox) const =0
SYS_FORCE_INLINE openvdb::GridBase::ConstPtr getGridPtr() const
Return a shared pointer to this primitive's grid.
Definition: GEO_PrimVDB.h:482
GLuint index
Definition: glcorearb.h:786
SYS_FORCE_INLINE GA_Offset getVertexOffset(GA_Size primvertexnum) const
Definition: GA_Primitive.h:240
virtual void stealCEBuffers(const GA_Primitive *src)
Steal the underlying CE buffer from the source.
Definition: GA_Primitive.h:814
void setVisOptions(const GEO_VolumeOptions &vis)
Definition: GEO_PrimVDB.h:382
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:99
virtual bool evaluatePointRefMap(GA_Offset result_vtx, GA_AttributeRefMap &map, fpreal u, fpreal v=0, uint du=0, uint dv=0) const =0
GEO_VolumeVisLod getVisLod() const
Definition: GEO_PrimVDB.h:399
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_PrimVDB.h:48
Definition: core.h:1131
void callTypedGrid(GEO_PrimVDB &prim, OpType &op)
Definition: GEO_PrimVDB.h:778
GEO_VolumeVisLod
#define const
Definition: zconf.h:214
SYS_FORCE_INLINE const openvdb::GridBase & getGrid() const
Return a reference to this primitive's grid.
Definition: GEO_PrimVDB.h:460
fpreal getVisIso() const
Definition: GEO_PrimVDB.h:397
SYS_FORCE_INLINE void setPointOffset(GA_Offset pt)
Definition: GEO_PrimVDB.h:91
void write(T &out, bool v)
Definition: ImfXdr.h:287
void countBaseMemory(UT_MemoryCounter &counter) const
unsigned int uint
Definition: SYS_Types.h:45
GEO_VolumeVis getVisualization() const
Definition: GEO_PrimVDB.h:396
SYS_FORCE_INLINE openvdb::GridBase & getGrid()
Return a reference to this primitive's grid.
Definition: GEO_PrimVDB.h:466
bool GEOvdbProcessTypedGrid(const GEO_PrimVDB &vdb, OpT &op)
Utility function to process the grid of a const primitive using functor op.
Definition: GEO_PrimVDB.h:807
GLint lod
Definition: glcorearb.h:2765
void incrTreeUniqueId()
Definition: GEO_PrimVDB.h:633
virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v=0, unsigned du=0, unsigned dv=0) const
virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET)
constexpr T normalize(UT_FixedVector< T, D > &a) noexcept
bool isEmpty() const
True if the underlying grid has no voxels.
Definition: GEO_PrimVDB.h:179
bool apply(OpT &op, bool makeUnique=true)
If this primitive's grid resolves to one of the listed grid types, invoke the functor op on the resol...
Definition: GEO_PrimVDB.h:585
const openvdb::MetaMap & getConstMetadata() const
Return a reference to this primitive's grid metadata.
Definition: GEO_PrimVDB.h:506
GLenum src
Definition: glcorearb.h:1793