4 * The functions and structures in this file
5 * provide a unified method for iterating over
6 * the elements of a mesh and answering simple
7 * adjacency queries. Tool authors should use
8 * the iterators provided in this file instead
9 * of inspecting the structure directly.
13 #ifndef BM_ITERATORS_H
14 #define BM_ITERATORS_H
16 #include "BLI_mempool.h"
18 /*Defines for passing to BMIter_New.
20 "OF" can be substituted for "around"
21 so BM_VERTS_OF_FACE means "vertices
25 /*these iterator over all elements of a specific
27 #define BM_VERTS_OF_MESH 1
28 #define BM_EDGES_OF_MESH 2
29 #define BM_FACES_OF_MESH 3
31 /*these are topological iterators.*/
32 #define BM_EDGES_OF_VERT 4
33 #define BM_FACES_OF_VERT 5
34 #define BM_LOOPS_OF_VERT 6
35 #define BM_FACES_OF_EDGE 7
36 #define BM_VERTS_OF_FACE 8
37 #define BM_EDGES_OF_FACE 9
38 #define BM_LOOPS_OF_FACE 10
39 /*returns elements from all boundaries, and returns
40 the first element at the end to flag that we're entering
41 a different face hole boundary*/
42 #define BM_ALL_LOOPS_OF_FACE 11
44 /*iterate through loops around this loop, which are fetched
45 from the other faces in the radial cycle surrounding the
47 #define BM_LOOPS_OF_LOOP 12
48 #define BM_LOOPS_OF_EDGE 13
50 #define BM_ITER(ele, iter, bm, type, data) \
51 ele = BMIter_New(iter, bm, type, data); \
52 for ( ; ele; ele=BMIter_Step(iter))
54 #define BM_ITER_INDEX(ele, iter, bm, type, data, indexvar) \
55 ele = BMIter_New(iter, bm, type, data); \
56 for (indexvar=0; ele; indexvar++, ele=BMIter_Step(iter))
58 /*Iterator Structure*/
59 typedef struct BMIter {
60 BLI_mempool_iter pooliter;
62 struct BMVert *firstvert, *nextvert, *vdata;
63 struct BMEdge *firstedge, *nextedge, *edata;
64 struct BMLoop *firstloop, *nextloop, *ldata, *l;
65 struct BMFace *firstpoly, *nextpoly, *pdata;
67 void (*begin)(struct BMIter *iter);
68 void *(*step)(struct BMIter *iter);
78 void *BMIter_New(struct BMIter *iter, struct BMesh *bm, int type, void *data);
79 void *BMIter_Step(struct BMIter *iter);
80 void *BMIter_AtIndex(struct BMesh *bm, int type, void *data, int index);