#pragma once /** * @file geometry_host_services.h * @brief 宿主侧几何服务表构建器(P1.x 起编译进内核 vde_brep;内核测试/应用/kernel-only 使用) * * 返回的 VdePluginHost 表指向本进程内的唯一内核实例(BrepModel/测量/三角化/序列化), * 插件只通过该表访问几何,因此不存在"插件另带一份内核静态库"的句柄错配问题。 * * 服务语义补充(P0-4): * - 内存:\c alloc/\c realloc/\c free 对应 C 运行库 malloc/realloc/free; * 句柄由 \c body_create_* 用 operator new 创建,只能由 \c body_destroy 销毁; * - 诊断:\c set_error 写入**线程本地**错误串(宿主侧可用 * \c geometry_host_last_error() 读取,便于测试/宿主判断失败原因); * - \c body_tessellate:\c deflection 为相对包围盒对角线的比例(≤0 时取 0.01); * 输出的 \c normals 为**每顶点法向**(长度 3×num_vertices,与 positions 对齐; * 无三角形时为 null); * - \c body_serialize:输出 VDE-TEXT 1.0(UTF-8,末尾 null 终止但 \c VdeBuffer.size * 不含终止符);\c body_from_serialized 自动识别 VDE-TEXT / VDE 二进制; * - \c body_from_mesh(ABI minor 1 / P1):三角网格 positions(3×N)+indices(3×M) * → 实体;内部用 HalfedgeMesh::build_from_triangles + brep::mesh_to_brep_model, * 与内置 STL/OBJ/PLY 导入同源转换(同输入得到同面数/同体积的 B-Rep)。 */ #include "vde/plugin/vde_plugin_api.h" namespace vde::plugin { /// 构建几何宿主服务表(abi/version/allocator/log + P0 几何服务子集) VdePluginHost make_geometry_host_services(); /// 释放服务表内部持有的资源(当前为无操作;保留接口用于 P1 线程本地错误缓存) void release_geometry_host_services(VdePluginHost* host); /// 读取当前线程最近一次 host->set_error 记录的文本(宿主侧诊断;空 = 无错误) [[nodiscard]] const char* geometry_host_last_error(); /// 清空当前线程错误记录(宿主在调用插件前清空,便于判断本次调用是否报错) void clear_geometry_host_last_error(); } // namespace vde::plugin