Blender  V2.93
Macros | Functions
bmesh_bisect_plane.c File Reference
#include <limits.h>
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_utildefines_stack.h"
#include "bmesh.h"
#include "bmesh_bisect_plane.h"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Macros

#define BM_VERT_DIR(v)   ((short *)(&(v)->head.index))[0] /* Direction -1/0/1 */
 
#define BM_VERT_SKIP(v)   ((short *)(&(v)->head.index))[1] /* Skip Vert 0/1 */
 
#define BM_VERT_DIST(v)   ((v)->no[0]) /* Distance from the plane. */
 
#define BM_VERT_SORTVAL(v)   ((v)->no[1]) /* Temp value for sorting. */
 
#define BM_VERT_LOOPINDEX(v)
 

Functions

static short plane_point_test_v3 (const float plane[4], const float co[3], const float eps, float *r_depth)
 
BLI_INLINE void vert_is_center_enable (BMVert *v)
 
BLI_INLINE void vert_is_center_disable (BMVert *v)
 
BLI_INLINE bool vert_is_center_test (BMVert *v)
 
BLI_INLINE bool vert_pair_adjacent_in_orig_face (BMVert *v_a, BMVert *v_b, const uint f_len_orig)
 
BLI_INLINE void edge_is_cut_enable (BMEdge *e)
 
BLI_INLINE void edge_is_cut_disable (BMEdge *e)
 
BLI_INLINE bool edge_is_cut_test (BMEdge *e)
 
BLI_INLINE void face_in_stack_enable (BMFace *f)
 
BLI_INLINE void face_in_stack_disable (BMFace *f)
 
BLI_INLINE bool face_in_stack_test (BMFace *f)
 
static int bm_vert_sortval_cb (const void *v_a_v, const void *v_b_v)
 
static void bm_face_bisect_verts (BMesh *bm, BMFace *f, const float plane[4], const short oflag_center, const short oflag_new)
 
void BM_mesh_bisect_plane (BMesh *bm, const float plane[4], const bool use_snap_center, const bool use_tag, const short oflag_center, const short oflag_new, const float eps)
 

Detailed Description

Cut the geometry in half using a plane.

Implementation
This simply works by splitting tagged edges who's verts span either side of the plane, then splitting faces along their dividing verts. The only complex case is when a ngon spans the axis multiple times, in this case we need to do some extra checks to correctly bisect the ngon. see: bm_face_bisect_verts

Definition in file bmesh_bisect_plane.c.

Macro Definition Documentation

◆ BM_VERT_DIR

#define BM_VERT_DIR (   v)    ((short *)(&(v)->head.index))[0] /* Direction -1/0/1 */

Definition at line 71 of file bmesh_bisect_plane.c.

◆ BM_VERT_DIST

#define BM_VERT_DIST (   v)    ((v)->no[0]) /* Distance from the plane. */

Definition at line 73 of file bmesh_bisect_plane.c.

◆ BM_VERT_LOOPINDEX

#define BM_VERT_LOOPINDEX (   v)
Value:
/* The verts index within a face (temp var) */ \
(*((uint *)(&(v)->no[2])))
unsigned int uint
Definition: BLI_sys_types.h:83
ATTR_WARN_UNUSED_RESULT const BMVert * v

Definition at line 75 of file bmesh_bisect_plane.c.

◆ BM_VERT_SKIP

#define BM_VERT_SKIP (   v)    ((short *)(&(v)->head.index))[1] /* Skip Vert 0/1 */

Definition at line 72 of file bmesh_bisect_plane.c.

◆ BM_VERT_SORTVAL

#define BM_VERT_SORTVAL (   v)    ((v)->no[1]) /* Temp value for sorting. */

Definition at line 74 of file bmesh_bisect_plane.c.

Function Documentation

◆ bm_face_bisect_verts()

static void bm_face_bisect_verts ( BMesh bm,
BMFace f,
const float  plane[4],
const short  oflag_center,
const short  oflag_new 
)
static

