Skip to content

Commit e82c7c3

Browse files
Implement Edge.close
1 parent 68dba0a commit e82c7c3

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

cadquery/occ_impl/shapes.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,6 +1386,20 @@ def _geomAdaptorH(self) -> Tuple[BRepAdaptor_Curve, BRepAdaptor_HCurve]:
13861386

13871387
return curve, BRepAdaptor_HCurve(curve)
13881388

1389+
def close(self) -> Union["Edge", "Wire"]:
1390+
"""
1391+
Close an Edge
1392+
"""
1393+
rv: Union[Wire, Edge]
1394+
1395+
if not self.IsClosed():
1396+
e = Edge.makeLine(self.endPoint(), self.startPoint())
1397+
rv = Wire.assembleEdges((self, e))
1398+
else:
1399+
rv = self
1400+
1401+
return rv
1402+
13891403
@classmethod
13901404
def makeCircle(
13911405
cls: Type["Edge"],

tests/test_cadquery.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4410,6 +4410,14 @@ def testSplineApprox(self):
44104410
with raises(ValueError):
44114411
e4 = Edge.makeSplineApprox(pts, 1e-6, maxDeg=3, smoothing=(1, 1, 1.0))
44124412

4413+
pts_closed = pts + [pts[0]]
4414+
4415+
e3 = Edge.makeSplineApprox(pts_closed)
4416+
w = Edge.makeSplineApprox(pts).close()
4417+
4418+
self.assertTrue(e3.IsClosed())
4419+
self.assertTrue(w.IsClosed())
4420+
44134421
N = 40
44144422
T = 20
44154423
A = 5

0 commit comments

Comments
 (0)