Blender V4.3
bmo_beautify.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
12#include "MEM_guardedalloc.h"
13
14#include "bmesh.hh"
15#include "bmesh_tools.hh"
17
18#define ELE_NEW 1
19#define FACE_MARK 2
20
22{
23 BMIter iter;
24 BMOIter siter;
25 BMFace *f;
26 BMEdge *e;
27 const bool use_restrict_tag = BMO_slot_bool_get(op->slots_in, "use_restrict_tag");
28 const short flag =
29 ((use_restrict_tag ? VERT_RESTRICT_TAG : 0) |
30 /* Enable to avoid iterative edge rotation to cause the direction of faces to flip. */
32 const short method = short(BMO_slot_int_get(op->slots_in, "method"));
33
34 BMEdge **edge_array;
35 int edge_array_len = 0;
36 BMO_ITER (f, &siter, op->slots_in, "faces", BM_FACE) {
37 if (f->len == 3) {
39 }
40 }
41
44 }
45
46 /* will over alloc if some edges can't be rotated */
47 edge_array = static_cast<BMEdge **>(MEM_mallocN(
48 sizeof(*edge_array) * size_t(BMO_slot_buffer_len(op->slots_in, "edges")), __func__));
49
50 BMO_ITER (e, &siter, op->slots_in, "edges", BM_EDGE) {
51
52 /* edge is manifold and can be rotated */
54 /* faces are tagged */
56 BMO_face_flag_test(bm, e->l->radial_next->f, FACE_MARK))
57 {
58 edge_array[edge_array_len] = e;
59 edge_array_len++;
60 }
61 }
62
64 bm, edge_array, edge_array_len, flag, method, ELE_NEW, FACE_MARK | ELE_NEW);
65
66 MEM_freeN(edge_array);
67
69}
Read Guarded memory(de)allocation.
void BM_mesh_beautify_fill(BMesh *bm, BMEdge **edge_array, const int edge_array_len, const short flag, const short method, const short oflag_edge, const short oflag_face)
@ EDGE_RESTRICT_DEGENERATE
@ VERT_RESTRICT_TAG
@ BM_ELEM_TAG
#define BM_elem_flag_disable(ele, hflag)
#define BM_ITER_MESH(ele, iter, bm, itype)
@ BM_EDGES_OF_MESH
ATTR_WARN_UNUSED_RESULT BMesh * bm
bool BM_edge_rotate_check(BMEdge *e)
Check if Rotate Edge is OK.
#define BM_FACE
#define BM_EDGE
void BMO_slot_buffer_from_enabled_flag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, short oflag)
#define BMO_face_flag_enable(bm, e, oflag)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
int BMO_slot_buffer_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
#define BMO_face_flag_test(bm, e, oflag)
bool BMO_slot_bool_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
#define ELE_NEW
#define FACE_MARK
void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
void *(* MEM_mallocN)(size_t len, const char *str)
Definition mallocn.cc:44
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]
uint8_t flag
Definition wm_window.cc:138