Blender  V3.3
bmo_beautify.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
10 #include "BLI_math.h"
11 
12 #include "MEM_guardedalloc.h"
13 
14 #include "bmesh.h"
15 #include "bmesh_tools.h"
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 
42  BM_ITER_MESH (e, &iter, bm, BM_EDGES_OF_MESH) {
44  }
45 
46  /* will over alloc if some edges can't be rotated */
47  edge_array = 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 */
53  if (BM_edge_rotate_check(e) &&
54  /* faces are tagged */
55  BMO_face_flag_test(bm, e->l->f, FACE_MARK) &&
56  BMO_face_flag_test(bm, e->l->radial_next->f, FACE_MARK)) {
57  edge_array[edge_array_len] = e;
58  edge_array_len++;
59  }
60  }
61 
63  bm, edge_array, edge_array_len, flag, method, ELE_NEW, FACE_MARK | ELE_NEW);
64 
65  MEM_freeN(edge_array);
66 
68 }
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_FACE
Definition: bmesh_class.h:386
@ BM_EDGE
Definition: bmesh_class.h:384
@ BM_ELEM_TAG
Definition: bmesh_class.h:484
#define BM_elem_flag_disable(ele, hflag)
Definition: bmesh_inline.h:15
#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.
Definition: bmesh_mods.c:661
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
Definition: bmo_beautify.c:18
#define FACE_MARK
Definition: bmo_beautify.c:19
void bmo_beautify_fill_exec(BMesh *bm, BMOperator *op)
Definition: bmo_beautify.c:21
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:33
int len
Definition: bmesh_class.h:267
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]