Blender  V2.93
Classes | Macros | Typedefs | Enumerations | Functions | Variables
bmesh_iterators.h File Reference
#include "BLI_compiler_attrs.h"
#include "BLI_mempool.h"
#include "intern/bmesh_iterators_inline.h"

Go to the source code of this file.

Classes

struct  BMIter__elem_of_mesh
 
struct  BMIter__edge_of_vert
 
struct  BMIter__face_of_vert
 
struct  BMIter__loop_of_vert
 
struct  BMIter__loop_of_edge
 
struct  BMIter__loop_of_loop
 
struct  BMIter__face_of_edge
 
struct  BMIter__vert_of_edge
 
struct  BMIter__vert_of_face
 
struct  BMIter__edge_of_face
 
struct  BMIter__loop_of_face
 
struct  BMIter
 

Macros

#define BM_ITYPE_MAX   14
 
#define BM_ITER_MESH(ele, iter, bm, itype)
 
#define BM_ITER_MESH_INDEX(ele, iter, bm, itype, indexvar)
 
#define BM_ITER_MESH_MUTABLE(ele, ele_next, iter, bm, itype)
 
#define BM_ITER_ELEM(ele, iter, data, itype)
 
#define BM_ITER_ELEM_INDEX(ele, iter, data, itype, indexvar)
 
#define BMITER_CB_DEF(name)
 
#define BM_ITER_CHECK_TYPE_DATA(data)    CHECK_TYPE_ANY(data, void *, BMFace *, BMEdge *, BMVert *, BMLoop *, BMElem *)
 
#define BM_iter_new(iter, bm, itype, data)    (BM_ITER_CHECK_TYPE_DATA(data), BM_iter_new(iter, bm, itype, data))
 
#define BM_iter_init(iter, bm, itype, data)    (BM_ITER_CHECK_TYPE_DATA(data), BM_iter_init(iter, bm, itype, data))
 

Typedefs

typedef enum BMIterType BMIterType
 BMesh Iterators. More...
 
typedef void(* BMIter__begin_cb) (void *)
 
typedef void *(* BMIter__step_cb) (void *)
 
typedef struct BMIter BMIter
 

Enumerations

enum  BMIterType {
  BM_VERTS_OF_MESH = 1 , BM_EDGES_OF_MESH = 2 , BM_FACES_OF_MESH = 3 , BM_EDGES_OF_VERT = 4 ,
  BM_FACES_OF_VERT = 5 , BM_LOOPS_OF_VERT = 6 , BM_VERTS_OF_EDGE = 7 , BM_FACES_OF_EDGE = 8 ,
  BM_VERTS_OF_FACE = 9 , BM_EDGES_OF_FACE = 10 , BM_LOOPS_OF_FACE = 11 , BM_LOOPS_OF_LOOP = 12 ,
  BM_LOOPS_OF_EDGE = 13
}
 BMesh Iterators. More...
 

Functions

void * BM_iter_at_index (BMesh *bm, const char itype, void *data, int index) ATTR_WARN_UNUSED_RESULT
 
int BM_iter_as_array (BMesh *bm, const char itype, void *data, void **array, const int len)
 Iterator as Array. More...
 
void * BM_iter_as_arrayN (BMesh *bm, const char itype, void *data, int *r_len, void **stack_array, int stack_array_size) ATTR_WARN_UNUSED_RESULT
 Iterator as Array. More...
 
int BMO_iter_as_array (BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char restrictmask, void **array, const int len)
 Operator Iterator as Array. More...
 
void * BMO_iter_as_arrayN (BMOpSlot slot_args[BMO_OP_MAX_SLOTS], const char *slot_name, const char restrictmask, int *r_len, void **stack_array, int stack_array_size)
 
int BM_iter_mesh_bitmap_from_filter (const char itype, BMesh *bm, uint *bitmap, bool(*test_fn)(BMElem *, void *user_data), void *user_data)
 
int BM_iter_mesh_bitmap_from_filter_tessface (BMesh *bm, uint *bitmap, bool(*test_fn)(BMFace *, void *user_data), void *user_data)
 
int BM_iter_elem_count_flag (const char itype, void *data, const char hflag, const bool value)
 Elem Iter Flag Count. More...
 