◆ BM_mesh_bisect_plane()

void BM_mesh_bisect_plane ( BMesh bm,
const float  plane[4],
const bool  use_snap_center,
const bool  use_tag,
const short  oflag_center,
const short  oflag_new,
const float  eps 
)

◆ bm_vert_sortval_cb()

static int bm_vert_sortval_cb ( const void *  v_a_v,
const void *  v_b_v 
)
static

Definition at line 134 of file bmesh_bisect_plane.c.

References BM_VERT_SORTVAL.

Referenced by bm_face_bisect_verts().

◆ edge_is_cut_disable()

BLI_INLINE void edge_is_cut_disable ( BMEdge e)

Definition at line 108 of file bmesh_bisect_plane.c.

References BM_elem_flag_disable, BM_ELEM_TAG, and e.

◆ edge_is_cut_enable()

BLI_INLINE void edge_is_cut_enable ( BMEdge e)

Definition at line 104 of file bmesh_bisect_plane.c.

References BM_elem_flag_enable, BM_ELEM_TAG, and e.

Referenced by BM_mesh_bisect_plane().

◆ edge_is_cut_test()

BLI_INLINE bool edge_is_cut_test ( BMEdge e)

Definition at line 112 of file bmesh_bisect_plane.c.

References BM_elem_flag_test, BM_ELEM_TAG, and e.

Referenced by BM_mesh_bisect_plane().

◆ face_in_stack_disable()

BLI_INLINE void face_in_stack_disable ( BMFace f)

Definition at line 122 of file bmesh_bisect_plane.c.

References BM_elem_flag_enable, and BM_ELEM_TAG.

Referenced by BM_mesh_bisect_plane().

◆ face_in_stack_enable()

BLI_INLINE void face_in_stack_enable ( BMFace f)

Definition at line 118 of file bmesh_bisect_plane.c.

References BM_elem_flag_disable, and BM_ELEM_TAG.

Referenced by BM_mesh_bisect_plane().

◆ face_in_stack_test()

BLI_INLINE bool face_in_stack_test ( BMFace f)

Definition at line 126 of file bmesh_bisect_plane.c.

References BM_elem_flag_test, and BM_ELEM_TAG.

Referenced by BM_mesh_bisect_plane().

◆ plane_point_test_v3()

static short plane_point_test_v3 ( const float  plane[4],
const float  co[3],
const float  eps,
float r_depth 
)
static

Definition at line 49 of file bmesh_bisect_plane.c.

References eps, and plane_point_side_v3().

Referenced by BM_mesh_bisect_plane().

◆ vert_is_center_disable()

BLI_INLINE void vert_is_center_disable ( BMVert v)

Definition at line 88 of file bmesh_bisect_plane.c.

References BM_elem_flag_disable, BM_ELEM_TAG, and v.

Referenced by BM_mesh_bisect_plane().

◆ vert_is_center_enable()

BLI_INLINE void vert_is_center_enable ( BMVert v)

Hide flag access (for more readable code since same flag is used differently for vert/edgeface)...

Definition at line 84 of file bmesh_bisect_plane.c.

References BM_elem_flag_enable, BM_ELEM_TAG, and v.

Referenced by BM_mesh_bisect_plane().

◆ vert_is_center_test()

BLI_INLINE bool vert_is_center_test ( BMVert v)

Definition at line 92 of file bmesh_bisect_plane.c.

References BM_elem_flag_test, BM_ELEM_TAG, and v.

Referenced by bm_face_bisect_verts(), and BM_mesh_bisect_plane().

◆ vert_pair_adjacent_in_orig_face()

BLI_INLINE bool vert_pair_adjacent_in_orig_face ( BMVert v_a,
BMVert v_b,
const uint  f_len_orig 
)

Definition at line 97 of file bmesh_bisect_plane.c.

References abs(), BM_VERT_LOOPINDEX, and ELEM.

Referenced by bm_face_bisect_verts().