16
16
version = sys .version_info [0 ]
17
17
18
18
19
- class Doc :
20
- def __init__ (self ):
21
- self .DisplayName = "gCPy.Doc(DocDisplayName)"
22
- self .FilePath = "gCPy.Doc(DocFilePath)"
23
-
24
-
25
19
class Line :
26
20
def __init__ (self , * args ):
27
21
"""Adds new line using two input points, or two input lists or 6 input doubles
@@ -53,7 +47,6 @@ def __init__(self, *args):
53
47
self .X2 = pointb .X
54
48
self .Y2 = pointb .Y
55
49
self .Z2 = pointb .Z
56
-
57
50
elif version == 3 :
58
51
if isinstance (args [0 ], str ) and isinstance (args [1 ], str ):
59
52
pointa = Point (args [0 ])
@@ -80,6 +73,14 @@ def addLine(self):
80
73
+ str (self .Y2 ) + ", " \
81
74
+ str (self .Z2 ) + ")"
82
75
76
+ def __repr__ (self ):
77
+ return "gCPy.Line(" + str (self .X1 ) + ", " \
78
+ + str (self .Y1 ) + ", " \
79
+ + str (self .Z1 ) + ", " \
80
+ + str (self .X2 ) + ", " \
81
+ + str (self .Y2 ) + ", " \
82
+ + str (self .Z2 ) + ")"
83
+
83
84
def length (self ):
84
85
return ((self .X2 - self .X1 ) ** 2 + (self .Y2 - self .Y1 ) ** 2 + (self .Z2 - self .Z1 ) ** 2 ) ** 0.5
85
86
@@ -88,13 +89,7 @@ def pointOnLine(self, parameter=0.5):
88
89
(self .Y2 - self .Y1 ) * parameter + self .Y1 , \
89
90
(self .Z2 - self .Z1 ) * parameter + self .Z1 )
90
91
91
- def __str__ (self ):
92
- return "gCPy.Line(" + str (self .X1 ) + ", " \
93
- + str (self .Y1 ) + ", " \
94
- + str (self .Z1 ) + ", " \
95
- + str (self .X2 ) + ", " \
96
- + str (self .Y2 ) + ", " \
97
- + str (self .Z2 ) + ")"
92
+
98
93
99
94
100
95
class Point :
@@ -151,9 +146,38 @@ def __init__(self, x=0., y=0., z=0.):
151
146
self .Z = z
152
147
self .addPoint = "gCPy.Point(" + str (x ) + "," + str (y ) + "," + str (z ) + ")"
153
148
149
+ def __repr__ (self ):
150
+ return "gCPy.Point(" + str (self .X ) + "," + str (self .Y ) + "," + str (self .Z ) + ")"
151
+
154
152
def __str__ (self ):
155
153
return "gCPy.Point(" + str (self .X ) + "," + str (self .Y ) + "," + str (self .Z ) + ")"
156
154
155
+ class Surface :
156
+ def __init__ (self , * args ):
157
+ if len (args ) == 4 :
158
+ if isinstance (args [0 ], Point ) and isinstance (args [1 ], Point ) and isinstance (args [2 ], Point ) and isinstance (args [3 ], Point ):
159
+ self .P1 = args [0 ]
160
+ self .P2 = args [1 ]
161
+ self .P3 = args [2 ]
162
+ self .P4 = args [3 ]
163
+ self .addSurface = "gCPy.Surface(" + str (args [0 ].X ) + "," \
164
+ + str (args [0 ].Y ) + "," \
165
+ + str (args [0 ].Z ) + "," \
166
+ + str (args [1 ].X ) + "," \
167
+ + str (args [1 ].Y ) + "," \
168
+ + str (args [1 ].Z ) + "," \
169
+ + str (args [2 ].X ) + "," \
170
+ + str (args [2 ].Y ) + "," \
171
+ + str (args [2 ].Z ) + "," \
172
+ + str (args [3 ].X ) + "," \
173
+ + str (args [3 ].Y ) + "," \
174
+ + str (args [3 ].Z ) + "," \
175
+ + ")"
176
+ elif len (args ) == 2 :
177
+ pass
178
+ else :
179
+ print "you have to create surface from 4 points"
180
+
157
181
158
182
########################### DEFINE METHODS ################################
159
183
@@ -173,19 +197,18 @@ def addLine(*args):
173
197
174
198
def addPoint (* args ):
175
199
"""
176
-
177
200
:param args:
178
201
:return:
179
202
"""
180
203
if len (args ) == 1 :
181
204
return Point (args [0 ])
182
205
elif len (args ) == 3 :
183
- return Point (args [0 ], args [1 ], args [2 ]). addPoint
206
+ return Point (args [0 ], args [1 ], args [2 ])
184
207
185
208
186
- ##################################vars#################################
209
+ def addSurface (* args ):
210
+ return Surface (args [0 ], args [1 ], args [2 ], args [3 ]).addSurface
187
211
188
- doc = Doc ();
189
212
190
213
if __name__ == '__main__' :
191
214
print __name__
0 commit comments