5#include "testing/testing.h"
29 std::string ply_path = blender::tests::flags_test_asset_dir() +
35 const char *header_err =
read_header(infile, header);
36 if (header_err !=
nullptr) {
41 if (!
data->error.empty()) {
42 fprintf(stderr,
"%s\n",
data->error.c_str());
43 ASSERT_EQ(0,
exp.totvert);
44 ASSERT_EQ(0,
exp.faces_num);
49 ASSERT_EQ(
data->vertices.size(),
exp.totvert);
50 ASSERT_EQ(
data->edges.size(),
exp.totedge);
51 ASSERT_EQ(
data->face_sizes.size(),
exp.faces_num);
52 ASSERT_EQ(
data->face_vertices.size(),
exp.totindex);
63 if (!
data->face_vertices.is_empty()) {
64 ASSERT_EQ(face_hash,
exp.polyhash);
67 if (!
data->edges.is_empty()) {
69 (
const uchar *)
data->edges.data(),
data->edges.size() *
sizeof(
data->edges[0]), 0);
70 ASSERT_EQ(edge_hash,
exp.edgehash);
74 EXPECT_V3_NEAR(
data->vertices.first(),
exp.vert_first, 0.0001f);
75 EXPECT_V3_NEAR(
data->vertices.last(),
exp.vert_last, 0.0001f);
79 data->vertex_normals.first();
80 EXPECT_V3_NEAR(got_normal,
exp.normal_first, 0.0001f);
84 EXPECT_V2_NEAR(got_uv,
exp.uv_first, 0.0001f);
88 data->vertex_colors.first();
89 EXPECT_V4_NEAR(got_color,
exp.color_first, 0.0001f);
104 float2(0.979336, 0.844958),
106 import_and_check(
"cube_ascii.ply", expect);
111 Expectation expect = {8, 0, 0, 12, 0, 31435,
float3(-1, -1, -1),
float3(1, 1, 1)};
112 import_and_check(
"ASCII_wireframe_cube.ply", expect);
113 import_and_check(
"wireframe_cube.ply", expect);
118 Expectation expect = {4, 1, 4, 0, 37235, 0,
float3(-1, -1, 0),
float3(-1, 1, 0)};
119 import_and_check(
"bin_data_starts_with_lf.ply", expect);
120 import_and_check(
"bin_data_starts_with_lf_header_crlf.ply", expect);
131 float3(0.0380425, 0.109755, 0.0161689),
132 float3(-0.0722821, 0.143895, -0.0129091)};
133 import_and_check(
"bunny2.ply", expect);
144 float3(-0.0131592, -0.0598382, 1.58958),
145 float3(-0.0177622, 0.0105153, 1.61977),
148 float4(0.7215, 0.6784, 0.6627, 1)};
149 import_and_check(
"many_small_holes.ply", expect);
154 Expectation expect = {4, 1, 4, 0, 37235, 0,
float3(1, 0, 1),
float3(-1, 0, 1)};
155 import_and_check(
"color_not_full_a.ply", expect);
156 import_and_check(
"color_not_full_b.ply", expect);
167 float3(-0.78193f, 0.40659f, -1),
168 float3(-0.75537f, 1, -0.24777f),
171 float4(0.31373f, 0, 0, 1)};
172 import_and_check(
"custom_data_elements.ply", expect);
188 import_and_check(
"double_xyz_a.ply", expect);
189 import_and_check(
"double_xyz_b.ply", expect);
194 Expectation expect = {4, 2, 6, 0, 4136, 0,
float3(1, 0, 1),
float3(-1, 0, 1)};
195 import_and_check(
"face_indices_not_first_prop_a.ply", expect);
196 import_and_check(
"face_indices_not_first_prop_b.ply", expect);
201 Expectation expect = {4, 2, 6, 0, 4136, 0,
float3(1, 0, 1),
float3(-1, 0, 1)};
202 import_and_check(
"face_indices_preceded_by_list_a.ply", expect);
203 import_and_check(
"face_indices_preceded_by_list_b.ply", expect);
208 Expectation expect = {4, 1, 4, 0, 37235, 0,
float3(1, 0, 1),
float3(-1, 0, 1)};
209 import_and_check(
"face_uvs_colors_a.ply", expect);
210 import_and_check(
"face_uvs_colors_b.ply", expect);
226 import_and_check(
"faces_first_a.ply", expect);
227 import_and_check(
"faces_first_b.ply", expect);
242 float4(0.5f, 0, 0.25f, 1)};
243 import_and_check(
"float_formats_a.ply", expect);
244 import_and_check(
"float_formats_b.ply", expect);
250 import_and_check(
"position_not_full_a.ply", expect);
251 import_and_check(
"position_not_full_b.ply", expect);
256 Expectation expect = {6, 4, 12, 0, 3404, 0,
float3(1, 0, 1),
float3(-3, 0, 1)};
257 import_and_check(
"tristrips_a.ply", expect);
258 import_and_check(
"tristrips_b.ply", expect);
273 float4(220 / 255.0f, 20 / 255.0f, 20 / 255.0f, 1)};
274 import_and_check(
"type_aliases_a.ply", expect);
275 import_and_check(
"type_aliases_b.ply", expect);
276 import_and_check(
"type_aliases_be_b.ply", expect);
291 float4(0.8f, 0.2f, 0, 1)};
292 import_and_check(
"vertex_comp_order_a.ply", expect);
293 import_and_check(
"vertex_comp_order_b.ply", expect);
File and directory operations.
void BLI_hash_mm2a_init(BLI_HashMurmur2A *mm2, uint32_t seed)
void BLI_hash_mm2a_add(BLI_HashMurmur2A *mm2, const unsigned char *data, size_t len)
uint32_t BLI_hash_mm2a_end(BLI_HashMurmur2A *mm2)
uint32_t BLI_hash_mm2(const unsigned char *data, size_t len, uint32_t seed)
void import_and_check(const char *path, const Expectation &exp)
ccl_device_inline float3 exp(float3 v)
std::unique_ptr< PlyData > import_ply_data(PlyReadBuffer &file, PlyHeader &header)
const char * read_header(PlyReadBuffer &file, PlyHeader &r_header)
TEST_F(PLYExportTest, WriteHeaderAscii)
VecBase< float, 4 > float4
VecBase< float, 2 > float2
VecBase< float, 3 > float3