6 * $Id: BKE_bmesh.h,v 1.00 2007/01/17 17:42:01 Briggs Exp $
8 * ***** BEGIN GPL LICENSE BLOCK *****
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version. The Blender
14 * Foundation also sells licenses for use in proprietary software under
15 * the Blender License. See http://www.blender.org/BL/ for information
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software Foundation,
25 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 * The Original Code is Copyright (C) 2004 Blender Foundation.
28 * All rights reserved.
30 * The Original Code is: all of this file.
32 * Contributor(s): Geoffrey Bantle, Levi Schooley.
34 * ***** END GPL LICENSE BLOCK *****
40 #include "DNA_listBase.h"
41 #include "DNA_customdata_types.h"
42 #include "BLI_mempool.h"
43 #include "BKE_customdata.h"
45 /*forward declarations*/
54 * All mesh elements begin with a BMHeader. This structure
55 * hold several types of data
57 * 1: The type of the element (vert, edge, loop or face)
58 * 2: Persistant flags/markings (sharp, seam, select, hidden, ect)
59 * 3: Unique ID in the bmesh.
60 * 4: some elements for internal record keeping.
69 #define BM_ALL BM_VERT | BM_EDGE | BM_FACE | BM_LOOP
72 #define BM_SELECT (1<<0)
74 #define BM_SEAM (1<<1)
75 #define BM_FGON (1<<2)
76 #define BM_HIDDEN (1<<3)
77 #define BM_SHARP (1<<4)
78 #define BM_SMOOTH (1<<5)
80 typedef struct BMHeader {
81 struct BMHeader *next, *prev;
82 int EID; /*Consider removing this/making it ifdeffed for debugging*/
84 int eflag1, eflag2; /*Flags used by eulers. Try and get rid of/minimize some of these*/
85 struct BMFlagLayer *flags; /*Dynamically allocated block of flag layers for operators to use*/
88 typedef struct BMFlagLayer {
93 #define BM_OVERLAP (1<<14) /*used by bmesh_verts_in_face*/
94 #define BM_EDGEVERT (1<<15) /*used by bmesh_make_ngon*/
99 * Used for circular/linked list functions that form basis of
100 * adjacency system in BMesh. This should probably be hidden
101 * somewhere since tool authors never need to know about it.
105 typedef struct BMNode {
106 struct BMNode *next, *prev;
110 typedef struct BMesh {
111 ListBase verts, edges, polys;
112 struct BLI_mempool *vpool;
113 struct BLI_mempool *epool;
114 struct BLI_mempool *lpool;
115 struct BLI_mempool *ppool;
116 struct BMVert **vtar;
117 struct BMEdge **edar;
118 struct BMLoop **lpar;
119 struct BMFace **plar;
120 int vtarlen, edarlen, lparlen, plarlen;
121 int totvert, totedge, totface, totloop;
122 int nextv, nexte, nextp, nextl;
123 struct CustomData vdata, edata, pdata, ldata;
125 struct BLI_mempool *flagpool; /*memory pool for dynamically allocated flag layers*/
126 int stackdepth; /*current depth of operator stack*/
127 int totflags, walkers; /*total number of tool flag layers*/
131 typedef struct BMVert {
132 struct BMHeader head;
138 float bweight; /*please, someone just get rid of me...*/
141 typedef struct BMEdge {
142 struct BMHeader head;
143 struct BMVert *v1, *v2;
144 struct BMNode d1, d2;
147 float crease, bweight; /*make these custom data.... no really, please....*/
150 typedef struct BMLoop {
151 struct BMHeader head;
152 struct BMNode radial;
159 typedef struct BMFace {
160 struct BMHeader head;
161 struct BMLoop *loopbase;
166 /*custom data again*/
171 void bmesh_error(void);
174 struct BMesh *BM_Make_Mesh(int allocsize[4]);
175 void BM_Free_Mesh(struct BMesh *bm);
176 void BM_Compute_Normals(struct BMesh *bm);
179 struct BMVert *BM_Make_Vert(struct BMesh *bm, float co[3], struct BMVert *example);
180 struct BMEdge *BM_Make_Edge(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge *example, int nodouble);
181 struct BMFace *BM_Make_Quadtriangle(struct BMesh *bm, struct BMVert **verts, BMEdge **edges, int len, struct BMFace *example, int nodouble);
182 struct BMFace *BM_Make_Ngon(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMEdge **edges, int len, int nodouble);
183 void BM_Copy_Attributes(struct BMesh *source_mesh, struct BMesh *target_mesh, void *source, void *target);
184 void BM_remove_tagged_faces(struct BMesh *bm, int flag);
185 void BM_remove_tagged_edges(struct BMesh *bm, int flag);
186 void BM_remove_tagged_verts(struct BMesh *bm, int flag);
190 struct BMFace *BM_Join_Faces(struct BMesh *bm, struct BMFace *f1, struct BMFace *f2, struct BMEdge *e, int calcnorm, int weldUVs);
191 struct BMFace *BM_Split_Face(struct BMesh *bm, struct BMFace *f, struct BMVert *v1, struct BMVert *v2, struct BMLoop **nl, struct BMEdge *example, int calcnorm);
192 void BM_Collapse_Vert(struct BMesh *bm, struct BMEdge *ke, struct BMVert *kv, float fac, int calcnorm);
193 struct BMVert *BM_Split_Edge(struct BMesh *bm, struct BMVert *v, struct BMEdge *e, struct BMEdge **ne, float percent, int calcnorm);
194 struct BMVert *BM_Split_Edge_Multi(struct BMesh *bm, struct BMEdge *e, int numcuts);
195 BMEdge *BM_Connect_Verts(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **nf);
196 void BM_Dissolve_Disk(BMesh *bm, BMVert *v);
199 void BM_Data_Interp_From_Verts(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, float fac);
200 void BM_Data_Facevert_Edgeinterp(struct BMesh *bm, struct BMVert *v1, struct BMVert *v2, struct BMVert *v, struct BMEdge *e1, float fac);
201 //void bmesh_data_interp_from_face(struct BMesh *bm, struct BMFace *source, struct BMFace *target);
204 BMesh *editmesh_to_bmesh(struct EditMesh *em);
205 struct EditMesh *bmesh_to_editmesh(BMesh *bm);
207 /*include the rest of the API*/
208 #include "bmesh_filters.h"
209 #include "bmesh_iterators.h"
210 #include "bmesh_marking.h"
211 #include "bmesh_operators.h"
212 #include "bmesh_queries.h"