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