Skip to content

Commit 9925b2d

Browse files
committed
Added through section example
1 parent 84d051c commit 9925b2d

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
##Copyright 2009-2015 Thomas Paviot ([email protected])
2+
##
3+
##This file is part of pythonOCC.
4+
##
5+
##pythonOCC is free software: you can redistribute it and/or modify
6+
##it under the terms of the GNU Lesser General Public License as published by
7+
##the Free Software Foundation, either version 3 of the License, or
8+
##(at your option) any later version.
9+
##
10+
##pythonOCC is distributed in the hope that it will be useful,
11+
##but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
##GNU Lesser General Public License for more details.
14+
##
15+
##You should have received a copy of the GNU Lesser General Public License
16+
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
17+
18+
from OCC.gp import gp_Dir, gp_Pnt, gp_Circ, gp_Ax2
19+
from OCC.BRepBuilderAPI import (BRepBuilderAPI_MakeWire,
20+
BRepBuilderAPI_MakeEdge)
21+
from OCC.BRepOffsetAPI import BRepOffsetAPI_ThruSections
22+
23+
from OCC.Display.SimpleGui import init_display
24+
display, start_display, add_menu, add_function_to_menu = init_display()
25+
26+
27+
def through_sections():
28+
#ruled
29+
circle_1 = gp_Circ(gp_Ax2(gp_Pnt(-100., 0., -100.), gp_Dir(0., 0., 1.)), 40.)
30+
wire_1 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_1).Edge()).Wire()
31+
circle_2 = gp_Circ(gp_Ax2(gp_Pnt(-10., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
32+
wire_2 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_2).Edge()).Wire()
33+
circle_3 = gp_Circ(gp_Ax2(gp_Pnt(-75., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
34+
wire_3 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_3).Edge()).Wire()
35+
circle_4 = gp_Circ(gp_Ax2(gp_Pnt(0., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
36+
wire_4 = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_4).Edge()).Wire()
37+
38+
generatorA = BRepOffsetAPI_ThruSections(False, True)
39+
map(generatorA.AddWire, [wire_1, wire_2, wire_3, wire_4])
40+
generatorA.Build()
41+
display.DisplayShape(generatorA.Shape())
42+
43+
#smooth
44+
circle_1b = gp_Circ(gp_Ax2(gp_Pnt(100., 0., -100.), gp_Dir(0., 0., 1.)), 40.)
45+
wire_1b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_1b).Edge()).Wire()
46+
circle_2b = gp_Circ(gp_Ax2(gp_Pnt(210., 0., -0.), gp_Dir(0., 0., 1.)), 40.)
47+
wire_2b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_2b).Edge()).Wire()
48+
circle_3b = gp_Circ(gp_Ax2(gp_Pnt(275., 0., 100.), gp_Dir(0., 0., 1.)), 40.)
49+
wire_3b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_3b).Edge()).Wire()
50+
circle_4b = gp_Circ(gp_Ax2(gp_Pnt(200., 0., 200.), gp_Dir(0., 0., 1.)), 40.)
51+
wire_4b = BRepBuilderAPI_MakeWire(BRepBuilderAPI_MakeEdge(circle_4b).Edge()).Wire()
52+
generatorB = BRepOffsetAPI_ThruSections(True, False)
53+
map(generatorB.AddWire, [wire_1b, wire_2b, wire_3b, wire_4b])
54+
generatorB.Build()
55+
display.DisplayShape(generatorB.Shape(), update=True)
56+
57+
if __name__ == '__main__':
58+
through_sections()
59+
start_display()

0 commit comments

Comments
 (0)