Blender  V3.3
bmesh_core_test.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include "testing/testing.h"
4 
5 #include "BLI_math.h"
6 #include "BLI_utildefines.h"
7 #include "bmesh.h"
8 
9 TEST(bmesh_core, BMVertCreate)
10 {
11  BMesh *bm;
12  BMVert *bv1, *bv2, *bv3;
13  const float co1[3] = {1.0f, 2.0f, 0.0f};
14 
15  BMeshCreateParams bmesh_create_params{};
16  bmesh_create_params.use_toolflags = true;
17  bm = BM_mesh_create(&bm_mesh_allocsize_default, &bmesh_create_params);
18  EXPECT_EQ(bm->totvert, 0);
19  /* make a custom layer so we can see if it is copied properly */
21  bv1 = BM_vert_create(bm, co1, nullptr, BM_CREATE_NOP);
22  ASSERT_TRUE(bv1 != nullptr);
23  EXPECT_EQ(bv1->co[0], 1.0f);
24  EXPECT_EQ(bv1->co[1], 2.0f);
25  EXPECT_EQ(bv1->co[2], 0.0f);
26  EXPECT_TRUE(is_zero_v3(bv1->no));
27  EXPECT_EQ(bv1->head.htype, (char)BM_VERT);
28  EXPECT_EQ(bv1->head.hflag, 0);
29  EXPECT_EQ(bv1->head.api_flag, 0);
30  bv2 = BM_vert_create(bm, nullptr, nullptr, BM_CREATE_NOP);
31  ASSERT_TRUE(bv2 != nullptr);
32  EXPECT_TRUE(is_zero_v3(bv2->co));
33  /* create with example should copy custom data but not select flag */
34  BM_vert_select_set(bm, bv2, true);
36  bv3 = BM_vert_create(bm, co1, bv2, BM_CREATE_NOP);
37  ASSERT_TRUE(bv3 != nullptr);
38  EXPECT_FALSE(BM_elem_flag_test((BMElem *)bv3, BM_ELEM_SELECT));
42 }
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
MINLINE bool is_zero_v3(const float a[3]) ATTR_WARN_UNUSED_RESULT
@ CD_PROP_FLOAT
@ BM_VERT
Definition: bmesh_class.h:383
@ BM_ELEM_SELECT
Definition: bmesh_class.h:471
BMVert * BM_vert_create(BMesh *bm, const float co[3], const BMVert *v_example, const eBMCreateFlag create_flag)
Main function for creating a new vertex.
Definition: bmesh_core.c:41
@ BM_CREATE_NOP
Definition: bmesh_core.h:12
TEST(bmesh_core, BMVertCreate)
#define BM_elem_flag_test(ele, hflag)
Definition: bmesh_inline.h:12
float BM_elem_float_data_get(CustomData *cd, void *element, int type)
Definition: bmesh_interp.c:990
void BM_data_layer_add(BMesh *bm, CustomData *data, int type)
Definition: bmesh_interp.c:839
void BM_elem_float_data_set(CustomData *cd, void *element, int type, const float val)
Definition: bmesh_interp.c:996
ATTR_WARN_UNUSED_RESULT BMesh * bm
void BM_vert_select_set(BMesh *bm, BMVert *v, const bool select)
Select Vert.
const BMAllocTemplate bm_mesh_allocsize_default
Definition: bmesh_mesh.cc:23
void BM_mesh_free(BMesh *bm)
BMesh Free Mesh.
Definition: bmesh_mesh.cc:258
BMesh * BM_mesh_create(const BMAllocTemplate *allocsize, const struct BMeshCreateParams *params)
Definition: bmesh_mesh.cc:125
int BM_mesh_elem_count(BMesh *bm, const char htype)
Definition: bmesh_mesh.cc:708
char htype
Definition: bmesh_class.h:64
char hflag
Definition: bmesh_class.h:66
char api_flag
Definition: bmesh_class.h:74
float co[3]
Definition: bmesh_class.h:87
float no[3]
Definition: bmesh_class.h:88
BMHeader head
Definition: bmesh_class.h:85
int totvert
Definition: bmesh_class.h:297
CustomData vdata
Definition: bmesh_class.h:337