sample_mesher(P4 / ABI 1.4 示例)
最小 Mesher 扩展点示例插件:纯 C ABI、不链接 VDE 内核,默认不加入插件聚合构建。
构建
cmake -S plugins/sample_mesher -B build/sample_mesher -G Ninja `
-DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER=<g++> -DPROJECT_SOURCE_DIR=<repo>
cmake --build build/sample_mesher
或作为其它工程子目录:
add_subdirectory(plugins/sample_mesher)
产物:<build>/plugins/sample_mesher/vde_sample_mesher.dll + vde-plugin.json
(manifest:id=com.vde.sample.mesher、kind=mesher、abi=1.4、capability=mesher:tet)。
接口
实现 VdeMesherPlugin:
mesher_id = "mesher.mock.tet4";mesh(host, model_data, model_size, options, result):本 mock 忽略真实几何, 输出固定单位立方体 tet4 网格(8 节点 / 5 四面体)JSON,并回显model_bytes/element_size/tolerance;result.mesh_json由host->alloc分配;vde_plugin_query/vde_plugin_init导出,注册VdePluginRegistration.mesher。
调用(宿主)
pm.load("com.vde.sample.mesher");
std::string mesh_json;
pm.invoke_mesher("mesher.mock.tet4", model_data, model_size,
"{\"element_size\":2.0}", &mesh_json);
限制
mock 实现(固定模板,不读取模型),仅用于 ABI/契约/调用路径验证;
生产 mesher 应使用 host->body_from_serialized + host->body_* 查询几何并实现真实网格算法。