Blender  V3.3
Enumerations | Functions
bmesh_mods.h File Reference

Go to the source code of this file.

Enumerations

enum  { BM_EDGEROT_CHECK_EXISTS = (1 << 0) , BM_EDGEROT_CHECK_SPLICE = (1 << 1) , BM_EDGEROT_CHECK_DEGENERATE = (1 << 2) , BM_EDGEROT_CHECK_BEAUTY = (1 << 3) }
 

Functions

bool BM_vert_dissolve (BMesh *bm, BMVert *v)
 Dissolve Vert. More...
 
bool BM_disk_dissolve (BMesh *bm, BMVert *v)
 
BMFaceBM_faces_join_pair (BMesh *bm, BMLoop *l_a, BMLoop *l_b, bool do_del)
 Faces Join Pair. More...
 
BMFaceBM_face_split (BMesh *bm, BMFace *f, BMLoop *l_a, BMLoop *l_b, BMLoop **r_l, BMEdge *example, bool no_double)
 Face Split. More...
 
BMFaceBM_face_split_n (BMesh *bm, BMFace *f, BMLoop *l_a, BMLoop *l_b, float cos[][3], int n, BMLoop **r_l, BMEdge *example)
 Face Split with intermediate points. More...
 
BMEdgeBM_vert_collapse_faces (BMesh *bm, BMEdge *e_kill, BMVert *v_kill, float fac, bool do_del, bool join_faces, bool kill_degenerate_faces, bool kill_duplicate_faces)
 Vert Collapse Faces. More...
 
BMEdgeBM_vert_collapse_edge (BMesh *bm, BMEdge *e_kill, BMVert *v_kill, bool do_del, bool kill_degenerate_faces, bool kill_duplicate_faces)
 Vert Collapse Faces. More...
 
BMVertBM_edge_collapse (BMesh *bm, BMEdge *e_kill, BMVert *v_kill, bool do_del, bool kill_degenerate_faces)
 
BMVertBM_edge_split (BMesh *bm, BMEdge *e, BMVert *v, BMEdge **r_e, float fac)
 Edge Split. More...
 
BMVertBM_edge_split_n (BMesh *bm, BMEdge *e, int numcuts, BMVert **r_varr)
 Split an edge multiple times evenly. More...
 
void BM_edge_verts_swap (BMEdge *e)
 
bool BM_face_validate (BMFace *face, FILE *err)
 
void BM_edge_calc_rotate (BMEdge *e, bool ccw, BMLoop **r_l1, BMLoop **r_l2)
 
bool BM_edge_rotate_check (BMEdge *e)
 Check if Rotate Edge is OK. More...
 
bool BM_edge_rotate_check_degenerate (BMEdge *e, BMLoop *l1, BMLoop *l2)
 Check if Edge Rotate Gives Degenerate Faces. More...
 
bool BM_edge_rotate_check_beauty (BMEdge *e, BMLoop *l1, BMLoop *l2)
 
BMEdgeBM_edge_rotate (BMesh *bm, BMEdge *e, bool ccw, short check_flag)
 Rotate Edge. More...
 
BMVertBM_face_loop_separate (BMesh *bm, BMLoop *l_sep)
 Rip a single face from a vertex fan. More...
 
BMVertBM_face_loop_separate_multi_isolated (BMesh *bm, BMLoop *l_sep)
 
BMVertBM_face_loop_separate_multi (BMesh *bm, BMLoop **larr, int larr_len)
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Flags for BM_edge_rotate

Enumerator
BM_EDGEROT_CHECK_EXISTS 

Disallow rotating when the new edge matches an existing one.

BM_EDGEROT_CHECK_SPLICE 

Overrides existing check, if the edge already, rotate and merge them.

BM_EDGEROT_CHECK_DEGENERATE 

Disallow creating bow-tie, concave or zero area faces

BM_EDGEROT_CHECK_BEAUTY 

Disallow rotating into ugly topology.

Definition at line 246 of file bmesh_mods.h.

Function Documentation

◆ BM_disk_dissolve()

bool BM_disk_dissolve ( BMesh bm,
BMVert v 
)

