HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointRasterizeTrilinear.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 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>
21 
22 #include "PointDataGrid.h"
23 #include "PointMask.h"
24 #include "PointTransfer.h"
25 
26 #include <string>
27 
28 namespace openvdb {
30 namespace OPENVDB_VERSION_NAME {
31 namespace points {
32 
33 ///
34 template <typename ValueT, bool Staggered = true>
36 {
37  using ResultT = typename std::conditional<
39  template <typename PointDataTreeT>
40  using TreeT = typename PointDataTreeT::template ValueConverter<ResultT>::Type;
41 };
42 
43 ///
44 template <typename ValueT>
45 struct TrilinearTraits<ValueT, false>
46 {
47  using ResultT = ValueT;
48  template <typename PointDataTreeT>
49  using TreeT = typename PointDataTreeT::template ValueConverter<ResultT>::Type;
50 };
51 
52 /// @brief Perform weighted trilinear rasterization of all points within a
53 /// voxel. This method takes and returns a tree i.e. ignores grid
54 /// transformations.
55 /// @details Accumulates values and weights according to a simple 0-1-0 weighted
56 /// hat function. This algorithm is an exact inverse of a trilinear
57 /// interpolation and thus a key method used in PIC/FLIP style simulations.
58 /// Returns a tree of the same precision as the input source attribute, but
59 /// may be of a different math type depending on the value of the Staggered
60 /// template attribute. If Staggered is true, this method produces values at
61 /// each voxels negative faces, causing scalar attributes to produce
62 /// math::Vec3<ValueT> tree types. The result Tree type is equal to:
63 /// TrilinearTraits<ValueT, Staggered>::template TreeT<PointDataTreeT>
64 /// @tparam Staggered whether to perform a staggered or collocated rasterization
65 /// @tparam ValueT the value type of the point attribute to rasterize
66 /// @param points the point tree to be rasterized
67 /// @param attribute the name of the attribute to rasterize. Must be a scalar
68 /// or Vec3 attribute.
69 /// @param filter an optional point filter to use
70 template <bool Staggered,
71  typename ValueT,
72  typename FilterT = NullFilter,
73  typename PointDataTreeT = PointDataTree>
74 inline auto
75 rasterizeTrilinear(const PointDataTreeT& points,
76  const std::string& attribute,
77  const FilterT& filter = NullFilter());
78 
79 } // namespace points
80 } // namespace OPENVDB_VERSION_NAME
81 } // namespace openvdb
82 
84 
85 #endif //OPENVDB_POINTS_RASTERIZE_TRILINEAR_HAS_BEEN_INCLUDED
GLdouble GLdouble GLint GLint const GLdouble * points
Definition: glad.h:2676
GLsizei const GLchar *const * string
Definition: glcorearb.h:814
Framework methods for rasterizing PointDataGrid data to Trees.
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:239
A no-op filter that can be used when iterating over all indices.
Definition: IndexIterator.h:50
typename PointDataTreeT::template ValueConverter< ResultT >::Type TreeT
ValueAccessors are designed to help accelerate accesses into the OpenVDB Tree structures by storing c...
auto rasterizeTrilinear(const PointDataTreeT &points, const std::string &attribute, const FilterT &filter)
Perform weighted trilinear rasterization of all points within a voxel. This method takes and returns ...
General-purpose arithmetic and comparison routines, most of which accept arbitrary value types (or at...
Methods for extracting masks from VDB Point grids.
Implementation of morphological dilation and erosion.
OIIO_API bool attribute(string_view name, TypeDesc type, const void *val)
typename std::conditional< VecTraits< ValueT >::IsVec, ValueT, math::Vec3< ValueT >>::type ResultT
typename PointDataTreeT::template ValueConverter< ResultT >::Type TreeT
type
Definition: core.h:1059
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:119
Attribute-owned data structure for points. Point attributes are stored in leaf nodes and ordered by v...
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297