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