/[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 4984 - (show annotations)
Mon Jun 2 02:50:34 2014 UTC (4 years, 10 months ago) by sshaw
File MIME type: text/x-python
File size: 244033 byte(s)
revamping testrunners, now uses automated discovery and allows running specific tests without modifying files (see escriptcore/py_src/testing.py for more info/examples)

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