OpenVDB  7.1.0
Grid.h
Go to the documentation of this file.
1 // Copyright Contributors to the OpenVDB Project
2 // SPDX-License-Identifier: MPL-2.0
3 
4 #ifndef OPENVDB_GRID_HAS_BEEN_INCLUDED
5 #define OPENVDB_GRID_HAS_BEEN_INCLUDED
6 
7 #include "Exceptions.h"
8 #include "MetaMap.h"
9 #include "Types.h"
10 #include "io/io.h"
11 #include "math/Transform.h"
12 #include "tree/Tree.h"
13 #include "util/logging.h"
14 #include "util/Name.h"
15 #include <cassert>
16 #include <iostream>
17 #include <set>
18 #include <type_traits>
19 #include <vector>
20 
21 
22 namespace openvdb {
24 namespace OPENVDB_VERSION_NAME {
25 
27 
28 template<typename> class Grid; // forward declaration
29 
30 
35 template<typename GridType>
36 inline typename GridType::Ptr createGrid(const typename GridType::ValueType& background);
37 
38 
42 template<typename GridType>
43 inline typename GridType::Ptr createGrid();
44 
45 
50 template<typename TreePtrType>
52 
53 
68 template<typename GridType>
69 typename GridType::Ptr createLevelSet(
70  Real voxelSize = 1.0, Real halfWidth = LEVEL_SET_HALF_WIDTH);
71 
72 
74 
75 
78 {
79 public:
82 
83  using GridFactory = Ptr (*)();
84 
85 
86  ~GridBase() override {}
87 
88 
91 
94  virtual GridBase::Ptr copyGrid() = 0;
97  virtual GridBase::ConstPtr copyGrid() const = 0;
100  virtual GridBase::Ptr copyGridWithNewTree() const = 0;
101 
102 #if OPENVDB_ABI_VERSION_NUMBER >= 7
103  virtual GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap& meta) const = 0;
115  math::Transform::Ptr xform) const = 0;
116 #endif
117 
119  virtual GridBase::Ptr deepCopyGrid() const = 0;
120 
122 
123 
126 
128  static Ptr createGrid(const Name& type);
129 
131  static bool isRegistered(const Name &type);
132 
134  static void clearRegistry();
135 
137 
140 
142  virtual Name type() const = 0;
144  virtual Name valueType() const = 0;
145 
147  template<typename GridType>
148  bool isType() const { return (this->type() == GridType::gridType()); }
149 
151 
153  template<typename GridType>
156  static typename GridType::Ptr grid(const GridBase::Ptr&);
157  template<typename GridType>
158  static typename GridType::ConstPtr grid(const GridBase::ConstPtr&);
159  template<typename GridType>
160  static typename GridType::ConstPtr constGrid(const GridBase::Ptr&);
161  template<typename GridType>
162  static typename GridType::ConstPtr constGrid(const GridBase::ConstPtr&);
164 
167 
170  TreeBase::Ptr baseTreePtr();
173  TreeBase::ConstPtr baseTreePtr() const { return this->constBaseTreePtr(); }
177 
182  TreeBase& baseTree() { return const_cast<TreeBase&>(this->constBaseTree()); }
187  const TreeBase& baseTree() const { return this->constBaseTree(); }
192  const TreeBase& constBaseTree() const { return *(this->constBaseTreePtr()); }
193 
200  virtual void setTree(TreeBase::Ptr) = 0;
201 
203  virtual void newTree() = 0;
204 
206 
208  virtual bool empty() const = 0;
210  virtual void clear() = 0;
211 
212 
215 
221  virtual void pruneGrid(float tolerance = 0.0) = 0;
222 
227  void clipGrid(const BBoxd&);
228 
233  virtual void clip(const CoordBBox&) = 0;
234 
236 
261  template<typename GridTypeListT, typename OpT> inline bool apply(OpT&) const;
262  template<typename GridTypeListT, typename OpT> inline bool apply(OpT&);
263  template<typename GridTypeListT, typename OpT> inline bool apply(const OpT&) const;
264  template<typename GridTypeListT, typename OpT> inline bool apply(const OpT&);
266 
269 
271  std::string getName() const;
273  void setName(const std::string&);
274 
276  std::string getCreator() const;
278  void setCreator(const std::string&);
279 
282  bool saveFloatAsHalf() const;
283  void setSaveFloatAsHalf(bool);
284 
295 
297 
299  static std::string gridClassToString(GridClass);
301  static std::string gridClassToMenuName(GridClass);
306  static GridClass stringToGridClass(const std::string&);
307 
310 
321 
323 
325  static std::string vecTypeToString(VecType);
328  static std::string vecTypeExamples(VecType);
331  static std::string vecTypeDescription(VecType);
332  static VecType stringToVecType(const std::string&);
333 
336 
340  bool isInWorldSpace() const;
342  void setIsInWorldSpace(bool);
343 
345 
346  // Standard metadata field names
347  // (These fields should normally not be accessed directly, but rather
348  // via the accessor methods above, when available.)
349  // Note: Visual C++ requires these declarations to be separate statements.
350  static const char* const META_GRID_CLASS;
351  static const char* const META_GRID_CREATOR;
352  static const char* const META_GRID_NAME;
353  static const char* const META_SAVE_HALF_FLOAT;
354  static const char* const META_IS_LOCAL_SPACE;
355  static const char* const META_VECTOR_TYPE;
356  static const char* const META_FILE_BBOX_MIN;
357  static const char* const META_FILE_BBOX_MAX;
358  static const char* const META_FILE_COMPRESSION;
359  static const char* const META_FILE_MEM_BYTES;
360  static const char* const META_FILE_VOXEL_COUNT;
361  static const char* const META_FILE_DELAYED_LOAD;
362 
363 
366 
368  virtual Index64 activeVoxelCount() const = 0;
369 
373 
375  virtual Coord evalActiveVoxelDim() const = 0;
376 
378  virtual Index64 memUsage() const = 0;
379 
391 
393 
394 
397 
399  math::Transform::Ptr transformPtr() { return mTransform; }
402  math::Transform::ConstPtr transformPtr() const { return mTransform; }
403  math::Transform::ConstPtr constTransformPtr() const { return mTransform; }
405 
406  math::Transform& transform() { return *mTransform; }
411  const math::Transform& transform() const { return *mTransform; }
412  const math::Transform& constTransform() const { return *mTransform; }
414 
416 
419 
426  void setTransform(math::Transform::Ptr);
427 
429  Vec3d voxelSize() const { return transform().voxelSize(); }
432  Vec3d voxelSize(const Vec3d& xyz) const { return transform().voxelSize(xyz); }
434  bool hasUniformVoxels() const { return mTransform->hasUniformScale(); }
436  Vec3d indexToWorld(const Vec3d& xyz) const { return transform().indexToWorld(xyz); }
438  Vec3d indexToWorld(const Coord& ijk) const { return transform().indexToWorld(ijk); }
440  Vec3d worldToIndex(const Vec3d& xyz) const { return transform().worldToIndex(xyz); }
441 
443 
444 
447 
450  virtual void readTopology(std::istream&) = 0;
453  virtual void writeTopology(std::ostream&) const = 0;
454 
456  virtual void readBuffers(std::istream&) = 0;
458  virtual void readBuffers(std::istream&, const CoordBBox&) = 0;
464  virtual void readNonresidentBuffers() const = 0;
466  virtual void writeBuffers(std::ostream&) const = 0;
467 
469  void readTransform(std::istream& is) { transform().read(is); }
471  void writeTransform(std::ostream& os) const { transform().write(os); }
472 
474  virtual void print(std::ostream& = std::cout, int verboseLevel = 1) const = 0;
475 
477 
478 
479 protected:
481  GridBase(): mTransform(math::Transform::createLinearTransform()) {}
482 
483 #if OPENVDB_ABI_VERSION_NUMBER >= 7
484  GridBase(const MetaMap& meta, math::Transform::Ptr xform);
487 #endif
488 
490  GridBase(const GridBase& other): MetaMap(other), mTransform(other.mTransform->copy()) {}
491 
493  GridBase(GridBase& other, ShallowCopy): MetaMap(other), mTransform(other.mTransform) {}
494 
496  static void registerGrid(const Name& type, GridFactory);
498  static void unregisterGrid(const Name& type);
499 
500 
501 private:
502  math::Transform::Ptr mTransform;
503 }; // class GridBase
504 
505 
507 
508 
509 using GridPtrVec = std::vector<GridBase::Ptr>;
510 using GridPtrVecIter = GridPtrVec::iterator;
511 using GridPtrVecCIter = GridPtrVec::const_iterator;
513 
514 using GridCPtrVec = std::vector<GridBase::ConstPtr>;
515 using GridCPtrVecIter = GridCPtrVec::iterator;
516 using GridCPtrVecCIter = GridCPtrVec::const_iterator;
518 
519 using GridPtrSet = std::set<GridBase::Ptr>;
520 using GridPtrSetIter = GridPtrSet::iterator;
521 using GridPtrSetCIter = GridPtrSet::const_iterator;
523 
524 using GridCPtrSet = std::set<GridBase::ConstPtr>;
525 using GridCPtrSetIter = GridCPtrSet::iterator;
526 using GridCPtrSetCIter = GridCPtrSet::const_iterator;
528 
529 
532 {
533  GridNamePred(const Name& _name): name(_name) {}
534  bool operator()(const GridBase::ConstPtr& g) const { return g && g->getName() == name; }
536 };
537 
539 template<typename GridPtrContainerT>
540 inline typename GridPtrContainerT::value_type
541 findGridByName(const GridPtrContainerT& container, const Name& name)
542 {
543  using GridPtrT = typename GridPtrContainerT::value_type;
544  typename GridPtrContainerT::const_iterator it =
545  std::find_if(container.begin(), container.end(), GridNamePred(name));
546  return (it == container.end() ? GridPtrT() : *it);
547 }
548 
550 template<typename KeyT, typename GridPtrT>
551 inline GridPtrT
552 findGridByName(const std::map<KeyT, GridPtrT>& container, const Name& name)
553 {
554  using GridPtrMapT = std::map<KeyT, GridPtrT>;
555  for (typename GridPtrMapT::const_iterator it = container.begin(), end = container.end();
556  it != end; ++it)
557  {
558  const GridPtrT& grid = it->second;
559  if (grid && grid->getName() == name) return grid;
560  }
561  return GridPtrT();
562 }
564 
565 
567 
568 
570 template<typename _TreeType>
571 class Grid: public GridBase
572 {
573 public:
576 
577  using TreeType = _TreeType;
578  using TreePtrType = typename _TreeType::Ptr;
579  using ConstTreePtrType = typename _TreeType::ConstPtr;
580  using ValueType = typename _TreeType::ValueType;
581  using BuildType = typename _TreeType::BuildType;
582 
583  using ValueOnIter = typename _TreeType::ValueOnIter;
584  using ValueOnCIter = typename _TreeType::ValueOnCIter;
585  using ValueOffIter = typename _TreeType::ValueOffIter;
586  using ValueOffCIter = typename _TreeType::ValueOffCIter;
587  using ValueAllIter = typename _TreeType::ValueAllIter;
588  using ValueAllCIter = typename _TreeType::ValueAllCIter;
589 
594 
601  template<typename OtherValueType>
602  struct ValueConverter {
604  };
605 
607  static Ptr create(const ValueType& background);
609  static Ptr create();
612  static Ptr create(TreePtrType);
615  static Ptr create(const GridBase& other);
616 
617 
619  Grid();
621  explicit Grid(const ValueType& background);
625  explicit Grid(TreePtrType);
627  Grid(const Grid&);
633  template<typename OtherTreeType>
634  explicit Grid(const Grid<OtherTreeType>&);
636  Grid(Grid&, ShallowCopy);
639  explicit Grid(const GridBase&);
640 
641  ~Grid() override {}
642 
644  Grid& operator=(const Grid&) = delete;
645 
648 
651  Ptr copy();
654  ConstPtr copy() const;
657  Ptr copyWithNewTree() const;
658 
661  GridBase::Ptr copyGrid() override;
664  GridBase::ConstPtr copyGrid() const override;
667  GridBase::Ptr copyGridWithNewTree() const override;
669 
672 
673 #if OPENVDB_ABI_VERSION_NUMBER >= 7
674  ConstPtr copyReplacingMetadata(const MetaMap& meta) const;
681  ConstPtr copyReplacingTransform(math::Transform::Ptr xform) const;
685  ConstPtr copyReplacingMetadataAndTransform(const MetaMap& meta,
686  math::Transform::Ptr xform) const;
687 
690  GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap& meta) const override;
695  GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const override;
699  GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap& meta,
700  math::Transform::Ptr xform) const override;
701 #endif
702 
704  Ptr deepCopy() const { return Ptr(new Grid(*this)); }
706  GridBase::Ptr deepCopyGrid() const override { return this->deepCopy(); }
707 
709 
710 
712  Name type() const override { return this->gridType(); }
714  static Name gridType() { return TreeType::treeType(); }
715 
717  Name valueType() const override { return tree().valueType(); }
718 
719 
722 
725  const ValueType& background() const { return mTree->background(); }
726 
728  bool empty() const override { return tree().empty(); }
730  void clear() override { tree().clear(); }
731 
735  Accessor getAccessor() { return Accessor(tree()); }
745  ConstAccessor getAccessor() const { return ConstAccessor(tree()); }
747  ConstAccessor getConstAccessor() const { return ConstAccessor(tree()); }
756 
758  ValueOnIter beginValueOn() { return tree().beginValueOn(); }
760  ValueOnCIter beginValueOn() const { return tree().cbeginValueOn(); }
762  ValueOnCIter cbeginValueOn() const { return tree().cbeginValueOn(); }
764  ValueOffIter beginValueOff() { return tree().beginValueOff(); }
766  ValueOffCIter beginValueOff() const { return tree().cbeginValueOff(); }
768  ValueOffCIter cbeginValueOff() const { return tree().cbeginValueOff(); }
770  ValueAllIter beginValueAll() { return tree().beginValueAll(); }
772  ValueAllCIter beginValueAll() const { return tree().cbeginValueAll(); }
774  ValueAllCIter cbeginValueAll() const { return tree().cbeginValueAll(); }
775 
777 
780 
789  void sparseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
798  void fill(const CoordBBox& bbox, const ValueType& value, bool active = true);
799 
806  void denseFill(const CoordBBox& bbox, const ValueType& value, bool active = true);
807 
809  void pruneGrid(float tolerance = 0.0) override;
810 
815  void clip(const CoordBBox&) override;
816 
822  void merge(Grid& other, MergePolicy policy = MERGE_ACTIVE_STATES);
823 
837  template<typename OtherTreeType>
838  void topologyUnion(const Grid<OtherTreeType>& other);
839 
852  template<typename OtherTreeType>
853  void topologyIntersection(const Grid<OtherTreeType>& other);
854 
865  template<typename OtherTreeType>
866  void topologyDifference(const Grid<OtherTreeType>& other);
867 
869 
872 
874  Index64 activeVoxelCount() const override { return tree().activeVoxelCount(); }
876  CoordBBox evalActiveVoxelBoundingBox() const override;
878  Coord evalActiveVoxelDim() const override;
880  void evalMinMax(ValueType& minVal, ValueType& maxVal) const;
881 
884  Index64 memUsage() const override { return tree().memUsage(); }
885 
887 
888 
891 
893  TreePtrType treePtr() { return mTree; }
896  ConstTreePtrType treePtr() const { return mTree; }
897  ConstTreePtrType constTreePtr() const { return mTree; }
898  TreeBase::ConstPtr constBaseTreePtr() const override { return mTree; }
900  bool isTreeUnique() const;
904  TreeType& tree() { return *mTree; }
909  const TreeType& tree() const { return *mTree; }
910  const TreeType& constTree() const { return *mTree; }
912 
914 
917 
923  void setTree(TreeBase::Ptr) override;
924 
927  void newTree() override;
928 
930 
931 
934 
937  void readTopology(std::istream&) override;
940  void writeTopology(std::ostream&) const override;
941 
943  void readBuffers(std::istream&) override;
945  void readBuffers(std::istream&, const CoordBBox&) override;
951  void readNonresidentBuffers() const override;
953  void writeBuffers(std::ostream&) const override;
954 
956  void print(std::ostream& = std::cout, int verboseLevel = 1) const override;
957 
959 
963  static inline bool hasMultiPassIO();
964 
965 
968 
972  static void registerGrid()
973  {
974  GridBase::registerGrid(Grid::gridType(), Grid::factory);
976  OPENVDB_LOG_WARN("delayed loading of grids of type " << Grid::gridType()
977  << " might not be threadsafe on this platform");
978  }
979  }
982 
984 
985 
986 private:
987 #if OPENVDB_ABI_VERSION_NUMBER >= 7
988  Grid(TreePtrType tree, const MetaMap& meta, math::Transform::Ptr xform);
990 #endif
991 
993  static GridBase::Ptr factory() { return Grid::create(); }
994 
995  TreePtrType mTree;
996 }; // class Grid
997 
998 
1000 
1001 
1009 template<typename GridType>
1010 inline typename GridType::Ptr
1012 {
1013  return GridBase::grid<GridType>(grid);
1014 }
1015 
1016 
1025 template<typename GridType>
1026 inline typename GridType::ConstPtr
1028 {
1029  return GridBase::constGrid<GridType>(grid);
1030 }
1031 
1032 
1034 
1035 
1042 template<typename GridType>
1043 inline typename GridType::Ptr
1045 {
1046  if (!grid || !grid->isType<GridType>()) return typename GridType::Ptr();
1047  return gridPtrCast<GridType>(grid->deepCopyGrid());
1048 }
1049 
1050 
1051 template<typename GridType>
1052 inline typename GridType::Ptr
1054 {
1055  if (!grid.isType<GridType>()) return typename GridType::Ptr();
1056  return gridPtrCast<GridType>(grid.deepCopyGrid());
1057 }
1059 
1060 
1062 
1063 
1065 template<typename _TreeType>
1069 {
1070  using TreeType = _TreeType;
1071  using NonConstTreeType = typename std::remove_const<TreeType>::type;
1072  using TreePtrType = typename TreeType::Ptr;
1073  using ConstTreePtrType = typename TreeType::ConstPtr;
1074  using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1077  using GridPtrType = typename GridType::Ptr;
1080  using ValueType = typename TreeType::ValueType;
1084 
1085  static TreeType& tree(TreeType& t) { return t; }
1086  static TreeType& tree(GridType& g) { return g.tree(); }
1087  static const TreeType& tree(const TreeType& t) { return t; }
1088  static const TreeType& tree(const GridType& g) { return g.tree(); }
1089  static const TreeType& constTree(TreeType& t) { return t; }
1090  static const TreeType& constTree(GridType& g) { return g.constTree(); }
1091  static const TreeType& constTree(const TreeType& t) { return t; }
1092  static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1093 };
1094 
1095 
1097 template<typename _TreeType>
1098 struct TreeAdapter<Grid<_TreeType> >
1099 {
1100  using TreeType = _TreeType;
1101  using NonConstTreeType = typename std::remove_const<TreeType>::type;
1102  using TreePtrType = typename TreeType::Ptr;
1103  using ConstTreePtrType = typename TreeType::ConstPtr;
1104  using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1107  using GridPtrType = typename GridType::Ptr;
1110  using ValueType = typename TreeType::ValueType;
1114 
1115  static TreeType& tree(TreeType& t) { return t; }
1116  static TreeType& tree(GridType& g) { return g.tree(); }
1117  static const TreeType& tree(const TreeType& t) { return t; }
1118  static const TreeType& tree(const GridType& g) { return g.tree(); }
1119  static const TreeType& constTree(TreeType& t) { return t; }
1120  static const TreeType& constTree(GridType& g) { return g.constTree(); }
1121  static const TreeType& constTree(const TreeType& t) { return t; }
1122  static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1123 };
1124 
1126 template<typename _TreeType>
1127 struct TreeAdapter<tree::ValueAccessor<_TreeType> >
1128 {
1129  using TreeType = _TreeType;
1130  using NonConstTreeType = typename std::remove_const<TreeType>::type;
1131  using TreePtrType = typename TreeType::Ptr;
1132  using ConstTreePtrType = typename TreeType::ConstPtr;
1133  using NonConstTreePtrType = typename NonConstTreeType::Ptr;
1136  using GridPtrType = typename GridType::Ptr;
1139  using ValueType = typename TreeType::ValueType;
1143 
1144  static TreeType& tree(TreeType& t) { return t; }
1145  static TreeType& tree(GridType& g) { return g.tree(); }
1146  static TreeType& tree(AccessorType& a) { return a.tree(); }
1147  static const TreeType& tree(const TreeType& t) { return t; }
1148  static const TreeType& tree(const GridType& g) { return g.tree(); }
1149  static const TreeType& tree(const AccessorType& a) { return a.tree(); }
1150  static const TreeType& constTree(TreeType& t) { return t; }
1151  static const TreeType& constTree(GridType& g) { return g.constTree(); }
1152  static const TreeType& constTree(const TreeType& t) { return t; }
1153  static const TreeType& constTree(const GridType& g) { return g.constTree(); }
1154 };
1155 
1157 
1158 
1160 
1161 
1167 template<typename LeafNodeType>
1169  static const bool value = std::is_base_of<io::MultiPass, LeafNodeType>::value;
1170 };
1171 
1172 // Partial specialization for Tree types
1173 template<typename RootNodeType>
1174 struct HasMultiPassIO<tree::Tree<RootNodeType>> {
1175  // A tree is multi-pass if its (root node's) leaf node type is multi-pass.
1177 };
1178 
1179 // Partial specialization for Grid types
1180 template<typename TreeType>
1181 struct HasMultiPassIO<Grid<TreeType>> {
1182  // A grid is multi-pass if its tree's leaf node type is multi-pass.
1184 };
1185 
1186 
1188 
1189 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1191  : MetaMap(meta)
1192  , mTransform(xform)
1193 {
1194  if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1195 }
1196 #endif
1197 
1198 template<typename GridType>
1199 inline typename GridType::Ptr
1201 {
1202  // The string comparison on type names is slower than a dynamic pointer cast, but
1203  // it is safer when pointers cross DSO boundaries, as they do in many Houdini nodes.
1204  if (grid && grid->type() == GridType::gridType()) {
1205  return StaticPtrCast<GridType>(grid);
1206  }
1207  return typename GridType::Ptr();
1208 }
1209 
1210 
1211 template<typename GridType>
1212 inline typename GridType::ConstPtr
1214 {
1215  return ConstPtrCast<const GridType>(
1216  GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1217 }
1218 
1219 
1220 template<typename GridType>
1221 inline typename GridType::ConstPtr
1223 {
1224  return ConstPtrCast<const GridType>(GridBase::grid<GridType>(grid));
1225 }
1226 
1227 
1228 template<typename GridType>
1229 inline typename GridType::ConstPtr
1231 {
1232  return ConstPtrCast<const GridType>(
1233  GridBase::grid<GridType>(ConstPtrCast<GridBase>(grid)));
1234 }
1235 
1236 
1237 inline TreeBase::Ptr
1239 {
1240  return ConstPtrCast<TreeBase>(this->constBaseTreePtr());
1241 }
1242 
1243 
1244 inline void
1246 {
1247  if (!xform) OPENVDB_THROW(ValueError, "Transform pointer is null");
1248  mTransform = xform;
1249 }
1250 
1251 
1253 
1254 
1255 template<typename TreeT>
1256 inline Grid<TreeT>::Grid(): mTree(new TreeType)
1257 {
1258 }
1259 
1260 
1261 template<typename TreeT>
1262 inline Grid<TreeT>::Grid(const ValueType &background): mTree(new TreeType(background))
1263 {
1264 }
1265 
1266 
1267 template<typename TreeT>
1268 inline Grid<TreeT>::Grid(TreePtrType tree): mTree(tree)
1269 {
1270  if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1271 }
1272 
1273 
1274 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1275 template<typename TreeT>
1276 inline Grid<TreeT>::Grid(TreePtrType tree, const MetaMap& meta, math::Transform::Ptr xform):
1277  GridBase(meta, xform),
1278  mTree(tree)
1279 {
1280  if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1281 }
1282 #endif
1283 
1284 
1285 template<typename TreeT>
1286 inline Grid<TreeT>::Grid(const Grid& other):
1287  GridBase(other),
1288  mTree(StaticPtrCast<TreeType>(other.mTree->copy()))
1289 {
1290 }
1291 
1292 
1293 template<typename TreeT>
1294 template<typename OtherTreeType>
1296  GridBase(other),
1297  mTree(new TreeType(other.constTree()))
1298 {
1299 }
1300 
1301 
1302 template<typename TreeT>
1304  GridBase(other),
1305  mTree(other.mTree)
1306 {
1307 }
1308 
1309 
1310 template<typename TreeT>
1311 inline Grid<TreeT>::Grid(const GridBase& other):
1312  GridBase(other),
1313  mTree(new TreeType)
1314 {
1315 }
1316 
1317 
1318 //static
1319 template<typename TreeT>
1320 inline typename Grid<TreeT>::Ptr
1322 {
1323  return Grid::create(zeroVal<ValueType>());
1324 }
1325 
1326 
1327 //static
1328 template<typename TreeT>
1329 inline typename Grid<TreeT>::Ptr
1330 Grid<TreeT>::create(const ValueType& background)
1331 {
1332  return Ptr(new Grid(background));
1333 }
1334 
1335 
1336 //static
1337 template<typename TreeT>
1338 inline typename Grid<TreeT>::Ptr
1340 {
1341  return Ptr(new Grid(tree));
1342 }
1343 
1344 
1345 //static
1346 template<typename TreeT>
1347 inline typename Grid<TreeT>::Ptr
1349 {
1350  return Ptr(new Grid(other));
1351 }
1352 
1353 
1355 
1356 
1357 template<typename TreeT>
1358 inline typename Grid<TreeT>::ConstPtr
1360 {
1361  return ConstPtr{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1362 }
1363 
1364 
1365 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1366 template<typename TreeT>
1367 inline typename Grid<TreeT>::ConstPtr
1369 {
1370  math::Transform::Ptr transformPtr = ConstPtrCast<math::Transform>(
1371  this->constTransformPtr());
1372  TreePtrType treePtr = ConstPtrCast<TreeT>(this->constTreePtr());
1373  return ConstPtr{new Grid<TreeT>{treePtr, meta, transformPtr}};
1374 }
1375 
1376 template<typename TreeT>
1377 inline typename Grid<TreeT>::ConstPtr
1379 {
1380  return this->copyReplacingMetadataAndTransform(*this, xform);
1381 }
1382 
1383 template<typename TreeT>
1384 inline typename Grid<TreeT>::ConstPtr
1386  math::Transform::Ptr xform) const
1387 {
1388  TreePtrType treePtr = ConstPtrCast<TreeT>(this->constTreePtr());
1389  return ConstPtr{new Grid<TreeT>{treePtr, meta, xform}};
1390 }
1391 #endif
1392 
1393 
1394 template<typename TreeT>
1395 inline typename Grid<TreeT>::Ptr
1397 {
1398  return Ptr{new Grid{*this, ShallowCopy{}}};
1399 }
1400 
1401 
1402 template<typename TreeT>
1403 inline typename Grid<TreeT>::Ptr
1405 {
1406  Ptr result{new Grid{*const_cast<Grid*>(this), ShallowCopy{}}};
1407  result->newTree();
1408  return result;
1409 }
1410 
1411 
1412 template<typename TreeT>
1413 inline GridBase::Ptr
1415 {
1416  return this->copy();
1417 }
1418 
1419 template<typename TreeT>
1420 inline GridBase::ConstPtr
1422 {
1423  return this->copy();
1424 }
1425 
1426 #if OPENVDB_ABI_VERSION_NUMBER >= 7
1427 template<typename TreeT>
1428 inline GridBase::ConstPtr
1430 {
1431  return this->copyReplacingMetadata(meta);
1432 }
1433 
1434 template<typename TreeT>
1435 inline GridBase::ConstPtr
1437 {
1438  return this->copyReplacingTransform(xform);
1439 }
1440 
1441 template<typename TreeT>
1442 inline GridBase::ConstPtr
1444  math::Transform::Ptr xform) const
1445 {
1446  return this->copyReplacingMetadataAndTransform(meta, xform);
1447 }
1448 #endif
1449 
1450 template<typename TreeT>
1451 inline GridBase::Ptr
1453 {
1454  return this->copyWithNewTree();
1455 }
1456 
1457 
1459 
1460 
1461 template<typename TreeT>
1462 inline bool
1464 {
1465  return mTree.use_count() == 1;
1466 }
1467 
1468 
1469 template<typename TreeT>
1470 inline void
1472 {
1473  if (!tree) OPENVDB_THROW(ValueError, "Tree pointer is null");
1474  if (tree->type() != TreeType::treeType()) {
1475  OPENVDB_THROW(TypeError, "Cannot assign a tree of type "
1476  + tree->type() + " to a grid of type " + this->type());
1477  }
1478  mTree = StaticPtrCast<TreeType>(tree);
1479 }
1480 
1481 
1482 template<typename TreeT>
1483 inline void
1485 {
1486  mTree.reset(new TreeType(this->background()));
1487 }
1488 
1489 
1491 
1492 
1493 template<typename TreeT>
1494 inline void
1495 Grid<TreeT>::sparseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1496 {
1497  tree().sparseFill(bbox, value, active);
1498 }
1499 
1500 
1501 template<typename TreeT>
1502 inline void
1503 Grid<TreeT>::fill(const CoordBBox& bbox, const ValueType& value, bool active)
1504 {
1505  this->sparseFill(bbox, value, active);
1506 }
1507 
1508 template<typename TreeT>
1509 inline void
1510 Grid<TreeT>::denseFill(const CoordBBox& bbox, const ValueType& value, bool active)
1511 {
1512  tree().denseFill(bbox, value, active);
1513 }
1514 
1515 template<typename TreeT>
1516 inline void
1517 Grid<TreeT>::pruneGrid(float tolerance)
1518 {
1520  const auto value = zeroVal<ValueType>() + tolerance;
1522  this->tree().prune(static_cast<ValueType>(value));
1523 }
1524 
1525 template<typename TreeT>
1526 inline void
1528 {
1529  tree().clip(bbox);
1530 }
1531 
1532 template<typename TreeT>
1533 inline void
1535 {
1536  tree().merge(other.tree(), policy);
1537 }
1538 
1539 
1540 template<typename TreeT>
1541 template<typename OtherTreeType>
1542 inline void
1544 {
1545  tree().topologyUnion(other.tree());
1546 }
1547 
1548 
1549 template<typename TreeT>
1550 template<typename OtherTreeType>
1551 inline void
1553 {
1554  tree().topologyIntersection(other.tree());
1555 }
1556 
1557 
1558 template<typename TreeT>
1559 template<typename OtherTreeType>
1560 inline void
1562 {
1563  tree().topologyDifference(other.tree());
1564 }
1565 
1566 
1568 
1569 
1570 template<typename TreeT>
1571 inline void
1573 {
1574  tree().evalMinMax(minVal, maxVal);
1575 }
1576 
1577 
1578 template<typename TreeT>
1579 inline CoordBBox
1581 {
1582  CoordBBox bbox;
1583  tree().evalActiveVoxelBoundingBox(bbox);
1584  return bbox;
1585 }
1586 
1587 
1588 template<typename TreeT>
1589 inline Coord
1591 {
1592  Coord dim;
1593  const bool nonempty = tree().evalActiveVoxelDim(dim);
1594  return (nonempty ? dim : Coord());
1595 }
1596 
1597 
1599 
1600 
1603 
1604 template<typename TreeT>
1605 inline void
1606 Grid<TreeT>::readTopology(std::istream& is)
1607 {
1608  tree().readTopology(is, saveFloatAsHalf());
1609 }
1610 
1611 
1612 template<typename TreeT>
1613 inline void
1614 Grid<TreeT>::writeTopology(std::ostream& os) const
1615 {
1616  tree().writeTopology(os, saveFloatAsHalf());
1617 }
1618 
1619 
1620 template<typename TreeT>
1621 inline void
1622 Grid<TreeT>::readBuffers(std::istream& is)
1623 {
1624  if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1625  tree().readBuffers(is, saveFloatAsHalf());
1626  } else {
1627  uint16_t numPasses = 1;
1628  is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1630  assert(bool(meta));
1631  for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1632  uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1633  meta->setPass(pass);
1634  tree().readBuffers(is, saveFloatAsHalf());
1635  }
1636  }
1637 }
1638 
1639 
1642 template<typename TreeT>
1643 inline void
1644 Grid<TreeT>::readBuffers(std::istream& is, const CoordBBox& bbox)
1645 {
1646  if (!hasMultiPassIO() || (io::getFormatVersion(is) < OPENVDB_FILE_VERSION_MULTIPASS_IO)) {
1647  tree().readBuffers(is, bbox, saveFloatAsHalf());
1648  } else {
1649  uint16_t numPasses = 1;
1650  is.read(reinterpret_cast<char*>(&numPasses), sizeof(uint16_t));
1652  assert(bool(meta));
1653  for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1654  uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1655  meta->setPass(pass);
1656  tree().readBuffers(is, saveFloatAsHalf());
1657  }
1658  // Cannot clip inside readBuffers() when using multiple passes,
1659  // so instead clip afterwards.
1660  tree().clip(bbox);
1661  }
1662 }
1663 
1664 
1665 template<typename TreeT>
1666 inline void
1668 {
1669  tree().readNonresidentBuffers();
1670 }
1671 
1672 
1673 template<typename TreeT>
1674 inline void
1675 Grid<TreeT>::writeBuffers(std::ostream& os) const
1676 {
1677  if (!hasMultiPassIO()) {
1678  tree().writeBuffers(os, saveFloatAsHalf());
1679  } else {
1680  // Determine how many leaf buffer passes are required for this grid
1682  assert(bool(meta));
1683  uint16_t numPasses = 1;
1684  meta->setCountingPasses(true);
1685  meta->setPass(0);
1686  tree().writeBuffers(os, saveFloatAsHalf());
1687  numPasses = static_cast<uint16_t>(meta->pass());
1688  os.write(reinterpret_cast<const char*>(&numPasses), sizeof(uint16_t));
1689  meta->setCountingPasses(false);
1690 
1691  // Save out the data blocks of the grid.
1692  for (uint16_t passIndex = 0; passIndex < numPasses; ++passIndex) {
1693  uint32_t pass = (uint32_t(numPasses) << 16) | uint32_t(passIndex);
1694  meta->setPass(pass);
1695  tree().writeBuffers(os, saveFloatAsHalf());
1696  }
1697  }
1698 }
1699 
1700 
1701 //static
1702 template<typename TreeT>
1703 inline bool
1705 {
1707 }
1708 
1709 
1710 template<typename TreeT>
1711 inline void
1712 Grid<TreeT>::print(std::ostream& os, int verboseLevel) const
1713 {
1714  tree().print(os, verboseLevel);
1715 
1716  if (metaCount() > 0) {
1717  os << "Additional metadata:" << std::endl;
1718  for (ConstMetaIterator it = beginMeta(), end = endMeta(); it != end; ++it) {
1719  os << " " << it->first;
1720  if (it->second) {
1721  const std::string value = it->second->str();
1722  if (!value.empty()) os << ": " << value;
1723  }
1724  os << "\n";
1725  }
1726  }
1727 
1728  os << "Transform:" << std::endl;
1729  transform().print(os, /*indent=*/" ");
1730  os << std::endl;
1731 }
1732 
1733 
1735 
1736 
1737 template<typename GridType>
1738 inline typename GridType::Ptr
1739 createGrid(const typename GridType::ValueType& background)
1740 {
1741  return GridType::create(background);
1742 }
1743 
1744 
1745 template<typename GridType>
1746 inline typename GridType::Ptr
1748 {
1749  return GridType::create();
1750 }
1751 
1752 
1753 template<typename TreePtrType>
1755 createGrid(TreePtrType tree)
1756 {
1757  using TreeType = typename TreePtrType::element_type;
1758  return Grid<TreeType>::create(tree);
1759 }
1760 
1761 
1762 template<typename GridType>
1763 typename GridType::Ptr
1764 createLevelSet(Real voxelSize, Real halfWidth)
1765 {
1766  using ValueType = typename GridType::ValueType;
1767 
1768  // GridType::ValueType is required to be a floating-point scalar.
1769  static_assert(std::is_floating_point<ValueType>::value,
1770  "level-set grids must be floating-point-valued");
1771 
1772  typename GridType::Ptr grid = GridType::create(
1773  /*background=*/static_cast<ValueType>(voxelSize * halfWidth));
1774  grid->setTransform(math::Transform::createLinearTransform(voxelSize));
1775  grid->setGridClass(GRID_LEVEL_SET);
1776  return grid;
1777 }
1778 
1779 
1781 
1782 
1783 namespace internal {
1784 
1786 template<typename OpT, typename GridBaseT, typename T, typename ...Ts>
1787 struct GridApplyImpl { static bool apply(GridBaseT&, OpT&) { return false; } };
1788 
1789 // Partial specialization for (nonempty) TypeLists
1791 template<typename OpT, typename GridBaseT, typename GridT, typename ...GridTs>
1792 struct GridApplyImpl<OpT, GridBaseT, TypeList<GridT, GridTs...>>
1793 {
1794  static bool apply(GridBaseT& grid, OpT& op)
1795  {
1796  if (grid.template isType<GridT>()) {
1797  op(static_cast<typename CopyConstness<GridBaseT, GridT>::Type&>(grid));
1798  return true;
1799  }
1800  return GridApplyImpl<OpT, GridBaseT, TypeList<GridTs...>>::apply(grid, op);
1801  }
1802 };
1803 
1804 } // namespace internal
1805 
1806 
1807 template<typename GridTypeListT, typename OpT>
1808 inline bool
1809 GridBase::apply(OpT& op) const
1810 {
1811  return internal::GridApplyImpl<OpT, const GridBase, GridTypeListT>::apply(*this, op);
1812 }
1813 
1814 template<typename GridTypeListT, typename OpT>
1815 inline bool
1817 {
1818  return internal::GridApplyImpl<OpT, GridBase, GridTypeListT>::apply(*this, op);
1819 }
1820 
1821 template<typename GridTypeListT, typename OpT>
1822 inline bool
1823 GridBase::apply(const OpT& op) const
1824 {
1825  return internal::GridApplyImpl<const OpT, const GridBase, GridTypeListT>::apply(*this, op);
1826 }
1827 
1828 template<typename GridTypeListT, typename OpT>
1829 inline bool
1830 GridBase::apply(const OpT& op)
1831 {
1832  return internal::GridApplyImpl<const OpT, GridBase, GridTypeListT>::apply(*this, op);
1833 }
1834 
1835 } // namespace OPENVDB_VERSION_NAME
1836 } // namespace openvdb
1837 
1838 #endif // OPENVDB_GRID_HAS_BEEN_INCLUDED
openvdb::v7_1::GridBase::constBaseTree
const TreeBase & constBaseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:192
openvdb::v7_1::TreeAdapter::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1079
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1145
openvdb::v7_1::MetaMap
Container that maps names (strings) to values of arbitrary types.
Definition: MetaMap.h:20
openvdb::v7_1::Grid::copy
Ptr copy()
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition: Grid.h:1396
openvdb::v7_1::TypeList
A list of types (not necessarily unique)
Definition: Types.h:653
openvdb::v7_1::TreeAdapter::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1081
OPENVDB_NO_TYPE_CONVERSION_WARNING_END
#define OPENVDB_NO_TYPE_CONVERSION_WARNING_END
Definition: Platform.h:197
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1136
openvdb::v7_1::Grid::Ptr
SharedPtr< Grid > Ptr
Definition: Grid.h:574
openvdb::v7_1::Grid::ValueAllCIter
typename _TreeType::ValueAllCIter ValueAllCIter
Definition: Grid.h:588
openvdb::v7_1::GridBase
Abstract base class for typed grids.
Definition: Grid.h:78
openvdb::v7_1::gridConstPtrCast
GridType::ConstPtr gridConstPtrCast(const GridBase::ConstPtr &grid)
Cast a generic const grid pointer to a const pointer to a grid of a concrete class.
Definition: Grid.h:1027
openvdb::v7_1::io::getFormatVersion
OPENVDB_API uint32_t getFormatVersion(std::ios_base &)
Return the file format version number associated with the given input stream.
openvdb::v7_1::Grid::copyGridReplacingMetadata
GridBase::ConstPtr copyGridReplacingMetadata(const MetaMap &meta) const override
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition: Grid.h:1429
openvdb::v7_1::Grid::registerGrid
static void registerGrid()
Register this grid type along with a factory function.
Definition: Grid.h:972
openvdb::v7_1::Grid::ConstAccessor
typename tree::ValueAccessor< const _TreeType, true > ConstAccessor
Definition: Grid.h:591
openvdb::v7_1::GridBase::empty
virtual bool empty() const =0
Return true if this grid contains only background voxels.
openvdb::v7_1::Grid::copyGrid
GridBase::Ptr copyGrid() override
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
Definition: Grid.h:1414
openvdb::v7_1::tree::TreeBase::Ptr
SharedPtr< TreeBase > Ptr
Definition: Tree.h:38
openvdb::v7_1::GridBase::voxelSize
Vec3d voxelSize(const Vec3d &xyz) const
Return the size of this grid's voxel at position (x, y, z).
Definition: Grid.h:432
openvdb::v7_1::io::StreamMetadata::Ptr
SharedPtr< StreamMetadata > Ptr
Definition: io.h:33
openvdb::v7_1::Grid::~Grid
~Grid() override
Definition: Grid.h:641
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(AccessorType &a)
Definition: Grid.h:1146
openvdb::v7_1::Grid::create
static Ptr create()
Return a new grid with background value zero.
Definition: Grid.h:1321
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1133
openvdb::v7_1::Grid::beginValueAll
ValueAllIter beginValueAll()
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:770
openvdb::v7_1::TreeAdapter::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1080
openvdb::v7_1::Grid::deepCopyGrid
GridBase::Ptr deepCopyGrid() const override
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition: Grid.h:706
openvdb::v7_1::Grid::tree
const TreeType & tree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:909
openvdb::v7_1::GridBase::setSaveFloatAsHalf
void setSaveFloatAsHalf(bool)
Return this grid's user-specified name.
Types.h
openvdb::v7_1::GridBase::pruneGrid
virtual void pruneGrid(float tolerance=0.0)=0
Reduce the memory footprint of this grid by increasing its sparseness either losslessly (tolerance = ...
openvdb::v7_1::GridBase::META_IS_LOCAL_SPACE
static const char *const META_IS_LOCAL_SPACE
Definition: Grid.h:354
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1108
openvdb::v7_1::Grid::merge
void merge(Grid &other, MergePolicy policy=MERGE_ACTIVE_STATES)
Efficiently merge another grid into this grid using one of several schemes.
Definition: Grid.h:1534
openvdb::v7_1::GridBase::type
virtual Name type() const =0
Return the name of this grid's type.
openvdb::v7_1::TreeAdapter::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1090
openvdb::v7_1::Grid::UnsafeAccessor
typename tree::ValueAccessor< _TreeType, false > UnsafeAccessor
Definition: Grid.h:592
openvdb::v7_1::TreeAdapter::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1091
openvdb::v7_1::tree::TreeBase::ConstPtr
SharedPtr< const TreeBase > ConstPtr
Definition: Tree.h:39
openvdb::v7_1::GridBase::readBuffers
virtual void readBuffers(std::istream &, const CoordBBox &)=0
Read all of this grid's data buffers that intersect the given index-space bounding box.
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const AccessorType &a)
Definition: Grid.h:1149
openvdb::v7_1::GridNamePred::operator()
bool operator()(const GridBase::ConstPtr &g) const
Definition: Grid.h:534
openvdb::v7_1::TreeAdapter::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1088
openvdb::v7_1::Grid::ValueOffIter
typename _TreeType::ValueOffIter ValueOffIter
Definition: Grid.h:585
openvdb::v7_1::Grid::getUnsafeAccessor
UnsafeAccessor getUnsafeAccessor()
Return an unsafe accessor that provides random read and write access to this grid's voxels.
Definition: Grid.h:743
openvdb::v7_1::GridBase::readTransform
void readTransform(std::istream &is)
Read in the transform for this grid.
Definition: Grid.h:469
openvdb::v7_1::GridBase::setName
void setName(const std::string &)
Specify a name for this grid.
openvdb::v7_1::GridBase::constBaseTreePtr
virtual TreeBase::ConstPtr constBaseTreePtr() const =0
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
openvdb::v7_1::createGrid
Grid< typename TreePtrType::element_type >::Ptr createGrid(TreePtrType)
Create a new grid of the appropriate type that wraps the given tree.
Definition: Grid.h:1755
openvdb::v7_1::GridBase::activeVoxelCount
virtual Index64 activeVoxelCount() const =0
Return the number of active voxels.
openvdb::v7_1::Grid::copyGridWithNewTree
GridBase::Ptr copyGridWithNewTree() const override
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition: Grid.h:1452
openvdb::v7_1::Grid::readNonresidentBuffers
void readNonresidentBuffers() const override
Read all of this grid's data buffers that are not yet resident in memory (because delayed loading is ...
Definition: Grid.h:1667
openvdb::v7_1::GridBase::getStatsMetadata
MetaMap::Ptr getStatsMetadata() const
Return a new MetaMap containing just the metadata that was added to this grid with addStatsMetadata.
openvdb::v7_1::GridBase::setIsInWorldSpace
void setIsInWorldSpace(bool)
Specify whether this grid's voxel values are in world space or in local space.
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1113
openvdb::v7_1::GridBase::stringToGridClass
static GridClass stringToGridClass(const std::string &)
Return the class of volumetric data specified by the given string.
openvdb::v7_1::Grid::getAccessor
ConstAccessor getAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:745
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1138
openvdb::v7_1::GridBase::setGridClass
void setGridClass(GridClass)
Specify the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
openvdb::v7_1::GridBase::Ptr
SharedPtr< GridBase > Ptr
Definition: Grid.h:80
openvdb::v7_1::GridBase::writeBuffers
virtual void writeBuffers(std::ostream &) const =0
Write out all data buffers for this grid.
openvdb::v7_1::Name
std::string Name
Definition: Name.h:17
openvdb::v7_1::Grid::getConstAccessor
ConstAccessor getConstAccessor() const
Return an accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:747
openvdb::v7_1::Grid::cbeginValueOff
ValueOffCIter cbeginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:768
openvdb::v7_1::StaticPtrCast
SharedPtr< T > StaticPtrCast(const SharedPtr< U > &ptr)
Return a new shared pointer that points to the same object as the given pointer after a static_cast.
Definition: Types.h:123
openvdb::v7_1::Grid::clear
void clear() override
Empty this grid, so that all voxels become inactive background voxels.
Definition: Grid.h:730
Transform.h
openvdb::v7_1::Grid::constTree
const TreeType & constTree() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:910
openvdb::v7_1::GridBase::valueType
virtual Name valueType() const =0
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
openvdb::v7_1::GridBase::GridFactory
Ptr(*)() GridFactory
Definition: Grid.h:83
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1151
openvdb::v7_1::Grid::Grid
Grid()
Construct a new grid with background value zero.
Definition: Grid.h:1256
openvdb::v7_1::GridPtrVecIter
GridPtrVec::iterator GridPtrVecIter
Definition: Grid.h:510
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1115
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1132
openvdb::v7_1::GridBase::writeTransform
void writeTransform(std::ostream &os) const
Write out the transform for this grid.
Definition: Grid.h:471
openvdb::v7_1::Grid::constBaseTreePtr
TreeBase::ConstPtr constBaseTreePtr() const override
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:898
openvdb::v7_1::Grid::ConstPtr
SharedPtr< const Grid > ConstPtr
Definition: Grid.h:575
openvdb::v7_1::GridBase::indexToWorld
Vec3d indexToWorld(const Vec3d &xyz) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:436
openvdb::v7_1::Grid::copyReplacingMetadataAndTransform
ConstPtr copyReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition: Grid.h:1385
openvdb::v7_1::Grid::cbeginValueAll
ValueAllCIter cbeginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:774
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1116
openvdb::v7_1::GridBase::readBuffers
virtual void readBuffers(std::istream &)=0
Read all data buffers for this grid.
openvdb::v7_1::GridBase::getName
std::string getName() const
Return this grid's user-specified name.
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1153
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1121
openvdb::v7_1::TreeAdapter::tree
static TreeType & tree(GridType &g)
Definition: Grid.h:1086
openvdb::v7_1::Grid::beginValueOn
ValueOnIter beginValueOn()
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:758
openvdb::v7_1::Grid::type
Name type() const override
Return the name of this grid's type.
Definition: Grid.h:712
openvdb::v7_1::GridNamePred::name
Name name
Definition: Grid.h:535
openvdb::v7_1::GridBase::isInWorldSpace
bool isInWorldSpace() const
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1147
openvdb::v7_1::GridClass
GridClass
Definition: Types.h:816
openvdb::v7_1::GridCPtrVecIter
GridCPtrVec::iterator GridCPtrVecIter
Definition: Grid.h:515
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1130
openvdb::v7_1::GridPtrVecPtr
SharedPtr< GridPtrVec > GridPtrVecPtr
Definition: Grid.h:512
openvdb::v7_1::GridBase::constGrid
static GridType::ConstPtr constGrid(const GridBase::Ptr &)
Definition: Grid.h:1222
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:1129
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1110
openvdb::v7_1::Index64
uint64_t Index64
Definition: Types.h:30
openvdb::v7_1::Grid::tree
TreeType & tree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:908
openvdb::v7_1::Grid::copyWithNewTree
Ptr copyWithNewTree() const
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
Definition: Grid.h:1404
openvdb::v7_1::Grid::evalActiveVoxelDim
Coord evalActiveVoxelDim() const override
Return the dimensions of the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1590
openvdb::v7_1::Grid::ValueType
typename _TreeType::ValueType ValueType
Definition: Grid.h:580
Name.h
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::TreeType
_TreeType TreeType
Definition: Grid.h:1100
openvdb::v7_1::GridBase::META_GRID_CREATOR
static const char *const META_GRID_CREATOR
Definition: Grid.h:351
openvdb::v7_1::Grid::print
void print(std::ostream &=std::cout, int verboseLevel=1) const override
Output a human-readable description of this grid.
Definition: Grid.h:1712
openvdb::v7_1::Grid::copyReplacingMetadata
ConstPtr copyReplacingMetadata(const MetaMap &meta) const
Return a new grid of the same type as this grid whose tree and transform is shared with this grid and...
Definition: Grid.h:1368
openvdb::v7_1::Grid::ValueOffCIter
typename _TreeType::ValueOffCIter ValueOffCIter
Definition: Grid.h:586
openvdb::v7_1::GridCPtrSetCIter
GridCPtrSet::const_iterator GridCPtrSetCIter
Definition: Grid.h:526
openvdb::v7_1::GridBase::setCreator
void setCreator(const std::string &)
Provide a description of this grid's creator.
openvdb::v7_1::Grid::constTreePtr
ConstTreePtrType constTreePtr() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:897
openvdb::v7_1::createGrid
GridType::Ptr createGrid(const typename GridType::ValueType &background)
Create a new grid of type GridType with a given background value.
Definition: Grid.h:1739
openvdb::v7_1::TreeAdapter::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1078
openvdb::v7_1::GridBase::grid
static GridType::Ptr grid(const GridBase::Ptr &)
Return the result of downcasting a GridBase pointer to a Grid pointer of the specified type,...
Definition: Grid.h:1200
openvdb::v7_1::Grid::writeBuffers
void writeBuffers(std::ostream &) const override
Write out all data buffers for this grid.
Definition: Grid.h:1675
openvdb::v7_1::Grid::empty
bool empty() const override
Return true if this grid contains only inactive background voxels.
Definition: Grid.h:728
openvdb::v7_1::io::getStreamMetadataPtr
OPENVDB_API SharedPtr< StreamMetadata > getStreamMetadataPtr(std::ios_base &)
Return a shared pointer to an object that stores metadata (file format, compression scheme,...
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1141
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::ConstGridPtrType
typename GridType::ConstPtr ConstGridPtrType
Definition: Grid.h:1109
openvdb::v7_1::TreeAdapter::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1074
openvdb::v7_1::Grid::BuildType
typename _TreeType::BuildType BuildType
Definition: Grid.h:581
openvdb::v7_1::MERGE_ACTIVE_STATES
@ MERGE_ACTIVE_STATES
Definition: Types.h:870
openvdb_houdini::Grid
openvdb::GridBase Grid
Definition: Utils.h:33
MetaMap.h
openvdb::v7_1::Grid::writeTopology
void writeTopology(std::ostream &) const override
Write the grid topology to a stream. This will write only the grid structure, not the actual data buf...
Definition: Grid.h:1614
openvdb::v7_1::Grid::treePtr
ConstTreePtrType treePtr() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:896
openvdb::v7_1::GridBase::readTopology
virtual void readTopology(std::istream &)=0
Read the grid topology from a stream. This will read only the grid structure, not the actual data buf...
openvdb::v7_1::Grid::beginValueOn
ValueOnCIter beginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:760
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1103
openvdb::v7_1::Grid
Container class that associates a tree with a transform and metadata.
Definition: Grid.h:28
openvdb::v7_1::GridBase::clip
virtual void clip(const CoordBBox &)=0
Clip this grid to the given index-space bounding box.
openvdb::v7_1::math::CoordBBox
Axis-aligned bounding box of signed integer coordinates.
Definition: Coord.h:249
OPENVDB_API
#define OPENVDB_API
Helper macros for defining library symbol visibility.
Definition: Platform.h:230
openvdb::v7_1::GridPtrSetIter
GridPtrSet::iterator GridPtrSetIter
Definition: Grid.h:520
openvdb::v7_1::Grid::TreeType
_TreeType TreeType
Definition: Grid.h:577
openvdb::v7_1::GridBase::memUsage
virtual Index64 memUsage() const =0
Return the number of bytes of memory used by this grid.
openvdb::v7_1::Grid::ValueOnCIter
typename _TreeType::ValueOnCIter ValueOnCIter
Definition: Grid.h:584
openvdb::v7_1::GridBase::META_FILE_BBOX_MAX
static const char *const META_FILE_BBOX_MAX
Definition: Grid.h:357
openvdb::v7_1::math::Transform::ConstPtr
SharedPtr< const Transform > ConstPtr
Definition: Transform.h:43
openvdb::v7_1::Grid::isTreeUnique
bool isTreeUnique() const
Return true if tree is not shared with another grid.
Definition: Grid.h:1463
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(GridType &g)
Definition: Grid.h:1120
openvdb::v7_1::GridBase::transform
const math::Transform & transform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:411
openvdb::v7_1::GRID_LEVEL_SET
@ GRID_LEVEL_SET
Definition: Types.h:818
openvdb::v7_1::GridBase::META_FILE_MEM_BYTES
static const char *const META_FILE_MEM_BYTES
Definition: Grid.h:359
openvdb::v7_1::GridNamePred
Predicate functor that returns true for grids that have a specified name.
Definition: Grid.h:532
openvdb::v7_1::GridPtrVec
std::vector< GridBase::Ptr > GridPtrVec
Definition: Grid.h:509
openvdb::v7_1::Grid::readBuffers
void readBuffers(std::istream &) override
Read all data buffers for this grid.
Definition: Grid.h:1622
openvdb::v7_1::GridBase::newTree
virtual void newTree()=0
Set a new tree with the same background value as the previous tree.
openvdb::v7_1::GridBase::setTransform
void setTransform(math::Transform::Ptr)
Associate the given transform with this grid, in place of its existing transform.
Definition: Grid.h:1245
openvdb::v7_1::MetaMap::Ptr
SharedPtr< MetaMap > Ptr
Definition: MetaMap.h:22
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1142
openvdb::v7_1::GridBase::GridBase
GridBase()
Initialize with an identity linear transform.
Definition: Grid.h:481
openvdb::v7_1::TreeAdapter::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1089
openvdb::v7_1::GridBase::isType
bool isType() const
Return true if this grid is of the same type as the template parameter.
Definition: Grid.h:148
openvdb::v7_1::OPENVDB_FILE_VERSION_MULTIPASS_IO
@ OPENVDB_FILE_VERSION_MULTIPASS_IO
Definition: version.h:190
openvdb::v7_1::GridBase::addStatsMetadata
void addStatsMetadata()
Add metadata to this grid comprising the current values of statistics like the active voxel count and...
openvdb::v7_1::GridBase::isRegistered
static bool isRegistered(const Name &type)
Return true if the given grid type name is registered.
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::Grid::topologyUnion
void topologyUnion(const Grid< OtherTreeType > &other)
Union this grid's set of active values with the active values of the other grid, whose value type may...
Definition: Grid.h:1543
openvdb::v7_1::tools::clip
GridType::Ptr clip(const GridType &grid, const BBoxd &bbox, bool keepInterior=true)
Clip the given grid against a world-space bounding box and return a new grid containing the result.
Definition: Clip.h:348
openvdb::v7_1::GridBase::clearGridClass
void clearGridClass()
Remove the setting specifying the class of this grid's volumetric data.
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(const TreeType &t)
Definition: Grid.h:1152
openvdb::v7_1::GridBase::setTree
virtual void setTree(TreeBase::Ptr)=0
Associate the given tree with this grid, in place of its existing tree.
openvdb::v7_1::Grid::copyGridReplacingTransform
GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition: Grid.h:1436
openvdb::v7_1::GridCPtrSetIter
GridCPtrSet::iterator GridCPtrSetIter
Definition: Grid.h:525
openvdb::v7_1::GridBase::clear
virtual void clear()=0
Empty this grid, setting all voxels to the background.
openvdb::v7_1::Grid::denseFill
void denseFill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value and ensure that those voxels are a...
Definition: Grid.h:1510
openvdb::v7_1::Grid::hasMultiPassIO
static bool hasMultiPassIO()
Return true if grids of this type require multiple I/O passes to read and write data buffers.
Definition: Grid.h:1704
openvdb::v7_1::GridBase::META_FILE_DELAYED_LOAD
static const char *const META_FILE_DELAYED_LOAD
Definition: Grid.h:361
openvdb::v7_1::GridBase::unregisterGrid
static void unregisterGrid(const Name &type)
Remove a grid type from the registry.
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1111
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1119
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::AccessorType
typename tree::ValueAccessor< TreeType > AccessorType
Definition: Grid.h:1140
openvdb::v7_1::GridPtrSet
std::set< GridBase::Ptr > GridPtrSet
Definition: Grid.h:519
openvdb::v7_1::Grid::evalMinMax
void evalMinMax(ValueType &minVal, ValueType &maxVal) const
Return the minimum and maximum active values in this grid.
Definition: Grid.h:1572
openvdb::v7_1::GridBase::deepCopyGrid
virtual GridBase::Ptr deepCopyGrid() const =0
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
openvdb::v7_1::Grid::ValueAllIter
typename _TreeType::ValueAllIter ValueAllIter
Definition: Grid.h:587
openvdb::v7_1::Grid::Accessor
typename tree::ValueAccessor< _TreeType, true > Accessor
Definition: Grid.h:590
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1112
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::NonConstTreePtrType
typename NonConstTreeType::Ptr NonConstTreePtrType
Definition: Grid.h:1104
openvdb::v7_1::GridBase::saveFloatAsHalf
bool saveFloatAsHalf() const
Return true if this grid should be written out with floating-point voxel values (including components...
openvdb::v7_1::GridBase::copyGridReplacingMetadataAndTransform
virtual GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
openvdb::v7_1::HasMultiPassIO
Metafunction that specifies whether a given leaf node, tree, or grid type requires multiple passes to...
Definition: Grid.h:1168
openvdb::v7_1::GridBase::~GridBase
~GridBase() override
Definition: Grid.h:86
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1131
openvdb::v7_1::GridBase::constTransformPtr
math::Transform::ConstPtr constTransformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:403
openvdb::v7_1::createLevelSet
GridType::Ptr createLevelSet(Real voxelSize=1.0, Real halfWidth=LEVEL_SET_HALF_WIDTH)
Create a new grid of type GridType classified as a "Level Set", i.e., a narrow-band level set.
Definition: Grid.h:1764
openvdb::v7_1::Grid::beginValueOff
ValueOffIter beginValueOff()
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:764
openvdb::v7_1::GridBase::voxelSize
Vec3d voxelSize() const
Return the size of this grid's voxels.
Definition: Grid.h:429
openvdb::v7_1::Grid::TreePtrType
typename _TreeType::Ptr TreePtrType
Definition: Grid.h:578
openvdb::v7_1::GridBase::stringToVecType
static VecType stringToVecType(const std::string &)
openvdb::v7_1::math::Coord
Signed (x, y, z) 32-bit integer coordinates.
Definition: Coord.h:26
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::ValueType
typename TreeType::ValueType ValueType
Definition: Grid.h:1139
openvdb::v7_1::math::Vec3d
Vec3< double > Vec3d
Definition: Vec3.h:662
openvdb::v7_1::GridBase::ConstPtr
SharedPtr< const GridBase > ConstPtr
Definition: Grid.h:81
openvdb::v7_1::TreeAdapter::TreeType
_TreeType TreeType
Definition: Grid.h:1070
openvdb::v7_1::Grid::deepCopy
Ptr deepCopy() const
Return a new grid whose metadata, transform and tree are deep copies of this grid's.
Definition: Grid.h:704
openvdb::v7_1::Grid::gridType
static Name gridType()
Return the name of this type of grid.
Definition: Grid.h:714
openvdb::v7_1::GridCPtrSetPtr
SharedPtr< GridCPtrSet > GridCPtrSetPtr
Definition: Grid.h:527
openvdb::v7_1::GridBase::writeTopology
virtual void writeTopology(std::ostream &) const =0
Write the grid topology to a stream. This will write only the grid structure, not the actual data buf...
openvdb::v7_1::VecType
VecType
Definition: Types.h:846
openvdb::v7_1::Grid::pruneGrid
void pruneGrid(float tolerance=0.0) override
Reduce the memory footprint of this grid by increasing its sparseness.
Definition: Grid.h:1517
openvdb::v7_1::TreeAdapter
This adapter allows code that is templated on a Tree type to accept either a Tree type or a Grid type...
Definition: Grid.h:1069
openvdb::v7_1::GridBase::gridClassToMenuName
static std::string gridClassToMenuName(GridClass)
Return a formatted string version of the grid class.
openvdb::v7_1::TreeAdapter::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1077
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::GridPtrType
typename GridType::Ptr GridPtrType
Definition: Grid.h:1107
openvdb::v7_1::TreeAdapter::ConstTreePtrType
typename TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:1073
openvdb::v7_1::GridPtrVecCIter
GridPtrVec::const_iterator GridPtrVecCIter
Definition: Grid.h:511
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:146
openvdb::v7_1::GridBase::hasUniformVoxels
bool hasUniformVoxels() const
Return true if the voxels in world space are uniformly sized cubes.
Definition: Grid.h:434
openvdb::v7_1::Grid::getConstUnsafeAccessor
ConstUnsafeAccessor getConstUnsafeAccessor() const
Return an unsafe accessor that provides random read-only access to this grid's voxels.
Definition: Grid.h:755
openvdb::v7_1::Grid::topologyIntersection
void topologyIntersection(const Grid< OtherTreeType > &other)
Intersect this grid's set of active values with the active values of the other grid,...
Definition: Grid.h:1552
openvdb::v7_1::math::BBox< Vec3d >
openvdb::v7_1::GridPtrSetCIter
GridPtrSet::const_iterator GridPtrSetCIter
Definition: Grid.h:521
openvdb::v7_1::Grid::evalActiveVoxelBoundingBox
CoordBBox evalActiveVoxelBoundingBox() const override
Return the axis-aligned bounding box of all active voxels.
Definition: Grid.h:1580
openvdb::v7_1::GridBase::vecTypeToString
static std::string vecTypeToString(VecType)
Return the metadata string value for the given type of vector data.
openvdb::v7_1::Grid::unregisterGrid
static void unregisterGrid()
Remove this grid type from the registry.
Definition: Grid.h:981
openvdb::v7_1::GridBase::evalActiveVoxelDim
virtual Coord evalActiveVoxelDim() const =0
Return the dimensions of the axis-aligned bounding box of all active voxels.
openvdb::v7_1::MergePolicy
MergePolicy
Definition: Types.h:869
openvdb::v7_1::Grid::newTree
void newTree() override
Associate a new, empty tree with this grid, in place of its existing tree.
Definition: Grid.h:1484
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1117
openvdb::v7_1::GridBase::copyGrid
virtual GridBase::ConstPtr copyGrid() const =0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
openvdb::v7_1::GridCPtrVecCIter
GridCPtrVec::const_iterator GridCPtrVecCIter
Definition: Grid.h:516
openvdb::v7_1::GridBase::baseTree
const TreeBase & baseTree() const
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:187
openvdb::v7_1::TreeBase
tree::TreeBase TreeBase
Definition: Grid.h:26
openvdb::v7_1::Grid::ValueConverter
ValueConverter<T>::Type is the type of a grid having the same hierarchy as this grid but a different ...
Definition: Grid.h:602
Tree.h
openvdb::v7_1::GridBase::worldToIndex
Vec3d worldToIndex(const Vec3d &xyz) const
Apply the inverse of this grid's transform to the given coordinates.
Definition: Grid.h:440
openvdb::v7_1::TreeAdapter::ConstAccessorType
typename tree::ValueAccessor< const TreeType > ConstAccessorType
Definition: Grid.h:1082
openvdb::v7_1::Grid::background
const ValueType & background() const
Return this grid's background value.
Definition: Grid.h:725
openvdb::v7_1::GridBase::META_SAVE_HALF_FLOAT
static const char *const META_SAVE_HALF_FLOAT
Definition: Grid.h:353
openvdb::v7_1::TreeAdapter::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1072
openvdb::v7_1::GridCPtrSet
std::set< GridBase::ConstPtr > GridCPtrSet
Definition: Grid.h:524
openvdb::v7_1::TreeAdapter::tree
static const TreeType & tree(const TreeType &t)
Definition: Grid.h:1087
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::TreePtrType
typename TreeType::Ptr TreePtrType
Definition: Grid.h:1102
openvdb::v7_1::Grid::ConstTreePtrType
typename _TreeType::ConstPtr ConstTreePtrType
Definition: Grid.h:579
openvdb::v7_1::GridBase::getCreator
std::string getCreator() const
Return the user-specified description of this grid's creator.
openvdb::v7_1::GridBase::vecTypeDescription
static std::string vecTypeDescription(VecType)
Return a string describing how the given type of vector data is affected by transformations (e....
openvdb::v7_1::GridBase::META_FILE_COMPRESSION
static const char *const META_FILE_COMPRESSION
Definition: Grid.h:358
openvdb::v7_1::Grid::copyReplacingTransform
ConstPtr copyReplacingTransform(math::Transform::Ptr xform) const
Return a new grid of the same type as this grid whose tree is shared with this grid,...
Definition: Grid.h:1378
openvdb::v7_1::Grid::valueType
Name valueType() const override
Return the name of the type of a voxel's value (e.g., "float" or "vec3d").
Definition: Grid.h:717
openvdb::v7_1::GridBase::setVectorType
void setVectorType(VecType)
Specify the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this ...
openvdb::v7_1::Grid::memUsage
Index64 memUsage() const override
Definition: Grid.h:884
OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
#define OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN
Bracket code with OPENVDB_NO_TYPE_CONVERSION_WARNING_BEGIN/_END, to inhibit warnings about type conve...
Definition: Platform.h:196
openvdb::v7_1::Grid::fill
void fill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value.
Definition: Grid.h:1503
openvdb::v7_1::GridBase::clipGrid
void clipGrid(const BBoxd &)
Clip this grid to the given world-space bounding box.
openvdb::v7_1::gridPtrCast
GridType::Ptr gridPtrCast(const GridBase::Ptr &grid)
Cast a generic grid pointer to a pointer to a grid of a concrete class.
Definition: Grid.h:1011
openvdb::v7_1::Grid::ConstUnsafeAccessor
typename tree::ValueAccessor< const _TreeType, false > ConstUnsafeAccessor
Definition: Grid.h:593
openvdb::v7_1::Grid::isRegistered
static bool isRegistered()
Return true if this grid type is registered.
Definition: Grid.h:970
logging.h
io.h
openvdb::v7_1::deepCopyTypedGrid
GridType::Ptr deepCopyTypedGrid(const GridBase &grid)
Return a pointer to a deep copy of the given grid, provided that the grid's concrete type is GridType...
Definition: Grid.h:1053
openvdb::v7_1::GridBase::baseTreePtr
TreeBase::ConstPtr baseTreePtr() const
Return a pointer to this grid's tree, which might be shared with other grids. The pointer is guarante...
Definition: Grid.h:173
openvdb::v7_1::CopyConstness::Type
typename std::remove_const< ToType >::type Type
Definition: Types.h:298
openvdb::v7_1::tree::ValueAccessor
Definition: ValueAccessor.h:183
openvdb::v7_1::GridBase::GridBase
GridBase(GridBase &other, ShallowCopy)
Copy another grid's metadata but share its transform.
Definition: Grid.h:493
openvdb::v7_1::GridBase::META_GRID_NAME
static const char *const META_GRID_NAME
Definition: Grid.h:352
openvdb::v7_1::GridBase::clearVectorType
void clearVectorType()
Remove the setting specifying the type of vector data stored in this grid.
openvdb::v7_1::GridBase::baseTree
TreeBase & baseTree()
Return a reference to this grid's tree, which might be shared with other grids.
Definition: Grid.h:182
openvdb::v7_1::GridBase::transformPtr
math::Transform::ConstPtr transformPtr() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:402
openvdb::v7_1::GridBase::print
virtual void print(std::ostream &=std::cout, int verboseLevel=1) const =0
Output a human-readable description of this grid.
openvdb::v7_1::GridBase::createGrid
static Ptr createGrid(const Name &type)
Create a new grid of the given (registered) type.
openvdb::v7_1::TreeAdapter::NonConstAccessorType
typename tree::ValueAccessor< NonConstTreeType > NonConstAccessorType
Definition: Grid.h:1083
openvdb::v7_1::findGridByName
GridPtrT findGridByName(const std::map< KeyT, GridPtrT > &container, const Name &name)
Return the first grid in the given map whose name is name.
Definition: Grid.h:552
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:94
openvdb::v7_1::GridBase::META_GRID_CLASS
static const char *const META_GRID_CLASS
Definition: Grid.h:350
openvdb::v7_1::GridBase::constTransform
const math::Transform & constTransform() const
Return a pointer to this grid's transform, which might be shared with other grids.
Definition: Grid.h:412
openvdb::v7_1::Grid::beginValueOff
ValueOffCIter beginValueOff() const
Return an iterator over all of this grid's inactive values (tile and voxel).
Definition: Grid.h:766
openvdb::v7_1::Grid::setTree
void setTree(TreeBase::Ptr) override
Associate the given tree with this grid, in place of its existing tree.
Definition: Grid.h:1471
openvdb::v7_1::Grid::topologyDifference
void topologyDifference(const Grid< OtherTreeType > &other)
Difference this grid's set of active values with the active values of the other grid,...
Definition: Grid.h:1561
openvdb::v7_1::GridBase::getVectorType
VecType getVectorType() const
Return the type of vector data (invariant, covariant, etc.) stored in this grid, assuming that this g...
openvdb::v7_1::TreeAdapter::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1085
openvdb::v7_1::GridBase::copyGridWithNewTree
virtual GridBase::Ptr copyGridWithNewTree() const =0
Return a new grid of the same type as this grid whose metadata and transform are deep copies of this ...
openvdb::v7_1::Grid::ValueOnIter
typename _TreeType::ValueOnIter ValueOnIter
Definition: Grid.h:583
openvdb::v7_1::math::Transform::Ptr
SharedPtr< Transform > Ptr
Definition: Transform.h:42
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1122
openvdb::v7_1::tree::internal::LeafBufferFlags
Definition: LeafBuffer.h:41
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1148
openvdb::v7_1::TreeAdapter::constTree
static const TreeType & constTree(const GridType &g)
Definition: Grid.h:1092
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::v7_1::GridBase::copyGridReplacingTransform
virtual GridBase::ConstPtr copyGridReplacingTransform(math::Transform::Ptr xform) const =0
Return a new grid of the same type as this grid whose tree is shared with this grid,...
openvdb::v7_1::GridCPtrVec
std::vector< GridBase::ConstPtr > GridCPtrVec
Definition: Grid.h:514
openvdb::v7_1::math::Transform
Definition: Transform.h:40
openvdb::v7_1::ValueError
Definition: Exceptions.h:65
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::NonConstGridPtrType
typename NonConstGridType::Ptr NonConstGridPtrType
Definition: Grid.h:1137
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::tree
static TreeType & tree(TreeType &t)
Definition: Grid.h:1144
openvdb::v7_1::Grid::readTopology
void readTopology(std::istream &) override
Read the grid topology from a stream. This will read only the grid structure, not the actual data buf...
Definition: Grid.h:1606
openvdb::v7_1::GridBase::META_FILE_VOXEL_COUNT
static const char *const META_FILE_VOXEL_COUNT
Definition: Grid.h:360
openvdb::v7_1::ShallowCopy
Tag dispatch class that distinguishes shallow copy constructors from deep copy constructors.
Definition: Types.h:1042
openvdb
Definition: Exceptions.h:13
openvdb::v7_1::math::Transform::createLinearTransform
static Transform::Ptr createLinearTransform(double voxelSize=1.0)
Create and return a shared pointer to a new transform.
openvdb::v7_1::GridBase::META_FILE_BBOX_MIN
static const char *const META_FILE_BBOX_MIN
Definition: Grid.h:356
openvdb::v7_1::Grid::cbeginValueOn
ValueOnCIter cbeginValueOn() const
Return an iterator over all of this grid's active values (tile and voxel).
Definition: Grid.h:762
openvdb::v7_1::GridBase::indexToWorld
Vec3d indexToWorld(const Coord &ijk) const
Apply this grid's transform to the given coordinates.
Definition: Grid.h:438
openvdb::v7_1::GridBase::registerGrid
static void registerGrid(const Name &type, GridFactory)
Register a grid type along with a factory function.
openvdb::v7_1::LEVEL_SET_HALF_WIDTH
static const Real LEVEL_SET_HALF_WIDTH
Definition: Types.h:824
openvdb::v7_1::Grid::operator=
Grid & operator=(const Grid &)=delete
Disallow assignment, since it wouldn't be obvious whether the copy is deep or shallow.
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::tree
static const TreeType & tree(const GridType &g)
Definition: Grid.h:1118
openvdb::v7_1::GridBase::META_VECTOR_TYPE
static const char *const META_VECTOR_TYPE
Definition: Grid.h:355
openvdb::v7_1::SharedPtr
std::shared_ptr< T > SharedPtr
Definition: Types.h:91
openvdb::v7_1::Real
double Real
Definition: Types.h:37
openvdb::v7_1::Grid::sparseFill
void sparseFill(const CoordBBox &bbox, const ValueType &value, bool active=true)
Set all voxels within a given axis-aligned box to a constant value.
Definition: Grid.h:1495
openvdb::v7_1::Grid::beginValueAll
ValueAllCIter beginValueAll() const
Return an iterator over all of this grid's values (tile and voxel).
Definition: Grid.h:772
openvdb::v7_1::GridBase::vecTypeExamples
static std::string vecTypeExamples(VecType)
openvdb::v7_1::GridBase::evalActiveVoxelBoundingBox
virtual CoordBBox evalActiveVoxelBoundingBox() const =0
openvdb::v7_1::GridBase::readNonresidentBuffers
virtual void readNonresidentBuffers() const =0
Read all of this grid's data buffers that are not yet resident in memory (because delayed loading is ...
openvdb::v7_1::GridBase::getGridClass
GridClass getGridClass() const
Return the class of volumetric data (level set, fog volume, etc.) that is stored in this grid.
openvdb::v7_1::Grid::activeVoxelCount
Index64 activeVoxelCount() const override
Return the number of active voxels.
Definition: Grid.h:874
openvdb::v7_1::Grid::clip
void clip(const CoordBBox &) override
Clip this grid to the given index-space bounding box.
Definition: Grid.h:1527
openvdb::v7_1::GridPtrSetPtr
SharedPtr< GridPtrSet > GridPtrSetPtr
Definition: Grid.h:522
openvdb::v7_1::TreeAdapter::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1071
openvdb::v7_1::GridBase::gridClassToString
static std::string gridClassToString(GridClass)
Return the metadata string value for the given class of volumetric data.
OPENVDB_THROW
#define OPENVDB_THROW(exception, message)
Definition: Exceptions.h:82
openvdb::v7_1::Grid::copyGridReplacingMetadataAndTransform
GridBase::ConstPtr copyGridReplacingMetadataAndTransform(const MetaMap &meta, math::Transform::Ptr xform) const override
Return a new grid of the same type as this grid whose tree is shared with this grid and whose transfo...
Definition: Grid.h:1443
openvdb::v7_1::TreeAdapter< tree::ValueAccessor< _TreeType > >::constTree
static const TreeType & constTree(TreeType &t)
Definition: Grid.h:1150
Exceptions.h
openvdb::v7_1::GridBase::clearRegistry
static void clearRegistry()
Clear the grid type registry.
openvdb::v7_1::TreeAdapter< Grid< _TreeType > >::NonConstTreeType
typename std::remove_const< TreeType >::type NonConstTreeType
Definition: Grid.h:1101
openvdb::v7_1::GridBase::GridBase
GridBase(const GridBase &other)
Deep copy another grid's metadata and transform.
Definition: Grid.h:490
openvdb::v7_1::Grid::getAccessor
Accessor getAccessor()
Return an accessor that provides random read and write access to this grid's voxels.
Definition: Grid.h:735
openvdb::v7_1::GridBase::copyGrid
virtual GridBase::Ptr copyGrid()=0
Return a new grid of the same type as this grid whose metadata is a deep copy of this grid's and whos...
openvdb::v7_1::GridCPtrVecPtr
SharedPtr< GridCPtrVec > GridCPtrVecPtr
Definition: Grid.h:517
openvdb::v7_1::TypeError
Definition: Exceptions.h:64
openvdb::v7_1::GridNamePred::GridNamePred
GridNamePred(const Name &_name)
Definition: Grid.h:533
openvdb::v7_1::tree::TreeBase
Base class for typed trees.
Definition: Tree.h:36
OPENVDB_LOG_WARN
#define OPENVDB_LOG_WARN(message)
Log a warning message of the form 'someVar << "some text" << ...'.
Definition: logging.h:253