Merged changes in the trunk up to revision 51853.
[blender-staging.git] / source / blender / bmesh / operators / bmo_similar.c
1 /*
2  * ***** BEGIN GPL LICENSE BLOCK *****
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  *
18  * Contributor(s): Joseph Eagar, Campbell Barton
19  *
20  * ***** END GPL LICENSE BLOCK *****
21  */
22
23 /** \file blender/bmesh/operators/bmo_similar.c
24  *  \ingroup bmesh
25  *
26  * bmesh operators to select based on
27  * comparisons with the existing selection.
28  */
29
30 #include "MEM_guardedalloc.h"
31
32 #include "DNA_object_types.h"
33 #include "DNA_meshdata_types.h"
34
35 #include "BLI_math.h"
36
37 #include "BKE_customdata.h"
38 #include "BKE_deform.h"
39
40 #include "bmesh.h"
41
42 #include "intern/bmesh_operators_private.h"  /* own include */
43
44 /* in fact these could all be the same */
45
46 /*
47  * extra face data (computed data)
48  */
49 typedef struct SimSel_FaceExt {
50         BMFace  *f;             /* the face */
51         float    c[3];          /* center */
52         union {
53                 float   area;       /* area */
54                 float   perim;      /* perimeter */
55                 float   d;          /* 4th component of plane (the first three being the normal) */
56                 struct Image *t;    /* image pointer */
57         };
58 } SimSel_FaceExt;
59
60 static int bm_sel_similar_cmp_fl(const float delta, const float thresh, const int compare)
61 {
62         switch (compare) {
63                 case SIM_CMP_EQ:
64                         return (fabsf(delta) <= thresh);
65                 case SIM_CMP_GT:
66                         return ((delta + thresh) >= 0.0f);
67                 case SIM_CMP_LT:
68                         return ((delta - thresh) <= 0.0f);
69                 default:
70                         BLI_assert(0);
71                         return 0;
72         }
73 }
74
75 static int bm_sel_similar_cmp_i(const int delta, const int compare)
76 {
77         switch (compare) {
78                 case SIM_CMP_EQ:
79                         return (delta == 0);
80                 case SIM_CMP_GT:
81                         return (delta > 0);
82                 case SIM_CMP_LT:
83                         return (delta < 0);
84                 default:
85                         BLI_assert(0);
86                         return 0;
87         }
88 }
89
90 /*
91  * Select similar faces, the choices are in the enum in source/blender/bmesh/bmesh_operators.h
92  * We select either similar faces based on material, image, area, perimeter, normal, or the coplanar faces
93  */
94 void bmo_similar_faces_exec(BMesh *bm, BMOperator *op)
95 {
96 #define FACE_MARK       1
97
98         BMIter fm_iter;
99         BMFace *fs, *fm;
100         BMOIter fs_iter;
101         int num_sels = 0, num_total = 0, i = 0, idx = 0;
102         float angle = 0.0f;
103         SimSel_FaceExt *f_ext = NULL;
104         int *indices = NULL;
105         float t_no[3];  /* temporary normal */
106         const int type = BMO_slot_int_get(op, "type");
107         const float thresh = BMO_slot_float_get(op, "thresh");
108         const float thresh_radians = thresh * (float)M_PI;
109         const int compare = BMO_slot_int_get(op, "compare");
110
111         /* initial_elem - other_elem */
112         float delta_fl;
113         int   delta_i;
114
115         num_total = BM_mesh_elem_count(bm, BM_FACE);
116
117         /*
118          * The first thing to do is to iterate through all the the selected items and mark them since
119          * they will be in the selection anyway.
120          * This will increase performance, (especially when the number of originally selected faces is high)
121          * so the overall complexity will be less than $O(mn)$ where is the total number of selected faces,
122          * and n is the total number of faces
123          */
124         BMO_ITER (fs, &fs_iter, bm, op, "faces", BM_FACE) {
125                 if (!BMO_elem_flag_test(bm, fs, FACE_MARK)) {   /* is this really needed ? */
126                         BMO_elem_flag_enable(bm, fs, FACE_MARK);
127                         num_sels++;
128                 }
129         }
130
131         /* allocate memory for the selected faces indices and for all temporary faces */
132         indices = (int *)MEM_callocN(sizeof(int) * num_sels, "face indices util.c");
133         f_ext = (SimSel_FaceExt *)MEM_callocN(sizeof(SimSel_FaceExt) * num_total, "f_ext util.c");
134
135         /* loop through all the faces and fill the faces/indices structure */
136         BM_ITER_MESH (fm, &fm_iter, bm, BM_FACES_OF_MESH) {
137                 f_ext[i].f = fm;
138                 if (BMO_elem_flag_test(bm, fm, FACE_MARK)) {
139                         indices[idx] = i;
140                         idx++;
141                 }
142                 i++;
143         }
144
145         /*
146          * Save us some computation burden: In case of perimeter/area/coplanar selection we compute
147          * only once.
148          */
149         if (type == SIMFACE_PERIMETER || type == SIMFACE_AREA || type == SIMFACE_COPLANAR || type == SIMFACE_IMAGE) {
150                 for (i = 0; i < num_total; i++) {
151                         switch (type) {
152                                 case SIMFACE_PERIMETER:
153                                         /* set the perimeter */
154                                         f_ext[i].perim = BM_face_calc_perimeter(f_ext[i].f);
155                                         break;
156
157                                 case SIMFACE_COPLANAR:
158                                         /* compute the center of the polygon */
159                                         BM_face_calc_center_mean(f_ext[i].f, f_ext[i].c);
160
161                                         /* normalize the polygon normal */
162                                         copy_v3_v3(t_no, f_ext[i].f->no);
163                                         normalize_v3(t_no);
164
165                                         /* compute the plane distance */
166                                         f_ext[i].d = dot_v3v3(t_no, f_ext[i].c);
167                                         break;
168
169                                 case SIMFACE_AREA:
170                                         f_ext[i].area = BM_face_calc_area(f_ext[i].f);
171                                         break;
172
173                                 case SIMFACE_IMAGE:
174                                         f_ext[i].t = NULL;
175                                         if (CustomData_has_layer(&(bm->pdata), CD_MTEXPOLY)) {
176                                                 MTexPoly *mtpoly = CustomData_bmesh_get(&bm->pdata, f_ext[i].f->head.data, CD_MTEXPOLY);
177                                                 f_ext[i].t = mtpoly->tpage;
178                                         }
179                                         break;
180                         }
181                 }
182         }
183
184         /* now select the rest (if any) */
185         for (i = 0; i < num_total; i++) {
186                 fm = f_ext[i].f;
187                 if (!BMO_elem_flag_test(bm, fm, FACE_MARK) && !BM_elem_flag_test(fm, BM_ELEM_HIDDEN)) {
188                         int cont = TRUE;
189                         for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
190                                 fs = f_ext[indices[idx]].f;
191                                 switch (type) {
192                                         case SIMFACE_MATERIAL:
193                                                 if (fm->mat_nr == fs->mat_nr) {
194                                                         BMO_elem_flag_enable(bm, fm, FACE_MARK);
195                                                         cont = FALSE;
196                                                 }
197                                                 break;
198
199                                         case SIMFACE_IMAGE:
200                                                 if (f_ext[i].t == f_ext[indices[idx]].t) {
201                                                         BMO_elem_flag_enable(bm, fm, FACE_MARK);
202                                                         cont = FALSE;
203                                                 }
204                                                 break;
205
206                                         case SIMFACE_NORMAL:
207                                                 angle = angle_normalized_v3v3(fs->no, fm->no);  /* if the angle between the normals -> 0 */
208                                                 if (angle <= thresh_radians) {
209                                                         BMO_elem_flag_enable(bm, fm, FACE_MARK);
210                                                         cont = FALSE;
211                                                 }
212                                                 break;
213
214                                         case SIMFACE_COPLANAR:
215                                                 angle = angle_normalized_v3v3(fs->no, fm->no); /* angle -> 0 */
216                                                 if (angle <= thresh_radians) { /* and dot product difference -> 0 */
217                                                         delta_fl = f_ext[i].d - f_ext[indices[idx]].d;
218                                                         if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
219                                                                 BMO_elem_flag_enable(bm, fm, FACE_MARK);
220                                                                 cont = FALSE;
221                                                         }
222                                                 }
223                                                 break;
224
225                                         case SIMFACE_AREA:
226                                                 delta_fl = f_ext[i].area - f_ext[indices[idx]].area;
227                                                 if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
228                                                         BMO_elem_flag_enable(bm, fm, FACE_MARK);
229                                                         cont = FALSE;
230                                                 }
231                                                 break;
232
233                                         case SIMFACE_SIDES:
234                                                 delta_i = fm->len - fs->len;
235                                                 if (bm_sel_similar_cmp_i(delta_i, compare)) {
236                                                         BMO_elem_flag_enable(bm, fm, FACE_MARK);
237                                                         cont = FALSE;
238                                                 }
239                                                 break;
240
241                                         case SIMFACE_PERIMETER:
242                                                 delta_fl = f_ext[i].perim - f_ext[indices[idx]].perim;
243                                                 if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
244                                                         BMO_elem_flag_enable(bm, fm, FACE_MARK);
245                                                         cont = FALSE;
246                                                 }
247                                                 break;
248                                         default:
249                                                 BLI_assert(0);
250                                 }
251                         }
252                 }
253         }
254
255         MEM_freeN(f_ext);
256         MEM_freeN(indices);
257
258         /* transfer all marked faces to the output slot */
259         BMO_slot_buffer_from_enabled_flag(bm, op, "faceout", BM_FACE, FACE_MARK);
260 #undef FACE_MARK
261 }
262
263 /**************************************************************************** *
264  * Similar Edges
265  **************************************************************************** */
266
267 /*
268  * extra edge information
269  */
270 typedef struct SimSel_EdgeExt {
271         BMEdge *e;
272         union {
273                 float dir[3];
274                 float angle;            /* angle between the face */
275         };
276
277         union {
278                 float length;           /* edge length */
279                 int   faces;            /* faces count */
280         };
281 } SimSel_EdgeExt;
282
283 /*
284  * select similar edges: the choices are in the enum in source/blender/bmesh/bmesh_operators.h
285  * choices are length, direction, face, ...
286  */
287 void bmo_similar_edges_exec(BMesh *bm, BMOperator *op)
288 {
289 #define EDGE_MARK       1
290
291         BMOIter es_iter;        /* selected edges iterator */
292         BMIter e_iter;          /* mesh edges iterator */
293         BMEdge *es;             /* selected edge */
294         BMEdge *e;              /* mesh edge */
295         int idx = 0, i = 0 /* , f = 0 */;
296         int *indices = NULL;
297         SimSel_EdgeExt *e_ext = NULL;
298         // float *angles = NULL;
299         float angle;
300
301         int num_sels = 0, num_total = 0;
302         const int type = BMO_slot_int_get(op, "type");
303         const float thresh = BMO_slot_float_get(op, "thresh");
304         const int compare = BMO_slot_int_get(op, "compare");
305
306         /* initial_elem - other_elem */
307         float delta_fl;
308         int   delta_i;
309
310         /* sanity checks that the data we need is available */
311         switch (type) {
312                 case SIMEDGE_CREASE:
313                         if (!CustomData_has_layer(&bm->edata, CD_CREASE)) {
314                                 return;
315                         }
316                         break;
317                 case SIMEDGE_BEVEL:
318                         if (!CustomData_has_layer(&bm->edata, CD_BWEIGHT)) {
319                                 return;
320                         }
321                         break;
322         }
323
324         num_total = BM_mesh_elem_count(bm, BM_EDGE);
325
326         /* iterate through all selected edges and mark them */
327         BMO_ITER (es, &es_iter, bm, op, "edges", BM_EDGE) {
328                 BMO_elem_flag_enable(bm, es, EDGE_MARK);
329                 num_sels++;
330         }
331
332         /* allocate memory for the selected edges indices and for all temporary edges */
333         indices = (int *)MEM_callocN(sizeof(int) * num_sels, __func__);
334         e_ext = (SimSel_EdgeExt *)MEM_callocN(sizeof(SimSel_EdgeExt) * num_total, __func__);
335
336         /* loop through all the edges and fill the edges/indices structure */
337         BM_ITER_MESH (e, &e_iter, bm, BM_EDGES_OF_MESH) {
338                 e_ext[i].e = e;
339                 if (BMO_elem_flag_test(bm, e, EDGE_MARK)) {
340                         indices[idx] = i;
341                         idx++;
342                 }
343                 i++;
344         }
345
346         /* save us some computation time by doing heavy computation once */
347         if (type == SIMEDGE_LENGTH || type == SIMEDGE_FACE || type == SIMEDGE_DIR || type == SIMEDGE_FACE_ANGLE) {
348                 for (i = 0; i < num_total; i++) {
349                         switch (type) {
350                                 case SIMEDGE_LENGTH:    /* compute the length of the edge */
351                                         e_ext[i].length = len_v3v3(e_ext[i].e->v1->co, e_ext[i].e->v2->co);
352                                         break;
353
354                                 case SIMEDGE_DIR:               /* compute the direction */
355                                         sub_v3_v3v3(e_ext[i].dir, e_ext[i].e->v1->co, e_ext[i].e->v2->co);
356                                         normalize_v3(e_ext[i].dir);
357                                         break;
358
359                                 case SIMEDGE_FACE:              /* count the faces around the edge */
360                                         e_ext[i].faces = BM_edge_face_count(e_ext[i].e);
361                                         break;
362
363                                 case SIMEDGE_FACE_ANGLE:
364                                         e_ext[i].faces = BM_edge_face_count(e_ext[i].e);
365                                         if (e_ext[i].faces == 2)
366                                                 e_ext[i].angle = BM_edge_calc_face_angle(e_ext[i].e);
367                                         break;
368                         }
369                 }
370         }
371
372         /* select the edges if any */
373         for (i = 0; i < num_total; i++) {
374                 e = e_ext[i].e;
375                 if (!BMO_elem_flag_test(bm, e, EDGE_MARK) && !BM_elem_flag_test(e, BM_ELEM_HIDDEN)) {
376                         int cont = TRUE;
377                         for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
378                                 es = e_ext[indices[idx]].e;
379                                 switch (type) {
380                                         case SIMEDGE_LENGTH:
381                                                 delta_fl = e_ext[i].length - e_ext[indices[idx]].length;
382                                                 if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
383                                                         BMO_elem_flag_enable(bm, e, EDGE_MARK);
384                                                         cont = FALSE;
385                                                 }
386                                                 break;
387
388                                         case SIMEDGE_DIR:
389                                                 /* compute the angle between the two edges */
390                                                 angle = angle_normalized_v3v3(e_ext[i].dir, e_ext[indices[idx]].dir);
391
392                                                 if (angle > (float)(M_PI / 2.0)) /* use the smallest angle between the edges */
393                                                         angle = fabsf(angle - (float)M_PI);
394
395                                                 if (angle / (float)(M_PI / 2.0) <= thresh) {
396                                                         BMO_elem_flag_enable(bm, e, EDGE_MARK);
397                                                         cont = FALSE;
398                                                 }
399                                                 break;
400
401                                         case SIMEDGE_FACE:
402                                                 delta_i = e_ext[i].faces - e_ext[indices[idx]].faces;
403                                                 if (bm_sel_similar_cmp_i(delta_i, compare)) {
404                                                         BMO_elem_flag_enable(bm, e, EDGE_MARK);
405                                                         cont = FALSE;
406                                                 }
407                                                 break;
408
409                                         case SIMEDGE_FACE_ANGLE:
410                                                 if (e_ext[i].faces == 2) {
411                                                         if (e_ext[indices[idx]].faces == 2) {
412                                                                 if (fabsf(e_ext[i].angle - e_ext[indices[idx]].angle) <= thresh) {
413                                                                         BMO_elem_flag_enable(bm, e, EDGE_MARK);
414                                                                         cont = FALSE;
415                                                                 }
416                                                         }
417                                                 }
418                                                 else {
419                                                         cont = FALSE;
420                                                 }
421                                                 break;
422
423                                         case SIMEDGE_CREASE:
424                                                 {
425                                                         float *c1, *c2;
426
427                                                         c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_CREASE);
428                                                         c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_CREASE);
429                                                         delta_fl = *c1 - *c2;
430
431                                                         if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
432                                                                 BMO_elem_flag_enable(bm, e, EDGE_MARK);
433                                                                 cont = FALSE;
434                                                         }
435                                                 }
436                                                 break;
437
438                                         case SIMEDGE_BEVEL:
439                                                 {
440                                                         float *c1, *c2;
441
442                                                         c1 = CustomData_bmesh_get(&bm->edata, e->head.data, CD_BWEIGHT);
443                                                         c2 = CustomData_bmesh_get(&bm->edata, es->head.data, CD_BWEIGHT);
444                                                         delta_fl = *c1 - *c2;
445
446                                                         if (bm_sel_similar_cmp_fl(delta_fl, thresh, compare)) {
447                                                                 BMO_elem_flag_enable(bm, e, EDGE_MARK);
448                                                                 cont = FALSE;
449                                                         }
450                                                 }
451                                                 break;
452
453                                         case SIMEDGE_SEAM:
454                                                 if (BM_elem_flag_test(e, BM_ELEM_SEAM) == BM_elem_flag_test(es, BM_ELEM_SEAM)) {
455                                                         BMO_elem_flag_enable(bm, e, EDGE_MARK);
456                                                         cont = FALSE;
457                                                 }
458                                                 break;
459
460                                         case SIMEDGE_SHARP:
461                                                 if (BM_elem_flag_test(e, BM_ELEM_SMOOTH) == BM_elem_flag_test(es, BM_ELEM_SMOOTH)) {
462                                                         BMO_elem_flag_enable(bm, e, EDGE_MARK);
463                                                         cont = FALSE;
464                                                 }
465                                                 break;
466                                         case SIMEDGE_FREESTYLE:
467                                                 if (BM_elem_flag_test(e, BM_ELEM_FREESTYLE) == BM_elem_flag_test(es, BM_ELEM_FREESTYLE)) {
468                                                         BMO_elem_flag_enable(bm, e, EDGE_MARK);
469                                                         cont = 0;
470                                                 }
471                                                 break;
472                                         default:
473                                                 BLI_assert(0);
474                                 }
475                         }
476                 }
477         }
478
479         MEM_freeN(e_ext);
480         MEM_freeN(indices);
481
482         /* transfer all marked edges to the output slot */
483         BMO_slot_buffer_from_enabled_flag(bm, op, "edgeout", BM_EDGE, EDGE_MARK);
484
485 #undef EDGE_MARK
486 }
487
488 /**************************************************************************** *
489  * Similar Vertices
490  **************************************************************************** */
491
492 typedef struct SimSel_VertExt {
493         BMVert *v;
494         union {
495                 int num_faces; /* adjacent faces */
496                 int num_edges; /* adjacent edges */
497                 MDeformVert *dvert; /* deform vertex */
498         };
499 } SimSel_VertExt;
500
501 /*
502  * select similar vertices: the choices are in the enum in source/blender/bmesh/bmesh_operators.h
503  * choices are normal, face, vertex group...
504  */
505 void bmo_similar_verts_exec(BMesh *bm, BMOperator *op)
506 {
507 #define VERT_MARK       1
508
509         BMOIter vs_iter;        /* selected verts iterator */
510         BMIter v_iter;          /* mesh verts iterator */
511         BMVert *vs;             /* selected vertex */
512         BMVert *v;                      /* mesh vertex */
513         SimSel_VertExt *v_ext = NULL;
514         int *indices = NULL;
515         int num_total = 0, num_sels = 0, i = 0, idx = 0;
516         const int type = BMO_slot_int_get(op, "type");
517         const float thresh = BMO_slot_float_get(op, "thresh");
518         const float thresh_radians = thresh * (float)M_PI;
519         const int compare = BMO_slot_int_get(op, "compare");
520
521         /* initial_elem - other_elem */
522 //      float delta_fl;
523         int   delta_i;
524
525         num_total = BM_mesh_elem_count(bm, BM_VERT);
526
527         /* iterate through all selected edges and mark them */
528         BMO_ITER (vs, &vs_iter, bm, op, "verts", BM_VERT) {
529                 BMO_elem_flag_enable(bm, vs, VERT_MARK);
530                 num_sels++;
531         }
532
533         /* allocate memory for the selected vertices indices and for all temporary vertices */
534         indices = (int *)MEM_mallocN(sizeof(int) * num_sels, "vertex indices");
535         v_ext = (SimSel_VertExt *)MEM_mallocN(sizeof(SimSel_VertExt) * num_total, "vertex extra");
536
537         /* loop through all the vertices and fill the vertices/indices structure */
538         BM_ITER_MESH (v, &v_iter, bm, BM_VERTS_OF_MESH) {
539                 v_ext[i].v = v;
540                 if (BMO_elem_flag_test(bm, v, VERT_MARK)) {
541                         indices[idx] = i;
542                         idx++;
543                 }
544
545                 switch (type) {
546                         case SIMVERT_FACE:
547                                 /* calling BM_vert_face_count every time is time consumming, so call it only once per vertex */
548                                 v_ext[i].num_faces = BM_vert_face_count(v);
549                                 break;
550
551                         case SIMVERT_VGROUP:
552                                 if (CustomData_has_layer(&(bm->vdata), CD_MDEFORMVERT)) {
553                                         v_ext[i].dvert = CustomData_bmesh_get(&bm->vdata, v_ext[i].v->head.data, CD_MDEFORMVERT);
554                                 }
555                                 else {
556                                         v_ext[i].dvert = NULL;
557                                 }
558                                 break;
559                         case SIMVERT_EDGE:
560                                 v_ext[i].num_edges = BM_vert_edge_count(v);
561                                 break;
562                 }
563
564                 i++;
565         }
566
567         /* select the vertices if any */
568         for (i = 0; i < num_total; i++) {
569                 v = v_ext[i].v;
570                 if (!BMO_elem_flag_test(bm, v, VERT_MARK) && !BM_elem_flag_test(v, BM_ELEM_HIDDEN)) {
571                         int cont = TRUE;
572                         for (idx = 0; idx < num_sels && cont == TRUE; idx++) {
573                                 vs = v_ext[indices[idx]].v;
574                                 switch (type) {
575                                         case SIMVERT_NORMAL:
576                                                 /* compare the angle between the normals */
577                                                 if (angle_normalized_v3v3(v->no, vs->no) <= thresh_radians) {
578                                                         BMO_elem_flag_enable(bm, v, VERT_MARK);
579                                                         cont = FALSE;
580                                                 }
581                                                 break;
582                                         case SIMVERT_FACE:
583                                                 /* number of adjacent faces */
584                                                 delta_i = v_ext[i].num_faces - v_ext[indices[idx]].num_faces;
585                                                 if (bm_sel_similar_cmp_i(delta_i, compare)) {
586                                                         BMO_elem_flag_enable(bm, v, VERT_MARK);
587                                                         cont = FALSE;
588                                                 }
589                                                 break;
590
591                                         case SIMVERT_VGROUP:
592                                                 if (v_ext[i].dvert != NULL && v_ext[indices[idx]].dvert != NULL) {
593                                                         if (defvert_find_shared(v_ext[i].dvert, v_ext[indices[idx]].dvert) != -1) {
594                                                                 BMO_elem_flag_enable(bm, v, VERT_MARK);
595                                                                 cont = FALSE;
596                                                         }
597                                                 }
598                                                 break;
599                                         case SIMVERT_EDGE:
600                                                 /* number of adjacent edges */
601                                                 delta_i = v_ext[i].num_edges - v_ext[indices[idx]].num_edges;
602                                                 if (bm_sel_similar_cmp_i(delta_i, compare)) {
603                                                         BMO_elem_flag_enable(bm, v, VERT_MARK);
604                                                         cont = FALSE;
605                                                 }
606                                                 break;
607                                         default:
608                                                 BLI_assert(0);
609                                 }
610                         }
611                 }
612         }
613
614         MEM_freeN(indices);
615         MEM_freeN(v_ext);
616
617         BMO_slot_buffer_from_enabled_flag(bm, op, "vertout", BM_VERT, VERT_MARK);
618
619 #undef VERT_MARK
620 }