Blender V4.3
bmesh_bisect_plane.cc File Reference
#include <climits>
#include "MEM_guardedalloc.h"
#include "BLI_alloca.h"
#include "BLI_linklist.h"
#include "BLI_linklist_stack.h"
#include "BLI_math_geom.h"
#include "BLI_math_vector.h"
#include "BLI_utildefines.h"
#include "BLI_utildefines_stack.h"
#include "bmesh.hh"
#include "bmesh_bisect_plane.hh"
#include "BLI_strict_flags.h"

Go to the source code of this file.

Macros

BMesh Element Accessors

Wrappers to hide internal data-structure abuse, later we may want to move this into some hash lookup to a separate struct, but for now we can store in BMesh data.

#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

Math Functions
static short plane_point_test_v3 (const float plane[4], const float co[3], const float eps, float *r_depth)
 
BMesh Flag Accessors

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

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)
 
BMesh Face Bisect
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)
 
Public BMesh Bisect Function
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.cc.

Macro Definition Documentation

◆ BM_VERT_DIR

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

Definition at line 66 of file bmesh_bisect_plane.cc.

Referenced by bm_face_bisect_verts(), and BM_mesh_bisect_plane().

◆ BM_VERT_DIST

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

Definition at line 68 of file bmesh_bisect_plane.cc.

Referenced by BM_mesh_bisect_plane().

◆ BM_VERT_LOOPINDEX

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

Definition at line 70 of file bmesh_bisect_plane.cc.

Referenced by bm_face_bisect_verts(), and vert_pair_adjacent_in_orig_face().

◆ BM_VERT_SKIP

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

Definition at line 67 of file bmesh_bisect_plane.cc.

Referenced by bm_face_bisect_verts().

◆ BM_VERT_SORTVAL

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

Definition at line 69 of file bmesh_bisect_plane.cc.

Referenced by bm_face_bisect_verts(), and bm_vert_sortval_cb().

Function Documentation

◆ bm_face_bisect_verts()

◆ BM_mesh_bisect_plane()

◆ bm_vert_sortval_cb()

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

Definition at line 136 of file bmesh_bisect_plane.cc.

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 107 of file bmesh_bisect_plane.cc.

References BM_elem_flag_disable, BM_ELEM_TAG, and e.

◆ edge_is_cut_enable()

BLI_INLINE void edge_is_cut_enable ( BMEdge * e)

Enable when the edge can be cut.

Definition at line 103 of file bmesh_bisect_plane.cc.

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 111 of file bmesh_bisect_plane.cc.

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 121 of file bmesh_bisect_plane.cc.

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)

Enable when the faces are added to the stack.

Definition at line 117 of file bmesh_bisect_plane.cc.

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 125 of file bmesh_bisect_plane.cc.

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 39 of file bmesh_bisect_plane.cc.

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 87 of file bmesh_bisect_plane.cc.

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)

Enable when vertex is in the center and its faces have been added to the stack.

Definition at line 83 of file bmesh_bisect_plane.cc.

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 91 of file bmesh_bisect_plane.cc.

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 96 of file bmesh_bisect_plane.cc.

References abs(), BM_VERT_LOOPINDEX, and ELEM.

Referenced by bm_face_bisect_verts().