/[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 3893 - (show annotations)
Wed Apr 11 01:40:10 2012 UTC (7 years, 7 months ago) by jfenwick
File MIME type: text/x-python
File size: 237746 byte(s)
Pycad now generates scripts with floating points at 6 decimal places.
Tests have been ammended to match this.

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