Blender V5.3
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"_ustr)
16 .structure_type(StructureType::Field)
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 {
25 }
26
28 const AttrDomain domain,
29 const IndexMask & /*mask*/) const final
30 {
31 Array<int> counts(mesh.edges_num, 0);
32 array_utils::count_indices(mesh.corner_edges(), counts);
33 return mesh.attributes().adapt_domain<int>(
34 VArray<int>::from_container(std::move(counts)), AttrDomain::Edge, domain);
35 }
36
37 void hash_unique(UniqueHashBytes &hash, fn::FieldHashDeep & /*deep_hash_cache*/) const override
38 {
39 static constexpr int8_t id = 0;
40 hash.add(&id);
41 }
42
43 std::optional<AttrDomain> preferred_domain(const Mesh & /*mesh*/) const override
44 {
45 return AttrDomain::Edge;
46 }
47};
48
50{
52}
53
54static void node_register()
55{
56 static bke::bNodeType ntype;
58 &ntype, "GeometryNodeInputMeshEdgeNeighbors"_ustr, GEO_NODE_INPUT_MESH_EDGE_NEIGHBORS);
59 ntype.ui_name = "Edge Neighbors";
60 ntype.ui_description = "Retrieve the number of faces that use each edge as one of their sides";
61 ntype.enum_name_legacy = "MESH_EDGE_NEIGHBORS";
63 ntype.declare = node_declare;
66}
68
69} // namespace blender::nodes::node_geo_input_mesh_edge_neighbors_cc
#define NODE_CLASS_INPUT
Definition BKE_node.hh:478
#define GEO_NODE_INPUT_MESH_EDGE_NEIGHBORS
#define final(a, b, c)
Definition BLI_hash_c.hh:21
#define NOD_REGISTER_NODE(REGISTER_FUNC)
static VArray from_container(ContainerT container)
uint64_t hash() const
Definition field.cc:185
static Field from_input(Args &&...args)
void set_output(const UString identifier, T &&value)
GVArray get_varray_for_context(const Mesh &mesh, const AttrDomain domain, const IndexMask &) const final
void count_indices(Span< int > indices, MutableSpan< int > counts)
void node_register_type(bNodeType &ntype)
Definition node.cc:2920
void geo_node_type_base(bke::bNodeType *ntype, UString idname, const std::optional< int16_t > legacy_type)
signed char int8_t
Definition BKE_text.h:76
Defines a node type.
Definition BKE_node.hh:265
std::string ui_description
Definition BKE_node.hh:271
NodeGeometryExecFunction geometry_node_execute
Definition BKE_node.hh:385
const char * enum_name_legacy
Definition BKE_node.hh:274
NodeDeclareFunction declare
Definition BKE_node.hh:393