Skip to content
This repository has been archived by the owner on Feb 9, 2021. It is now read-only.

Commit

Permalink
Added tests and fixed bugs related to some of the more esoteric Shape…
Browse files Browse the repository at this point in the history
… functions.
  • Loading branch information
jmwright committed Mar 1, 2018
1 parent ec24428 commit f27884b
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cadquery/freecad_impl/shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ def makeRuledSurface(cls, edgeOrWire1, edgeOrWire2, dist=None):
Create a ruled surface out of two edges or wires. If wires are used then
these must have the same
"""
return Shape.cast(FreeCADPart.makeRuledSurface(edgeOrWire1.obj, edgeOrWire2.obj, dist))
return Shape.cast(FreeCADPart.makeRuledSurface(edgeOrWire1.wrapped, edgeOrWire2.wrapped))

def cut(self, faceToCut):
"Remove a face from another one"
Expand Down
33 changes: 33 additions & 0 deletions tests/TestCadObjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,39 @@ def testTranslate(self):

self.assertTupleAlmostEquals((1.0, 2.0, 4.0), e2.Center().toTuple(), 3)

def testScale(self):
"""
Tests scaling a shape and whether the dimensions are correct afterwards
"""
e = Shape.cast(Part.makeCircle(2.0, FreeCAD.Base.Vector(1, 2, 3)))
e2 = e.scale(0.5)

self.assertAlmostEquals(2.0, e2.BoundingBox().xlen)
self.assertAlmostEquals(2.0, e2.BoundingBox().ylen)

def testCopy(self):
"""
Tests making a copy of a shape object and whether the new one has the
same properties as the original.
"""
e = Shape.cast(Part.makeCircle(2.0, FreeCAD.Base.Vector(1, 2, 3)))
e2 = e.copy()

self.assertEquals(e.BoundingBox().xlen, e2.BoundingBox().xlen)
self.assertEquals(e.BoundingBox().ylen, e2.BoundingBox().ylen)

def testRuledSurface(self):
"""
Tests making a ruled surface from two edges/wires.
"""
edge1 = Shape(Part.makeLine((0, 0, 5), (0, 10, 5)))
edge2 = Shape(Part.makeLine((5, 5, 0), (10, 10, 0)))

surf1 = Face.makeRuledSurface(edge1, edge2)

self.assertEquals(surf1.ShapeType(), 'Face')
self.assertTrue(surf1.isValid())

def testVertices(self):
e = Shape.cast(Part.makeLine((0, 0, 0), (1, 1, 0)))
self.assertEqual(2, len(e.Vertices()))
Expand Down

0 comments on commit f27884b

Please sign in to comment.