Blender  V3.3
Functions
bmesh_walkers.c File Reference
#include <stdlib.h>
#include <string.h>
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "bmesh.h"
#include "bmesh_walkers_private.h"

Go to the source code of this file.

Functions

voidBMW_begin (BMWalker *walker, void *start)
 
void BMW_init (BMWalker *walker, BMesh *bm, int type, short mask_vert, short mask_edge, short mask_face, BMWFlag flag, int layer)
 Init Walker. More...
 
void BMW_end (BMWalker *walker)
 End Walker. More...
 
voidBMW_step (BMWalker *walker)
 Step Walker. More...
 
int BMW_current_depth (BMWalker *walker)
 Walker Current Depth. More...
 
voidBMW_walk (BMWalker *walker)
 Main Walking Function. More...
 
voidBMW_current_state (BMWalker *walker)
 Current Walker State. More...
 
void BMW_state_remove (BMWalker *walker)
 Remove Current Walker State. More...
 
voidBMW_state_add (BMWalker *walker)
 Add a new Walker State. More...
 
void BMW_reset (BMWalker *walker)
 Reset Walker. More...
 

Detailed Description

BMesh Walker API.

Definition in file bmesh_walkers.c.

Function Documentation

◆ BMW_begin()

void* BMW_begin ( BMWalker walker,
void start 
)

NOTE(@joeedh): Details on design.

Original design: walkers directly emulation recursive functions. functions save their state onto a BMWalker.worklist, and also add new states to implement recursive or looping behavior. Generally only one state push per call with a specific state is desired.

basic design pattern: the walker step function goes through its list of possible choices for recursion, and recurses (by pushing a new state) using the first non-visited one. This choice is the flagged as visited using the GHash. Each step may push multiple new states onto the BMWalker.worklist at once.

  • Walkers use tool flags, not header flags.
  • Walkers now use GHash for storing visited elements, rather than stealing flags. GHash can be rewritten to be faster if necessary, in the far future :) .
  • tools should ALWAYS have necessary error handling for if walkers fail.

Definition at line 40 of file bmesh_walkers.c.

References BMWalker::begin, BMWalker::begin_htype, BLI_assert, BMW_current_state(), NULL, and BMWalker::step.

Referenced by BM_mesh_decimate_unsubdivide_ex(), bmo_collapse_exec(), bmo_collapsecon_do_layer(), bmo_dissolve_faces_exec(), check_hole_in_region(), edgering_select(), view3d_preselect_mesh_edgering_update_edges_from_edge(), walker_deselect_nth(), walker_select(), and walker_select_count().

◆ BMW_current_depth()

int BMW_current_depth ( BMWalker walker)

Walker Current Depth.

Returns the current depth of the walker.

Definition at line 123 of file bmesh_walkers.c.

References BMWalker::depth.

Referenced by BM_mesh_decimate_unsubdivide_ex(), and walker_deselect_nth().

◆ BMW_current_state()

void* BMW_current_state ( BMWalker walker)

◆ BMW_end()

void BMW_end ( struct BMWalker walker)

◆ BMW_init()

void BMW_init ( struct BMWalker walker,
BMesh bm,
int  type,
short  mask_vert,
short  mask_edge,
short  mask_face,
BMWFlag  flag,
int  layer 
)

◆ BMW_reset()

void BMW_reset ( BMWalker walker)

Reset Walker.

Frees all states from the worklist, resetting the walker for reuse in a new walk.

Definition at line 187 of file bmesh_walkers.c.

References BLI_gset_clear(), BMW_current_state(), BMW_state_remove(), BMWalker::depth, NULL, BMWalker::visit_set, and BMWalker::visit_set_alt.

◆ BMW_state_add()

void* BMW_state_add ( BMWalker walker)

◆ BMW_state_remove()

void BMW_state_remove ( BMWalker walker)

Remove Current Walker State.

Remove and free an item from the end of the walker state worklist.

Definition at line 160 of file bmesh_walkers.c.

References BLI_mempool_free(), BLI_remlink(), BMW_current_state(), BMWalker::states, and BMWalker::worklist.

Referenced by bmw_IslandboundWalker_step(), and BMW_reset().

◆ BMW_step()

void* BMW_step ( BMWalker walker)

◆ BMW_walk()

void* BMW_walk ( BMWalker walker)

Main Walking Function.

Steps a mesh walker forward by one element

Definition at line 128 of file bmesh_walkers.c.

References BMW_current_state(), NULL, and BMWalker::step.

Referenced by bmw_EdgeLoopWalker_begin(), bmw_EdgeringWalker_begin(), bmw_FaceLoopWalker_begin(), and BMW_step().