int BMO_iter_elem_count_flag (BMesh *bm, const char itype, void *data, const short oflag, const bool value)
 Elem Iter Tool Flag Count. More...
 
int BM_iter_mesh_count (const char itype, BMesh *bm)
 
int BM_iter_mesh_count_flag (const char itype, BMesh *bm, const char hflag, const bool value)
 Mesh Iter Flag Count. More...
 
 BMITER_CB_DEF (elem_of_mesh)
 
 BMITER_CB_DEF (edge_of_vert)
 
 BMITER_CB_DEF (face_of_vert)
 
 BMITER_CB_DEF (loop_of_vert)
 
 BMITER_CB_DEF (loop_of_edge)
 
 BMITER_CB_DEF (loop_of_loop)
 
 BMITER_CB_DEF (face_of_edge)
 
 BMITER_CB_DEF (vert_of_edge)
 
 BMITER_CB_DEF (vert_of_face)
 
 BMITER_CB_DEF (edge_of_face)
 
 BMITER_CB_DEF (loop_of_face)
 

Variables

const char bm_iter_itype_htype_map [BM_ITYPE_MAX]
 

Macro Definition Documentation

◆ BM_ITER_CHECK_TYPE_DATA

#define BM_ITER_CHECK_TYPE_DATA (   data)     CHECK_TYPE_ANY(data, void *, BMFace *, BMEdge *, BMVert *, BMLoop *, BMElem *)

Definition at line 247 of file bmesh_iterators.h.

◆ BM_ITER_ELEM

#define BM_ITER_ELEM (   ele,
  iter,
  data,
  itype 
)
Value:
for (BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_new(iter, NULL, itype, data); ele; \
BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_step(iter))
#define BM_CHECK_TYPE_ELEM_ASSIGN(ele)
Definition: bmesh_class.h:466
#define BM_iter_new(iter, bm, itype, data)
ATTR_WARN_UNUSED_RESULT BMesh const char itype

Definition at line 103 of file bmesh_iterators.h.

◆ BM_ITER_ELEM_INDEX

#define BM_ITER_ELEM_INDEX (   ele,
  iter,
  data,
  itype,
  indexvar 
)
Value:
for (BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_new(iter, NULL, itype, data), indexvar = 0; ele; \
BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_step(iter), (indexvar)++)

Definition at line 107 of file bmesh_iterators.h.

◆ BM_iter_init

#define BM_iter_init (   iter,
  bm,
  itype,
  data 
)     (BM_ITER_CHECK_TYPE_DATA(data), BM_iter_init(iter, bm, itype, data))

Definition at line 252 of file bmesh_iterators.h.

◆ BM_ITER_MESH

#define BM_ITER_MESH (   ele,
  iter,
  bm,
  itype 
)
Value:
for (BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_new(iter, bm, itype, NULL); ele; \
BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_step(iter))
ATTR_WARN_UNUSED_RESULT BMesh * bm

Definition at line 78 of file bmesh_iterators.h.

◆ BM_ITER_MESH_INDEX

#define BM_ITER_MESH_INDEX (   ele,
  iter,
  bm,
  itype,
  indexvar 
)
Value:
for (BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_new(iter, bm, itype, NULL), indexvar = 0; ele; \
BM_CHECK_TYPE_ELEM_ASSIGN(ele) = BM_iter_step(iter), (indexvar)++)

Definition at line 82 of file bmesh_iterators.h.

◆ BM_ITER_MESH_MUTABLE

#define BM_ITER_MESH_MUTABLE (   ele,
  ele_next,
  iter,
  bm,
  itype 
)
Value:
ele ? ((BM_CHECK_TYPE_ELEM_ASSIGN(ele_next) = BM_iter_step(iter)), 1) : 0; \
ele = ele_next)

Definition at line 97 of file bmesh_iterators.h.

◆ BM_iter_new

#define BM_iter_new (   iter,
  bm,
  itype,
  data 
)     (BM_ITER_CHECK_TYPE_DATA(data), BM_iter_new(iter, bm, itype, data))

Definition at line 250 of file bmesh_iterators.h.

◆ BM_ITYPE_MAX

#define BM_ITYPE_MAX   14

Definition at line 73 of file bmesh_iterators.h.

◆ BMITER_CB_DEF

