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