Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions cadquery/occ_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
ShapeAnalysis_Edge,
ShapeAnalysis_Wire,
ShapeAnalysis_Surface,
ShapeAnalysis,
)
from OCP.TopTools import TopTools_HSequenceOfShape

Expand Down Expand Up @@ -2102,10 +2103,10 @@ def startPoint(self: Mixin1DProtocol) -> Vector:
Note, circles may have the start and end points the same
"""

curve = self._geomAdaptor()
umin = curve.FirstParameter()
v1, _ = TopoDS_Vertex(), TopoDS_Vertex()
ShapeAnalysis.FindBounds_s(self.wrapped, v1, _)

return Vector(curve.Value(umin))
return Vertex(v1).Center()

def endPoint(self: Mixin1DProtocol) -> Vector:
"""
Expand All @@ -2115,10 +2116,10 @@ def endPoint(self: Mixin1DProtocol) -> Vector:
Note, circles may have the start and end points the same
"""

curve = self._geomAdaptor()
umax = curve.LastParameter()
_, v2 = TopoDS_Vertex(), TopoDS_Vertex()
ShapeAnalysis.FindBounds_s(self.wrapped, _, v2)

return Vector(curve.Value(umax))
return Vertex(v2).Center()

def _approxCurve(self: Mixin1DProtocol) -> Geom_BSplineCurve:
"""
Expand Down
10 changes: 5 additions & 5 deletions tests/test_cadquery.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,12 +313,12 @@ def testRotate(self):
startPoint = box.faces("<Y").edges("<X").first().val().startPoint().toTuple()
endPoint = box.faces("<Y").edges("<X").first().val().endPoint().toTuple()

self.assertEqual(-0.5, startPoint[0])
self.assertEqual(-0.5, startPoint[1])
self.assertEqual(-2.5, startPoint[2])
self.assertEqual(-0.5, endPoint[0])
self.assertEqual(-0.5, endPoint[1])
self.assertEqual(2.5, endPoint[2])
self.assertEqual(-2.5, endPoint[2])
self.assertEqual(-0.5, startPoint[0])
self.assertEqual(-0.5, startPoint[1])
self.assertEqual(2.5, startPoint[2])

def testRotateAboutCenter(self):
r = Workplane().box(1, 1, 1).rotateAboutCenter((1, 0, 0), 20)
Expand Down Expand Up @@ -4196,7 +4196,7 @@ def testSlot2D(self):

# Test to see if slot is rotated correctly
result = Workplane("XY").slot2D(4, 1, 45).extrude(1)
point = result.faces(">Z").edges(">X").first().val().startPoint().toTuple()
point = result.faces(">Z").edges(">X").first().val().endPoint().toTuple()
self.assertTupleAlmostEquals(
point, (0.707106781, 1.414213562, 1.0), decimal_places
)
Expand Down
9 changes: 9 additions & 0 deletions tests/test_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -475,3 +475,12 @@ def test_set_ops(simple_box):
assert (simple_box.faces(">Z") | simple_box.faces("<Z")).size() == 2
assert (simple_box.faces(">Z") & simple_box.faces("<Z")).size() == 0
assert (simple_box.faces("|Z") % simple_box.faces("<Z")).size() == 1


def test_start_end():

seg = segment((0, 0), (1, 0))
seg_r = seg.reverse()

assert (seg.startPoint() - seg_r.endPoint()).Length == approx(0)
assert (seg.endPoint() - seg_r.startPoint()).Length == approx(0)