#define BMITER_CB_DEF (   name)
Value:
struct BMIter__##name; \
void bmiter__##name##_begin(struct BMIter__##name *iter); \
void *bmiter__##name##_step(struct BMIter__##name *iter)

Definition at line 226 of file bmesh_iterators.h.

Typedef Documentation

◆ BMIter

typedef struct BMIter BMIter

◆ BMIter__begin_cb

typedef void(* BMIter__begin_cb) (void *)

Definition at line 157 of file bmesh_iterators.h.

◆ BMIter__step_cb

typedef void*(* BMIter__step_cb) (void *)

Definition at line 158 of file bmesh_iterators.h.

◆ BMIterType

typedef enum BMIterType BMIterType

BMesh Iterators.

The functions and structures in this file provide a unified method for iterating over the elements of a mesh and answering simple adjacency queries. Tool authors should use the iterators provided in this file instead of inspecting the structure directly.

Enumeration Type Documentation

◆ BMIterType

enum BMIterType

BMesh Iterators.

The functions and structures in this file provide a unified method for iterating over the elements of a mesh and answering simple adjacency queries. Tool authors should use the iterators provided in this file instead of inspecting the structure directly.

Enumerator
BM_VERTS_OF_MESH 
BM_EDGES_OF_MESH 
BM_FACES_OF_MESH 
BM_EDGES_OF_VERT 
BM_FACES_OF_VERT 
BM_LOOPS_OF_VERT 
BM_VERTS_OF_EDGE 
BM_FACES_OF_EDGE 
BM_VERTS_OF_FACE 
BM_EDGES_OF_FACE 
BM_LOOPS_OF_FACE 
BM_LOOPS_OF_LOOP 
BM_LOOPS_OF_EDGE 

Definition at line 49 of file bmesh_iterators.h.

Function Documentation

◆ BM_iter_as_array()

int BM_iter_as_array ( BMesh bm,
const char  itype,
void *  data,
void **  array,
const int  len 
)

Iterator as Array.

Sometimes its convenient to get the iterator as an array to avoid multiple calls to BM_iter_at_index.

Definition at line 107 of file bmesh_iterators.c.

References bm, BM_iter_new, data, itype, and len.

Referenced by BM_mesh_elem_table_ensure(), bm_vert_dissolve_fan(), edbm_rip_invoke__vert(), pbvh_bmesh_edge_loops(), quad_from_tris(), and skin_fix_hole_no_good_verts().

◆ BM_iter_as_arrayN()

void* BM_iter_as_arrayN ( BMesh bm,
const char  itype,
void *  data,
int *  r_len,
void **  stack_array,
int  stack_array_size 
)

Iterator as Array.

Allocates a new array, has the advantage that you don't need to know the size ahead of time.

Takes advantage of less common iterator usage to avoid counting twice, which you might end up doing when BM_iter_as_array is used.

Caller needs to free the array.

Definition at line 168 of file bmesh_iterators.c.

References BLI_assert, bm, BM_EDGES_OF_MESH, BM_FACES_OF_MESH, BM_iter_init(), BM_VERTS_OF_MESH, BMIter::count, data, itype, MEM_mallocN, NULL, BMesh::totedge, BMesh::totface, and BMesh::totvert.

Referenced by bevel_rebuild_existing_polygons(), and BM_mesh_decimate_dissolve().

◆ BM_iter_at_index()

void* BM_iter_at_index ( BMesh bm,
const char  itype,
void *  data,
int  index 
)

◆ BM_iter_elem_count_flag()

int BM_iter_elem_count_flag ( const char  itype,
void *  data,
const char  hflag,
const bool  value 
)

Elem Iter Flag Count.

Counts how many flagged / unflagged items are found in this element.

Definition at line 313 of file bmesh_iterators.c.

References BM_elem_flag_test_bool, BM_ITER_ELEM, count, data, and itype.

Referenced by bm_vert_is_select_history_open().

◆ BM_iter_mesh_bitmap_from_filter()

