OpenVDB  8.0.1
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  ~GEO_PrimVDB() override;
69 public:
70  static GA_PrimitiveFamilyMask buildFamilyMask()
71  { return GA_FAMILY_NONE; }
72 
75  bool isDegenerate() const override;
76  int getBBox(UT_BoundingBox *bbox) const override;
77  void reverse() override;
78  UT_Vector3 computeNormal() const override;
79  void copyPrimitive(const GEO_Primitive *src) override;
80  void copySubclassData(const GA_Primitive *source) override;
81 
82  using GEO_Primitive::getVertexOffset;
83  using GEO_Primitive::getPointOffset;
84  using GEO_Primitive::setPointOffset;
85  using GEO_Primitive::getPos3;
86  using GEO_Primitive::setPos3;
87  SYS_FORCE_INLINE
88  GA_Offset getVertexOffset() const
89  { return getVertexOffset(0); }
90  SYS_FORCE_INLINE
91  GA_Offset getPointOffset() const
92  { return getPointOffset(0); }
93  SYS_FORCE_INLINE
94  void setPointOffset(GA_Offset pt)
95  { setPointOffset(0, pt); }
96  SYS_FORCE_INLINE
97  UT_Vector3 getPos3() const
98  { return getPos3(0); }
99  SYS_FORCE_INLINE
100  void setPos3(const UT_Vector3 &pos)
101  { setPos3(0, pos); }
102 
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 
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 
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 
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 
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 
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 
157  SYS_FORCE_INLINE
158  UT_VDBType getStorageType() const
159  { return myGridAccessor.getStorageType(); }
161  SYS_FORCE_INLINE
162  int getTupleSize() const
163  { return UTvdbGetGridTupleSize(getStorageType()); }
164 
165  bool isSDF() const;
166 
168  bool isAligned(const GEO_PrimVDB *vdb) const;
170  bool isActiveRegionMatched(const GEO_PrimVDB *vdb) const;
171 
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 
184  void setTransform4(const UT_DMatrix4 &xform4);
185  void setTransform4(const UT_Matrix4 &xform4);
186  UT_Matrix4D getTransform4() const;
188 
189  // Take the whole set of points into consideration when applying the
190  // point removal operation to this primitive. The method returns 0 if
191  // successful, -1 if it failed because it would have become degenerate,
192  // and -2 if it failed because it would have had to remove the primitive
193  // altogether.
194  int detachPoints(GA_PointGroup &grp) override;
198  GA_DereferenceStatus dereferencePoint(GA_Offset point,
199  bool dry_run=false) override;
200  GA_DereferenceStatus dereferencePoints(const GA_RangeMemberQuery &pt_q,
201  bool dry_run=false) override;
202  const GA_PrimitiveJSON *getJSON() const override;
203 
206  void assignVertex(GA_Offset new_vtx, bool update_topology);
207 
209  bool evaluatePointRefMap(
210  GA_Offset result_vtx,
211  GA_AttributeRefMap &hlist,
212  fpreal u, fpreal v,
213  uint du, uint dv) const override;
215  int evaluatePointV4(
216  UT_Vector4 &pos,
217  float u, float v = 0,
218  unsigned du=0, unsigned dv=0) const override
219  {
220  return GEO_Primitive::evaluatePointV4(pos, u, v,
221  du, dv);
222  }
224 
227 
232  GEO_PrimVolumeXform getIndexSpaceTransform() const;
233 
238  GEO_PrimVolumeXform getSpaceTransform() const;
239 
247  GEO_PrimVolumeXform getSpaceTransform(const UT_BoundingBoxD &bbox) const;
248 
253  void setSpaceTransform(const GEO_PrimVolumeXform &space,
254  const UT_Vector3R &resolution,
255  bool force_taper = false);
256 
258 
259  fpreal getTaper() const;
260 
263  void getRes(int &rx, int &ry, int &rz) const;
264 
267  fpreal getVoxelDiameter() const;
268 
270  UT_Vector3 getVoxelSize() const;
271 
273  fpreal calcMinimum() const;
274  fpreal calcMaximum() const;
275  fpreal calcAverage() const;
276 
283  bool getFrustumBounds(UT_BoundingBox &idxbox) const;
284 
285  enum ActivateOperation
286  {
287  ACTIVATE_UNION, // Activate anything in source
288  ACTIVATE_INTERSECT, // Deactivate anything not in source
289  ACTIVATE_SUBTRACT, // Deactivate anything in source
290  ACTIVATE_COPY // Set our activation to match source
291  };
292 
298  void activateIndexBBox(
299  const openvdb::CoordBBox& bbox,
300  ActivateOperation operation,
301  bool setvalue, fpreal value)
302  {
303  activateIndexBBoxAdapter(
304  &bbox, operation, setvalue, value);
305  }
306 
311  void activateByVDB(const GEO_PrimVDB *vdb,
312  ActivateOperation operation,
313  bool setvalue, fpreal value,
314  bool ignore_transform=false);
315 
319  GEO_Primitive *copy(int preserve_shared_pts = 0) const override;
320 
321  // Have we been deactivated and stashed?
322  void stashed(bool beingstashed,
323  GA_Offset offset=GA_INVALID_OFFSET) override;
324 
326 
330  UT_Vector3 baryCenter() const override;
331  fpreal calcVolume(const UT_Vector3 &refpt) const override;
334  fpreal calcArea() const override;
336 
342  bool enlargeBoundingBox(
343  UT_BoundingRect &b,
344  const GA_Attribute *P) const override;
345  bool enlargeBoundingBox(
346  UT_BoundingBox &b,
347  const GA_Attribute *P) const override;
348  void enlargePointBounds(UT_BoundingBox &e) const override;
354  bool enlargeBoundingSphere(
355  UT_BoundingSphere &b,
356  const GA_Attribute *P) const override;
357 
362  void getLocalTransform(UT_Matrix3D &result) const override;
363  void setLocalTransform(const UT_Matrix3D &new_mat3) override;
365 
369  static bool conditionMatrix(UT_Matrix4D &mat4);
370 
373  const GEO_VolumeOptions &getVisOptions() const { return myVis; }
374  void setVisOptions(const GEO_VolumeOptions &vis)
375  { setVisualization(vis.myMode, vis.myIso, vis.myDensity, vis.myLod); }
376 
377  void setVisualization(
378  GEO_VolumeVis vismode,
379  fpreal iso,
380  fpreal density,
381  GEO_VolumeVisLod lod = GEO_VOLUMEVISLOD_FULL)
382  {
383  myVis.myMode = vismode;
384  myVis.myIso = iso;
385  myVis.myDensity = density;
386  myVis.myLod = lod;
387  }
388  GEO_VolumeVis getVisualization() const { return myVis.myMode; }
389  fpreal getVisIso() const { return myVis.myIso; }
390  fpreal getVisDensity() const { return myVis.myDensity; }
391  GEO_VolumeVisLod getVisLod() const { return myVis.myLod; }
393 
395  bool loadOrder(const UT_JSONValue &p);
396 
399  bool saveVDB(UT_JSONWriter &w, const GA_SaveMap &sm,
400  bool as_shmem = false) const;
401  bool loadVDB(UT_JSONParser &p,
402  bool as_shmem = false);
404 
405  bool saveVisualization(
406  UT_JSONWriter &w,
407  const GA_SaveMap &map) const;
408  bool loadVisualization(
409  UT_JSONParser &p,
410  const GA_LoadMap &map);
411 
413  GA_Offset fastVertexOffset(GA_Size UT_IF_ASSERT_P(index)) const
414  {
415  UT_ASSERT_P(index < 1);
416  return getVertexOffset();
417  }
418 
419  void setVertexPoint(int i, GA_Offset pt)
420  {
421  if (i == 0)
422  setPointOffset(pt);
423  }
424 
427  fpreal calcPositiveDensity() const;
428 
429  SYS_FORCE_INLINE
430  bool hasGrid() const { return myGridAccessor.hasGrid(); }
431 
435  SYS_FORCE_INLINE
436  void makeGridUnique()
437  { myGridAccessor.makeGridUnique(); }
438 
441  bool isGridUnique() const
442  { return myGridAccessor.isGridUnique(); }
443 
446  SYS_FORCE_INLINE
447  const openvdb::GridBase & getConstGrid() const
448  { return myGridAccessor.getConstGrid(*this); }
451  SYS_FORCE_INLINE
452  const openvdb::GridBase & getGrid() const
453  { return getConstGrid(); }
457  SYS_FORCE_INLINE
458  openvdb::GridBase & getGrid()
459  {
460  incrGridUniqueIds();
461  return myGridAccessor.getGrid(*this);
462  }
463 
467  SYS_FORCE_INLINE
468  openvdb::GridBase::ConstPtr getConstGridPtr() const
469  { return myGridAccessor.getConstGridPtr(*this); }
473  SYS_FORCE_INLINE
474  openvdb::GridBase::ConstPtr getGridPtr() const
475  { return getConstGridPtr(); }
480  SYS_FORCE_INLINE
481  openvdb::GridBase::Ptr getGridPtr()
482  {
483  incrGridUniqueIds();
484  return myGridAccessor.getGridPtr(*this);
485  }
486 
489  SYS_FORCE_INLINE
490  void setGrid(const openvdb::GridBase &grid, bool copyPosition=true)
491  {
492  incrGridUniqueIds();
493  myGridAccessor.setGrid(grid, *this, copyPosition);
494  }
495 
498  const openvdb::MetaMap& getConstMetadata() const
499  { return getConstGrid(); }
502  const openvdb::MetaMap& getMetadata() const
503  { return getConstGrid(); }
506  SYS_FORCE_INLINE
507  openvdb::MetaMap& getMetadata()
508  {
509  incrMetadataUniqueId();
510  return myGridAccessor.getGrid(*this);
511  }
512 
515  const char * getGridName() const;
516 
519  UniqueId getUniqueId() const
520  { return static_cast<UniqueId>(myUniqueId.relaxedLoad()); }
521 
526  UniqueId getTreeUniqueId() const
527  { return static_cast<UniqueId>(myTreeUniqueId.relaxedLoad()); }
532  UniqueId getMetadataUniqueId() const
533  { return static_cast<UniqueId>(myMetadataUniqueId.relaxedLoad()); }
538  UniqueId getTransformUniqueId() const
539  { return static_cast<UniqueId>(myTransformUniqueId.relaxedLoad()); }
540 
541 
554  template<typename GridTypeListT, typename OpT>
555  bool apply(OpT& op) const
556  { return hasGrid() ? getConstGrid().apply<GridTypeListT>(op) : false; }
557 
576  template<typename GridTypeListT, typename OpT>
577  bool apply(OpT& op, bool makeUnique = true)
578  {
579  if (hasGrid()) {
580  auto& grid = myGridAccessor.getGrid(*this);
581  if (makeUnique) {
582  auto treePtr = grid.baseTreePtr();
583  if (treePtr.use_count() > 2) { // grid + treePtr = 2
584  // If the grid resolves to one of the listed types and its tree
585  // is shared with other grids, replace the tree with a deep copy.
586  grid.apply<GridTypeListT>([this](openvdb::GridBase& baseGrid) {
587  baseGrid.setTree(baseGrid.constBaseTree().copy());
588  this->incrTreeUniqueId();
589  });
590  }
591  }
592  if (grid.apply<GridTypeListT>(op)) {
593  incrGridUniqueIds();
594  return true;
595  }
596  }
597  return false;
598  }
599 
600 protected:
601  typedef SYS_AtomicCounter AtomicUniqueId; // 64-bit
602 
604  GA_DECLARE_INTRINSICS(override)
605 
606 
607  static bool isIntrinsicMetadata(const char *name);
608 
610  GA_Offset vertexPoint(GA_Size) const
611  { return getPointOffset(); }
612 
615  int64 getBaseMemoryUsage() const;
616 
617  // This is called by the subclasses to count the
618  // memory used by this, excluding sizeof(*this).
619  void countBaseMemory(UT_MemoryCounter &counter) const;
620 
623  static UniqueId nextUniqueId();
624 
625  void incrTreeUniqueId()
626  { myTreeUniqueId.maximum(nextUniqueId()); }
627  void incrMetadataUniqueId()
628  { myMetadataUniqueId.maximum(nextUniqueId()); }
629  void incrTransformUniqueId()
630  { myTransformUniqueId.maximum(nextUniqueId()); }
631  void incrGridUniqueIds()
632  {
633  incrTreeUniqueId();
634  incrMetadataUniqueId();
635  incrTransformUniqueId();
636  }
637 
640  void copyGridFrom(const GEO_PrimVDB&, bool copyPosition=true);
641 
655  class OPENVDB_HOUDINI_API GridAccessor
656  {
657  public:
658  SYS_FORCE_INLINE
659  GridAccessor() : myStorageType(UT_VDB_INVALID)
660  { }
661 
662  SYS_FORCE_INLINE
663  void clear()
664  {
665  myGrid.reset();
666  myStorageType = UT_VDB_INVALID;
667  }
668 
669  SYS_FORCE_INLINE
671  getGrid(const GEO_PrimVDB &prim)
672  { updateGridTranslates(prim); return *myGrid; }
673 
674  SYS_FORCE_INLINE
675  const openvdb::GridBase &
676  getConstGrid(const GEO_PrimVDB &prim) const
677  { updateGridTranslates(prim); return *myGrid; }
678 
679  SYS_FORCE_INLINE
681  getGridPtr(const GEO_PrimVDB &prim)
682  { updateGridTranslates(prim); return myGrid; }
683 
684  SYS_FORCE_INLINE
686  getConstGridPtr(const GEO_PrimVDB &prim) const
687  { updateGridTranslates(prim); return myGrid; }
688 
689  // These accessors will ensure the transform's translate is set into
690  // the vertex position.
691  SYS_FORCE_INLINE
692  void setGrid(const openvdb::GridBase& grid, GEO_PrimVDB& prim, bool copyPosition=true)
693  { setGridAdapter(&grid, prim, copyPosition); }
694  SYS_FORCE_INLINE
695  void setTransform(
696  const openvdb::math::Transform &xform,
697  GEO_PrimVDB &prim)
698  { setTransformAdapter(&xform, prim); }
699 
700  void makeGridUnique();
701  bool isGridUnique() const;
702 
703  SYS_FORCE_INLINE
704  UT_VDBType getStorageType() const { return myStorageType; }
705 
706  SYS_FORCE_INLINE
707  bool hasGrid() const { return myGrid != 0; }
708 
709  private:
710  void updateGridTranslates(const GEO_PrimVDB &prim) const;
711 
712  SYS_FORCE_INLINE
713  void setVertexPosition(
714  const openvdb::math::Transform &xform,
715  GEO_PrimVDB &prim)
716  { setVertexPositionAdapter(&xform, prim); }
717 
718  void setGridAdapter(const void* grid, GEO_PrimVDB&, bool copyPosition);
719  void setTransformAdapter(const void* xform, GEO_PrimVDB&);
720  void setVertexPositionAdapter(const void* xform, GEO_PrimVDB&);
721 
722  private:
723  openvdb::GridBase::Ptr myGrid;
724  UT_VDBType myStorageType;
725  };
726 
727 private:
728  void activateIndexBBoxAdapter(
729  const void* bbox,
730  ActivateOperation,
731  bool setvalue, fpreal value);
732 
733 
734  GridAccessor myGridAccessor;
735 
736  GEO_VolumeOptions myVis;
737 
738  AtomicUniqueId myUniqueId;
739  AtomicUniqueId myTreeUniqueId;
740  AtomicUniqueId myMetadataUniqueId;
741  AtomicUniqueId myTransformUniqueId;
742 
743 }; // class GEO_PrimVDB
744 
745 
746 #ifndef SESI_OPENVDB
747 namespace openvdb_houdini {
748 using ::GEO_VolumeOptions;
749 using ::GEO_PrimVDB;
750 }
751 #endif
752 
753 
755 
756 
757 namespace UT_VDBUtils {
758 
759 // This overload of UT_VDBUtils::callTypedGrid(), for GridBaseType = GEO_PrimVDB,
760 // calls makeGridUnique() on the primitive just before instantiating and
761 // invoking the functor on the primitive's grid. This delays the call
762 // to makeGridUnique() until it is known to be necessary and thus avoids
763 // making deep copies of grids of types that won't be processed.
764 template<typename GridType, typename OpType>
765 inline void
766 callTypedGrid(GEO_PrimVDB& prim, OpType& op)
767 {
768  prim.makeGridUnique();
769  op.template operator()<GridType>(*(UTverify_cast<GridType*>(&prim.getGrid())));
770 }
771 
772 // Overload of callTypedGrid() for GridBaseType = const GEO_PrimVDB
773 template<typename GridType, typename OpType>
774 inline void
775 callTypedGrid(const GEO_PrimVDB& prim, OpType& op)
776 {
777  op.template operator()<GridType>(*(UTverify_cast<const GridType*>(&prim.getConstGrid())));
778 }
779 
780 } // namespace UT_VDBUtils
781 
782 // Define UTvdbProcessTypedGrid*() (see UT_VDBUtils.h) for grids
783 // belonging to primitives, for various subsets of grid types.
784 UT_VDB_DECL_PROCESS_TYPED_GRID(GEO_PrimVDB&)
785 UT_VDB_DECL_PROCESS_TYPED_GRID(const GEO_PrimVDB&)
786 
787 
788 
790 
791 template <typename OpT>
795 inline bool GEOvdbProcessTypedGrid(const GEO_PrimVDB &vdb, OpT &op)
796 {
797  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
798 }
799 
800 template <typename OpT>
801 inline bool GEOvdbProcessTypedGridReal(const GEO_PrimVDB &vdb, OpT &op)
802 {
803  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
804 }
805 
806 template <typename OpT>
807 inline bool GEOvdbProcessTypedGridScalar(const GEO_PrimVDB &vdb, OpT &op)
808 {
809  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
810 }
811 
812 template <typename OpT>
813 inline bool GEOvdbProcessTypedGridTopology(const GEO_PrimVDB &vdb, OpT &op)
814 {
815  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
816 }
817 
818 template <typename OpT>
819 inline bool GEOvdbProcessTypedGridVec3(const GEO_PrimVDB &vdb, OpT &op)
820 {
821  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
822 }
823 
824 template <typename OpT>
825 inline bool GEOvdbProcessTypedGridPoint(const GEO_PrimVDB &vdb, OpT &op)
826 {
827  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
828 }
830 
838 template <typename OpT>
839 inline bool GEOvdbProcessTypedGrid(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
840 {
841  if (makeUnique) return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb, op);
842  return UTvdbProcessTypedGrid(vdb.getStorageType(), vdb.getGrid(), op);
843 }
844 
845 template <typename OpT>
846 inline bool GEOvdbProcessTypedGridReal(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
847 {
848  if (makeUnique) return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb, op);
849  return UTvdbProcessTypedGridReal(vdb.getStorageType(), vdb.getGrid(), op);
850 }
851 
852 template <typename OpT>
853 inline bool GEOvdbProcessTypedGridScalar(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
854 {
855  if (makeUnique) return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb, op);
856  return UTvdbProcessTypedGridScalar(vdb.getStorageType(), vdb.getGrid(), op);
857 }
858 
859 template <typename OpT>
860 inline bool GEOvdbProcessTypedGridTopology(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
861 {
862  if (makeUnique) return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb, op);
863  return UTvdbProcessTypedGridTopology(vdb.getStorageType(), vdb.getGrid(), op);
864 }
865 
866 template <typename OpT>
867 inline bool GEOvdbProcessTypedGridVec3(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
868 {
869  if (makeUnique) return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb, op);
870  return UTvdbProcessTypedGridVec3(vdb.getStorageType(), vdb.getGrid(), op);
871 }
872 
873 template <typename OpT>
874 inline bool GEOvdbProcessTypedGridPoint(GEO_PrimVDB &vdb, OpT &op, bool makeUnique = true)
875 {
876  if (makeUnique) return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb, op);
877  return UTvdbProcessTypedGridPoint(vdb.getStorageType(), vdb.getGrid(), op);
878 }
880 
881 #endif // __HDK_GEO_PrimVDB__
882 
883 #endif // SESI_OPENVDB || SESI_OPENVDB_PRIM
openvdb_houdini
Definition: AttributeTransferUtil.h:33
UT_VDBUtils.h
openvdb::v8_0::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:1247
Platform.h
openvdb::v8_0::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:20
openvdb::v8_0::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::v8_0::GridBase
Abstract base class for typed grids.
Definition: Grid.h:78
openvdb::v8_0::GridBase::ConstPtr
SharedPtr< const GridBase > ConstPtr
Definition: Grid.h:81
openvdb::v8_0::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:249
OPENVDB_HOUDINI_API
#define OPENVDB_HOUDINI_API
Definition: Platform.h:216
openvdb.h
openvdb::v8_0::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:80
openvdb::v8_0::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:1816