◆ BM_edge_calc_rotate()

void BM_edge_calc_rotate ( BMEdge e,
bool  ccw,
BMLoop **  r_l1,
BMLoop **  r_l2 
)

Calculate the 2 loops which would make up the newly rotated Edge but don't actually change anything.

Use this to further inspect if the loops to be connected have issues:

Examples:

  • the newly formed edge already exists
  • the new face would be degenerate (zero area / concave / bow-tie)
  • may want to measure if the new edge gives improved results topology. over the old one, as with beauty fill.
Note
BM_edge_rotate_check must have already run.

Definition at line 635 of file bmesh_mods.c.

References BLI_assert, BM_edge_face_pair(), BM_edge_ordered_verts(), BM_edge_rotate_check(), BM_face_other_vert_loop(), e, fb(), SWAP, v1, and v2.

Referenced by BM_edge_rotate().

◆ BM_edge_collapse()

BMVert* BM_edge_collapse ( BMesh bm,
BMEdge e_kill,
BMVert v_kill,
bool  do_del,
bool  kill_degenerate_faces 
)

◆ BM_edge_rotate()

BMEdge* BM_edge_rotate ( BMesh bm,
BMEdge e,
bool  ccw,
short  check_flag 
)

Rotate Edge.

Spins an edge topologically, either counter-clockwise or clockwise depending on ccw.

Returns
The spun edge, NULL on error (e.g., if the edge isn't surrounded by exactly two faces).
Note
This works by dissolving the edge then re-creating it, so the returned edge won't have the same pointer address as the original one.
See also
header definition for check_flag enum.

Definition at line 785 of file bmesh_mods.c.

References BMesh::act_face, bm, BM_CREATE_NO_DOUBLE, BM_CREATE_NOP, BM_edge_calc_rotate(), BM_edge_create(), BM_edge_exists(), BM_edge_face_pair(), BM_edge_is_contiguous(), BM_edge_rotate_check(), BM_edge_rotate_check_beauty(), BM_edge_rotate_check_degenerate(), BM_EDGEROT_CHECK_BEAUTY, BM_EDGEROT_CHECK_DEGENERATE, BM_EDGEROT_CHECK_EXISTS, BM_EDGEROT_CHECK_SPLICE, BM_face_edge_share_loop(), BM_face_normal_flip(), BM_face_split(), BM_face_vert_share_loop(), BM_faces_join_pair(), e, BMLoop::f, fb(), BMFace::head, BMHeader::hflag, BMEdge::l, NULL, BMLoop::radial_next, BMLoop::v, v1, and v2.

Referenced by BM_mesh_beautify_fill(), bm_rotate_edges_shared(), bm_rotate_edges_simple(), and bpy_bm_utils_edge_rotate().

◆ BM_edge_rotate_check()

bool BM_edge_rotate_check ( BMEdge e)

Check if Rotate Edge is OK.

Quick check to see if we could rotate the edge, use this to avoid calling exceptions on common cases.

Definition at line 661 of file bmesh_mods.c.

References BM_edge_face_pair(), BM_face_other_vert_loop(), e, fb(), and BMLoop::v.

Referenced by BM_edge_calc_rotate(), BM_edge_rotate(), BM_edge_rotate_check_degenerate(), bm_rotate_edges_shared(), bm_rotate_edges_simple(), and bmo_beautify_fill_exec().

◆ BM_edge_rotate_check_beauty()

bool BM_edge_rotate_check_beauty ( BMEdge e,
BMLoop l1,
BMLoop l2 
)

Definition at line 777 of file bmesh_mods.c.

References BMVert::co, e, len_squared_v3v3(), and BMLoop::v.

Referenced by BM_edge_rotate().

◆ BM_edge_rotate_check_degenerate()

bool BM_edge_rotate_check_degenerate ( BMEdge e,
BMLoop l1,
BMLoop l2 
)

Check if Edge Rotate Gives Degenerate Faces.

Check 2 cases 1) does the newly forms edge form a flipped face (compare with previous cross product) 2) does the newly formed edge cause a zero area corner (or close enough to be almost zero)

