本文整理汇总了Python中tests.makeUnitCube函数的典型用法代码示例。如果您正苦于以下问题:Python makeUnitCube函数的具体用法?Python makeUnitCube怎么用?Python makeUnitCube使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了makeUnitCube函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testChamfer
def testChamfer(self):
"""
Test chamfer API with a box shape
"""
cube = CQ(makeUnitCube()).faces(">Z").chamfer(0.1)
self.saveModel(cube)
self.assertEqual(10, cube.faces().size())
示例2: testTranslateSolid
def testTranslateSolid(self):
c = CQ(makeUnitCube())
self.assertAlmostEqual(0.0,c.faces("<Z").vertices().item(0).val().Z, 3 )
#TODO: it might be nice to provide a version of translate that modifies the existing geometry too
d = c.translate(Vector(0,0,1.5))
self.assertAlmostEqual(1.5,d.faces("<Z").vertices().item(0).val().Z, 3 )
示例3: testFillet
def testFillet(self):
"""
Tests filleting edges on a solid
"""
c = CQ( makeUnitCube()).faces(">Z").workplane().circle(0.25).extrude(0.25,True).edges("|Z").fillet(0.2)
self.saveModel(c)
self.assertEqual(12,c.faces().size() )
示例4: testFrontReference
def testFrontReference(self):
s = CQ(makeUnitCube()).faces("front").workplane() #make a workplane on the top face
r = s.circle(0.125).cutBlind(-2.0)
self.saveModel(r)
#the result should have 7 faces
self.assertEqual(7,r.faces().size() )
self.assertEqual(type(r.val()), Solid)
self.assertEqual(type(r.first().val()),Solid)
示例5: testSolidReferencesCombine
def testSolidReferencesCombine(self):
"test that solid references are updated correctly"
c = CQ( makeUnitCube()) #the cube is the context solid
self.assertEqual(6,c.faces().size()) #cube has six faces
r = c.faces().workplane().circle(0.125).extrude(0.5,True) #make a boss, not updating the original
self.assertEqual(8,r.faces().size()) #just the boss faces
self.assertEqual(8,c.faces().size()) #original is modified too
示例6: testFaceTypesFilter
def testFaceTypesFilter(self):
"Filters by face type"
c = CQ(makeUnitCube())
self.assertEqual(c.faces().size(), c.faces('%PLANE').size())
self.assertEqual(c.faces().size(), c.faces('%plane').size())
self.assertEqual(0, c.faces('%sphere').size())
self.assertEqual(0, c.faces('%cone').size())
self.assertEqual(0, c.faces('%SPHERE').size())
示例7: testParallelPlaneFaceFilter
def testParallelPlaneFaceFilter(self):
c = CQ(makeUnitCube())
#faces parallel to Z axis
self.assertEqual(2, c.faces("|Z").size())
#TODO: provide short names for ParallelDirSelector
self.assertEqual(2, c.faces(selectors.ParallelDirSelector(Vector((0,0,1)))).size()) #same thing as above
self.assertEqual(2, c.faces(selectors.ParallelDirSelector(Vector((0,0,-1)))).size()) #same thing as above
#just for fun, vertices on faces parallel to z
self.assertEqual(8, c.faces("|Z").vertices().size())
示例8: testFaceDirFilter
def testFaceDirFilter(self):
c = CQ(makeUnitCube())
#a cube has one face in each direction
self.assertEqual(1, c.faces("+Z").size())
self.assertEqual(1, c.faces("-Z").size())
self.assertEqual(1, c.faces("+X").size())
self.assertEqual(1, c.faces("X").size()) #should be same as +X
self.assertEqual(1, c.faces("-X").size())
self.assertEqual(1, c.faces("+Y").size())
self.assertEqual(1, c.faces("-Y").size())
self.assertEqual(0, c.faces("XY").size())
示例9: testMinDistance
def testMinDistance(self):
c = CQ(makeUnitCube())
#should select the topmost face
self.assertEqual(1, c.faces("<Z").size())
self.assertEqual(4, c.faces("<Z").vertices().size())
#vertices should all be at z=1, if this is the top face
self.assertEqual(4, len(c.faces("<Z").vertices().vals() ))
for v in c.faces("<Z").vertices().vals():
self.assertAlmostEqual(0.0,v.Z,3)
示例10: testSubtractSelector
def testSubtractSelector(self):
c = CQ(makeUnitCube())
S = selectors.StringSyntaxSelector
fl = c.faces(selectors.SubtractSelector(S("#Z"), S(">X"))).vals()
self.assertEqual(3, len(fl))
# test the subtract operator
fl = c.faces(S("#Z") - S(">X")).vals()
self.assertEqual(3, len(fl))
示例11: testAndSelector
def testAndSelector(self):
c = CQ(makeUnitCube())
S = selectors.StringSyntaxSelector
BS = selectors.BoxSelector
el = c.edges(selectors.AndSelector(S('|X'), BS((-2,-2,0.1), (2,2,2)))).vals()
self.assertEqual(2, len(el))
# test 'and' (intersection) operator
el = c.edges(S('|X') & BS((-2,-2,0.1), (2,2,2))).vals()
self.assertEqual(2, len(el))
示例12: testSplitKeepingHalf
def testSplitKeepingHalf(self):
"Tests splitting a solid"
#drill a hole in the side
c = CQ(makeUnitCube()).faces(">Z").workplane().circle(0.25).cutThruAll()
self.assertEqual(7,c.faces().size() )
#now cut it in half sideways
c.faces(">Y").workplane(-0.5).split(keepTop=True)
self.saveModel(c)
self.assertEqual(8,c.faces().size())
示例13: testPointList
def testPointList(self):
"Tests adding points and using them"
c = CQ(makeUnitCube())
s = c.faces(">Z").workplane().pushPoints([(-0.3,0.3),(0.3,0.3),(0,0)])
self.assertEqual(3,s.size())
#TODO: is the ability to iterate over points with circle really worth it?
#maybe we should just require using all() and a loop for this. the semantics and
#possible combinations got too hard ( ie, .circle().circle() ) was really odd
body = s.circle(0.05).cutThruAll()
self.saveModel(body)
self.assertEqual(9,body.faces().size())
示例14: testVertexFilter
def testVertexFilter(self):
"test selecting vertices on a face"
c = CQ(makeUnitCube())
#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
v2 = c.faces("+Z").vertices("<XY")
self.assertEqual(1,v2.size() ) #another way
#make sure the vertex is the right one
self.assertTupleAlmostEquals((0.0,0.0,1.0),v2.val().toTuple() ,3)
示例15: testChamferAsymmetrical
def testChamferAsymmetrical(self):
"""
Test chamfer API with a box shape for asymmetrical lengths
"""
cube = CQ(makeUnitCube()).faces(">Z").chamfer(0.1, 0.2)
self.saveModel(cube)
self.assertEqual(10, cube.faces().size())
# test if edge lengths are different
edge = cube.edges(">Z").vals()[0]
self.assertAlmostEqual(0.6, edge.Length(), 3)
edge = cube.edges("|Z").vals()[0]
self.assertAlmostEqual(0.9, edge.Length(), 3)