/[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 1045 - (hide annotations)
Tue Mar 20 01:30:58 2007 UTC (12 years, 8 months ago) by gross
File MIME type: text/x-python
File size: 214836 byte(s)
some modifications on the pycad implementation to make it easier to build
interfaces for other mesh generators. The script statement generation is now
done by the Design and not the Primitive classes.


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 gross 929 def test_Spline(self):
754 gross 916 p0=Point(0,0,0,0.1)
755     p1=Point(1,1,1,0.2)
756     p2=Point(2,2,2,0.3)
757     p3=Point(3,3,3,0.4)
758     p4=Point(1,2,3)
759    
760 gross 931 self.failUnlessRaises(ValueError,Spline,p0)
761 gross 916 c=Spline(p0,p1,p2,p3)
762 gross 915
763 gross 916 self.failUnless(len(c) == 4, "wrong spline curve length")
764     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
765     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
766    
767 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
768     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
769    
770 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
771     self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"spline is colocated with spline of different length.")
772     self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
773     self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
774     self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
775     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
776    
777 gross 916 co=c.getControlPoints()
778     self.failUnless(co[0]==p0, "1st control point is wrong.")
779     self.failUnless(co[1]==p1, "2nd control point is wrong.")
780     self.failUnless(co[2]==p2, "3rd control point is wrong.")
781     self.failUnless(co[3]==p3, "4th control point is wrong.")
782    
783     c.setLocalScale(3.)
784     co=c.getControlPoints()
785     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
786     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
787     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
788     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
789    
790     h=c.getPrimitives()
791     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
792     self.failUnless(p0 in h, "missing p0 in history.")
793     self.failUnless(p1 in h, "missing p1 in history.")
794     self.failUnless(p2 in h, "missing p2 in history.")
795     self.failUnless(p3 in h, "missing p3 in history.")
796     self.failUnless(c in h, "missing spline curve in history.")
797    
798     cp=c.copy()
799 gross 919 cpcp=cp.getControlPoints()
800 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
801 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
802     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
803     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
804     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
805     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
806 gross 916
807     c.modifyBy(Dilation(-1.))
808 gross 919 cp=c.getControlPoints()
809 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.")
810     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
811     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
812     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
813     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
814    
815     dc=c.apply(Dilation(-1.))
816 gross 919 dccp=dc.getControlPoints()
817 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.")
818     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
819 gross 929 self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
820 gross 916 self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
821 gross 929 self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
822 gross 916 self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
823 gross 929 self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
824 gross 916 self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
825 gross 929 self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
826 gross 916
827 gross 929 def test_ReverseSpline(self):
828     p0=Point(0,0,0,0.1)
829     p1=Point(1,1,1,0.2)
830     p2=Point(2,2,2,0.3)
831     p3=Point(3,3,3,0.4)
832     p4=Point(1,2,3)
833    
834     CC0=Spline(p0,p1,p2,p3)
835     c=-CC0
836 gross 916
837 gross 929 self.failUnless(len(c) == 4, "wrong reverse spline curve length")
838     self.failUnless(c.getStartPoint()==p3, "wrong start point of reverse spline curve")
839     self.failUnless(c.getEndPoint()==p0, "wrong end point of reverse spline curve")
840    
841 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
842     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
843    
844 gross 929 self.failUnless(not c.isColocated(p1),"reverse spline is colocated with point.")
845     self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"reverse spline is colocated with spline of different length.")
846     self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"reverse spline is colocated with spline with different point.")
847     self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"reverse spline is not colocated with spline with same points but opposite direction.")
848     self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"reverse spline is not colocated with spline with same points.")
849     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
850    
851     co=c.getControlPoints()
852     self.failUnless(co[0]==p3, "1st control point is wrong.")
853     self.failUnless(co[1]==p2, "2nd control point is wrong.")
854     self.failUnless(co[2]==p1, "3rd control point is wrong.")
855     self.failUnless(co[3]==p0, "4th control point is wrong.")
856    
857     c.setLocalScale(3.)
858     co=c.getControlPoints()
859     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
860     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
861     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
862     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
863    
864     h=c.getPrimitives()
865     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
866     self.failUnless(p0 in h, "missing p0 in history.")
867     self.failUnless(p1 in h, "missing p1 in history.")
868     self.failUnless(p2 in h, "missing p2 in history.")
869     self.failUnless(p3 in h, "missing p3 in history.")
870     self.failUnless(CC0 in h, "missing spline curve in history.")
871    
872     cp=c.copy()
873     cpcp=cp.getControlPoints()
874     self.failUnless(not cp == c, "copy returns same spline curve.")
875     self.failUnless(not cp == CC0, "copy returns same spline curve.")
876     self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
877     self.failUnless(not p3 == cpcp[0],"1st point of deep copy and souce are the same.")
878     self.failUnless(not p2 == cpcp[1],"2st point of deep copy and source are the same.")
879     self.failUnless(not p1 == cpcp[2],"3st point of deep copy and source are the same.")
880     self.failUnless(not p0 == cpcp[3],"4st point of deep copy and source are the same.")
881    
882     c.modifyBy(Dilation(-1.))
883     cp=c.getControlPoints()
884     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.")
885     self.failUnless(p3 == cp[0],"1st new point after Dilation.")
886     self.failUnless(p2 == cp[1],"2nd new point after Dilation.")
887     self.failUnless(p1 == cp[2],"3rd new point after Dilation.")
888     self.failUnless(p0 == cp[3],"4th new point after Dilation.")
889    
890     dc=c.apply(Dilation(-1.))
891     dccp=dc.getControlPoints()
892     self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
893     self.failUnless(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
894     self.failUnless(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
895     self.failUnless(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
896     self.failUnless(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
897    
898 gross 916 def test_BezierCurve(self):
899     p0=Point(0,0,0,0.1)
900     p1=Point(1,1,1,0.2)
901     p2=Point(2,2,2,0.3)
902     p3=Point(3,3,3,0.4)
903     p4=Point(1,2,3)
904    
905 gross 931 self.failUnlessRaises(ValueError,BezierCurve,p0)
906 gross 916 c=BezierCurve(p0,p1,p2,p3)
907    
908     self.failUnless(len(c) == 4, "wrong spline curve length")
909     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
910     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
911    
912 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
913     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p2)),"spline is colocated with spline of different length.")
914     self.failUnless(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
915     self.failUnless(c.isColocated(BezierCurve(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
916     self.failUnless(c.isColocated(BezierCurve(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
917     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
918    
919 gross 916 co=c.getControlPoints()
920     self.failUnless(co[0]==p0, "1st control point is wrong.")
921     self.failUnless(co[1]==p1, "2nd control point is wrong.")
922     self.failUnless(co[2]==p2, "3rd control point is wrong.")
923     self.failUnless(co[3]==p3, "4th control point is wrong.")
924    
925     c.setLocalScale(3.)
926     co=c.getControlPoints()
927     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
928     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
929     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
930     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
931    
932     h=c.getPrimitives()
933     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
934     self.failUnless(p0 in h, "missing p0 in history.")
935     self.failUnless(p1 in h, "missing p1 in history.")
936     self.failUnless(p2 in h, "missing p2 in history.")
937     self.failUnless(p3 in h, "missing p3 in history.")
938     self.failUnless(c in h, "missing spline curve in history.")
939    
940     cp=c.copy()
941 gross 919 cpcp=cp.getControlPoints()
942 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
943 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
944     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
945     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
946     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
947     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
948 gross 916
949     c.modifyBy(Dilation(-1.))
950 gross 919 cp=c.getControlPoints()
951 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.")
952     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
953     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
954     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
955     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
956    
957     dc=c.apply(Dilation(-1.))
958 gross 919 dccp=dc.getControlPoints()
959 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.")
960     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
961     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
962     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
963     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
964    
965     def test_BSpline(self):
966     p0=Point(0,0,0,0.1)
967     p1=Point(1,1,1,0.2)
968     p2=Point(2,2,2,0.3)
969     p3=Point(3,3,3,0.4)
970     p4=Point(1,2,3)
971    
972 gross 931 self.failUnlessRaises(ValueError,BSpline,p0)
973 gross 916 c=BSpline(p0,p1,p2,p3)
974    
975     self.failUnless(len(c) == 4, "wrong spline curve length")
976     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
977     self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve")
978    
979 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
980     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
981    
982 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
983     self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
984     self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
985     self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
986     self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
987     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
988    
989 gross 916 co=c.getControlPoints()
990     self.failUnless(co[0]==p0, "1st control point is wrong.")
991     self.failUnless(co[1]==p1, "2nd control point is wrong.")
992     self.failUnless(co[2]==p2, "3rd control point is wrong.")
993     self.failUnless(co[3]==p3, "4th control point is wrong.")
994    
995     c.setLocalScale(3.)
996     co=c.getControlPoints()
997     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
998     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
999     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1000     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1001    
1002     h=c.getPrimitives()
1003     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
1004     self.failUnless(p0 in h, "missing p0 in history.")
1005     self.failUnless(p1 in h, "missing p1 in history.")
1006     self.failUnless(p2 in h, "missing p2 in history.")
1007     self.failUnless(p3 in h, "missing p3 in history.")
1008     self.failUnless(c in h, "missing spline curve in history.")
1009    
1010     cp=c.copy()
1011 gross 919 cpcp=cp.getControlPoints()
1012 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
1013 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1014     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1015     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1016     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1017     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1018 gross 916
1019     c.modifyBy(Dilation(-1.))
1020 gross 919 cp=c.getControlPoints()
1021 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.")
1022     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
1023     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
1024     self.failUnless(p2 == cp[2],"3rd new point after Dilation.")
1025     self.failUnless(p3 == cp[3],"4th new point after Dilation.")
1026    
1027     dc=c.apply(Dilation(-1.))
1028 gross 919 dccp=dc.getControlPoints()
1029 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.")
1030     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1031 gross 929 self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1032 gross 916 self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1033 gross 929 self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1034 gross 916 self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1035 gross 929 self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1036 gross 916 self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1037 gross 929 self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1038 gross 916
1039 gross 929 def test_ReverseBSpline(self):
1040     p0=Point(0,0,0,0.1)
1041     p1=Point(1,1,1,0.2)
1042     p2=Point(2,2,2,0.3)
1043     p3=Point(3,3,3,0.4)
1044     p4=Point(1,2,3)
1045    
1046     CC0=BSpline(p0,p1,p2,p3)
1047     c=-CC0
1048    
1049     self.failUnless(len(c) == 4, "wrong spline curve length")
1050     self.failUnless(c.getStartPoint()==p3, "wrong start point of spline curve")
1051     self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve")
1052    
1053 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1054     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1055    
1056 gross 929 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1057     self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.")
1058     self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.")
1059     self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.")
1060     self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1061     self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.")
1062    
1063     co=c.getControlPoints()
1064     self.failUnless(co[0]==p3, "1st control point is wrong.")
1065     self.failUnless(co[1]==p2, "2nd control point is wrong.")
1066     self.failUnless(co[2]==p1, "3rd control point is wrong.")
1067     self.failUnless(co[3]==p0, "4th control point is wrong.")
1068    
1069     c.setLocalScale(3.)
1070     co=c.getControlPoints()
1071     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1072     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1073     self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.")
1074     self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.")
1075    
1076     h=c.getPrimitives()
1077     self.failUnless(len(h) == 5, "number of primitives in history is wrong.")
1078     self.failUnless(p0 in h, "missing p0 in history.")
1079     self.failUnless(p1 in h, "missing p1 in history.")
1080     self.failUnless(p2 in h, "missing p2 in history.")
1081     self.failUnless(p3 in h, "missing p3 in history.")
1082     self.failUnless(CC0 in h, "missing spline curve in history.")
1083    
1084     cp=c.copy()
1085     cpcp=cp.getControlPoints()
1086     self.failUnless(not cp == c, "copy returns same spline curve.")
1087     self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1088     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1089     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1090     self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.")
1091     self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.")
1092    
1093     c.modifyBy(Dilation(-1.))
1094     cp=c.getControlPoints()
1095     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.")
1096     self.failUnless(p3 == cp[0],"1st new point after Dilation.")
1097     self.failUnless(p2 == cp[1],"2nd new point after Dilation.")
1098     self.failUnless(p1 == cp[2],"3rd new point after Dilation.")
1099     self.failUnless(p0 == cp[3],"4th new point after Dilation.")
1100    
1101     dc=c.apply(Dilation(-1.))
1102     dccp=dc.getControlPoints()
1103     self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.")
1104     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1105     self.failUnless(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.")
1106     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1107     self.failUnless(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.")
1108     self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.")
1109     self.failUnless(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1110     self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.")
1111     self.failUnless(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1112    
1113 gross 916 def test_LineSegment(self):
1114     p0=Point(0,0,0,0.1)
1115     p1=Point(1,1,1,0.2)
1116     p4=Point(1,2,3)
1117    
1118     self.failUnlessRaises(TypeError,Line,p0)
1119     self.failUnlessRaises(TypeError,Line,p0,p1,p4)
1120    
1121     c=Line(p0,p1)
1122    
1123     self.failUnless(len(c) == 2, "wrong spline curve length")
1124     self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve")
1125     self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve")
1126    
1127 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1128     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1129    
1130 gross 919 self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1131     self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1132     self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1133     self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1134     self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1135    
1136 gross 916 co=c.getControlPoints()
1137     self.failUnless(co[0]==p0, "1st control point is wrong.")
1138     self.failUnless(co[1]==p1, "2nd control point is wrong.")
1139    
1140     c.setLocalScale(3.)
1141     co=c.getControlPoints()
1142     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1143     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1144    
1145     h=c.getPrimitives()
1146     self.failUnless(len(h) == 3, "number of primitives in history is wrong.")
1147     self.failUnless(p0 in h, "missing p0 in history.")
1148     self.failUnless(p1 in h, "missing p1 in history.")
1149     self.failUnless(c in h, "missing spline curve in history.")
1150    
1151     cp=c.copy()
1152 gross 919 cpcp=cp.getControlPoints()
1153 gross 916 self.failUnless(not cp == c, "copy returns same spline curve.")
1154 gross 919 self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1155     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1156     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1157 gross 916
1158     c.modifyBy(Dilation(-1.))
1159 gross 919 cp=c.getControlPoints()
1160 gross 916 self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1161     self.failUnless(p0 == cp[0],"1st new point after Dilation.")
1162     self.failUnless(p1 == cp[1],"2nd new point after Dilation.")
1163    
1164     dc=c.apply(Dilation(-1.))
1165 gross 919 dccp=dc.getControlPoints()
1166 gross 916 self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1167     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1168 gross 929 self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.")
1169 gross 916 self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1170 gross 929 self.failUnless(dccp[1].isColocated(Point(1,1,1)),"2st point of Dilation is is wrongly located.")
1171 gross 916
1172 gross 929 def test_ReverseLineSegment(self):
1173     p0=Point(0,0,0,0.1)
1174     p1=Point(1,1,1,0.2)
1175     p4=Point(1,2,3)
1176    
1177     self.failUnlessRaises(TypeError,Line,p0)
1178     self.failUnlessRaises(TypeError,Line,p0,p1,p4)
1179    
1180     CC0=Line(p0,p1)
1181     c=-CC0
1182    
1183 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1184     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1185    
1186 gross 929 self.failUnless(len(c) == 2, "wrong spline curve length")
1187     self.failUnless(c.getStartPoint()==p1, "wrong start point of spline curve")
1188     self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve")
1189    
1190     self.failUnless(not c.isColocated(p1),"spline is colocated with point.")
1191     self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.")
1192     self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.")
1193     self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.")
1194     self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.")
1195    
1196     co=c.getControlPoints()
1197     self.failUnless(co[0]==p1, "1st control point is wrong.")
1198     self.failUnless(co[1]==p0, "2nd control point is wrong.")
1199    
1200     c.setLocalScale(3.)
1201     co=c.getControlPoints()
1202     self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.")
1203     self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.")
1204    
1205     h=c.getPrimitives()
1206     self.failUnless(len(h) == 3, "number of primitives in history is wrong.")
1207     self.failUnless(p0 in h, "missing p0 in history.")
1208     self.failUnless(p1 in h, "missing p1 in history.")
1209     self.failUnless(CC0 in h, "missing spline curve in history.")
1210    
1211     cp=c.copy()
1212     cpcp=cp.getControlPoints()
1213     self.failUnless(not cp == c, "copy returns same spline curve.")
1214     self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.")
1215     self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.")
1216     self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.")
1217    
1218     c.modifyBy(Dilation(-1.))
1219     cp=c.getControlPoints()
1220     self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.")
1221     self.failUnless(p1 == cp[0],"1st new point after Dilation.")
1222     self.failUnless(p0 == cp[1],"2nd new point after Dilation.")
1223    
1224     dc=c.apply(Dilation(-1.))
1225     dccp=dc.getControlPoints()
1226     self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.")
1227     self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.")
1228     self.failUnless(dccp[0].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.")
1229     self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.")
1230     self.failUnless(dccp[1].isColocated(Point(0,0,0)),"2st point of Dilation is is wrongly located.")
1231    
1232     def test_Arc(self):
1233 gross 917 center=Point(0,0,0,0.1)
1234     p_start=Point(1,1,1,0.2)
1235     p_end=Point(1,2,3)
1236 gross 919 p4=Point(10,2,3)
1237 gross 917
1238     self.failUnlessRaises(TypeError,Arc,Primitive())
1239 gross 916
1240 gross 917 c=Arc(center,p_start,p_end)
1241    
1242     self.failUnless(c.getCenterPoint()==center, "wrong center point")
1243     self.failUnless(c.getStartPoint()==p_start, "wrong start point")
1244     self.failUnless(c.getEndPoint()==p_end, "wrong end point")
1245    
1246 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1247     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1248    
1249 gross 919 self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1250     self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1251     self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1252     self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1253     self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1254     self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1255     self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1256    
1257 gross 917 h=c.getPrimitives()
1258     self.failUnless(len(h) == 4, "number of primitives in history is wrong.")
1259     self.failUnless(center in h, "missing center in history.")
1260     self.failUnless(p_start in h, "missing p_start in history.")
1261     self.failUnless(p_end in h, "missing p_end in history.")
1262     self.failUnless(c in h, "missing spline curve in history.")
1263    
1264    
1265     c.setLocalScale(3.)
1266     self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1267     self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1268     self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1269    
1270     cp=c.copy()
1271     self.failUnless(isinstance(cp,Arc), "copy returns is not an arc.")
1272     self.failUnless(not cp == c, "copy returns same arc.")
1273 gross 919 self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.")
1274     self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1275     self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1276     self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1277 gross 917
1278     c.modifyBy(Dilation(-1.))
1279 gross 919 self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1280     self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.")
1281     self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.")
1282     self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.")
1283 gross 917
1284     dc=c.apply(Dilation(-1.))
1285 gross 919 self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1286     self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1287 gross 929 self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1288 gross 919 self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1289 gross 929 self.failUnless(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.")
1290 gross 919 self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1291 gross 929 self.failUnless(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.")
1292 gross 917
1293 gross 929 def test_ReverseArc(self):
1294     center=Point(0,0,0,0.1)
1295     p_start=Point(1,1,1,0.2)
1296     p_end=Point(1,2,3)
1297     p4=Point(10,2,3)
1298    
1299     self.failUnlessRaises(TypeError,Arc,Primitive())
1300    
1301     CC0=Arc(center,p_start,p_end)
1302     c=-CC0
1303    
1304     self.failUnless(c.getCenterPoint()==center, "wrong center point")
1305     self.failUnless(c.getStartPoint()==p_end, "wrong start point")
1306     self.failUnless(c.getEndPoint()==p_start, "wrong end point")
1307    
1308 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1309     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1310    
1311 gross 929 self.failUnless(not c.isColocated(p4),"spline is colocated with point.")
1312     self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.")
1313     self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.")
1314     self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.")
1315     self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.")
1316     self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.")
1317     self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.")
1318    
1319     h=c.getPrimitives()
1320     self.failUnless(len(h) == 4, "number of primitives in history is wrong.")
1321     self.failUnless(center in h, "missing center in history.")
1322     self.failUnless(p_start in h, "missing p_start in history.")
1323     self.failUnless(p_end in h, "missing p_end in history.")
1324     self.failUnless(CC0 in h, "missing spline curve in history.")
1325    
1326    
1327     c.setLocalScale(3.)
1328     self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.")
1329     self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.")
1330     self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.")
1331    
1332     cp=c.copy()
1333     self.failUnless(isinstance(cp,ReverseArc), "copy returns is not an arc.")
1334     self.failUnless(not cp == c, "copy returns same arc.")
1335     self.failUnless(cp.isColocated(Arc(center,p_end,p_start)),"arc is not colocated with its copy.")
1336     self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source")
1337     self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source")
1338     self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source")
1339    
1340     c.modifyBy(Dilation(-1.))
1341     self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.")
1342     self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.")
1343     self.failUnless(c.getStartPoint() == p_end,"wrong start point after dilation.")
1344     self.failUnless(c.getEndPoint() == p_start,"wrong end point after dilation.")
1345    
1346     dc=c.apply(Dilation(-1.))
1347     self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.")
1348     self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.")
1349     self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.")
1350     self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.")
1351     self.failUnless(dc.getStartPoint().isColocated(Point(1,2,3)),"start point of dilation is wrong.")
1352     self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.")
1353     self.failUnless(dc.getEndPoint().isColocated(Point(1,1,1)),"end point of dilation is wrong.")
1354    
1355 gross 923 def test_CurveLoop(self):
1356     p0=Point(0,0,0,0.1)
1357     p1=Point(1,1,1,0.2)
1358     p2=Point(2,2,2,0.3)
1359     p3=Point(3,3,3,0.4)
1360     p4=Point(1,2,3)
1361 gross 925 p5=Point(10,20,3)
1362     p6=Point(1,2,30)
1363 gross 917
1364 gross 923 l01=Line(p0,p1)
1365     l12=Arc(p3,p1,p2)
1366     l20=Spline(p2,p4,p0)
1367    
1368     lx=Line(p2,p3)
1369     ly=Line(p3,p1)
1370    
1371     c=CurveLoop(l01,l12,l20)
1372 gross 932 # self.failUnlessRaises(ValueError,CurveLoop,l01,lx,l20)
1373     # self.failUnlessRaises(ValueError,CurveLoop,l01,l20,l20)
1374     # self.failUnlessRaises(ValueError,CurveLoop,l01,l20,ly)
1375 gross 931
1376 gross 923 c=CurveLoop(l01,l20,l12)
1377 gross 930 self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself")
1378     self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself")
1379    
1380 gross 925 self.failUnless(not c.isColocated(p4),"CurveLoop is colocated with point.")
1381     self.failUnless(c.isColocated(c),"CurveLoop is not colocated with its self.")
1382     self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.")
1383     self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.")
1384     self.failUnless(c.isColocated(CurveLoop(l20,l12,l01)),"CurveLoop is not colocated with its copy with shuffled points.")
1385     self.failUnless(not c.isColocated(CurveLoop(lx,ly,l12)),"CurveLoop is colocated with different CurveLoop.")
1386    
1387     self.failUnless(len(c) == 3, "wrong length")
1388    
1389     c.setLocalScale(3.)
1390     self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.")
1391     self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.")
1392     self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.")
1393     self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.")
1394    
1395 gross 928
1396 gross 923 cc=c.getCurves()
1397     self.failUnless(len(cc) == 3, "too many curves.")
1398     self.failUnless(l01 in cc, "l01 is missing")
1399     self.failUnless(l12 in cc, "l12 is missing")
1400     self.failUnless(l20 in cc, "l20 is missing")
1401 gross 925
1402     p=c.getPrimitives()
1403     self.failUnless(len(p) == 9, "too many primitives.")
1404     self.failUnless(l01 in p, "l01 is missing")
1405     self.failUnless(l12 in p, "l21 is missing")
1406     self.failUnless(l20 in p, "l20 is missing")
1407     self.failUnless(p0 in p, "p0 is missing")