Change to ProjectedOrigin (#532)

* Change to ProjectedOrigin

* Fix most tests

* Fix remaining tests

* Fix example building

* Update selector docs

* Fix the bottle+formatting changes

* Renamed centered to xycentered

* Ignore utils for coverage calculation
This commit is contained in:
Adam Urbańczyk
2020-12-08 18:32:57 +01:00
committed by GitHub
parent 52ae38596f
commit a03648c842
7 changed files with 48 additions and 30 deletions

View File

@ -25,12 +25,15 @@ def makeUnitSquareWire():
)
def makeUnitCube():
return makeCube(1.0)
def makeUnitCube(centered=True):
return makeCube(1.0, centered)
def makeCube(size):
return Solid.makeBox(size, size, size)
def makeCube(size, xycentered=True):
if xycentered:
return Workplane().rect(size, size).extrude(size).val()
else:
return Solid.makeBox(size, size, size)
def toTuple(v):

View File

@ -941,11 +941,11 @@ class TestCadQuery(BaseTest):
.workplane(offset=-5)
.moveTo(0, 4)
.circle(1.5)
.workplane(offset=5)
.workplane(offset=5, centerOption="CenterOfMass")
.circle(1.5)
.moveTo(0, -8)
.circle(1.0)
.workplane(offset=-5)
.workplane(offset=-5, centerOption="CenterOfMass")
.circle(1.0)
.sweep(path, multisection=True)
)
@ -1400,7 +1400,12 @@ class TestCadQuery(BaseTest):
self.assertEqual(11, t.faces().size())
# side hole, thru all
t = t.faces(">Y").workplane().circle(0.125).cutThruAll()
t = (
t.faces(">Y")
.workplane(centerOption="CenterOfMass")
.circle(0.125)
.cutThruAll()
)
self.saveModel(t)
self.assertEqual(13, t.faces().size())
@ -1473,12 +1478,22 @@ class TestCadQuery(BaseTest):
self.assertEqual(5, r.faces().size())
# now add a circle through a side face
r1 = r.faces("+XY").workplane().circle(0.08).cutThruAll()
r1 = (
r.faces("+XY")
.workplane(centerOption="CenterOfMass")
.circle(0.08)
.cutThruAll()
)
self.assertEqual(6, r1.faces().size())
r1.val().exportStep(os.path.join(OUTDIR, "testBasicLinesXY.STEP"))
# now add a circle through a top
r2 = r1.faces("+Z").workplane().circle(0.08).cutThruAll()
r2 = (
r1.faces("+Z")
.workplane(centerOption="CenterOfMass")
.circle(0.08)
.cutThruAll()
)
self.assertEqual(9, r2.faces().size())
r2.val().exportStep(os.path.join(OUTDIR, "testBasicLinesZ.STEP"))
@ -2246,7 +2261,7 @@ class TestCadQuery(BaseTest):
.rect(10, 5)
.cutBlind(-5)
.faces(">Z")
.workplane()
.workplane(centerOption="CenterOfMass")
.center(0, 2.5)
.rect(5, 5)
.cutThruAll()

View File

@ -76,7 +76,7 @@ class TestCQSelectors(BaseTest):
self.assertEqual(0, c.solids().size())
def testSolid(self):
c = CQ(makeUnitCube())
c = CQ(makeUnitCube(False))
# make sure all the counts are right for a cube
self.assertEqual(1, c.solids().size())
self.assertEqual(6, c.faces().size())
@ -267,7 +267,7 @@ class TestCQSelectors(BaseTest):
)
def testNearestTo(self):
c = CQ(makeUnitCube())
c = CQ(makeUnitCube(centered=False))
# nearest vertex to origin is (0,0,0)
t = (0.1, 0.1, 0.1)
@ -286,7 +286,7 @@ class TestCQSelectors(BaseTest):
self.assertEqual(1, len(s))
def testBox(self):
c = CQ(makeUnitCube())
c = CQ(makeUnitCube(centered=False))
# test vertice selection
test_data_vertices = [
@ -561,7 +561,7 @@ class TestCQSelectors(BaseTest):
def testVertexFilter(self):
"test selecting vertices on a face"
c = CQ(makeUnitCube())
c = CQ(makeUnitCube(centered=False))
# TODO: filters work ok, but they are in global coordinates which sux. it would be nice
# if they were available in coordinates local to the selected face