Skip to content

Commit cbdf987

Browse files
author
kimstik
committed
Keep the march order when assembling the hull wire
Fixes #1891.
1 parent fa1b899 commit cbdf987

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

‎cadquery/hull.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from math import pi, sin, cos, atan2, sqrt, inf, degrees
33
from numpy import lexsort, argmin
44

5-
from .occ_impl.shapes import Edge, Wire
5+
from .occ_impl.shapes import Edge, Wire, wire
66
from .occ_impl.geom import Vector
77

88

@@ -374,7 +374,7 @@ def finalize_hull(hull: Hull) -> Wire:
374374
Edge.makeCircle(el_n.r, Vector(el_n.c.x, el_n.c.y), angle1=a1, angle2=a2)
375375
)
376376

377-
return Wire.assembleEdges(rv)
377+
return wire(*rv)
378378

379379

380380
def find_hull(edges: Iterable[Edge]) -> Wire:

‎tests/test_hull.py‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import cadquery as cq
77
from cadquery import hull
8+
from cadquery.func import face
89

910

1011
def area(edges):
@@ -182,6 +183,17 @@ def shape(dx, dy):
182183
assert area(shape(0, 40)) == pytest.approx(area(shape(40, 0)))
183184

184185

186+
def test_hull_face_normal():
187+
# #1891: func.face reads the edges in storage order - keep the march order
188+
edges = [
189+
cq.Edge.makeLine(cq.Vector(0, 0), cq.Vector(4, 0)),
190+
cq.Edge.makeLine(cq.Vector(4, 0), cq.Vector(0, 3)),
191+
cq.Edge.makeLine(cq.Vector(0, 3), cq.Vector(0, 0)),
192+
]
193+
194+
assert face(hull.find_hull(edges)).normalAt().z == pytest.approx(1)
195+
196+
185197
# temporary: two plain circles stall the march until the arc rework (3/3)
186198
@pytest.mark.xfail(strict=True, raises=ValueError, reason="fixed by the arc rework")
187199
def test_two_circles():

0 commit comments

Comments
 (0)