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"_ustr).structure_type(StructureType::Grid).align_with_previous();
28 .
description(
"Number of iterations to apply the filter");
40 const int iterations = params.
extract_input<
int>(
"Iterations"_ustr);
42 if (iterations <= 0 || width <= 0) {
43 params.
set_output(
"Grid"_ustr, std::move(grid));
47 bke::VolumeTreeAccessToken tree_token;
48 openvdb::FloatGrid &vdb_grid = grid.grid_for_write(tree_token);
51 openvdb::tools::LevelSetFilter<openvdb::FloatGrid>
filter(vdb_grid);
52 for (
int i = 0; i < iterations; i++) {
56 catch (
const openvdb::RuntimeError & ) {
61 params.
set_output(
"Grid"_ustr, std::move(grid));
71 ntype.
ui_name =
"SDF Grid Median";
73 "Apply median filter to a signed distance field. Reduces noise while preserving sharp "
74 "features and edges in the distance field";
#define NODE_CLASS_GEOMETRY
#define NOD_REGISTER_NODE(REGISTER_FUNC)
T extract_input(const UString identifier)
void set_default_remaining_outputs()
void set_output(const UString identifier, T &&value)
StructureType structure_type
void node_register_type(bNodeType &ntype)
void node_geo_sdf_grid_error_not_levelset(GeoNodeExecParams ¶ms)
void node_geo_exec_with_missing_openvdb(GeoNodeExecParams ¶ms)
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
std::string ui_description
NodeGeometryExecFunction geometry_node_execute
NodeDeclareFunction declare