Welcome to mirror list, hosted at ThFree Co, Russian Federation.

bmesh_walkers.h « bmesh « blender « source - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3d6891c1c3918d9942bad227df884e3a29ac902e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef BM_WALKERS_H
#define BM_WALKERS_H

#include "BLI_ghash.h"

/*
  NOTE: do NOT modify topology while walking a mesh!
*/

/*Walkers*/
typedef struct BMWalker {
	BLI_mempool *stack;
	BMesh *bm;
	void *currentstate;
	void (*begin) (struct BMWalker *walker, void *start);
	void *(*yield)(struct BMWalker *walker);
	void *(*step) (struct BMWalker *walker);
	int restrictflag;
	GHash *visithash;
	int flag;
} BMWalker;

/*initialize a walker.  searchmask restricts some (not all) walkers to
  elements with a specific tool flag set.  flags is specific to each walker.*/
void BMW_Init(struct BMWalker *walker, BMesh *bm, int type, int searchmask, int flags);
void *BMW_Begin(BMWalker *walker, void *start);
void *BMW_Step(struct BMWalker *walker);
void BMW_End(struct BMWalker *walker);

/*
example of usage, walking over an island of tool flagged faces:

BMWalker walker;
BMFace *f;

BMW_Init(&walker, bm, BMW_ISLAND, SOME_OP_FLAG);
f = BMW_Begin(&walker, some_start_face);
for (; f; f=BMW_Step(&walker)) {
	//do something with f
}
BMW_End(&walker);
*/

enum {
	/*walk over connected geometry.  can restrict to a search flag,
	or not, it's optional.
	
	takes a vert as an arugment, and spits out edges, restrict flag acts
	on the edges as well.*/
	BMW_SHELL,
	/*walk over an edge loop.  search flag doesn't do anything.*/
	BMW_LOOP,
	BMW_FACELOOP,
	BMW_EDGERING,
	/*#define BMW_RING	2*/
	//walk over uv islands; takes a loop as input.  restrict flag 
	//restricts the walking to loops whose vert has restrict flag set as a
	//tool flag.
	//
	//the flag parameter to BMW_Init maps to a loop customdata layer index.
	BMW_LOOPDATA_ISLAND,
	/*walk over an island of flagged faces.  note, that this doesn't work on
	  non-manifold geometry.  it might be better to rewrite this to extract
	  boundary info from the island walker, rather then directly walking
	  over the boundary.  raises an error if it encouters nonmanifold
	  geometry.*/
	BMW_ISLANDBOUND,
	/*walk over all faces in an island of tool flagged faces.*/
	BMW_ISLAND,
	BMW_MAXWALKERS,
};

#endif