Blender V4.3
mesh_topology_test.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2020 Blender Foundation
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 *
5 * Author: Sergey Sharybin. */
6
8#include "testing/testing.h"
9
10namespace blender::opensubdiv {
11
12TEST(MeshTopology, TrivialVertexSharpness)
13{
14 MeshTopology mesh_topology;
15
16 mesh_topology.setNumVertices(3);
17 mesh_topology.finishResizeTopology();
18
19 mesh_topology.setVertexSharpness(0, 0.1f);
20 mesh_topology.setVertexSharpness(1, 0.2f);
21
22 EXPECT_EQ(mesh_topology.getVertexSharpness(0), 0.1f);
23 EXPECT_EQ(mesh_topology.getVertexSharpness(1), 0.2f);
24 EXPECT_EQ(mesh_topology.getVertexSharpness(2), 0.0f);
25}
26
27TEST(MeshTopology, TrivialEdgeSharpness)
28{
29 MeshTopology mesh_topology;
30
31 mesh_topology.setNumVertices(8);
32 mesh_topology.setNumEdges(3);
33 mesh_topology.finishResizeTopology();
34
35 mesh_topology.setEdgeVertexIndices(0, 0, 1);
36 mesh_topology.setEdgeVertexIndices(1, 1, 2);
37 mesh_topology.setEdgeVertexIndices(2, 2, 3);
38
39 mesh_topology.setEdgeSharpness(0, 0.1f);
40 mesh_topology.setEdgeSharpness(2, 0.2f);
41
42 EXPECT_EQ(mesh_topology.getEdgeSharpness(0), 0.1f);
43 EXPECT_EQ(mesh_topology.getEdgeSharpness(1), 0.0f);
44 EXPECT_EQ(mesh_topology.getEdgeSharpness(2), 0.2f);
45}
46
47TEST(MeshTopology, TrivialFaceTopology)
48{
49 MeshTopology mesh_topology;
50
51 mesh_topology.setNumFaces(3);
52 mesh_topology.setNumFaceVertices(0, 4);
53 mesh_topology.setNumFaceVertices(1, 3);
54 mesh_topology.setNumFaceVertices(2, 5);
55 mesh_topology.finishResizeTopology();
56
57 EXPECT_EQ(mesh_topology.getNumFaceVertices(0), 4);
58 EXPECT_EQ(mesh_topology.getNumFaceVertices(1), 3);
59 EXPECT_EQ(mesh_topology.getNumFaceVertices(2), 5);
60
61 {
62 const int vertex_indices[] = {0, 1, 2, 3};
63 mesh_topology.setFaceVertexIndices(0, 4, vertex_indices);
64 }
65
66 {
67 const int vertex_indices[] = {4, 5, 6};
68 mesh_topology.setFaceVertexIndices(1, 3, vertex_indices);
69 }
70
71 {
72 const int vertex_indices[] = {7, 8, 9, 10, 11};
73 mesh_topology.setFaceVertexIndices(2, 5, vertex_indices);
74 }
75
76 EXPECT_TRUE(mesh_topology.isFaceVertexIndicesEqual(0, {{0, 1, 2, 3}}));
77 EXPECT_FALSE(mesh_topology.isFaceVertexIndicesEqual(0, {{10, 1, 2, 3}}));
78 EXPECT_FALSE(mesh_topology.isFaceVertexIndicesEqual(0, {{0, 1, 2}}));
79
80 EXPECT_TRUE(mesh_topology.isFaceVertexIndicesEqual(1, {{4, 5, 6}}));
81 EXPECT_TRUE(mesh_topology.isFaceVertexIndicesEqual(2, {{7, 8, 9, 10, 11}}));
82}
83
84} // namespace blender::opensubdiv
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
void setEdgeSharpness(int edge_index, float sharpness)
float getEdgeSharpness(int edge_index) const
void setNumVertices(int num_vertices)
void setFaceVertexIndices(int face_index, int num_face_vertex_indices, const int *face_vertex_indices)
void setVertexSharpness(int vertex_index, float sharpness)
int getNumFaceVertices(int face_index) const
bool isFaceVertexIndicesEqual(int face_index, int num_expected_face_vertex_indices, const int *expected_face_vertex_indices) const
void setEdgeVertexIndices(int edge_index, int v1, int v2)
float getVertexSharpness(int vertex_index) const
void setNumFaceVertices(int face_index, int num_face_vertices)
TEST(MeshTopology, TrivialVertexSharpness)