Blender V5.0
node_geo_separate_components.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
6
8
10{
11 b.add_input<decl::Geometry>("Geometry")
12 .description("Geometry to split into separate components");
13 b.add_output<decl::Geometry>("Mesh").propagate_all();
14 b.add_output<decl::Geometry>("Curve").propagate_all();
15 b.add_output<decl::Geometry>("Grease Pencil").propagate_all();
16 b.add_output<decl::Geometry>("Point Cloud").propagate_all();
17 b.add_output<decl::Geometry>("Volume")
18 .translation_context(BLT_I18NCONTEXT_ID_ID)
19 .propagate_all();
20 b.add_output<decl::Geometry>("Instances").propagate_all();
21}
22
24{
25 GeometrySet geometry_set = params.extract_input<GeometrySet>("Geometry");
26
27 GeometrySet meshes;
28 GeometrySet curves;
29 GeometrySet grease_pencil;
30 GeometrySet pointclouds;
31 GeometrySet volumes;
32 GeometrySet instances;
33
34 const std::string &name = geometry_set.name;
35 meshes.name = name;
36 curves.name = name;
37 grease_pencil.name = name;
38 pointclouds.name = name;
39 volumes.name = name;
40 instances.name = name;
41
42 if (geometry_set.has<MeshComponent>()) {
43 meshes.add(*geometry_set.get_component<MeshComponent>());
44 }
45 if (geometry_set.has<CurveComponent>()) {
46 curves.add(*geometry_set.get_component<CurveComponent>());
47 }
48 if (geometry_set.has<GreasePencilComponent>()) {
49 grease_pencil.add(*geometry_set.get_component<GreasePencilComponent>());
50 }
51 if (geometry_set.has<PointCloudComponent>()) {
52 pointclouds.add(*geometry_set.get_component<PointCloudComponent>());
53 }
54 if (geometry_set.has<VolumeComponent>()) {
55 volumes.add(*geometry_set.get_component<VolumeComponent>());
56 }
57 if (geometry_set.has<InstancesComponent>()) {
58 instances.add(*geometry_set.get_component<InstancesComponent>());
59 }
60
61 params.set_output("Mesh", meshes);
62 params.set_output("Curve", curves);
63 params.set_output("Grease Pencil", grease_pencil);
64 params.set_output("Point Cloud", pointclouds);
65 params.set_output("Volume", volumes);
66 params.set_output("Instances", instances);
67}
68
69static void node_register()
70{
71 static blender::bke::bNodeType ntype;
72
73 geo_node_type_base(&ntype, "GeometryNodeSeparateComponents", GEO_NODE_SEPARATE_COMPONENTS);
74 ntype.ui_name = "Separate Components";
75 ntype.ui_description =
76 "Split a geometry into a separate output for each type of data in the geometry";
77 ntype.enum_name_legacy = "SEPARATE_COMPONENTS";
79 ntype.declare = node_declare;
82}
84
85} // namespace blender::nodes::node_geo_separate_components_cc
#define NODE_CLASS_GEOMETRY
Definition BKE_node.hh:461
#define GEO_NODE_SEPARATE_COMPONENTS
#define BLT_I18NCONTEXT_ID_ID
#define NOD_REGISTER_NODE(REGISTER_FUNC)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void node_register_type(bNodeType &ntype)
Definition node.cc:2416
void geo_node_type_base(blender::bke::bNodeType *ntype, std::string idname, const std::optional< int16_t > legacy_type)
const char * name
bool has(const GeometryComponent::Type component_type) const
const GeometryComponent * get_component(GeometryComponent::Type component_type) const
void add(const GeometryComponent &component)
Defines a node type.
Definition BKE_node.hh:238
std::string ui_description
Definition BKE_node.hh:244
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:354
const char * enum_name_legacy
Definition BKE_node.hh:247
NodeDeclareFunction declare
Definition BKE_node.hh:362