这里返回总目录>>返回总目录
本例从https://github.com/tpaviot/pythonocc-demos搬运而来
运行版本:0.18.1 在其余版本运行不保证正确
先上结果图
代码部分
from OCC.gp import gp_Pnt, gp_Pnt2d, gp_OX2d
from OCC.Geom2d import Geom2d_Circle
from OCC.Geom2dAdaptor import Geom2dAdaptor_Curve
from OCC.GCPnts import GCPnts_UniformAbscissa
from OCC.Display.SimpleGui import init_display
display, start_display, add_menu, add_function_to_menu = init_display()
def points_from_curve():
radius = 5.
abscissa = 3.
circle = Geom2d_Circle(gp_OX2d(), radius, True)
gac = Geom2dAdaptor_Curve(circle.GetHandle())
ua = GCPnts_UniformAbscissa(gac, abscissa)
a_sequence = []
if ua.IsDone():
n = ua.NbPoints()
for count in range(1, n + 1):
p = gp_Pnt2d()
circle.D0(ua.Parameter(count), p)
a_sequence.append(p)
# convert analytic to bspline
display.DisplayShape(circle, update=True)
i = 0
for p in a_sequence:
i = i + 1
pstring = 'P%i : parameter %f' % (i, ua.Parameter(i))
pnt = gp_Pnt(p.X(), p.Y(), 0)
# display points
display.DisplayShape(pnt, update=True)
display.DisplayMessage(pnt, pstring) #这里是重点
if __name__ == '__main__':
points_from_curve()
start_display()
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容