/[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 928 - (hide annotations)
Tue Jan 16 08:36:03 2007 UTC (12 years, 9 months ago) by gross
File MIME type: text/x-python
File size: 86231 byte(s)
more tests but there is a problem with reversing directions.
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     def test_baseclass(self):
602     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 916 hs=p.getPrimitives()
609 gross 912 self.failUnless(len(hs)==0,"history should be empty.")
610    
611 gross 916 ps=p.getConstructionPoints()
612 gross 912 self.failUnless(len(ps)==0,"point set should be empty.")
613    
614     def test_point(self):
615     p=Point(1.,2.,3.,local_scale=9.)
616    
617     id=p.getID()
618     self.failUnless(isinstance(id,int),"id number is not an integer")
619 gross 915 self.failUnless(not id==Primitive().getID(),"id number is not unique")
620 gross 912
621 gross 915 # check history:
622 gross 916 hs=p.getPrimitives()
623 gross 912 self.failUnless(len(hs)==1,"history must have length 1.")
624     self.failUnless(p in hs,"history must contain point p")
625    
626 gross 915 # check incolved points:
627 gross 916 ps=p.getConstructionPoints()
628 gross 912 self.failUnless(len(ps)==1,"point set must have length 1.")
629     self.failUnless(p in ps,"point set must contain point p")
630    
631 gross 915 # check coordinates:
632 gross 912 c=p.getCoordinates()
633     self.failUnless(isinstance(c,numarray.NumArray),"coordinates are not a numarray object.")
634     self.failUnless(c[0]==1.,"x coordinate is not 1.")
635     self.failUnless(c[1]==2.,"y coordinate is not 2.")
636     self.failUnless(c[2]==3.,"z coordinate is not 3.")
637    
638 gross 915 # reset coordinates:
639     p.setCoordinates([-1.,-2.,-3.])
640 gross 912 c=p.getCoordinates()
641     self.failUnless(isinstance(c,numarray.NumArray),"new coordinates are not a numarray object.")
642     self.failUnless(c[0]==-1.,"new x coordinate is not -1.")
643     self.failUnless(c[1]==-2.,"new y coordinate is not -2.")
644     self.failUnless(c[2]==-3.,"new z coordinate is not -3.")
645    
646 gross 915 # check for a colocated point:
647 gross 912 self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.")
648 gross 916 self.failUnless(not p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.")
649     self.failUnless(not p.isColocated(Point(1.,-2.,-3.)),"false colocation detected.")
650     self.failUnless(not p.isColocated(Point(0.,0.,0.)),"false colocation with origin detected.")
651 gross 912
652 gross 915 # check for local length scale
653 gross 912 l=p.getLocalScale()
654     self.failUnless(l==9.,"refinement scale is not 9.")
655    
656 gross 915 # check for new local length scale
657 gross 912 p.setLocalScale(3.)
658     l=p.getLocalScale()
659     self.failUnless(l==3.,"new refinement scale is not 3.")
660    
661 gross 915 # negative value shouldn't work.
662     self.failUnlessRaises(ValueError,p.setLocalScale,-3.)
663    
664     # copy:
665     an_other_p=p.copy()
666     self.failUnless(isinstance(an_other_p ,Point),"copy is not a point")
667     self.failUnless(not an_other_p.getID() == p.getID(),"copy has same Id")
668     self.failUnless(p.isColocated(an_other_p),"p is not colocated with its copy.")
669     self.failUnless(an_other_p.isColocated(p),"the copy is not colocated with p.")
670     self.failUnless(an_other_p.getLocalScale()==3.,"copy has wrong local scale.")
671    
672     # modify by Transformation:
673     p.modifyBy(Dilation(-1))
674     self.failUnless(p.isColocated(Point(1.,2.,3.)),"in-place transformation failed")
675    
676     # apply Transformation:
677     dil_p=p.apply(Dilation(4))
678     self.failUnless(dil_p.isColocated(Point(4.,8.,12.)),"applying transformation failed")
679     self.failUnless(not dil_p.getID() == p.getID(),"transformed point has same Id")
680     self.failUnless(dil_p.getLocalScale()==3.,"transformed point has wrong local scale.")
681    
682     # overloaded add:
683     shift_p=p+[1,1,1]
684     self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by list failed")
685     self.failUnless(not shift_p.getID() == p.getID(),"shift by list has same Id")
686     self.failUnless(shift_p.getLocalScale()==3.,"shift by list has wrong local scale.")
687    
688     shift_p=p+numarray.array([1,1,1])
689     self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by numarray failed")
690     self.failUnless(not shift_p.getID() == p.getID(),"shift by numarray has same Id")
691     self.failUnless(shift_p.getLocalScale()==3.,"shift by numarray has wrong local scale.")
692     # overloaded minus
693     shift_p=p-[1,1,1]
694     self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -list failed")
695     self.failUnless(not shift_p.getID() == p.getID(),"shift by -list has same Id")
696     self.failUnless(shift_p.getLocalScale()==3.,"shift by -list has wrong local scale.")
697    
698     shift_p=p-numarray.array([1,1,1])
699     self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -numarray failed")
700     self.failUnless(not shift_p.getID() == p.getID(),"shift by -numarray has same Id")
701     self.failUnless(shift_p.getLocalScale()==3.,"shift by -numarray has wrong local scale.")
702     # overloaded inplace add:
703     p+=[1,1,1]
704     self.failUnless(p.isColocated(Point(2,3.,4)),"modification by list shift failed")
705    
706     p+=numarray.array([1,1,1])
707     self.failUnless(p.isColocated(Point(3,4,5)),"modification by numarray shift failed")
708    
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(1,2.,3)),"modification by -numarray shift failed")
715    
716     #overloaded multiplication:
717     mult_p=2*p
718     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying int factor failed")
719     self.failUnless(not mult_p.getID() == p.getID(),"shift by int factor has same Id")
720     self.failUnless(mult_p.getLocalScale()==3.,"shift by int factor has wrong local scale.")
721    
722     mult_p=2.*p
723     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying float factor failed")
724     self.failUnless(not mult_p.getID() == p.getID(),"shift by float factor has same Id")
725     self.failUnless(mult_p.getLocalScale()==3.,"shift by float factor has wrong local scale.")
726    
727     mult_p=Dilation(2)*p
728     self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying Dilation factor failed")
729     self.failUnless(not mult_p.getID() == p.getID(),"shift by Dilation factor has same Id")
730     self.failUnless(mult_p.getLocalScale()==3.,"shift by Dilation factor has wrong local scale.")
731    
732     #overloaded inplace multiplication:
733     p*=2
734     self.failUnless(p.isColocated(Point(2,4,6)),"applying in-place int factor failed")
735    
736     p*=2.
737     self.failUnless(p.isColocated(Point(4,8,12)),"applying in-place float factor failed")
738    
739     p*=Dilation(2)
740     self.failUnless(p.isColocated(Point(8,16,24)),"applying in-place Dilation factor failed")
741    
742     # get gmsh code
743     code=p.getGmshCommand(2.)
744     self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code")
745    
746 gross 916 def test_spline(self):
747     p0=Point(0,0,0,0.1)
748     p1=Point(1,1,1,0.2)
749     p2=Point(2,2,2,0.3)
750     p3=Point(3,3,3,0.4)
751     p4=Point(1,2,3)
752    
753     self.failUnlessRaises(TypeError,Spline,p0)
754     c=Spline(p0,p1,p2,p3)
755 gross 915
756 gross 916 self.failUnless(len(c) == 4, "wrong spline curve length")
757     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
758     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
759    
760 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
761     self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"spline is colocated with spline of different length.")
762     self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
763     self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
764     self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
765     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
766    
767 gross 916 co=c.getControlPoints()
768     self.failUnless(co[0]==p0, "1st control point is wrong.")
769     self.failUnless(co[1]==p1, "2nd control point is wrong.")
770     self.failUnless(co[2]==p2, "3rd control point is wrong.")
771     self.failUnless(co[3]==p3, "4th control point is wrong.")
772    
773     c.setLocalScale(3.)
774     co=c.getControlPoints()
775     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
776     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
777     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
778     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
779    
780     code=c.getGmshCommand()
781     self.failUnless(code == "Spline(6) = {1, 2, 3, 4};", "gmsh command wrong.")
782    
783     h=c.getPrimitives()
784     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
785     self.failUnless(p0 in h, "missing p0 in history.")
786     self.failUnless(p1 in h, "missing p1 in history.")
787     self.failUnless(p2 in h, "missing p2 in history.")
788     self.failUnless(p3 in h, "missing p3 in history.")
789     self.failUnless(c in h, "missing spline curve in history.")
790    
791     cp=c.copy()
792 gross 919 cpcp=cp.getControlPoints()
793 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
794 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
795     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
796     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
797     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
798     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
799 gross 916
800     c.modifyBy(Dilation(-1.))
801 gross 919 cp=c.getControlPoints()
802 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.")
803     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
804     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
805     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
806     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
807    
808     dc=c.apply(Dilation(-1.))
809 gross 919 dccp=dc.getControlPoints()
810 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.")
811     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
812     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
813     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
814     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
815    
816    
817     def test_BezierCurve(self):
818     p0=Point(0,0,0,0.1)
819     p1=Point(1,1,1,0.2)
820     p2=Point(2,2,2,0.3)
821     p3=Point(3,3,3,0.4)
822     p4=Point(1,2,3)
823    
824     self.failUnlessRaises(TypeError,BezierCurve,p0)
825     c=BezierCurve(p0,p1,p2,p3)
826    
827     self.failUnless(len(c) == 4, "wrong spline curve length")
828     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
829     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
830    
831 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
832     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p2)),"spline is colocated with spline of different length.")
833     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
834     self.failUnless(c.isColocated(BezierCurve(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
835     self.failUnless(c.isColocated(BezierCurve(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
836     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
837    
838 gross 916 co=c.getControlPoints()
839     self.failUnless(co[0]==p0, "1st control point is wrong.")
840     self.failUnless(co[1]==p1, "2nd control point is wrong.")
841     self.failUnless(co[2]==p2, "3rd control point is wrong.")
842     self.failUnless(co[3]==p3, "4th control point is wrong.")
843    
844     c.setLocalScale(3.)
845     co=c.getControlPoints()
846     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
847     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
848     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
849     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
850    
851     code=c.getGmshCommand()
852     self.failUnless(code == "Bezier(6) = {1, 2, 3, 4};", "gmsh command wrong.")
853    
854     h=c.getPrimitives()
855     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
856     self.failUnless(p0 in h, "missing p0 in history.")
857     self.failUnless(p1 in h, "missing p1 in history.")
858     self.failUnless(p2 in h, "missing p2 in history.")
859     self.failUnless(p3 in h, "missing p3 in history.")
860     self.failUnless(c in h, "missing spline curve in history.")
861    
862     cp=c.copy()
863 gross 919 cpcp=cp.getControlPoints()
864 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
865 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
866     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
867     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
868     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
869     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
870 gross 916
871     c.modifyBy(Dilation(-1.))
872 gross 919 cp=c.getControlPoints()
873 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.")
874     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
875     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
876     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
877     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
878    
879     dc=c.apply(Dilation(-1.))
880 gross 919 dccp=dc.getControlPoints()
881 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.")
882     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
883     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
884     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
885     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
886    
887     def test_BSpline(self):
888     p0=Point(0,0,0,0.1)
889     p1=Point(1,1,1,0.2)
890     p2=Point(2,2,2,0.3)
891     p3=Point(3,3,3,0.4)
892     p4=Point(1,2,3)
893    
894     self.failUnlessRaises(TypeError,BSpline,p0)
895     c=BSpline(p0,p1,p2,p3)
896    
897     self.failUnless(len(c) == 4, "wrong spline curve length")
898     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
899     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
900    
901 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
902     self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
903     self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
904     self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
905     self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
906     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
907    
908 gross 916 co=c.getControlPoints()
909     self.failUnless(co[0]==p0, "1st control point is wrong.")
910     self.failUnless(co[1]==p1, "2nd control point is wrong.")
911     self.failUnless(co[2]==p2, "3rd control point is wrong.")
912     self.failUnless(co[3]==p3, "4th control point is wrong.")
913    
914     c.setLocalScale(3.)
915     co=c.getControlPoints()
916     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
917     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
918     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
919     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
920    
921     code=c.getGmshCommand()
922     self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.")
923    
924     h=c.getPrimitives()
925     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
926     self.failUnless(p0 in h, "missing p0 in history.")
927     self.failUnless(p1 in h, "missing p1 in history.")
928     self.failUnless(p2 in h, "missing p2 in history.")
929     self.failUnless(p3 in h, "missing p3 in history.")
930     self.failUnless(c in h, "missing spline curve in history.")
931    
932     cp=c.copy()
933 gross 919 cpcp=cp.getControlPoints()
934 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
935 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
936     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
937     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
938     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
939     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
940 gross 916
941     c.modifyBy(Dilation(-1.))
942 gross 919 cp=c.getControlPoints()
943 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.")
944     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
945     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
946     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
947     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
948    
949     dc=c.apply(Dilation(-1.))
950 gross 919 dccp=dc.getControlPoints()
951 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.")
952     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
953     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
954     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
955     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
956    
957     def test_LineSegment(self):
958     p0=Point(0,0,0,0.1)
959     p1=Point(1,1,1,0.2)
960     p4=Point(1,2,3)
961    
962     self.failUnlessRaises(TypeError,Line,p0)
963     self.failUnlessRaises(TypeError,Line,p0,p1,p4)
964    
965     c=Line(p0,p1)
966    
967     self.failUnless(len(c) == 2, "wrong spline curve length")
968     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
969     self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve")
970    
971 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
972     self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
973     self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
974     self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
975     self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
976    
977 gross 916 co=c.getControlPoints()
978     self.failUnless(co[0]==p0, "1st control point is wrong.")
979     self.failUnless(co[1]==p1, "2nd control point is wrong.")
980    
981     c.setLocalScale(3.)
982     co=c.getControlPoints()
983     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
984     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
985    
986     code=c.getGmshCommand()
987     self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.")
988    
989     h=c.getPrimitives()
990     self.failUnless(len(h) == 3, "number of primitives in history is wrong.")
991     self.failUnless(p0 in h, "missing p0 in history.")
992     self.failUnless(p1 in h, "missing p1 in history.")
993     self.failUnless(c in h, "missing spline curve in history.")
994    
995     cp=c.copy()
996 gross 919 cpcp=cp.getControlPoints()
997 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
998 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
999     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1000     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1001 gross 916
1002     c.modifyBy(Dilation(-1.))
1003 gross 919 cp=c.getControlPoints()
1004 gross 916 self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1005     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
1006     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
1007    
1008     dc=c.apply(Dilation(-1.))
1009 gross 919 dccp=dc.getControlPoints()
1010 gross 916 self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1011     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1012     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1013    
1014 gross 917 def test_arc(self):
1015     center=Point(0,0,0,0.1)
1016     p_start=Point(1,1,1,0.2)
1017     p_end=Point(1,2,3)
1018 gross 919 p4=Point(10,2,3)
1019 gross 917
1020     self.failUnlessRaises(TypeError,Arc,Primitive())
1021 gross 916
1022 gross 917 c=Arc(center,p_start,p_end)
1023    
1024     self.failUnless(c.getCenterPoint()==center, "wrong center point")
1025     self.failUnless(c.getStartPoint()==p_start, "wrong start point")
1026     self.failUnless(c.getEndPoint()==p_end, "wrong end point")
1027    
1028     code=c.getGmshCommand()
1029 gross 919 self.failUnless(code == "Circle(6) = {2, 1, 3};", "gmsh command wrong.")
1030 gross 917
1031 gross 919 self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1032     self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1033     self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1034     self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1035     self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1036     self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1037     self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1038    
1039 gross 917 h=c.getPrimitives()
1040     self.failUnless(len(h) == 4, "number of primitives in history is wrong.")
1041     self.failUnless(center in h, "missing center in history.")
1042     self.failUnless(p_start in h, "missing p_start in history.")
1043     self.failUnless(p_end in h, "missing p_end in history.")
1044     self.failUnless(c in h, "missing spline curve in history.")
1045    
1046    
1047     c.setLocalScale(3.)
1048     self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1049     self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1050     self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1051    
1052     cp=c.copy()
1053     self.failUnless(isinstance(cp,Arc), "copy returns is not an arc.")
1054     self.failUnless(not cp == c, "copy returns same arc.")
1055 gross 919 self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.")
1056     self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1057     self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1058     self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1059 gross 917
1060     c.modifyBy(Dilation(-1.))
1061 gross 919 self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1062     self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.")
1063     self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.")
1064     self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.")
1065 gross 917
1066     dc=c.apply(Dilation(-1.))
1067 gross 919 self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1068     self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1069     self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1070     self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1071 gross 917
1072 gross 923 def test_CurveLoop(self):
1073     p0=Point(0,0,0,0.1)
1074     p1=Point(1,1,1,0.2)
1075     p2=Point(2,2,2,0.3)
1076     p3=Point(3,3,3,0.4)
1077     p4=Point(1,2,3)
1078 gross 925 p5=Point(10,20,3)
1079     p6=Point(1,2,30)
1080 gross 917
1081 gross 923 l01=Line(p0,p1)
1082     l12=Arc(p3,p1,p2)
1083     l20=Spline(p2,p4,p0)
1084    
1085     lx=Line(p2,p3)
1086     ly=Line(p3,p1)
1087    
1088     c=CurveLoop(l01,l12,l20)
1089     c=CurveLoop(l01,l20,l12)
1090     self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,lx,l20,msg="loop detected.")
1091     self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,l20,msg="douple not detected.")
1092     self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,ly,msg="loop detected.")
1093    
1094     code=c.getGmshCommand()
1095     self.failUnless(code == "Line Loop(14) = {8, 9, 10};", "gmsh command wrong.")
1096    
1097 gross 925
1098     self.failUnless(not c.isColocated(p4),"CurveLoop is colocated with point.")
1099     self.failUnless(c.isColocated(c),"CurveLoop is not colocated with its self.")
1100     self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.")
1101     self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.")
1102     self.failUnless(c.isColocated(CurveLoop(l20,l12,l01)),"CurveLoop is not colocated with its copy with shuffled points.")
1103     self.failUnless(not c.isColocated(CurveLoop(lx,ly,l12)),"CurveLoop is colocated with different CurveLoop.")
1104    
1105     self.failUnless(len(c) == 3, "wrong length")
1106    
1107     c.setLocalScale(3.)
1108     self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
1109     self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
1110     self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
1111     self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
1112    
1113 gross 928
1114 gross 923 cc=c.getCurves()
1115     self.failUnless(len(cc) == 3, "too many curves.")
1116     self.failUnless(l01 in cc, "l01 is missing")
1117     self.failUnless(l12 in cc, "l12 is missing")
1118     self.failUnless(l20 in cc, "l20 is missing")
1119 gross 925
1120     p=c.getPrimitives()
1121     self.failUnless(len(p) == 9, "too many primitives.")
1122     self.failUnless(l01 in p, "l01 is missing")
1123     self.failUnless(l12 in p, "l21 is missing")
1124     self.failUnless(l20 in p, "l20 is missing")
1125     self.failUnless(p0 in p, "p0 is missing")
1126     self.failUnless(p1 in p, "p1 is missing")
1127     self.failUnless(p2 in p, "p2 is missing")
1128     self.failUnless(p3 in p, "p3 is missing")
1129     self.failUnless(p4 in p, "p4 is missing")
1130    
1131     cp=c.copy()
1132     self.failUnless(isinstance(cp,CurveLoop), "copy returns is not an arc.")
1133     self.failUnless(not cp == c, "copy equals source")
1134 gross 928 self.failUnless(cp.isColocated(c),"copy is not colocated with its source.")
1135 gross 925 cc=cp.getCurves()
1136     self.failUnless(len(cc) == 3, "too many primitives in copy.")
1137     self.failUnless(not l01 in cc,"copy uses l01.")
1138     self.failUnless(not l12 in cc,"copy uses l12.")
1139     self.failUnless(not l20 in cc,"copy uses l20.")
1140    
1141     p0_m=Point(0,0,0)
1142     p1_m=Point(-1,-1,-1)
1143     p2_m=Point(-2,-2,-2)
1144     p3_m=Point(-3,-3,-3)
1145     p4_m=Point(-1,-2,-3)
1146    
1147     l01_m=Line(p0_m,p1_m)
1148     l12_m=Arc(p3_m,p1_m,p2_m)
1149     l20_m=Spline(p2_m,p4_m,p0_m)
1150    
1151     dc=c.apply(Dilation(-1.))
1152     self.failUnless(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.")
1153     cc=dc.getCurves()
1154     self.failUnless(len(cc) == 3, "too many primitives in dilation result.")
1155     self.failUnless(not l01 in cc,"l01 is in dilation result.")
1156     self.failUnless(not l12 in cc,"l12 is in dilation result.")
1157     self.failUnless(not l20 in cc,"l20 is in dilation result.")
1158    
1159     c.modifyBy(Dilation(-1.))
1160     self.failUnless(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.")
1161     cc=c.getCurves()
1162     self.failUnless(len(cc) == 3, "too many primitives in modified object.")
1163     self.failUnless(l01 in cc,"l01 missed in modified object.")
1164     self.failUnless(l12 in cc,"l12 missed in modified object.")
1165     self.failUnless(l20 in cc,"l20 missed in modified object.")
1166    
1167 gross 928 def test_RuledSurface(self):
1168     p0=Point(0,0,0,0.1)
1169     p1=Point(1,1,1,0.2)
1170     p2=Point(2,2,2,0.3)
1171     p3=Point(3,3,3,0.4)
1172     p4=Point(1,2,3)
1173     p5=Point(10,20,3)
1174     p6=Point(1,2,30)
1175    
1176     l01=Line(p0,p1)
1177     l12_1=Arc(p3,p1,p2)
1178     l12_2_1=Spline(p1,p3,p4)
1179     l12_2_2=Spline(p4,p5,p2)
1180     l12_3=Line(p1,p2)
1181     l20=Spline(p2,p4,p0)
1182    
1183     cl1=CurveLoop(l01,l12_1,l20)
1184     cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20)
1185     cl3=CurveLoop(l01,l12_3,l20)
1186    
1187     self.failUnlessRaises(TypeError,ValueError,RuledSurface,l01,msg="non CurveLoop argument accepted.")
1188    
1189     s=RuledSurface(cl1)
1190    
1191     cl=s.getBoundaryLoop()
1192     self.failUnless(cl == cl1, " wrong boundary loops")
1193    
1194     h=s.getHoles()
1195     self.failUnless(len(h) == 0, "too many holes.")
1196    
1197     crvs=s.getBoundary()
1198     self.failUnless(len(crvs) == 3, "too many boundary corves.")
1199     self.failUnless(l01 in crvs, "l01 is missing in boundary")
1200     self.failUnless(l12_1 in crvs, "l21 is missing in boundary")
1201     self.failUnless(l20 in crvs, "l20 is missing in boundary")
1202    
1203    
1204     code=s.getGmshCommand()
1205     self.failUnless(code == "Ruled Surface(17) = {14};", "gmsh command wrong.")
1206    
1207     self.failUnless(not s.isColocated(p4),"RuledSurface is colocated with point.")
1208     self.failUnless(s.isColocated(s),"RuledSurface is not colocated with its self.")
1209     self.failUnless(s.isColocated(RuledSurface(cl1)),"RuledSurface is not colocated with its copy.")
1210     self.failUnless(not s.isColocated(RuledSurface(cl2)),"RuledSurface is colocated with different length")
1211     self.failUnless(not s.isColocated(RuledSurface(cl3)),"RuledSurface is colocated with same length.")
1212    
1213     s.setLocalScale(3.)
1214     self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
1215     self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
1216     self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
1217     self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
1218    
1219     p=s.getPrimitives()
1220     self.failUnless(len(p) == 10, "too many primitives.")
1221     self.failUnless(cl1 in p, "cl1 is missing")
1222     self.failUnless(l01 in p, "l01 is missing")
1223     self.failUnless(l12_1 in p, "l21 is missing")
1224     self.failUnless(l20 in p, "l20 is missing")
1225     self.failUnless(p0 in p, "p0 is missing")
1226     self.failUnless(p1 in p, "p1 is missing")
1227     self.failUnless(p2 in p, "p2 is missing")
1228     self.failUnless(p3 in p, "p3 is missing")
1229     self.failUnless(p4 in p, "p4 is missing")
1230    
1231     sp=s.copy()
1232     self.failUnless(isinstance(sp,RuledSurface), "copy returns is not a RuledSurface.")
1233     self.failUnless(not sp == s, "copy equals source")
1234     self.failUnless(sp.isColocated(s),"copy is not colocated with its source.")
1235     cbl=sp.getBoundaryLoop()
1236     self.failUnless(not cbl == cl1,"copy uses cl1.")
1237     cp=sp.getPrimitives()
1238     self.failUnless(len(cp) == 10, "copy as too many primitives.")
1239     self.failUnless(not cl1 in cp, "copy is using cl1")
1240     self.failUnless(not l01 in cp, "copy is using l01")
1241     self.failUnless(not l12_1 in cp, "copy is using l21")
1242     self.failUnless(not l20 in cp, "copy is using l20")
1243     self.failUnless(not p0 in cp, "copy is using p0")
1244     self.failUnless(not p1 in cp, "copy is using p1")
1245     self.failUnless(not p2 in cp, "copy is using p2")
1246     self.failUnless(not p3 in cp, "copy is using p3")
1247     self.failUnless(not p4 in cp, "copy is using p4")
1248     del cp
1249    
1250     p0_m=Point(0,0,0)
1251     p1_m=Point(-1,-1,-1)
1252     p2_m=Point(-2,-2,-2)
1253     p3_m=Point(-3,-3,-3)
1254     p4_m=Point(-1,-2,-3)
1255    
1256     l01_m=Line(p0_m,p1_m)
1257     l12_m=Arc(p3_m,p1_m,p2_m)
1258     l20_m=Spline(p2_m,p4_m,p0_m)
1259    
1260     ds=s.apply(Dilation(-1.))
1261     self.failUnless(ds.isColocated(RuledSurface(CurveLoop(l01_m,l12_m,l20_m))),"dilation is wrong.")
1262     cbl=ds.getBoundaryLoop()
1263     self.failUnless(not cbl == cl1,"dilation uses cl1.")
1264     cp=ds.getPrimitives()
1265     self.failUnless(len(cp) == 10, "dilation as too many primitives.")
1266     self.failUnless(not cl1 in cp, "dilation is using cl1")
1267     self.failUnless(not l01 in cp, "dilation is using l01")
1268     self.failUnless(not l12_1 in cp, "dilation is using l21")
1269     self.failUnless(not l20 in cp, "dilation is using l20")
1270     self.failUnless(not p0 in cp, "dilation is using p0")
1271     self.failUnless(not p1 in cp, "dilation is using p1")
1272     self.failUnless(not p2 in cp, "dilation is using p2")
1273     self.failUnless(not p3 in cp, "dilation is using p3")
1274     self.failUnless(not p4 in cp, "dilation is using p4")
1275    
1276     s.modifyBy(Dilation(-1.))
1277     self.failUnless(s.isColocated(RuledSurface(CurveLoop(l01_m,l12_m,l20_m))),"inplace dilation is wrong.")
1278    
1279     p=s.getPrimitives()
1280     self.failUnless(len(p) == 10, "inplace dilation has too many primitives.")
1281     self.failUnless(cl1 in p, "inplace dilation cl1 is missing")
1282     self.failUnless(l01 in p, "inplace dilation l01 is missing")
1283     self.failUnless(l12_1 in p, "inplace dilation l21 is missing")
1284     self.failUnless(l20 in p, "inplace dilation l20 is missing")
1285     self.failUnless(p0 in p, "inplace dilation p0 is missing")
1286     self.failUnless(p1 in p, "inplace dilation p1 is missing")
1287     self.failUnless(p2 in p, "inplace dilation p2 is missing")
1288     self.failUnless(p3 in p, "inplace dilation p3 is missing")
1289     self.failUnless(p4 in p, "inplace dilation p4 is missing")
1290    
1291     def test_PlaneSurface(self):
1292     p0=Point(0,0,0,0.1)
1293     p1=Point(10,0,0,0.2)
1294     p2=Point(10,10,0,0.3)
1295     p3=Point(0,10,3,0.4)
1296     p4=Point(5,5,0,0.001)
1297     p5=Point(7,5,0,0.001)
1298     p6=Point(5,7,0,0.001)
1299     p7=Point(8,8,0,0.001)
1300     p8=Point(9,9,0,0.001)
1301    
1302     l0=Line(p0,p1)
1303     l1=Line(p1,p2)
1304     l2=Line(p2,p3)
1305     l3=Line(p3,p0)
1306    
1307     l9=Line(p1,p8)
1308     l10=Line(p8,p3)
1309    
1310     l4=Line(p4,p5)
1311     l5=Line(p5,p6)
1312     l6=Line(p6,p4)
1313     l7=Line(p6,p7)
1314     l8=Line(p7,p4)
1315    
1316     a1=Arc(p4,p3,p1)
1317     a2=Arc(p7,p5,p6)
1318    
1319     cl=CurveLoop(l0,l1,l2,l3)
1320     h=CurveLoop(l4,l5,l6)
1321     cl_s=CurveLoop(l0,l9,l10,l3)
1322     h2=CurveLoop(l4,l5,l7,l8)
1323     cl_a=CurveLoop(a1,l1,l2)
1324     h_a=CurveLoop(a2,l6,l4)
1325    
1326     self.failUnlessRaises(TypeError,ValueError,PlaneSurface,l4,msg="non CurveLoop argument accepted.")
1327     self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl_a,h,msg="CurveLoop with no line curves accepted.")
1328     self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl,[h_a],msg="CurveLoop with no line curves as holes accepted.")
1329    
1330     s=PlaneSurface(cl,holes=[h])
1331    
1332     cl=s.getBoundaryLoop()
1333     self.failUnless(cl == cl, " wrong boundary loops")
1334    
1335     hs=s.getHoles()
1336     self.failUnless(len(hs) == 1, "one holes expected.")
1337     self.failUnless(h in hs, "h is not defined as hole.")
1338    
1339     crvs=s.getBoundary()
1340     self.failUnless(len(crvs) == 7, "too many boundary corves.")
1341     self.failUnless(l0 in crvs, "l0 is missing in boundary")
1342     self.failUnless(l1 in crvs, "l1 is missing in boundary")
1343     self.failUnless(l2 in crvs, "l2 is missing in boundary")
1344     self.failUnless(l3 in crvs, "l3 is missing in boundary")
1345     self.failUnless(l4 in crvs, "l4 is missing in boundary")
1346     self.failUnless(l5 in crvs, "l5 is missing in boundary")
1347     self.failUnless(l6 in crvs, "l6 is missing in boundary")
1348    
1349     code=s.getGmshCommand()
1350     self.failUnless(code == "Plane Surface(29) = {23, 24};", "gmsh command wrong.")
1351    
1352     self.failUnless(not s.isColocated(p4),"PlaneSurface is colocated with point.")
1353     self.failUnless(s.isColocated(s),"PlaneSurface is not colocated with its self.")
1354     self.failUnless(s.isColocated(PlaneSurface(cl,holes=[h])),"PlaneSurface is not colocated with its copy.")
1355     self.failUnless(not s.isColocated(PlaneSurface(cl)),"PlaneSurface is colocated with PlaneSurface with same boundary but no hole")
1356     self.failUnless(not s.isColocated(PlaneSurface(cl_s,holes=[h])),"PlaneSurface is colocated with PlaneSurface with deformed boundary")
1357     self.failUnless(not s.isColocated(PlaneSurface(cl,holes=[h2])),"PlaneSurface is colocated with modified hole")
1358    
1359     s.setLocalScale(3.)
1360     self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
1361     self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
1362     self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
1363     self.failUnless(p3.getLocalScale()==3., "p3 has wrong local scale.")
1364     self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
1365     self.failUnless(p5.getLocalScale()==3., "p5 has wrong local scale.")
1366     self.failUnless(p6.getLocalScale()==3., "p6 has wrong local scale.")
1367    
1368     p=s.getPrimitives()
1369     self.failUnless(len(p) == 17, "too many primitives.")
1370     self.failUnless(s in p, "cl is missing")
1371     self.failUnless(cl in p, "cl is missing")
1372     self.failUnless(h in p, "h is missing")
1373     self.failUnless(l0 in p, "l0 is missing")
1374     self.failUnless(l1 in p, "l1 is missing")
1375     self.failUnless(l2 in p, "l2 is missing")
1376     self.failUnless(l3 in p, "l3 is missing")
1377     self.failUnless(l4 in p, "l4 is missing")
1378     self.failUnless(l5 in p, "l5 is missing")
1379     self.failUnless(l6 in p, "l6 is missing")
1380     self.failUnless(p0 in p, "p0 is missing")
1381     self.failUnless(p1 in p, "p1 is missing")
1382     self.failUnless(p2 in p, "p2 is missing")
1383     self.failUnless(p3 in p, "p3 is missing")
1384     self.failUnless(p4 in p, "p4 is missing")
1385     self.failUnless(p5 in p, "p5 is missing")
1386     self.failUnless(p6 in p, "p6 is missing")
1387    
1388     sp=s.copy()
1389     self.failUnless(isinstance(sp,PlaneSurface), "copy returns is not a PlaneSurface.")
1390     self.failUnless(not sp == s, "copy equals source")
1391     self.failUnless(sp.isColocated(s),"copy is not colocated with its source.")
1392     cbl=sp.getBoundaryLoop()
1393     self.failUnless(not cbl == cl,"copy uses cl1.")
1394     hs=sp.getHoles()
1395     self.failUnless(len(hs)==1,"copy is missing holes.")
1396     self.failUnless(not hs[0]== h,"copy contains h as a hole.")
1397     cp=sp.getPrimitives()
1398     self.failUnless(len(cp) == 17, "copy as too many primitives.")
1399     self.failUnless(not s in cp, "copy contains s")
1400     self.failUnless(not cl in cp, "copy contains cl")
1401     self.failUnless(not h in cp, "copy contains h")
1402     self.failUnless(not l0 in cp, "copy contains l0")
1403     self.failUnless(not l1 in cp, "copy contains l1")
1404     self.failUnless(not l2 in cp, "copy contains l2")
1405     self.failUnless(not l3 in cp, "copy contains l3")
1406     self.failUnless(not l4 in cp, "copy contains l4")
1407     self.failUnless(not l5 in cp, "copy contains l5")
1408     self.failUnless(not l6 in cp, "copy contains l6")
1409     self.failUnless(not p0 in cp, "copy contains p0")
1410     self.failUnless(not p1 in cp, "copy contains p1")
1411     self.failUnless(not p2 in cp, "copy contains p2")
1412     self.failUnless(not p3 in cp, "copy contains p3")
1413     self.failUnless(not p4 in cp, "copy contains p4")
1414     self.failUnless(not p5 in cp, "copy contains p5")
1415     self.failUnless(not p6 in cp, "copy contains p6")
1416     del sp
1417    
1418    
1419     p0_m=Point(0,0,0,0.1)
1420     p1_m=Point(-10,0,0,0.2)
1421     p2_m=Point(-10,-10,0,0.3)
1422     p3_m=Point(0,-10,-3,0.4)
1423     p4_m=Point(-5,-5,0,0.001)
1424     p5_m=Point(-7,-5,0,0.001)
1425     p6_m=Point(-5,-7,0,0.001)
1426    
1427     l0_m=Line(p0_m,p1_m)
1428     l1_m=Line(p1_m,p2_m)
1429     l2_m=Line(p2_m,p3_m)
1430     l3_m=Line(p3_m,p0_m)
1431    
1432     l4_m=Line(p4_m,p5_m)
1433     l5_m=Line(p5_m,p6_m)
1434     l6_m=Line(p6_m,p4_m)
1435    
1436     cl_m=CurveLoop(l0_m,l1_m,l2_m,l3_m)
1437     h_m=CurveLoop(l4_m,l5_m,l6_m)
1438    
1439     ds=s.apply(Dilation(-1.))
1440     self.failUnless(ds.isColocated(PlaneSurface(cl_m,holes=[h_m])),"dilation is wrong.")
1441     cbl=ds.getBoundaryLoop()
1442     self.failUnless(not cbl == cl,"dilation uses cl1.")
1443     hs=ds.getHoles()
1444     self.failUnless(len(hs)==1,"dilation is missing holes.")
1445     self.failUnless(not hs[0]== h,"dilation contains h as a hole.")
1446     cp=ds.getPrimitives()
1447     self.failUnless(len(cp) == 17, "dilation as too many primitives.")
1448     self.failUnless(not s in cp, "dilation contains s")
1449     self.failUnless(not cl in cp, "dilation contains cl")
1450     self.failUnless(not h in cp, "dilation contains h")
1451     self.failUnless(not l0 in cp, "dilation contains l0")
1452     self.failUnless(not l1 in cp, "dilation contains l1")
1453     self.failUnless(not l2 in cp, "dilation contains l2")
1454     self.failUnless(not l3 in cp, "dilation contains l3")
1455     self.failUnless(not l4 in cp, "dilation contains l4")
1456     self.failUnless(not l5 in cp, "dilation contains l5")
1457     self.failUnless(not l6 in cp, "dilation contains l6")
1458     self.failUnless(not p0 in cp, "dilation contains p0")
1459     self.failUnless(not p1 in cp, "dilation contains p1")
1460     self.failUnless(not p2 in cp, "dilation contains p2")
1461     self.failUnless(not p3 in cp, "dilation contains p3")
1462     self.failUnless(not p4 in cp, "dilation contains p4")
1463     self.failUnless(not p5 in cp, "dilation contains p5")
1464     self.failUnless(not p6 in cp, "dilation contains p6")
1465    
1466     s.