diff options
author | Campbell Barton <ideasman42@gmail.com> | 2012-02-28 22:28:30 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2012-02-28 22:28:30 +0400 |
commit | d1d11bbe9bc73f8578dbd138d079dc6488b5920d (patch) | |
tree | 09e60c6006fa5f0fdef22d7027f75b6a3a2079af /source/blender/bmesh/intern | |
parent | df0f0c63d32b3819bab625f72d62e1fcf6d5ced5 (diff) |
more header re-arranging.
Some function comments were in headers, some in the C files, some in both.
Moved function comments from headers into the C files.
Diffstat (limited to 'source/blender/bmesh/intern')
20 files changed, 510 insertions, 430 deletions
diff --git a/source/blender/bmesh/intern/bmesh_construct.c b/source/blender/bmesh/intern/bmesh_construct.c index 9056f59835c..f6883c5596e 100644 --- a/source/blender/bmesh/intern/bmesh_construct.c +++ b/source/blender/bmesh/intern/bmesh_construct.c @@ -73,7 +73,6 @@ BMFace *BM_face_create_quad_tri(BMesh *bm, return BM_face_create_quad_tri_v(bm, vtar, v4 ? 4 : 3, example, nodouble); } -/* remove the edge array bits from this. Its not really needed? */ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFace *example, const int nodouble) { BMFace *f = NULL; @@ -107,7 +106,6 @@ BMFace *BM_face_create_quad_tri_v(BMesh *bm, BMVert **verts, int len, const BMFa return f; } - /* copies face data from shared adjacent faces */ void BM_face_copy_shared(BMesh *bm, BMFace *f) { @@ -132,8 +130,8 @@ void BM_face_copy_shared(BMesh *bm, BMFace *f) /** * \brief BMESH MAKE NGON * - * Attempts to make a new Ngon from a list of edges. - * If nodouble equals one, a check for overlaps or existing + * Makes an ngon from an unordered list of edges. v1 and v2 must be the verts + * defining edges[0], and define the winding of the new face. * * The edges are not required to be ordered, simply to to form * a single closed loop as a whole @@ -371,8 +369,12 @@ static void bmo_remove_tagged_context_edges(BMesh *bm, const short oflag) #define DEL_WIREVERT (1 << 10) -/* warning, oflag applies to different types in some contexts, - * not just the type being removed */ +/** + * \warning oflag applies to different types in some contexts, + * not just the type being removed. + * + * \warning take care, uses operator flag DEL_WIREVERT + */ void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type) { BMVert *v; @@ -537,6 +539,10 @@ static void bm_face_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, /* BMESH_TODO: Special handling for hide flags? */ +/** + * Copies attributes, e.g. customdata, header flags, etc, from one element + * to another of the same type. + */ void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *source, void *target) { const BMHeader *sheader = source; diff --git a/source/blender/bmesh/intern/bmesh_construct.h b/source/blender/bmesh/intern/bmesh_construct.h new file mode 100644 index 00000000000..8d624592ae7 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_construct.h @@ -0,0 +1,58 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Joseph Eagar. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_CONSTRUCT_H__ +#define __BMESH_CONSTRUCT_H__ + +/** \file blender/bmesh/intern/bmesh_construct.h + * \ingroup bmesh + */ + +BMFace *BM_face_create_quad_tri_v(BMesh *bm, + BMVert **verts, int len, + const BMFace *example, const int nodouble); + +BMFace *BM_face_create_quad_tri(BMesh *bm, BMVert *v1, BMVert *v2, BMVert *v3, BMVert *v4, + const BMFace *example, const int nodouble); + +void BM_face_copy_shared(BMesh *bm, BMFace *f); + +BMFace *BM_face_create_ngon(BMesh *bm, BMVert *v1, BMVert *v2, BMEdge **edges, int len, int nodouble); + +void BMO_remove_tagged_faces(BMesh *bm, const short oflag); +void BMO_remove_tagged_edges(BMesh *bm, const short oflag); +void BMO_remove_tagged_verts(BMesh *bm, const short oflag); + +void BMO_remove_tagged_context(BMesh *bm, const short oflag, const int type); + +void BM_elem_attrs_copy(BMesh *source_mesh, BMesh *target_mesh, const void *source, void *target); + +BMesh *BM_mesh_copy(BMesh *bmold); + +char BM_face_flag_from_mflag(const char mflag); +char BM_edge_flag_from_mflag(const short mflag); +char BM_vert_flag_from_mflag(const char mflag); +char BM_face_flag_to_mflag(BMFace *f); +short BM_edge_flag_to_mflag(BMEdge *e); +char BM_vert_flag_to_mflag(BMVert *v); + +#endif /* __BMESH_CONSTRUCT_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_core.c b/source/blender/bmesh/intern/bmesh_core.c index 8b1693cba95..d38a898e329 100644 --- a/source/blender/bmesh/intern/bmesh_core.c +++ b/source/blender/bmesh/intern/bmesh_core.c @@ -87,30 +87,6 @@ BMVert *BM_vert_create(BMesh *bm, const float co[3], const struct BMVert *exampl return v; } -/** - * BMESH EDGE EXIST - * - * Finds out if two vertices already have an edge - * connecting them. Note that multiple edges may - * exist between any two vertices, and therefore - * This function only returns the first one found. - * - * Returns - - * BMEdge pointer - */ -BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2) -{ - BMIter iter; - BMEdge *e; - - BM_ITER(e, &iter, NULL, BM_EDGES_OF_VERT, v1) { - if (e->v1 == v2 || e->v2 == v2) - return e; - } - - return NULL; -} - BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, int nodouble) { BMEdge *e; @@ -511,6 +487,10 @@ static void bmesh_kill_only_loop(BMesh *bm, BMLoop *l) BLI_mempool_free(bm->lpool, l); } +/** + * kills all edges associated with f, along with any other faces containing + * those edges + */ void BM_face_edges_kill(BMesh *bm, BMFace *f) { BMEdge **edges = NULL; @@ -531,6 +511,10 @@ void BM_face_edges_kill(BMesh *bm, BMFace *f) BLI_array_free(edges); } +/** + * kills all verts associated with f, along with any other faces containing + * those vertices + */ void BM_face_verts_kill(BMesh *bm, BMFace *f) { BMVert **verts = NULL; @@ -858,9 +842,7 @@ static int disk_is_flagged(BMVert *v, int flag) /* Midlevel Topology Manipulation Functions */ -/* - * BM_faces_join - * +/** * Joins a collected group of faces into one. Only restriction on * the input data is that the faces must be connected to each other. * @@ -868,6 +850,9 @@ static int disk_is_flagged(BMVert *v, int flag) * faces will be joined at every edge. * * Returns a pointer to the combined face. + * + * \note this is a generic, flexible join faces function, almost everything + * uses this, including #BM_faces_join_pair */ BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface) { @@ -1435,7 +1420,7 @@ BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e) * Returns - * The resulting edge, NULL for failure. */ -struct BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_double) +BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_double) { BMEdge *oe; BMVert *ov, *tv; diff --git a/source/blender/bmesh/intern/bmesh_core.h b/source/blender/bmesh/intern/bmesh_core.h new file mode 100644 index 00000000000..d3afe1955c0 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_core.h @@ -0,0 +1,62 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Joseph Eagar. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_CORE_H__ +#define __BMESH_CORE_H__ + +/** \file blender/bmesh/intern/bmesh_core.h + * \ingroup bmesh + */ + +BMFace *BM_face_copy(BMesh *bm, BMFace *f, const short copyverts, const short copyedges); + +BMVert *BM_vert_create(BMesh *bm, const float co[3], const BMVert *example); +BMEdge *BM_edge_create(BMesh *bm, BMVert *v1, BMVert *v2, const BMEdge *example, int nodouble); +BMFace *BM_face_create(BMesh *bm, BMVert **verts, BMEdge **edges, const int len, int nodouble); + +void BM_face_edges_kill(BMesh *bm, BMFace *f); +void BM_face_verts_kill(BMesh *bm, BMFace *f); + +void BM_loop_kill(BMesh *bm, BMLoop *l); +void BM_face_kill(BMesh *bm, BMFace *f); +void BM_edge_kill(BMesh *bm, BMEdge *e); +void BM_vert_kill(BMesh *bm, BMVert *v); + +int bmesh_loop_reverse(BMesh *bm, BMFace *f); + +BMFace *BM_faces_join(BMesh *bm, BMFace **faces, int totface); + +/* EULER API - For modifying structure */ +BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, + BMVert *v2, BMLoop **r_l, +#ifdef USE_BMESH_HOLES + ListBase *holes, +#endif + BMEdge *example + ); + +BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e); +BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_splice); +BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e); +BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv); + +#endif /* __BMESH_CORE_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_interp.c b/source/blender/bmesh/intern/bmesh_interp.c index 406da71ce4d..93a31a34dcd 100644 --- a/source/blender/bmesh/intern/bmesh_interp.c +++ b/source/blender/bmesh/intern/bmesh_interp.c @@ -145,6 +145,8 @@ void BM_data_interp_face_vert_edge(BMesh *bm, BMVert *v1, BMVert *UNUSED(v2), BM } while ((l_iter = l_iter->radial_next) != e1->l); } +/* convert MLoop*** in a bmface to mtface and mcol in + * an MFace */ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex, BMFace *f, int numTex, int numCol) { @@ -195,8 +197,7 @@ void BM_loops_to_corners(BMesh *bm, Mesh *me, int findex, * projects target onto source, and pulls interpolated customdata from * source. * - * Returns - - * Nothing + * \note only does loop customdata. multires is handled. */ void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source) { @@ -527,6 +528,10 @@ static void bmesh_loop_interp_mdisps(BMesh *bm, BMLoop *target, BMFace *source) } } +/** + * smoothes boundaries between multires grids, + * including some borders in adjacent faces + */ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f) { BMLoop *l; @@ -629,11 +634,18 @@ void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f) } } +/** + * project the multires grid in target onto source's set of multires grids + */ void BM_loop_interp_multires(BMesh *bm, BMLoop *target, BMFace *source) { bmesh_loop_interp_mdisps(bm, target, source); } +/** + * projects a single loop, target, onto source for customdata interpolation. multires is handled. + * if do_vertex is true, target's vert data will also get interpolated. + */ void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source, int do_vertex, int do_multires) { diff --git a/source/blender/bmesh/intern/bmesh_interp.h b/source/blender/bmesh/intern/bmesh_interp.h index 01c9870e94e..260784bce3e 100644 --- a/source/blender/bmesh/intern/bmesh_interp.h +++ b/source/blender/bmesh/intern/bmesh_interp.h @@ -27,11 +27,8 @@ * \ingroup bmesh */ -#ifdef __cplusplus -extern "C" { -#endif +struct Mesh; -/* project the multires grid in target onto source's set of multires grids */ void BM_loop_interp_multires(BMesh *bm, BMLoop *target, BMFace *source); void BM_vert_interp_from_face(BMesh *bm, BMVert *v, BMFace *source); @@ -44,27 +41,13 @@ void BM_data_layer_free_n(BMesh *bm, CustomData *data, int type, int n); float BM_elem_float_data_get(CustomData *cd, void *element, int type); void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float val); - -/** - * projects target onto source for customdata interpolation. - * \note only does loop customdata. multires is handled. */ -void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source); - -/* projects a single loop, target, onto source for customdata interpolation. multires is handled. - * if do_vertex is true, target's vert data will also get interpolated.*/ -void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source, +void BM_face_interp_from_face(BMesh *bm, BMFace *target, BMFace *source); +void BM_loop_interp_from_face(BMesh *bm, BMLoop *target, BMFace *source, int do_vertex, int do_multires); -/* smoothes boundaries between multires grids, including some borders in adjacent faces */ -void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f); - -/* convert MLoop*** in a bmface to mtface and mcol in - * an MFace*/ -void BM_loops_to_corners(BMesh *bm, struct Mesh *me, int findex, - BMFace *f, int numTex, int numCol); +void BM_face_multires_bounds_smooth(BMesh *bm, BMFace *f); -#ifdef __cplusplus -} -#endif +void BM_loops_to_corners(BMesh *bm, struct Mesh *me, int findex, + BMFace *f, int numTex, int numCol); #endif /* __BMESH_INTERP_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_marking.c b/source/blender/bmesh/intern/bmesh_marking.c index 8548c7816a9..5df24d8107a 100644 --- a/source/blender/bmesh/intern/bmesh_marking.c +++ b/source/blender/bmesh/intern/bmesh_marking.c @@ -144,7 +144,9 @@ void BM_mesh_select_mode_flush(BMesh *bm) recount_totsels(bm); } -/* BMESH NOTE: matches EM_deselect_flush() behavior from trunk */ +/** + * mode independent flushing up/down + */ void BM_mesh_deselect_flush(BMesh *bm) { BMEdge *e; @@ -193,7 +195,9 @@ void BM_mesh_deselect_flush(BMesh *bm) } -/* BMESH NOTE: matches EM_select_flush() behavior from trunk */ +/** + * mode independent flushing up/down + */ void BM_mesh_select_flush(BMesh *bm) { BMEdge *e; @@ -238,7 +242,7 @@ void BM_mesh_select_flush(BMesh *bm) recount_totsels(bm); } -/* +/** * BMESH SELECT VERT * * Changes selection state of a single vertex @@ -445,7 +449,9 @@ void BM_select_mode_set(BMesh *bm, int selectmode) } } - +/** + * counts number of elements with flag set + */ int BM_mesh_count_flag(struct BMesh *bm, const char htype, const char hflag, int respecthide) { BMElem *ele; @@ -474,7 +480,10 @@ int BM_mesh_count_flag(struct BMesh *bm, const char htype, const char hflag, int return tot; } -/* note: by design, this will not touch the editselection history stuff */ +/** + * \note use BM_elem_flag_test(ele, BM_ELEM_SELECT) to test selection + * \note by design, this will not touch the editselection history stuff + */ void _bm_elem_select_set(struct BMesh *bm, BMHeader *head, int select) { switch (head->htype) { diff --git a/source/blender/bmesh/intern/bmesh_marking.h b/source/blender/bmesh/intern/bmesh_marking.h index 76131231a2c..598cc02126a 100644 --- a/source/blender/bmesh/intern/bmesh_marking.h +++ b/source/blender/bmesh/intern/bmesh_marking.h @@ -45,8 +45,6 @@ void BM_face_hide_set(BMesh *bm, BMFace *f, int hide); #define BM_elem_select_set(bm, ele, hide) _bm_elem_select_set(bm, &(ele)->head, hide) void _bm_elem_select_set(BMesh *bm, BMHeader *ele, int select); -/* use BM_elem_flag_test(ele, BM_ELEM_SELECT) to test selection */ - void BM_mesh_elem_flag_enable_all(BMesh *bm, const char htype, const char hflag); void BM_mesh_elem_flag_disable_all(BMesh *bm, const char htype, const char hflag); @@ -59,11 +57,9 @@ void BM_face_select_set(BMesh *bm, BMFace *f, int select); void BM_select_mode_set(BMesh *bm, int selectmode); void BM_mesh_select_mode_flush(BMesh *bm); -/* mode independent flushing up/down */ void BM_mesh_deselect_flush(BMesh *bm); void BM_mesh_select_flush(BMesh *bm); -/* counts number of elements with flag set */ int BM_mesh_count_flag(BMesh *bm, const char htype, const char hflag, int respecthide); /* edit selection stuff */ diff --git a/source/blender/bmesh/intern/bmesh_mesh.c b/source/blender/bmesh/intern/bmesh_mesh.c index c4a00fe1464..80a557771c6 100644 --- a/source/blender/bmesh/intern/bmesh_mesh.c +++ b/source/blender/bmesh/intern/bmesh_mesh.c @@ -30,17 +30,13 @@ #include "DNA_listBase.h" #include "DNA_object_types.h" -#include "DNA_meshdata_types.h" -#include "DNA_mesh_types.h" #include "BLI_listbase.h" #include "BLI_math.h" #include "BLI_utildefines.h" -#include "BKE_utildefines.h" #include "BKE_cdderivedmesh.h" #include "BKE_tessmesh.h" -#include "BKE_customdata.h" #include "BKE_multires.h" #include "ED_mesh.h" @@ -65,13 +61,14 @@ static void bmesh_mempool_init(BMesh *bm, const int allocsize[4]) bm->toolflagpool = BLI_mempool_create(sizeof(BMFlagLayer), 512, 512, FALSE, FALSE); } -/* +/** * BMESH MAKE MESH * * Allocates a new BMesh structure. * Returns - * Pointer to a BM * + * \note ob is needed by multires */ BMesh *BM_mesh_create(struct Object *ob, const int allocsize[4]) @@ -91,12 +88,13 @@ BMesh *BM_mesh_create(struct Object *ob, const int allocsize[4]) return bm; } -/* +/** * BMESH FREE MESH * * Frees a BMesh structure. + * + * \note frees mesh, but not actual BMesh struct */ - void BM_mesh_data_free(BMesh *bm) { BMVert *v; @@ -159,6 +157,9 @@ void BM_mesh_data_free(BMesh *bm) BMO_error_clear(bm); } +/** + * clear all data in bm + */ void BM_mesh_clear(BMesh *bm) { Object *ob = bm->ob; diff --git a/source/blender/bmesh/intern/bmesh_mesh.h b/source/blender/bmesh/intern/bmesh_mesh.h new file mode 100644 index 00000000000..373b530894a --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_mesh.h @@ -0,0 +1,49 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Geoffrey Bantle, Levi Schooley. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_MESH_H__ +#define __BMESH_MESH_H__ + +/** \file blender/bmesh/intern/bmesh_mesh.h + * \ingroup bmesh + */ + +BMesh *BM_mesh_create(struct Object *ob, const int allocsize[4]); + +void BM_mesh_free(BMesh *bm); +void BM_mesh_data_free(BMesh *bm); +void BM_mesh_clear(BMesh *bm); + +void BM_mesh_normals_update(BMesh *bm, const short skip_hidden); + +void bmesh_edit_begin(BMesh *bm, int flag); +void bmesh_edit_end(BMesh *bm, int flag); + +void BM_mesh_elem_index_ensure(BMesh *bm, const char hflag); +void BM_mesh_elem_index_validate(BMesh *bm, const char *location, const char *func, + const char *msg_a, const char *msg_b); + +BMVert *BM_vert_at_index(BMesh *bm, const int index); +BMEdge *BM_edge_at_index(BMesh *bm, const int index); +BMFace *BM_face_at_index(BMesh *bm, const int index); + +#endif /* __BMESH_MESH_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_mods.c b/source/blender/bmesh/intern/bmesh_mods.c index 964565fe5c8..16b2c248519 100644 --- a/source/blender/bmesh/intern/bmesh_mods.c +++ b/source/blender/bmesh/intern/bmesh_mods.c @@ -55,6 +55,9 @@ * |=========| |=========| * * + * \note dissolves vert, in more situations then BM_disk_dissolve + * (e.g. if the vert is part of a wire edge, etc). + * */ int BM_vert_dissolve(BMesh *bm, BMVert *v) { @@ -92,6 +95,10 @@ int BM_vert_dissolve(BMesh *bm, BMVert *v) } } +/** + * dissolves all faces around a vert, and removes it. + */ + int BM_disk_dissolve(BMesh *bm, BMVert *v) { BMFace *f, *f2; @@ -296,7 +303,8 @@ BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f) /** - * Splits a single face into two. + * Split a face along two vertices. returns the newly made face, and sets + * the 'r_l' member to a loop in the newly created edge. * * \param the original face * \param v1,v2 vertices which define the split edge, must be different @@ -636,6 +644,7 @@ BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float perce return nv; } +/* split an edge multiple times evenly */ BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts) { int i; @@ -649,6 +658,7 @@ BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts) return nv; } +/* checks if a face is valid in the data structure */ int BM_face_validate(BMesh *bm, BMFace *face, FILE *err) { BMIter iter; @@ -752,6 +762,7 @@ BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, int ccw) return nl->e; } +/* Rip a single face from a vertex fan */ BMVert *BM_vert_rip(BMesh *bm, BMFace *sf, BMVert *sv) { return bmesh_urmv(bm, sf, sv); diff --git a/source/blender/bmesh/intern/bmesh_mods.h b/source/blender/bmesh/intern/bmesh_mods.h new file mode 100644 index 00000000000..6d4b1333549 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_mods.h @@ -0,0 +1,60 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Joseph Eagar. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_MODS_H__ +#define __BMESH_MODS_H__ + +/** \file blender/bmesh/intern/bmesh_mods.h + * \ingroup bmesh + */ + +#include <stdio.h> + +int BM_vert_dissolve(BMesh *bm, BMVert *v); + +int BM_disk_dissolve(BMesh *bm, BMVert *v); + +BMFace *BM_faces_join_pair(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e); + +BMEdge *BM_verts_connect(BMesh *bm, BMVert *v1, BMVert *v2, BMFace **r_f); + +BMFace *BM_face_split(BMesh *bm, BMFace *f, + BMVert *v1, BMVert *v2, + BMLoop **r_l, BMEdge *example); + +BMEdge* BM_vert_collapse_faces(BMesh *bm, BMEdge *ke, BMVert *kv, float fac, + const short join_faces, const short kill_degenerate_faces); +BMEdge* BM_vert_collapse_edge(BMesh *bm, BMEdge *ke, BMVert *kv, + const short kill_degenerate_faces); + + +BMVert *BM_edge_split(BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float percent); + +BMVert *BM_edge_split_n(BMesh *bm, BMEdge *e, int numcuts); + +int BM_face_validate(BMesh *bm, BMFace *face, FILE *err); + +BMEdge *BM_edge_rotate(BMesh *bm, BMEdge *e, int ccw); + +BMVert *BM_vert_rip(BMesh *bm, BMFace *sf, BMVert *sv); + +#endif /* __BMESH_MODS_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_operators.h b/source/blender/bmesh/intern/bmesh_operators.h index fc24e1960ab..52525dab51b 100644 --- a/source/blender/bmesh/intern/bmesh_operators.h +++ b/source/blender/bmesh/intern/bmesh_operators.h @@ -88,15 +88,8 @@ extern int bmesh_total_ops; /*------specific operator helper functions-------*/ -/* executes the duplicate operation, feeding elements of - * type flag etypeflag and header flag flag to it. note, - * to get more useful information (such as the mapping from - * original to new elements) you should run the dupe op manually.*/ struct Object; -#if 0 -void BMO_dupe_from_flag(BMesh *bm, int etypeflag, const char hflag); -#endif void BM_mesh_esubdivideflag(struct Object *obedit, BMesh *bm, int flag, float smooth, float fractal, int beauty, int numcuts, int seltype, int cornertype, int singleedge, int gridfill, int seed); diff --git a/source/blender/bmesh/intern/bmesh_polygon.c b/source/blender/bmesh/intern/bmesh_polygon.c index c7fa91e8f13..2ec2a536852 100644 --- a/source/blender/bmesh/intern/bmesh_polygon.c +++ b/source/blender/bmesh/intern/bmesh_polygon.c @@ -221,6 +221,9 @@ static int compute_poly_center(float center[3], float *r_area, float (*verts)[3] return FALSE; } +/** + * get the area of the face + */ float BM_face_area_calc(BMesh *bm, BMFace *f) { BMLoop *l; @@ -245,7 +248,7 @@ float BM_face_area_calc(BMesh *bm, BMFace *f) return area; } -/* +/** * computes center of face in 3d. uses center of bounding box. */ void BM_face_center_bounds_calc(BMesh *bm, BMFace *f, float r_cent[3]) @@ -264,6 +267,9 @@ void BM_face_center_bounds_calc(BMesh *bm, BMFace *f, float r_cent[3]) mid_v3_v3v3(r_cent, min, max); } +/** + * computes the centroid of a face, using the mean average + */ void BM_face_center_mean_calc(BMesh *bm, BMFace *f, float r_cent[3]) { BMIter iter; @@ -280,7 +286,7 @@ void BM_face_center_mean_calc(BMesh *bm, BMFace *f, float r_cent[3]) if (f->len) mul_v3_fl(r_cent, 1.0f / (float)f->len); } -/* +/** * COMPUTE POLY PLANE * * Projects a set polygon's vertices to @@ -340,23 +346,6 @@ void compute_poly_plane(float (*verts)[3], int nverts) * the list that bridges a concave region of the face or intersects * any of the faces's edges. */ -#if 0 /* needs BLI math double versions of these functions */ -static void shrink_edged(double *v1, double *v2, double fac) -{ - double mid[3]; - - mid_v3_v3v3(mid, v1, v2); - - sub_v3_v3v3(v1, v1, mid); - sub_v3_v3v3(v2, v2, mid); - - mul_v3_fl(v1, fac); - mul_v3_fl(v2, fac); - - add_v3_v3v3(v1, v1, mid); - add_v3_v3v3(v2, v2, mid); -} -#endif static void shrink_edgef(float v1[3], float v2[3], const float fac) { @@ -441,6 +430,9 @@ void BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3], float (*verte } } +/** + * updates face and vertex normals incident on an edge + */ void BM_edge_normals_update(BMesh *bm, BMEdge *e) { BMIter iter; @@ -455,6 +447,9 @@ void BM_edge_normals_update(BMesh *bm, BMEdge *e) BM_vert_normal_update(bm, e->v2); } +/** + * update a vert normal (but not the faces incident on it) + */ void BM_vert_normal_update(BMesh *bm, BMVert *v) { /* TODO, we can normalize each edge only once, then compare with previous edge */ @@ -651,13 +646,15 @@ static int linecrossesf(const float v1[2], const float v2[2], const float v3[2], return FALSE; } -/* +/** * BM POINT IN FACE * * Projects co onto face f, and returns true if it is inside - * the face bounds. Note that this uses a best-axis projection - * test, instead of projecting co directly into f's orientation - * space, so there might be accuracy issues. + * the face bounds. + * + * \note this uses a best-axis projection test, + * instead of projecting co directly into f's orientation space, + * so there might be accuracy issues. */ int BM_face_point_inside_test(BMesh *bm, BMFace *f, const float co[3]) { @@ -802,21 +799,20 @@ static BMLoop *find_ear(BMesh *UNUSED(bm), BMFace *f, float (*verts)[3], const i return bestear; } -/* +/** * BMESH TRIANGULATE FACE * - * Triangulates a face using a - * simple 'ear clipping' algorithm - * that tries to favor non-skinny - * triangles (angles less than - * 90 degrees). If the triangulator - * has bits left over (or cannot - * triangulate at all) it uses a - * simple fan triangulation + * Triangulates a face using a simple 'ear clipping' algorithm that tries to + * favor non-skinny triangles (angles less than 90 degrees). + * + * If the triangulator has bits left over (or cannot triangulate at all) + * it uses a simple fan triangulation, * * newfaces, if non-null, must be an array of BMFace pointers, * with a length equal to f->len. it will be filled with the new * triangles, and will be NULL-terminated. + * + * \note newedgeflag sets a flag layer flag, obviously not the header flag. */ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], const short newedge_oflag, const short newface_oflag, BMFace **newfaces) @@ -909,12 +905,14 @@ void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], if (newfaces) newfaces[nf_i] = NULL; } -/* each pair of loops defines a new edge, a split. this function goes +/** + * each pair of loops defines a new edge, a split. this function goes * through and sets pairs that are geometrically invalid to null. a * split is invalid, if it forms a concave angle or it intersects other * edges in the face, or it intersects another split. in the case of * intersecting splits, only the first of the set of intersecting - * splits survives */ + * splits survives + */ void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len) { BMIter iter; diff --git a/source/blender/bmesh/intern/bmesh_polygon.h b/source/blender/bmesh/intern/bmesh_polygon.h new file mode 100644 index 00000000000..9ee1714d125 --- /dev/null +++ b/source/blender/bmesh/intern/bmesh_polygon.h @@ -0,0 +1,50 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributor(s): Joseph Eagar. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __BMESH_POLYGON_H__ +#define __BMESH_POLYGON_H__ + +/** \file blender/bmesh/intern/bmesh_polygon.h + * \ingroup bmesh + */ + +float BM_face_area_calc(BMesh *bm, BMFace *f); +void BM_face_center_bounds_calc(BMesh *bm, BMFace *f, float center[3]); +void BM_face_center_mean_calc(BMesh *bm, BMFace *f, float center[3]); + +void BM_face_normal_update(BMesh *bm, BMFace *f); +void BM_face_normal_update_vcos(BMesh *bm, BMFace *f, float no[3], float (*vertexCos)[3]); + +void BM_edge_normals_update(BMesh *bm, BMEdge *e); + +void BM_vert_normal_update(BMesh *bm, BMVert *v); +void BM_vert_normal_update_all(BMesh *bm, BMVert *v); + +void BM_face_normal_flip(BMesh *bm, BMFace *f); +int BM_face_point_inside_test(BMesh *bm, BMFace *f, const float co[3]); + +void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], + const short newedge_oflag, const short newface_oflag, BMFace **newfaces); + +void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len); + +#endif /* __BMESH_POLYGON_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_private.h b/source/blender/bmesh/intern/bmesh_private.h index 5b42788fe88..81195977681 100644 --- a/source/blender/bmesh/intern/bmesh_private.h +++ b/source/blender/bmesh/intern/bmesh_private.h @@ -65,10 +65,6 @@ int bmesh_disk_count(BMVert *v); #define BM_ELEM_API_FLAG_DISABLE(element, f) ((element)->oflags[0].pflag &= ~(f)) #define BM_ELEM_API_FLAG_TEST(element, f) ((element)->oflags[0].pflag & (f)) -/* Polygon Utilities ? FIXME... where do these each go? */ -/* newedgeflag sets a flag layer flag, obviously not the header flag. */ -void BM_face_triangulate(BMesh *bm, BMFace *f, float (*projectverts)[3], - const short newedge_oflag, const short newface_oflag, BMFace **newfaces); void bmesh_face_normal_update(BMesh *bm, BMFace *f, float no[3], float (*projectverts)[3]); void bmesh_face_normal_update_vertex_cos(BMesh *bm, BMFace *f, float no[3], diff --git a/source/blender/bmesh/intern/bmesh_queries.c b/source/blender/bmesh/intern/bmesh_queries.c index 2ea37a5c01b..ab4bc0810de 100644 --- a/source/blender/bmesh/intern/bmesh_queries.c +++ b/source/blender/bmesh/intern/bmesh_queries.c @@ -41,13 +41,9 @@ #define BM_OVERLAP (1 << 13) -/* - * BMESH COUNT ELEMENT - * - * Return the amount of element of - * type 'type' in a given bmesh. +/** + * Return the amount of element of type 'type' in a given bmesh. */ - int BM_mesh_elem_count(BMesh *bm, const char htype) { if (htype == BM_VERT) return bm->totvert; @@ -57,27 +53,20 @@ int BM_mesh_elem_count(BMesh *bm, const char htype) return 0; } - -/* - * BMESH VERT IN EDGE - * +/** * Returns whether or not a given vertex is * is part of a given edge. - * */ - int BM_vert_in_edge(BMEdge *e, BMVert *v) { return bmesh_vert_in_edge(e, v); } -/* +/** * BMESH OTHER EDGE IN FACE SHARING A VERTEX * - * Returns an opposing loop that shares the same face. - * + * Finds the other loop that shares 'v' with 'e's loop in 'f'. */ - BMLoop *BM_face_other_loop(BMEdge *e, BMFace *f, BMVert *v) { BMLoop *l_iter; @@ -94,12 +83,8 @@ BMLoop *BM_face_other_loop(BMEdge *e, BMFace *f, BMVert *v) return l_iter->v == v ? l_iter->prev : l_iter->next; } -/* - * BMESH VERT IN FACE - * - * Returns whether or not a given vertex is - * is part of a given face. - * +/** + * Returns TRUE if the vertex is used in a given face. */ int BM_vert_in_face(BMFace *f, BMVert *v) @@ -126,12 +111,9 @@ int BM_vert_in_face(BMFace *f, BMVert *v) return FALSE; } -/* - * BMESH VERTS IN FACE - * +/** * Compares the number of vertices in an array * that appear in a given face - * */ int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len) { @@ -171,14 +153,9 @@ int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len) return count; } -/* - * BMESH EDGE IN FACE - * - * Returns whether or not a given edge is - * is part of a given face. - * +/** + * Returns whether or not a given edge is is part of a given face. */ - int BM_edge_in_face(BMFace *f, BMEdge *e) { BMLoop *l_iter; @@ -195,49 +172,35 @@ int BM_edge_in_face(BMFace *f, BMEdge *e) return FALSE; } -/* - * BMESH VERTS IN EDGE - * +/** * Returns whether or not two vertices are in * a given edge - * */ - int BM_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e) { return bmesh_verts_in_edge(v1, v2, e); } -/* - * BMESH GET OTHER EDGEVERT - * +/** * Given a edge and one of its vertices, returns * the other vertex. - * */ - BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v) { return bmesh_edge_other_vert_get(e, v); } -/* - * BMESH VERT EDGECOUNT - * +/** * Returns the number of edges around this vertex. */ - int BM_vert_edge_count(BMVert *v) { return bmesh_disk_count(v); } -/* - * BMESH EDGE FACECOUNT - * +/** * Returns the number of faces around this edge */ - int BM_edge_face_count(BMEdge *e) { int count = 0; @@ -253,12 +216,9 @@ int BM_edge_face_count(BMEdge *e) return count; } -/* - * BMESH VERT FACECOUNT - * +/** * Returns the number of faces around this vert */ - int BM_vert_face_count(BMVert *v) { int count = 0; @@ -284,16 +244,10 @@ int BM_vert_face_count(BMVert *v) #endif } -/* - * BMESH WIRE VERT - * - * Tests whether or not the vertex is part of a wire edge. - * (ie: has no faces attached to it) - * - * Returns - - * 1 for true, 0 for false. +/** + * Tests whether or not the vertex is part of a wire edge. + * (ie: has no faces attached to it) */ - int BM_vert_is_wire(BMesh *UNUSED(bm), BMVert *v) { BMEdge *curedge; @@ -314,34 +268,22 @@ int BM_vert_is_wire(BMesh *UNUSED(bm), BMVert *v) return TRUE; } -/* - * BMESH WIRE EDGE - * - * Tests whether or not the edge is part of a wire. - * (ie: has no faces attached to it) - * - * Returns - - * 1 for true, 0 for false. +/** + * Tests whether or not the edge is part of a wire. + * (ie: has no faces attached to it) */ - int BM_edge_is_wire(BMesh *UNUSED(bm), BMEdge *e) { return (e->l) ? FALSE : TRUE; } -/* - * BMESH NONMANIFOLD VERT - * - * A vertex is non-manifold if it meets the following conditions: - * 1: Loose - (has no edges/faces incident upon it) - * 2: Joins two distinct regions - (two pyramids joined at the tip) - * 3: Is part of a non-manifold edge (edge with more than 2 faces) - * 4: Is part of a wire edge - * - * Returns - - * 1 for true, 0 for false. +/** + * A vertex is non-manifold if it meets the following conditions: + * 1: Loose - (has no edges/faces incident upon it) + * 2: Joins two distinct regions - (two pyramids joined at the tip) + * 3: Is part of a non-manifold edge (edge with more than 2 faces) + * 4: Is part of a wire edge */ - int BM_vert_is_manifold(BMesh *UNUSED(bm), BMVert *v) { BMEdge *e, *oe; @@ -402,17 +344,10 @@ int BM_vert_is_manifold(BMesh *UNUSED(bm), BMVert *v) return TRUE; } -/* - * BMESH NONMANIFOLD EDGE - * - * Tests whether or not this edge is manifold. - * A manifold edge either has 1 or 2 faces attached - * to it. - * - * Returns - - * 1 for true, 0 for false. +/** + * Tests whether or not this edge is manifold. + * A manifold edge either has 1 or 2 faces attached to it. */ - int BM_edge_is_manifold(BMesh *UNUSED(bm), BMEdge *e) { int count = BM_edge_face_count(e); @@ -422,16 +357,10 @@ int BM_edge_is_manifold(BMesh *UNUSED(bm), BMEdge *e) return TRUE; } -/* - * BMESH BOUNDARY EDGE - * - * Tests whether or not an edge is on the boundary - * of a shell (has one face associated with it) - * - * Returns - - * 1 for true, 0 for false. +/** + * Tests whether or not an edge is on the boundary + * of a shell (has one face associated with it) */ - int BM_edge_is_boundary(BMEdge *e) { int count = BM_edge_face_count(e); @@ -441,18 +370,9 @@ int BM_edge_is_boundary(BMEdge *e) return FALSE; } -/* - * BMESH FACE SHAREDEDGES - * +/** * Counts the number of edges two faces share (if any) - * - * BMESH_TODO: - * Move this to structure, and wrap. - * - * Returns - - * Integer */ - int BM_face_share_edge_count(BMFace *f1, BMFace *f2) { BMLoop *l_iter; @@ -469,14 +389,9 @@ int BM_face_share_edge_count(BMFace *f1, BMFace *f2) return count; } -/* - * - * BMESH EDGE SHARE FACES - * - * Tests to see if e1 shares any faces with e2 - * +/** + * Test if e1 shares any faces with e2 */ - int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2) { BMLoop *l; @@ -496,13 +411,8 @@ int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2) } /** - * - * BMESH EDGE SHARE A VERTEX - * * Tests to see if e1 shares a vertex with e2 - * */ - int BM_edge_share_vert_count(struct BMEdge *e1, struct BMEdge *e2) { return (e1->v1 == e2->v1 || @@ -512,13 +422,8 @@ int BM_edge_share_vert_count(struct BMEdge *e1, struct BMEdge *e2) } /** - * - * BMESH EDGE SHARE A VERTEX - * * Return the shared vertex between the two edges or NULL - * */ - BMVert *BM_edge_share_vert(struct BMEdge *e1, struct BMEdge *e2) { if (BM_vert_in_edge(e2, e1->v1)) { @@ -533,18 +438,13 @@ BMVert *BM_edge_share_vert(struct BMEdge *e1, struct BMEdge *e2) } /** + * Returns the verts of an edge as used in a face + * if used in a face at all, otherwise just assign as used in the edge. * - * BMESH EDGE ORDERED VERTS - * - * Returns the verts of an edge as used in a face - * if used in a face at all, otherwise just assign as used in the edge. - * - * Useful to get a determanistic winding order when calling - * BM_face_create_ngon() on an arbitrary array of verts, - * though be sure to pick an edge which has a face. - * + * Useful to get a determanistic winding order when calling + * BM_face_create_ngon() on an arbitrary array of verts, + * though be sure to pick an edge which has a face. */ - void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2) { if ((edge->l == NULL) || @@ -561,16 +461,12 @@ void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2) } } -/* - * BMESH LOOP ANGLE - * - * Calculates the angle between the previous and next loops - * (angle at this loops face corner). +/** + * Calculates the angle between the previous and next loops + * (angle at this loops face corner). * - * Returns - - * Float. + * \return angle in radians */ - float BM_loop_face_angle(BMesh *UNUSED(bm), BMLoop *l) { return angle_v3v3v3(l->prev->v->co, @@ -578,16 +474,12 @@ float BM_loop_face_angle(BMesh *UNUSED(bm), BMLoop *l) l->next->v->co); } -/* - * BMESH FACE ANGLE - * +/** * Calculates the angle between two faces. * Assumes the face normals are correct. * - * Returns - - * Float. + * \return angle in radians */ - float BM_edge_face_angle(BMesh *UNUSED(bm), BMEdge *e) { if (BM_edge_face_count(e) == 2) { @@ -630,8 +522,25 @@ float BM_vert_edge_angle(BMesh *UNUSED(bm), BMVert *v) } /** - * BMESH EXIST FACE OVERLAPS + * Returns the edge existing between v1 and v2, or NULL if there isn't one. * + * \note multiple edges may exist between any two vertices, and therefore + * this function only returns the first one found. + */ +BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2) +{ + BMIter iter; + BMEdge *e; + + BM_ITER(e, &iter, NULL, BM_EDGES_OF_VERT, v1) { + if (e->v1 == v2 || e->v2 == v2) + return e; + } + + return NULL; +} + +/** * Given a set of vertices (varr), find out if * all those vertices overlap an existing face. * @@ -666,18 +575,11 @@ int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_overlap return FALSE; } -/* - * BMESH FACE EXISTS - * +/** * Given a set of vertices (varr), find out if * there is a face with exactly those vertices * (and only those vertices). - * - * Returns: - * 0 for no face found - * 1 for face found */ - int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface) { BMIter viter; @@ -703,9 +605,7 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface) } -/* - * BMESH EXIST FACE MULTI - * +/** * Given a set of vertices and edges (varr, earr), find out if * all those vertices are filled in by existing faces that _only_ use those vertices. * @@ -716,13 +616,7 @@ int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface) * pressing Fkey would make a new overlapping quad (without a check like this) * * 'earr' and 'varr' can be in any order, however they _must_ form a closed loop. - * - * Returns: - * 0 for no overlap - * 1 for overlap - * */ - int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len) { BMFace *f; diff --git a/source/blender/bmesh/intern/bmesh_queries.h b/source/blender/bmesh/intern/bmesh_queries.h index 4285031c3b5..1fb0df7e2af 100644 --- a/source/blender/bmesh/intern/bmesh_queries.h +++ b/source/blender/bmesh/intern/bmesh_queries.h @@ -23,108 +23,54 @@ #ifndef __BMESH_QUERIES_H__ #define __BMESH_QUERIES_H__ -/** \file blender/bmesh/bmesh_queries.h +/** \file blender/bmesh/intern/bmesh_queries.h * \ingroup bmesh */ -#include <stdio.h> +int BM_mesh_elem_count(BMesh *bm, const char htype); -/* Queries */ +int BM_vert_in_face(BMFace *f, BMVert *v); +int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len); -/* counts number of elements of type type are in the mesh. */ -int BM_mesh_elem_count(BMesh *bm, const char htype); +int BM_edge_in_face(BMFace *f, BMEdge *e); -/*returns true if v is in f*/ -int BM_vert_in_face(BMFace *f, BMVert *v); +int BM_vert_in_edge(BMEdge *e, BMVert *v); +int BM_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e); -// int BM_verts_in_face(BMFace *f, BMVert **varr, int len); -int BM_verts_in_face(BMesh *bm, BMFace *f, BMVert **varr, int len); - -int BM_edge_in_face(BMFace *f, BMEdge *e); - -int BM_vert_in_edge(BMEdge *e, BMVert *v); - -int BM_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e); - -/*get opposing vert from v in edge e.*/ BMVert *BM_edge_other_vert(BMEdge *e, BMVert *v); - -/*finds other loop that shares v with e's loop in f.*/ BMLoop *BM_face_other_loop(BMEdge *e, BMFace *f, BMVert *v); -/*returns the edge existing between v1 and v2, or NULL if there isn't one.*/ -BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2); - - -/*returns number of edges aroudn a vert*/ -int BM_vert_edge_count(BMVert *v); - -/*returns number of faces around an edge*/ -int BM_edge_face_count(BMEdge *e); - -/*returns number of faces around a vert.*/ -int BM_vert_face_count(BMVert *v); +int BM_vert_edge_count(BMVert *v); +int BM_edge_face_count(BMEdge *e); +int BM_vert_face_count(BMVert *v); +int BM_vert_is_wire(BMesh *bm, BMVert *v); +int BM_edge_is_wire(BMesh *bm, BMEdge *e); -/*returns true if v is a wire vert*/ -int BM_vert_is_wire(BMesh *bm, BMVert *v); +int BM_vert_is_manifold(BMesh *bm, BMVert *v); +int BM_edge_is_manifold(BMesh *bm, BMEdge *e); +int BM_edge_is_boundary(BMEdge *e); -/*returns true if e is a wire edge*/ -int BM_edge_is_wire(BMesh *bm, BMEdge *e); +float BM_loop_face_angle(BMesh *bm, BMLoop *l); -/* returns FALSE if v is part of a non-manifold edge in the mesh, - * I believe this includes if it's part of both a wire edge and - * a face.*/ -int BM_vert_is_manifold(BMesh *bm, BMVert *v); +float BM_edge_face_angle(BMesh *bm, BMEdge *e); +float BM_vert_edge_angle(BMesh *bm, BMVert *v); -/* returns FALSE if e is shared by more then two faces. */ -int BM_edge_is_manifold(BMesh *bm, BMEdge *e); - -/* returns true if e is a boundary edge, e.g. has only 1 face bordering it. */ -int BM_edge_is_boundary(BMEdge *e); - -/* returns the face corner angle */ -float BM_loop_face_angle(BMesh *bm, BMLoop *l); - -/* returns angle of two faces surrounding an edge. note there must be - * exactly two faces sharing the edge.*/ -float BM_edge_face_angle(BMesh *bm, BMEdge *e); - -/* returns angle of two faces surrounding edges. note there must be - * exactly two edges sharing the vertex.*/ -float BM_vert_edge_angle(BMesh *bm, BMVert *v); - -/* checks overlapping of existing faces with the verts in varr. */ -int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); - -/* checks if a face defined by varr already exists. */ -int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); +BMEdge *BM_edge_exists(BMVert *v1, BMVert *v2); -/* checks if many existing faces overlap the faces defined by varr */ -int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len); -int BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len); +int BM_face_exists_overlap(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); -/* returns number of edges f1 and f2 share. */ -int BM_face_share_edge_count(BMFace *f1, BMFace *f2); +int BM_face_exists(BMesh *bm, BMVert **varr, int len, BMFace **r_existface); -/* returns number of faces e1 and e2 share. */ -int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2); +int BM_face_exists_multi(BMesh *bm, BMVert **varr, BMEdge **earr, int len); +int BM_face_exists_multi_edge(BMesh *bm, BMEdge **earr, int len); -/* returns bool 1/0 if the edges share a vertex */ -int BM_edge_share_vert_count(BMEdge *e1, BMEdge *e2); +int BM_face_share_edge_count(BMFace *f1, BMFace *f2); +int BM_edge_share_face_count(BMEdge *e1, BMEdge *e2); +int BM_edge_share_vert_count(BMEdge *e1, BMEdge *e2); BMVert *BM_edge_share_vert(BMEdge *e1, BMEdge *e2); -/* edge verts in winding order from face */ -void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2); - -/* checks if a face is valid in the data structure */ -int BM_face_validate(BMesh *bm, BMFace *face, FILE *err); - -/* each pair of loops defines a new edge, a split. this function goes - * through and sets pairs that are geometrically invalid to null. a - * split is invalid, if it forms a concave angle or it intersects other - * edges in the face.*/ -void BM_face_legal_splits(BMesh *bm, BMFace *f, BMLoop *(*loops)[2], int len); +void BM_edge_ordered_verts(BMEdge *edge, BMVert **r_v1, BMVert **r_v2); #endif /* __BMESH_QUERIES_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_structure.h b/source/blender/bmesh/intern/bmesh_structure.h index 67bb87ef1f8..ba7f83b73e2 100644 --- a/source/blender/bmesh/intern/bmesh_structure.h +++ b/source/blender/bmesh/intern/bmesh_structure.h @@ -68,22 +68,6 @@ int bmesh_verts_in_edge(BMVert *v1, BMVert *v2, BMEdge *e); int bmesh_edge_swapverts(BMEdge *e, BMVert *orig, BMVert *newv); /*relink edge*/ BMVert *bmesh_edge_other_vert_get(BMEdge *e, BMVert *v); BMEdge *bmesh_disk_edge_exists(BMVert *v1, BMVert *v2); -int bmesh_disk_validate(int len, BMEdge *e, BMVert *v); - -/* EULER API - For modifying structure */ -BMVert *bmesh_semv(BMesh *bm, BMVert *tv, BMEdge *e, BMEdge **r_e); -BMFace *bmesh_sfme(BMesh *bm, BMFace *f, BMVert *v1, - BMVert *v2, BMLoop **r_l, -#ifdef USE_BMESH_HOLES - ListBase *holes, -#endif - BMEdge *example - ); - -BMEdge *bmesh_jekv(BMesh *bm, BMEdge *ke, BMVert *kv, const short check_edge_splice); -int bmesh_loop_reverse(BMesh *bm, BMFace *f); -BMFace *bmesh_jfke(BMesh *bm, BMFace *f1, BMFace *f2, BMEdge *e); - -BMVert *bmesh_urmv(BMesh *bm, BMFace *sf, BMVert *sv); +int bmesh_disk_validate(int len, BMEdge *e, BMVert *v); #endif /* __BMESH_STRUCTURE_H__ */ diff --git a/source/blender/bmesh/intern/bmesh_walkers_impl.c b/source/blender/bmesh/intern/bmesh_walkers_impl.c index 15b46cbcdf8..3ec7cbb60b1 100644 --- a/source/blender/bmesh/intern/bmesh_walkers_impl.c +++ b/source/blender/bmesh/intern/bmesh_walkers_impl.c @@ -32,17 +32,14 @@ #include "bmesh_private.h" #include "bmesh_walkers_private.h" -/* Shell Walker: +/** + * Shell Walker: * - * Starts at a vertex on the mesh and walks over the 'shell' it belongs - * to via visiting connected edges. - * - * TODO: - * - * Add restriction flag/callback for wire edges. + * Starts at a vertex on the mesh and walks over the 'shell' it belongs + * to via visiting connected edges. * + * \todo Add restriction flag/callback for wire edges. */ - static void shellWalker_visitEdge(BMWalker *walker, BMEdge *e) { shellWalker *shellWalk = NULL; @@ -164,12 +161,11 @@ static void *shellWalker_step(BMWalker *walker) } #endif -/* Connected Vertex Walker: - * - * Similar to shell walker, but visits vertices instead of edges. +/** + * Connected Vertex Walker: * + * Similar to shell walker, but visits vertices instead of edges. */ - static void connectedVertexWalker_visitVertex(BMWalker *walker, BMVert *v) { connectedVertexWalker *vwalk; @@ -221,17 +217,13 @@ static void *connectedVertexWalker_step(BMWalker *walker) return v; } -/* Island Boundary Walker: - * - * Starts at a edge on the mesh and walks over the boundary of an - * island it belongs to. +/** + * Island Boundary Walker: * - * TODO: - * - * Add restriction flag/callback for wire edges. + * Starts at a edge on the mesh and walks over the boundary of an island it belongs to. * + * \todo Add restriction flag/callback for wire edges. */ - static void islandboundWalker_begin(BMWalker *walker, void *data) { BMLoop *l = data; @@ -318,16 +310,13 @@ static void *islandboundWalker_step(BMWalker *walker) } -/* Island Walker: +/** + * Island Walker: * - * Starts at a tool flagged-face and walks over the face region - * - * TODO: - * - * Add restriction flag/callback for wire edges. + * Starts at a tool flagged-face and walks over the face region * + * \todo Add restriction flag/callback for wire edges. */ - static void islandWalker_begin(BMWalker *walker, void *data) { islandWalker *iwalk = NULL; @@ -384,12 +373,11 @@ static void *islandWalker_step(BMWalker *walker) } -/* Edge Loop Walker: - * - * Starts at a tool-flagged edge and walks over the edge loop +/** + * Edge Loop Walker: * + * Starts at a tool-flagged edge and walks over the edge loop */ - static void loopWalker_begin(BMWalker *walker, void *data) { loopWalker *lwalk = NULL, owalk; @@ -516,12 +504,12 @@ static void *loopWalker_step(BMWalker *walker) return owalk.cur; } -/* Face Loop Walker: +/** + * Face Loop Walker: * - * Starts at a tool-flagged face and walks over the face loop + * Starts at a tool-flagged face and walks over the face loop * Conditions for starting and stepping the face loop have been * tuned in an attempt to match the face loops built by EditMesh - * */ /* Check whether the face loop should includes the face specified @@ -648,14 +636,13 @@ static void *faceloopWalker_step(BMWalker *walker) return f; } -/* Edge Ring Walker: +/** + * Edge Ring Walker: * - * Starts at a tool-flagged edge and walks over the edge ring + * Starts at a tool-flagged edge and walks over the edge ring * Conditions for starting and stepping the edge ring have been * tuned in an attempt to match the edge rings built by EditMesh - * */ - static void edgeringWalker_begin(BMWalker *walker, void *data) { edgeringWalker *lwalk, owalk; |