Files
ocp/CMakeLists.txt
stroblme 2c2c4e4712 10C Inc 1: core modeling
Binds the modeling core the app builds every feature out of — 93 of its 138
symbols now resolve, up from 34. New modules: GeomAbs, Geom2d, Geom,
TCollection, TColgp, TColStd, GProp, BRepGProp, Bnd, BRepBndLib, Adaptor3d,
BRepAdaptor, GeomLProp, GeomAPI, BRepBuilderAPI, BOPAlgo, BRepAlgoAPI,
BRepPrimAPI, GC, BRepMesh; gp and BRep_Tool completed.

Three structural decisions:

- BRepBuilderAPI_MakeShape carries Build/Shape/Generated/Modified/IsDeleted for
  every maker in the binding, so the booleans, the primitives and (later) the
  fillet builders all answer the app's duck-typed provenance layer through
  ordinary virtual dispatch. History lists come back copied, so they outlive
  the builder.
- The executing two-argument BRepAlgoAPI constructors stay unbound; operands go
  in through SetArguments/SetTools. Section keeps Init1/Init2, which are plain
  setters. BOPAlgo moved up from Inc 2 — SetGlue needs its enum.
- Adaptor3d is registered although the app never imports it: every method it
  calls on BRepAdaptor_Curve/Surface is a virtual declared there, so binding
  them once on the bases leaves mod_BRepAdaptor.cpp with just constructors.

Gate: tests/test_inc1_modeling.py against reference values gen_fixtures.py now
records from the stock wheel — measurements, per-face area/centroid in map
order, mesh counts, and the boolean history map compared exactly, since that is
the substrate the app's topological naming is built on.

tools/sigdiff.py compares our bound surface against stock's, because a wrong
nb::init<> is silent: MakePrism's five-argument form bound OCCT's semi-infinite
gp_Dir overload (gp_Dir converts from gp_Vec), producing a valid solid of the
wrong shape with the flags shifted along. The fixture digest caught it; sigdiff
finds the class of bug directly, and now reports only one deliberate deviation.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DfriM8XUkn7uYf5Dwe2xo6
2026-08-10 19:52:58 +02:00

70 lines
2.1 KiB
CMake

cmake_minimum_required(VERSION 3.20)
project(n3xd_ocp LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Match the kernel's flags: -O2, no fast-math, no -march=native. OCCT's
# version is a determinism input for assay's committed goldens, so the binding
# has no business introducing a different FP contract than the kernel it wraps.
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG")
find_package(Python 3.12 REQUIRED
COMPONENTS Interpreter Development.Module Development.SABIModule)
find_package(nanobind CONFIG REQUIRED)
find_package(OpenCASCADE REQUIRED)
# The version scheme is enforced, not merely conventional: a wheel labelled
# 7.9.3.N must actually wrap OCCT 7.9.3.
set(_occt_ver "${OpenCASCADE_MAJOR_VERSION}.${OpenCASCADE_MINOR_VERSION}.${OpenCASCADE_MAINTENANCE_VERSION}")
if(DEFINED SKBUILD_PROJECT_VERSION)
if(NOT SKBUILD_PROJECT_VERSION MATCHES "^${_occt_ver}\\.")
message(FATAL_ERROR
"Version '${SKBUILD_PROJECT_VERSION}' does not match the OCCT found "
"(${_occt_ver}). The scheme is <occt-version>.N — see pyproject.toml.")
endif()
endif()
message(STATUS "Building n3xd-ocp against OCCT ${_occt_ver}")
file(GLOB OCP_MODULE_SOURCES CONFIGURE_DEPENDS "src/modules/*.cpp")
file(GLOB OCP_EXT_SOURCES CONFIGURE_DEPENDS "src/ext/*.cpp")
nanobind_add_module(_OCP
STABLE_ABI
NB_STATIC
src/core.cpp
src/common/occt_module.cpp
src/common/occt_exceptions.cpp
${OCP_MODULE_SOURCES}
${OCP_EXT_SOURCES}
)
target_include_directories(_OCP PRIVATE ${OpenCASCADE_INCLUDE_DIR})
# Only the toolkits the bound surface actually reaches. Grows with each
# coverage increment; auditwheel bundles whatever the linker records.
target_link_libraries(_OCP PRIVATE
TKernel
TKMath
TKG2d
TKG3d
TKGeomBase
TKBRep
TKTopAlgo
# Inc 1
TKGeomAlgo # GeomAPI, GCPnts
TKPrim # BRepPrimAPI
TKBO # BRepAlgoAPI, BOPAlgo
TKMesh # BRepMesh
)
target_compile_definitions(_OCP PRIVATE
N3XD_OCP_VERSION="${SKBUILD_PROJECT_VERSION}"
)
install(TARGETS _OCP LIBRARY DESTINATION OCP)