Skip to content

Commit 0ed16a7

Browse files
Krandeclaude
andcommitted
fix(cad): PlateCurved bbox + Surface render under adacpp (full parity)
- _calc_bbox_of_plate_curved: a PlateCurved wraps a face produced externally by OCC (loft tool / gxml AdvancedFace import). Under adacpp that raw OCC face isn't a native handle — adopt it across the kernel boundary (from_topods_pointer, same OCCT version) before querying backend.bbox. - test_surface_renders_as_face: introspect the result via active_backend().faces() instead of a raw OCC TopExp_Explorer, so the assertion holds under either backend. Closes the last geometry-parity gap: every core geometry test passing under OccBackend now also passes under adacpp (663 vs OCC 655; remaining adacpp deltas are a hardcoded OCC-mesher vertex-count fingerprint and a dev-link kaleido PATH artifact — neither a geometry-parity issue). OccBackend unchanged (655). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 364f770 commit 0ed16a7

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

src/ada/api/bounding_box.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,21 @@ def _calc_bbox_of_plate_curved(self) -> tuple[tuple, tuple]:
100100
"""
101101
from ada.cad import active_backend
102102

103+
backend = active_backend()
104+
103105
# Use the bare face (no extrusion) so the bbox isn't padded by
104106
# the prism thickness on whichever axis the normal points.
105107
# solid_occ returns the face for the raw-OCC path and the
106108
# AdvancedFace→OCC for the Geometry-backed path. optimal=False +
107109
# use_mesh reproduces the prior brepbndlib.Add(face, bbox) exactly.
108-
xmin, ymin, zmin, xmax, ymax, zmax = active_backend().bbox(
109-
self.parent.solid_occ(), optimal=False, use_mesh=True
110-
)
110+
shape = self.parent.solid_occ()
111+
# PlateCurved wraps a face produced externally by OCC (loft tool /
112+
# gxml AdvancedFace import). Under a non-OCC backend that raw OCC face
113+
# isn't a native handle yet — adopt it across the kernel boundary
114+
# (same OCCT version → safe) before querying the backend.
115+
if not backend.is_handle(shape):
116+
shape = backend.adopt_occ_shape(shape)
117+
xmin, ymin, zmin, xmax, ymax, zmax = backend.bbox(shape, optimal=False, use_mesh=True)
111118
return (xmin, ymin, zmin), (xmax, ymax, zmax)
112119

113120
def _calc_bbox_of_plate(self) -> tuple[tuple, tuple]:

tests/core/api/plates/test_plate_curved.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,11 @@ def test_surface_renders_as_face_not_extruded_prism():
189189
occ_shape = surf.solid_occ()
190190
assert occ_shape is not None
191191
# The shape should be a face (or compound with a face), not a
192-
# zero-volume prism. We just check it's not the placeholder None.
193-
from OCC.Core.TopAbs import TopAbs_FACE
194-
from OCC.Core.TopExp import TopExp_Explorer
195-
assert TopExp_Explorer(occ_shape, TopAbs_FACE).More()
192+
# zero-volume prism. Introspect via the active CAD backend so this
193+
# holds under either backend (pythonocc or adacpp).
194+
from ada.cad import active_backend
195+
196+
assert len(active_backend().faces(occ_shape)) >= 1
196197

197198

198199
def test_surface_curved_inherits_plate_curved_handling():

0 commit comments

Comments
 (0)