Blender V5.0
openvdb.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#ifdef WITH_OPENVDB
8# include <openvdb/openvdb.h>
9
10namespace openvdb {
11
12using Vec4fTree = tree::Tree4<Vec4f, 5, 4, 3>::Type;
13using Vec4fGrid = Grid<Vec4fTree>;
14
15} // namespace openvdb
16
18
19/* Convert to the few grid types we can render natively. */
20openvdb::GridBase::ConstPtr openvdb_convert_to_known_type(const openvdb::GridBase::ConstPtr &grid);
21
22/* Apply operation to known grid types. */
23template<typename OpType>
24bool openvdb_grid_type_operation(const openvdb::GridBase::ConstPtr &grid, OpType &&op)
25{
26 if (grid->isType<openvdb::FloatGrid>()) {
27 return op.template operator()<openvdb::FloatGrid, float, 1>(
28 openvdb::gridConstPtrCast<openvdb::FloatGrid>(grid));
29 }
30 if (grid->isType<openvdb::Vec3fGrid>()) {
31 return op.template operator()<openvdb::Vec3fGrid, openvdb::Vec3f, 3>(
32 openvdb::gridConstPtrCast<openvdb::Vec3fGrid>(grid));
33 }
34 if (grid->isType<openvdb::Vec4fGrid>()) {
35 return op.template operator()<openvdb::Vec4fGrid, openvdb::Vec4f, 4>(
36 openvdb::gridConstPtrCast<openvdb::Vec4fGrid>(grid));
37 }
38 assert(0);
39 return false;
40}
41
42/* Count number of channels in known types. */
43int openvdb_num_channels(const openvdb::GridBase::ConstPtr &grid);
44
46
47#endif
nullptr float
#define CCL_NAMESPACE_END
#define assert(assertion)