Blender  V3.3
bmo_fill_holes.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
9 #include "BLI_utildefines.h"
10 
11 #include "bmesh.h"
12 #include "bmesh_tools.h"
13 
14 #include "intern/bmesh_operators_private.h" /* own include */
15 
17 {
18  BMOperator op_attr;
19  const uint sides = BMO_slot_int_get(op->slots_in, "sides");
20 
23 
24  BM_mesh_edgenet(bm, true, true); // TODO: sides
25 
26  /* bad - remove faces after as a workaround */
27  if (sides != 0) {
28  BMOIter siter;
29  BMFace *f;
30 
32  BMO_ITER (f, &siter, op->slots_out, "faces.out", BM_FACE) {
33  if (f->len > sides) {
34  BM_face_kill(bm, f);
35  }
36  }
37  }
38 
40 
41  /* --- Attribute Fill --- */
42  /* may as well since we have the faces already in a buffer */
44  &op_attr,
45  op->flag,
46  "face_attribute_fill faces=%S use_normals=%b use_data=%b",
47  op,
48  "faces.out",
49  true,
50  true);
51 
52  BMO_op_exec(bm, &op_attr);
53 
54  /* check if some faces couldn't be touched */
55  if (BMO_slot_buffer_len(op_attr.slots_out, "faces_fail.out")) {
56  BMOIter siter;
57  BMFace *f;
58 
59  BMO_ITER (f, &siter, op_attr.slots_out, "faces_fail.out", BM_FACE) {
60  BM_face_normal_update(f); /* normals are zero'd */
61  }
62 
63  BMO_op_callf(bm, op->flag, "recalc_face_normals faces=%S", &op_attr, "faces_fail.out");
64  }
65  BMO_op_finish(bm, &op_attr);
66 }
unsigned int uint
Definition: BLI_sys_types.h:67
@ BM_FACE
Definition: bmesh_class.h:386
@ BM_EDGE
Definition: bmesh_class.h:384
@ BM_ELEM_TAG
Definition: bmesh_class.h:484
void BM_face_kill(BMesh *bm, BMFace *f)
Definition: bmesh_core.c:828
void BM_mesh_edgenet(BMesh *bm, const bool use_edge_tag, const bool use_new_face_tag)
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_mesh_elem_hflag_disable_all(BMesh *bm, const char htype, const char hflag, const bool respecthide)
void BMO_slot_buffer_hflag_enable(BMesh *bm, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag, bool do_flush)
BMO_FLAG_BUFFER.
void BMO_slot_buffer_from_enabled_hflag(BMesh *bm, BMOperator *op, BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, char htype, char hflag)
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
bool BMO_op_initf(BMesh *bm, BMOperator *op, int flag, const char *fmt,...)
int BMO_slot_int_get(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
void BMO_op_finish(BMesh *bm, BMOperator *op)
BMESH OPSTACK FINISH OP.
int BMO_slot_buffer_len(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
bool BMO_op_callf(BMesh *bm, int flag, const char *fmt,...)
void BM_face_normal_update(BMFace *f)
void bmo_holes_fill_exec(BMesh *bm, BMOperator *op)
int len
Definition: bmesh_class.h:267
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]