4 #include "BLI_memarena.h"
7 #define BMOP_OPSLOT_INT 0
8 #define BMOP_OPSLOT_FLT 1
9 #define BMOP_OPSLOT_PNT 2
10 #define BMOP_OPSLOT_VEC 6
12 /*after BMOP_OPSLOT_VEC, everything is
13 dynamically allocated arrays. we
14 leave a space in the identifiers
16 #define BMOP_OPSLOT_PNT_BUF 7
18 #define BMOP_OPSLOT_MAPPING 8
19 #define BMOP_OPSLOT_TYPES 9
21 typedef struct BMOpSlot{
25 int index; /*index within slot array*/
30 float vec[3]; /*vector*/
37 /*is a dynamically-allocated array. set at runtime.*/
38 #define BMOS_DYNAMIC_ARRAY 1
40 /*operators represent logical, executable mesh modules.*/
41 #define BMOP_MAX_SLOTS 16 /*way more than probably needed*/
43 typedef struct BMOperator{
47 struct BMOpSlot slots[BMOP_MAX_SLOTS];
48 void (*exec)(struct BMesh *bm, struct BMOperator *op);
52 /*need to refactor code to use this*/
53 typedef struct BMOpDefine {
54 int slottypes[BMOP_MAX_SLOTS];
55 void (*exec)(BMesh *bm, BMOperator *op);
61 //doesn't do anything at the moment.
65 /*data types that use pointers (arrays, etc) should never
66 have it set directly. and never use BMO_Set_Pnt to
67 pass in a list of edges or any arrays, really.*/
68 void BMO_Init_Op(struct BMOperator *op, int opcode);
69 void BMO_Exec_Op(struct BMesh *bm, struct BMOperator *op);
70 void BMO_Finish_Op(struct BMesh *bm, struct BMOperator *op);
71 BMOpSlot *BMO_GetSlot(struct BMOperator *op, int slotcode);
72 void BMO_CopySlot(struct BMOperator *source_op, struct BMOperator *dest_op, int src, int dst);
73 void BMO_Set_Float(struct BMOperator *op, int slotcode, float f);
74 void BMO_Set_Int(struct BMOperator *op, int slotcode, int i);
75 void BMO_Set_Pnt(struct BMOperator *op, int slotcode, void *p);
76 void BMO_Set_Vec(struct BMOperator *op, int slotcode, float *vec);
77 void BMO_SetFlag(struct BMesh *bm, void *element, int flag);
78 void BMO_ClearFlag(struct BMesh *bm, void *element, int flag);
79 int BMO_TestFlag(struct BMesh *bm, void *element, int flag);
80 int BMO_CountFlag(struct BMesh *bm, int flag, int type);
81 void BMO_Flag_To_Slot(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag, int type);
82 void BMO_Flag_Buffer(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag);
83 void BMO_Unflag_Buffer(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag);
84 void BMO_HeaderFlag_To_Slot(struct BMesh *bm, struct BMOperator *op, int slotcode, int flag, int type);
85 int BMO_CountSlotBuf(struct BMesh *bm, struct BMOperator *op, int slotcode);
87 /*copies data, doesn't store a reference to it.*/
88 void BMO_Insert_Mapping(BMesh *bm, BMOperator *op, int slotcode,
89 void *element, void *data, int len);
90 void BMO_Insert_MapFloat(BMesh *bm, BMOperator *op, int slotcode,
91 void *element, float val);
93 //returns 1 if the specified element is in the map.
94 int BMO_InMap(BMesh *bm, BMOperator *op, int slotcode, void *element);
95 void *BMO_Get_MapData(BMesh *bm, BMOperator *op, int slotcode,
97 float BMO_Get_MapFloat(BMesh *bm, BMOperator *op, int slotcode,
99 void BMO_Mapping_To_Flag(struct BMesh *bm, struct BMOperator *op,
100 int slotcode, int flag);
102 /*do NOT use these for non-operator-api-allocated memory! instead
103 use BMO_Get_MapData, which copies the data.*/
104 void BMO_Insert_MapPointer(BMesh *bm, BMOperator *op, int slotcode,
105 void *element, void *val);
106 void *BMO_Get_MapPointer(BMesh *bm, BMOperator *op, int slotcode,
109 struct GHashIterator;
110 typedef struct BMOIter {
112 int cur; //for arrays
113 struct GHashIterator giter;
117 void *BMO_IterNew(BMOIter *iter, BMesh *bm, BMOperator *op,
119 void *BMO_IterStep(BMOIter *iter);
121 /*returns a pointer to the key value when iterating over mappings.
122 remember for pointer maps this will be a pointer to a pointer.*/
123 void *BMO_IterMapVal(BMOIter *iter);
125 /*----------- bmop error system ----------*/
127 /*pushes an error onto the bmesh error stack.
128 if msg is null, then the default message for the errorcode is used.*/
129 void BMO_RaiseError(BMesh *bm, BMOperator *owner, int errcode, char *msg);
131 /*gets the topmost error from the stack.
132 returns error code or 0 if no error.*/
133 int BMO_GetError(BMesh *bm, char **msg, BMOperator **op);
135 /*same as geterror, only pops the error off the stack as well*/
136 int BMO_PopError(BMesh *bm, char **msg, BMOperator **op);
137 void BMO_ClearStack(BMesh *bm);
140 //this is meant for handling errors, like self-intersection test failures.
141 //it's dangerous to handle errors in general though, so disabled for now.
143 /*catches an error raised by the op pointed to by catchop.
144 errorcode is either the errorcode, or BMERR_ALL for any
146 int BMO_CatchOpError(BMesh *bm, BMOperator *catchop, int errorcode, char **msg);
149 /*------ error code defines -------*/
152 #define BMERR_SELF_INTERSECTING 1
153 #define BMERR_DISSOLVEDISK_FAILED 2
155 static char *bmop_error_messages[] = {
157 "Self intersection error",
158 "Could not dissolve vert",
161 /*------------begin operator defines (see bmesh_opdefines.c too)------------*/
168 BMOP_SPLIT_BOUNDS_EDGEMAP, //bounding edges of split faces
179 /*we need a map for verts duplicated not connected
181 BMOP_DUPE_BOUNDS_EDGEMAP,
196 #define DEL_ONLYFACES 3
197 #define DEL_EDGESFACES 4
200 #define DEL_ONLYTAGGED 7
211 /*editmesh->bmesh op*/
212 #define BMOP_FROM_EDITMESH 3
214 BMOP_FROM_EDITMESH_EM,
215 BMOP_FROM_EDITMESH_TOTSLOT,
218 #define BMOP_TO_EDITMESH 4
219 /*bmesh->editmesh op*/
221 BMOP_TO_EDITMESH_EMOUT,
222 BMOP_TO_EDITMESH_TOTSLOT,
225 /*edge subdivide op*/
226 #define BMOP_ESUBDIVIDE 5
228 BMOP_ESUBDIVIDE_EDGES,
229 BMOP_ESUBDIVIDE_NUMCUTS,
230 BMOP_ESUBDIVIDE_FLAG, //beauty flag in esubdivide
231 BMOP_ESUBDIVIDE_RADIUS,
233 BMOP_ESUBDIVIDE_CUSTOMFILL_FACEMAP,
234 BMOP_ESUBDIVIDE_PERCENT_EDGEMAP,
236 /*inner verts/new faces of completely filled faces, e.g.
237 fully selected face.*/
238 BMOP_ESUBDIVIDE_INNER_MULTOUT,
240 /*new edges and vertices from splitting original edges,
241 doesn't include edges creating by connecting verts.*/
242 BMOP_ESUBDIVIDE_SPLIT_MULTOUT,
243 BMOP_ESUBDIVIDE_TOTSLOT,
248 SUBDIV_SELECT_INNER_SEL
249 SUBDIV_SELECT_LOOPCUT
254 #define BMOP_TRIANGULATE 6
258 BMOP_TRIANG_NEW_EDGES,
259 BMOP_TRIANG_NEW_FACES,
264 #define BMOP_DISSOLVE_FACES 7
266 BMOP_DISFACES_FACEIN,
267 //list of faces that comprise regions of split faces
268 BMOP_DISFACES_REGIONOUT,
269 BMOP_DISFACES_TOTSLOT,
273 #define BMOP_DISSOLVE_VERTS 8
275 #define BMOP_DISVERTS_VERTIN 0
276 #define BMOP_DISVERTS_TOTSLOT 1
278 #define BMOP_MAKE_FGONS 9
279 #define BMOP_MAKE_FGONS_TOTSLOT 0
281 #define BMOP_EXTRUDE_EDGECONTEXT 10
283 BMOP_EXFACE_EDGEFACEIN,
284 BMOP_EXFACE_EXCLUDEMAP, //exclude edges from skirt connecting
285 BMOP_EXFACE_MULTOUT, //new geometry
290 /*keep this updated!*/
291 #define BMOP_TOTAL_OPS 11
292 /*-------------------------------end operator defines-------------------------------*/
294 extern BMOpDefine *opdefines[];
295 extern int bmesh_total_ops;
297 /*------specific operator helper functions-------*/
299 /*executes the duplicate operation, feeding elements of
300 type flag etypeflag and header flag flag to it. note,
301 to get more useful information (such as the mapping from
302 original to new elements) you should run the dupe op manually.*/
306 void BMOP_DupeFromFlag(struct BMesh *bm, int etypeflag, int flag);
307 void BM_esubdivideflag(struct Object *obedit, struct BMesh *bm, int selflag, float rad,
308 int flag, int numcuts, int seltype);
309 void BM_extrudefaceflag(BMesh *bm, int flag);
310 int BM_DissolveFaces(struct EditMesh *em, int flag);