Parameters
eThe edge to test rotation.
l1,l2are the loops of the proposed verts to rotate too and should be the result of calling BM_edge_calc_rotate

Definition at line 690 of file bmesh_mods.c.

References BLI_assert, BM_edge_exists(), BM_edge_ordered_verts(), BM_edge_rotate_check(), BM_face_other_vert_loop(), BMVert::co, cross_v3_v3v3(), dot_v3v3(), e, BMLoop::f, negate_v3_v3(), normalize_v3(), sub_v3_v3v3(), BMLoop::v, v1, and v2.

Referenced by BM_edge_rotate().

◆ BM_edge_split()

BMVert* BM_edge_split ( BMesh bm,
BMEdge e,
BMVert v,
BMEdge **  r_e,
float  fac 
)

Edge Split.

Before: v
        +-----------------------------------+
                          e

After:  v                 v_new (returned)
        +-----------------+-----------------+
                r_e                e
Parameters
eThe edge to split.
vOne of the vertices in e and defines the "from" end of the splitting operation, the new vertex will be fac of the way from v to the other end.
r_eThe newly created edge.
Returns
The new vertex.

Definition at line 448 of file bmesh_mods.c.

References _FLAG_OVERLAP, BLI_array_append, BLI_array_free, BLI_array_len, BLI_array_staticdeclare, BLI_assert, bm, BM_data_interp_face_vert_edge(), BM_data_interp_from_verts(), BM_edge_is_wire(), BM_edge_other_vert(), BM_ELEM_API_FLAG_DISABLE, BM_ELEM_API_FLAG_ENABLE, BM_ELEM_API_FLAG_TEST, BM_elem_attrs_copy(), BM_face_calc_center_median(), BM_face_copy(), BM_face_interp_multires_ex(), BM_face_multires_bounds_smooth(), BM_face_verts_kill(), BM_vert_in_edge(), BMESH_ASSERT, bmesh_kernel_split_edge_make_vert(), CD_MDISPS, BMVert::co, CustomData_get_offset(), e, BMLoop::f, BMVert::head, BMEdge::head, BMHeader::hflag, BMEdge::l, l, BMesh::ldata, madd_v3_v3v3fl(), NULL, BMLoop::radial_next, sub_v3_v3v3(), UNLIKELY, and v.

Referenced by BM_edge_split_n(), BM_mesh_bisect_plane(), BM_mesh_intersect(), BM_mesh_intersect_edges(), bm_subdivide_edge_addvert(), bmo_connect_vert_pair_exec(), bmo_dissolve_degenerate_exec(), bmo_offset_edgeloops_exec(), bpy_bm_utils_edge_split(), edbm_face_split_by_edges_exec(), edbm_polybuild_face_at_cursor_invoke(), edbm_polybuild_split_at_cursor_invoke(), edbm_rip_edge_invoke(), and knife_make_cuts().

◆ BM_edge_split_n()

BMVert* BM_edge_split_n ( BMesh bm,
BMEdge e,
int  numcuts,
BMVert **  r_varr 
)

Split an edge multiple times evenly.

Parameters
r_varrOptional array, verts in between (v1 -> v2)

Definition at line 563 of file bmesh_mods.c.

References bm, BM_edge_split(), e, float(), and NULL.

Referenced by bm_edge_subdiv_as_loop().

◆ BM_edge_verts_swap()

void BM_edge_verts_swap ( BMEdge e)

Swap v1 & v2

Note
Typically we shouldn't care about this, however it's used when extruding wire edges.

Definition at line 580 of file bmesh_mods.c.

References e, and SWAP.

Referenced by bmo_edge_copy().

◆ BM_face_loop_separate()

BMVert* BM_face_loop_separate ( BMesh bm,
BMLoop l_sep 
)

Rip a single face from a vertex fan.

Definition at line 896 of file bmesh_mods.c.

References bm, and bmesh_kernel_unglue_region_make_vert().

Referenced by bmo_face_inset_individual(), bpy_bm_utils_face_vert_separate(), and bpy_bm_utils_loop_separate().

◆ BM_face_loop_separate_multi()

BMVert* BM_face_loop_separate_multi ( BMesh bm,
BMLoop **  larr,
int  larr_len 
)

