cf13496ff6
新增功能: - core: 2D Voronoi 图(Delaunay 对偶图) - mesh: Marching Cubes(完整256项三角表 + SDF 辅助函数) - mesh: 离散曲率(Gaussian/Mean, Cotan 公式) - foundation: 二进制序列化(版本化格式,Little-Endian) - python: pybind11 绑定(30+ API 暴露) - marching_cubes.h: SDF 基本体(球/盒)+ 光滑布尔
39 lines
1.1 KiB
C++
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 HalfedgeMesh& mesh);
|
|
|
|
/// Deserialize mesh from binary buffer
|
|
static HalfedgeMesh deserialize(const std::vector<uint8_t>& data);
|
|
|
|
/// Write to file
|
|
static bool write_file(const std::string& path, const HalfedgeMesh& mesh);
|
|
|
|
/// Read from file
|
|
static HalfedgeMesh read_file(const std::string& path);
|
|
};
|
|
|
|
} // namespace vde::foundation
|