int BM_iter_mesh_bitmap_from_filter ( const char  itype,
BMesh bm,
uint bitmap,
bool(*)(BMElem *, void *user_data test_fn,
void *  user_data 
)

Definition at line 251 of file bmesh_iterators.c.

References BLI_BITMAP_DISABLE, BLI_BITMAP_ENABLE, bm, BM_ITER_MESH_INDEX, itype, and user_data.

Referenced by snapEditMesh().

◆ BM_iter_mesh_bitmap_from_filter_tessface()

int BM_iter_mesh_bitmap_from_filter_tessface ( BMesh bm,
BLI_bitmap bitmap,
bool(*)(BMFace *, void *user_data test_fn,
void *  user_data 
)

Needed when we want to check faces, but return a loop aligned array.

Definition at line 278 of file bmesh_iterators.c.

References BLI_BITMAP_DISABLE, BLI_BITMAP_ENABLE, bm, BM_FACES_OF_MESH, BM_ITER_MESH_INDEX, BMFace::len, and user_data.

Referenced by raycastEditMesh().

◆ BM_iter_mesh_count()

int BM_iter_mesh_count ( const char  itype,
BMesh bm 
)

◆ BM_iter_mesh_count_flag()

int BM_iter_mesh_count_flag ( const char  itype,
BMesh bm,
const char  hflag,
const bool  value 
)

Mesh Iter Flag Count.

Counts how many flagged / unflagged items are found in this mesh.

Definition at line 379 of file bmesh_iterators.c.

References bm, BM_elem_flag_test_bool, BM_ITER_MESH, count, and itype.

Referenced by bmo_collapse_uvs_exec(), and transform_convert_mesh_connectivity_distance().

◆ BMITER_CB_DEF() [1/11]

BMITER_CB_DEF ( edge_of_face  )

◆ BMITER_CB_DEF() [2/11]

BMITER_CB_DEF ( edge_of_vert  )

◆ BMITER_CB_DEF() [3/11]

BMITER_CB_DEF ( elem_of_mesh  )

◆ BMITER_CB_DEF() [4/11]

BMITER_CB_DEF ( face_of_edge  )

◆ BMITER_CB_DEF() [5/11]

BMITER_CB_DEF ( face_of_vert  )

◆ BMITER_CB_DEF() [6/11]

BMITER_CB_DEF ( loop_of_edge  )

◆ BMITER_CB_DEF() [7/11]

BMITER_CB_DEF ( loop_of_face  )

◆ BMITER_CB_DEF() [8/11]

BMITER_CB_DEF ( loop_of_loop  )

◆ BMITER_CB_DEF() [9/11]

BMITER_CB_DEF ( loop_of_vert  )

◆ BMITER_CB_DEF() [10/11]

BMITER_CB_DEF ( vert_of_edge  )

◆ BMITER_CB_DEF() [11/11]

BMITER_CB_DEF ( vert_of_face  )

◆ BMO_iter_as_array()

int BMO_iter_as_array ( BMOpSlot  slot_args[BMO_OP_MAX_SLOTS],
const char *  slot_name,
const char  restrictmask,
void **  array,
const int  len 
)

Operator Iterator as Array.

Sometimes its convenient to get the iterator as an array.

Definition at line 132 of file bmesh_iterators.c.

References BMO_iter_new(), BMO_iter_step(), and len.

Referenced by bmo_contextual_create_exec().

◆ BMO_iter_as_arrayN()

void* BMO_iter_as_arrayN ( BMOpSlot  slot_args[BMO_OP_MAX_SLOTS],
const char *  slot_name,
const char  restrictmask,
int *  r_len,
void **  stack_array,
int  stack_array_size 
)

◆ BMO_iter_elem_count_flag()

int BMO_iter_elem_count_flag ( BMesh bm,
const char  itype,
void *  data,
const short  oflag,
const bool  value 
)

Elem Iter Tool Flag Count.

Counts how many flagged / unflagged items are found in this element.

Definition at line 333 of file bmesh_iterators.c.

References BLI_assert, bm, BM_EDGE, BM_FACE, BM_ITER_ELEM, bm_iter_itype_htype_map, BM_LOOP, BM_VERT, BMO_edge_flag_test_bool, BMO_face_flag_test_bool, BMO_vert_flag_test_bool, count, data, itype, and oflag.

Referenced by bmo_contextual_create_exec(), bmo_edgeloop_fill_exec(), and bmo_edgenet_prepare_exec().

Variable Documentation

◆ bm_iter_itype_htype_map

const char bm_iter_itype_htype_map[BM_ITYPE_MAX]
extern