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