OpenVDB 13.0.0

Loading...
Searching...
No Matches
PointRasterizeTrilinear.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 Nick Avramoussis
5///
6/// @file PointRasterizeTrilinear.h
7///
8/// @brief Transfer schemes for rasterizing point data
9///
10
11#ifndef OPENVDB_POINTS_RASTERIZE_TRILINEAR_HAS_BEEN_INCLUDED
12#define OPENVDB_POINTS_RASTERIZE_TRILINEAR_HAS_BEEN_INCLUDED
13
14#include <openvdb/openvdb.h>
15#include <openvdb/Types.h>
16#include <openvdb/Grid.h>
17#include <openvdb/math/Math.h>
18#include <openvdb/math/Transform.h>
19#include <openvdb/tools/Morphology.h>
20#include <openvdb/tree/ValueAccessor.h>
21#include <openvdb/util/Assert.h>
22
23#include "PointDataGrid.h"
24#include "PointMask.h"
25#include "PointTransfer.h"
26
27#include <string>
28
29 namespace openvdb {
30 OPENVDB_USE_VERSION_NAMESPACE
31 namespace OPENVDB_VERSION_NAME {
32 namespace points {
33
34///
35 template <typename ValueT, bool Staggered = true>
36 struct TrilinearTraits
37{
38 using ResultT = typename std::conditional<
39 VecTraits<ValueT>::IsVec, ValueT, math::Vec3<ValueT>>::type;
40 template <typename PointDataTreeT>
41 using TreeT = typename PointDataTreeT::template ValueConverter<ResultT>::Type;
42};
43
44///
45 template <typename ValueT>
46 struct TrilinearTraits<ValueT, false>
47{
48 using ResultT = ValueT;
49 template <typename PointDataTreeT>
50 using TreeT = typename PointDataTreeT::template ValueConverter<ResultT>::Type;
51};
52
53/// @brief Perform weighted trilinear rasterization of all points within a
54/// voxel. This method takes and returns a tree i.e. ignores grid
55/// transformations.
56/// @details Accumulates values and weights according to a simple 0-1-0 weighted
57/// hat function. This algorithm is an exact inverse of a trilinear
58/// interpolation and thus a key method used in PIC/FLIP style simulations.
59/// Returns a tree of the same precision as the input source attribute, but
60/// may be of a different math type depending on the value of the Staggered
61/// template attribute. If Staggered is true, this method produces values at
62/// each voxels negative faces, causing scalar attributes to produce
63/// math::Vec3<ValueT> tree types. The result Tree type is equal to:
64/// TrilinearTraits<ValueT, Staggered>::template TreeT<PointDataTreeT>
65/// @tparam Staggered whether to perform a staggered or collocated rasterization
66/// @tparam ValueT the value type of the point attribute to rasterize
67/// @param points the point tree to be rasterized
68/// @param attribute the name of the attribute to rasterize. Must be a scalar
69/// or Vec3 attribute.
70/// @param filter an optional point filter to use
71 template <bool Staggered,
72 typename ValueT,
73 typename FilterT = NullFilter,
74 typename PointDataTreeT = PointDataTree>
75 inline auto
76 rasterizeTrilinear(const PointDataTreeT& points,
77 const std::string& attribute,
78 const FilterT& filter = NullFilter());
79
80} // namespace points
81} // namespace OPENVDB_VERSION_NAME
82} // namespace openvdb
83
84#include "impl/PointRasterizeTrilinearImpl.h"
85
86#endif //OPENVDB_POINTS_RASTERIZE_TRILINEAR_HAS_BEEN_INCLUDED
Assert.h
Grid.h
Math.h
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Morphology.h
Implementation of morphological dilation and erosion.
PointDataGrid.h
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
PointMask.h
Methods for extracting masks from VDB Point grids.
PointRasterizeTrilinearImpl.h
PointTransfer.h
Framework methods for rasterizing PointDataGrid data to Trees.
Transform.h
ValueAccessor.h
ValueAccessors are designed to help accelerate accesses into the OpenVDB Tree structures by storing c...
openvdb::v13_0::math::Vec3
Definition Vec3.h:25
openvdb::v13_0::points::NullFilter
A no-op filter that can be used when iterating over all indices.
Definition IndexIterator.h:52
openvdb::v13_0::points
Definition AttributeArray.h:42
openvdb::v13_0::points::rasterizeTrilinear
auto rasterizeTrilinear(const PointDataTreeT &points, const std::string &attribute, const FilterT &filter=NullFilter())
Perform weighted trilinear rasterization of all points within a voxel. This method takes and returns ...
Definition PointRasterizeTrilinearImpl.h:350
openvdb::v13_0::points::PointDataTree
tree::Tree< tree::RootNode< tree::InternalNode< tree::InternalNode< PointDataLeafNode< PointDataIndex32, 3 >, 4 >, 5 > > > PointDataTree
Point index tree configured to match the default VDB configurations.
Definition PointDataGrid.h:190
openvdb
Definition Exceptions.h:13
Types.h
openvdb.h
openvdb::v13_0::VecTraits::IsVec
static const bool IsVec
Definition Types.h:297
openvdb::v13_0::points::TrilinearTraits< ValueT, false >::TreeT
typename PointDataTreeT::template ValueConverter< ResultT >::Type TreeT
Definition PointRasterizeTrilinear.h:50
openvdb::v13_0::points::TrilinearTraits< ValueT, false >::ResultT
ValueT ResultT
Definition PointRasterizeTrilinear.h:48
openvdb::v13_0::points::TrilinearTraits
Definition PointRasterizeTrilinear.h:37
openvdb::v13_0::points::TrilinearTraits::ResultT
typename std::conditional< VecTraits< ValueT >::IsVec, ValueT, math::Vec3< ValueT > >::type ResultT
Definition PointRasterizeTrilinear.h:38
openvdb::v13_0::points::TrilinearTraits::TreeT
typename PointDataTreeT::template ValueConverter< ResultT >::Type TreeT
Definition PointRasterizeTrilinear.h:41
OPENVDB_VERSION_NAME
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
OPENVDB_USE_VERSION_NAMESPACE
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218