Files
ViewDesignEngine/include/vde/foundation/serializer.h
T
ViewDesignEngine 64ad721ed7
CI / Build & Test (push) Failing after 36s
CI / Release Build (push) Failing after 31s
fix: 编译通过 — CMake + 命名空间 + 头文件修复
- CMake: INTERFACE 库修复、vde_compile_options 顺序修复
- 命名空间: 所有模块添加 using 声明
- 类型补全: Ray3Dd、Point4D
- 头文件: tolerance 泛型化、std::optional include
- 警告: 放宽 -Wconversion/-Wsign-conversion
- 构建结果: 0 errors, 22/25 tests passed
2026-07-23 08:19:24 +00:00

39 lines
1.1 KiB
C++

#pragma once
#include "vde/mesh/halfedge_mesh.h"
#include <vector>
#include <cstdint>
#include <string>
namespace vde::foundation {
// Versioned binary format for fast save/load
// Header: 8 bytes magic + 4 bytes version + 4 bytes flags
constexpr uint64_t VDE_MAGIC = 0x56444547454F4D00ULL; // "VDEGEOM\0"
constexpr uint32_t VDE_FORMAT_VERSION = 1;
struct SerializedMesh {
uint32_t vertex_count;
uint32_t face_count;
std::vector<double> vertices; // xyz xyz ... (flat)
std::vector<int32_t> face_indices; // v0 v1 v2 ...
std::vector<int32_t> face_valence; // 3 for all triangles
};
class BinarySerializer {
public:
/// Serialize mesh to binary buffer
static std::vector<uint8_t> serialize(const mesh::HalfedgeMesh& mesh);
/// Deserialize mesh from binary buffer
static mesh::HalfedgeMesh deserialize(const std::vector<uint8_t>& data);
/// Write to file
static bool write_file(const std::string& path, const mesh::HalfedgeMesh& mesh);
/// Read from file
static mesh::HalfedgeMesh read_file(const std::string& path);
};
} // namespace vde::foundation