Blender  V3.3
node_geo_mesh_to_curve.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "GEO_mesh_to_curve.hh"
4 
5 #include "node_geometry_util.hh"
6 
8 
10 {
11  b.add_input<decl::Geometry>(N_("Mesh")).supported_type(GEO_COMPONENT_TYPE_MESH);
12  b.add_input<decl::Bool>(N_("Selection")).default_value(true).hide_value().supports_field();
13  b.add_output<decl::Geometry>(N_("Curve"));
14 }
15 
17 {
18  GeometrySet geometry_set = params.extract_input<GeometrySet>("Mesh");
19 
20  geometry_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
21  const Mesh *mesh = geometry_set.get_mesh_for_read();
22  if (mesh == nullptr) {
23  geometry_set.remove_geometry_during_modify();
24  return;
25  }
26 
29  fn::FieldEvaluator evaluator{context, component.attribute_domain_size(ATTR_DOMAIN_EDGE)};
30  evaluator.add(params.get_input<Field<bool>>("Selection"));
31  evaluator.evaluate();
32  const IndexMask selection = evaluator.get_evaluated_as_mask(0);
33  if (selection.size() == 0) {
34  geometry_set.remove_geometry_during_modify();
35  return;
36  }
37 
39  geometry_set.replace_curves(bke::curves_new_nomain(std::move(curves)));
41  });
42 
43  params.set_output("Curve", std::move(geometry_set));
44 }
45 
46 } // namespace blender::nodes::node_geo_mesh_to_curve_cc
47 
49 {
51 
52  static bNodeType ntype;
53 
57  nodeRegisterType(&ntype);
58 }
@ ATTR_DOMAIN_EDGE
Definition: BKE_attribute.h:28
@ GEO_COMPONENT_TYPE_MESH
@ GEO_COMPONENT_TYPE_CURVE
#define NODE_CLASS_GEOMETRY
Definition: BKE_node.h:359
#define GEO_NODE_MESH_TO_CURVE
Definition: BKE_node.h:1466
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
static uint8 component(Color32 c, uint i)
Definition: ColorBlock.cpp:108
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to curves
int64_t size() const
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
Curves * curves_new_nomain(int points_num, int curves_num)
Definition: curves.cc:367
bke::CurvesGeometry mesh_to_curve_convert(const Mesh &mesh, const IndexMask selection)
static void node_geo_exec(GeoNodeExecParams params)
static void node_declare(NodeDeclarationBuilder &b)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_mesh_to_curve()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
void replace_curves(Curves *curves, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void keep_only_during_modify(const blender::Span< GeometryComponentType > component_types)
const GeometryComponent * get_component_for_read(GeometryComponentType component_type) const
const Mesh * get_mesh_for_read() const
void modify_geometry_sets(ForeachSubGeometryCallback callback)
void remove_geometry_during_modify()
Defines a node type.
Definition: BKE_node.h:226
NodeGeometryExecFunction geometry_node_execute
Definition: BKE_node.h:316
NodeDeclareFunction declare
Definition: BKE_node.h:324
#define N_(msgid)