Blender  V3.3
Functions | Variables
bmesh_iterators.c File Reference
#include "MEM_guardedalloc.h"
#include "BLI_bitmap.h"
#include "BLI_utildefines.h"
#include "bmesh.h"
#include "intern/bmesh_private.h"

Go to the source code of this file.

Functions

int BM_iter_mesh_count (const char itype, BMesh *bm)
 
voidBM_iter_at_index (BMesh *bm, const char itype, void *data, int index)
 
int BM_iter_as_array (BMesh *bm, const char itype, void *data, void **array, const int len)
 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...
 
voidBM_iter_as_arrayN (BMesh *bm, const char itype, void *data, int *r_len, void **stack_array, int stack_array_size)
 Iterator as Array. More...
 
voidBMO_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, BLI_bitmap *bitmap, bool(*test_fn)(BMElem *, void *user_data), void *user_data)
 
int BM_iter_mesh_bitmap_from_filter_tessface (BMesh *bm, BLI_bitmap *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_flag (const char itype, BMesh *bm, const char hflag, const bool value)
 Mesh Iter Flag Count. More...
 
void bmiter__elem_of_mesh_begin (struct BMIter__elem_of_mesh *iter)
 
voidbmiter__elem_of_mesh_step (struct BMIter__elem_of_mesh *iter)
 
void bmiter__edge_of_vert_begin (struct BMIter__edge_of_vert *iter)
 
voidbmiter__edge_of_vert_step (struct BMIter__edge_of_vert *iter)
 
void bmiter__face_of_vert_begin (struct BMIter__face_of_vert *iter)
 
voidbmiter__face_of_vert_step (struct BMIter__face_of_vert *iter)
 
void bmiter__loop_of_vert_begin (struct BMIter__loop_of_vert *iter)
 
voidbmiter__loop_of_vert_step (struct BMIter__loop_of_vert *iter)
 
void bmiter__loop_of_edge_begin (struct BMIter__loop_of_edge *iter)
 
voidbmiter__loop_of_edge_step (struct BMIter__loop_of_edge *iter)
 
void bmiter__loop_of_loop_begin (struct BMIter__loop_of_loop *iter)
 
voidbmiter__loop_of_loop_step (struct BMIter__loop_of_loop *iter)
 
void bmiter__face_of_edge_begin (struct BMIter__face_of_edge *iter)
 
voidbmiter__face_of_edge_step (struct BMIter__face_of_edge *iter)
 
void bmiter__vert_of_edge_begin (struct BMIter__vert_of_edge *iter)
 
voidbmiter__vert_of_edge_step (struct BMIter__vert_of_edge *iter)
 
void bmiter__vert_of_face_begin (struct BMIter__vert_of_face *iter)
 
voidbmiter__vert_of_face_step (struct BMIter__vert_of_face *iter)
 
void bmiter__edge_of_face_begin (struct BMIter__edge_of_face *iter)
 
voidbmiter__edge_of_face_step (struct BMIter__edge_of_face *iter)
 
void bmiter__loop_of_face_begin (struct BMIter__loop_of_face *iter)
 
voidbmiter__loop_of_face_step (struct BMIter__loop_of_face *iter)
 

Variables

const char bm_iter_itype_htype_map [BM_ITYPE_MAX]
 

Detailed Description

Functions to abstract looping over bmesh data structures.

See: bmesh_iterators_inlin.c too, some functions are here for speed reasons.

Definition in file bmesh_iterators.c.

Function Documentation

◆ BM_iter_as_array()

int BM_iter_as_array ( BMesh bm,
char  itype,
void data,
void **  array,
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 81 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,
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 127 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,
char  itype,
void data,
int  index 
)

◆ BM_iter_elem_count_flag()

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

Elem Iter Flag Count.

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

Definition at line 264 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,
BLI_bitmap bitmap,
bool(*)(BMElem *, void *user_data test_fn,
void user_data 
)

Definition at line 210 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,
uint 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 234 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 snap_object_data_editmesh_treedata_get().

◆ BM_iter_mesh_count()

int BM_iter_mesh_count ( char  itype,
BMesh bm 
)

◆ BM_iter_mesh_count_flag()

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

Mesh Iter Flag Count.

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

Definition at line 320 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__edge_of_face_begin()

void bmiter__edge_of_face_begin ( struct BMIter__edge_of_face iter)

◆ bmiter__edge_of_face_step()

void* bmiter__edge_of_face_step ( struct BMIter__edge_of_face iter)

◆ bmiter__edge_of_vert_begin()

void bmiter__edge_of_vert_begin ( struct BMIter__edge_of_vert iter)

◆ bmiter__edge_of_vert_step()

void* bmiter__edge_of_vert_step ( struct BMIter__edge_of_vert iter)

◆ bmiter__elem_of_mesh_begin()

void bmiter__elem_of_mesh_begin ( struct BMIter__elem_of_mesh iter)

Notes on iterator implementation:

Iterators keep track of the next element in a sequence. When a step() callback is invoked the current value of 'next' is stored to be returned later and the next variable is incremented.

When the end of a sequence is reached, next should always equal NULL

The 'bmiter__' prefix is used because these are used in bmesh_iterators_inine.c but should otherwise be seen as private.

Definition at line 361 of file bmesh_iterators.c.

References BLI_mempool_iternew(), BLI_mempool_len(), BLI_mempool_iter::pool, and BMIter__elem_of_mesh::pooliter.

Referenced by BM_iter_init().

◆ bmiter__elem_of_mesh_step()

void* bmiter__elem_of_mesh_step ( struct BMIter__elem_of_mesh iter)

◆ bmiter__face_of_edge_begin()

void bmiter__face_of_edge_begin ( struct BMIter__face_of_edge iter)

◆ bmiter__face_of_edge_step()

void* bmiter__face_of_edge_step ( struct BMIter__face_of_edge iter)

◆ bmiter__face_of_vert_begin()

void bmiter__face_of_vert_begin ( struct BMIter__face_of_vert iter)

◆ bmiter__face_of_vert_step()

void* bmiter__face_of_vert_step ( struct BMIter__face_of_vert iter)

◆ bmiter__loop_of_edge_begin()

void bmiter__loop_of_edge_begin ( struct BMIter__loop_of_edge iter)

◆ bmiter__loop_of_edge_step()

void* bmiter__loop_of_edge_step ( struct BMIter__loop_of_edge iter)

◆ bmiter__loop_of_face_begin()

void bmiter__loop_of_face_begin ( struct BMIter__loop_of_face iter)

◆ bmiter__loop_of_face_step()

void* bmiter__loop_of_face_step ( struct BMIter__loop_of_face iter)

◆ bmiter__loop_of_loop_begin()

void bmiter__loop_of_loop_begin ( struct BMIter__loop_of_loop iter)

◆ bmiter__loop_of_loop_step()

void* bmiter__loop_of_loop_step ( struct BMIter__loop_of_loop iter)

◆ bmiter__loop_of_vert_begin()

void bmiter__loop_of_vert_begin ( struct BMIter__loop_of_vert iter)

◆ bmiter__loop_of_vert_step()

void* bmiter__loop_of_vert_step ( struct BMIter__loop_of_vert iter)

◆ bmiter__vert_of_edge_begin()

void bmiter__vert_of_edge_begin ( struct BMIter__vert_of_edge iter)

Definition at line 570 of file bmesh_iterators.c.

Referenced by BM_iter_init().

◆ bmiter__vert_of_edge_step()

void* bmiter__vert_of_edge_step ( struct BMIter__vert_of_edge iter)

Definition at line 575 of file bmesh_iterators.c.

References count, BMIter__vert_of_edge::edata, NULL, BMEdge::v1, and BMEdge::v2.

Referenced by BM_iter_init().

◆ bmiter__vert_of_face_begin()

void bmiter__vert_of_face_begin ( struct BMIter__vert_of_face iter)

◆ bmiter__vert_of_face_step()

void* bmiter__vert_of_face_step ( struct BMIter__vert_of_face iter)

◆ BMO_iter_as_array()

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

Operator Iterator as Array.

Sometimes its convenient to get the iterator as an array.

Definition at line 101 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,
char  itype,
void data,
short  oflag,
bool  value 
)

Elem Iter Tool Flag Count.

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

Definition at line 279 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]