diff --git a/openvdb/openvdb/Types.h b/openvdb/openvdb/Types.h index 6578802185..ed4fc53a69 100644 --- a/openvdb/openvdb/Types.h +++ b/openvdb/openvdb/Types.h @@ -234,6 +234,18 @@ using make_index_sequence = std::decay_t())>; +//////////////////////////////////////// + +/// @brief A Traits struct that can be used to query properties of an input T. + +template +struct TreeTraits +{ + static const bool IsSparse = false; + static const bool IsAdaptive = false; +}; + + //////////////////////////////////////// diff --git a/openvdb/openvdb/adaptive/AdaptiveGrid.h b/openvdb/openvdb/adaptive/AdaptiveGrid.h index bca97305b3..f0a646c684 100644 --- a/openvdb/openvdb/adaptive/AdaptiveGrid.h +++ b/openvdb/openvdb/adaptive/AdaptiveGrid.h @@ -282,6 +282,34 @@ struct TreeAdapter > }; +//////////////////////////////////////// + +// Overload the TreeTraits struct to declare a const/non-const AdaptiveTree as adaptive + +template +struct TreeTraits> +{ + static const bool IsSparse = false; + static const bool IsAdaptive = true; +}; + +template +struct TreeTraits> +{ + static const bool IsSparse = false; + static const bool IsAdaptive = true; +}; + +// Overload the TreeTraits struct to declare an AdaptiveAccessor as adaptive + +template +struct TreeTraits> +{ + static const bool IsSparse = false; + static const bool IsAdaptive = true; +}; + + //////////////////////////////////////// diff --git a/openvdb/openvdb/tree/Tree.h b/openvdb/openvdb/tree/Tree.h index 22ea00a914..4149e0e929 100644 --- a/openvdb/openvdb/tree/Tree.h +++ b/openvdb/openvdb/tree/Tree.h @@ -2125,6 +2125,30 @@ Tree::print(std::ostream& os, int verboseLevel) const } } // namespace tree + + +//////////////////////////////////////// + +// Overload the TreeTraits struct to declare a const/non-const Tree as sparse + +template +struct TreeTraits> +{ + static const bool IsSparse = true; + static const bool IsAdaptive = false; +}; + +template +struct TreeTraits> +{ + static const bool IsSparse = true; + static const bool IsAdaptive = false; +}; + + +//////////////////////////////////////// + + } // namespace OPENVDB_VERSION_NAME } // namespace openvdb diff --git a/openvdb/openvdb/tree/ValueAccessor.h b/openvdb/openvdb/tree/ValueAccessor.h index bf749e8785..850b0cb292 100644 --- a/openvdb/openvdb/tree/ValueAccessor.h +++ b/openvdb/openvdb/tree/ValueAccessor.h @@ -1021,6 +1021,20 @@ class ValueAccessorImpl final : }; // ValueAccessorImpl } // namespace tree + + +//////////////////////////////////////// + +// Overload the TreeTraits struct to declare a const/non-const ValueAccessorImpl as sparse + +template +struct TreeTraits> +{ + static const bool IsSparse = true; + static const bool IsAdaptive = false; +}; + + } // namespace OPENVDB_VERSION_NAME } // namespace openvdb