/[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 1109 - (hide annotations)
Thu Apr 19 04:21:43 2007 UTC (15 years, 7 months ago) by btully
File MIME type: text/x-python
File size: 216250 byte(s)


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