本文主要是介绍pythonocc 用BRepOffsetAPI_ThruSections建3D棱台,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
棱台就是棱锥被一个平面截掉上半部分后的几何实体。可以用下底平面和上底平面来确定一个棱台。BRepOffsetAPI_ThruSections用下底曲线和上底曲线来构建的棱台。BRepOffsetAPI_ThruSections是通过所用的曲线的几何实体。
from OCC.Core.BRepOffsetAPI import BRepOffsetAPI_ThruSections
from OCC.Core.gp import gp_Pnt
from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakePolygon
def GetTrapezoid3dShape(offset_x, offset_y, bottom_x, bottom_y, top_x, top_y, z0, z1):
aP1 = gp_Pnt(-bottom_x/2 + offset_x, -bottom_y/2 + offset_y, z0)
aP2 = gp_Pnt(bottom_x/2 + offset_x, -bottom_y/2 + offset_y, z0)
aP3 = gp_Pnt(bottom_x/2 + offset_x, bottom_y/2 + offset_y, z0)
aP4 = gp_Pnt(-bottom_x/2 + offset_x, bottom_y/2 + offset_y, z0)
aPolygon_bottom = BRepBuilderAPI_MakePolygon(aP1, aP2, aP3, aP4, True)
aP1_top = gp_Pnt(-top_x/2 + offset_x, -top_y/2 + offset_y, z1)
aP2_top = gp_Pnt(top_x/2 + offset_x, -top_y/2 + offset_y, z1)
aP3_top = gp_Pnt(top_x/2 + offset_x, top_y/2 + offset_y, z1)
aP4_top = gp_Pnt(-top_x/2 + offset_x, top_y/2 + offset_y, z1)
aPolygon_top = BRepBuilderAPI_MakePolygon(aP1_top, aP2_top, aP3_top, aP4_top, True)
box = BRepOffsetAPI_ThruSections(True, True)
box.AddWire(aPolygon_bottom.Wire())
box.AddWire(aPolygon_top.Wire())
return box.Shape()
这篇关于pythonocc 用BRepOffsetAPI_ThruSections建3D棱台的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!