OpenVDB 12.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: Apache-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#include <openvdb/util/Assert.h>
37
38#include "PointDataGrid.h"
39#include "PointMask.h"
40
41#include <tbb/concurrent_vector.h>
42
43#include <algorithm>
44#include <iterator> // for std::begin(), std::end()
45#include <map>
46#include <numeric> // for std::iota()
47#include <tuple>
48#include <unordered_map>
49#include <vector>
50
51namespace openvdb {
53namespace OPENVDB_VERSION_NAME {
54namespace points {
55
56// dummy object for future use
57namespace future { struct Advect { }; }
58
59/// @brief Move points in a PointDataGrid using a custom deformer
60/// @param points the PointDataGrid containing the points to be moved.
61/// @param deformer a custom deformer that defines how to move the points.
62/// @param filter an optional index filter
63/// @param objectNotInUse for future use, this object is currently ignored
64/// @param threaded enable or disable threading (threading is enabled by default)
65template <typename PointDataGridT, typename DeformerT, typename FilterT = NullFilter>
66inline void movePoints(PointDataGridT& points,
67 DeformerT& deformer,
68 const FilterT& filter = NullFilter(),
69 future::Advect* objectNotInUse = nullptr,
70 bool threaded = true);
71
72
73/// @brief Move points in a PointDataGrid using a custom deformer and a new transform
74/// @param points the PointDataGrid containing the points to be moved.
75/// @param transform target transform to use for the resulting points.
76/// @param deformer a custom deformer that defines how to move the points.
77/// @param filter an optional index filter
78/// @param objectNotInUse for future use, this object is currently ignored
79/// @param threaded enable or disable threading (threading is enabled by default)
80template <typename PointDataGridT, typename DeformerT, typename FilterT = NullFilter>
81inline void movePoints(PointDataGridT& points,
82 const math::Transform& transform,
83 DeformerT& deformer,
84 const FilterT& filter = NullFilter(),
85 future::Advect* objectNotInUse = nullptr,
86 bool threaded = true);
87
88} // namespace points
89} // namespace OPENVDB_VERSION_NAME
90} // namespace openvdb
91
92#include "impl/PointMoveImpl.h"
93
94#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:52
A container for ABI=5 to help ease introduction of upcoming features.
Definition AttributeSet.h:294
Definition AttributeArray.h:42
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:218