Blender
V3.3
|
Enumerations | |
enum class | EdgeType : int8_t { Loose = 0 , Boundary = 1 , Normal = 2 , NonManifold = 3 } |
enum class | VertexType : int8_t { Loose = 0 , Normal = 1 , Boundary = 2 , NonManifold = 3 } |
Functions | |
static void | node_declare (NodeDeclarationBuilder &b) |
static EdgeType | get_edge_type_with_added_neighbor (EdgeType old_type) |
static VertexType | get_vertex_type_with_added_neighbor (VertexType old_type) |
template<typename T > | |
static void | copy_data_based_on_vertex_types (Span< T > data, MutableSpan< T > r_data, const Span< VertexType > vertex_types, const bool keep_boundaries) |
template<typename T > | |
static void | copy_data_based_on_pairs (Span< T > data, MutableSpan< T > r_data, const Span< std::pair< int, int >> new_to_old_map) |
template<typename T > | |
static void | copy_data_based_on_new_to_old_map (Span< T > data, MutableSpan< T > r_data, const Span< int > new_to_old_map) |
static void | transfer_attributes (const Map< AttributeIDRef, AttributeKind > &attributes, const Span< VertexType > vertex_types, const bool keep_boundaries, const Span< int > new_to_old_edges_map, const Span< int > new_to_old_face_corners_map, const Span< std::pair< int, int >> boundary_vertex_to_relevant_face_map, const AttributeAccessor src_attributes, MutableAttributeAccessor dst_attributes) |
static void | calc_boundaries (const Mesh &mesh, MutableSpan< VertexType > r_vertex_types, MutableSpan< EdgeType > r_edge_types) |
static void | create_vertex_poly_map (const Mesh &mesh, MutableSpan< Vector< int >> r_vertex_poly_indices) |
static bool | sort_vertex_polys (const Mesh &mesh, const int vertex_index, const bool boundary_vertex, const Span< EdgeType > edge_types, MutableSpan< int > connected_polygons, MutableSpan< int > r_shared_edges, MutableSpan< int > r_sorted_corners) |
static void | boundary_edge_on_poly (const MPoly &poly, const Mesh &mesh, const int vertex_index, const Span< EdgeType > edge_types, int &r_edge) |
static void | boundary_edges_on_poly (const MPoly &poly, const Mesh &mesh, const int vertex_index, const Span< EdgeType > edge_types, int &r_edge1, int &r_edge2) |
static void | add_edge (const Mesh &mesh, const int old_edge_i, const int v1, const int v2, Vector< int > &new_to_old_edges_map, Vector< MEdge > &new_edges, Vector< int > &loop_edges) |
static bool | vertex_needs_dissolving (const int vertex, const int first_poly_index, const int second_poly_index, const Span< VertexType > vertex_types, const Span< Vector< int >> vertex_poly_indices) |
static void | dissolve_redundant_verts (const Mesh &mesh, const Span< Vector< int >> vertex_poly_indices, MutableSpan< VertexType > vertex_types, MutableSpan< int > old_to_new_edges_map, Vector< MEdge > &new_edges, Vector< int > &new_to_old_edges_map) |
static void | calc_dual_mesh (GeometrySet &geometry_set, const MeshComponent &in_component, const bool keep_boundaries) |
static void | node_geo_exec (GeoNodeExecParams params) |
|
strong |
Enumerator | |
---|---|
Loose | |
Boundary | |
Normal | |
NonManifold |
Definition at line 26 of file node_geo_dual_mesh.cc.
|
strong |
Enumerator | |
---|---|
Loose | |
Normal | |
Boundary | |
NonManifold |
Definition at line 48 of file node_geo_dual_mesh.cc.
|
static |
Definition at line 513 of file node_geo_dual_mesh.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), Mesh::medge, mesh, blender::nodes::node_geo_extrude_mesh_cc::new_edge(), blender::Vector< T, InlineBufferCapacity, Allocator >::size(), v1, MEdge::v1, v2, and MEdge::v2.
|
static |
Get the edge on the poly that contains the given vertex and is a boundary edge.
Definition at line 457 of file node_geo_dual_mesh.cc.
References Boundary, MPoly::loopstart, Mesh::medge, mesh, Mesh::mloop, and MPoly::totloop.
|
static |
Get the two edges on the poly that contain the given vertex and are boundary edges. The orientation of the poly is taken into account.
Definition at line 478 of file node_geo_dual_mesh.cc.
References Boundary, MPoly::loopstart, Mesh::medge, mesh, Mesh::mloop, and MPoly::totloop.
|
static |
Calculates the boundaries of the mesh. Boundary polygons are not computed since we don't need them later on. We use the following definitions:
Definition at line 206 of file node_geo_dual_mesh.cc.
References BLI_assert, Boundary, blender::MutableSpan< T >::fill(), get_edge_type_with_added_neighbor(), get_vertex_type_with_added_neighbor(), MPoly::loopstart, Loose, Mesh::medge, mesh, Mesh::mloop, Mesh::mpoly, NonManifold, Normal, blender::MutableSpan< T >::size(), Mesh::totedge, MPoly::totloop, Mesh::totpoly, and Mesh::totvert.
Referenced by calc_dual_mesh().
|
static |
Calculate the barycentric dual of a mesh. The dual is only "dual" in terms of connectivity, i.e. applying the function twice will give the same vertices, edges, and faces, but not the same positions. When the option "Keep Boundaries" is selected the connectivity is no longer dual.
For the dual mesh of a manifold input mesh:
Some special cases are needed for boundaries and non-manifold geometry.
The code handles boundary vertices like the vertex marked "V" in the diagram below. The first thing that happens is ordering the faces f1,f2 and f3 (stored in loop_indices), together with their shared edges e3 and e4 (which get stored in shared_edges). The ordering could end up being clockwise or counterclockwise, for this we'll assume that the ordering f1->f2->f3 is chosen. After that we add the edges in between the polygons, in this case the edges f1–f2, and f2–f3. Now we need to merge these with the boundary edges e1 and e2. To do this we create an edge from f3 to the midpoint of e2 (computed in a previous step), from this midpoint to V, from V to the midpoint of e1 and from the midpoint of e1 to f1.
Definition at line 615 of file node_geo_dual_mesh.cc.
References calc_boundaries(), create_vertex_poly_map(), GeometrySet::gather_attributes_for_propagation(), GEO_COMPONENT_TYPE_MESH, MeshComponent::get_for_read(), blender::Array< T, InlineBufferCapacity, Allocator >::index_range(), blender::threading::parallel_for(), Mesh::totedge, and Mesh::totvert.
Referenced by node_geo_exec().
|
static |
Definition at line 110 of file node_geo_dual_mesh.cc.
References data, and blender::MutableSpan< T >::index_range().
Referenced by transfer_attributes().
|
static |
Definition at line 99 of file node_geo_dual_mesh.cc.
References data.
Referenced by transfer_attributes().
|
static |
Definition at line 73 of file node_geo_dual_mesh.cc.
References Boundary, data, ELEM, and Normal.
Referenced by transfer_attributes().
|
static |
Stores the indices of the polygons connected to each vertex.
Definition at line 258 of file node_geo_dual_mesh.cc.
References MPoly::loopstart, mesh, Mesh::mloop, Mesh::mpoly, MPoly::totloop, and Mesh::totpoly.
Referenced by calc_dual_mesh().
|
static |
Finds 'normal' vertices which are connected to only two polygons and marks them to not be used in the data-structures derived from the mesh. For each pair of polygons which has such a vertex, an edge is created for the dual mesh between the centers of those two polygons. All edges in the input mesh which contain such a vertex are marked as 'done' to prevent duplicate edges being created. (See T94144)
Definition at line 552 of file node_geo_dual_mesh.cc.
References blender::Vector< T, InlineBufferCapacity, Allocator >::append(), MPoly::loopstart, Loose, Mesh::medge, mesh, Mesh::mloop, Mesh::mpoly, blender::nodes::node_geo_extrude_mesh_cc::new_edge(), Normal, blender::Vector< T, InlineBufferCapacity, Allocator >::size(), size(), MPoly::totloop, Mesh::totvert, v1, MEdge::v1, v2, MEdge::v2, and vertex_needs_dissolving().
|
static |
Definition at line 33 of file node_geo_dual_mesh.cc.
References BLI_assert_unreachable, Boundary, Loose, NonManifold, and Normal.
Referenced by calc_boundaries().
|
static |
Definition at line 55 of file node_geo_dual_mesh.cc.
References BLI_assert_unreachable, Boundary, Loose, NonManifold, and Normal.
Referenced by calc_boundaries().
|
static |
Definition at line 15 of file node_geo_dual_mesh.cc.
References usdtokens::b(), blender::nodes::SocketDeclaration::description(), and GEO_COMPONENT_TYPE_MESH.
Referenced by register_node_type_geo_dual_mesh().
|
static |
Definition at line 901 of file node_geo_dual_mesh.cc.
References calc_dual_mesh(), component(), GeometrySet::get_component_for_read(), GeometrySet::has_mesh(), GeometrySet::modify_geometry_sets(), and params.
Referenced by register_node_type_geo_dual_mesh().
|
static |
Sorts the polygons connected to the given vertex based on polygon adjacency. The ordering is so such that the normals point in the same way as the original mesh. If the vertex is a boundary vertex, the first and last polygon have a boundary edge connected to the vertex. The r_shared_edges
array at index i is set to the index of the shared edge between the i-th and (i+1)-th
sorted polygon. Similarly the r_sorted_corners
array at index i is set to the corner in the i-th sorted polygon. If the polygons couldn't be sorted, false
is returned.
How the faces are sorted (see diagrams below): (For this explanation we'll assume all faces are oriented clockwise) (The vertex whose connected polygons we need to sort is "v0")
shared_edge_i
which indicates the index of the shared edge between this polygon and the next one. There are two possible choices: v0<->v4 and v2<->v0. To choose we look at the corners. Since the edge v0<->v2 lies on the corner which has v0, we set shared_edge_i
to the other edge (v0<->v4), such that the next face will be "f1" which is the next face in clockwise order.r_sorted_corners
. This will simply be the corner which doesn't contain the shared edge.Definition at line 324 of file node_geo_dual_mesh.cc.
References BLI_assert, Boundary, MLoop::e, blender::Array< T, InlineBufferCapacity, Allocator >::first(), blender::MutableSpan< T >::index_range(), blender::MutableSpan< T >::last(), MPoly::loopstart, Mesh::medge, mesh, Mesh::mloop, Mesh::mpoly, blender::MutableSpan< T >::size(), swap(), MPoly::totloop, MLoop::v, MEdge::v1, and MEdge::v2.
|
static |
Transfers the attributes from the original mesh to the new mesh using the following logic:
new_to_old_edges_map
. We have to do it in this reverse order, because there can be more edges in the new mesh if keep boundaries is on.Some of the vertices (on the boundary) in the dual mesh don't come from faces, but from edges or vertices. For these the boundary_vertex_to_relevant_face_map
is used, which maps them to the closest face.
Definition at line 139 of file node_geo_dual_mesh.cc.
References ATTR_DOMAIN_EDGE, ATTR_DOMAIN_FACE, ATTR_DOMAIN_POINT, blender::attribute_math::convert_to_static_type(), copy_data_based_on_new_to_old_map(), copy_data_based_on_pairs(), copy_data_based_on_vertex_types(), blender::bke::cpp_type_to_custom_data_type(), blender::bke::GAttributeReader::domain, blender::bke::GSpanAttributeWriter::finish(), blender::Map< Key, Value, InlineBufferCapacity, ProbingStrategy, Hash, IsEqual, Slot, Allocator >::items(), blender::bke::AttributeAccessor::lookup(), blender::bke::MutableAttributeAccessor::lookup_or_add_for_write_only_span(), blender::bke::GSpanAttributeWriter::span, T, blender::MutableSpan< T >::take_front(), blender::GVArrayCommon::type(), blender::GMutableSpan::typed(), blender::GVArray::typed(), and blender::bke::GAttributeReader::varray.
|
static |
Definition at line 531 of file node_geo_dual_mesh.cc.
References Boundary, and size().
Referenced by dissolve_redundant_verts().