pythonocc 球体构造BRepPrimAPI_MakeSphere

from OCC.Display.SimpleGui import init_display
import math

from OCC.Core.BRepPrimAPI import (
    BRepPrimAPI_MakeSphere,
    BRepPrimAPI_MakeCylinder,
    BRepPrimAPI_MakeBox,
)
from OCC.Core.gp import gp_Ax2, gp_Pnt, gp_Dir, gp_Ax1, gp_Trsf, gp_Vec

from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()
#球心在零点,半径构造球体sphere_radius
def sphere_creat1(sphere_radius):
    sphere1 = BRepPrimAPI_MakeSphere(sphere_radius).Shape()
    return sphere1
#通过球心点gp_Pnt,半径sphere_radius构造球体
def sphere_creat2(gp_Pnt,sphere_radius):
    sphere2 = BRepPrimAPI_MakeSphere(gp_Pnt,sphere_radius).Shape()
    return sphere2
#通过半径sphere_radius,绕Z轴初始角度angle1以及绕Z轴结束角度angle2构造球体,angle2>angle1,两者之差小于180度,用于生成部分球体
def sphere_creat3(sphere_radius,angle1,angle2):
    sphere3 = BRepPrimAPI_MakeSphere(sphere_radius,angle1,angle2).Shape()
    return sphere3
#通过半径sphere_radius,角度angle1构造球体,绕Z轴angle1表示与X轴的夹角为结束角度,绕Z轴初始角度为0,用于生成部分球体
def sphere_creat4(sphere_radius,angle1):
    sphere4 = BRepPrimAPI_MakeSphere(sphere_radius,angle1).Shape()
    return sphere4
#通过半径sphere_radius,angle1表示绕Z轴初始角度,angle3表示绕Z轴结束角度,angle2表示绕Y轴结束角度,绕Y轴初始角度为0,用于生成部分球体
def sphere_creat5(sphere_radius,angle1,angle2,angle3):
    sphere5 = BRepPrimAPI_MakeSphere(sphere_radius,angle1,angle2,angle3).Shape()
    return sphere5

sphere_radius = 1.0
P0=gp_Pnt(0,0,3)
angle1=0.0
angle2=math.pi/4
angle3=math.pi/2
'''
sphere1=sphere_creat1(sphere_radius)
display.DisplayShape(sphere1, update=True)

sphere2=sphere_creat2(P0,sphere_radius)
display.DisplayShape(sphere2, update=True)

sphere3=sphere_creat3(sphere_radius,angle1,angle2)
display.DisplayShape(sphere3, update=True)

sphere4=sphere_creat4(sphere_radius,angle1)
display.DisplayShape(sphere4, update=True)
'''
sphere5=sphere_creat5(sphere_radius,angle1,angle2,angle3)
display.DisplayShape(sphere5, update=True)
start_display()



pythonocc 球体构造BRepPrimAPI_MakeSphere_第1张图片

你可能感兴趣的:(Python,python,pythonocc)