OpenVDB  7.1.0
GEO_PrimVDB.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 /*
5  * Copyright (c) Side Effects Software Inc.
6  *
7  * Produced by:
8  * Side Effects Software Inc
9  * 477 Richmond Street West
10  * Toronto, Ontario
11  * Canada M5V 3E7
12  * 416-504-9876
13  *
14  * NAME: GEO_PrimVDB.h ( GEO Library, C++)
15  *
16  * COMMENTS: Custom VDB primitive.
17  */
18 
19 
20 // Using the native OpenVDB Primitive shipped with Houdini is strongly recommended,
21 // as there is no guarantee that this code will be kept in sync with Houdini.
22 // However, for debugging it can be useful, so supply -DSESI_OPENVDB_PRIM to
23 // the compiler to build this custom primitive.
24 
25 #if !defined(SESI_OPENVDB) && !defined(SESI_OPENVDB_PRIM)
26 
27 #include <GEO/GEO_PrimVDB.h>
28 
29 namespace openvdb_houdini {
30 using ::GEO_VolumeOptions;
31 using ::GEO_PrimVDB;
32 }
33 
34 #else // SESI_OPENVDB || SESI_OPENVDB_PRIM
35 
36 #ifndef __HDK_GEO_PrimVDB__
37 #define __HDK_GEO_PrimVDB__
38 
39 #include <GEO/GEO_Primitive.h>
40 #include <GEO/GEO_VolumeOptions.h>
41 #include <GA/GA_Defines.h>
42 
43 #include <SYS/SYS_AtomicInt.h> // for SYS_AtomicCounter
44 
45 #include <UT/UT_BoundingBox.h>
46 #include "UT_VDBUtils.h"
47 
48 #include <openvdb/Platform.h>
49 #include <openvdb/openvdb.h>
50 
51 
52 class GEO_Detail;
53 class GEO_PrimVolume;
54 class GEO_PrimVolumeXform;
55 class UT_MemoryCounter;
56 
57 
58 class OPENVDB_HOUDINI_API GEO_PrimVDB : public GEO_Primitive
59 {
60 public:
61  typedef uint64 UniqueId;
62 
63 protected:
66  GEO_PrimVDB(GEO_Detail *d, GA_Offset offset = GA_INVALID_OFFSET);
67 
68 public:
69  static GA_PrimitiveFamilyMask buildFamilyMask()
70  { return GA_FAMILY_NONE; }
71 
74  virtual bool isDegenerate() const;
75  virtual int getBBox(UT_BoundingBox *bbox) const;
76  virtual void reverse();
77  virtual UT_Vector3 computeNormal() const;
78  virtual void copyPrimitive(const GEO_Primitive *src);
79  virtual void copySubclassData(const GA_Primitive *source);
80 
81  using GEO_Primitive::getVertexOffset;
82  using GEO_Primitive::getPointOffset;
83  using GEO_Primitive::setPointOffset;
84  using GEO_Primitive::getPos3;
85  using GEO_Primitive::setPos3;
86  SYS_FORCE_INLINE
87  GA_Offset getVertexOffset() const
88  { return getVertexOffset(0); }
89  SYS_FORCE_INLINE
90  GA_Offset getPointOffset() const
91  { return getPointOffset(0); }
92  SYS_FORCE_INLINE
93  void setPointOffset(GA_Offset pt)
94  { setPointOffset(0, pt); }
95  SYS_FORCE_INLINE
96  UT_Vector3 getPos3() const
97  { return getPos3(0); }
98  SYS_FORCE_INLINE
99  void setPos3(const UT_Vector3 &pos)
100  { setPos3(0, pos); }
101 
104  void indexToPos(int x, int y, int z, UT_Vector3 &pos) const;
105  void findexToPos(UT_Vector3 index, UT_Vector3 &pos) const;
106  void indexToPos(exint x, exint y, exint z, UT_Vector3D &pos) const;
107  void findexToPos(UT_Vector3D index, UT_Vector3D &pos) const;
108 
110  void posToIndex(UT_Vector3 pos, int &x, int &y, int &z) const;
111  void posToIndex(UT_Vector3 pos, UT_Vector3 &index) const;
112  void posToIndex(UT_Vector3D pos, exint &x, exint &y, exint &z) const;
113  void posToIndex(UT_Vector3D pos, UT_Vector3D &index) const;
114 
118  fpreal getValueF(const UT_Vector3 &pos) const;
119  fpreal getValueAtIndexF(int ix, int iy, int iz) const;
120  UT_Vector3D getValueV3(const UT_Vector3 &pos) const;
121  UT_Vector3D getValueAtIndexV3(int ix, int iy, int iz) const;
122 
123  void getValues(float *f, int stride, const UT_Vector3 *pos, int num) const;
124  void getValues(int *f, int stride, const UT_Vector3 *pos, int num) const;
125  void getValuesAtIndices(float *f, int stride, const int *ix, const int *iy, const int *iz, int num) const;
126  void getValuesAtIndices(int *f, int stride, const int *ix, const int *iy, const int *iz, int num) const;
127 
129  void getValues(UT_Vector3 *f, int stride, const UT_Vector3 *pos, int num) const;
130  void getValuesAtIndices(UT_Vector3 *f, int stride, const int *ix, const int *iy, const int *iz, int num) const;
131 
132  void getValues(double *f, int stride, const UT_Vector3D *pos, int num) const;
133  void getValues(exint *f, int stride, const UT_Vector3D *pos, int num) const;
134  void getValuesAtIndices(double *f, int stride, const exint *ix, const exint *iy, const exint *iz, int num) const;
135  void getValuesAtIndices(exint *f, int stride, const exint *ix, const exint *iy, const exint *iz, int num) const;
136 
138  void getValues(UT_Vector3D *f, int stride, const UT_Vector3D *pos, int num) const;
139  void getValuesAtIndices(UT_Vector3D *f, int stride, const exint *ix, const exint *iy, const exint *iz, int num) const;
140 
141  // Worldspace gradient at the given position
142  UT_Vector3 getGradient(const UT_Vector3 &pos) const;
143 
148  bool evalGradients(
149  UT_Vector3 *gradients,
150  int gradients_stride,
151  const UT_Vector3 *positions,
152  int num_positions,
153  bool normalize = false) const;
154 
156  SYS_FORCE_INLINE
157  UT_VDBType getStorageType() const
158  { return myGridAccessor.getStorageType(); }
160  SYS_FORCE_INLINE
161  int getTupleSize() const
162  { return UTvdbGetGridTupleSize(getStorageType()); }
163 
164  bool isSDF() const;
165 
167  bool isAligned(const GEO_PrimVDB *vdb) const;
169  bool isActiveRegionMatched(const GEO_PrimVDB *vdb) const;
170 
173  bool isWorldAxisAligned() const;
174 
175  // Transform the matrix associated with this primitive. Translate is
176  // ignored.
177  virtual void transform(const UT_Matrix4 &mat);
178 
183  void setTransform4(const UT_DMatrix4 &xform4);
184  void setTransform4(const UT_Matrix4 &xform4);
185  UT_Matrix4D getTransform4() const;
187 
188  // Take the whole set of points into consideration when applying the
189  // point removal operation to this primitive. The method returns 0 if
190  // successful, -1 if it failed because it would have become degenerate,
191  // and -2 if it failed because it would have had to remove the primitive
192  // altogether.
193  virtual int detachPoints(GA_PointGroup &grp);
197  virtual GA_DereferenceStatus dereferencePoint(GA_Offset point,
198  bool dry_run=false);
199  virtual GA_DereferenceStatus dereferencePoints(
200  const GA_RangeMemberQuery &pt_q,
201  bool dry_run=false);
202  virtual const GA_PrimitiveJSON *getJSON() const;
203 
206  void assignVertex(GA_Offset new_vtx, bool update_topology);
207 
209  virtual bool evaluatePointRefMap(GA_Offset result_vtx,
210  GA_AttributeRefMap &hlist,
211  fpreal u, fpreal v, uint du, uint dv) const;
213  virtual int evaluatePointV4(UT_Vector4 &pos, float u, float v = 0,
214  unsigned du=0, unsigned dv=0) const
215  {
216  return GEO_Primitive::evaluatePointV4(pos, u, v,
217  du, dv);
218  }
220 
223 
228  GEO_PrimVolumeXform getIndexSpaceTransform() const;
229 
234  GEO_PrimVolumeXform getSpaceTransform() const;
235 
243  GEO_PrimVolumeXform getSpaceTransform(const UT_BoundingBoxD &bbox) const;
244 
249  void setSpaceTransform(const GEO_PrimVolumeXform &space,
250  const UT_Vector3R &resolution,
251  bool force_taper = false);
252 
254 
255  fpreal getTaper() const;
256 
259  void getRes(int &rx, int &ry, int &rz) const;
260 
263  fpreal getVoxelDiameter() const;
264 
266  UT_Vector3 getVoxelSize() const;
267 
269  fpreal calcMinimum() const;
270  fpreal calcMaximum() const;
271  fpreal calcAverage() const;
272 
279  bool getFrustumBounds(UT_BoundingBox &idxbox) const;
280 
281  enum ActivateOperation
282  {
283  ACTIVATE_UNION, // Activate anything in source
284  ACTIVATE_INTERSECT, // Deactivate anything not in source
285  ACTIVATE_SUBTRACT, // Deactivate anything in source
286  ACTIVATE_COPY // Set our activation to match source
287  };
288 
294  void activateIndexBBox(
295  const openvdb::CoordBBox& bbox,
296  ActivateOperation operation,
297  bool setvalue, fpreal value)
298  {
299  activateIndexBBoxAdapter(
300  &bbox, operation, setvalue, value);
301  }
302 
307  void activateByVDB(const GEO_PrimVDB *vdb,
308  ActivateOperation operation,
309  bool setvalue, fpreal value,
310  bool ignore_transform=false);
311 
315  virtual GEO_Primitive *copy(int preserve_shared_pts = 0) const;
316 
317  // Have we been deactivated and stashed?
318  virtual void stashed(bool beingstashed, GA_Offset offset=GA_INVALID_OFFSET);
319 
321 
325  virtual UT_Vector3 baryCenter() const;
326  virtual fpreal calcVolume(const UT_Vector3 &refpt) const;
329  virtual fpreal calcArea() const;
331 
337  virtual bool enlargeBoundingBox(UT_BoundingRect &b,
338  const GA_Attribute *P) const;
339  virtual bool enlargeBoundingBox(UT_BoundingBox &b,
340  const GA_Attribute *P) const;
341  virtual void enlargePointBounds(UT_BoundingBox &e) const;
347  virtual bool enlargeBoundingSphere(UT_BoundingSphere &b,
348  const GA_Attribute *P) const;
349 
354  virtual void getLocalTransform(UT_Matrix3D &result) const;
355  virtual void setLocalTransform(const UT_Matrix3D &new_mat3);
357 
361  static bool conditionMatrix(UT_Matrix4D &mat4);
362 
365  const GEO_VolumeOptions &getVisOptions() const { return myVis; }
366  void setVisOptions(const GEO_VolumeOptions &vis)
367  { setVisualization(vis.myMode, vis.myIso, vis.myDensity, vis.myLod); }
368 
369  void setVisualization(
370  GEO_VolumeVis vismode,
371  fpreal iso,
372  fpreal density,
373  GEO_VolumeVisLod lod = GEO_VOLUMEVISLOD_FULL)
374  {
375  myVis.myMode = vismode;
376  myVis.myIso = iso;
377  myVis.myDensity = density;
378  myVis.myLod = lod;
379  }
380  GEO_VolumeVis getVisualization() const { return myVis.myMode; }
381  fpreal getVisIso() const { return myVis.myIso; }
382  fpreal getVisDensity() const { return myVis.myDensity; }
383  GEO_VolumeVisLod getVisLod() const { return myVis.myLod; }
385 
387  bool loadOrder(const UT_JSONValue &p);
388 
391  bool saveVDB(UT_JSONWriter &w, const GA_SaveMap &sm,
392  bool as_shmem = false) const;
393  bool loadVDB(UT_JSONParser &p,
394  bool as_shmem = false);
396 
397  bool saveVisualization(
398  UT_JSONWriter &w,
399  const GA_SaveMap &map) const;
400  bool loadVisualization(
401  UT_JSONParser &p,
402  const GA_LoadMap &map);
403 
405  GA_Offset fastVertexOffset(GA_Size UT_IF_ASSERT_P(index)) const
406  {
407  UT_ASSERT_P(index < 1);
408  return getVertexOffset();
409  }
410 
411  void setVertexPoint(int i, GA_Offset pt)
412  {
413  if (i == 0)
414  setPointOffset(pt);
415  }
416 
419  fpreal calcPositiveDensity() const;
420 
421  SYS_FORCE_INLINE
422  bool hasGrid() const { return myGridAccessor.hasGrid(); }
423 
427  SYS_FORCE_INLINE
428  void makeGridUnique()
429  { myGridAccessor.makeGridUnique(); }
430 
433  bool isGridUnique() const
434  { return myGridAccessor.isGridUnique(); }
435 
438  SYS_FORCE_INLINE
439  const openvdb::GridBase & getConstGrid() const
440  { return myGridAccessor.getConstGrid(*this); }
443  SYS_FORCE_INLINE
444  const openvdb::GridBase & getGrid() const
445  { return getConstGrid(); }
449  SYS_FORCE_INLINE
450  openvdb::GridBase & getGrid()
451  {
452  incrGridUniqueIds();
453  return myGridAccessor.getGrid(*this);
454  }
455 
459  SYS_FORCE_INLINE
460  openvdb::GridBase::ConstPtr getConstGridPtr() const
461  { return myGridAccessor.getConstGridPtr(*this); }
465  SYS_FORCE_INLINE
466  openvdb::GridBase::ConstPtr getGridPtr() const
467  { return getConstGridPtr(); }
472  SYS_FORCE_INLINE
473  openvdb::GridBase::Ptr getGridPtr()
474  {
475  incrGridUniqueIds();
476  return myGridAccessor.getGridPtr(*this);
477  }
478 
481  SYS_FORCE_INLINE
482  void setGrid(const openvdb::GridBase &grid, bool copyPosition=true)
483  {
484  incrGridUniqueIds();
485  myGridAccessor.setGrid(grid, *this, copyPosition);
486  }
487 
490  const openvdb::MetaMap& getConstMetadata() const
491  { return getConstGrid(); }
494  const openvdb::MetaMap& getMetadata() const
495  { return getConstGrid(); }
498  SYS_FORCE_INLINE
499  openvdb::MetaMap& getMetadata()
500  {
501  incrMetadataUniqueId();
502  return myGridAccessor.getGrid(*this);
503  }
504 
507  const char * getGridName() const;
508 
511  UniqueId getUniqueId() const
512  { return static_cast<UniqueId>(myUniqueId.relaxedLoad()); }
513 
518  UniqueId getTreeUniqueId() const
519  { return static_cast<UniqueId>(myTreeUniqueId.relaxedLoad()); }
524  UniqueId getMetadataUniqueId() const
525  { return static_cast<UniqueId>(myMetadataUniqueId.relaxedLoad()); }
530  UniqueId getTransformUniqueId() const
531  { return static_cast<UniqueId>(myTransformUniqueId.relaxedLoad()); }
532 
533 
546  template<typename GridTypeListT, typename OpT>
547  bool apply(OpT& op) const
548  { return hasGrid() ? getConstGrid().apply<GridTypeListT>(op) : false; }
549 
568  template<typename GridTypeListT, typename OpT>
569  bool apply(OpT& op, bool makeUnique = true)
570  {
571  if (hasGrid()) {
572  auto& grid = myGridAccessor.getGrid(*this);
573  if (makeUnique) {
574  auto treePtr = grid.baseTreePtr();
575  if (treePtr.use_count() > 2) { // grid + treePtr = 2
576  // If the grid resolves to one of the listed types and its tree
577  // is shared with other grids, replace the tree with a deep copy.
578  grid.apply<GridTypeListT>([this](openvdb::GridBase& baseGrid) {
579  baseGrid.setTree(baseGrid.constBaseTree().copy());
580  this->incrTreeUniqueId();
581  });
582  }
583  }
584  if (grid.apply<GridTypeListT>(op)) {
585  incrGridUniqueIds();
586  return true;
587  }
588  }
589  return false;
590  }
591 
592 protected:
593  typedef SYS_AtomicCounter AtomicUniqueId; // 64-bit
594 
596  GA_DECLARE_INTRINSICS(GA_NO_OVERRIDE)
597 
598 
599  static bool isIntrinsicMetadata(const char *name);
600 
602  GA_Offset vertexPoint(GA_Size) const
603  { return getPointOffset(); }
604 
607  int64 getBaseMemoryUsage() const;
608 
609  // This is called by the subclasses to count the
610  // memory used by this, excluding sizeof(*this).
611  void countBaseMemory(UT_MemoryCounter &counter) const;
612 
615  static UniqueId nextUniqueId();
616 
617  void incrTreeUniqueId()
618  { myTreeUniqueId.maximum(nextUniqueId()); }
619  void incrMetadataUniqueId()
620  { myMetadataUniqueId.maximum(nextUniqueId()); }
621  void incrTransformUniqueId()
622  { myTransformUniqueId.maximum(nextUniqueId()); }
623  void incrGridUniqueIds()
624  {
625  incrTreeUniqueId();
626  incrMetadataUniqueId();
627  incrTransformUniqueId();
628  }
629 
632  void copyGridFrom(const GEO_PrimVDB&, bool copyPosition=true);
633 
647  class OPENVDB_HOUDINI_API GridAccessor
648  {
649  public:
650  SYS_FORCE_INLINE
651  GridAccessor() : myStorageType(UT_VDB_INVALID)
652  { }
653 
654  SYS_FORCE_INLINE
655  void clear()
656  {
657  myGrid.reset();
658  myStorageType = UT_VDB_INVALID;
659  }
660 
661  SYS_FORCE_INLINE
663  getGrid(const GEO_PrimVDB &prim)
664  { updateGridTranslates(prim); return *myGrid; }
665 
666  SYS_FORCE_INLINE
667  const openvdb::GridBase &
668  getConstGrid(const GEO_PrimVDB &prim) const
669  { updateGridTranslates(prim); return *myGrid; }
670 
671  SYS_FORCE_INLINE
673  getGridPtr(const GEO_PrimVDB &prim)
674  { updateGridTranslates(prim); return myGrid; }
675 
676  SYS_FORCE_INLINE
678  getConstGridPtr(const GEO_PrimVDB &prim) const
679  { updateGridTranslates(prim); return myGrid; }
680 
681  // These accessors will ensure the transform's translate is set into
682  // the vertex position.
683  SYS_FORCE_INLINE
684  void setGrid(const openvdb::GridBase& grid, GEO_PrimVDB& prim, bool copyPosition=true)
685  { setGridAdapter(&grid, prim, copyPosition); }
686  SYS_FORCE_INLINE
687  void setTransform(
688  const openvdb::math::Transform &xform,
689  GEO_PrimVDB &prim)
690  { setTransformAdapter(&xform, prim); }
691 
692  void makeGridUnique();
693  bool isGridUnique() const;
694 
695  SYS_FORCE_INLINE
696  UT_VDBType getStorageType() const { return myStorageType; }
697 
698  SYS_FORCE_INLINE
699  bool hasGrid() const { return myGrid != 0; }
700 
701  private:
702  void updateGridTranslates(const GEO_PrimVDB &prim) const;
703 
704  SYS_FORCE_INLINE
705  void setVertexPosition(
706  const openvdb::math::Transform &xform,
707  GEO_PrimVDB &prim)
708  { setVertexPositionAdapter(&xform, prim); }
709 
710  void setGridAdapter(const void* grid, GEO_PrimVDB&, bool copyPosition);
711  void setTransformAdapter(const void* xform, GEO_PrimVDB&);
712  void setVertexPositionAdapter(const void* xform, GEO_PrimVDB&);
713 
714  private:
715  openvdb::GridBase::Ptr myGrid;
716  UT_VDBType myStorageType;
717  };
718 
719 private:
720  void activateIndexBBoxAdapter(
721  const void* bbox,
722  ActivateOperation,
723  bool setvalue, fpreal value);
724 
725 
726  GridAccessor myGridAccessor;
727 
728  GEO_VolumeOptions myVis;
729 
730  AtomicUniqueId myUniqueId;
731  AtomicUniqueId myTreeUniqueId;
732  AtomicUniqueId myMetadataUniqueId;
733  AtomicUniqueId myTransformUniqueId;
734 
735 }; // class GEO_PrimVDB
736 
737 
738 #ifndef SESI_OPENVDB
739 namespace openvdb_houdini {
740 using ::GEO_VolumeOptions;
741 using ::GEO_PrimVDB;
742 }
743 #endif
744 
745 
747 
748 
749 namespace UT_VDBUtils {
750 
751 // This overload of UT_VDBUtils::callTypedGrid(), for GridBaseType = GEO_PrimVDB,
752 // calls makeGridUnique() on the primitive just before instantiating and
753 // invoking the functor on the primitive's grid. This delays the call
754 // to makeGridUnique() until it is known to be necessary and thus avoids
755 // making deep copies of grids of types that won't be processed.
756 template<typename GridType, typename OpType>
757 inline void
758 callTypedGrid(GEO_PrimVDB& prim, OpType& op)
759 {
760  prim.makeGridUnique();
761  op.template operator()<GridType>(*(UTverify_cast<GridType*>(&prim.getGrid())));
762 }
763 
764 // Overload of callTypedGrid() for GridBaseType = const GEO_PrimVDB
765 template<typename GridType, typename OpType>
766 inline void
767 callTypedGrid(const GEO_PrimVDB& prim, OpType& op)
768 {
769  op.template operator()<GridType>(*(UTverify_cast<const GridType*>(&prim.getConstGrid())));
770 }
771 
772 } // namespace UT_VDBUtils
773 
774 // Define UTvdbProcessTypedGrid*() (see UT_VDBUtils.h) for grids
775 // belonging to primitives, for various subsets of grid types.
776 UT_VDB_DECL_PROCESS_TYPED_GRID(GEO_PrimVDB&)
777 UT_VDB_DECL_PROCESS_TYPED_GRID(const GEO_PrimVDB&)
778 
779 
780 
782 
783 template <typename OpT>
787 inline bool GEOvdbProcessTypedGrid(const GEO_PrimVDB &vdb, OpT &op)
788 {
789  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
790 }
791 
792 template <typename OpT>
793 inline bool GEOvdbProcessTypedGridReal(const GEO_PrimVDB &vdb, OpT &op)
794 {
795  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
796 }
797 
798 template <typename OpT>
799 inline bool GEOvdbProcessTypedGridScalar(const GEO_PrimVDB &vdb, OpT &op)
800 {
801  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
802 }
803 
804 template <typename OpT>
805 inline bool GEOvdbProcessTypedGridTopology(const GEO_PrimVDB &vdb, OpT &op)
806 {
807  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
808 }
809 
810 template <typename OpT>
811 inline bool GEOvdbProcessTypedGridVec3(const GEO_PrimVDB &vdb, OpT &op)
812 {
813  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
814 }
815 
816 template <typename OpT>
817 inline bool GEOvdbProcessTypedGridPoint(const GEO_PrimVDB &vdb, OpT &op)
818 {
819  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
820 }
822 
830 template <typename OpT>
831 inline bool GEOvdbProcessTypedGrid(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
832 {
833  if (makeUnique) return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb, op);
834  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
835 }
836 
837 template <typename OpT>
838 inline bool GEOvdbProcessTypedGridReal(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
839 {
840  if (makeUnique) return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb, op);
841  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
842 }
843 
844 template <typename OpT>
845 inline bool GEOvdbProcessTypedGridScalar(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
846 {
847  if (makeUnique) return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb, op);
848  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
849 }
850 
851 template <typename OpT>
852 inline bool GEOvdbProcessTypedGridTopology(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
853 {
854  if (makeUnique) return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb, op);
855  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
856 }
857 
858 template <typename OpT>
859 inline bool GEOvdbProcessTypedGridVec3(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
860 {
861  if (makeUnique) return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb, op);
862  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
863 }
864 
865 template <typename OpT>
866 inline bool GEOvdbProcessTypedGridPoint(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
867 {
868  if (makeUnique) return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb, op);
869  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
870 }
872 
873 #endif // __HDK_GEO_PrimVDB__
874 
875 #endif // SESI_OPENVDB || SESI_OPENVDB_PRIM
openvdb::v7_1::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:20
openvdb::v7_1::GridBase
Abstract base class for typed grids.
Definition: Grid.h:78
openvdb_houdini
Definition: AttributeTransferUtil.h:33
UT_VDBUtils.h
openvdb::v7_1::tools::normalize
GridType::Ptr normalize(const GridType &grid, bool threaded, InterruptT *interrupt)
Normalize the vectors of the given vector-valued grid.
Definition: GridOperators.h:1064
openvdb::v7_1::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:80
Platform.h
openvdb::v7_1::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:249
openvdb::v7_1::GridBase::baseTreePtr
TreeBase::Ptr baseTreePtr()
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:1238
openvdb::v7_1::GridBase::ConstPtr
SharedPtr< const GridBase > ConstPtr
Definition: Grid.h:81
openvdb::v7_1::GridBase::apply
bool apply(OpT &) const
If this grid resolves to one of the listed grid types, invoke the given functor on the resolved grid.
Definition: Grid.h:1809
OPENVDB_HOUDINI_API
#define OPENVDB_HOUDINI_API
Definition: Platform.h:238
openvdb.h