Blender V4.3
io_ply_exporter_test.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#include "testing/testing.h"
7
8#include "BLI_fileops.h"
9#include "BLI_string.h"
10
11#include "BKE_appdir.hh"
12#include "BKE_blender_version.h"
13
14#include "DEG_depsgraph.hh"
15
16#include "IO_ply.hh"
17#include "intern/ply_data.hh"
18
19#include "ply_export_data.hh"
20#include "ply_export_header.hh"
24
25#include <fstream>
26
27namespace blender::io::ply {
28
30 public:
31 bool load_file_and_depsgraph(const std::string &filepath,
32 const eEvaluationMode eval_mode = DAG_EVAL_VIEWPORT)
33 {
34 if (!blendfile_load(filepath.c_str())) {
35 return false;
36 }
37 depsgraph_create(eval_mode);
38 return true;
39 }
40
41 protected:
42 void SetUp() override
43 {
44 BlendfileLoadingBaseTest::SetUp();
45
46 BKE_tempdir_init(nullptr);
47 }
48
55
56 std::string get_temp_ply_filename(const std::string &filename)
57 {
58 return std::string(BKE_tempdir_session()) + SEP_STR + filename;
59 }
60};
61
62static std::unique_ptr<PlyData> load_cube(PLYExportParams &params)
63{
64 std::unique_ptr<PlyData> plyData = std::make_unique<PlyData>();
65 plyData->vertices = {
66 {1.122082, 1.122082, 1.122082},
67 {1.122082, 1.122082, -1.122082},
68 {1.122082, -1.122082, 1.122082},
69 {1.122082, -1.122082, -1.122082},
70 {-1.122082, 1.122082, 1.122082},
71 {-1.122082, 1.122082, -1.122082},
72 {-1.122082, -1.122082, 1.122082},
73 {-1.122082, -1.122082, -1.122082},
74 };
75
76 plyData->face_sizes = {4, 4, 4, 4, 4, 4};
77 plyData->face_vertices = {0, 2, 6, 4, 3, 7, 6, 2, 7, 5, 4, 6,
78 5, 7, 3, 1, 1, 3, 2, 0, 5, 1, 0, 4};
79
80 if (params.export_normals) {
81 plyData->vertex_normals = {
82 {-0.5773503, -0.5773503, -0.5773503},
83 {-0.5773503, -0.5773503, 0.5773503},
84 {-0.5773503, 0.5773503, -0.5773503},
85 {-0.5773503, 0.5773503, 0.5773503},
86 {0.5773503, -0.5773503, -0.5773503},
87 {0.5773503, -0.5773503, 0.5773503},
88 {0.5773503, 0.5773503, -0.5773503},
89 {0.5773503, 0.5773503, 0.5773503},
90 };
91 }
92
93 return plyData;
94}
95
96/* The following is relative to BKE_tempdir_base.
97 * Use Latin Capital Letter A with Ogonek, Cyrillic Capital Letter Zhe
98 * at the end, to test I/O on non-English file names. */
99const char *const temp_file_path = "output\xc4\x84\xd0\x96.ply";
100
101static std::string read_temp_file_in_string(const std::string &file_path)
102{
103 std::string res;
104 size_t buffer_len;
105 void *buffer = BLI_file_read_text_as_mem(file_path.c_str(), 0, &buffer_len);
106 if (buffer != nullptr) {
107 res.assign((const char *)buffer, buffer_len);
108 MEM_freeN(buffer);
109 }
110 return res;
111}
112
113static char read(std::ifstream &file)
114{
115 char return_val;
116 file.read((char *)&return_val, sizeof(return_val));
117 return return_val;
118}
119
120static std::vector<char> read_temp_file_in_vectorchar(const std::string &file_path)
121{
122 std::vector<char> res;
123 std::ifstream infile(file_path, std::ios::binary);
124 while (true) {
125 uint64_t c = read(infile);
126 if (!infile.eof()) {
127 res.push_back(c);
128 }
129 else {
130 break;
131 }
132 }
133 return res;
134}
135
136TEST_F(PLYExportTest, WriteHeaderAscii)
137{
138 std::string filePath = get_temp_ply_filename(temp_file_path);
139 PLYExportParams _params = {};
140 _params.ascii_format = true;
141 _params.export_normals = false;
143 STRNCPY(_params.filepath, filePath.c_str());
144
145 std::unique_ptr<PlyData> plyData = load_cube(_params);
146
147 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferAscii>(_params.filepath);
148
149 write_header(*buffer.get(), *plyData.get(), _params);
150
151 buffer->close_file();
152
153 std::string result = read_temp_file_in_string(filePath);
154
156
157 std::string expected =
158 "ply\n"
159 "format ascii 1.0\n"
160 "comment Created in Blender version " +
161 version +
162 "\n"
163 "element vertex 8\n"
164 "property float x\n"
165 "property float y\n"
166 "property float z\n"
167 "element face 6\n"
168 "property list uchar uint vertex_indices\n"
169 "end_header\n";
170
171 ASSERT_STREQ(result.c_str(), expected.c_str());
172}
173
174TEST_F(PLYExportTest, WriteHeaderBinary)
175{
176 std::string filePath = get_temp_ply_filename(temp_file_path);
177 PLYExportParams _params = {};
178 _params.ascii_format = false;
179 _params.export_normals = false;
181 STRNCPY(_params.filepath, filePath.c_str());
182
183 std::unique_ptr<PlyData> plyData = load_cube(_params);
184
185 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferBinary>(_params.filepath);
186
187 write_header(*buffer.get(), *plyData.get(), _params);
188
189 buffer->close_file();
190
191 std::string result = read_temp_file_in_string(filePath);
192
194
195 std::string expected =
196 "ply\n"
197 "format binary_little_endian 1.0\n"
198 "comment Created in Blender version " +
199 version +
200 "\n"
201 "element vertex 8\n"
202 "property float x\n"
203 "property float y\n"
204 "property float z\n"
205 "element face 6\n"
206 "property list uchar uint vertex_indices\n"
207 "end_header\n";
208
209 ASSERT_STREQ(result.c_str(), expected.c_str());
210}
211
212TEST_F(PLYExportTest, WriteVerticesAscii)
213{
214 std::string filePath = get_temp_ply_filename(temp_file_path);
215 PLYExportParams _params = {};
216 _params.ascii_format = true;
217 _params.export_normals = false;
219 STRNCPY(_params.filepath, filePath.c_str());
220
221 std::unique_ptr<PlyData> plyData = load_cube(_params);
222
223 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferAscii>(_params.filepath);
224
225 write_vertices(*buffer.get(), *plyData.get());
226
227 buffer->close_file();
228
229 std::string result = read_temp_file_in_string(filePath);
230
231 std::string expected =
232 "1.122082 1.122082 1.122082\n"
233 "1.122082 1.122082 -1.122082\n"
234 "1.122082 -1.122082 1.122082\n"
235 "1.122082 -1.122082 -1.122082\n"
236 "-1.122082 1.122082 1.122082\n"
237 "-1.122082 1.122082 -1.122082\n"
238 "-1.122082 -1.122082 1.122082\n"
239 "-1.122082 -1.122082 -1.122082\n";
240
241 ASSERT_STREQ(result.c_str(), expected.c_str());
242}
243
244TEST_F(PLYExportTest, WriteVerticesBinary)
245{
246 std::string filePath = get_temp_ply_filename(temp_file_path);
247 PLYExportParams _params = {};
248 _params.ascii_format = false;
249 _params.export_normals = false;
251 STRNCPY(_params.filepath, filePath.c_str());
252
253 std::unique_ptr<PlyData> plyData = load_cube(_params);
254
255 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferBinary>(_params.filepath);
256
257 write_vertices(*buffer.get(), *plyData.get());
258
259 buffer->close_file();
260
261 std::vector<char> result = read_temp_file_in_vectorchar(filePath);
262
263 std::vector<char> expected({
264 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0,
265 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F,
266 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0,
267 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F,
268 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0,
269 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F,
270 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF,
271 });
272
273 ASSERT_EQ(result.size(), expected.size());
274
275 for (int i = 0; i < result.size(); i++) {
276 ASSERT_EQ(result[i], expected[i]);
277 }
278}
279
280TEST_F(PLYExportTest, WriteFacesAscii)
281{
282 std::string filePath = get_temp_ply_filename(temp_file_path);
283 PLYExportParams _params = {};
284 _params.ascii_format = true;
285 _params.export_normals = false;
287 STRNCPY(_params.filepath, filePath.c_str());
288
289 std::unique_ptr<PlyData> plyData = load_cube(_params);
290
291 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferAscii>(_params.filepath);
292
293 write_faces(*buffer.get(), *plyData.get());
294
295 buffer->close_file();
296
297 std::string result = read_temp_file_in_string(filePath);
298
299 std::string expected =
300 "4 0 2 6 4\n"
301 "4 3 7 6 2\n"
302 "4 7 5 4 6\n"
303 "4 5 7 3 1\n"
304 "4 1 3 2 0\n"
305 "4 5 1 0 4\n";
306
307 ASSERT_STREQ(result.c_str(), expected.c_str());
308}
309
310TEST_F(PLYExportTest, WriteFacesBinary)
311{
312 std::string filePath = get_temp_ply_filename(temp_file_path);
313 PLYExportParams _params = {};
314 _params.ascii_format = false;
315 _params.export_normals = false;
317 STRNCPY(_params.filepath, filePath.c_str());
318
319 std::unique_ptr<PlyData> plyData = load_cube(_params);
320
321 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferBinary>(_params.filepath);
322
323 write_faces(*buffer.get(), *plyData.get());
324
325 buffer->close_file();
326
327 std::vector<char> result = read_temp_file_in_vectorchar(filePath);
328
329 std::vector<char> expected({
330 0x04, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00,
331 0x00, 0x00, 0x04, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00,
332 0x02, 0x00, 0x00, 0x00, 0x04, 0x07, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x04, 0x00,
333 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00,
334 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00,
335 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x05, 0x00, 0x00, 0x00,
336 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
337 });
338
339 ASSERT_EQ(result.size(), expected.size());
340
341 for (int i = 0; i < result.size(); i++) {
342 ASSERT_EQ(result[i], expected[i]);
343 }
344}
345
346TEST_F(PLYExportTest, WriteVertexNormalsAscii)
347{
348 std::string filePath = get_temp_ply_filename(temp_file_path);
349 PLYExportParams _params = {};
350 _params.ascii_format = true;
351 _params.export_normals = true;
353 STRNCPY(_params.filepath, filePath.c_str());
354
355 std::unique_ptr<PlyData> plyData = load_cube(_params);
356
357 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferAscii>(_params.filepath);
358
359 write_vertices(*buffer.get(), *plyData.get());
360
361 buffer->close_file();
362
363 std::string result = read_temp_file_in_string(filePath);
364
365 std::string expected =
366 "1.122082 1.122082 1.122082 -0.5773503 -0.5773503 -0.5773503\n"
367 "1.122082 1.122082 -1.122082 -0.5773503 -0.5773503 0.5773503\n"
368 "1.122082 -1.122082 1.122082 -0.5773503 0.5773503 -0.5773503\n"
369 "1.122082 -1.122082 -1.122082 -0.5773503 0.5773503 0.5773503\n"
370 "-1.122082 1.122082 1.122082 0.5773503 -0.5773503 -0.5773503\n"
371 "-1.122082 1.122082 -1.122082 0.5773503 -0.5773503 0.5773503\n"
372 "-1.122082 -1.122082 1.122082 0.5773503 0.5773503 -0.5773503\n"
373 "-1.122082 -1.122082 -1.122082 0.5773503 0.5773503 0.5773503\n";
374
375 ASSERT_STREQ(result.c_str(), expected.c_str());
376}
377
378TEST_F(PLYExportTest, WriteVertexNormalsBinary)
379{
380 std::string filePath = get_temp_ply_filename(temp_file_path);
381 PLYExportParams _params = {};
382 _params.ascii_format = false;
383 _params.export_normals = true;
385 STRNCPY(_params.filepath, filePath.c_str());
386
387 std::unique_ptr<PlyData> plyData = load_cube(_params);
388
389 std::unique_ptr<FileBuffer> buffer = std::make_unique<FileBufferBinary>(_params.filepath);
390
391 write_vertices(*buffer.get(), *plyData.get());
392
393 buffer->close_file();
394
395 std::vector<char> result = read_temp_file_in_vectorchar(filePath);
396
397 std::vector<char> expected({
398 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0x3F, 0x3B, 0xCD, 0x13,
399 0xBF, 0x3B, 0xCD, 0x13, 0xBF, 0x3B, 0xCD, 0x13, 0xBF, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0,
400 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x3B, 0xCD, 0x13, 0xBF, 0x3B, 0xCD, 0x13, 0xBF, 0x3B,
401 0xCD, 0x13, 0x3F, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F,
402 0x3B, 0xCD, 0x13, 0xBF, 0x3B, 0xCD, 0x13, 0x3F, 0x3B, 0xCD, 0x13, 0xBF, 0x62, 0xA0, 0x8F,
403 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x3B, 0xCD, 0x13, 0xBF, 0x3B, 0xCD,
404 0x13, 0x3F, 0x3B, 0xCD, 0x13, 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F, 0x62,
405 0xA0, 0x8F, 0x3F, 0x3B, 0xCD, 0x13, 0x3F, 0x3B, 0xCD, 0x13, 0xBF, 0x3B, 0xCD, 0x13, 0xBF,
406 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x3B, 0xCD, 0x13,
407 0x3F, 0x3B, 0xCD, 0x13, 0xBF, 0x3B, 0xCD, 0x13, 0x3F, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0,
408 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0x3F, 0x3B, 0xCD, 0x13, 0x3F, 0x3B, 0xCD, 0x13, 0x3F, 0x3B,
409 0xCD, 0x13, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF, 0x62, 0xA0, 0x8F, 0xBF,
410 0x3B, 0xCD, 0x13, 0x3F, 0x3B, 0xCD, 0x13, 0x3F, 0x3B, 0xCD, 0x13, 0x3F,
411 });
412
413 ASSERT_EQ(result.size(), expected.size());
414
415 for (int i = 0; i < result.size(); i++) {
416 ASSERT_EQ(result[i], expected[i]);
417 }
418}
419
421 public:
423 {
425 if (!load_file_and_depsgraph(blendfile)) {
426 return data;
427 }
428
430
431 return data;
432 }
433};
434
436{
438 PlyData plyData = load_ply_data_from_blendfile("io_tests/blend_geometry/cube_all_data.blend",
439 params);
440 EXPECT_EQ(plyData.vertices.size(), 8);
441 EXPECT_EQ(plyData.uv_coordinates.size(), 0);
442}
443TEST_F(PLYExportPLYDataTest, CubeLoadPLYDataUV)
444{
446 params.export_uv = true;
447 PlyData plyData = load_ply_data_from_blendfile("io_tests/blend_geometry/cube_all_data.blend",
448 params);
449 EXPECT_EQ(plyData.vertices.size(), 8);
450 EXPECT_EQ(plyData.uv_coordinates.size(), 8);
451}
452TEST_F(PLYExportPLYDataTest, CubeLooseEdgesLoadPLYData)
453{
455 params.forward_axis = IO_AXIS_Y;
456 params.up_axis = IO_AXIS_Z;
457 params.global_scale = 1.0f;
458 PlyData plyData = load_ply_data_from_blendfile(
459 "io_tests/blend_geometry/cube_loose_edges_verts.blend", params);
460 float3 exp_vertices[] = {
461 {1, 1, 1},
462 {1, 1, -1},
463 {1, -1, 1},
464 {1, -1, -1},
465 {-1, 1, 1},
466 {-1, 1, -1},
467 {-1, -1, 1},
468 {-1, -1, -1},
469 };
470 std::pair<int, int> exp_edges[] = {{7, 6}, {6, 4}};
471 uint32_t exp_face_sizes[] = {4, 4};
472 uint32_t exp_faces[] = {5, 1, 3, 7, 5, 4, 0, 1};
473 EXPECT_EQ(plyData.vertices.size(), ARRAY_SIZE(exp_vertices));
474 EXPECT_EQ(plyData.uv_coordinates.size(), 0);
475 EXPECT_EQ(plyData.edges.size(), ARRAY_SIZE(exp_edges));
476 EXPECT_EQ(plyData.face_sizes.size(), ARRAY_SIZE(exp_face_sizes));
477 EXPECT_EQ(plyData.face_vertices.size(), ARRAY_SIZE(exp_faces));
478 EXPECT_EQ_ARRAY(exp_vertices, plyData.vertices.data(), ARRAY_SIZE(exp_vertices));
479 EXPECT_EQ_ARRAY(exp_edges, plyData.edges.data(), ARRAY_SIZE(exp_edges));
480 EXPECT_EQ_ARRAY(exp_face_sizes, plyData.face_sizes.data(), ARRAY_SIZE(exp_face_sizes));
481 EXPECT_EQ_ARRAY(exp_faces, plyData.face_vertices.data(), ARRAY_SIZE(exp_faces));
482}
483TEST_F(PLYExportPLYDataTest, CubeLooseEdgesLoadPLYDataUV)
484{
486 params.forward_axis = IO_AXIS_Y;
487 params.up_axis = IO_AXIS_Z;
488 params.global_scale = 1.0f;
489 params.export_uv = true;
490 PlyData plyData = load_ply_data_from_blendfile(
491 "io_tests/blend_geometry/cube_loose_edges_verts.blend", params);
492 float3 exp_vertices[] = {
493 {-1, 1, -1},
494 {1, 1, -1},
495 {1, -1, -1},
496 {-1, -1, -1},
497 {-1, 1, -1},
498 {-1, 1, 1},
499 {1, 1, 1},
500 {1, -1, 1},
501 {-1, -1, 1},
502 };
503 float2 exp_uv[] = {
504 {0.125f, 0.5f},
505 {0.375f, 0.5f},
506 {0.375f, 0.75f},
507 {0.125f, 0.75f},
508 {0.375f, 0.25f},
509 {0.625f, 0.25f},
510 {0.625f, 0.5f},
511 {0, 0},
512 {0, 0},
513 };
514 std::pair<int, int> exp_edges[] = {{3, 8}, {8, 5}};
515 uint32_t exp_face_sizes[] = {4, 4};
516 uint32_t exp_faces[] = {0, 1, 2, 3, 4, 5, 6, 1};
517 EXPECT_EQ(plyData.vertices.size(), 9);
518 EXPECT_EQ(plyData.uv_coordinates.size(), 9);
519 EXPECT_EQ(plyData.edges.size(), ARRAY_SIZE(exp_edges));
520 EXPECT_EQ(plyData.face_sizes.size(), ARRAY_SIZE(exp_face_sizes));
521 EXPECT_EQ(plyData.face_vertices.size(), ARRAY_SIZE(exp_faces));
522 EXPECT_EQ_ARRAY(exp_vertices, plyData.vertices.data(), ARRAY_SIZE(exp_vertices));
523 EXPECT_EQ_ARRAY(exp_uv, plyData.uv_coordinates.data(), ARRAY_SIZE(exp_uv));
524 EXPECT_EQ_ARRAY(exp_edges, plyData.edges.data(), ARRAY_SIZE(exp_edges));
525 EXPECT_EQ_ARRAY(exp_face_sizes, plyData.face_sizes.data(), ARRAY_SIZE(exp_face_sizes));
526 EXPECT_EQ_ARRAY(exp_faces, plyData.face_vertices.data(), ARRAY_SIZE(exp_faces));
527}
528
529TEST_F(PLYExportPLYDataTest, CubesVertexAttrs)
530{
532 params.export_uv = true;
533 params.export_attributes = true;
534 PlyData plyData = load_ply_data_from_blendfile(
535 "io_tests/blend_geometry/cubes_vertex_attrs.blend", params);
536 EXPECT_EQ(plyData.vertices.size(), 28);
537 EXPECT_EQ(plyData.vertex_custom_attr.size(), 11); /* Float 1 + Color 4 + ByteColor 4 + Int2D 2 */
538 EXPECT_EQ(plyData.vertex_custom_attr[0].data.size(), 28);
539}
540
541TEST_F(PLYExportPLYDataTest, SuzanneLoadPLYDataUV)
542{
544 params.export_uv = true;
545 PlyData plyData = load_ply_data_from_blendfile("io_tests/blend_geometry/suzanne_all_data.blend",
546 params);
547 EXPECT_EQ(plyData.uv_coordinates.size(), 542);
548}
549
550} // namespace blender::io::ply
void BKE_tempdir_init(const char *userdir)
Definition appdir.cc:1190
void BKE_tempdir_session_purge()
Definition appdir.cc:1216
const char * BKE_blender_version_string(void)
Definition blender.cc:139
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
File and directory operations.
void * BLI_file_read_text_as_mem(const char *filepath, size_t pad_bytes, size_t *r_size)
Definition storage.cc:502
#define STRNCPY(dst, src)
Definition BLI_string.h:593
#define ARRAY_SIZE(arr)
eEvaluationMode
@ DAG_EVAL_VIEWPORT
@ IO_AXIS_Y
@ IO_AXIS_Z
@ PLY_VERTEX_COLOR_NONE
Definition IO_ply.hh:22
virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode)
bool blendfile_load(const char *filepath)
int64_t size() const
PlyData load_ply_data_from_blendfile(const std::string &blendfile, PLYExportParams &params)
bool load_file_and_depsgraph(const std::string &filepath, const eEvaluationMode eval_mode=DAG_EVAL_VIEWPORT)
std::string get_temp_ply_filename(const std::string &filename)
uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]
void MEM_freeN(void *vmemh)
Definition mallocn.cc:105
static std::string read_temp_file_in_string(const std::string &file_path)
const char *const temp_file_path
static std::unique_ptr< PlyData > load_cube(PLYExportParams &params)
void write_vertices(FileBuffer &buffer, const PlyData &ply_data)
void load_plydata(PlyData &plyData, Depsgraph *depsgraph, const PLYExportParams &export_params)
static std::vector< char > read_temp_file_in_vectorchar(const std::string &file_path)
static char read(std::ifstream &file)
TEST_F(PLYExportTest, WriteHeaderAscii)
void write_faces(FileBuffer &buffer, const PlyData &ply_data)
void write_header(FileBuffer &buffer, const PlyData &ply_data, const PLYExportParams &export_params)
unsigned int uint32_t
Definition stdint.h:80
unsigned __int64 uint64_t
Definition stdint.h:90
bool ascii_format
Definition IO_ply.hh:37
ePLYVertexColorMode vertex_colors
Definition IO_ply.hh:49
char filepath[FILE_MAX]
Definition IO_ply.hh:29
bool export_normals
Definition IO_ply.hh:48
Vector< float3 > vertices
Definition ply_data.hh:29
Vector< uint32_t > face_vertices
Definition ply_data.hh:34
Vector< std::pair< int, int > > edges
Definition ply_data.hh:33
Vector< PlyCustomAttribute > vertex_custom_attr
Definition ply_data.hh:32
Vector< float2 > uv_coordinates
Definition ply_data.hh:36
Vector< uint32_t > face_sizes
Definition ply_data.hh:35
void * BKE_tempdir_session
Definition stubs.c:38
#define SEP_STR
Definition unit.cc:39