Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Adaptive Grid prototype #1760

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions openvdb/openvdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,10 @@ set(OPENVDB_LIBRARY_IO_INCLUDE_FILES
io/TempFile.h
)

set(OPENVDB_LIBRARY_ADAPTIVE_INCLUDE_FILES
adaptive/AdaptiveGrid.h
)

set(OPENVDB_LIBRARY_MATH_INCLUDE_FILES
math/BBox.h
math/ConjGradient.h
Expand Down Expand Up @@ -741,6 +745,7 @@ endif()

install(FILES ${OPENVDB_LIBRARY_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/openvdb/version.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb)
install(FILES ${OPENVDB_LIBRARY_ADAPTIVE_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/adaptive)
install(FILES ${OPENVDB_LIBRARY_IO_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/io)
install(FILES ${OPENVDB_LIBRARY_MATH_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/math)
install(FILES ${OPENVDB_LIBRARY_POINTS_INCLUDE_FILES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/points)
Expand Down
18 changes: 9 additions & 9 deletions openvdb/openvdb/Grid.h
Original file line number Diff line number Diff line change
Expand Up @@ -586,10 +586,10 @@ class Grid: public GridBase
using ValueAllIter = typename _TreeType::ValueAllIter;
using ValueAllCIter = typename _TreeType::ValueAllCIter;

using Accessor = typename tree::ValueAccessor<_TreeType, true>;
using ConstAccessor = typename tree::ValueAccessor<const _TreeType, true>;
using UnsafeAccessor = typename tree::ValueAccessor<_TreeType, false>;
using ConstUnsafeAccessor = typename tree::ValueAccessor<const _TreeType, false>;
using Accessor = typename _TreeType::Accessor;
using ConstAccessor = typename _TreeType::ConstAccessor;
using UnsafeAccessor = typename _TreeType::UnsafeAccessor;
using ConstUnsafeAccessor = typename _TreeType::ConstUnsafeAccessor;

/// @brief ValueConverter<T>::Type is the type of a grid having the same
/// hierarchy as this grid but a different value type, T.
Expand Down Expand Up @@ -729,27 +729,27 @@ class Grid: public GridBase
/// @brief Return an accessor that provides random read and write access
/// to this grid's voxels.
/// @details The accessor is safe in the sense that it is registered with this grid's tree.
Accessor getAccessor() { return Accessor(tree()); }
Accessor getAccessor() { return mTree->getAccessor(); }
/// @brief Return an unsafe accessor that provides random read and write access
/// to this grid's voxels.
/// @details The accessor is unsafe in the sense that it is not registered
/// with this grid's tree. In some rare cases this can give a performance advantage
/// over a registered accessor, but it is unsafe if the tree topology is modified.
/// @warning Only use this method if you're an expert and know the
/// risks of using an unregistered accessor (see tree/ValueAccessor.h)
UnsafeAccessor getUnsafeAccessor() { return UnsafeAccessor(tree()); }
UnsafeAccessor getUnsafeAccessor() { return mTree->getUnsafeAccessor(); }
/// Return an accessor that provides random read-only access to this grid's voxels.
ConstAccessor getAccessor() const { return ConstAccessor(tree()); }
ConstAccessor getAccessor() const { return mTree->getConstAccessor(); }
/// Return an accessor that provides random read-only access to this grid's voxels.
ConstAccessor getConstAccessor() const { return ConstAccessor(tree()); }
ConstAccessor getConstAccessor() const { return mTree->getConstAccessor(); }
/// @brief Return an unsafe accessor that provides random read-only access
/// to this grid's voxels.
/// @details The accessor is unsafe in the sense that it is not registered
/// with this grid's tree. In some rare cases this can give a performance advantage
/// over a registered accessor, but it is unsafe if the tree topology is modified.
/// @warning Only use this method if you're an expert and know the
/// risks of using an unregistered accessor (see tree/ValueAccessor.h)
ConstUnsafeAccessor getConstUnsafeAccessor() const { return ConstUnsafeAccessor(tree()); }
ConstUnsafeAccessor getConstUnsafeAccessor() const { return mTree->getConstUnsafeAccessor(); }

/// Return an iterator over all of this grid's active values (tile and voxel).
ValueOnIter beginValueOn() { return tree().beginValueOn(); }
Expand Down
44 changes: 44 additions & 0 deletions openvdb/openvdb/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,30 @@ using make_index_sequence =

////////////////////////////////////////

/// @brief An enum to distinguish between different types of Tree representation.
enum class TreeRepresentation : uint32_t {Unknown = 0, Sparse = 1, Adaptive = 2, End = 3};

/// @brief A TreeTraits struct that can be used to query properties of an input T.
template<typename T>
struct TreeTraits
{
constexpr static TreeRepresentation Representation = TreeRepresentation::Unknown;
};

template <typename T>
constexpr bool isSparseTree()
{
return TreeTraits<T>::Representation == TreeRepresentation::Sparse;
}

template <typename T>
constexpr bool isAdaptiveTree()
{
return TreeTraits<T>::Representation == TreeRepresentation::Adaptive;
}

////////////////////////////////////////


template<typename T, bool = IsSpecializationOf<T, math::Vec2>::value ||
IsSpecializationOf<T, math::Vec3>::value ||
Expand Down Expand Up @@ -446,6 +470,26 @@ template<typename FromType, typename ToType> struct CopyConstness<const FromType
/// @endcond


////////////////////////////////////////

/// @brief A type-dependent expression that always evaluates to false.
/// This is used as a work-around for the much discussed problem of wanting to do:
/// if constexpr (expr) { }
/// else { static_assert(false); }
///
/// At present, C++ evaluates static_assert(false) regardless of the outcome of the
/// compile-time expression. By using a type-dependent expression, the static assert
/// is only evaluated during instantiation:
///
/// static_assert(openvdb::AlwaysFalseValue<T>);
///
/// This results in the desired outcome of generating a compile-time static assert
/// only if the first clause evaluates to false.

template<class>
inline constexpr bool AlwaysFalseValue = false;


////////////////////////////////////////


Expand Down
Loading
Loading