merge: resolve main integration conflicts

This commit is contained in:
2026-09-09 10:39:34 +08:00
18 changed files with 839 additions and 36 deletions
@@ -25,10 +25,13 @@ from OCP.TopTools import TopTools_ListOfShape
from OCP.TopoDS import TopoDS
from OCP.gp import gp_Ax1, gp_Dir, gp_Pnt, gp_Trsf, gp_Vec
from .parametric_bend import build_bend_solid
from .parametric_gears import build_gear_solid, build_rack_solid
from .parametric_thread import build_thread_solid
from .runtime_types import (
AxisSpec, BendSpec, HoleSpec, PlaneSpec, ThreadSpec, TopologyDelta,
TopologyDeltaRelation, TopologyRecord, Vector3, canonical_plane_signature,
AxisSpec, BendSpec, GearSpec, HoleSpec, PlaneSpec, RackSpec, ThreadSpec,
TopologyDelta, TopologyDeltaRelation, TopologyRecord, Vector3,
canonical_plane_signature,
)
@@ -1354,6 +1357,47 @@ class Build123dGeometryAdapter:
)
return solid.moved(Location(plane))
@staticmethod
def gear_solid(spec: GearSpec) -> Any:
"""Build an involute gear placed on ``spec.axis``.
The parametric generator constructs the gear in a local +Z frame
spanning ``z in [0, width_mm]``. This gate rotates that frame so the
gear axis lands on ``spec.axis.direction`` with ``spec.axis.origin_mm``
at the centre of the ``z = 0`` end face (same placement contract as
``thread_solid``).
"""
solid = build_gear_solid(spec)
direction = _vector(spec.axis.direction)
if abs(direction.X) <= 1e-9 and abs(direction.Y) <= 1e-9:
# 轴沿 ±Z:起始相位绕轴无意义,X 方向任意。
frame_x = Vector(1.0, 0.0, 0.0)
else:
frame_x = Vector(0.0, 0.0, 1.0).cross(direction).normalized()
plane = Plane(origin=_vector(spec.axis.origin_mm), x_dir=frame_x, z_dir=direction)
return solid.moved(Location(plane))
@staticmethod
def rack_solid(spec: RackSpec) -> Any:
"""Build a rack placed on ``spec.axis``.
The parametric generator constructs the rack locally with the length
along +X, thickness along +Y and the teeth pointing along +Z (the
root/backing plane spans +X/+Y at ``z = 0``). This gate maps local
+Z onto ``spec.axis.direction`` (the direction the teeth point) with
``spec.axis.origin_mm`` at the length-start / thickness-start corner;
the length direction (+X) is a deterministic orthogonal of the tooth
direction.
"""
solid = build_rack_solid(spec)
direction = _vector(spec.axis.direction)
if abs(direction.Z) <= 0.9:
frame_x = Vector(0.0, 0.0, 1.0).cross(direction).normalized()
else:
frame_x = Vector(1.0, 0.0, 0.0)
plane = Plane(origin=_vector(spec.axis.origin_mm), x_dir=frame_x, z_dir=direction)
return solid.moved(Location(plane))
@staticmethod
def fillet(body: Any, radius_mm: float, edges: Iterable[Edge]) -> Any:
# 对指定边以给定半径做圆角。