Blender V5.0
node_geo_input_mesh_edge_neighbors.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
5#include "BLI_array_utils.hh"
6
7#include "DNA_mesh_types.h"
8
10
12
14{
15 b.add_output<decl::Int>("Face Count")
16 .field_source()
17 .description("The number of faces that use each edge as one of their sides");
18}
19
21 public:
23 : bke::MeshFieldInput(CPPType::get<int>(), "Edge Neighbor Count Field")
24 {
26 }
27
29 const AttrDomain domain,
30 const IndexMask & /*mask*/) const final
31 {
32 Array<int> counts(mesh.edges_num, 0);
33 array_utils::count_indices(mesh.corner_edges(), counts);
34 return mesh.attributes().adapt_domain<int>(
35 VArray<int>::from_container(std::move(counts)), AttrDomain::Edge, domain);
36 }
37
38 uint64_t hash() const override
39 {
40 /* Some random constant hash. */
41 return 985671075;
42 }
43
44 bool is_equal_to(const fn::FieldNode &other) const override
45 {
46 return dynamic_cast<const EdgeNeighborCountFieldInput *>(&other) != nullptr;
47 }
48
49 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const override
50 {
51 return AttrDomain::Edge;
52 }
53};
54
56{
57 Field<int> neighbor_count_field{std::make_shared<EdgeNeighborCountFieldInput>()};
58 params.set_output("Face Count", std::move(neighbor_count_field));
59}
60
61static void node_register()
62{
63 static blender::bke::bNodeType ntype;
65 &ntype, "GeometryNodeInputMeshEdgeNeighbors", GEO_NODE_INPUT_MESH_EDGE_NEIGHBORS);
66 ntype.ui_name = "Edge Neighbors";
67 ntype.ui_description = "Retrieve the number of faces that use each edge as one of their sides";
68 ntype.enum_name_legacy = "MESH_EDGE_NEIGHBORS";
70 ntype.declare = node_declare;
73}
75
76} // namespace blender::nodes::node_geo_input_mesh_edge_neighbors_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:447
#define GEO_NODE_INPUT_MESH_EDGE_NEIGHBORS
#define final(a, b, c)
Definition BLI_hash.h:19
#define NOD_REGISTER_NODE(REGISTER_FUNC)
unsigned long long int uint64_t
static VArray from_container(ContainerT container)
GVArray get_varray_for_context(const Mesh &mesh, const AttrDomain domain, const IndexMask &) const final
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void count_indices(Span< int > indices, MutableSpan< int > counts)
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)
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