本文整理汇总了Python中Mesh.createBox方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.createBox方法的具体用法?Python Mesh.createBox怎么用?Python Mesh.createBox使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mesh
的用法示例。
在下文中一共展示了Mesh.createBox方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _createBox
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createBox [as 别名]
def _createBox(proxy, size, colour, moiScale, withMesh):
"""
Private function.
Use createBox() or createArticulatedBox() instead.
"""
# Mesh and cdps will be set manually
proxy.meshes = None
proxy.cdps = None
# Compute box moi
size = PyUtils.toVector3d(size)
proxy.moi = (
MathLib.Vector3d(
size.y * size.y + size.z * size.z, size.x * size.x + size.z * size.z, size.x * size.x + size.y * size.y
)
* 1.0
/ 12.0
* proxy.mass
* moiScale
)
box = proxy.createAndFillObject()
cdp = Physics.BoxCDP()
halfSize = PyUtils.toVector3d(size) * 0.5
cdp.setPoint1(MathLib.Point3d(halfSize * -1))
cdp.setPoint2(MathLib.Point3d(halfSize))
box.addCollisionDetectionPrimitive(cdp)
if withMesh:
mesh = Mesh.createBox(size=size, colour=colour)
box.addMesh(mesh)
return box
示例2: construct
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createBox [as 别名]
#.........这里部分代码省略.........
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
elif isinstance(zet, euclid.Box):
size = spexpr2fcexpr(zet.size)
mesh = Mesh.createBox(size.x, size.y, size.z)
rot = zet.orientation
placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
mesh.Placement = placement
return mesh
elif isinstance(zet, euclid.Cylinder):
radius = spexpr2fcexpr(zet.radius)
height = spexpr2fcexpr(zet.height)
pnt = FreeCAD.Vector(0, 0, -height/2)
mesh = createConicalFrustum(radius, radius, height, pnt, fn=fn)
rot = rmat_k2d(zet.direction)
placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
mesh.Placement = placement
return mesh
elif isinstance(zet, euclid.Cone):
radius = spexpr2fcexpr(zet.radius)
height = spexpr2fcexpr(zet.height)
mesh = createConicalFrustum(0, radius, height, fn=fn)
rot = rmat_k2d(zet.direction)
placement = spexpr2fcexpr(AffineTransformation(matrix=rot, vector=zet.center))
mesh.Placement = placement
return mesh
else:
raise TypeError
示例3: PlaceBox
# 需要导入模块: import Mesh [as 别名]
# 或者: from Mesh import createBox [as 别名]
# Script to create a Menger sponge
# (c) 2012 Werner Mayer LGPL
# The script is based on the work of daxmick at
# http://forum.freecadweb.org/viewtopic.php?f=3&t=2307
import threading
import Mesh, MeshGui
from FreeCAD import Base
# Create a global mesh and make copies of them
# This makes the algorithm faster by ~60%.
box = Mesh.createBox(1,1,1)
# Create a Box and Place it a coords (x,y,z)
def PlaceBox(x,y,z):
global box
mbox=box.copy()
mbox.translate(x,y,z)
return mbox
def Sierpinski(level,x0,y0,z0):
#print(threading.current_thread().name)
boxnums = pow(3,level)
thirds = boxnums / 3
twothirds = thirds * 2
if(level == 0):
rangerx = [x0]
rangery = [y0]
rangerz = [z0]
else: