OpenVDB 11.0.0
Loading...
Searching...
No Matches
PointMove.h
Go to the documentation of this file.
1// Copyright Contributors to the OpenVDB Project
2// SPDX-License-Identifier: MPL-2.0
3
4/// @author Dan Bailey
5///
6/// @file PointMove.h
7///
8/// @brief Ability to move VDB Points using a custom deformer.
9///
10/// Deformers used when moving points are in world space by default and must adhere
11/// to the interface described in the example below:
12/// @code
13/// struct MyDeformer
14/// {
15/// // A reset is performed on each leaf in turn before the points in that leaf are
16/// // deformed. A leaf and leaf index (standard leaf traversal order) are supplied as
17/// // the arguments, which matches the functor interface for LeafManager::foreach().
18/// template <typename LeafNoteType>
19/// void reset(LeafNoteType& leaf, size_t idx);
20///
21/// // Evaluate the deformer and modify the given position to generate the deformed
22/// // position. An index iterator is supplied as the argument to allow querying the
23/// // point offset or containing voxel coordinate.
24/// template <typename IndexIterT>
25/// void apply(Vec3d& position, const IndexIterT& iter) const;
26/// };
27/// @endcode
28///
29/// @note The DeformerTraits struct (defined in PointMask.h) can be used to configure
30/// a deformer to evaluate in index space.
31
32#ifndef OPENVDB_POINTS_POINT_MOVE_HAS_BEEN_INCLUDED
33#define OPENVDB_POINTS_POINT_MOVE_HAS_BEEN_INCLUDED
34
35#include <openvdb/openvdb.h>
36
37#include "PointDataGrid.h"
38#include "PointMask.h"
39
40#include <tbb/concurrent_vector.h>
41
42#include <algorithm>
43#include <iterator> // for std::begin(), std::end()
44#include <map>
45#include <numeric> // for std::iota()
46#include <tuple>
47#include <unordered_map>
48#include <vector>
49
50namespace openvdb {
52namespace OPENVDB_VERSION_NAME {
53namespace points {
54
55// dummy object for future use
56namespace future { struct Advect { }; }
57
58/// @brief Move points in a PointDataGrid using a custom deformer
59/// @param points the PointDataGrid containing the points to be moved.
60/// @param deformer a custom deformer that defines how to move the points.
61/// @param filter an optional index filter
62/// @param objectNotInUse for future use, this object is currently ignored
63/// @param threaded enable or disable threading (threading is enabled by default)
64template <typename PointDataGridT, typename DeformerT, typename FilterT = NullFilter>
65inline void movePoints(PointDataGridT& points,
66 DeformerT& deformer,
67 const FilterT& filter = NullFilter(),
68 future::Advect* objectNotInUse = nullptr,
69 bool threaded = true);
70
71
72/// @brief Move points in a PointDataGrid using a custom deformer and a new transform
73/// @param points the PointDataGrid containing the points to be moved.
74/// @param transform target transform to use for the resulting points.
75/// @param deformer a custom deformer that defines how to move the points.
76/// @param filter an optional index filter
77/// @param objectNotInUse for future use, this object is currently ignored
78/// @param threaded enable or disable threading (threading is enabled by default)
79template <typename PointDataGridT, typename DeformerT, typename FilterT = NullFilter>
80inline void movePoints(PointDataGridT& points,
81 const math::Transform& transform,
82 DeformerT& deformer,
83 const FilterT& filter = NullFilter(),
84 future::Advect* objectNotInUse = nullptr,
85 bool threaded = true);
86
87} // namespace points
88} // namespace OPENVDB_VERSION_NAME
89} // namespace openvdb
90
91#include "impl/PointMoveImpl.h"
92
93#endif // OPENVDB_POINTS_POINT_MOVE_HAS_BEEN_INCLUDED
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
Methods for extracting masks from VDB Point grids.
Definition Transform.h:40
A no-op filter that can be used when iterating over all indices.
Definition IndexIterator.h:51
void movePoints(PointDataGridT &points, DeformerT &deformer, const FilterT &filter=NullFilter(), future::Advect *objectNotInUse=nullptr, bool threaded=true)
Move points in a PointDataGrid using a custom deformer.
Definition PointMoveImpl.h:619
Definition Exceptions.h:13
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:212