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