10# include "openvdb/tools/LevelSetFilter.h"
17 b.use_custom_socket_order();
18 b.allow_any_socket_order();
20 b.add_output<
decl::Float>(
"Grid").structure_type(StructureType::Grid).align_with_previous();
24 .
description(
"Number of iterations to apply the filter");
32 params.set_default_remaining_outputs();
36 const int iterations =
params.extract_input<
int>(
"Iterations");
37 if (iterations <= 0) {
38 params.set_output(
"Grid", std::move(grid));
42 bke::VolumeTreeAccessToken tree_token;
43 openvdb::FloatGrid &vdb_grid = grid.grid_for_write(tree_token);
46 openvdb::tools::LevelSetFilter<openvdb::FloatGrid>
filter(vdb_grid);
47 for (
int i = 0;
i < iterations;
i++) {
51 catch (
const openvdb::RuntimeError & ) {
56 params.set_output(
"Grid", std::move(grid));
66 ntype.
ui_name =
"SDF Grid Laplacian";
68 "Apply Laplacian flow smoothing to a signed distance field. Computationally efficient "
69 "alternative to mean curvature flow, ideal when combined with SDF normalization";
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
StructureType structure_type
void node_register_type(bNodeType &ntype)
static void node_geo_exec(GeoNodeExecParams params)
static void node_register()
static void node_declare(NodeDeclarationBuilder &b)
void node_geo_sdf_grid_error_not_levelset(GeoNodeExecParams ¶ms)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare