Blender V5.0
bmesh_query_inline.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "BLI_compiler_attrs.h"
12#include "BLI_compiler_compat.h"
13#include "BLI_utildefines.h"
14
15#include "bmesh_class.hh"
16
22 bool BM_vert_in_edge(const BMEdge *e, const BMVert *v)
23{
24 return (ELEM(v, e->v1, e->v2));
25}
26
31 bool BM_edge_in_loop(const BMEdge *e, const BMLoop *l)
32{
33 return (l->e == e || l->prev->e == e);
34}
35
41 bool BM_verts_in_edge(const BMVert *v1, const BMVert *v2, const BMEdge *e)
42{
43 return ((e->v1 == v1 && e->v2 == v2) || (e->v1 == v2 && e->v2 == v1));
44}
45
51 const BMVert *v)
52{
53 if (e->v1 == v) {
54 return e->v2;
55 }
56 if (e->v2 == v) {
57 return e->v1;
58 }
59 return nullptr;
60}
61
67{
68 return (e->l == nullptr);
69}
70
75
76#if 1 /* fast path for checking manifold */
78{
79 const BMLoop *l = e->l;
80 return (l && (l->radial_next != l) && /* not 0 or 1 face users */
81 (l->radial_next->radial_next == l)); /* 2 face users */
82}
83#else
85{
86 return (BM_edge_face_count(e) == 2);
87}
88#endif
89
95{
96 const BMLoop *l = e->l;
97 const BMLoop *l_other;
98 return (l && ((l_other = l->radial_next) != l) && /* not 0 or 1 face users */
99 (l_other->radial_next == l) && /* 2 face users */
100 (l_other->v != l->v));
101}
102
107
108#if 1 /* fast path for checking boundary */
110{
111 const BMLoop *l = e->l;
112 return (l && (l->radial_next == l));
113}
114#else
116{
117 return (BM_edge_face_count(e) == 1);
118}
119#endif
120
125 bool BM_loop_is_adjacent(const BMLoop *l_a, const BMLoop *l_b)
126{
127 BLI_assert(l_a->f == l_b->f);
129 return (ELEM(l_b, l_a->next, l_a->prev));
130}
131
132ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE bool BM_loop_is_manifold(const BMLoop *l)
133{
134 return ((l != l->radial_next) && (l == l->radial_next->radial_next));
135}
136
140ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) BLI_INLINE bool BM_vert_is_wire_endpoint(const BMVert *v)
141{
142 const BMEdge *e = v->e;
143 if (e && e->l == nullptr) {
144 return (BM_DISK_EDGE_NEXT(e, v) == e);
145 }
146 return false;
147}
#define BLI_assert(a)
Definition BLI_assert.h:46
#define ATTR_WARN_UNUSED_RESULT
#define ATTR_NONNULL(...)
#define BLI_INLINE
#define ELEM(...)
int BM_edge_face_count(const BMEdge *e)
BLI_INLINE bool BM_edge_is_contiguous(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_edge_is_manifold(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_edge_is_boundary(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_loop_is_adjacent(const BMLoop *l_a, const BMLoop *l_b) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE BMVert * BM_edge_other_vert(BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_edge_in_loop(const BMEdge *e, const BMLoop *l) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_verts_in_edge(const BMVert *v1, const BMVert *v2, const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_edge_is_wire(const BMEdge *e) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
BLI_INLINE bool BM_vert_in_edge(const BMEdge *e, const BMVert *v) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
ATTR_WARN_UNUSED_RESULT const BMVert * v2
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMLoop * l_b
ATTR_WARN_UNUSED_RESULT const BMVert * v
struct BMVert * v
struct BMLoop * radial_next