Blender V4.3
bmesh_walkers.cc File Reference
#include <cstdlib>
#include <cstring>
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
#include "bmesh.hh"
#include "bmesh_walkers_private.hh"

Go to the source code of this file.

Functions

void * BMW_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.
 
void BMW_end (BMWalker *walker)
 End Walker.
 
void * BMW_step (BMWalker *walker)
 Step Walker.
 
int BMW_current_depth (BMWalker *walker)
 Walker Current Depth.
 
void * BMW_walk (BMWalker *walker)
 Main Walking Function.
 
void * BMW_current_state (BMWalker *walker)
 Current Walker State.
 
void BMW_state_remove (BMWalker *walker)
 Remove Current Walker State.
 
void * BMW_state_add (BMWalker *walker)
 Add a new Walker State.
 
void BMW_reset (BMWalker *walker)
 Reset Walker.
 

Detailed Description

BMesh Walker API.

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 in file bmesh_walkers.cc.

Function Documentation

◆ BMW_begin()

◆ 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.cc.

References BMWalker::depth.

Referenced by BM_mesh_decimate_unsubdivide_ex(), and walker_deselect_nth().

◆ BMW_current_state()

◆ BMW_end()

◆ BMW_init()

◆ 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.cc.

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

◆ BMW_state_add()

◆ 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.cc.

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

Referenced by bmw_IslandboundWalker_step(), and BMW_reset().

◆ BMW_step()

◆ 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.cc.

References BMW_current_state(), and BMWalker::step.

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