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 
272  /// Computes the voxel diameter by taking a step in x, y, and z
273  /// converting to world space and taking the length of that vector.
274  fpreal getVoxelDiameter() const;
275 
276  /// Returns the length of the voxel when you take an x, y, and z step
277  UT_Vector3 getVoxelSize() const;
278 
279  /// Compute useful aggregate properties of the volume.
280  fpreal calcMinimum() const;
281  fpreal calcMaximum() const;
282  fpreal calcAverage() const;
283 
284  /// VDBs may either be unbounded, or created with a specific frustum
285  /// range. The latter is important for tapered VDBs that otherwise
286  /// have a singularity at the camera location. Tools can use the
287  /// presence of an idxbox as a clipping box in index space.
288  /// This does *NOT* relate to getRes - it may be much larger or
289  /// even in some cases smaller.
290  bool getFrustumBounds(UT_BoundingBox &idxbox) const;
291 
293  {
294  ACTIVATE_UNION, // Activate anything in source
295  ACTIVATE_INTERSECT, // Deactivate anything not in source
296  ACTIVATE_SUBTRACT, // Deactivate anything in source
297  ACTIVATE_COPY // Set our activation to match source
298  };
299 
300  /// Activates voxels given an *index* space bounding box. This
301  /// is an inclusive box.
302  /// If this is Frustum VDB, the activation will be clipped by that.
303  /// Setting the value only takes effect if the voxels are activated,
304  /// deactivated voxels are set to the background.
306  const openvdb::CoordBBox& bbox,
307  ActivateOperation operation,
308  bool setvalue, fpreal value)
309  {
310  activateIndexBBoxAdapter(
311  &bbox, operation, setvalue, value);
312  }
313 
314  /// Activates all of the voxels in this VDB that are touched
315  /// by active voxels in the source.
316  /// If ignore_transform is true, voxels will be activated
317  /// by grid index instead of world space position.
318  void activateByVDB(const GEO_PrimVDB *vdb,
319  ActivateOperation operation,
320  bool setvalue, fpreal value,
321  bool ignore_transform=false);
322 
323  /// @{
324  /// Though not strictly required (i.e. not pure virtual), these methods
325  /// should be implemented for proper behaviour.
326  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
327 
328  // Have we been deactivated and stashed?
329  void stashed(bool beingstashed,
331 
332  /// @}
333 
334  /// @{
335  /// Optional interface methods. Though not required, implementing these
336  /// will give better behaviour for the new primitive.
337  UT_Vector3 baryCenter() const override;
338  fpreal calcVolume(const UT_Vector3 &refpt) const override;
339  /// Calculate the surface area of the active voxels where
340  /// a voxel face contributes if it borders an inactive voxel.
341  fpreal calcArea() const override;
342  /// @}
343 
344  /// @{
345  /// Enlarge a bounding box by the bounding box of the primitive. A
346  /// return value of false indicates an error in the operation, most
347  /// likely an invalid P. For any attribute other than the position
348  /// these methods simply enlarge the bounding box based on the vertex.
349  bool enlargeBoundingBox(
351  const GA_Attribute *P) const override;
352  bool enlargeBoundingBox(
353  UT_BoundingBox &b,
354  const GA_Attribute *P) const override;
355  void enlargePointBounds(UT_BoundingBox &e) const override;
356  /// @}
357  /// Enlarge a bounding sphere to encompass the primitive. A return value
358  /// of false indicates an error in the operation, most likely an invalid
359  /// P. For any attribute other than the position this method simply
360  /// enlarges the sphere based on the vertex.
363  const GA_Attribute *P) const override;
364 
365  /// Accessor for the local 3x3 affine transform matrix for the primitive.
366  /// For frustum maps, this will be transform as if the taper value is set
367  /// to 1.
368  /// @{
369  void getLocalTransform(UT_Matrix3D &result) const override;
370  void setLocalTransform(const UT_Matrix3D &new_mat3) override;
371  /// @}
372 
373  /// @internal Hack to condition 4x4 matrices that we avoid creating what
374  /// OpenVDB erroneously thinks are singular matrices. Returns true if mat4
375  /// was modified.
376  static bool conditionMatrix(UT_Matrix4D &mat4);
377 
378  /// Visualization accessors
379  /// @{
380  const GEO_VolumeOptions &getVisOptions() const { return myVis; }
382  { setVisualization(vis.myMode, vis.myIso, vis.myDensity, vis.myLod); }
383 
385  GEO_VolumeVis vismode,
386  fpreal iso,
387  fpreal density,
389  {
390  myVis.myMode = vismode;
391  myVis.myIso = iso;
392  myVis.myDensity = density;
393  myVis.myLod = lod;
394  }
395  GEO_VolumeVis getVisualization() const { return myVis.myMode; }
396  fpreal getVisIso() const { return myVis.myIso; }
397  fpreal getVisDensity() const { return myVis.myDensity; }
398  GEO_VolumeVisLod getVisLod() const { return myVis.myLod; }
399  /// @}
400 
401  /// Load the order from a JSON value
402  bool loadOrder(const UT_JSONValue &p);
403 
404  /// @{
405  /// Save/Load vdb to a JSON stream
406  bool saveVDB(UT_JSONWriter &w, const GA_SaveMap &sm,
407  bool as_shmem = false) const;
408  bool loadVDB(UT_JSONParser &p,
409  bool as_shmem = false);
410  /// @}
411 
412  bool saveVisualization(
413  UT_JSONWriter &w,
414  const GA_SaveMap &map) const;
415  bool loadVisualization(
416  UT_JSONParser &p,
417  const GA_LoadMap &map);
418 
419  /// Method to perform quick lookup of vertex without the virtual call
421  {
422  UT_ASSERT_P(index < 1);
423  return getVertexOffset();
424  }
425 
426  void setVertexPoint(int i, GA_Offset pt)
427  {
428  if (i == 0)
429  setPointOffset(pt);
430  }
431 
432  /// @brief Computes the total density of the volume, scaled by
433  /// the volume's size. Negative values will be ignored.
434  fpreal calcPositiveDensity() const;
435 
437  bool hasGrid() const { return myGridAccessor.hasGrid(); }
438 
439  /// @brief If this primitive's grid's voxel data (i.e., its tree)
440  /// is shared, replace the tree with a deep copy of itself that is
441  /// not shared with anyone else.
444  { myGridAccessor.makeGridUnique(); }
445 
446  /// @brief Returns true if the tree is not shared. If it is not shared,
447  /// one can make destructive edits without makeGridUnique.
448  bool isGridUnique() const
449  { return myGridAccessor.isGridUnique(); }
450 
451  /// @brief Return a reference to this primitive's grid.
452  /// @note Calling setGrid() invalidates all references previously returned.
454  const openvdb::GridBase & getConstGrid() const
455  { return myGridAccessor.getConstGrid(*this); }
456  /// @brief Return a reference to this primitive's grid.
457  /// @note Calling setGrid() invalidates all references previously returned.
459  const openvdb::GridBase & getGrid() const
460  { return getConstGrid(); }
461  /// @brief Return a reference to this primitive's grid.
462  /// @note Calling setGrid() invalidates all references previously returned.
463  /// @warning Call makeGridUnique() before modifying the grid's voxel data.
465  openvdb::GridBase & getGrid()
466  {
467  incrGridUniqueIds();
468  return myGridAccessor.getGrid(*this);
469  }
470 
471  /// @brief Return a shared pointer to this primitive's grid.
472  /// @note Calling setGrid() causes the grid to which the shared pointer
473  /// refers to be disassociated with this primitive.
475  openvdb::GridBase::ConstPtr getConstGridPtr() const
476  { return myGridAccessor.getConstGridPtr(*this); }
477  /// @brief Return a shared pointer to this primitive's grid.
478  /// @note Calling setGrid() causes the grid to which the shared pointer
479  /// refers to be disassociated with this primitive.
481  openvdb::GridBase::ConstPtr getGridPtr() const
482  { return getConstGridPtr(); }
483  /// @brief Return a shared pointer to this primitive's grid.
484  /// @note Calling setGrid() causes the grid to which the shared pointer
485  /// refers to be disassociated with this primitive.
486  /// @warning Call makeGridUnique() before modifying the grid's voxel data.
488  openvdb::GridBase::Ptr getGridPtr()
489  {
490  incrGridUniqueIds();
491  return myGridAccessor.getGridPtr(*this);
492  }
493 
494  /// @brief Set this primitive's grid to a shallow copy of the given grid.
495  /// @note Invalidates all previous getGrid() and getConstGrid() references
497  void setGrid(const openvdb::GridBase &grid, bool copyPosition=true)
498  {
499  incrGridUniqueIds();
500  myGridAccessor.setGrid(grid, *this, copyPosition);
501  }
502 
503  /// @brief Return a reference to this primitive's grid metadata.
504  /// @note Calling setGrid() invalidates all references previously returned.
505  const openvdb::MetaMap& getConstMetadata() const
506  { return getConstGrid(); }
507  /// @brief Return a reference to this primitive's grid metadata.
508  /// @note Calling setGrid() invalidates all references previously returned.
509  const openvdb::MetaMap& getMetadata() const
510  { return getConstGrid(); }
511  /// @brief Return a reference to this primitive's grid metadata.
512  /// @note Calling setGrid() invalidates all references previously returned.
514  openvdb::MetaMap& getMetadata()
515  {
516  incrMetadataUniqueId();
517  return myGridAccessor.getGrid(*this);
518  }
519 
520  /// @brief Return the value of this primitive's "name" attribute
521  /// in the given detail.
522  const char * getGridName() const;
523 
524  /// @brief Return this primitive's serial number.
525  /// @details A primitive's serial number never changes.
527  { return static_cast<UniqueId>(myUniqueId.relaxedLoad()); }
528 
529  /// @brief Return the serial number of this primitive's voxel data.
530  /// @details The serial number is incremented whenever a non-const
531  /// reference or pointer to this primitive's grid is requested
532  /// (whether or not the voxel data is ultimately modified).
534  { return static_cast<UniqueId>(myTreeUniqueId.relaxedLoad()); }
535  /// @brief Return the serial number of this primitive's grid metadata.
536  /// @details The serial number is incremented whenever a non-const
537  /// reference to the metadata or non-const access to the grid is requested
538  /// (whether or not the metadata is ultimately modified).
540  { return static_cast<UniqueId>(myMetadataUniqueId.relaxedLoad()); }
541  /// @brief Return the serial number of this primitive's transform.
542  /// @details The serial number is incremented whenever the transform
543  /// is modified or non-const access to this primitive's grid is requested
544  /// (whether or not the transform is ultimately modified).
546  { return static_cast<UniqueId>(myTransformUniqueId.relaxedLoad()); }
547 
548 
549  /// @brief If this primitive's grid resolves to one of the listed grid types,
550  /// invoke the functor @a op on the resolved grid.
551  /// @return @c true if the functor was invoked, @c false otherwise
552  ///
553  /// @par Example:
554  /// @code
555  /// auto printOp = [](const openvdb::GridBase& grid) { grid.print(); };
556  /// const GEO_PrimVDB* prim = ...;
557  /// using RealGridTypes = openvdb::TypeList<openvdb::FloatGrid, openvdb::DoubleGrid>;
558  /// // Print info about the primitive's grid if it is a floating-point grid.
559  /// prim->apply<RealGridTypes>(printOp);
560  /// @endcode
561  template<typename GridTypeListT, typename OpT>
562  bool apply(OpT& op) const
563  { return hasGrid() ? getConstGrid().apply<GridTypeListT>(op) : false; }
564 
565  /// @brief If this primitive's grid resolves to one of the listed grid types,
566  /// invoke the functor @a op on the resolved grid.
567  /// @return @c true if the functor was invoked, @c false otherwise
568  /// @details If @a makeUnique is true, deep copy the grid's tree before
569  /// invoking the functor if the tree is shared with other grids.
570  ///
571  /// @par Example:
572  /// @code
573  /// auto fillOp = [](const auto& grid) { // C++14
574  /// // Convert voxels in the given bounding box into background voxels.
575  /// grid.fill(openvdb::CoordBBox(openvdb::Coord(0), openvdb::Coord(99)),
576  /// grid.background(), /*active=*/false);
577  /// };
578  /// GEO_PrimVDB* prim = ...;
579  /// // Set background voxels in the primitive's grid if it is a floating-point grid.
580  /// using RealGridTypes = openvdb::TypeList<openvdb::FloatGrid, openvdb::DoubleGrid>;
581  /// prim->apply<RealGridTypes>(fillOp);
582  /// @endcode
583  template<typename GridTypeListT, typename OpT>
584  bool apply(OpT& op, bool makeUnique = true)
585  {
586  if (hasGrid()) {
587  auto& grid = myGridAccessor.getGrid(*this);
588  if (makeUnique) {
589  auto treePtr = grid.baseTreePtr();
590  if (treePtr.use_count() > 2) { // grid + treePtr = 2
591  // If the grid resolves to one of the listed types and its tree
592  // is shared with other grids, replace the tree with a deep copy.
593  grid.apply<GridTypeListT>([this](openvdb::GridBase& baseGrid) {
594  baseGrid.setTree(baseGrid.constBaseTree().copy());
595  this->incrTreeUniqueId();
596  });
597  }
598  }
599  if (grid.apply<GridTypeListT>(op)) {
600  incrGridUniqueIds();
601  return true;
602  }
603  }
604  return false;
605  }
606 
607 protected:
609 
610  /// Register intrinsic attributes
611  GA_DECLARE_INTRINSICS(override)
612 
613  /// Return true if the given metadata token is an intrinsic
614  static bool isIntrinsicMetadata(const char *name);
615 
616  /// @warning vertexPoint() doesn't check the bounds. Use with caution.
617  GA_Offset vertexPoint(GA_Size) const
618  { return getPointOffset(); }
619 
620  /// Report approximate memory usage, excluding sizeof(*this),
621  /// because the subclass doesn't have access to myGridAccessor.
622  int64 getBaseMemoryUsage() const;
623 
624  // This is called by the subclasses to count the
625  // memory used by this, excluding sizeof(*this).
627 
628  /// @brief Return an ID number that is guaranteed to be unique across
629  /// all VDB primitives.
630  static UniqueId nextUniqueId();
631 
633  { myTreeUniqueId.maximum(nextUniqueId()); }
635  { myMetadataUniqueId.maximum(nextUniqueId()); }
637  { myTransformUniqueId.maximum(nextUniqueId()); }
639  {
640  incrTreeUniqueId();
641  incrMetadataUniqueId();
642  incrTransformUniqueId();
643  }
644 
645  /// @brief Replace this primitive's grid with a shallow copy
646  /// of another primitive's grid.
647  void copyGridFrom(const GEO_PrimVDB&, bool copyPosition=true);
648 
649  /// @brief GridAccessor manages access to a GEO_PrimVDB's grid.
650  /// @details In keeping with OpenVDB library conventions, the grid
651  /// is stored internally by shared pointer. However, grid objects
652  /// are never shared among primitives, though their voxel data
653  /// (i.e., their trees) may be shared.
654  /// <p>Among other things, GridAccessor
655  /// - ensures that each primitive's transform and metadata are unique
656  /// (i.e., not shared with anyone else)
657  /// - allows primitives to share voxel data but, via makeGridUnique(),
658  /// provides a way to break the connection
659  /// - ensures that the primitive's transform and the grid's transform
660  /// are in sync (specifically, the translation component, which is
661  /// stored independently as a vertex offset).
663  {
664  public:
666  GridAccessor() : myStorageType(UT_VDB_INVALID)
667  { }
668 
670  void clear()
671  {
672  myGrid.reset();
673  myStorageType = UT_VDB_INVALID;
674  }
675 
677  openvdb::GridBase &
678  getGrid(const GEO_PrimVDB &prim)
679  { updateGridTranslates(prim); return *myGrid; }
680 
682  const openvdb::GridBase &
683  getConstGrid(const GEO_PrimVDB &prim) const
684  { updateGridTranslates(prim); return *myGrid; }
685 
687  openvdb::GridBase::Ptr
688  getGridPtr(const GEO_PrimVDB &prim)
689  { updateGridTranslates(prim); return myGrid; }
690 
692  openvdb::GridBase::ConstPtr
693  getConstGridPtr(const GEO_PrimVDB &prim) const
694  { updateGridTranslates(prim); return myGrid; }
695 
696  // These accessors will ensure the transform's translate is set into
697  // the vertex position.
699  void setGrid(const openvdb::GridBase& grid, GEO_PrimVDB& prim, bool copyPosition=true)
700  { setGridAdapter(&grid, prim, copyPosition); }
703  const openvdb::math::Transform &xform,
704  GEO_PrimVDB &prim)
705  { setTransformAdapter(&xform, prim); }
706 
707  void makeGridUnique();
708  bool isGridUnique() const;
709 
711  UT_VDBType getStorageType() const { return myStorageType; }
712 
714  bool hasGrid() const { return myGrid != 0; }
715 
716  private:
717  void updateGridTranslates(const GEO_PrimVDB &prim) const;
718 
720  void setVertexPosition(
721  const openvdb::math::Transform &xform,
722  GEO_PrimVDB &prim)
723  { setVertexPositionAdapter(&xform, prim); }
724 
725  void setGridAdapter(const void* grid, GEO_PrimVDB&, bool copyPosition);
726  void setTransformAdapter(const void* xform, GEO_PrimVDB&);
727  void setVertexPositionAdapter(const void* xform, GEO_PrimVDB&);
728 
729  private:
730  openvdb::GridBase::Ptr myGrid;
731  UT_VDBType myStorageType;
732  };
733 
734 private:
735  void activateIndexBBoxAdapter(
736  const void* bbox,
737  ActivateOperation,
738  bool setvalue, fpreal value);
739 
740 
741  GridAccessor myGridAccessor;
742 
743  GEO_VolumeOptions myVis;
744 
745  mutable CE_VDBGrid *myCEGrid;
746  mutable bool myCEGridAuthorative;
747  mutable bool myCEGridIsOwned;
748 
749  AtomicUniqueId myUniqueId;
750  AtomicUniqueId myTreeUniqueId;
751  AtomicUniqueId myMetadataUniqueId;
752  AtomicUniqueId myTransformUniqueId;
753 
754 }; // class GEO_PrimVDB
755 
756 
757 #if 0 // ndef SESI_OPENVDB
758 namespace openvdb_houdini {
759 using ::GEO_VolumeOptions;
760 using ::GEO_PrimVDB;
761 }
762 #endif
763 
764 
765 ////////////////////////////////////////
766 
767 
768 namespace UT_VDBUtils {
769 
770 // This overload of UT_VDBUtils::callTypedGrid(), for GridBaseType = GEO_PrimVDB,
771 // calls makeGridUnique() on the primitive just before instantiating and
772 // invoking the functor on the primitive's grid. This delays the call
773 // to makeGridUnique() until it is known to be necessary and thus avoids
774 // making deep copies of grids of types that won't be processed.
775 template<typename GridType, typename OpType>
776 inline void
777 callTypedGrid(GEO_PrimVDB& prim, OpType& op)
778 {
779  prim.makeGridUnique();
780  op.template operator()<GridType>(*(UTverify_cast<GridType*>(&prim.getGrid())));
781 }
782 
783 // Overload of callTypedGrid() for GridBaseType = const GEO_PrimVDB
784 template<typename GridType, typename OpType>
785 inline void
786 callTypedGrid(const GEO_PrimVDB& prim, OpType& op)
787 {
788  op.template operator()<GridType>(*(UTverify_cast<const GridType*>(&prim.getConstGrid())));
789 }
790 
791 } // namespace UT_VDBUtils
792 
793 // Define UTvdbProcessTypedGrid*() (see UT_VDBUtils.h) for grids
794 // belonging to primitives, for various subsets of grid types.
797 
798 
799 ////////////////////////////////////////
800 
801 
802 /// @brief Utility function to process the grid of a const primitive using functor @a op.
803 /// @details It will invoke @code op.operator()<GridT>(const GridT &grid) @endcode
804 /// @{
805 template <typename OpT>
806 inline bool GEOvdbProcessTypedGrid(const GEO_PrimVDB &vdb, OpT &op)
807 {
808  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
809 }
810 
811 template <typename OpT>
812 inline bool GEOvdbProcessTypedGridReal(const GEO_PrimVDB &vdb, OpT &op)
813 {
814  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
815 }
816 
817 template <typename OpT>
818 inline bool GEOvdbProcessTypedGridScalar(const GEO_PrimVDB &vdb, OpT &op)
819 {
820  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
821 }
822 
823 template <typename OpT>
824 inline bool GEOvdbProcessTypedGridTopology(const GEO_PrimVDB &vdb, OpT &op)
825 {
826  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
827 }
828 
829 template <typename OpT>
830 inline bool GEOvdbProcessTypedGridVec3(const GEO_PrimVDB &vdb, OpT &op)
831 {
832  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
833 }
834 
835 template <typename OpT>
836 inline bool GEOvdbProcessTypedGridPoint(const GEO_PrimVDB &vdb, OpT &op)
837 {
838  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
839 }
840 /// @}
841 
842 /// @brief Utility function to process the grid of a primitive using functor @a op.
843 /// @param vdb the primitive whose grid is to be processed
844 /// @param op a functor with a call operator of the form
845 /// @code op.operator()<GridT>(GridT &grid) @endcode
846 /// @param makeUnique if @c true, call <tt>vdb.makeGridUnique()</tt> before
847 /// invoking the functor
848 /// @{
849 template <typename OpT>
850 inline bool GEOvdbProcessTypedGrid(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
851 {
852  if (makeUnique) return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb, op);
853  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
854 }
855 
856 template <typename OpT>
857 inline bool GEOvdbProcessTypedGridReal(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
858 {
859  if (makeUnique) return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb, op);
860  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
861 }
862 
863 template <typename OpT>
864 inline bool GEOvdbProcessTypedGridScalar(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
865 {
866  if (makeUnique) return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb, op);
867  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
868 }
869 
870 template <typename OpT>
871 inline bool GEOvdbProcessTypedGridTopology(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
872 {
873  if (makeUnique) return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb, op);
874  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
875 }
876 
877 template <typename OpT>
878 inline bool GEOvdbProcessTypedGridVec3(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
879 {
880  if (makeUnique) return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb, op);
881  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
882 }
883 
884 template <typename OpT>
885 inline bool GEOvdbProcessTypedGridPoint(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
886 {
887  if (makeUnique) return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb, op);
888  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
889 }
890 /// @}
891 
892 #endif // __GEO_PrimVDB__
virtual void flushCEWriteCaches()
Copy any modified caches from the GPU back to CPU cache.
Definition: GA_Primitive.h:798
virtual void flushCECaches()
Definition: GA_Primitive.h:802
GLboolean GLboolean GLboolean b
Definition: glcorearb.h:1222
Definition of a geometry attribute.
Definition: GA_Attribute.h:197
GridAccessor manages access to a GEO_PrimVDB's grid.
Definition: GEO_PrimVDB.h:662
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
GLuint counter
Definition: glew.h:2745
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:420
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:824
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:514
SYS_FORCE_INLINE GridAccessor()
Definition: GEO_PrimVDB.h:666
virtual UT_Vector3D computeNormalD() const =0
SYS_FORCE_INLINE void clear()
Definition: GEO_PrimVDB.h:670
SYS_FORCE_INLINE openvdb::GridBase::ConstPtr getConstGridPtr() const
Return a shared pointer to this primitive's grid.
Definition: GEO_PrimVDB.h:475
virtual void copySubclassData(const GA_Primitive *source)
Definition: GA_Primitive.h:499
SYS_AtomicCounter AtomicUniqueId
Definition: GEO_PrimVDB.h:608
const openvdb::MetaMap & getMetadata() const
Return a reference to this primitive's grid metadata.
Definition: GEO_PrimVDB.h:509
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:454
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:526
virtual GA_DereferenceStatus dereferencePoint(GA_Offset point, bool dry_run=false)=0
void incrTransformUniqueId()
Definition: GEO_PrimVDB.h:636
JSON reader class which handles parsing of JSON or bJSON files.
Definition: UT_JSONParser.h:88
void reverse() override=0
Reverse the order of vertices.
#define GA_DECLARE_INTRINSICS(OVERRIDE)
Definition: GA_Primitive.h:80
bool enlargeBoundingBox(UT_BoundingRect &b, const GA_Attribute *P) const override
GEO_VolumeVis myMode
Class which writes ASCII or binary JSON streams.
Definition: UT_JSONWriter.h:35
Abstract base class for a range membership query object.
SYS_FORCE_INLINE TO_T UTverify_cast(FROM_T from)
Definition: UT_Assert.h:226
GLuint const GLchar * name
Definition: glcorearb.h:786
UT_VDBType
Definition: UT_VDBUtils.h:11
const GEO_VolumeOptions & getVisOptions() const
Definition: GEO_PrimVDB.h:380
GLenum src
Definition: glcorearb.h:1793
unsigned long long uint64
Definition: SYS_Types.h:117
#define UT_IF_ASSERT_P(ZZ)
Definition: UT_Assert.h:179
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:836
SYS_FORCE_INLINE openvdb::GridBase::ConstPtr getConstGridPtr(const GEO_PrimVDB &prim) const
Definition: GEO_PrimVDB.h:693
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:539
void incrGridUniqueIds()
Definition: GEO_PrimVDB.h:638
exint GA_Size
Defines the bit width for index and offset types in GA.
Definition: GA_Types.h:234
SYS_FORCE_INLINE int64 getBaseMemoryUsage() const
Report approximate memory usage for myVertexList for subclasses.
Definition: GA_Primitive.h:831
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:562
GA_PrimitiveFamilyMask
void setVisualization(GEO_VolumeVis vismode, fpreal iso, fpreal density, GEO_VolumeVisLod lod=GEO_VOLUMEVISLOD_FULL)
Definition: GEO_PrimVDB.h:384
virtual UT_Vector3 computeNormal() const =0
Return a normal vector for the primitive.
#define GA_INVALID_OFFSET
Definition: GA_Types.h:677
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:812
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:830
GLint GLenum GLint x
Definition: glcorearb.h:409
GLubyte GLubyte GLubyte GLubyte w
Definition: glcorearb.h:857
uint64 UniqueId
Definition: GEO_PrimVDB.h:39
virtual bool isDegenerate() const =0
Is the primitive degenerate.
GA_Size GA_Offset
Definition: GA_Types.h:640
SYS_FORCE_INLINE bool hasGrid() const
Definition: GEO_PrimVDB.h:714
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:711
SYS_FORCE_INLINE UT_Vector3 getPos3(GA_Size i) const
Definition: GA_Primitive.h:274
virtual void setLocalTransform(const UT_Matrix3D &matrix)
Set the local transform. The default implementation does nothing.
GLuint64EXT * result
Definition: glew.h:14311
SYS_FORCE_INLINE openvdb::GridBase::Ptr getGridPtr()
Return a shared pointer to this primitive's grid.
Definition: GEO_PrimVDB.h:488
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:818
GEO_VolumeVisLod myLod
#define UT_ASSERT_P(ZZ)
Definition: UT_Assert.h:152
const GLdouble * v
Definition: glcorearb.h:837
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
void incrMetadataUniqueId()
Definition: GEO_PrimVDB.h:634
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
virtual const GA_PrimitiveJSON * getJSON() const =0
GLuint num
Definition: glew.h:2695
void setVertexPoint(int i, GA_Offset pt)
Definition: GEO_PrimVDB.h:426
Provide a JSON interface to a primitive.
#define GEO_API
Definition: GEO_API.h:14
void activateIndexBBox(const openvdb::CoordBBox &bbox, ActivateOperation operation, bool setvalue, fpreal value)
Definition: GEO_PrimVDB.h:305
SYS_FORCE_INLINE void setTransform(const openvdb::math::Transform &xform, GEO_PrimVDB &prim)
Definition: GEO_PrimVDB.h:702
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:848
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:533
GLfloat GLfloat p
Definition: glew.h:16656
SYS_FORCE_INLINE bool hasGrid() const
Definition: GEO_PrimVDB.h:437
Options during loading.
Definition: GA_LoadMap.h:42
HUSD_API const char * resolution()
SYS_FORCE_INLINE void setGrid(const openvdb::GridBase &grid, GEO_PrimVDB &prim, bool copyPosition=true)
Definition: GEO_PrimVDB.h:699
SYS_FORCE_INLINE openvdb::GridBase & getGrid(const GEO_PrimVDB &prim)
Definition: GEO_PrimVDB.h:678
SYS_FORCE_INLINE openvdb::GridBase::Ptr getGridPtr(const GEO_PrimVDB &prim)
Definition: GEO_PrimVDB.h:688
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:497
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:545
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:683
virtual void getLocalTransform(UT_Matrix3D &matrix) const
virtual int detachPoints(GA_PointGroup &grp)=0
fpreal getVisDensity() const
Definition: GEO_PrimVDB.h:397
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:443
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:448
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:481
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:805
void setVisOptions(const GEO_VolumeOptions &vis)
Definition: GEO_PrimVDB.h:381
Class to store JSON objects as C++ objects.
Definition: UT_JSONValue.h:77
GLfloat f
Definition: glcorearb.h:1926
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:398
static GA_PrimitiveFamilyMask buildFamilyMask()
Definition: GEO_PrimVDB.h:48
Definition: core.h:1131
GLintptr offset
Definition: glcorearb.h:665
void callTypedGrid(GEO_PrimVDB &prim, OpType &op)
Definition: GEO_PrimVDB.h:777
GEO_VolumeVisLod
#define const
Definition: zconf.h:214
GLint GLenum GLboolean GLsizei stride
Definition: glcorearb.h:872
SYS_FORCE_INLINE const openvdb::GridBase & getGrid() const
Return a reference to this primitive's grid.
Definition: GEO_PrimVDB.h:459
fpreal getVisIso() const
Definition: GEO_PrimVDB.h:396
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:395
SYS_FORCE_INLINE openvdb::GridBase & getGrid()
Return a reference to this primitive's grid.
Definition: GEO_PrimVDB.h:465
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:806
GLint y
Definition: glcorearb.h:103
GLint lod
Definition: glcorearb.h:2765
void incrTreeUniqueId()
Definition: GEO_PrimVDB.h:632
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:584
const openvdb::MetaMap & getConstMetadata() const
Return a reference to this primitive's grid metadata.
Definition: GEO_PrimVDB.h:505