Definition at line 906 of file bmesh_mods.c.

References bm, and bmesh_kernel_unglue_region_make_vert_multi().

Referenced by BM_mesh_separate_faces(), and edbm_rip_invoke__vert().

◆ BM_face_loop_separate_multi_isolated()

BMVert* BM_face_loop_separate_multi_isolated ( BMesh bm,
BMLoop l_sep 
)

Definition at line 901 of file bmesh_mods.c.

References bm, and bmesh_kernel_unglue_region_make_vert_multi_isolated().

Referenced by edbm_rip_invoke__vert().

◆ BM_face_split()

BMFace* BM_face_split ( BMesh bm,
BMFace f,
BMLoop l_a,
BMLoop l_b,
BMLoop **  r_l,
BMEdge example,
bool  no_double 
)

Face Split.

see: bmesh_polygon_edgenet.h for BM_face_split_edgenet

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.

Parameters
bmThe bmesh
fthe original face
l_a,l_bLoops of this face, their vertices define the split edge to be created (must be differ and not can't be adjacent in the face).
r_lpointer which will receive the BMLoop for the split edge in the new face
exampleEdge used for attributes of splitting edge, if non-NULL
no_doubleUse an existing edge if found
Returns
Pointer to the newly created face representing one side of the split if the split is successful (and the original face will be the other side). NULL if the split fails.

Definition at line 179 of file bmesh_mods.c.

References BLI_assert, bm, BM_face_calc_center_median(), BM_face_copy(), BM_face_interp_multires_ex(), BM_face_kill(), BM_face_multires_bounds_smooth(), BM_loop_is_adjacent(), bmesh_kernel_split_face_make_edge(), CD_MDISPS, CustomData_get_offset(), BMLoop::f, l_b, BMesh::ldata, NULL, and UNLIKELY.

Referenced by bevel_build_trifan(), BM_disk_dissolve(), BM_edge_rotate(), bm_face_bisect_verts(), bm_face_connect_verts(), bm_face_slice(), bm_face_split(), bm_face_split_by_angle(), BM_vert_collapse_faces(), bm_vert_dissolve_fan(), bmo_dissolve_degenerate_exec(), bmo_offset_edgeloops_exec(), bmo_subdivide_edges_exec(), bpy_bm_utils_face_split(), connect_smallest_face(), and remdoubles_splitface().

◆ BM_face_split_n()

BMFace* BM_face_split_n ( BMesh bm,
BMFace f,
BMLoop l_a,
BMLoop l_b,
float  cos[][3],
int  n,
BMLoop **  r_l,
BMEdge example 
)

Face Split with intermediate points.

Like BM_face_split, but with an edge split by n intermediate points with given coordinates.

Parameters
bmThe bmesh.
fthe original face.
l_a,l_bVertices which define the split edge, must be different.
cosArray of coordinates for intermediate points.
nLength of cos (must be > 0).
r_lpointer which will receive the BMLoop. for the first split edge (from l_a) in the new face.
exampleEdge used for attributes of splitting edge, if non-NULL.
Returns
Pointer to the newly created face representing one side of the split if the split is successful (and the original face will be the other side). NULL if the split fails.

Definition at line 243 of file bmesh_mods.c.

References BLI_assert, bm, BM_face_copy(), BM_face_verts_kill(), BM_loop_interp_from_face(), BM_loop_is_adjacent(), bmesh_kernel_split_edge_make_vert(), bmesh_kernel_split_face_make_edge(), BMVert::co, copy_v3_v3(), KDL::cos(), BMLoop::e, e, BMLoop::f, BMEdge::l, l_b, NULL, BMLoop::radial_next, UNLIKELY, and BMLoop::v.

Referenced by bm_face_split_walk_back(), and bpy_bm_utils_face_split().

◆ BM_face_validate()

bool BM_face_validate ( BMFace face,
FILE *  err 
)

◆ BM_faces_join_pair()

BMFace* BM_faces_join_pair ( BMesh bm,
BMLoop l_a,
BMLoop l_b,
bool  do_del 
)

Faces Join Pair.

Joins two adjacent faces together.

Note
This method calls to BM_faces_join to do its work. This means connected edges which also share the two faces will be joined.

If the windings do not match the winding of the new face will follow l_a's winding (i.e. l_b will be reversed before the join).

Returns
The combined face or NULL on failure.

Definition at line 166 of file bmesh_mods.c.

References BLI_assert, bm, BM_faces_join(), bmesh_kernel_loop_reverse(), CD_MDISPS, CustomData_get_offset(), BMLoop::e, BMLoop::f, faces, l_b, BMesh::ldata, and BMLoop::v.

Referenced by BM_disk_dissolve(), BM_edge_rotate(), BM_mesh_decimate_dissolve_ex(), bmo_dissolve_edges_exec(), bmo_dissolve_verts_exec(), bmo_join_triangles_exec(), bmo_triangle_fill_exec(), and edbm_polybuild_dissolve_at_cursor_invoke().

◆ BM_vert_collapse_edge()

BMEdge* BM_vert_collapse_edge ( BMesh bm,
BMEdge e_kill,
BMVert v_kill,
bool  do_del,
bool  kill_degenerate_faces,
bool  kill_duplicate_faces 
)

◆ BM_vert_collapse_faces()

BMEdge* BM_vert_collapse_faces ( BMesh bm,
BMEdge e_kill,
BMVert v_kill,
float  fac,
bool  do_del,
bool  join_faces,
bool  kill_degenerate_faces,
bool  kill_duplicate_faces 
)

Vert Collapse Faces.

Collapses vertex v_kill that has only two manifold edges onto a vertex it shares an edge with. fac defines the amount of interpolation for Custom Data.

Note
that this is not a general edge collapse function.
this function is very close to BM_vert_collapse_edge, both collapse a vertex and return a new edge. Except this takes a factor and merges custom data.
Parameters
bmThe bmesh
e_killThe edge to collapse
v_killThe vertex to collapse into the edge
facThe factor along the edge
join_facesWhen true the faces around the vertex will be joined otherwise collapse the vertex by merging the 2 edges this vert touches into one.
kill_degenerate_facesRemoves faces with less than 3 verts after collapsing.
Returns
The New Edge

Definition at line 316 of file bmesh_mods.c.

References BLI_array_append, BLI_array_free, BLI_array_len, BLI_array_staticdeclare, BLI_assert, bm, BM_data_interp_from_verts(), BM_DEFAULT_ITER_STACK_SIZE, BM_edge_other_vert(), BM_face_split(), BM_face_vert_share_loop(), BM_faces_join(), BM_FACES_OF_VERT, BM_ITER_ELEM, bmesh_disk_count(), bmesh_disk_edge_next(), bmesh_kernel_join_edge_kill_vert(), CustomData_bmesh_interp(), BMHeader::data, BMLoop::e, faces, BMLoop::head, BMEdge::l, l_b, BMesh::ldata, BMLoop::next, NULL, BMLoop::radial_next, src, BMLoop::v, and w().

Referenced by BM_disk_dissolve(), BM_vert_collapse_edge(), and bpy_bm_utils_vert_collapse_faces().

◆ BM_vert_dissolve()

bool BM_vert_dissolve ( BMesh bm,
BMVert v 
)

Dissolve Vert.

Turns the face region surrounding a manifold vertex into a single polygon.

Example:
             +---------+             +---------+
             |  \   /  |             |         |
    Before:  |    v    |      After: |         |
             |  /   \  |             |         |
             +---------+             +---------+

This function can also collapse edges too in cases when it can't merge into faces.

Example:
    Before:  +----v----+      After: +---------+
Note
dissolves vert, in more situations than BM_disk_dissolve (e.g. if the vert is part of a wire edge, etc).

Definition at line 20 of file bmesh_mods.c.

References bm, BM_disk_dissolve(), BM_vert_collapse_edge(), BM_vert_edge_count_at_most(), BM_vert_face_count_is_equal, BM_vert_is_manifold(), BM_vert_kill(), BMVert::e, BMEdge::l, len, NULL, and v.

Referenced by bm_vert_dissolve_fan(), and bpy_bm_utils_vert_dissolve().