Blender  V3.3
node_geo_curve_to_mesh.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "BKE_curves.hh"
4 
5 #include "BKE_curve_to_mesh.hh"
6 
7 #include "UI_interface.h"
8 #include "UI_resources.h"
9 
10 #include "node_geometry_util.hh"
11 
13 
15 {
16  b.add_input<decl::Geometry>(N_("Curve")).supported_type(GEO_COMPONENT_TYPE_CURVE);
17  b.add_input<decl::Geometry>(N_("Profile Curve"))
18  .only_realized_data()
19  .supported_type(GEO_COMPONENT_TYPE_CURVE);
20  b.add_input<decl::Bool>(N_("Fill Caps"))
21  .description(
22  N_("If the profile spline is cyclic, fill the ends of the generated mesh with N-gons"));
23  b.add_output<decl::Geometry>(N_("Mesh"));
24 }
25 
26 static void geometry_set_curve_to_mesh(GeometrySet &geometry_set,
27  const GeometrySet &profile_set,
28  const bool fill_caps)
29 {
30  const Curves &curves = *geometry_set.get_curves_for_read();
31  const Curves *profile_curves = profile_set.get_curves_for_read();
32 
34 
35  if (profile_curves == nullptr) {
37  geometry_set.replace_mesh(mesh);
38  }
39  else {
41  bke::CurvesGeometry::wrap(profile_curves->geometry),
42  fill_caps);
43  geometry_set.replace_mesh(mesh);
44  }
45 }
46 
48 {
49  GeometrySet curve_set = params.extract_input<GeometrySet>("Curve");
50  GeometrySet profile_set = params.extract_input<GeometrySet>("Profile Curve");
51  const bool fill_caps = params.extract_input<bool>("Fill Caps");
52 
53  bool has_curves = false;
54  curve_set.modify_geometry_sets([&](GeometrySet &geometry_set) {
55  if (geometry_set.has_curves()) {
56  has_curves = true;
57  geometry_set_curve_to_mesh(geometry_set, profile_set, fill_caps);
58  }
60  });
61 
62  params.set_output("Mesh", std::move(curve_set));
63 }
64 
65 } // namespace blender::nodes::node_geo_curve_to_mesh_cc
66 
68 {
70 
71  static bNodeType ntype;
72 
76  nodeRegisterType(&ntype);
77 }
Low-level operations for curves.
@ GEO_COMPONENT_TYPE_MESH
@ GEO_COMPONENT_TYPE_CURVE
#define NODE_CLASS_GEOMETRY
Definition: BKE_node.h:359
#define GEO_NODE_CURVE_TO_MESH
Definition: BKE_node.h:1401
void nodeRegisterType(struct bNodeType *ntype)
Definition: node.cc:1357
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
static void remember_deformed_curve_positions_if_necessary(GeometrySet &geometry)
static CurvesGeometry & wrap(::CurvesGeometry &dna_struct)
Definition: BKE_curves.hh:138
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
Mesh * curve_to_wire_mesh(const CurvesGeometry &curve)
Mesh * curve_to_mesh_sweep(const CurvesGeometry &main, const CurvesGeometry &profile, bool fill_caps)
static void node_declare(NodeDeclarationBuilder &b)
static void geometry_set_curve_to_mesh(GeometrySet &geometry_set, const GeometrySet &profile_set, const bool fill_caps)
static void node_geo_exec(GeoNodeExecParams params)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
void register_node_type_geo_curve_to_mesh()
void geo_node_type_base(bNodeType *ntype, int type, const char *name, short nclass)
CurvesGeometry geometry
void replace_mesh(Mesh *mesh, GeometryOwnershipType ownership=GeometryOwnershipType::Owned)
void keep_only_during_modify(const blender::Span< GeometryComponentType > component_types)
const Curves * get_curves_for_read() const
void modify_geometry_sets(ForeachSubGeometryCallback callback)
bool has_curves() const
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)