-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMidSurface.py
More file actions
executable file
·65 lines (54 loc) · 2.33 KB
/
Copy pathMidSurface.py
File metadata and controls
executable file
·65 lines (54 loc) · 2.33 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
# EasyShells Module - API for easier Shell Model Construction in Salome
# MidSurface.py: Mid surface extraction for EasyShells module
#
# Copyright (C) 2013 Stefan Reiterer - maldun.finsterschreck@gmail.com
#
# This library 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 2.1 of the License, or (at your option) any later version.
#
# This library 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 this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
from __future__ import print_function
import salome
import geompy
from numpy import array, arange
from MyGeom.Types import *
def create_parallel_midpoints(points_lower, points_upper):
"""
Help function to create the midpoints of two given parallel surfaces
"""
length_u = len(points_lower[0])
length_v = len(points_lower)
return [[(points_lower[i][j] + points_upper[i][j])*0.5 \
for j in range(length_u)] \
for i in range(length_v)]
def parallel_midsurface(lower_face, upper_face, lower_deg = 2, upper_deg = 5):
"""
Determines the midsurface of 2 parallel
surfaces. Hereby parallel means that they
share the same normal direction. It is assumed
that both normals point outwards.
"""
points_u = arange(0,1+1./upper_deg,1./upper_deg)
points_v = points_u
lower_points = create_local_coordinates(lower_face,points_u,points_v)
lower_points = create_local_coordinates(upper_face,points_u,points_v)
midpoints = create_parallel_midpoints
def face_normal_translation(face,distance,change_orientation = False):
"""
Help function to make a translation
"""
if change_orientation:
face.changeOrientation()
normal = face.getNormal()
result = geompy.MakeTranslationVectorDistance(face.getGeomObject(),normal.getGeomObject(),
distance)
return MyFace(result)