Blender  V2.59
BKE_mesh.h
Go to the documentation of this file.
00001 /*
00002  * blenlib/BKE_mesh.h (mar-2001 nzc)
00003  *      
00004  * $Id: BKE_mesh.h 36332 2011-04-26 07:17:21Z campbellbarton $ 
00005  *
00006  * ***** BEGIN GPL LICENSE BLOCK *****
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software Foundation,
00020  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00021  *
00022  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00023  * All rights reserved.
00024  *
00025  * The Original Code is: all of this file.
00026  *
00027  * Contributor(s): none yet.
00028  *
00029  * ***** END GPL LICENSE BLOCK *****
00030  */
00031 #ifndef BKE_MESH_H
00032 #define BKE_MESH_H
00033 
00038 /***/
00039 
00040 struct BoundBox;
00041 struct DispList;
00042 struct ListBase;
00043 struct EditMesh;
00044 struct MDeformVert;
00045 struct Mesh;
00046 struct MFace;
00047 struct MEdge;
00048 struct MVert;
00049 struct MCol;
00050 struct Object;
00051 struct MTFace;
00052 struct VecNor;
00053 struct CustomData;
00054 struct DerivedMesh;
00055 struct Scene;
00056 
00057 #ifdef __cplusplus
00058 extern "C" {
00059 #endif
00060 
00061 struct EditMesh *BKE_mesh_get_editmesh(struct Mesh *me);
00062 void BKE_mesh_end_editmesh(struct Mesh *me, struct EditMesh *em);
00063 
00064 void unlink_mesh(struct Mesh *me);
00065 void free_mesh(struct Mesh *me);
00066 struct Mesh *add_mesh(const char *name);
00067 struct Mesh *copy_mesh(struct Mesh *me);
00068 void mesh_update_customdata_pointers(struct Mesh *me);
00069 void make_local_mesh(struct Mesh *me);
00070 void boundbox_mesh(struct Mesh *me, float *loc, float *size);
00071 void tex_space_mesh(struct Mesh *me);
00072 float *get_mesh_orco_verts(struct Object *ob);
00073 void transform_mesh_orco_verts(struct Mesh *me, float (*orco)[3], int totvert, int invert);
00074 int test_index_face(struct MFace *mface, struct CustomData *mfdata, int mfindex, int nr);
00075 struct Mesh *get_mesh(struct Object *ob);
00076 void set_mesh(struct Object *ob, struct Mesh *me);
00077 void mball_to_mesh(struct ListBase *lb, struct Mesh *me);
00078 int nurbs_to_mdata(struct Object *ob, struct MVert **allvert, int *_totvert,
00079         struct MEdge **alledge, int *_totedge, struct MFace **allface, int *_totface);
00080 int nurbs_to_mdata_customdb(struct Object *ob, struct ListBase *dispbase,
00081         struct MVert **allvert, int *_totvert, struct MEdge **alledge, int *_totedge,
00082         struct MFace **allface, int *_totface);
00083 void nurbs_to_mesh(struct Object *ob);
00084 void mesh_to_curve(struct Scene *scene, struct Object *ob);
00085 void free_dverts(struct MDeformVert *dvert, int totvert);
00086 void copy_dverts(struct MDeformVert *dst, struct MDeformVert *src, int totvert); /* __NLA */
00087 void mesh_delete_material_index(struct Mesh *me, int index);
00088 void mesh_set_smooth_flag(struct Object *meshOb, int enableSmooth);
00089 
00090 struct BoundBox *mesh_get_bb(struct Object *ob);
00091 void mesh_get_texspace(struct Mesh *me, float *loc_r, float *rot_r, float *size_r);
00092 
00093 /* if old, it converts mface->edcode to edge drawflags */
00094 void make_edges(struct Mesh *me, int old);
00095 
00096 void mesh_strip_loose_faces(struct Mesh *me);
00097 void mesh_strip_loose_edges(struct Mesh *me);
00098 
00099         /* Calculate vertex and face normals, face normals are returned in *faceNors_r if non-NULL
00100          * and vertex normals are stored in actual mverts.
00101          */
00102 void mesh_calc_normals(struct MVert *mverts, int numVerts, struct MFace *mfaces, int numFaces, float (*faceNors_r)[3]);
00103 
00104         /* Return a newly MEM_malloc'd array of all the mesh vertex locations
00105          * (_numVerts_r_ may be NULL) */
00106 float (*mesh_getVertexCos(struct Mesh *me, int *numVerts_r))[3];
00107 
00108 /* map from uv vertex to face (for select linked, stitch, uv suburf) */
00109 
00110 /* UvVertMap */
00111 
00112 #define STD_UV_CONNECT_LIMIT    0.0001f
00113 
00114 typedef struct UvVertMap {
00115         struct UvMapVert **vert;
00116         struct UvMapVert *buf;
00117 } UvVertMap;
00118 
00119 typedef struct UvMapVert {
00120         struct UvMapVert *next;
00121         unsigned int f;
00122         unsigned char tfindex, separate, flag;
00123 } UvMapVert;
00124 
00125 UvVertMap *make_uv_vert_map(struct MFace *mface, struct MTFace *tface, unsigned int totface, unsigned int totvert, int selected, float *limit);
00126 UvMapVert *get_uv_map_vert(UvVertMap *vmap, unsigned int v);
00127 void free_uv_vert_map(UvVertMap *vmap);
00128 
00129 /* Connectivity data */
00130 typedef struct IndexNode {
00131         struct IndexNode *next, *prev;
00132         int index;
00133 } IndexNode;
00134 void create_vert_face_map(ListBase **map, IndexNode **mem, const struct MFace *mface,
00135                           const int totvert, const int totface);
00136 void create_vert_edge_map(ListBase **map, IndexNode **mem, const struct MEdge *medge,
00137                           const int totvert, const int totedge);
00138 
00139 /* Partial Mesh Visibility */
00140 struct PartialVisibility *mesh_pmv_copy(struct PartialVisibility *);
00141 void mesh_pmv_free(struct PartialVisibility *);
00142 void mesh_pmv_revert(struct Mesh *me);
00143 void mesh_pmv_off(struct Mesh *me);
00144 
00145 /* functions for making menu's from customdata layers */
00146 int mesh_layers_menu_charlen(struct CustomData *data, int type); /* use this to work out how many chars to allocate */
00147 void mesh_layers_menu_concat(struct CustomData *data, int type, char *str);
00148 int mesh_layers_menu(struct CustomData *data, int type);
00149 
00150 /* vertex level transformations & checks (no derived mesh) */
00151 
00152 int minmax_mesh(struct Mesh *me, float min[3], float max[3]);
00153 int mesh_center_median(struct Mesh *me, float cent[3]);
00154 int mesh_center_bounds(struct Mesh *me, float cent[3]);
00155 void mesh_translate(struct Mesh *me, float offset[3], int do_keys);
00156 
00157 /* mesh_validate.c */
00158 int BKE_mesh_validate_arrays(struct Mesh *me, struct MVert *mverts, unsigned int totvert, struct MEdge *medges, unsigned int totedge, struct MFace *mfaces, unsigned int totface, const short do_verbose, const short do_fixes);
00159 int BKE_mesh_validate(struct Mesh *me, int do_verbose);
00160 int BKE_mesh_validate_dm(struct DerivedMesh *dm);
00161 
00162 void BKE_mesh_calc_edges(struct Mesh *mesh, int update);
00163 
00164 #ifdef __cplusplus
00165 }
00166 #endif
00167 
00168 #endif /* BKE_MESH_H */