/[escript]/trunk/pycad/test/python/run_pycad_test.py
ViewVC logotype

Contents of /trunk/pycad/test/python/run_pycad_test.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4008 - (show annotations)
Tue Oct 2 04:33:27 2012 UTC (6 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 243268 byte(s)
point coordinates are now written in %.14e rather then %f. This fixes accuracy problems when it comes to geometrically small domains.


1 # -*- coding: utf-8 -*-
2
3 ##############################################################################
4 #
5 # Copyright (c) 2003-2012 by University of Queensland
6 # http://www.uq.edu.au
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13 # Development since 2012 by School of Earth Sciences
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2012 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 import os
25 import sys
26 import unittest
27 import math
28 import numpy
29 from esys.pycad import *
30 from esys.pycad.design import Design as Design0
31 from esys.pycad.gmsh import Design as GMSHDesign
32 from esys.pycad.extras import layer_cake
33 # from esys.pycad.Triangle import Design as TriangleDesign
34
35 try:
36 PYCAD_TEST_DATA=os.environ['PYCAD_TEST_DATA']
37 except KeyError:
38 PYCAD_TEST_DATA='.'
39
40 try:
41 PYCAD_WORKDIR=os.environ['PYCAD_WORKDIR']
42 except KeyError:
43 PYCAD_WORKDIR='.'
44
45 #PYCAD_TEST_MESH_PATH=PYCAD_TEST_DATA+os.sep+"data_meshes"+os.sep
46 #PYCAD_WORKDIR_PATH=PYCAD_WORKDIR+os.sep
47
48
49
50 def _cross(x, y):
51 return numpy.array([x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0]])
52
53
54 class Test_PyCAD_Transformations(unittest.TestCase):
55 ABS_TOL=1.e-8
56 def __distance(self,x,y):
57 return math.sqrt(numpy.dot(x-y,x-y))
58 def test_Translation_x(self):
59 t=Translation([1,0,0])
60 s0=t([1,0,0])
61 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
62 self.assertTrue(self.__distance(s0,numpy.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
63 s1=t([0,1,0])
64 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
65 self.assertTrue(self.__distance(s1,numpy.array([1,1,0]))<self.ABS_TOL,"s1 is wrong.")
66 s2=t([0,0,1])
67 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
68 self.assertTrue(self.__distance(s2,numpy.array([1,0,1]))<self.ABS_TOL,"s2 is wrong.")
69 def test_Translation_y(self):
70 t=Translation([0,1,0])
71 s0=t([1,0,0])
72 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
73 self.assertTrue(self.__distance(s0,numpy.array([1,1,0]))<self.ABS_TOL,"s0 is wrong.")
74 s1=t([0,1,0])
75 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
76 self.assertTrue(self.__distance(s1,numpy.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
77 s2=t([0,0,1])
78 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
79 self.assertTrue(self.__distance(s2,numpy.array([0,1,1]))<self.ABS_TOL,"s2 is wrong.")
80 def test_Translation_z(self):
81 t=Translation([0,0,1])
82 s0=t([1,0,0])
83 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
84 self.assertTrue(self.__distance(s0,numpy.array([1,0,1]))<self.ABS_TOL,"s0 is wrong.")
85 s1=t([0,1,0])
86 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
87 self.assertTrue(self.__distance(s1,numpy.array([0,1,1]))<self.ABS_TOL,"s1 is wrong.")
88 s2=t([0,0,1])
89 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
90 self.assertTrue(self.__distance(s2,numpy.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
91 def test_Dilation_0_two(self):
92 t=Dilation(2.)
93 s0=t([1,0,0])
94 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
95 self.assertTrue(self.__distance(s0,numpy.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
96 s1=t([0,1,0])
97 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
98 self.assertTrue(self.__distance(s1,numpy.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
99 s2=t([0,0,1])
100 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
101 self.assertTrue(self.__distance(s2,numpy.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
102 def test_Dilation_0_half(self):
103 t=Dilation(0.5)
104 s0=t([1,0,0])
105 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
106 self.assertTrue(self.__distance(s0,numpy.array([0.5,0,0]))<self.ABS_TOL,"s0 is wrong.")
107 s1=t([0,1,0])
108 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
109 self.assertTrue(self.__distance(s1,numpy.array([0,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
110 s2=t([0,0,1])
111 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
112 self.assertTrue(self.__distance(s2,numpy.array([0,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
113 def test_Dilation_x_two(self):
114 t=Dilation(2.,[1.,0.,0.])
115 s0=t([1,0,0])
116 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
117 self.assertTrue(self.__distance(s0,numpy.array([1,0,0]))<self.ABS_TOL,"s0 is wrong.")
118 s0_1=t([0,0,0])
119 self.assertTrue(isinstance(s0_1,numpy.ndarray),"s0_1 is not an ndarray object.")
120 self.assertTrue(self.__distance(s0_1,numpy.array([-1.,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
121 s1=t([0,1,0])
122 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
123 self.assertTrue(self.__distance(s1,numpy.array([-1,2,0]))<self.ABS_TOL,"s1 is wrong.")
124 s2=t([0,0,1])
125 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
126 self.assertTrue(self.__distance(s2,numpy.array([-1.,0,2]))<self.ABS_TOL,"s2 is wrong.")
127 def test_Dilation_x_half(self):
128 t=Dilation(0.5,[1.,0.,0.])
129 s0=t([1,0,0])
130 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
131 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0]))<self.ABS_TOL,"s0 is wrong.")
132 s0_1=t([0,0,0])
133 self.assertTrue(isinstance(s0_1,numpy.ndarray),"s0_1 is not an ndarray object.")
134 self.assertTrue(self.__distance(s0_1,numpy.array([.5,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
135 s1=t([0,1,0])
136 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
137 self.assertTrue(self.__distance(s1,numpy.array([0.5,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
138 s2=t([0,0,1])
139 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
140 self.assertTrue(self.__distance(s2,numpy.array([0.5,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
141 def test_Dilation_y_two(self):
142 t=Dilation(2.,[0.,1.,0.])
143 s0=t([1,0,0])
144 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
145 self.assertTrue(self.__distance(s0,numpy.array([2.,-1.,0]))<self.ABS_TOL,"s0 is wrong.")
146 s1_1=t([0,0,0])
147 self.assertTrue(isinstance(s1_1,numpy.ndarray),"s1_1 is not an ndarray object.")
148 self.assertTrue(self.__distance(s1_1,numpy.array([0.,-1.,0]))<self.ABS_TOL,"s1_1 is wrong.")
149 s1=t([0,1,0])
150 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
151 self.assertTrue(self.__distance(s1,numpy.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
152 s2=t([0,0,1])
153 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
154 self.assertTrue(self.__distance(s2,numpy.array([0.,-1.,2]))<self.ABS_TOL,"s2 is wrong.")
155 def test_Dilation_y_half(self):
156 t=Dilation(0.5,[0.,1.,0.])
157 s0=t([1,0,0])
158 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
159 self.assertTrue(self.__distance(s0,numpy.array([0.5,0.5,0]))<self.ABS_TOL,"s0 is wrong.")
160 s1_1=t([0,0,0])
161 self.assertTrue(isinstance(s1_1,numpy.ndarray),"s1_1 is not an ndarray object.")
162 self.assertTrue(self.__distance(s1_1,numpy.array([0,0.5,0]))<self.ABS_TOL,"s1_1 is wrong.")
163 s1=t([0,1,0])
164 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
165 self.assertTrue(self.__distance(s1,numpy.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
166 s2=t([0,0,1])
167 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
168 self.assertTrue(self.__distance(s2,numpy.array([0.,0.5,0.5]))<self.ABS_TOL,"s2 is wrong.")
169 def test_Dilation_z_two(self):
170 t=Dilation(2.,[0.,0.,1.])
171 s0=t([1,0,0])
172 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
173 self.assertTrue(self.__distance(s0,numpy.array([2.,0.,-1.]))<self.ABS_TOL,"s0 is wrong.")
174 s2_1=t([0,0,0])
175 self.assertTrue(isinstance(s2_1,numpy.ndarray),"s2_1 is not an ndarray object.")
176 self.assertTrue(self.__distance(s2_1,numpy.array([0.,0.,-1.]))<self.ABS_TOL,"s2_1 is wrong.")
177 s1=t([0,1,0])
178 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
179 self.assertTrue(self.__distance(s1,numpy.array([0.,2.,-1.]))<self.ABS_TOL,"s1 is wrong.")
180 s2=t([0,0,1])
181 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
182 self.assertTrue(self.__distance(s2,numpy.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
183 def test_Dilation_z_half(self):
184 t=Dilation(0.5,[0.,0.,1.])
185 s0=t([1,0,0])
186 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
187 self.assertTrue(self.__distance(s0,numpy.array([0.5,0.,0.5]))<self.ABS_TOL,"s0 is wrong.")
188 s2_1=t([0,0,0])
189 self.assertTrue(isinstance(s2_1,numpy.ndarray),"s2_1 is not an ndarray object.")
190 self.assertTrue(self.__distance(s2_1,numpy.array([0,0,0.5]))<self.ABS_TOL,"s2_1 is wrong.")
191 s1=t([0,1,0])
192 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
193 self.assertTrue(self.__distance(s1,numpy.array([0.,0.5,0.5]))<self.ABS_TOL,"s1 is wrong.")
194 s2=t([0,0,1])
195 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
196 self.assertTrue(self.__distance(s2,numpy.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
197 def test_Reflection_x_offset0(self):
198 t=Reflection([1.,0.,0.])
199 s0=t([1,0,0])
200 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
201 self.assertTrue(self.__distance(s0,numpy.array([-1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
202 s1=t([0,1,0])
203 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
204 self.assertTrue(self.__distance(s1,numpy.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
205 s2=t([0,0,1])
206 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
207 self.assertTrue(self.__distance(s2,numpy.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
208 s=t([1,2,3])
209 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
210 self.assertTrue(self.__distance(s,numpy.array([-1.,2,3]))<self.ABS_TOL,"s is wrong.")
211 def test_Reflection_x_offset2(self):
212 t=Reflection([-2.,0.,0.],offset=-4)
213 s0=t([1,0,0])
214 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
215 self.assertTrue(self.__distance(s0,numpy.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
216 s1=t([0,1,0])
217 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
218 self.assertTrue(self.__distance(s1,numpy.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
219 s2=t([0,0,1])
220 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
221 self.assertTrue(self.__distance(s2,numpy.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
222 s=t([1,2,3])
223 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
224 self.assertTrue(self.__distance(s,numpy.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
225 def test_Reflection_x_offset2_vector(self):
226 t=Reflection([1.,0.,0.],offset=[2,0,0])
227 s0=t([1,0,0])
228 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
229 self.assertTrue(self.__distance(s0,numpy.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
230 s1=t([0,1,0])
231 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
232 self.assertTrue(self.__distance(s1,numpy.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
233 s2=t([0,0,1])
234 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
235 self.assertTrue(self.__distance(s2,numpy.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
236 s=t([1,2,3])
237 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
238 self.assertTrue(self.__distance(s,numpy.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
239 def test_Reflection_y_offset0(self):
240 t=Reflection([0.,1.,0.])
241 s0=t([1,0,0])
242 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
243 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
244 s1=t([0,1,0])
245 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
246 self.assertTrue(self.__distance(s1,numpy.array([0,-1,0]))<self.ABS_TOL,"s1 is wrong.")
247 s2=t([0,0,1])
248 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
249 self.assertTrue(self.__distance(s2,numpy.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
250 s=t([1,2,3])
251 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
252 self.assertTrue(self.__distance(s,numpy.array([1.,-2,3]))<self.ABS_TOL,"s is wrong.")
253 def test_Reflection_y_offset2(self):
254 t=Reflection([0.,-2.,0.],offset=-4)
255 s0=t([1,0,0])
256 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
257 self.assertTrue(self.__distance(s0,numpy.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
258 s1=t([0,1,0])
259 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
260 self.assertTrue(self.__distance(s1,numpy.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
261 s2=t([0,0,1])
262 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
263 self.assertTrue(self.__distance(s2,numpy.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
264 s=t([1,2,3])
265 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
266 self.assertTrue(self.__distance(s,numpy.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
267 def test_Reflection_y_offset2_vector(self):
268 t=Reflection([0.,1.,0.],offset=[0,2,0])
269 s0=t([1,0,0])
270 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
271 self.assertTrue(self.__distance(s0,numpy.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
272 s1=t([0,1,0])
273 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
274 self.assertTrue(self.__distance(s1,numpy.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
275 s2=t([0,0,1])
276 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
277 self.assertTrue(self.__distance(s2,numpy.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
278 s=t([1,2,3])
279 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
280 self.assertTrue(self.__distance(s,numpy.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
281 def test_Reflection_z_offset0(self):
282 t=Reflection([0.,0.,1.])
283 s0=t([1,0,0])
284 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
285 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
286 s1=t([0,1,0])
287 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
288 self.assertTrue(self.__distance(s1,numpy.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
289 s2=t([0,0,1])
290 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
291 self.assertTrue(self.__distance(s2,numpy.array([0,0,-1]))<self.ABS_TOL,"s2 is wrong.")
292 s=t([1,2,3])
293 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
294 self.assertTrue(self.__distance(s,numpy.array([1.,2,-3]))<self.ABS_TOL,"s is wrong.")
295 def test_Reflection_z_offset2(self):
296 t=Reflection([0.,0.,-2.],offset=-4)
297 s0=t([1,0,0])
298 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
299 self.assertTrue(self.__distance(s0,numpy.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
300 s1=t([0,1,0])
301 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
302 self.assertTrue(self.__distance(s1,numpy.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
303 s2=t([0,0,1])
304 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
305 self.assertTrue(self.__distance(s2,numpy.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
306 s=t([1,2,3])
307 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
308 self.assertTrue(self.__distance(s,numpy.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
309 def test_Reflection_z_offset2_vector(self):
310 t=Reflection([0.,0.,1.],offset=[0,0,2])
311 s0=t([1,0,0])
312 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
313 self.assertTrue(self.__distance(s0,numpy.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
314 s1=t([0,1,0])
315 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
316 self.assertTrue(self.__distance(s1,numpy.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
317 s2=t([0,0,1])
318 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
319 self.assertTrue(self.__distance(s2,numpy.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
320 s=t([1,2,3])
321 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
322 self.assertTrue(self.__distance(s,numpy.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
323 def test_Rotatation_x_90_0(self):
324 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=90*DEG)
325 s0=t([1,0,0])
326 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
327 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
328 s1=t([0,1,0])
329 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
330 self.assertTrue(self.__distance(s1,numpy.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.")
331 s2=t([0,0,1])
332 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
333 self.assertTrue(self.__distance(s2,numpy.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.")
334 def test_Rotatation_x_30_0(self):
335 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
336 s0=t([1,0,0])
337 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
338 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
339 s1=t([0,1,0])
340 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
341 self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
342 self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
343 self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")
344 s2=t([0,0,1])
345 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
346 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
347 self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
348 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")
349 def test_Rotatation_x_330_0(self):
350 t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
351 s0=t([1,0,0])
352 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
353 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
354 s1=t([0,1,0])
355 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
356 self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
357 self.assertTrue(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
358 self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
359 s2=t([0,0,1])
360 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
361 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
362 self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
363 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
364 def test_Rotatation_x_90(self):
365 t=Rotatation(axis=[-1.,0.,0.],point=[2.,0.,0.],angle=90*DEG)
366 s0=t([1,0,0])
367 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
368 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
369 s1=t([0,1,0])
370 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
371 self.assertTrue(self.__distance(s1,numpy.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.")
372 s2=t([0,0,1])
373 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
374 self.assertTrue(self.__distance(s2,numpy.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.")
375 def test_Rotatation_x_30(self):
376 t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
377 s0=t([1,0,0])
378 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
379 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
380 s1=t([0,1,0])
381 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
382 self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
383 self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
384 self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")
385 s2=t([0,0,1])
386 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
387 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
388 self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
389 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")
390 def test_Rotatation_x_330(self):
391 t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
392 s0=t([1,0,0])
393 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
394 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
395 s1=t([0,1,0])
396 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
397 self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
398 self.assertTrue(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
399 self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
400 s2=t([0,0,1])
401 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
402 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
403 self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
404 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
405 def test_Rotatation_y_90_0(self):
406 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=90*DEG)
407 s0=t([1,0,0])
408 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
409 self.assertTrue(self.__distance(s0,numpy.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.")
410 s1=t([0,5,0])
411 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
412 self.assertTrue(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
413 s2=t([0,0,1])
414 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
415 self.assertTrue(self.__distance(s2,numpy.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
416 def test_Rotatation_y_30_0(self):
417 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=30*DEG)
418 s0=t([1,0,0])
419 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
420 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
421 self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
422 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")
423 s1=t([0,5,0])
424 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
425 self.assertTrue(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
426 s2=t([0,0,1])
427 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
428 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
429 self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
430 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")
431 def test_Rotatation_y_330_0(self):
432 t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=330*DEG)
433 s0=t([1,0,0])
434 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
435 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
436 self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
437 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
438 s1=t([0,1,0])
439 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
440 self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
441 s2=t([0,0,1])
442 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
443 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
444 self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
445 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
446 def test_Rotatation_y_90(self):
447 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=90*DEG)
448 s0=t([1,0,0])
449 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
450 self.assertTrue(self.__distance(s0,numpy.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.")
451 s1=t([0,5,0])
452 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
453 self.assertTrue(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
454 s2=t([0,0,1])
455 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
456 self.assertTrue(self.__distance(s2,numpy.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
457 def test_Rotatation_y_30(self):
458 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=30*DEG)
459 s0=t([1,0,0])
460 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
461 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
462 self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
463 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")
464 s1=t([0,1,0])
465 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
466 self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
467 s2=t([0,0,1])
468 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
469 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
470 self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
471 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")
472 def test_Rotatation_y_330(self):
473 t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=330*DEG)
474 s0=t([1,0,0])
475 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
476 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
477 self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
478 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
479 s1=t([0,1,0])
480 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
481 self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
482 s2=t([0,0,1])
483 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
484 self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
485 self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
486 self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
487 def test_Rotatation_z_90_0(self):
488 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=90*DEG)
489 s0=t([1,0,0])
490 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
491 self.assertTrue(self.__distance(s0,numpy.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.")
492 s1=t([0,5,0])
493 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
494 self.assertTrue(self.__distance(s1,numpy.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
495 s2=t([0,0,1])
496 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
497 self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
498 def test_Rotatation_z_30_0(self):
499 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=30*DEG)
500 s0=t([1,0,0])
501 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
502 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
503 self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
504 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")
505 s1=t([0,5,0])
506 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
507 self.assertTrue(abs(numpy.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
508 self.assertTrue(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
509 self.assertTrue(numpy.dot(_cross(s1,[0,5,0]),numpy.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")
510 s2=t([0,0,1])
511 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
512 self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
513 def test_Rotatation_z_330_0(self):
514 t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=330*DEG)
515 s0=t([1,0,0])
516 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
517 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
518 self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
519 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
520 s1=t([0,5,0])
521 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
522 self.assertTrue(abs(numpy.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
523 self.assertTrue(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
524 self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
525 def test_Rotatation_z_90(self):
526 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=90*DEG)
527 s0=t([1,0,0])
528 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
529 self.assertTrue(self.__distance(s0,numpy.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.")
530 s1=t([0,5,0])
531 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
532 self.assertTrue(self.__distance(s1,numpy.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
533 s2=t([0,0,1])
534 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
535 self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
536 def test_Rotatation_z_30(self):
537 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=30*DEG)
538 s0=t([1,0,0])
539 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
540 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
541 self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
542 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")
543 s1=t([0,1,0])
544 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
545 self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
546 self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
547 self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")
548 s2=t([0,0,1])
549 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
550 self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
551 def test_Rotatation_z_330(self):
552 t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=330*DEG)
553 s0=t([1,0,0])
554 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
555 self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
556 self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
557 self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
558 s1=t([0,1,0])
559 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
560 self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
561 self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
562 self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
563 s2=t([0,0,1])
564 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
565 self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
566 def test_Rotatation_x_90_1(self):
567 t=Rotatation(point=[0.,0.,1.],axis=[1.,0.,0.],angle=90*DEG)
568 s0=t([1,0,0])
569 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
570 self.assertTrue(self.__distance(s0,numpy.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.")
571 s1=t([0,1,0])
572 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
573 self.assertTrue(self.__distance(s1,numpy.array([0.,1,2.]))<self.ABS_TOL,"s1 is wrong.")
574 s2=t([0,0,1])
575 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
576 self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
577 def test_Rotatation_y_90_1(self):
578 t=Rotatation(point=[1.,0.,0.],axis=[0.,1.,0.],angle=90*DEG)
579 s0=t([1,0,0])
580 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
581 self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
582 s1=t([0,1,0])
583 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
584 self.assertTrue(self.__distance(s1,numpy.array([1.,1,1.]))<self.ABS_TOL,"s1 is wrong.")
585 s2=t([0,0,1])
586 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
587 self.assertTrue(self.__distance(s2,numpy.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
588 def test_Rotatation_z_90_1(self):
589 t=Rotatation(point=[0.,1.,0.],axis=[0.,0.,1.],angle=90*DEG)
590 s0=t([1,0,0])
591 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
592 self.assertTrue(self.__distance(s0,numpy.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.")
593 s1=t([0,1,0])
594 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
595 self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
596 s2=t([0,0,1])
597 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
598 self.assertTrue(self.__distance(s2,numpy.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.")
599 def test_Rotatation_diag_90_0(self):
600 t=Rotatation(axis=[1.,1.,1.],angle=90*DEG)
601 s0=t([1,-1,0])
602 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
603 self.assertTrue(abs(numpy.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.")
604 self.assertTrue(abs(numpy.dot(s0,numpy.array([1,-1,0])))<self.ABS_TOL,"s0 angle is wrong.")
605 self.assertTrue(numpy.dot(_cross(s0,[1,-1,0]),numpy.array([1.,1.,1.]))<0.,"s0 has wrong orientation.")
606 s1=t([0,1,-1])
607 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
608 self.assertTrue(abs(numpy.dot(s1,s1)-2.)<self.ABS_TOL,"s1 length is wrong.")
609 self.assertTrue(abs(numpy.dot(s1,numpy.array([0,1,-1])))<self.ABS_TOL,"s1 angle is wrong.")
610 self.assertTrue(numpy.dot(_cross(s1,[0,1,-1]),numpy.array([1.,1.,1.]))<0.,"s1 has wrong orientation.")
611 s2=t([-1,0,1])
612 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
613 self.assertTrue(abs(numpy.dot(s2,s2)-2.)<self.ABS_TOL,"s2 length is wrong.")
614 self.assertTrue(abs(numpy.dot(s2,numpy.array([-1,0,1])))<self.ABS_TOL,"s2 angle is wrong.")
615 self.assertTrue(numpy.dot(_cross(s2,[-1,0,1]),numpy.array([1.,1.,1.]))<0.,"s2 has wrong orientation.")
616 s3=t([1,1,1])
617 self.assertTrue(isinstance(s3,numpy.ndarray),"s3 is not an ndarray object.")
618 self.assertTrue(self.__distance(s3,numpy.array([1.,1,1.]))<self.ABS_TOL,"s3 is wrong.")
619
620 class Test_PyCAD_Primitives(unittest.TestCase):
621 def setUp(self):
622 resetGlobalPrimitiveIdCounter()
623
624 def test_Primitive(self):
625 p=Primitive()
626
627 id=p.getID()
628 self.assertTrue(isinstance(id,int),"id number is not an integer")
629 self.assertTrue(not id==Primitive().getID(),"id number is not unique")
630
631 self.assertTrue(p==p.getUnderlyingPrimitive(),"getUnderlyingPrimitive does not return self.")
632
633 def test_ReversePrimitive(self):
634 p=Primitive()
635
636 rp=ReversePrimitive(p)
637 self.assertTrue(p.getID()==rp.getID(),"reverse primitive does not have same id like source")
638 self.assertTrue(p==rp.getUnderlyingPrimitive(),"getUnderlyingPrimitive does return source.")
639 self.assertTrue(p == -rp,"reverse or reverse does not return source.")
640
641 def test_Point(self):
642 p=Point(1.,2.,3.,local_scale=9.)
643
644 id=p.getID()
645 self.assertTrue(isinstance(id,int),"id number is not an integer")
646 self.assertTrue(not id==Primitive().getID(),"id number is not unique")
647
648 # check reverse point
649 self.assertTrue(p == -p,"reverse is not working.")
650
651 # check history:
652 hs=p.getPrimitives()
653 self.assertTrue(len(hs)==1,"history must have length 1.")
654 self.assertTrue(p in hs,"history must contain point p")
655
656 # check incolved points:
657 ps=p.getConstructionPoints()
658 self.assertTrue(len(ps)==1,"point set must have length 1.")
659 self.assertTrue(p in ps,"point set must contain point p")
660
661 # check coordinates:
662 c=p.getCoordinates()
663 self.assertTrue(isinstance(c,numpy.ndarray),"coordinates are not an ndarray object.")
664 self.assertTrue(c[0]==1.,"x coordinate is not 1.")
665 self.assertTrue(c[1]==2.,"y coordinate is not 2.")
666 self.assertTrue(c[2]==3.,"z coordinate is not 3.")
667
668 # reset coordinates:
669 p.setCoordinates([-1.,-2.,-3.])
670 c=p.getCoordinates()
671 self.assertTrue(isinstance(c,numpy.ndarray),"new coordinates are not an ndarray object.")
672 self.assertTrue(c[0]==-1.,"new x coordinate is not -1.")
673 self.assertTrue(c[1]==-2.,"new y coordinate is not -2.")
674 self.assertTrue(c[2]==-3.,"new z coordinate is not -3.")
675
676 # check for a colocated point:
677 self.assertTrue(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.")
678 self.assertTrue(not p.isColocated(numpy.array([-1.,-2.,-3.])),"colocation with ndarray representation not detected.")
679 self.assertTrue(not p.isColocated(Point(1.,-2.,-3.)),"false colocation detected.")
680 self.assertTrue(not p.isColocated(Point(0.,0.,0.)),"false colocation with origin detected.")
681
682 # check for local length scale
683 l=p.getLocalScale()
684 self.assertTrue(l==9.,"refinement scale is not 9.")
685
686 # check for new local length scale
687 p.setLocalScale(3.)
688 l=p.getLocalScale()
689 self.assertTrue(l==3.,"new refinement scale is not 3.")
690
691 # negative value shouldn't work.
692 self.assertRaises(ValueError,p.setLocalScale,-3.)
693
694 # copy:
695 an_other_p=p.copy()
696 self.assertTrue(isinstance(an_other_p ,Point),"copy is not a point")
697 self.assertTrue(not an_other_p.getID() == p.getID(),"copy has same Id")
698 self.assertTrue(p.isColocated(an_other_p),"p is not colocated with its copy.")
699 self.assertTrue(an_other_p.isColocated(p),"the copy is not colocated with p.")
700 self.assertTrue(an_other_p.getLocalScale()==3.,"copy has wrong local scale.")
701
702 # modify by Transformation:
703 p.modifyBy(Dilation(-1))
704 self.assertTrue(p.isColocated(Point(1.,2.,3.)),"in-place transformation failed")
705
706 # apply Transformation:
707 dil_p=p.apply(Dilation(4))
708 self.assertTrue(dil_p.isColocated(Point(4.,8.,12.)),"applying transformation failed")
709 self.assertTrue(not dil_p.getID() == p.getID(),"transformed point has same Id")
710 self.assertTrue(dil_p.getLocalScale()==3.,"transformed point has wrong local scale.")
711
712 # overloaded add:
713 shift_p=p+[1,1,1]
714 self.assertTrue(shift_p.isColocated(Point(2,3.,4)),"applying shift by list failed")
715 self.assertTrue(not shift_p.getID() == p.getID(),"shift by list has same Id")
716 self.assertTrue(shift_p.getLocalScale()==3.,"shift by list has wrong local scale.")
717
718 shift_p=p+numpy.array([1,1,1])
719 self.assertTrue(shift_p.isColocated(Point(2,3.,4)),"applying shift by ndarray failed")
720 self.assertTrue(not shift_p.getID() == p.getID(),"shift by ndarray has same Id")
721 self.assertTrue(shift_p.getLocalScale()==3.,"shift by ndarray has wrong local scale.")
722 # overloaded minus
723 shift_p=p-[1,1,1]
724 self.assertTrue(shift_p.isColocated(Point(0,1,2.)),"applying shift by -list failed")
725 self.assertTrue(not shift_p.getID() == p.getID(),"shift by -list has same Id")
726 self.assertTrue(shift_p.getLocalScale()==3.,"shift by -list has wrong local scale.")
727
728 shift_p=p-numpy.array([1,1,1])
729 self.assertTrue(shift_p.isColocated(Point(0,1,2.)),"applying shift by -ndarray failed")
730 self.assertTrue(not shift_p.getID() == p.getID(),"shift by -ndarray has same Id")
731 self.assertTrue(shift_p.getLocalScale()==3.,"shift by -ndarray has wrong local scale.")
732 # overloaded inplace add:
733 p+=[1,1,1]
734 self.assertTrue(p.isColocated(Point(2,3.,4)),"modification by list shift failed")
735
736 p+=numpy.array([1,1,1])
737 self.assertTrue(p.isColocated(Point(3,4,5)),"modification by ndarray shift failed")
738
739 # overloaded inplace add:
740 p-=[1,1,1]
741 self.assertTrue(p.isColocated(Point(2,3,4)),"modification by -list shift failed")
742
743 p-=numpy.array([1,1,1])
744 self.assertTrue(p.isColocated(Point(1,2.,3)),"modification by -ndarray shift failed")
745
746 #overloaded multiplication:
747 mult_p=2*p
748 self.assertTrue(mult_p.isColocated(Point(2,4,6)),"applying int factor failed")
749 self.assertTrue(not mult_p.getID() == p.getID(),"shift by int factor has same Id")
750 self.assertTrue(mult_p.getLocalScale()==3.,"shift by int factor has wrong local scale.")
751
752 mult_p=2.*p
753 self.assertTrue(mult_p.isColocated(Point(2,4,6)),"applying float factor failed")
754 self.assertTrue(not mult_p.getID() == p.getID(),"shift by float factor has same Id")
755 self.assertTrue(mult_p.getLocalScale()==3.,"shift by float factor has wrong local scale.")
756
757 mult_p=Dilation(2)*p
758 self.assertTrue(mult_p.isColocated(Point(2,4,6)),"applying Dilation factor failed")
759 self.assertTrue(not mult_p.getID() == p.getID(),"shift by Dilation factor has same Id")
760 self.assertTrue(mult_p.getLocalScale()==3.,"shift by Dilation factor has wrong local scale.")
761
762 #overloaded inplace multiplication:
763 p*=2
764 self.assertTrue(p.isColocated(Point(2,4,6)),"applying in-place int factor failed")
765
766 p*=2.
767 self.assertTrue(p.isColocated(Point(4,8,12)),"applying in-place float factor failed")
768
769 p*=Dilation(2)
770 self.assertTrue(p.isColocated(Point(8,16,24)),"applying in-place Dilation factor failed")
771
772 def test_Spline(self):
773 p0=Point(0,0,0,0.1)
774 p1=Point(1,1,1,0.2)
775 p2=Point(2,2,2,0.3)
776 p3=Point(3,3,3,0.4)
777 p4=Point(1,2,3)
778
779 self.assertRaises(ValueError,Spline,p0)
780 c=Spline(p0,p1,p2,p3)
781
782 self.assertTrue(len(c) == 4, "wrong spline curve length")
783 self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
784 self.assertTrue(c.getEndPoint()==p3, "wrong end point of spline curve")
785
786 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
787 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
788
789 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
790 self.assertTrue(not c.isColocated(Spline(p0,p1,p2)),"spline is colocated with spline of different length.")
791 self.assertTrue(not c.isColocated(Spline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
792 self.assertTrue(c.isColocated(Spline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
793 self.assertTrue(c.isColocated(Spline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
794 self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
795
796 co=c.getControlPoints()
797 self.assertTrue(co[0]==p0, "1st control point is wrong.")
798 self.assertTrue(co[1]==p1, "2nd control point is wrong.")
799 self.assertTrue(co[2]==p2, "3rd control point is wrong.")
800 self.assertTrue(co[3]==p3, "4th control point is wrong.")
801
802 c.setLocalScale(3.)
803 co=c.getControlPoints()
804 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
805 self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
806 self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
807 self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
808
809 h=c.getPrimitives()
810 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
811 self.assertTrue(p0 in h, "missing p0 in history.")
812 self.assertTrue(p1 in h, "missing p1 in history.")
813 self.assertTrue(p2 in h, "missing p2 in history.")
814 self.assertTrue(p3 in h, "missing p3 in history.")
815 self.assertTrue(c in h, "missing spline curve in history.")
816
817 cp=c.copy()
818 cpcp=cp.getControlPoints()
819 self.assertTrue(not cp == c, "copy returns same spline curve.")
820 self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
821 self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
822 self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
823 self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
824 self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
825
826 c.modifyBy(Dilation(-1.))
827 cp=c.getControlPoints()
828 self.assertTrue(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
829 self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
830 self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
831 self.assertTrue(p2 == cp[2],"3rd new point after Dilation.")
832 self.assertTrue(p3 == cp[3],"4th new point after Dilation.")
833
834 dc=c.apply(Dilation(-1.))
835 dccp=dc.getControlPoints()
836 self.assertTrue(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
837 self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
838 self.assertTrue(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
839 self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
840 self.assertTrue(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
841 self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
842 self.assertTrue(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
843 self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
844 self.assertTrue(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
845
846 def test_ReverseSpline(self):
847 p0=Point(0,0,0,0.1)
848 p1=Point(1,1,1,0.2)
849 p2=Point(2,2,2,0.3)
850 p3=Point(3,3,3,0.4)
851 p4=Point(1,2,3)
852
853 CC0=Spline(p0,p1,p2,p3)
854 c=-CC0
855
856 self.assertTrue(len(c) == 4, "wrong reverse spline curve length")
857 self.assertTrue(c.getStartPoint()==p3, "wrong start point of reverse spline curve")
858 self.assertTrue(c.getEndPoint()==p0, "wrong end point of reverse spline curve")
859
860 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
861 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
862
863 self.assertTrue(not c.isColocated(p1),"reverse spline is colocated with point.")
864 self.assertTrue(not c.isColocated(Spline(p0,p1,p2)),"reverse spline is colocated with spline of different length.")
865 self.assertTrue(not c.isColocated(Spline(p0,p1,p4,p3)),"reverse spline is colocated with spline with different point.")
866 self.assertTrue(c.isColocated(Spline(p0,p1,p2,p3)),"reverse spline is not colocated with spline with same points but opposite direction.")
867 self.assertTrue(c.isColocated(Spline(p3,p2,p1,p0)),"reverse spline is not colocated with spline with same points.")
868 self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
869
870 co=c.getControlPoints()
871 self.assertTrue(co[0]==p3, "1st control point is wrong.")
872 self.assertTrue(co[1]==p2, "2nd control point is wrong.")
873 self.assertTrue(co[2]==p1, "3rd control point is wrong.")
874 self.assertTrue(co[3]==p0, "4th control point is wrong.")
875
876 c.setLocalScale(3.)
877 co=c.getControlPoints()
878 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
879 self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
880 self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
881 self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
882
883 h=c.getPrimitives()
884 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
885 self.assertTrue(p0 in h, "missing p0 in history.")
886 self.assertTrue(p1 in h, "missing p1 in history.")
887 self.assertTrue(p2 in h, "missing p2 in history.")
888 self.assertTrue(p3 in h, "missing p3 in history.")
889 self.assertTrue(CC0 in h, "missing spline curve in history.")
890
891 cp=c.copy()
892 cpcp=cp.getControlPoints()
893 self.assertTrue(not cp == c, "copy returns same spline curve.")
894 self.assertTrue(not cp == CC0, "copy returns same spline curve.")
895 self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
896 self.assertTrue(not p3 == cpcp[0],"1st point of deep copy and souce are the same.")
897 self.assertTrue(not p2 == cpcp[1],"2st point of deep copy and source are the same.")
898 self.assertTrue(not p1 == cpcp[2],"3st point of deep copy and source are the same.")
899 self.assertTrue(not p0 == cpcp[3],"4st point of deep copy and source are the same.")
900
901 c.modifyBy(Dilation(-1.))
902 cp=c.getControlPoints()
903 self.assertTrue(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
904 self.assertTrue(p3 == cp[0],"1st new point after Dilation.")
905 self.assertTrue(p2 == cp[1],"2nd new point after Dilation.")
906 self.assertTrue(p1 == cp[2],"3rd new point after Dilation.")
907 self.assertTrue(p0 == cp[3],"4th new point after Dilation.")
908
909 dc=c.apply(Dilation(-1.))
910 dccp=dc.getControlPoints()
911 self.assertTrue(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
912 self.assertTrue(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
913 self.assertTrue(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
914 self.assertTrue(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
915 self.assertTrue(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
916
917 def test_BezierCurve(self):
918 p0=Point(0,0,0,0.1)
919 p1=Point(1,1,1,0.2)
920 p2=Point(2,2,2,0.3)
921 p3=Point(3,3,3,0.4)
922 p4=Point(1,2,3)
923
924 self.assertRaises(ValueError,BezierCurve,p0)
925 c=BezierCurve(p0,p1,p2,p3)
926
927 self.assertTrue(len(c) == 4, "wrong spline curve length")
928 self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
929 self.assertTrue(c.getEndPoint()==p3, "wrong end point of spline curve")
930
931 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
932 self.assertTrue(not c.isColocated(BezierCurve(p0,p1,p2)),"spline is colocated with spline of different length.")
933 self.assertTrue(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
934 self.assertTrue(c.isColocated(BezierCurve(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
935 self.assertTrue(c.isColocated(BezierCurve(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
936 self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
937
938 co=c.getControlPoints()
939 self.assertTrue(co[0]==p0, "1st control point is wrong.")
940 self.assertTrue(co[1]==p1, "2nd control point is wrong.")
941 self.assertTrue(co[2]==p2, "3rd control point is wrong.")
942 self.assertTrue(co[3]==p3, "4th control point is wrong.")
943
944 c.setLocalScale(3.)
945 co=c.getControlPoints()
946 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
947 self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
948 self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
949 self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
950
951 h=c.getPrimitives()
952 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
953 self.assertTrue(p0 in h, "missing p0 in history.")
954 self.assertTrue(p1 in h, "missing p1 in history.")
955 self.assertTrue(p2 in h, "missing p2 in history.")
956 self.assertTrue(p3 in h, "missing p3 in history.")
957 self.assertTrue(c in h, "missing spline curve in history.")
958
959 cp=c.copy()
960 cpcp=cp.getControlPoints()
961 self.assertTrue(not cp == c, "copy returns same spline curve.")
962 self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
963 self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
964 self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
965 self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
966 self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
967
968 c.modifyBy(Dilation(-1.))
969 cp=c.getControlPoints()
970 self.assertTrue(c.isColocated(BezierCurve(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
971 self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
972 self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
973 self.assertTrue(p2 == cp[2],"3rd new point after Dilation.")
974 self.assertTrue(p3 == cp[3],"4th new point after Dilation.")
975
976 dc=c.apply(Dilation(-1.))
977 dccp=dc.getControlPoints()
978 self.assertTrue(dc.isColocated(BezierCurve(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
979 self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
980 self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
981 self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
982 self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
983
984 def test_BSpline(self):
985 p0=Point(0,0,0,0.1)
986 p1=Point(1,1,1,0.2)
987 p2=Point(2,2,2,0.3)
988 p3=Point(3,3,3,0.4)
989 p4=Point(1,2,3)
990
991 self.assertRaises(ValueError,BSpline,p0)
992 c=BSpline(p0,p1,p2,p3)
993
994 self.assertTrue(len(c) == 4, "wrong spline curve length")
995 self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
996 self.assertTrue(c.getEndPoint()==p3, "wrong end point of spline curve")
997
998 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
999 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1000
1001 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
1002 self.assertTrue(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1003 self.assertTrue(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1004 self.assertTrue(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1005 self.assertTrue(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1006 self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1007
1008 co=c.getControlPoints()
1009 self.assertTrue(co[0]==p0, "1st control point is wrong.")
1010 self.assertTrue(co[1]==p1, "2nd control point is wrong.")
1011 self.assertTrue(co[2]==p2, "3rd control point is wrong.")
1012 self.assertTrue(co[3]==p3, "4th control point is wrong.")
1013
1014 c.setLocalScale(3.)
1015 co=c.getControlPoints()
1016 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1017 self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1018 self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1019 self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1020
1021 h=c.getPrimitives()
1022 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
1023 self.assertTrue(p0 in h, "missing p0 in history.")
1024 self.assertTrue(p1 in h, "missing p1 in history.")
1025 self.assertTrue(p2 in h, "missing p2 in history.")
1026 self.assertTrue(p3 in h, "missing p3 in history.")
1027 self.assertTrue(c in h, "missing spline curve in history.")
1028
1029 cp=c.copy()
1030 cpcp=cp.getControlPoints()
1031 self.assertTrue(not cp == c, "copy returns same spline curve.")
1032 self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1033 self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1034 self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1035 self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1036 self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1037
1038 c.modifyBy(Dilation(-1.))
1039 cp=c.getControlPoints()
1040 self.assertTrue(c.isColocated(BSpline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
1041 self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
1042 self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
1043 self.assertTrue(p2 == cp[2],"3rd new point after Dilation.")
1044 self.assertTrue(p3 == cp[3],"4th new point after Dilation.")
1045
1046 dc=c.apply(Dilation(-1.))
1047 dccp=dc.getControlPoints()
1048 self.assertTrue(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1049 self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1050 self.assertTrue(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1051 self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1052 self.assertTrue(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1053 self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1054 self.assertTrue(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1055 self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1056 self.assertTrue(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1057
1058 def test_ReverseBSpline(self):
1059 p0=Point(0,0,0,0.1)
1060 p1=Point(1,1,1,0.2)
1061 p2=Point(2,2,2,0.3)
1062 p3=Point(3,3,3,0.4)
1063 p4=Point(1,2,3)
1064
1065 CC0=BSpline(p0,p1,p2,p3)
1066 c=-CC0
1067
1068 self.assertTrue(len(c) == 4, "wrong spline curve length")
1069 self.assertTrue(c.getStartPoint()==p3, "wrong start point of spline curve")
1070 self.assertTrue(c.getEndPoint()==p0, "wrong end point of spline curve")
1071
1072 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1073 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1074
1075 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
1076 self.assertTrue(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1077 self.assertTrue(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1078 self.assertTrue(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1079 self.assertTrue(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1080 self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1081
1082 co=c.getControlPoints()
1083 self.assertTrue(co[0]==p3, "1st control point is wrong.")
1084 self.assertTrue(co[1]==p2, "2nd control point is wrong.")
1085 self.assertTrue(co[2]==p1, "3rd control point is wrong.")
1086 self.assertTrue(co[3]==p0, "4th control point is wrong.")
1087
1088 c.setLocalScale(3.)
1089 co=c.getControlPoints()
1090 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1091 self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1092 self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1093 self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1094
1095 h=c.getPrimitives()
1096 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
1097 self.assertTrue(p0 in h, "missing p0 in history.")
1098 self.assertTrue(p1 in h, "missing p1 in history.")
1099 self.assertTrue(p2 in h, "missing p2 in history.")
1100 self.assertTrue(p3 in h, "missing p3 in history.")
1101 self.assertTrue(CC0 in h, "missing spline curve in history.")
1102
1103 cp=c.copy()
1104 cpcp=cp.getControlPoints()
1105 self.assertTrue(not cp == c, "copy returns same spline curve.")
1106 self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1107 self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1108 self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1109 self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1110 self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1111
1112 c.modifyBy(Dilation(-1.))
1113 cp=c.getControlPoints()
1114 self.assertTrue(c.isColocated(BSpline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
1115 self.assertTrue(p3 == cp[0],"1st new point after Dilation.")
1116 self.assertTrue(p2 == cp[1],"2nd new point after Dilation.")
1117 self.assertTrue(p1 == cp[2],"3rd new point after Dilation.")
1118 self.assertTrue(p0 == cp[3],"4th new point after Dilation.")
1119
1120 dc=c.apply(Dilation(-1.))
1121 dccp=dc.getControlPoints()
1122 self.assertTrue(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1123 self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1124 self.assertTrue(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1125 self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1126 self.assertTrue(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1127 self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1128 self.assertTrue(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1129 self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1130 self.assertTrue(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1131
1132 def test_LineSegment(self):
1133 p0=Point(0,0,0,0.1)
1134 p1=Point(1,1,1,0.2)
1135 p4=Point(1,2,3)
1136
1137 self.assertRaises(TypeError,Line,p0)
1138 self.assertRaises(TypeError,Line,p0,p1,p4)
1139
1140 c=Line(p0,p1)
1141
1142 self.assertTrue(len(c) == 2, "wrong spline curve length")
1143 self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
1144 self.assertTrue(c.getEndPoint()==p1, "wrong end point of spline curve")
1145
1146 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1147 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1148
1149 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
1150 self.assertTrue(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1151 self.assertTrue(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1152 self.assertTrue(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1153 self.assertTrue(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1154
1155 co=c.getControlPoints()
1156 self.assertTrue(co[0]==p0, "1st control point is wrong.")
1157 self.assertTrue(co[1]==p1, "2nd control point is wrong.")
1158
1159 c.setLocalScale(3.)
1160 co=c.getControlPoints()
1161 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1162 self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1163
1164 h=c.getPrimitives()
1165 self.assertTrue(len(h) == 3, "number of primitives in history is wrong.")
1166 self.assertTrue(p0 in h, "missing p0 in history.")
1167 self.assertTrue(p1 in h, "missing p1 in history.")
1168 self.assertTrue(c in h, "missing spline curve in history.")
1169
1170 cp=c.copy()
1171 cpcp=cp.getControlPoints()
1172 self.assertTrue(not cp == c, "copy returns same spline curve.")
1173 self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1174 self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1175 self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1176
1177 c.modifyBy(Dilation(-1.))
1178 cp=c.getControlPoints()
1179 self.assertTrue(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1180 self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
1181 self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
1182
1183 dc=c.apply(Dilation(-1.))
1184 dccp=dc.getControlPoints()
1185 self.assertTrue(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1186 self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1187 self.assertTrue(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1188 self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1189 self.assertTrue(dccp[1].isColocated(Point(1,1,1)),"2st point of Dilation is is wrongly located.")
1190
1191 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1192 dc.setElementDistribution(10,0.2,False)
1193 d=dc.getElementDistribution()
1194 self.assertTrue(d[0] == 10, "number of element is wrong.")
1195 self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1196 self.assertTrue(d[2] == False, "bump flag wrong")
1197 dc.resetElementDistribution()
1198 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1199
1200
1201 def test_ReverseLineSegment(self):
1202 p0=Point(0,0,0,0.1)
1203 p1=Point(1,1,1,0.2)
1204 p4=Point(1,2,3)
1205
1206 self.assertRaises(TypeError,Line,p0)
1207 self.assertRaises(TypeError,Line,p0,p1,p4)
1208
1209 CC0=Line(p0,p1)
1210 c=-CC0
1211
1212 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1213 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1214
1215 self.assertTrue(len(c) == 2, "wrong spline curve length")
1216 self.assertTrue(c.getStartPoint()==p1, "wrong start point of spline curve")
1217 self.assertTrue(c.getEndPoint()==p0, "wrong end point of spline curve")
1218
1219 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
1220 self.assertTrue(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1221 self.assertTrue(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1222 self.assertTrue(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1223 self.assertTrue(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1224
1225 co=c.getControlPoints()
1226 self.assertTrue(co[0]==p1, "1st control point is wrong.")
1227 self.assertTrue(co[1]==p0, "2nd control point is wrong.")
1228
1229 c.setLocalScale(3.)
1230 co=c.getControlPoints()
1231 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1232 self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1233
1234 h=c.getPrimitives()
1235 self.assertTrue(len(h) == 3, "number of primitives in history is wrong.")
1236 self.assertTrue(p0 in h, "missing p0 in history.")
1237 self.assertTrue(p1 in h, "missing p1 in history.")
1238 self.assertTrue(CC0 in h, "missing spline curve in history.")
1239
1240 cp=c.copy()
1241 cpcp=cp.getControlPoints()
1242 self.assertTrue(not cp == c, "copy returns same spline curve.")
1243 self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1244 self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1245 self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1246
1247 c.modifyBy(Dilation(-1.))
1248 cp=c.getControlPoints()
1249 self.assertTrue(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1250 self.assertTrue(p1 == cp[0],"1st new point after Dilation.")
1251 self.assertTrue(p0 == cp[1],"2nd new point after Dilation.")
1252
1253 dc=c.apply(Dilation(-1.))
1254 dccp=dc.getControlPoints()
1255 self.assertTrue(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1256 self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1257 self.assertTrue(dccp[0].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1258 self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1259 self.assertTrue(dccp[1].isColocated(Point(0,0,0)),"2st point of Dilation is is wrongly located.")
1260
1261 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1262 dc.setElementDistribution(10,0.2,False)
1263 d=dc.getElementDistribution()
1264 self.assertTrue(d[0] == 10, "number of element is wrong.")
1265 self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1266 self.assertTrue(d[2] == False, "bump flag wrong")
1267 dc.resetElementDistribution()
1268 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1269
1270
1271 def test_Arc(self):
1272 center=Point(0,0,0,0.1)
1273 p_start=Point(1,1,1,0.2)
1274 p_end=Point(1,2,3)
1275 p4=Point(10,2,3)
1276
1277 self.assertRaises(TypeError,Arc,Primitive())
1278
1279 c=Arc(center,p_start,p_end)
1280
1281 self.assertTrue(c.getCenterPoint()==center, "wrong center point")
1282 self.assertTrue(c.getStartPoint()==p_start, "wrong start point")
1283 self.assertTrue(c.getEndPoint()==p_end, "wrong end point")
1284
1285 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1286 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1287
1288 self.assertTrue(not c.isColocated(p4),"spline is colocated with point.")
1289 self.assertTrue(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1290 self.assertTrue(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1291 self.assertTrue(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1292 self.assertTrue(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1293 self.assertTrue(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1294 self.assertTrue(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1295
1296 h=c.getPrimitives()
1297 self.assertTrue(len(h) == 4, "number of primitives in history is wrong.")
1298 self.assertTrue(center in h, "missing center in history.")
1299 self.assertTrue(p_start in h, "missing p_start in history.")
1300 self.assertTrue(p_end in h, "missing p_end in history.")
1301 self.assertTrue(c in h, "missing spline curve in history.")
1302
1303
1304 c.setLocalScale(3.)
1305 self.assertTrue(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1306 self.assertTrue(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1307 self.assertTrue(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1308
1309 cp=c.copy()
1310 self.assertTrue(isinstance(cp,Arc), "copy returns is not an arc.")
1311 self.assertTrue(not cp == c, "copy returns same arc.")
1312 self.assertTrue(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.")
1313 self.assertTrue(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1314 self.assertTrue(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1315 self.assertTrue(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1316
1317 c.modifyBy(Dilation(-1.))
1318 self.assertTrue(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1319 self.assertTrue(c.getCenterPoint() == center,"wrong center point after dilation.")
1320 self.assertTrue(c.getStartPoint() == p_start,"wrong start point after dilation.")
1321 self.assertTrue(c.getEndPoint() == p_end,"wrong end point after dilation.")
1322
1323 dc=c.apply(Dilation(-1.))
1324 self.assertTrue(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1325 self.assertTrue(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1326 self.assertTrue(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1327 self.assertTrue(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1328 self.assertTrue(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.")
1329 self.assertTrue(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1330 self.assertTrue(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.")
1331
1332 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1333 dc.setElementDistribution(10,0.2,False)
1334 d=dc.getElementDistribution()
1335 self.assertTrue(d[0] == 10, "number of element is wrong.")
1336 self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1337 self.assertTrue(d[2] == False, "bump flag wrong")
1338 dc.resetElementDistribution()
1339 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1340
1341
1342 def test_ReverseArc(self):
1343 center=Point(0,0,0,0.1)
1344 p_start=Point(1,1,1,0.2)
1345 p_end=Point(1,2,3)
1346 p4=Point(10,2,3)
1347
1348 self.assertRaises(TypeError,Arc,Primitive())
1349
1350 CC0=Arc(center,p_start,p_end)
1351 c=-CC0
1352
1353 self.assertTrue(c.getCenterPoint()==center, "wrong center point")
1354 self.assertTrue(c.getStartPoint()==p_end, "wrong start point")
1355 self.assertTrue(c.getEndPoint()==p_start, "wrong end point")
1356
1357 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1358 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1359
1360 self.assertTrue(not c.isColocated(p4),"spline is colocated with point.")
1361 self.assertTrue(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1362 self.assertTrue(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1363 self.assertTrue(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1364 self.assertTrue(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1365 self.assertTrue(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1366 self.assertTrue(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1367
1368 h=c.getPrimitives()
1369 self.assertTrue(len(h) == 4, "number of primitives in history is wrong.")
1370 self.assertTrue(center in h, "missing center in history.")
1371 self.assertTrue(p_start in h, "missing p_start in history.")
1372 self.assertTrue(p_end in h, "missing p_end in history.")
1373 self.assertTrue(CC0 in h, "missing spline curve in history.")
1374
1375
1376 c.setLocalScale(3.)
1377 self.assertTrue(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1378 self.assertTrue(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1379 self.assertTrue(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1380
1381 cp=c.copy()
1382 self.assertTrue(isinstance(cp,ReverseArc), "copy returns is not an arc.")
1383 self.assertTrue(not cp == c, "copy returns same arc.")
1384 self.assertTrue(cp.isColocated(Arc(center,p_end,p_start)),"arc is not colocated with its copy.")
1385 self.assertTrue(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1386 self.assertTrue(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1387 self.assertTrue(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1388
1389 c.modifyBy(Dilation(-1.))
1390 self.assertTrue(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1391 self.assertTrue(c.getCenterPoint() == center,"wrong center point after dilation.")
1392 self.assertTrue(c.getStartPoint() == p_end,"wrong start point after dilation.")
1393 self.assertTrue(c.getEndPoint() == p_start,"wrong end point after dilation.")
1394
1395 dc=c.apply(Dilation(-1.))
1396 self.assertTrue(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1397 self.assertTrue(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1398 self.assertTrue(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1399 self.assertTrue(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1400 self.assertTrue(dc.getStartPoint().isColocated(Point(1,2,3)),"start point of dilation is wrong.")
1401 self.assertTrue(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1402 self.assertTrue(dc.getEndPoint().isColocated(Point(1,1,1)),"end point of dilation is wrong.")
1403
1404 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1405 dc.setElementDistribution(10,0.2,False)
1406 d=dc.getElementDistribution()
1407 self.assertTrue(d[0] == 10, "number of element is wrong.")
1408 self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1409 self.assertTrue(d[2] == False, "bump flag wrong")
1410 dc.resetElementDistribution()
1411 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1412
1413
1414 def test_Ellipse(self):
1415 center=Point(0,0,0,0.1)
1416 main_axis_point=Point(0,1,0,0.1)
1417 p_start=Point(1,1,1,0.2)
1418 p_end=Point(1,2,3)
1419 p4=Point(10,2,3)
1420
1421 self.assertRaises(TypeError,Ellipse,Primitive())
1422 self.assertRaises(TypeError,Ellipse,center,center,p_start,p_end)
1423 self.assertRaises(TypeError,Ellipse,center,main_axis_point,p_start,p_start)
1424
1425
1426 c=Ellipse(center,main_axis_point,p_start,p_end)
1427
1428 self.assertTrue(c.getCenterPoint()==center, "wrong center point")
1429 self.assertTrue(c.getStartPoint()==p_start, "wrong start point")
1430 self.assertTrue(c.getEndPoint()==p_end, "wrong end point")
1431 self.assertTrue(c.getPointOnMainAxis()==main_axis_point, "wrong point on main axis")
1432
1433 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1434 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1435
1436 self.assertTrue(not c.isColocated(p4),"spline is colocated with point.")
1437 self.assertTrue(not c.isColocated(Ellipse(center,main_axis_point,p4,p_end)),"spline is colocated with spline with differnt start point.")
1438 self.assertTrue(not c.isColocated(Ellipse(center,main_axis_point,p_start,p4)),"spline is colocated with spline with differnt end point.")
1439 self.assertTrue(not c.isColocated(Ellipse(center,p4,p_start,p_end)),"spline is colocated with spline with differnt main axis point.")
1440 self.assertTrue(not c.isColocated(Ellipse(p4,main_axis_point,p_start,p_end)),"spline is colocated with spline with differnt center.")
1441 self.assertTrue(c.isColocated(Ellipse(center,main_axis_point,p_start,p_end)),"spline is not colocated with spline with same points.")
1442 self.assertTrue(c.isColocated(Ellipse(center,main_axis_point,p_start,p_end)),"spline is not colocated with spline with same points.")
1443 self.assertTrue(c.isColocated(Ellipse(center,main_axis_point,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1444 self.assertTrue(not c.isColocated(Curve(center,main_axis_point,p_start,p_end)),"spline curve is identified with curve.")
1445
1446 h=c.getPrimitives()
1447 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
1448 self.assertTrue(center in h, "missing center in history.")
1449 self.assertTrue(p_start in h, "missing p_start in history.")
1450 self.assertTrue(p_end in h, "missing p_end in history.")
1451 self.assertTrue(main_axis_point in h, "missing main_axis_point in history.")
1452 self.assertTrue(c in h, "missing spline curve in history.")
1453
1454
1455 c.setLocalScale(3.)
1456 self.assertTrue(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1457 self.assertTrue(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1458 self.assertTrue(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1459 self.assertTrue(c.getPointOnMainAxis().getLocalScale() == 3., "new local scale of point on main axis is wrong.")
1460
1461 cp=c.copy()
1462 self.assertTrue(isinstance(cp,Ellipse), "copy returns is not an arc.")
1463 self.assertTrue(not cp == c, "copy returns same arc.")
1464 self.assertTrue(cp.isColocated(Ellipse(center,main_axis_point,p_start,p_end)),"arc is not colocated with its copy.")
1465 self.assertTrue(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1466 self.assertTrue(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1467 self.assertTrue(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1468 self.assertTrue(not cp.getPointOnMainAxis()==main_axis_point, "deep copy has same point on main axis like source")
1469
1470 c.modifyBy(Dilation(-1.))
1471 self.assertTrue(c.isColocated(Ellipse(Point(0,0,0),Point(0,-1,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1472 self.assertTrue(c.getCenterPoint() == center,"wrong center point after dilation.")
1473 self.assertTrue(c.getStartPoint() == p_start,"wrong start point after dilation.")
1474 self.assertTrue(c.getEndPoint() == p_end,"wrong end point after dilation.")
1475 self.assertTrue(c.getPointOnMainAxis() == main_axis_point,"wrong point on main axis after dilation.")
1476
1477 #=====================
1478 dc=c.apply(Dilation(-1.))
1479 self.assertTrue(dc.isColocated(Ellipse(Point(0,0,0),Point(0,1,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1480 self.assertTrue(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1481 self.assertTrue(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1482 self.assertTrue(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1483 self.assertTrue(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.")
1484 self.assertTrue(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1485 self.assertTrue(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.")
1486 self.assertTrue(not dc.getPointOnMainAxis() == main_axis_point,"point on main axis is identical to source.")
1487 self.assertTrue(dc.getPointOnMainAxis().isColocated(Point(0,1,0)),"point on main axis of dilation is wrong.")
1488
1489 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1490 dc.setElementDistribution(10,0.2,False)
1491 d=dc.getElementDistribution()
1492 self.assertTrue(d[0] == 10, "number of element is wrong.")
1493 self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1494 self.assertTrue(d[2] == False, "bump flag wrong")
1495 dc.resetElementDistribution()
1496 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1497
1498
1499 def test_ReverseEllipse(self):
1500 center=Point(0,0,0,0.1)
1501 main_axis_point=Point(0,1,0,0.1)
1502 p_start=Point(1,1,1,0.2)
1503 p_end=Point(1,2,3)
1504 p4=Point(10,2,3)
1505
1506 self.assertRaises(TypeError,Ellipse,Primitive())
1507
1508 CC0=Ellipse(center,main_axis_point,p_start,p_end)
1509 c=-CC0
1510
1511 self.assertTrue(c.getCenterPoint()==center, "wrong center point")
1512 self.assertTrue(c.getStartPoint()==p_end, "wrong start point")
1513 self.assertTrue(c.getEndPoint()==p_start, "wrong end point")
1514 self.assertTrue(c.getPointOnMainAxis()==main_axis_point, "wrong point on main axis")
1515
1516 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1517 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1518
1519 self.assertTrue(not c.isColocated(p4),"spline is colocated with point.")
1520 self.assertTrue(not c.isColocated(Ellipse(center,main_axis_point,p4,p_start)),"spline is colocated with spline with differnt start point.")
1521 self.assertTrue(not c.isColocated(Ellipse(center,main_axis_point,p_end,p4)),"spline is colocated with spline with differnt end point.")
1522 self.assertTrue(not c.isColocated(Ellipse(center,p4,p_end,p_start)),"spline is colocated with spline with differnt main axis point.")
1523 self.assertTrue(not c.isColocated(Ellipse(p4,main_axis_point,p_end,p_start)),"spline is colocated with spline with differnt center.")
1524 self.assertTrue(c.isColocated(Ellipse(center,main_axis_point,p_end,p_start)),"spline is not colocated with spline with same points.")
1525 self.assertTrue(c.isColocated(Ellipse(center,main_axis_point,p_end,p_start)),"spline is not colocated with spline with same points.")
1526 self.assertTrue(c.isColocated(Ellipse(center,main_axis_point,p_start,p_end)),"spline is not colocated with spline with same points but opposite direction.")
1527 self.assertTrue(not c.isColocated(Curve(center,main_axis_point,p_start,p_end)),"spline curve is identified with curve.")
1528
1529 h=c.getPrimitives()
1530 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
1531 self.assertTrue(center in h, "missing center in history.")
1532 self.assertTrue(p_start in h, "missing p_start in history.")
1533 self.assertTrue(p_end in h, "missing p_end in history.")
1534 self.assertTrue(main_axis_point in h, "missing main_axis_point in history.")
1535 self.assertTrue(CC0 in h, "missing spline curve in history.")
1536
1537
1538 c.setLocalScale(3.)
1539 self.assertTrue(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1540 self.assertTrue(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1541 self.assertTrue(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1542 self.assertTrue(c.getPointOnMainAxis().getLocalScale() == 3., "new local scale of point on main axis is wrong.")
1543
1544 cp=c.copy()
1545 self.assertTrue(isinstance(cp,ReverseEllipse), "copy returns is not an arc.")
1546 self.assertTrue(not cp == c, "copy returns same arc.")
1547 self.assertTrue(cp.isColocated(Ellipse(center,main_axis_point,p_end,p_start)),"arc is not colocated with its copy.")
1548 self.assertTrue(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1549 self.assertTrue(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1550 self.assertTrue(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1551 self.assertTrue(not cp.getPointOnMainAxis()==main_axis_point, "deep copy has same point on main axis like source")
1552
1553 c.modifyBy(Dilation(-1.))
1554 self.assertTrue(c.isColocated(Ellipse(Point(0,0,0),Point(0,-1,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1555 self.assertTrue(c.getCenterPoint() == center,"wrong center point after dilation.")
1556 self.assertTrue(c.getStartPoint() == p_end,"wrong start point after dilation.")
1557 self.assertTrue(c.getEndPoint() == p_start,"wrong end point after dilation.")
1558 self.assertTrue(c.getPointOnMainAxis() == main_axis_point,"wrong point on main axis after dilation.")
1559
1560 dc=c.apply(Dilation(-1.))
1561 self.assertTrue(dc.isColocated(Ellipse(Point(0,0,0),Point(0,1,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1562 self.assertTrue(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1563 self.assertTrue(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1564 self.assertTrue(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1565 self.assertTrue(dc.getStartPoint().isColocated(Point(1,2,3)),"start point of dilation is wrong.")
1566 self.assertTrue(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1567 self.assertTrue(dc.getEndPoint().isColocated(Point(1,1,1)),"end point of dilation is wrong.")
1568 self.assertTrue(not dc.getPointOnMainAxis() == main_axis_point,"point on main axis is identical to source.")
1569 self.assertTrue(dc.getPointOnMainAxis().isColocated(Point(0,1,0)),"point on main axis of dilation is wrong.")
1570
1571 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1572 dc.setElementDistribution(10,0.2,False)
1573 d=dc.getElementDistribution()
1574 self.assertTrue(d[0] == 10, "number of element is wrong.")
1575 self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1576 self.assertTrue(d[2] == False, "bump flag wrong")
1577 dc.resetElementDistribution()
1578 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1579
1580
1581 def test_CurveLoop(self):
1582 p0=Point(0,0,0,0.1)
1583 p1=Point(1,1,1,0.2)
1584 p2=Point(2,2,2,0.3)
1585 p3=Point(3,3,3,0.4)
1586 p4=Point(1,2,3)
1587 p5=Point(10,20,3)
1588 p6=Point(1,2,30)
1589
1590 l01=Line(p0,p1)
1591 l12=Arc(p3,p1,p2)
1592 l20=Spline(p2,p4,p0)
1593
1594 lx=Line(p2,p3)
1595 ly=Line(p3,p1)
1596
1597 c=CurveLoop(l01,l12,l20)
1598 # self.assertRaises(ValueError,CurveLoop,l01,lx,l20)
1599 # self.assertRaises(ValueError,CurveLoop,l01,l20,l20)
1600 # self.assertRaises(ValueError,CurveLoop,l01,l20,ly)
1601
1602 c=CurveLoop(l01,l20,l12)
1603 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1604 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1605
1606 self.assertTrue(not c.isColocated(p4),"CurveLoop is colocated with point.")
1607 self.assertTrue(c.isColocated(c),"CurveLoop is not colocated with its self.")
1608 self.assertTrue(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.")
1609 self.assertTrue(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.")
1610 self.assertTrue(c.isColocated(CurveLoop(l20,l12,l01)),"CurveLoop is not colocated with its copy with shuffled points.")
1611 self.assertTrue(not c.isColocated(CurveLoop(lx,ly,l12)),"CurveLoop is colocated with different CurveLoop.")
1612
1613 self.assertTrue(len(c) == 3, "wrong length")
1614
1615 c.setLocalScale(3.)
1616 self.assertTrue(p0.getLocalScale()==3., "p0 has wrong local scale.")
1617 self.assertTrue(p1.getLocalScale()==3., "p1 has wrong local scale.")
1618 self.assertTrue(p2.getLocalScale()==3., "p2 has wrong local scale.")
1619 self.assertTrue(p4.getLocalScale()==3., "p4 has wrong local scale.")
1620
1621
1622 cc=c.getCurves()
1623 self.assertTrue(len(cc) == 3, "too many curves.")
1624 self.assertTrue(l01 in cc, "l01 is missing")
1625 self.assertTrue(l12 in cc, "l12 is missing")
1626 self.assertTrue(l20 in cc, "l20 is missing")
1627
1628 p=c.getPrimitives()
1629 self.assertTrue(len(p) == 9, "too many primitives.")
1630 self.assertTrue(l01 in p, "l01 is missing")
1631 self.assertTrue(l12 in p, "l21 is missing")
1632 self.assertTrue(l20 in p, "l20 is missing")
1633 self.assertTrue(p0 in p, "p0 is missing")
1634 self.assertTrue(p1 in p, "p1 is missing")
1635 self.assertTrue(p2 in p, "p2 is missing")
1636 self.assertTrue(p3 in p, "p3 is missing")
1637 self.assertTrue(p4 in p, "p4 is missing")
1638
1639 cp=c.copy()
1640 self.assertTrue(isinstance(cp,CurveLoop), "copy returns is not an arc.")
1641 self.assertTrue(not cp == c, "copy equals source")
1642 self.assertTrue(cp.isColocated(c),"copy is not colocated with its source.")
1643 cc=cp.getCurves()
1644 self.assertTrue(len(cc) == 3, "too many primitives in copy.")
1645 self.assertTrue(not l01 in cc,"copy uses l01.")
1646 self.assertTrue(not l12 in cc,"copy uses l12.")
1647 self.assertTrue(not l20 in cc,"copy uses l20.")
1648
1649 p0_m=Point(0,0,0)
1650 p1_m=Point(-1,-1,-1)
1651 p2_m=Point(-2,-2,-2)
1652 p3_m=Point(-3,-3,-3)
1653 p4_m=Point(-1,-2,-3)
1654
1655 l01_m=Line(p0_m,p1_m)
1656 l12_m=Arc(p3_m,p1_m,p2_m)
1657 l20_m=Spline(p2_m,p4_m,p0_m)
1658
1659 dc=c.apply(Dilation(-1.))
1660 self.assertTrue(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.")
1661 cc=dc.getCurves()
1662 self.assertTrue(len(cc) == 3, "too many primitives in dilation result.")
1663 self.assertTrue(not l01 in cc,"l01 is in dilation result.")
1664 self.assertTrue(not l12 in cc,"l12 is in dilation result.")
1665 self.assertTrue(not l20 in cc,"l20 is in dilation result.")
1666
1667 c.modifyBy(Dilation(-1.))
1668 self.assertTrue(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.")
1669 cc=c.getCurves()
1670 self.assertTrue(len(cc) == 3, "too many primitives in modified object.")
1671 self.assertTrue(l01 in cc,"l01 missed in modified object.")
1672 self.assertTrue(cc[cc.index(l01)].hasSameOrientation(l01),"l01 in modified object has wrong orientation.")
1673 self.assertTrue(l12 in cc,"l12 missed in modified object.")
1674 self.assertTrue(cc[cc.index(l12)].hasSameOrientation(l12),"l12 in modified object has wrong orientation.")
1675 self.assertTrue(l20 in cc,"l20 missed in modified object.")
1676 self.assertTrue(cc[cc.index(l20)].hasSameOrientation(l20),"l20 in modified object has wrong orientation.")
1677
1678 def test_ReverseCurveLoop(self):
1679 p0=Point(0,0,0,0.1)
1680 p1=Point(1,1,1,0.2)
1681 p2=Point(2,2,2,0.3)
1682 p3=Point(3,3,3,0.4)
1683 p4=Point(1,2,3)
1684 p5=Point(10,20,3)
1685 p6=Point(1,2,30)
1686
1687 l01=Line(p0,p1)
1688 l12=Arc(p3,p1,p2)
1689 l20=Spline(p2,p4,p0)
1690
1691 lx=Line(p2,p3)
1692 ly=Line(p3,p1)
1693
1694 CC0=CurveLoop(l01,l20,l12)
1695 c=-CC0
1696
1697 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1698 self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1699
1700 self.assertTrue(not c.isColocated(p4),"-CurveLoop is colocated with point.")
1701 self.assertTrue(c.isColocated(c),"-CurveLoop is not colocated with its self.")
1702 self.assertTrue(c.isColocated(CurveLoop(l01,l12,l20)),"-CurveLoop is not colocated with its copy.")