Blender  V2.93
bmo_fill_holes.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
23 #include "BLI_utildefines.h"
24 
25 #include "bmesh.h"
26 #include "bmesh_tools.h"
27 
28 #include "intern/bmesh_operators_private.h" /* own include */
29 
31 {
32  BMOperator op_attr;
33  const uint sides = BMO_slot_int_get(op->slots_in, "sides");
34 
37 
38  BM_mesh_edgenet(bm, true, true); // TODO, sides
39 
40  /* bad - remove faces after as a workaround */
41  if (sides != 0) {
42  BMOIter siter;
43  BMFace *f;
44 
46  BMO_ITER (f, &siter, op->slots_out, "faces.out", BM_FACE) {
47  if (f->len > sides) {
48  BM_face_kill(bm, f);
49  }
50  }
51  }
52 
54 
55  /* --- Attribute Fill --- */
56  /* may as well since we have the faces already in a buffer */
58  &op_attr,
59  op->flag,
60  "face_attribute_fill faces=%S use_normals=%b use_data=%b",
61  op,
62  "faces.out",
63  true,
64  true);
65 
66  BMO_op_exec(bm, &op_attr);
67 
68  /* check if some faces couldn't be touched */
69  if (BMO_slot_buffer_count(op_attr.slots_out, "faces_fail.out")) {
70  BMOIter siter;
71  BMFace *f;
72 
73  BMO_ITER (f, &siter, op_attr.slots_out, "faces_fail.out", BM_FACE) {
74  BM_face_normal_update(f); /* normals are zero'd */
75  }
76 
77  BMO_op_callf(bm, op->flag, "recalc_face_normals faces=%S", &op_attr, "faces_fail.out");
78  }
79  BMO_op_finish(bm, &op_attr);
80 }
unsigned int uint
Definition: BLI_sys_types.h:83
@ 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:881
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, const char htype, const char hflag, const 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, const char htype, const char hflag)
void BMO_op_exec(BMesh *bm, BMOperator *op)
BMESH OPSTACK EXEC OP.
bool BMO_op_initf(BMesh *bm, BMOperator *op, const int flag, const char *fmt,...)
#define BMO_ITER(ele, iter, slot_args, slot_name, restrict_flag)
int BMO_slot_buffer_count(BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name)
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.
bool BMO_op_callf(BMesh *bm, const 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:279
struct BMOpSlot slots_out[BMO_OP_MAX_SLOTS]
struct BMOpSlot slots_in[BMO_OP_MAX_SLOTS]