本文整理汇总了Python中Mesh.createSphere方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.createSphere方法的具体用法?Python Mesh.createSphere怎么用?Python Mesh.createSphere使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.createSphere方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeMesh
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createSphere [as 别名]
def makeMesh():
FreeCAD.newDocument()
import Mesh
a=FreeCAD.ActiveDocument.addObject("Mesh::FeaturePython","Mesh")
a.Mesh=Mesh.createSphere(5.0)
MeshFeature(a)
ViewProviderMesh(a.ViewObject)
示例2: testLoadMesh
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createSphere [as 别名]
def testLoadMesh(self):
mesh=Mesh.createSphere(10.0,100) # a fine sphere
name=tempfile.gettempdir() + os.sep + "mesh.stl"
mesh.write(name)
FreeCAD.Console.PrintMessage("Write mesh to %s\n"%(name))
#lock=thread.allocate_lock()
for i in range(2):
thread.start_new(loadFile,(name,))
time.sleep(1)
示例3: makePoints
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createSphere [as 别名]
def makePoints():
FreeCAD.newDocument()
import Mesh
m=Mesh.createSphere(5.0).Points
import Points
p=Points.Points()
l=[]
for s in m:
l.append(s.Vector)
p.addPoints(l)
a=FreeCAD.ActiveDocument.addObject("Points::FeaturePython","Points")
a.Points=p
PointFeature(a)
ViewProviderPoints(a.ViewObject)
示例4: construct
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createSphere [as 别名]
def construct(zet, mbb, margin=1e-03, fn=50):
if zet is None:
return Mesh.Mesh()
elif isinstance(zet, Intersection):
return common(construct(arg, mbb, margin, fn) for arg in zet.args)
elif isinstance(zet, Union):
return fuse(construct(arg, mbb, margin, fn) for arg in zet.args)
elif isinstance(zet, Complement):
return common([construct(zet.arg[0], mbb, margin, fn),
complement(construct(zet.arg[1], mbb, margin, fn))])
elif isinstance(zet, AbsoluteComplement):
return complement(construct(zet.arg[0], mbb, margin, fn))
elif isinstance(zet, Image):
placement = spexpr2fcexpr(zet.function)
mbb_ = mbb.transformed(placement.inverse().toMatrix())
return transform(construct(zet.set, mbb_, margin, fn), zet.function)
elif isinstance(zet, euclid.EmptySpace):
return Mesh.Mesh()
elif isinstance(zet, euclid.WholeSpace):
mesh = Mesh.createSphere(mbb.DiagonalLength/2 + margin, int(fn))
mesh.translate(*mbb.Center)
return mesh
elif isinstance(zet, euclid.Halfspace):
direction = spexpr2fcexpr(zet.direction)
offset = spexpr2fcexpr(zet.offset)
if not mbb.isCutPlane(direction*offset, direction):
return direction*mbb.Center > offset
rot = rmat_k2d(zet.direction)
center = zet.direction*zet.offset
placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=center))
mbb_ = mbb.transformed(placement.inverse().toMatrix())
height = mbb_.ZMax + margin
xm = max(abs(mbb_.XMax), abs(mbb_.XMin))
ym = max(abs(mbb_.YMax), abs(mbb_.YMin))
radius = math.sqrt(xm**2 + ym**2) + margin
mesh = createConicalFrustum(radius, radius, height, fn=fn)
mesh.Placement = placement
return mesh
elif isinstance(zet, euclid.InfiniteCylinder):
direction = spexpr2fcexpr(zet.direction)
center = spexpr2fcexpr(zet.center)
dist = mbb.Center.distanceToLine(center, direction)
radius = spexpr2fcexpr(zet.radius)
mbb_radius = mbb.DiagonalLength/2
if radius + mbb_radius < dist:
return False
elif radius - mbb_radius > dist:
return True
rot = rmat_k2d(zet.direction)
placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
mbb_ = mbb.transformed(placement.inverse().toMatrix())
height = mbb_.ZLength + 2*margin
bottom = FreeCAD.Vector(0, 0, mbb_.ZMin-margin)
mesh = createConicalFrustum(radius, radius, height, bottom, fn=fn)
mesh.Placement = placement
return mesh
elif isinstance(zet, euclid.SemiInfiniteCone):
pnt = mbb.Center - spexpr2fcexpr(zet.center)
mbb_radius = mbb.DiagonalLength/2
if pnt.Length > mbb_radius:
direction = spexpr2fcexpr(zet.direction)
ang = abs(math.acos(direction*pnt/pnt.Length))
ang_cone = math.atan(spexpr2fcexpr(zet.slope))
ang_ball = math.asin(mbb_radius/pnt.Length)
if ang_cone + ang_ball < ang:
return False
elif ang_cone - ang_ball > ang:
return True
rot = rmat_k2d(zet.direction)
placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
mbb_ = mbb.transformed(placement.inverse().toMatrix())
height = mbb_.ZLength + margin
radius = height*spexpr2fcexpr(zet.slope)
mesh = createConicalFrustum(0, radius, height, fn=fn)
mesh.Placement = placement
return mesh
elif isinstance(zet, euclid.Sphere):
radius = spexpr2fcexpr(zet.radius)
mesh = Mesh.createSphere(radius, int(fn))
placement = spexpr2fcexpr(AffineTransformation(vector=zet.center))
mesh.Placement = placement
return mesh
#.........这里部分代码省略.........
示例5: createMesh
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createSphere [as 别名]
def createMesh(r,s):
FreeCAD.Console.PrintMessage("Create sphere (%s,%s)...\n"%(r,s))
mesh=Mesh.createSphere(r,s)
FreeCAD.Console.PrintMessage("... destroy sphere\n")