forked from tpaviot/pythonocc-utils
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoccutils_surfaces.py
More file actions
78 lines (66 loc) · 2.22 KB
/
occutils_surfaces.py
File metadata and controls
78 lines (66 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python
##Copyright 2009-2015 Jelle Ferina (jelleferinga@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 Lesser 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 Lesser General Public License for more details.
##
##You should have received a copy of the GNU Lesser General Public License
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
import sys
from itertools import chain
from OCC.Display.SimpleGui import init_display
sys.path.append('..')
from OCCUtils.Common import points_to_bspline
from OCCUtils.Construct import gp_Pnt, make_edge, make_n_sided, make_vertex
display, start_display, add_menu, add_function_to_menu = init_display()
def n_sided_patch():
# left
pts1 = (gp_Pnt(0, 0, 0.0),
gp_Pnt(0, 1, 0.3),
gp_Pnt(0, 2, -0.3),
gp_Pnt(0, 3, 0.15),
gp_Pnt(0, 4, 0),
)
# front
pts2 = (gp_Pnt(0, 0, 0.0),
gp_Pnt(1, 0, -0.3),
gp_Pnt(2, 0, 0.15),
gp_Pnt(3, 0, 0),
gp_Pnt(4, 0, 0),
)
# back
pts3 = (gp_Pnt(0, 4, 0),
gp_Pnt(1, 4, 0.3),
gp_Pnt(2, 4, -0.15),
gp_Pnt(3, 4, 0),
gp_Pnt(4, 4, 1),
)
# right
pts4 = (gp_Pnt(4, 0, 0),
gp_Pnt(4, 1, 0),
gp_Pnt(4, 2, 0.3),
gp_Pnt(4, 3, -0.15),
gp_Pnt(4, 4, 1),
)
spl1 = points_to_bspline(pts1)
spl2 = points_to_bspline(pts2)
spl3 = points_to_bspline(pts3)
spl4 = points_to_bspline(pts4)
edges = map(make_edge, [spl1, spl2, spl3, spl4])
verts = map(make_vertex, chain(pts1, pts2, pts3, pts4))
f1 = make_n_sided(edges, [])
display.DisplayShape(edges)
display.DisplayShape(verts)
display.DisplayShape(f1, update=True)
if __name__ == '__main__':
n_sided_patch()
start_display()