/[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 1006 - (hide annotations)
Sun Mar 4 23:15:15 2007 UTC (13 years, 6 months ago) by ksteube
File MIME type: text/x-python
File size: 187591 byte(s)
pycad test was failing due to typo and to missing parameter in Design.setOptions

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