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
79
80
81
82
83
84
85
86
87
88
89
90
91
|
'''
Created on 29-Nov-2014
@author: deepa
'''
import numpy
from ModelUtils import *
class ISection(object):
'''
^ v
|
c2 . c1
--- +-----------------|-----------------+ ---
^ | . | ^
| T | | | |
v | . | |
--- +------------+ | +------------+ |
b2 a2| | a1 b1 |
| t | |
|<------->| |
| | | |
| . | |D
| |O | |
-- -- -- -- -- -- -- -- --.-- -- -- -- -- -- -- -- |-- -- -> u
| | | |
| . | |
| | | |
| . | |
b3 a3| | |a4 b4 |
+-----------+ . +------------+ |
| | | |
| . | |
| | | v
+----------------.-----------------+ ---
c3 B c4
|<-------------------------------->|
'''
def __init__(self, B, T, D, t, R1, R2, alpha, length):
self.B = B
self.T = T
self.D = D
self.t = t
self.R1 = R1
self.R2 = R2
self.alpha = alpha
self.length = length
self.secOrigin = numpy.array([0, 0, 0])
self.uDir = numpy.array([1.0, 0, 0])
self.wDir = numpy.array([0.0, 0, 1.0])
self.computeParams()
def place(self, secOrigin, uDir, wDir):
self.secOrigin = secOrigin
self.uDir = uDir
self.wDir = wDir
self.computeParams()
def computeParams(self):
self.vDir = numpy.cross(self.wDir, self.uDir)
self.a1 = self.secOrigin + (self.t/2.0) * self.uDir + ((self.D/2.0) - self.T) * self.vDir
self.b1 = self.secOrigin + (self.B/2.0) * self.uDir + ((self.D/2.0) - self.T) * self.vDir
self.c1 = self.secOrigin + (self.B/2.0) * self.uDir + (self.D/2.0) * self.vDir
self.a2 = self.secOrigin + (-self.t/2.0) * self.uDir + ((self.D/2.0) - self.T) * self.vDir
self.b2 = self.secOrigin + (-self.B/2.0) * self.uDir + ((self.D/2.0) - self.T) * self.vDir
self.c2 = self.secOrigin + (-self.B/2.0) * self.uDir + (self.D/2.0) * self.vDir
self.a3 = self.secOrigin + (-self.t/2.0) * self.uDir + -((self.D/2.0) - self.T) * self.vDir
self.b3 = self.secOrigin + (-self.B/2.0) * self.uDir + -((self.D/2.0) - self.T) * self.vDir
self.c3 = self.secOrigin + (-self.B/2.0) * self.uDir + -(self.D/2.0) * self.vDir
self.a4 = self.secOrigin + (self.t/2.0) * self.uDir + -((self.D/2.0) - self.T) * self.vDir
self.b4 = self.secOrigin + (self.B/2.0) * self.uDir + -((self.D/2.0) - self.T) * self.vDir
self.c4 = self.secOrigin + (self.B/2.0) * self.uDir + -(self.D/2.0) * self.vDir
self.points = [self.a1, self.b1, self.c1,
self.c2, self.b2, self.a2,
self.a3, self.b3, self.c3,
self.c4, self.b4, self.a4]
#self.points = [[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]
def createModel(self):
edges = makeEdgesFromPoints(self.points)
wire = makeWireFromEdges(edges)
aFace = makeFaceFromWire(wire)
extrudeDir = self.length * self.wDir # extrudeDir is a numpy array
prism = makePrismFromFace(aFace, extrudeDir)
return prism
|