feat: Python 绑定 — pybind11 核心/曲线/网格模块
- 使用 pybind11 v2.11.1 (FetchContent) 构建 _vde 原生模块 - 模块化结构: bind_core.cpp / bind_curves.cpp / bind_mesh.cpp - 暴露核心类型: Point2D, Point3D, Vector3D, AABB3D, Polygon2D - 暴露曲线: BezierCurve, BSplineCurve, NurbsCurve - 暴露网格: delaunay_2d/3d, DelaunayResult, HalfedgeMesh - 变换函数: translate, rotate, scale 等 - Python 包 vde/ 含 __init__.py 及子模块封装 - setup.py 支持 pip install -e . 可编辑安装 - VDE_BUILD_PYTHON CMake 选项 (默认 OFF),通过 -DVDE_BUILD_PYTHON=ON 启用
This commit is contained in:
+25
-10
@@ -1,12 +1,27 @@
|
||||
option(VDE_BUILD_PYTHON "Build Python bindings" OFF)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
if(VDE_BUILD_PYTHON)
|
||||
find_package(pybind11 REQUIRED)
|
||||
message(STATUS "Building Python bindings for ViewDesignEngine")
|
||||
# ── Fetch pybind11 ──────────────────────────────────
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(
|
||||
pybind11
|
||||
URL https://github.com/pybind/pybind11/archive/refs/tags/v2.11.1.tar.gz
|
||||
URL_HASH SHA256=d475978da0cdc2d43dd73e309f0f53263607dd08f31d5facb02c8110e4a1ebd8
|
||||
)
|
||||
FetchContent_MakeAvailable(pybind11)
|
||||
|
||||
pybind11_add_module(_vde
|
||||
bindings.cpp
|
||||
)
|
||||
target_link_libraries(_vde PRIVATE vde)
|
||||
target_compile_definitions(_vde PRIVATE VDE_BUILDING_PYTHON)
|
||||
endif()
|
||||
# ── _vde native module ─────────────────────────────
|
||||
pybind11_add_module(_vde
|
||||
src/bind_module.cpp
|
||||
src/bind_core.cpp
|
||||
src/bind_curves.cpp
|
||||
src/bind_mesh.cpp
|
||||
)
|
||||
|
||||
target_include_directories(_vde
|
||||
PRIVATE ${CMAKE_SOURCE_DIR}/include
|
||||
)
|
||||
|
||||
target_link_libraries(_vde PRIVATE vde)
|
||||
|
||||
# Python 3.8+ compatibility
|
||||
target_compile_features(_vde PRIVATE cxx_std_17)
|
||||
|
||||
Reference in New Issue
Block a user