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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (3 years, 2 months ago) by jfenwick
File MIME type: text/x-python
File size: 243789 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 gross 2935 # -*- coding: utf-8 -*-
2 ksteube 1809
3 jfenwick 3981 ##############################################################################
4 ksteube 1312 #
5 jfenwick 6651 # Copyright (c) 2003-2018 by The University of Queensland
6 jfenwick 3981 # http://www.uq.edu.au
7 ksteube 1312 #
8 ksteube 1809 # Primary Business: Queensland, Australia
9 jfenwick 6112 # Licensed under the Apache License, version 2.0
10     # http://www.apache.org/licenses/LICENSE-2.0
11 ksteube 1312 #
12 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
13 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
14     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
15 jfenwick 3981 #
16     ##############################################################################
17 gross 905
18 sshaw 5706 from __future__ import print_function, division
19    
20 jfenwick 6651 __copyright__="""Copyright (c) 2003-2018 by The University of Queensland
21 jfenwick 3981 http://www.uq.edu.au
22 ksteube 1809 Primary Business: Queensland, Australia"""
23 jfenwick 6112 __license__="""Licensed under the Apache License, version 2.0
24     http://www.apache.org/licenses/LICENSE-2.0"""
25 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
26 gross 932
27     import os
28 gross 905 import sys
29 jfenwick 4938 import esys.escriptcore.utestselect as unittest
30 sshaw 4984 from esys.escriptcore.testing import *
31 gross 907 import math
32 jfenwick 2455 import numpy
33 gross 905 from esys.pycad import *
34 caltinay 5394 from esys.pycad.design import AbstractDesign
35 gross 933 from esys.pycad.gmsh import Design as GMSHDesign
36 ahallam 3062 from esys.pycad.extras import layer_cake
37 gross 905
38     try:
39     PYCAD_TEST_DATA=os.environ['PYCAD_TEST_DATA']
40     except KeyError:
41     PYCAD_TEST_DATA='.'
42    
43     try:
44     PYCAD_WORKDIR=os.environ['PYCAD_WORKDIR']
45     except KeyError:
46     PYCAD_WORKDIR='.'
47    
48 jfenwick 2419 #PYCAD_TEST_MESH_PATH=PYCAD_TEST_DATA+os.sep+"data_meshes"+os.sep
49     #PYCAD_WORKDIR_PATH=PYCAD_WORKDIR+os.sep
50 gross 905
51 gross 907 def _cross(x, y):
52 caltinay 5394 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]])
53 gross 907
54    
55 gross 912 class Test_PyCAD_Transformations(unittest.TestCase):
56 gross 905 ABS_TOL=1.e-8
57     def __distance(self,x,y):
58 jfenwick 2455 return math.sqrt(numpy.dot(x-y,x-y))
59 gross 905 def test_Translation_x(self):
60     t=Translation([1,0,0])
61     s0=t([1,0,0])
62 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
63     self.assertTrue(self.__distance(s0,numpy.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
64 gross 905 s1=t([0,1,0])
65 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
66     self.assertTrue(self.__distance(s1,numpy.array([1,1,0]))<self.ABS_TOL,"s1 is wrong.")
67 gross 905 s2=t([0,0,1])
68 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
69     self.assertTrue(self.__distance(s2,numpy.array([1,0,1]))<self.ABS_TOL,"s2 is wrong.")
70 gross 905 def test_Translation_y(self):
71     t=Translation([0,1,0])
72     s0=t([1,0,0])
73 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
74     self.assertTrue(self.__distance(s0,numpy.array([1,1,0]))<self.ABS_TOL,"s0 is wrong.")
75 gross 905 s1=t([0,1,0])
76 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
77     self.assertTrue(self.__distance(s1,numpy.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
78 gross 905 s2=t([0,0,1])
79 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
80     self.assertTrue(self.__distance(s2,numpy.array([0,1,1]))<self.ABS_TOL,"s2 is wrong.")
81 gross 905 def test_Translation_z(self):
82     t=Translation([0,0,1])
83     s0=t([1,0,0])
84 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
85     self.assertTrue(self.__distance(s0,numpy.array([1,0,1]))<self.ABS_TOL,"s0 is wrong.")
86 gross 905 s1=t([0,1,0])
87 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
88     self.assertTrue(self.__distance(s1,numpy.array([0,1,1]))<self.ABS_TOL,"s1 is wrong.")
89 gross 905 s2=t([0,0,1])
90 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
91     self.assertTrue(self.__distance(s2,numpy.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
92 gross 905 def test_Dilation_0_two(self):
93     t=Dilation(2.)
94     s0=t([1,0,0])
95 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
96     self.assertTrue(self.__distance(s0,numpy.array([2,0,0]))<self.ABS_TOL,"s0 is wrong.")
97 gross 905 s1=t([0,1,0])
98 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
99     self.assertTrue(self.__distance(s1,numpy.array([0,2,0]))<self.ABS_TOL,"s1 is wrong.")
100 gross 905 s2=t([0,0,1])
101 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
102     self.assertTrue(self.__distance(s2,numpy.array([0,0,2]))<self.ABS_TOL,"s2 is wrong.")
103 gross 905 def test_Dilation_0_half(self):
104     t=Dilation(0.5)
105     s0=t([1,0,0])
106 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
107     self.assertTrue(self.__distance(s0,numpy.array([0.5,0,0]))<self.ABS_TOL,"s0 is wrong.")
108 gross 905 s1=t([0,1,0])
109 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
110     self.assertTrue(self.__distance(s1,numpy.array([0,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
111 gross 905 s2=t([0,0,1])
112 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
113     self.assertTrue(self.__distance(s2,numpy.array([0,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
114 gross 905 def test_Dilation_x_two(self):
115     t=Dilation(2.,[1.,0.,0.])
116     s0=t([1,0,0])
117 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
118     self.assertTrue(self.__distance(s0,numpy.array([1,0,0]))<self.ABS_TOL,"s0 is wrong.")
119 gross 905 s0_1=t([0,0,0])
120 jfenwick 3551 self.assertTrue(isinstance(s0_1,numpy.ndarray),"s0_1 is not an ndarray object.")
121     self.assertTrue(self.__distance(s0_1,numpy.array([-1.,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
122 gross 905 s1=t([0,1,0])
123 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
124     self.assertTrue(self.__distance(s1,numpy.array([-1,2,0]))<self.ABS_TOL,"s1 is wrong.")
125 gross 905 s2=t([0,0,1])
126 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
127     self.assertTrue(self.__distance(s2,numpy.array([-1.,0,2]))<self.ABS_TOL,"s2 is wrong.")
128 gross 905 def test_Dilation_x_half(self):
129     t=Dilation(0.5,[1.,0.,0.])
130     s0=t([1,0,0])
131 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
132     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0]))<self.ABS_TOL,"s0 is wrong.")
133 gross 905 s0_1=t([0,0,0])
134 jfenwick 3551 self.assertTrue(isinstance(s0_1,numpy.ndarray),"s0_1 is not an ndarray object.")
135     self.assertTrue(self.__distance(s0_1,numpy.array([.5,0,0]))<self.ABS_TOL,"s0_1 is wrong.")
136 gross 905 s1=t([0,1,0])
137 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
138     self.assertTrue(self.__distance(s1,numpy.array([0.5,0.5,0]))<self.ABS_TOL,"s1 is wrong.")
139 gross 905 s2=t([0,0,1])
140 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
141     self.assertTrue(self.__distance(s2,numpy.array([0.5,0,0.5]))<self.ABS_TOL,"s2 is wrong.")
142 gross 905 def test_Dilation_y_two(self):
143     t=Dilation(2.,[0.,1.,0.])
144     s0=t([1,0,0])
145 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
146     self.assertTrue(self.__distance(s0,numpy.array([2.,-1.,0]))<self.ABS_TOL,"s0 is wrong.")
147 gross 905 s1_1=t([0,0,0])
148 jfenwick 3551 self.assertTrue(isinstance(s1_1,numpy.ndarray),"s1_1 is not an ndarray object.")
149     self.assertTrue(self.__distance(s1_1,numpy.array([0.,-1.,0]))<self.ABS_TOL,"s1_1 is wrong.")
150 gross 905 s1=t([0,1,0])
151 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
152     self.assertTrue(self.__distance(s1,numpy.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
153 gross 905 s2=t([0,0,1])
154 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
155     self.assertTrue(self.__distance(s2,numpy.array([0.,-1.,2]))<self.ABS_TOL,"s2 is wrong.")
156 gross 905 def test_Dilation_y_half(self):
157     t=Dilation(0.5,[0.,1.,0.])
158     s0=t([1,0,0])
159 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
160     self.assertTrue(self.__distance(s0,numpy.array([0.5,0.5,0]))<self.ABS_TOL,"s0 is wrong.")
161 gross 905 s1_1=t([0,0,0])
162 jfenwick 3551 self.assertTrue(isinstance(s1_1,numpy.ndarray),"s1_1 is not an ndarray object.")
163     self.assertTrue(self.__distance(s1_1,numpy.array([0,0.5,0]))<self.ABS_TOL,"s1_1 is wrong.")
164 gross 905 s1=t([0,1,0])
165 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
166     self.assertTrue(self.__distance(s1,numpy.array([0.,1.,0]))<self.ABS_TOL,"s1 is wrong.")
167 gross 905 s2=t([0,0,1])
168 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
169     self.assertTrue(self.__distance(s2,numpy.array([0.,0.5,0.5]))<self.ABS_TOL,"s2 is wrong.")
170 gross 905 def test_Dilation_z_two(self):
171     t=Dilation(2.,[0.,0.,1.])
172     s0=t([1,0,0])
173 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
174     self.assertTrue(self.__distance(s0,numpy.array([2.,0.,-1.]))<self.ABS_TOL,"s0 is wrong.")
175 gross 905 s2_1=t([0,0,0])
176 jfenwick 3551 self.assertTrue(isinstance(s2_1,numpy.ndarray),"s2_1 is not an ndarray object.")
177     self.assertTrue(self.__distance(s2_1,numpy.array([0.,0.,-1.]))<self.ABS_TOL,"s2_1 is wrong.")
178 gross 905 s1=t([0,1,0])
179 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
180     self.assertTrue(self.__distance(s1,numpy.array([0.,2.,-1.]))<self.ABS_TOL,"s1 is wrong.")
181 gross 905 s2=t([0,0,1])
182 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
183     self.assertTrue(self.__distance(s2,numpy.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
184 gross 905 def test_Dilation_z_half(self):
185     t=Dilation(0.5,[0.,0.,1.])
186     s0=t([1,0,0])
187 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
188     self.assertTrue(self.__distance(s0,numpy.array([0.5,0.,0.5]))<self.ABS_TOL,"s0 is wrong.")
189 gross 905 s2_1=t([0,0,0])
190 jfenwick 3551 self.assertTrue(isinstance(s2_1,numpy.ndarray),"s2_1 is not an ndarray object.")
191     self.assertTrue(self.__distance(s2_1,numpy.array([0,0,0.5]))<self.ABS_TOL,"s2_1 is wrong.")
192 gross 905 s1=t([0,1,0])
193 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
194     self.assertTrue(self.__distance(s1,numpy.array([0.,0.5,0.5]))<self.ABS_TOL,"s1 is wrong.")
195 gross 905 s2=t([0,0,1])
196 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
197     self.assertTrue(self.__distance(s2,numpy.array([0.,0.,1.]))<self.ABS_TOL,"s2 is wrong.")
198 gross 905 def test_Reflection_x_offset0(self):
199     t=Reflection([1.,0.,0.])
200     s0=t([1,0,0])
201 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
202     self.assertTrue(self.__distance(s0,numpy.array([-1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
203 gross 905 s1=t([0,1,0])
204 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
205     self.assertTrue(self.__distance(s1,numpy.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
206 gross 905 s2=t([0,0,1])
207 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
208     self.assertTrue(self.__distance(s2,numpy.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
209 gross 905 s=t([1,2,3])
210 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
211     self.assertTrue(self.__distance(s,numpy.array([-1.,2,3]))<self.ABS_TOL,"s is wrong.")
212 gross 905 def test_Reflection_x_offset2(self):
213     t=Reflection([-2.,0.,0.],offset=-4)
214     s0=t([1,0,0])
215 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
216     self.assertTrue(self.__distance(s0,numpy.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
217 gross 905 s1=t([0,1,0])
218 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
219     self.assertTrue(self.__distance(s1,numpy.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
220 gross 905 s2=t([0,0,1])
221 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
222     self.assertTrue(self.__distance(s2,numpy.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
223 gross 905 s=t([1,2,3])
224 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
225     self.assertTrue(self.__distance(s,numpy.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
226 gross 905 def test_Reflection_x_offset2_vector(self):
227     t=Reflection([1.,0.,0.],offset=[2,0,0])
228     s0=t([1,0,0])
229 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
230     self.assertTrue(self.__distance(s0,numpy.array([3.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
231 gross 905 s1=t([0,1,0])
232 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
233     self.assertTrue(self.__distance(s1,numpy.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.")
234 gross 905 s2=t([0,0,1])
235 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
236     self.assertTrue(self.__distance(s2,numpy.array([4,0,1]))<self.ABS_TOL,"s2 is wrong.")
237 gross 905 s=t([1,2,3])
238 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
239     self.assertTrue(self.__distance(s,numpy.array([3.,2,3]))<self.ABS_TOL,"s is wrong.")
240 gross 907 def test_Reflection_y_offset0(self):
241     t=Reflection([0.,1.,0.])
242     s0=t([1,0,0])
243 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
244     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
245 gross 907 s1=t([0,1,0])
246 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
247     self.assertTrue(self.__distance(s1,numpy.array([0,-1,0]))<self.ABS_TOL,"s1 is wrong.")
248 gross 907 s2=t([0,0,1])
249 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
250     self.assertTrue(self.__distance(s2,numpy.array([0,0,1]))<self.ABS_TOL,"s2 is wrong.")
251 gross 907 s=t([1,2,3])
252 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
253     self.assertTrue(self.__distance(s,numpy.array([1.,-2,3]))<self.ABS_TOL,"s is wrong.")
254 gross 907 def test_Reflection_y_offset2(self):
255     t=Reflection([0.,-2.,0.],offset=-4)
256     s0=t([1,0,0])
257 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
258     self.assertTrue(self.__distance(s0,numpy.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
259 gross 907 s1=t([0,1,0])
260 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
261     self.assertTrue(self.__distance(s1,numpy.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
262 gross 907 s2=t([0,0,1])
263 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
264     self.assertTrue(self.__distance(s2,numpy.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
265 gross 907 s=t([1,2,3])
266 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
267     self.assertTrue(self.__distance(s,numpy.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
268 gross 907 def test_Reflection_y_offset2_vector(self):
269     t=Reflection([0.,1.,0.],offset=[0,2,0])
270     s0=t([1,0,0])
271 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
272     self.assertTrue(self.__distance(s0,numpy.array([1.,4,0.]))<self.ABS_TOL,"s0 is wrong.")
273 gross 907 s1=t([0,1,0])
274 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
275     self.assertTrue(self.__distance(s1,numpy.array([0,3,0]))<self.ABS_TOL,"s1 is wrong.")
276 gross 907 s2=t([0,0,1])
277 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
278     self.assertTrue(self.__distance(s2,numpy.array([0,4,1]))<self.ABS_TOL,"s2 is wrong.")
279 gross 907 s=t([1,2,3])
280 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
281     self.assertTrue(self.__distance(s,numpy.array([1.,2,3]))<self.ABS_TOL,"s is wrong.")
282 gross 907 def test_Reflection_z_offset0(self):
283     t=Reflection([0.,0.,1.])
284     s0=t([1,0,0])
285 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
286     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
287 gross 907 s1=t([0,1,0])
288 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
289     self.assertTrue(self.__distance(s1,numpy.array([0,1,0]))<self.ABS_TOL,"s1 is wrong.")
290 gross 907 s2=t([0,0,1])
291 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
292     self.assertTrue(self.__distance(s2,numpy.array([0,0,-1]))<self.ABS_TOL,"s2 is wrong.")
293 gross 907 s=t([1,2,3])
294 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
295     self.assertTrue(self.__distance(s,numpy.array([1.,2,-3]))<self.ABS_TOL,"s is wrong.")
296 gross 907 def test_Reflection_z_offset2(self):
297     t=Reflection([0.,0.,-2.],offset=-4)
298     s0=t([1,0,0])
299 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
300     self.assertTrue(self.__distance(s0,numpy.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
301 gross 907 s1=t([0,1,0])
302 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
303     self.assertTrue(self.__distance(s1,numpy.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
304 gross 907 s2=t([0,0,1])
305 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
306     self.assertTrue(self.__distance(s2,numpy.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
307 gross 907 s=t([1,2,3])
308 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
309     self.assertTrue(self.__distance(s,numpy.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
310 gross 907 def test_Reflection_z_offset2_vector(self):
311     t=Reflection([0.,0.,1.],offset=[0,0,2])
312     s0=t([1,0,0])
313 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
314     self.assertTrue(self.__distance(s0,numpy.array([1.,0,4.]))<self.ABS_TOL,"s0 is wrong.")
315 gross 907 s1=t([0,1,0])
316 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
317     self.assertTrue(self.__distance(s1,numpy.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.")
318 gross 907 s2=t([0,0,1])
319 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
320     self.assertTrue(self.__distance(s2,numpy.array([0,0,3]))<self.ABS_TOL,"s2 is wrong.")
321 gross 907 s=t([1,2,3])
322 jfenwick 3551 self.assertTrue(isinstance(s,numpy.ndarray),"s is not an ndarray object.")
323     self.assertTrue(self.__distance(s,numpy.array([1.,2,1]))<self.ABS_TOL,"s is wrong.")
324 jfenwick 3259 def test_Rotatation_x_90_0(self):
325     t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=90*DEG)
326 gross 907 s0=t([1,0,0])
327 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
328     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
329 gross 907 s1=t([0,1,0])
330 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
331     self.assertTrue(self.__distance(s1,numpy.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.")
332 gross 907 s2=t([0,0,1])
333 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
334     self.assertTrue(self.__distance(s2,numpy.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.")
335 jfenwick 3259 def test_Rotatation_x_30_0(self):
336     t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
337 gross 907 s0=t([1,0,0])
338 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
339     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
340 gross 907 s1=t([0,1,0])
341 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
342     self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
343     self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
344     self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([1.,0.,0.]))<0.,"s1 has wrong orientation.")
345 gross 907 s2=t([0,0,1])
346 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
347     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
348     self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
349     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([1.,0.,0.]))<0.,"s2 has wrong orientation.")
350 jfenwick 3259 def test_Rotatation_x_330_0(self):
351     t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
352 gross 907 s0=t([1,0,0])
353 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
354     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
355 gross 907 s1=t([0,1,0])
356 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
357     self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
358     self.assertTrue(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
359     self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([1.,0.,0.]))>0.,"s1 has wrong orientation.")
360 gross 907 s2=t([0,0,1])
361 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
362     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
363     self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
364     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([1.,0.,0.]))>0.,"s2 has wrong orientation.")
365 jfenwick 3259 def test_Rotatation_x_90(self):
366     t=Rotatation(axis=[-1.,0.,0.],point=[2.,0.,0.],angle=90*DEG)
367 gross 907 s0=t([1,0,0])
368 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
369     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
370 gross 907 s1=t([0,1,0])
371 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
372     self.assertTrue(self.__distance(s1,numpy.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.")
373 gross 907 s2=t([0,0,1])
374 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
375     self.assertTrue(self.__distance(s2,numpy.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.")
376 jfenwick 3259 def test_Rotatation_x_30(self):
377     t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=30*DEG)
378 gross 907 s0=t([1,0,0])
379 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
380     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
381 gross 907 s1=t([0,1,0])
382 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
383     self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
384     self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
385     self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.")
386 gross 907 s2=t([0,0,1])
387 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
388     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
389     self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
390     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.")
391 jfenwick 3259 def test_Rotatation_x_330(self):
392     t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=330*DEG)
393 gross 907 s0=t([1,0,0])
394 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
395     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
396 gross 907 s1=t([0,1,0])
397 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
398     self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
399     self.assertTrue(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
400     self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.")
401 gross 907 s2=t([0,0,1])
402 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
403     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
404     self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
405     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.")
406 jfenwick 3259 def test_Rotatation_y_90_0(self):
407     t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=90*DEG)
408 gross 907 s0=t([1,0,0])
409 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
410     self.assertTrue(self.__distance(s0,numpy.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.")
411 gross 907 s1=t([0,5,0])
412 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
413     self.assertTrue(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
414 gross 907 s2=t([0,0,1])
415 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
416     self.assertTrue(self.__distance(s2,numpy.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
417 jfenwick 3259 def test_Rotatation_y_30_0(self):
418     t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=30*DEG)
419 gross 907 s0=t([1,0,0])
420 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
421     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
422     self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
423     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,1.,0.]))<0.,"s0 has wrong orientation.")
424 gross 907 s1=t([0,5,0])
425 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
426     self.assertTrue(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
427 gross 907 s2=t([0,0,1])
428 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
429     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
430     self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
431     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,1.,0.]))<0.,"s2 has wrong orientation.")
432 jfenwick 3259 def test_Rotatation_y_330_0(self):
433     t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=330*DEG)
434 gross 907 s0=t([1,0,0])
435 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
436     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
437     self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
438     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,1.,0.]))>0.,"s0 has wrong orientation.")
439 gross 907 s1=t([0,1,0])
440 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
441     self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
442 gross 907 s2=t([0,0,1])
443 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
444     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
445     self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
446     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,1.,0.]))>0.,"s2 has wrong orientation.")
447 jfenwick 3259 def test_Rotatation_y_90(self):
448     t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=90*DEG)
449 gross 907 s0=t([1,0,0])
450 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
451     self.assertTrue(self.__distance(s0,numpy.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.")
452 gross 910 s1=t([0,5,0])
453 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
454     self.assertTrue(self.__distance(s1,numpy.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.")
455 gross 907 s2=t([0,0,1])
456 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
457     self.assertTrue(self.__distance(s2,numpy.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.")
458 jfenwick 3259 def test_Rotatation_y_30(self):
459     t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=30*DEG)
460 gross 907 s0=t([1,0,0])
461 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
462     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
463     self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
464     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.")
465 gross 907 s1=t([0,1,0])
466 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
467     self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
468 gross 907 s2=t([0,0,1])
469 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
470     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
471     self.assertTrue(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.")
472     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.")
473 jfenwick 3259 def test_Rotatation_y_330(self):
474     t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=330*DEG)
475 gross 907 s0=t([1,0,0])
476 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
477     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
478     self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
479     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.")
480 gross 907 s1=t([0,1,0])
481 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
482     self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
483 gross 907 s2=t([0,0,1])
484 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
485     self.assertTrue(abs(numpy.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.")
486     self.assertTrue(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.")
487     self.assertTrue(numpy.dot(_cross(s2,[0,0,1]),numpy.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.")
488 jfenwick 3259 def test_Rotatation_z_90_0(self):
489     t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=90*DEG)
490 gross 907 s0=t([1,0,0])
491 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
492     self.assertTrue(self.__distance(s0,numpy.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.")
493 gross 907 s1=t([0,5,0])
494 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
495     self.assertTrue(self.__distance(s1,numpy.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
496 gross 907 s2=t([0,0,1])
497 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
498     self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
499 jfenwick 3259 def test_Rotatation_z_30_0(self):
500     t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=30*DEG)
501 gross 907 s0=t([1,0,0])
502 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
503     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
504     self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
505     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,1.]))<0.,"s0 has wrong orientation.")
506 gross 907 s1=t([0,5,0])
507 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
508     self.assertTrue(abs(numpy.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
509     self.assertTrue(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
510     self.assertTrue(numpy.dot(_cross(s1,[0,5,0]),numpy.array([0.,0.,1.]))<0.,"s1 has wrong orientation.")
511 gross 907 s2=t([0,0,1])
512 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
513     self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
514 jfenwick 3259 def test_Rotatation_z_330_0(self):
515     t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=330*DEG)
516 gross 907 s0=t([1,0,0])
517 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
518     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
519     self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
520     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,1.]))>0.,"s0 has wrong orientation.")
521 gross 907 s1=t([0,5,0])
522 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
523     self.assertTrue(abs(numpy.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.")
524     self.assertTrue(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.")
525     self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,1.]))>0.,"s1 has wrong orientation.")
526 jfenwick 3259 def test_Rotatation_z_90(self):
527     t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=90*DEG)
528 gross 907 s0=t([1,0,0])
529 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
530     self.assertTrue(self.__distance(s0,numpy.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.")
531 gross 910 s1=t([0,5,0])
532 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
533     self.assertTrue(self.__distance(s1,numpy.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.")
534 gross 907 s2=t([0,0,1])
535 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
536     self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
537 jfenwick 3259 def test_Rotatation_z_30(self):
538     t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=30*DEG)
539 gross 907 s0=t([1,0,0])
540 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
541     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
542     self.assertTrue(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.")
543     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.")
544 gross 907 s1=t([0,1,0])
545 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
546     self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
547     self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
548     self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.")
549 gross 907 s2=t([0,0,1])
550 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
551     self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
552 jfenwick 3259 def test_Rotatation_z_330(self):
553     t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=330*DEG)
554 gross 907 s0=t([1,0,0])
555 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
556     self.assertTrue(abs(numpy.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.")
557     self.assertTrue(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.")
558     self.assertTrue(numpy.dot(_cross(s0,[1,0,0]),numpy.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.")
559 gross 907 s1=t([0,1,0])
560 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
561     self.assertTrue(abs(numpy.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.")
562     self.assertTrue(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.")
563     self.assertTrue(numpy.dot(_cross(s1,[0,1,0]),numpy.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.")
564 gross 907 s2=t([0,0,1])
565 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
566     self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
567 jfenwick 3259 def test_Rotatation_x_90_1(self):
568     t=Rotatation(point=[0.,0.,1.],axis=[1.,0.,0.],angle=90*DEG)
569 gross 910 s0=t([1,0,0])
570 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
571     self.assertTrue(self.__distance(s0,numpy.array([1.,1,1.]))<self.ABS_TOL,"s0 is wrong.")
572 gross 910 s1=t([0,1,0])
573 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
574     self.assertTrue(self.__distance(s1,numpy.array([0.,1,2.]))<self.ABS_TOL,"s1 is wrong.")
575 gross 910 s2=t([0,0,1])
576 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
577     self.assertTrue(self.__distance(s2,numpy.array([0.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
578 jfenwick 3259 def test_Rotatation_y_90_1(self):
579     t=Rotatation(point=[1.,0.,0.],axis=[0.,1.,0.],angle=90*DEG)
580 gross 910 s0=t([1,0,0])
581 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
582     self.assertTrue(self.__distance(s0,numpy.array([1.,0,0.]))<self.ABS_TOL,"s0 is wrong.")
583 gross 910 s1=t([0,1,0])
584 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
585     self.assertTrue(self.__distance(s1,numpy.array([1.,1,1.]))<self.ABS_TOL,"s1 is wrong.")
586 gross 910 s2=t([0,0,1])
587 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
588     self.assertTrue(self.__distance(s2,numpy.array([2.,0,1.]))<self.ABS_TOL,"s2 is wrong.")
589 jfenwick 3259 def test_Rotatation_z_90_1(self):
590     t=Rotatation(point=[0.,1.,0.],axis=[0.,0.,1.],angle=90*DEG)
591 gross 910 s0=t([1,0,0])
592 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
593     self.assertTrue(self.__distance(s0,numpy.array([1.,2,0.]))<self.ABS_TOL,"s0 is wrong.")
594 gross 910 s1=t([0,1,0])
595 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
596     self.assertTrue(self.__distance(s1,numpy.array([0.,1,0.]))<self.ABS_TOL,"s1 is wrong.")
597 gross 910 s2=t([0,0,1])
598 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
599     self.assertTrue(self.__distance(s2,numpy.array([1.,1,1.]))<self.ABS_TOL,"s2 is wrong.")
600 jfenwick 3259 def test_Rotatation_diag_90_0(self):
601     t=Rotatation(axis=[1.,1.,1.],angle=90*DEG)
602 gross 910 s0=t([1,-1,0])
603 jfenwick 3551 self.assertTrue(isinstance(s0,numpy.ndarray),"s0 is not an ndarray object.")
604     self.assertTrue(abs(numpy.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.")
605     self.assertTrue(abs(numpy.dot(s0,numpy.array([1,-1,0])))<self.ABS_TOL,"s0 angle is wrong.")
606     self.assertTrue(numpy.dot(_cross(s0,[1,-1,0]),numpy.array([1.,1.,1.]))<0.,"s0 has wrong orientation.")
607 gross 910 s1=t([0,1,-1])
608 jfenwick 3551 self.assertTrue(isinstance(s1,numpy.ndarray),"s1 is not an ndarray object.")
609     self.assertTrue(abs(numpy.dot(s1,s1)-2.)<self.ABS_TOL,"s1 length is wrong.")
610     self.assertTrue(abs(numpy.dot(s1,numpy.array([0,1,-1])))<self.ABS_TOL,"s1 angle is wrong.")
611     self.assertTrue(numpy.dot(_cross(s1,[0,1,-1]),numpy.array([1.,1.,1.]))<0.,"s1 has wrong orientation.")
612 gross 910 s2=t([-1,0,1])
613 jfenwick 3551 self.assertTrue(isinstance(s2,numpy.ndarray),"s2 is not an ndarray object.")
614     self.assertTrue(abs(numpy.dot(s2,s2)-2.)<self.ABS_TOL,"s2 length is wrong.")
615     self.assertTrue(abs(numpy.dot(s2,numpy.array([-1,0,1])))<self.ABS_TOL,"s2 angle is wrong.")
616     self.assertTrue(numpy.dot(_cross(s2,[-1,0,1]),numpy.array([1.,1.,1.]))<0.,"s2 has wrong orientation.")
617 gross 910 s3=t([1,1,1])
618 jfenwick 3551 self.assertTrue(isinstance(s3,numpy.ndarray),"s3 is not an ndarray object.")
619     self.assertTrue(self.__distance(s3,numpy.array([1.,1,1.]))<self.ABS_TOL,"s3 is wrong.")
620 gross 912
621     class Test_PyCAD_Primitives(unittest.TestCase):
622     def setUp(self):
623 gross 915 resetGlobalPrimitiveIdCounter()
624 gross 912
625 gross 929 def test_Primitive(self):
626 gross 912 p=Primitive()
627    
628     id=p.getID()
629 jfenwick 3551 self.assertTrue(isinstance(id,int),"id number is not an integer")
630     self.assertTrue(not id==Primitive().getID(),"id number is not unique")
631 gross 912
632 jfenwick 3551 self.assertTrue(p==p.getUnderlyingPrimitive(),"getUnderlyingPrimitive does not return self.")
633 gross 912
634 gross 929 def test_ReversePrimitive(self):
635     p=Primitive()
636     rp=ReversePrimitive(p)
637 jfenwick 3551 self.assertTrue(p.getID()==rp.getID(),"reverse primitive does not have same id like source")
638     self.assertTrue(p==rp.getUnderlyingPrimitive(),"getUnderlyingPrimitive does return source.")
639     self.assertTrue(p == -rp,"reverse or reverse does not return source.")
640 caltinay 5394
641 gross 929 def test_Point(self):
642 gross 912 p=Point(1.,2.,3.,local_scale=9.)
643 caltinay 5394
644 gross 912 id=p.getID()
645 jfenwick 3551 self.assertTrue(isinstance(id,int),"id number is not an integer")
646     self.assertTrue(not id==Primitive().getID(),"id number is not unique")
647 caltinay 5394
648     # check reverse point
649 jfenwick 3551 self.assertTrue(p == -p,"reverse is not working.")
650 caltinay 5394
651 gross 915 # check history:
652 gross 916 hs=p.getPrimitives()
653 jfenwick 3551 self.assertTrue(len(hs)==1,"history must have length 1.")
654     self.assertTrue(p in hs,"history must contain point p")
655 gross 912
656 gross 915 # check incolved points:
657 gross 916 ps=p.getConstructionPoints()
658 jfenwick 3551 self.assertTrue(len(ps)==1,"point set must have length 1.")
659     self.assertTrue(p in ps,"point set must contain point p")
660 gross 912
661 gross 915 # check coordinates:
662 gross 912 c=p.getCoordinates()
663 jfenwick 3551 self.assertTrue(isinstance(c,numpy.ndarray),"coordinates are not an ndarray object.")
664     self.assertTrue(c[0]==1.,"x coordinate is not 1.")
665     self.assertTrue(c[1]==2.,"y coordinate is not 2.")
666     self.assertTrue(c[2]==3.,"z coordinate is not 3.")
667 caltinay 5394
668 gross 915 # reset coordinates:
669     p.setCoordinates([-1.,-2.,-3.])
670 gross 912 c=p.getCoordinates()
671 jfenwick 3551 self.assertTrue(isinstance(c,numpy.ndarray),"new coordinates are not an ndarray object.")
672     self.assertTrue(c[0]==-1.,"new x coordinate is not -1.")
673     self.assertTrue(c[1]==-2.,"new y coordinate is not -2.")
674     self.assertTrue(c[2]==-3.,"new z coordinate is not -3.")
675 gross 912
676 gross 915 # check for a colocated point:
677 jfenwick 3551 self.assertTrue(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.")
678     self.assertTrue(not p.isColocated(numpy.array([-1.,-2.,-3.])),"colocation with ndarray representation not detected.")
679     self.assertTrue(not p.isColocated(Point(1.,-2.,-3.)),"false colocation detected.")
680     self.assertTrue(not p.isColocated(Point(0.,0.,0.)),"false colocation with origin detected.")
681 gross 912
682 gross 915 # check for local length scale
683 gross 912 l=p.getLocalScale()
684 jfenwick 3551 self.assertTrue(l==9.,"refinement scale is not 9.")
685 gross 912
686 gross 915 # check for new local length scale
687 gross 912 p.setLocalScale(3.)
688     l=p.getLocalScale()
689 jfenwick 3551 self.assertTrue(l==3.,"new refinement scale is not 3.")
690 gross 912
691 gross 915 # negative value shouldn't work.
692 jfenwick 3551 self.assertRaises(ValueError,p.setLocalScale,-3.)
693 gross 915
694     # copy:
695     an_other_p=p.copy()
696 jfenwick 3551 self.assertTrue(isinstance(an_other_p ,Point),"copy is not a point")
697     self.assertTrue(not an_other_p.getID() == p.getID(),"copy has same Id")
698     self.assertTrue(p.isColocated(an_other_p),"p is not colocated with its copy.")
699     self.assertTrue(an_other_p.isColocated(p),"the copy is not colocated with p.")
700     self.assertTrue(an_other_p.getLocalScale()==3.,"copy has wrong local scale.")
701 caltinay 5394
702 gross 915 # modify by Transformation:
703     p.modifyBy(Dilation(-1))
704 jfenwick 3551 self.assertTrue(p.isColocated(Point(1.,2.,3.)),"in-place transformation failed")
705 caltinay 5394
706 gross 915 # apply Transformation:
707     dil_p=p.apply(Dilation(4))
708 jfenwick 3551 self.assertTrue(dil_p.isColocated(Point(4.,8.,12.)),"applying transformation failed")
709     self.assertTrue(not dil_p.getID() == p.getID(),"transformed point has same Id")
710     self.assertTrue(dil_p.getLocalScale()==3.,"transformed point has wrong local scale.")
711 caltinay 5394
712 gross 915 # overloaded add:
713     shift_p=p+[1,1,1]
714 jfenwick 3551 self.assertTrue(shift_p.isColocated(Point(2,3.,4)),"applying shift by list failed")
715     self.assertTrue(not shift_p.getID() == p.getID(),"shift by list has same Id")
716     self.assertTrue(shift_p.getLocalScale()==3.,"shift by list has wrong local scale.")
717 gross 915
718 jfenwick 2455 shift_p=p+numpy.array([1,1,1])
719 jfenwick 3551 self.assertTrue(shift_p.isColocated(Point(2,3.,4)),"applying shift by ndarray failed")
720     self.assertTrue(not shift_p.getID() == p.getID(),"shift by ndarray has same Id")
721     self.assertTrue(shift_p.getLocalScale()==3.,"shift by ndarray has wrong local scale.")
722 gross 915 # overloaded minus
723     shift_p=p-[1,1,1]
724 jfenwick 3551 self.assertTrue(shift_p.isColocated(Point(0,1,2.)),"applying shift by -list failed")
725     self.assertTrue(not shift_p.getID() == p.getID(),"shift by -list has same Id")
726     self.assertTrue(shift_p.getLocalScale()==3.,"shift by -list has wrong local scale.")
727 gross 915
728 jfenwick 2455 shift_p=p-numpy.array([1,1,1])
729 jfenwick 3551 self.assertTrue(shift_p.isColocated(Point(0,1,2.)),"applying shift by -ndarray failed")
730     self.assertTrue(not shift_p.getID() == p.getID(),"shift by -ndarray has same Id")
731     self.assertTrue(shift_p.getLocalScale()==3.,"shift by -ndarray has wrong local scale.")
732 gross 915 # overloaded inplace add:
733     p+=[1,1,1]
734 jfenwick 3551 self.assertTrue(p.isColocated(Point(2,3.,4)),"modification by list shift failed")
735 gross 915
736 jfenwick 2455 p+=numpy.array([1,1,1])
737 jfenwick 3551 self.assertTrue(p.isColocated(Point(3,4,5)),"modification by ndarray shift failed")
738 gross 915
739     # overloaded inplace add:
740     p-=[1,1,1]
741 jfenwick 3551 self.assertTrue(p.isColocated(Point(2,3,4)),"modification by -list shift failed")
742 gross 915
743 jfenwick 2455 p-=numpy.array([1,1,1])
744 jfenwick 3551 self.assertTrue(p.isColocated(Point(1,2.,3)),"modification by -ndarray shift failed")
745 gross 915
746     #overloaded multiplication:
747     mult_p=2*p
748 jfenwick 3551 self.assertTrue(mult_p.isColocated(Point(2,4,6)),"applying int factor failed")
749     self.assertTrue(not mult_p.getID() == p.getID(),"shift by int factor has same Id")
750     self.assertTrue(mult_p.getLocalScale()==3.,"shift by int factor has wrong local scale.")
751 gross 915
752     mult_p=2.*p
753 jfenwick 3551 self.assertTrue(mult_p.isColocated(Point(2,4,6)),"applying float factor failed")
754     self.assertTrue(not mult_p.getID() == p.getID(),"shift by float factor has same Id")
755     self.assertTrue(mult_p.getLocalScale()==3.,"shift by float factor has wrong local scale.")
756 gross 915
757     mult_p=Dilation(2)*p
758 jfenwick 3551 self.assertTrue(mult_p.isColocated(Point(2,4,6)),"applying Dilation factor failed")
759     self.assertTrue(not mult_p.getID() == p.getID(),"shift by Dilation factor has same Id")
760     self.assertTrue(mult_p.getLocalScale()==3.,"shift by Dilation factor has wrong local scale.")
761 gross 915
762     #overloaded inplace multiplication:
763     p*=2
764 jfenwick 3551 self.assertTrue(p.isColocated(Point(2,4,6)),"applying in-place int factor failed")
765 gross 915
766     p*=2.
767 jfenwick 3551 self.assertTrue(p.isColocated(Point(4,8,12)),"applying in-place float factor failed")
768 gross 915
769     p*=Dilation(2)
770 jfenwick 3551 self.assertTrue(p.isColocated(Point(8,16,24)),"applying in-place Dilation factor failed")
771 gross 915
772 gross 929 def test_Spline(self):
773 gross 916 p0=Point(0,0,0,0.1)
774     p1=Point(1,1,1,0.2)
775     p2=Point(2,2,2,0.3)
776     p3=Point(3,3,3,0.4)
777     p4=Point(1,2,3)
778 caltinay 5394
779 jfenwick 3551 self.assertRaises(ValueError,Spline,p0)
780 gross 916 c=Spline(p0,p1,p2,p3)
781 gross 915
782 jfenwick 3551 self.assertTrue(len(c) == 4, "wrong spline curve length")
783     self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
784     self.assertTrue(c.getEndPoint()==p3, "wrong end point of spline curve")
785 gross 916
786 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
787     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
788 gross 930
789 jfenwick 3551 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
790     self.assertTrue(not c.isColocated(Spline(p0,p1,p2)),"spline is colocated with spline of different length.")
791     self.assertTrue(not c.isColocated(Spline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
792     self.assertTrue(c.isColocated(Spline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
793     self.assertTrue(c.isColocated(Spline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
794     self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
795 gross 919
796 gross 916 co=c.getControlPoints()
797 jfenwick 3551 self.assertTrue(co[0]==p0, "1st control point is wrong.")
798     self.assertTrue(co[1]==p1, "2nd control point is wrong.")
799     self.assertTrue(co[2]==p2, "3rd control point is wrong.")
800     self.assertTrue(co[3]==p3, "4th control point is wrong.")
801 gross 916
802     c.setLocalScale(3.)
803     co=c.getControlPoints()
804 jfenwick 3551 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
805     self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
806     self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
807     self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
808 gross 916
809     h=c.getPrimitives()
810 jfenwick 3551 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
811     self.assertTrue(p0 in h, "missing p0 in history.")
812     self.assertTrue(p1 in h, "missing p1 in history.")
813     self.assertTrue(p2 in h, "missing p2 in history.")
814     self.assertTrue(p3 in h, "missing p3 in history.")
815     self.assertTrue(c in h, "missing spline curve in history.")
816 gross 916
817     cp=c.copy()
818 gross 919 cpcp=cp.getControlPoints()
819 jfenwick 3551 self.assertTrue(not cp == c, "copy returns same spline curve.")
820     self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
821     self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
822     self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
823     self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
824     self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
825 gross 916
826     c.modifyBy(Dilation(-1.))
827 gross 919 cp=c.getControlPoints()
828 jfenwick 3551 self.assertTrue(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
829     self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
830     self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
831     self.assertTrue(p2 == cp[2],"3rd new point after Dilation.")
832     self.assertTrue(p3 == cp[3],"4th new point after Dilation.")
833 gross 916
834     dc=c.apply(Dilation(-1.))
835 gross 919 dccp=dc.getControlPoints()
836 jfenwick 3551 self.assertTrue(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
837     self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
838     self.assertTrue(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
839     self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
840     self.assertTrue(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
841     self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
842     self.assertTrue(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
843     self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
844     self.assertTrue(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
845 caltinay 5394
846 gross 929 def test_ReverseSpline(self):
847     p0=Point(0,0,0,0.1)
848     p1=Point(1,1,1,0.2)
849     p2=Point(2,2,2,0.3)
850     p3=Point(3,3,3,0.4)
851     p4=Point(1,2,3)
852     CC0=Spline(p0,p1,p2,p3)
853     c=-CC0
854 gross 916
855 jfenwick 3551 self.assertTrue(len(c) == 4, "wrong reverse spline curve length")
856     self.assertTrue(c.getStartPoint()==p3, "wrong start point of reverse spline curve")
857     self.assertTrue(c.getEndPoint()==p0, "wrong end point of reverse spline curve")
858 gross 929
859 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
860     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
861 gross 930
862 jfenwick 3551 self.assertTrue(not c.isColocated(p1),"reverse spline is colocated with point.")
863     self.assertTrue(not c.isColocated(Spline(p0,p1,p2)),"reverse spline is colocated with spline of different length.")
864     self.assertTrue(not c.isColocated(Spline(p0,p1,p4,p3)),"reverse spline is colocated with spline with different point.")
865     self.assertTrue(c.isColocated(Spline(p0,p1,p2,p3)),"reverse spline is not colocated with spline with same points but opposite direction.")
866     self.assertTrue(c.isColocated(Spline(p3,p2,p1,p0)),"reverse spline is not colocated with spline with same points.")
867     self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
868 gross 929
869     co=c.getControlPoints()
870 jfenwick 3551 self.assertTrue(co[0]==p3, "1st control point is wrong.")
871     self.assertTrue(co[1]==p2, "2nd control point is wrong.")
872     self.assertTrue(co[2]==p1, "3rd control point is wrong.")
873     self.assertTrue(co[3]==p0, "4th control point is wrong.")
874 gross 929
875     c.setLocalScale(3.)
876     co=c.getControlPoints()
877 jfenwick 3551 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
878     self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
879     self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
880     self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
881 gross 929
882     h=c.getPrimitives()
883 jfenwick 3551 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
884     self.assertTrue(p0 in h, "missing p0 in history.")
885     self.assertTrue(p1 in h, "missing p1 in history.")
886     self.assertTrue(p2 in h, "missing p2 in history.")
887     self.assertTrue(p3 in h, "missing p3 in history.")
888     self.assertTrue(CC0 in h, "missing spline curve in history.")
889 gross 929
890     cp=c.copy()
891     cpcp=cp.getControlPoints()
892 jfenwick 3551 self.assertTrue(not cp == c, "copy returns same spline curve.")
893     self.assertTrue(not cp == CC0, "copy returns same spline curve.")
894     self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
895     self.assertTrue(not p3 == cpcp[0],"1st point of deep copy and souce are the same.")
896     self.assertTrue(not p2 == cpcp[1],"2st point of deep copy and source are the same.")
897     self.assertTrue(not p1 == cpcp[2],"3st point of deep copy and source are the same.")
898     self.assertTrue(not p0 == cpcp[3],"4st point of deep copy and source are the same.")
899 gross 929
900     c.modifyBy(Dilation(-1.))
901     cp=c.getControlPoints()
902 jfenwick 3551 self.assertTrue(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.")
903     self.assertTrue(p3 == cp[0],"1st new point after Dilation.")
904     self.assertTrue(p2 == cp[1],"2nd new point after Dilation.")
905     self.assertTrue(p1 == cp[2],"3rd new point after Dilation.")
906     self.assertTrue(p0 == cp[3],"4th new point after Dilation.")
907 gross 929
908     dc=c.apply(Dilation(-1.))
909     dccp=dc.getControlPoints()
910 jfenwick 3551 self.assertTrue(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
911     self.assertTrue(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
912     self.assertTrue(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
913     self.assertTrue(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
914     self.assertTrue(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
915 gross 929
916 gross 916 def test_BezierCurve(self):
917     p0=Point(0,0,0,0.1)
918     p1=Point(1,1,1,0.2)
919     p2=Point(2,2,2,0.3)
920     p3=Point(3,3,3,0.4)
921     p4=Point(1,2,3)
922 jfenwick 3551 self.assertRaises(ValueError,BezierCurve,p0)
923 gross 916 c=BezierCurve(p0,p1,p2,p3)
924    
925 jfenwick 3551 self.assertTrue(len(c) == 4, "wrong spline curve length")
926     self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
927     self.assertTrue(c.getEndPoint()==p3, "wrong end point of spline curve")
928 gross 916
929 jfenwick 3551 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
930     self.assertTrue(not c.isColocated(BezierCurve(p0,p1,p2)),"spline is colocated with spline of different length.")
931     self.assertTrue(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
932     self.assertTrue(c.isColocated(BezierCurve(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
933     self.assertTrue(c.isColocated(BezierCurve(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
934     self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
935 gross 919
936 gross 916 co=c.getControlPoints()
937 jfenwick 3551 self.assertTrue(co[0]==p0, "1st control point is wrong.")
938     self.assertTrue(co[1]==p1, "2nd control point is wrong.")
939     self.assertTrue(co[2]==p2, "3rd control point is wrong.")
940     self.assertTrue(co[3]==p3, "4th control point is wrong.")
941 gross 916
942     c.setLocalScale(3.)
943     co=c.getControlPoints()
944 jfenwick 3551 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
945     self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
946     self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
947     self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
948 gross 916
949     h=c.getPrimitives()
950 jfenwick 3551 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
951     self.assertTrue(p0 in h, "missing p0 in history.")
952     self.assertTrue(p1 in h, "missing p1 in history.")
953     self.assertTrue(p2 in h, "missing p2 in history.")
954     self.assertTrue(p3 in h, "missing p3 in history.")
955     self.assertTrue(c in h, "missing spline curve in history.")
956 gross 916
957     cp=c.copy()
958 gross 919 cpcp=cp.getControlPoints()
959 jfenwick 3551 self.assertTrue(not cp == c, "copy returns same spline curve.")
960     self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
961     self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
962     self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
963     self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
964     self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
965 gross 916
966     c.modifyBy(Dilation(-1.))
967 gross 919 cp=c.getControlPoints()
968 jfenwick 3551 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.")
969     self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
970     self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
971     self.assertTrue(p2 == cp[2],"3rd new point after Dilation.")
972     self.assertTrue(p3 == cp[3],"4th new point after Dilation.")
973 gross 916
974     dc=c.apply(Dilation(-1.))
975 gross 919 dccp=dc.getControlPoints()
976 jfenwick 3551 self.assertTrue(dc.isColocated(BezierCurve(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
977     self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
978     self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
979     self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
980     self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
981 gross 916
982     def test_BSpline(self):
983     p0=Point(0,0,0,0.1)
984     p1=Point(1,1,1,0.2)
985     p2=Point(2,2,2,0.3)
986     p3=Point(3,3,3,0.4)
987     p4=Point(1,2,3)
988 jfenwick 3551 self.assertRaises(ValueError,BSpline,p0)
989 gross 916 c=BSpline(p0,p1,p2,p3)
990    
991 jfenwick 3551 self.assertTrue(len(c) == 4, "wrong spline curve length")
992     self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
993     self.assertTrue(c.getEndPoint()==p3, "wrong end point of spline curve")
994 gross 916
995 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
996     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
997 gross 930
998 jfenwick 3551 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
999     self.assertTrue(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1000     self.assertTrue(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1001     self.assertTrue(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1002     self.assertTrue(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1003     self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1004 gross 919
1005 gross 916 co=c.getControlPoints()
1006 jfenwick 3551 self.assertTrue(co[0]==p0, "1st control point is wrong.")
1007     self.assertTrue(co[1]==p1, "2nd control point is wrong.")
1008     self.assertTrue(co[2]==p2, "3rd control point is wrong.")
1009     self.assertTrue(co[3]==p3, "4th control point is wrong.")
1010 gross 916
1011     c.setLocalScale(3.)
1012     co=c.getControlPoints()
1013 jfenwick 3551 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1014     self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1015     self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1016     self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1017 gross 916
1018     h=c.getPrimitives()
1019 jfenwick 3551 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
1020     self.assertTrue(p0 in h, "missing p0 in history.")
1021     self.assertTrue(p1 in h, "missing p1 in history.")
1022     self.assertTrue(p2 in h, "missing p2 in history.")
1023     self.assertTrue(p3 in h, "missing p3 in history.")
1024     self.assertTrue(c in h, "missing spline curve in history.")
1025 gross 916
1026     cp=c.copy()
1027 gross 919 cpcp=cp.getControlPoints()
1028 jfenwick 3551 self.assertTrue(not cp == c, "copy returns same spline curve.")
1029     self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1030     self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1031     self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1032     self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1033     self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1034 gross 916
1035     c.modifyBy(Dilation(-1.))
1036 gross 919 cp=c.getControlPoints()
1037 jfenwick 3551 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.")
1038     self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
1039     self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
1040     self.assertTrue(p2 == cp[2],"3rd new point after Dilation.")
1041     self.assertTrue(p3 == cp[3],"4th new point after Dilation.")
1042 gross 916
1043     dc=c.apply(Dilation(-1.))
1044 gross 919 dccp=dc.getControlPoints()
1045 jfenwick 3551 self.assertTrue(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1046     self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1047     self.assertTrue(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1048     self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1049     self.assertTrue(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1050     self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1051     self.assertTrue(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1052     self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1053     self.assertTrue(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1054 gross 916
1055 gross 929 def test_ReverseBSpline(self):
1056     p0=Point(0,0,0,0.1)
1057     p1=Point(1,1,1,0.2)
1058     p2=Point(2,2,2,0.3)
1059     p3=Point(3,3,3,0.4)
1060     p4=Point(1,2,3)
1061     CC0=BSpline(p0,p1,p2,p3)
1062     c=-CC0
1063    
1064 jfenwick 3551 self.assertTrue(len(c) == 4, "wrong spline curve length")
1065     self.assertTrue(c.getStartPoint()==p3, "wrong start point of spline curve")
1066     self.assertTrue(c.getEndPoint()==p0, "wrong end point of spline curve")
1067 gross 929
1068 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1069     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1070 gross 930
1071 jfenwick 3551 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
1072     self.assertTrue(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1073     self.assertTrue(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1074     self.assertTrue(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1075     self.assertTrue(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1076     self.assertTrue(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1077 gross 929
1078     co=c.getControlPoints()
1079 jfenwick 3551 self.assertTrue(co[0]==p3, "1st control point is wrong.")
1080     self.assertTrue(co[1]==p2, "2nd control point is wrong.")
1081     self.assertTrue(co[2]==p1, "3rd control point is wrong.")
1082     self.assertTrue(co[3]==p0, "4th control point is wrong.")
1083 gross 929
1084     c.setLocalScale(3.)
1085     co=c.getControlPoints()
1086 jfenwick 3551 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1087     self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1088     self.assertTrue(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1089     self.assertTrue(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1090 gross 929
1091     h=c.getPrimitives()
1092 jfenwick 3551 self.assertTrue(len(h) == 5, "number of primitives in history is wrong.")
1093     self.assertTrue(p0 in h, "missing p0 in history.")
1094     self.assertTrue(p1 in h, "missing p1 in history.")
1095     self.assertTrue(p2 in h, "missing p2 in history.")
1096     self.assertTrue(p3 in h, "missing p3 in history.")
1097     self.assertTrue(CC0 in h, "missing spline curve in history.")
1098 gross 929
1099     cp=c.copy()
1100     cpcp=cp.getControlPoints()
1101 jfenwick 3551 self.assertTrue(not cp == c, "copy returns same spline curve.")
1102     self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1103     self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1104     self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1105     self.assertTrue(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1106     self.assertTrue(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1107 gross 929
1108     c.modifyBy(Dilation(-1.))
1109     cp=c.getControlPoints()
1110 jfenwick 3551 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.")
1111     self.assertTrue(p3 == cp[0],"1st new point after Dilation.")
1112     self.assertTrue(p2 == cp[1],"2nd new point after Dilation.")
1113     self.assertTrue(p1 == cp[2],"3rd new point after Dilation.")
1114     self.assertTrue(p0 == cp[3],"4th new point after Dilation.")
1115 gross 929
1116     dc=c.apply(Dilation(-1.))
1117     dccp=dc.getControlPoints()
1118 jfenwick 3551 self.assertTrue(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1119     self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1120     self.assertTrue(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1121     self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1122     self.assertTrue(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1123     self.assertTrue(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1124     self.assertTrue(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1125     self.assertTrue(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1126     self.assertTrue(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1127 gross 929
1128 gross 916 def test_LineSegment(self):
1129     p0=Point(0,0,0,0.1)
1130     p1=Point(1,1,1,0.2)
1131     p4=Point(1,2,3)
1132 jfenwick 3551 self.assertRaises(TypeError,Line,p0)
1133     self.assertRaises(TypeError,Line,p0,p1,p4)
1134 gross 916
1135     c=Line(p0,p1)
1136    
1137 jfenwick 3551 self.assertTrue(len(c) == 2, "wrong spline curve length")
1138     self.assertTrue(c.getStartPoint()==p0, "wrong start point of spline curve")
1139     self.assertTrue(c.getEndPoint()==p1, "wrong end point of spline curve")
1140 gross 916
1141 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1142     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1143 gross 930
1144 jfenwick 3551 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
1145     self.assertTrue(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1146     self.assertTrue(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1147     self.assertTrue(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1148     self.assertTrue(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1149 gross 919
1150 gross 916 co=c.getControlPoints()
1151 jfenwick 3551 self.assertTrue(co[0]==p0, "1st control point is wrong.")
1152     self.assertTrue(co[1]==p1, "2nd control point is wrong.")
1153 gross 916
1154     c.setLocalScale(3.)
1155     co=c.getControlPoints()
1156 jfenwick 3551 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1157     self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1158 gross 916
1159     h=c.getPrimitives()
1160 jfenwick 3551 self.assertTrue(len(h) == 3, "number of primitives in history is wrong.")
1161     self.assertTrue(p0 in h, "missing p0 in history.")
1162     self.assertTrue(p1 in h, "missing p1 in history.")
1163     self.assertTrue(c in h, "missing spline curve in history.")
1164 gross 916
1165     cp=c.copy()
1166 gross 919 cpcp=cp.getControlPoints()
1167 jfenwick 3551 self.assertTrue(not cp == c, "copy returns same spline curve.")
1168     self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1169     self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1170     self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1171 gross 916
1172     c.modifyBy(Dilation(-1.))
1173 gross 919 cp=c.getControlPoints()
1174 jfenwick 3551 self.assertTrue(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1175     self.assertTrue(p0 == cp[0],"1st new point after Dilation.")
1176     self.assertTrue(p1 == cp[1],"2nd new point after Dilation.")
1177 gross 916
1178     dc=c.apply(Dilation(-1.))
1179 gross 919 dccp=dc.getControlPoints()
1180 jfenwick 3551 self.assertTrue(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1181     self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1182     self.assertTrue(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1183     self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1184     self.assertTrue(dccp[1].isColocated(Point(1,1,1)),"2st point of Dilation is is wrongly located.")
1185 gross 916
1186 jfenwick 3551 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1187 gross 2429 dc.setElementDistribution(10,0.2,False)
1188     d=dc.getElementDistribution()
1189 jfenwick 3551 self.assertTrue(d[0] == 10, "number of element is wrong.")
1190     self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1191     self.assertTrue(d[2] == False, "bump flag wrong")
1192 gross 2429 dc.resetElementDistribution()
1193 jfenwick 3551 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1194 gross 2429
1195 gross 929 def test_ReverseLineSegment(self):
1196     p0=Point(0,0,0,0.1)
1197     p1=Point(1,1,1,0.2)
1198     p4=Point(1,2,3)
1199 jfenwick 3551 self.assertRaises(TypeError,Line,p0)
1200     self.assertRaises(TypeError,Line,p0,p1,p4)
1201 gross 929
1202     CC0=Line(p0,p1)
1203     c=-CC0
1204    
1205 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1206     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1207 gross 930
1208 jfenwick 3551 self.assertTrue(len(c) == 2, "wrong spline curve length")
1209     self.assertTrue(c.getStartPoint()==p1, "wrong start point of spline curve")
1210     self.assertTrue(c.getEndPoint()==p0, "wrong end point of spline curve")
1211 gross 929
1212 jfenwick 3551 self.assertTrue(not c.isColocated(p1),"spline is colocated with point.")
1213     self.assertTrue(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1214     self.assertTrue(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1215     self.assertTrue(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1216     self.assertTrue(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1217 gross 929
1218     co=c.getControlPoints()
1219 jfenwick 3551 self.assertTrue(co[0]==p1, "1st control point is wrong.")
1220     self.assertTrue(co[1]==p0, "2nd control point is wrong.")
1221 gross 929
1222     c.setLocalScale(3.)
1223     co=c.getControlPoints()
1224 jfenwick 3551 self.assertTrue(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1225     self.assertTrue(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1226 gross 929
1227     h=c.getPrimitives()
1228 jfenwick 3551 self.assertTrue(len(h) == 3, "number of primitives in history is wrong.")
1229     self.assertTrue(p0 in h, "missing p0 in history.")
1230     self.assertTrue(p1 in h, "missing p1 in history.")
1231     self.assertTrue(CC0 in h, "missing spline curve in history.")
1232 gross 929
1233     cp=c.copy()
1234     cpcp=cp.getControlPoints()
1235 jfenwick 3551 self.assertTrue(not cp == c, "copy returns same spline curve.")
1236     self.assertTrue(c.isColocated(cp),"spline curve is not colocated with its copy.")
1237     self.assertTrue(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1238     self.assertTrue(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1239 gross 929
1240     c.modifyBy(Dilation(-1.))
1241     cp=c.getControlPoints()
1242 jfenwick 3551 self.assertTrue(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1243     self.assertTrue(p1 == cp[0],"1st new point after Dilation.")
1244     self.assertTrue(p0 == cp[1],"2nd new point after Dilation.")
1245 gross 929
1246     dc=c.apply(Dilation(-1.))
1247     dccp=dc.getControlPoints()
1248 jfenwick 3551 self.assertTrue(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1249     self.assertTrue(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1250     self.assertTrue(dccp[0].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1251     self.assertTrue(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1252     self.assertTrue(dccp[1].isColocated(Point(0,0,0)),"2st point of Dilation is is wrongly located.")
1253 gross 929
1254 jfenwick 3551 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1255 gross 2429 dc.setElementDistribution(10,0.2,False)
1256     d=dc.getElementDistribution()
1257 jfenwick 3551 self.assertTrue(d[0] == 10, "number of element is wrong.")
1258     self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1259     self.assertTrue(d[2] == False, "bump flag wrong")
1260 gross 2429 dc.resetElementDistribution()
1261 jfenwick 3551 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1262 gross 2429
1263 gross 929 def test_Arc(self):
1264 gross 917 center=Point(0,0,0,0.1)
1265     p_start=Point(1,1,1,0.2)
1266     p_end=Point(1,2,3)
1267 gross 919 p4=Point(10,2,3)
1268 caltinay 5394
1269 jfenwick 3551 self.assertRaises(TypeError,Arc,Primitive())
1270 gross 916
1271 gross 917 c=Arc(center,p_start,p_end)
1272    
1273 jfenwick 3551 self.assertTrue(c.getCenterPoint()==center, "wrong center point")
1274     self.assertTrue(c.getStartPoint()==p_start, "wrong start point")
1275     self.assertTrue(c.getEndPoint()==p_end, "wrong end point")
1276 gross 917
1277 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1278     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1279 gross 930
1280 jfenwick 3551 self.assertTrue(not c.isColocated(p4),"spline is colocated with point.")
1281     self.assertTrue(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1282     self.assertTrue(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1283     self.assertTrue(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1284     self.assertTrue(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1285     self.assertTrue(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1286     self.assertTrue(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1287 gross 919
1288 gross 917 h=c.getPrimitives()
1289 jfenwick 3551 self.assertTrue(len(h) == 4, "number of primitives in history is wrong.")
1290     self.assertTrue(center in h, "missing center in history.")
1291     self.assertTrue(p_start in h, "missing p_start in history.")
1292     self.assertTrue(p_end in h, "missing p_end in history.")
1293     self.assertTrue(c in h, "missing spline curve in history.")
1294 gross 917
1295    
1296     c.setLocalScale(3.)
1297 jfenwick 3551 self.assertTrue(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1298     self.assertTrue(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1299     self.assertTrue(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1300 gross 917
1301     cp=c.copy()
1302 jfenwick 3551 self.assertTrue(isinstance(cp,Arc), "copy returns is not an arc.")
1303     self.assertTrue(not cp == c, "copy returns same arc.")
1304     self.assertTrue(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.")
1305     self.assertTrue(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1306     self.assertTrue(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1307     self.assertTrue(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1308 gross 917
1309     c.modifyBy(Dilation(-1.))
1310 jfenwick 3551 self.assertTrue(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1311     self.assertTrue(c.getCenterPoint() == center,"wrong center point after dilation.")
1312     self.assertTrue(c.getStartPoint() == p_start,"wrong start point after dilation.")
1313     self.assertTrue(c.getEndPoint() == p_end,"wrong end point after dilation.")
1314 gross 917
1315     dc=c.apply(Dilation(-1.))
1316 jfenwick 3551 self.assertTrue(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1317     self.assertTrue(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1318     self.assertTrue(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1319     self.assertTrue(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1320     self.assertTrue(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.")
1321     self.assertTrue(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1322     self.assertTrue(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.")
1323 gross 917
1324 jfenwick 3551 self.assertTrue(dc.getElementDistribution() == None, "element distribution set.")
1325 gross 2429 dc.setElementDistribution(10,0.2,False)
1326     d=dc.getElementDistribution()
1327 jfenwick 3551 self.assertTrue(d[0] == 10, "number of element is wrong.")
1328     self.assertTrue(d[1] == 0.2, "propagation factor is wrong.")
1329     self.assertTrue(d[2] == False, "bump flag wrong")
1330 gross 2429 dc.resetElementDistribution()
1331 jfenwick 3551 self.assertTrue(dc.getElementDistribution() == None, "resetted element distribution set.")
1332 gross 2429
1333 gross 929 def test_ReverseArc(self):
1334     center=Point(0,0,0,0.1)
1335     p_start=Point(1,1,1,0.2)
1336     p_end=Point(1,2,3)
1337     p4=Point(10,2,3)
1338 jfenwick 3551 self.assertRaises(TypeError,Arc,Primitive())
1339 gross 929
1340     CC0=Arc(center,p_start,p_end)
1341     c=-CC0
1342    
1343 jfenwick 3551 self.assertTrue(c.getCenterPoint()==center, "wrong center point")
1344     self.assertTrue(c.getStartPoint()==p_end, "wrong start point")
1345     self.assertTrue(c.getEndPoint()==p_start, "wrong end point")
1346 gross 929
1347 jfenwick 3551 self.assertTrue(c.hasSameOrientation(c),"has not same orientation like itself")
1348     self.assertTrue(not c.hasSameOrientation(-c),"has same orientation like -itself")
1349 gross 930
1350 jfenwick 3551 self.assertTrue(not c.isColocated(p4),"spline is colocated with point.")
1351     self.assertTrue(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1352     self.assertTrue(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1353     self.assertTrue(not c.isColocated(Arc(center,p_start