资源简介
使用用于Python的Open cascade库PythonOCC,可以快速实现关于OCC的开发。
代码片段和文件信息
#!/usr/bin/env python
##Copyright 2009 Thomas Paviot (tpaviot@gmail.com)
##
##This file is part of pythonOCC.
##
##pythonOCC is free software: you can redistribute it and/or modify
##it under the terms of the GNU General Public License as published by
##the Free Software Foundation either version 3 of the License or
##(at your option) any later version.
##
##pythonOCC is distributed in the hope that it will be useful
##but WITHOUT ANY WARRANTY; without even the implied warranty of
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
##GNU General Public License for more details.
##
##You should have received a copy of the GNU General Public License
##along with pythonOCC. If not see .
from OCC.BRepPrimAPI import *
from OCC.gp import *
from OCC.TopLoc import *
from OCC.AIS import *
from OCC.Display.SimpleGui import *
display start_display add_menu add_function_to_menu = init_display()
ais_boxshp=None
def build_shape():
global ais_boxshp
if not isinstance(ais_boxshpHandle_AIS_Shape):
boxshp = BRepPrimAPI_MakeBox(50.50.50.).Shape()
ais_boxshp = display.DisplayShape(boxshp)
return ais_boxshp
def rotating_cube_1_axis(event=None):
build_shape()
Ax1 = gp_Ax1(gp_Pnt(000)gp_Dir(001))
aCubeTrsf = gp_Trsf()
angle = 0.0
for i in range(2000):
aCubeTrsf.SetRotation(Ax1angle)
aCubeToploc = TopLoc_Location(aCubeTrsf)
display.Context.SetLocation(ais_boxshpaCubeToploc)
display.Context.UpdateCurrentViewer()
angle += 0.001
def rotating_cube_2_axis(event=None):
build_shape()
Ax1 = gp_Ax1(gp_Pnt(000)gp_Dir(001))
Ax2 = gp_Ax1(gp_Pnt(000)gp_Dir(010))
aCubeTrsf = gp_Trsf()
aCubeTrsf2 = gp_Trsf()
angle = 0.0
angle2 = 0.0
for i in range(2000):
aCubeTrsf.SetRotation(Ax1angle)
aCubeTrsf2.SetRotation(Ax2angle)
aCubeToploc = TopLoc_Location(aCubeTrsf*aCubeTrsf2)
display.Context.SetLocation(ais_boxshpaCubeToploc)
display.Context.UpdateCurrentViewer()
angle += 0.001
if __name__ == ‘__main__‘:
add_menu(‘animation‘)
add_function_to_menu(‘animation‘ rotating_cube_1_axis)
add_function_to_menu(‘animation‘ rotating_cube_2_axis)
start_display()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples
文件 343 2010-01-05 22:35 pythonOCC-0.4-samples\AUTHORS
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\Animation
文件 2320 2010-03-10 16:06 pythonOCC-0.4-samples\Level1\Animation\animation.py
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\Dimensions
文件 625 2010-03-10 16:07 pythonOCC-0.4-samples\Level1\Dimensions\dimensions.py
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\FairCurve
文件 1334 2009-12-17 17:06 pythonOCC-0.4-samples\Level1\FairCurve\faircurve.py
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\Geometry
文件 42255 2009-12-03 13:05 pythonOCC-0.4-samples\Level1\Geometry\geometry_demos.py
文件 7340 2009-12-04 15:54 pythonOCC-0.4-samples\Level1\Geometry\geomplate.py
文件 3109 2009-12-04 15:54 pythonOCC-0.4-samples\Level1\Geometry\surfaces.py
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\Mesh
文件 2737 2010-03-11 16:48 pythonOCC-0.4-samples\Level1\Mesh\simple_mesh.py
目录 0 2010-03-10 15:15 pythonOCC-0.4-samples\Level1\OCAF
文件 7909 2010-01-04 21:39 pythonOCC-0.4-samples\Level1\OCAF\dynamic_XCAF.py
文件 3827 2009-12-17 17:06 pythonOCC-0.4-samples\Level1\OCAF\step_export.py
文件 26336 2010-03-10 15:15 pythonOCC-0.4-samples\Level1\OCAF\step_la
文件 5576 2009-12-17 17:06 pythonOCC-0.4-samples\Level1\OCAF\step_OCAF_import.py
文件 413858 2009-04-07 04:35 pythonOCC-0.4-samples\Level1\OCAF\test.stp
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\OCAF\topological_naming
文件 3080 2010-01-04 21:39 pythonOCC-0.4-samples\Level1\OCAF\topological_naming\named_shape_demo.py
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\Plot
文件 4361 2009-08-10 19:43 pythonOCC-0.4-samples\Level1\Plot\plot.py
文件 2712 2009-08-06 04:58 pythonOCC-0.4-samples\Level1\Plot\plot_view.py
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\Serialization
文件 1263 2009-08-05 04:35 pythonOCC-0.4-samples\Level1\Serialization\TopoDS_Shape_pickling.py
目录 0 2010-03-09 21:08 pythonOCC-0.4-samples\Level1\ShapeProperties
文件 1668 2009-12-17 17:06 pythonOCC-0.4-samples\Level1\ShapeProperties\volume_properties.py
............此处省略142个文件信息
评论
共有 条评论