Skip to content

Commit 77fe312

Browse files
committed
Added occutils_surfaces example
1 parent 0e6eda4 commit 77fe312

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

examples/occutils_surfaces.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env python
2+
3+
##Copyright 2009-2015 Jelle Ferina (jelleferinga@gmail.com)
4+
##
5+
##This file is part of pythonOCC.
6+
##
7+
##pythonOCC is free software: you can redistribute it and/or modify
8+
##it under the terms of the GNU Lesser General Public License as published by
9+
##the Free Software Foundation, either version 3 of the License, or
10+
##(at your option) any later version.
11+
##
12+
##pythonOCC is distributed in the hope that it will be useful,
13+
##but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
##MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
##GNU Lesser General Public License for more details.
16+
##
17+
##You should have received a copy of the GNU Lesser General Public License
18+
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
19+
20+
import sys
21+
from itertools import chain
22+
23+
from OCC.Display.SimpleGui import init_display
24+
25+
sys.path.append('..')
26+
from OCCUtils.Common import points_to_bspline
27+
from OCCUtils.Construct import gp_Pnt, make_edge, make_n_sided, make_vertex
28+
29+
display, start_display, add_menu, add_function_to_menu = init_display()
30+
31+
32+
def n_sided_patch():
33+
34+
# left
35+
pts1 = (gp_Pnt(0, 0, 0.0),
36+
gp_Pnt(0, 1, 0.3),
37+
gp_Pnt(0, 2, -0.3),
38+
gp_Pnt(0, 3, 0.15),
39+
gp_Pnt(0, 4, 0),
40+
)
41+
# front
42+
pts2 = (gp_Pnt(0, 0, 0.0),
43+
gp_Pnt(1, 0, -0.3),
44+
gp_Pnt(2, 0, 0.15),
45+
gp_Pnt(3, 0, 0),
46+
gp_Pnt(4, 0, 0),
47+
)
48+
# back
49+
pts3 = (gp_Pnt(0, 4, 0),
50+
gp_Pnt(1, 4, 0.3),
51+
gp_Pnt(2, 4, -0.15),
52+
gp_Pnt(3, 4, 0),
53+
gp_Pnt(4, 4, 1),
54+
)
55+
# right
56+
pts4 = (gp_Pnt(4, 0, 0),
57+
gp_Pnt(4, 1, 0),
58+
gp_Pnt(4, 2, 0.3),
59+
gp_Pnt(4, 3, -0.15),
60+
gp_Pnt(4, 4, 1),
61+
)
62+
63+
spl1 = points_to_bspline(pts1)
64+
spl2 = points_to_bspline(pts2)
65+
spl3 = points_to_bspline(pts3)
66+
spl4 = points_to_bspline(pts4)
67+
68+
edges = map(make_edge, [spl1, spl2, spl3, spl4])
69+
verts = map(make_vertex, chain(pts1, pts2, pts3, pts4))
70+
f1 = make_n_sided(edges, [])
71+
72+
display.DisplayShape(edges)
73+
display.DisplayShape(verts)
74+
display.DisplayShape(f1, update=True)
75+
76+
if __name__ == '__main__':
77+
n_sided_patch()
78+
start_display()

0 commit comments

Comments
 (0)