Parent Directory | Revision Log

Revision **1123** -
(**show annotations**)

*Thu May 3 04:13:52 2007 UTC*
(12 years, 5 months ago)
by *gross*

File MIME type: text/x-python

File size: 216005 byte(s)

File MIME type: text/x-python

File size: 216005 byte(s)

PropertySets cann now be created wirout an intial set of items.

1 | # $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 | |

9 | import os |

10 | import sys |

11 | import unittest |

12 | import math |

13 | import numarray |

14 | from esys.pycad import * |

15 | from esys.pycad.design import Design as Design0 |

16 | from esys.pycad.gmsh import Design as GMSHDesign |

17 | from esys.pycad.Triangle import Design as TriangleDesign |

18 | |

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 | PYCAD_TEST_MESH_PATH=PYCAD_TEST_DATA+os.sep+"data_meshes"+os.sep |

30 | PYCAD_WORKDIR_PATH=PYCAD_WORKDIR+os.sep |

31 | |

32 | 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 | class Test_PyCAD_Transformations(unittest.TestCase): |

37 | 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 | 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 | t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=90*DEG) |

307 | 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 | self.failUnless(self.__distance(s1,numarray.array([0.,0,1.]))<self.ABS_TOL,"s1 is wrong.") |

313 | s2=t([0,0,1]) |

314 | self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |

315 | self.failUnless(self.__distance(s2,numarray.array([0.,-1.,0.]))<self.ABS_TOL,"s2 is wrong.") |

316 | def test_Rotatation_x_30_0(self): |

317 | t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=30*DEG) |

318 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.") |

326 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.") |

331 | def test_Rotatation_x_330_0(self): |

332 | t=Rotatation(axis=[1.,0.,0.],point=[1.,0.,0.],angle=330*DEG) |

333 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.") |

341 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.") |

346 | def test_Rotatation_x_90(self): |

347 | t=Rotatation(axis=[-1.,0.,0.],point=[2.,0.,0.],angle=90*DEG) |

348 | 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 | self.failUnless(self.__distance(s1,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s1 is wrong.") |

354 | s2=t([0,0,1]) |

355 | self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |

356 | self.failUnless(self.__distance(s2,numarray.array([0.,1.,0.]))<self.ABS_TOL,"s2 is wrong.") |

357 | def test_Rotatation_x_30(self): |

358 | t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=30*DEG) |

359 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.") |

367 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.") |

372 | def test_Rotatation_x_330(self): |

373 | t=Rotatation(axis=[-1.,0.,0.],point=[1.,0.,0.],angle=330*DEG) |

374 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.") |

382 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.") |

387 | def test_Rotatation_y_90_0(self): |

388 | t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=90*DEG) |

389 | s0=t([1,0,0]) |

390 | self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |

391 | self.failUnless(self.__distance(s0,numarray.array([0.,0,-1.]))<self.ABS_TOL,"s0 is wrong.") |

392 | 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 | self.failUnless(self.__distance(s2,numarray.array([1,0.,0.]))<self.ABS_TOL,"s2 is wrong.") |

398 | def test_Rotatation_y_30_0(self): |

399 | t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=30*DEG) |

400 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.") |

405 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.") |

413 | def test_Rotatation_y_330_0(self): |

414 | t=Rotatation(axis=[0.,1.,0.],point=[0.,1.,0.],angle=330*DEG) |

415 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.") |

420 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.") |

428 | def test_Rotatation_y_90(self): |

429 | t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=90*DEG) |

430 | s0=t([1,0,0]) |

431 | self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |

432 | self.failUnless(self.__distance(s0,numarray.array([0.,0,1.]))<self.ABS_TOL,"s0 is wrong.") |

433 | s1=t([0,5,0]) |

434 | self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.") |

435 | self.failUnless(self.__distance(s1,numarray.array([0.,5,0.]))<self.ABS_TOL,"s1 is wrong.") |

436 | s2=t([0,0,1]) |

437 | self.failUnless(isinstance(s2,numarray.NumArray),"s2 is not a numarray object.") |

438 | self.failUnless(self.__distance(s2,numarray.array([-1,0.,0.]))<self.ABS_TOL,"s2 is wrong.") |

439 | def test_Rotatation_y_30(self): |

440 | t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=30*DEG) |

441 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.") |

446 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.") |

454 | def test_Rotatation_y_330(self): |

455 | t=Rotatation(axis=[0.,-1.,0.],point=[0.,2.,0.],angle=330*DEG) |

456 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.") |

461 | 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 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.") |

469 | def test_Rotatation_z_90_0(self): |

470 | t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=90*DEG) |

471 | s0=t([1,0,0]) |

472 | self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |

473 | self.failUnless(self.__distance(s0,numarray.array([0.,1,0.]))<self.ABS_TOL,"s0 is wrong.") |

474 | s1=t([0,5,0]) |

475 | self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.") |

476 | self.failUnless(self.__distance(s1,numarray.array([-5.,0,0.]))<self.ABS_TOL,"s1 is wrong.") |

477 | 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 | t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=30*DEG) |

482 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.") |

487 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.") |

492 | 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 | t=Rotatation(axis=[0.,0.,1.],point=[0.,0.,1.],angle=330*DEG) |

497 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.") |

502 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.") |

507 | def test_Rotatation_z_90(self): |

508 | t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=90*DEG) |

509 | s0=t([1,0,0]) |

510 | self.failUnless(isinstance(s0,numarray.NumArray),"s0 is not a numarray object.") |

511 | self.failUnless(self.__distance(s0,numarray.array([0.,-1,0.]))<self.ABS_TOL,"s0 is wrong.") |

512 | s1=t([0,5,0]) |

513 | self.failUnless(isinstance(s1,numarray.NumArray),"s1 is not a numarray object.") |

514 | self.failUnless(self.__distance(s1,numarray.array([5.,0,0.]))<self.ABS_TOL,"s1 is wrong.") |

515 | 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 | t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=30*DEG) |

520 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.") |

525 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.") |

530 | 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 | t=Rotatation(axis=[0.,0.,-1.],point=[0.,0.,2.],angle=330*DEG) |

535 | 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 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.") |

540 | 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 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.") |

545 | 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 | def test_Rotatation_x_90_1(self): |

549 | t=Rotatation(point=[0.,0.,1.],axis=[1.,0.,0.],angle=90*DEG) |

550 | 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 | t=Rotatation(point=[1.,0.,0.],axis=[0.,1.,0.],angle=90*DEG) |

561 | 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 | t=Rotatation(point=[0.,1.,0.],axis=[0.,0.,1.],angle=90*DEG) |

572 | 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 | t=Rotatation(axis=[1.,1.,1.],angle=90*DEG) |

583 | 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 | |

602 | class Test_PyCAD_Primitives(unittest.TestCase): |

603 | def setUp(self): |

604 | resetGlobalPrimitiveIdCounter() |

605 | |

606 | def test_Primitive(self): |

607 | p=Primitive() |

608 | |

609 | id=p.getID() |

610 | self.failUnless(isinstance(id,int),"id number is not an integer") |

611 | self.failUnless(not id==Primitive().getID(),"id number is not unique") |

612 | |

613 | self.failUnless(p==p.getUnderlyingPrimitive(),"getUnderlyingPrimitive does not return self.") |

614 | |

615 | 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 | 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 | self.failUnless(not id==Primitive().getID(),"id number is not unique") |

629 | |

630 | # check reverse point |

631 | self.failUnless(p == -p,"reverse is not working.") |

632 | |

633 | # check history: |

634 | hs=p.getPrimitives() |

635 | self.failUnless(len(hs)==1,"history must have length 1.") |

636 | self.failUnless(p in hs,"history must contain point p") |

637 | |

638 | # check incolved points: |

639 | ps=p.getConstructionPoints() |

640 | 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 | # check coordinates: |

644 | 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 | # reset coordinates: |

651 | p.setCoordinates([-1.,-2.,-3.]) |

652 | 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 | # check for a colocated point: |

659 | self.failUnless(p.isColocated(Point(-1.,-2.,-3.)),"colocation not detected.") |

660 | 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 | |

664 | # check for local length scale |

665 | l=p.getLocalScale() |

666 | self.failUnless(l==9.,"refinement scale is not 9.") |

667 | |

668 | # check for new local length scale |

669 | p.setLocalScale(3.) |

670 | l=p.getLocalScale() |

671 | self.failUnless(l==3.,"new refinement scale is not 3.") |

672 | |

673 | # 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 | def test_Spline(self): |

755 | 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 | self.failUnlessRaises(ValueError,Spline,p0) |

762 | c=Spline(p0,p1,p2,p3) |

763 | |

764 | 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 | 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 | 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 | 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 | cpcp=cp.getControlPoints() |

801 | self.failUnless(not cp == c, "copy returns same spline curve.") |

802 | 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 | |

808 | c.modifyBy(Dilation(-1.)) |

809 | cp=c.getControlPoints() |

810 | 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 | dccp=dc.getControlPoints() |

818 | 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 | self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.") |

821 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |

822 | self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.") |

823 | self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") |

824 | self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.") |

825 | self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") |

826 | self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.") |

827 | |

828 | 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 | |

838 | 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 | 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 | 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 | 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 | self.failUnlessRaises(ValueError,BezierCurve,p0) |

907 | 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 | 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 | 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 | cpcp=cp.getControlPoints() |

943 | self.failUnless(not cp == c, "copy returns same spline curve.") |

944 | 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 | |

950 | c.modifyBy(Dilation(-1.)) |

951 | cp=c.getControlPoints() |

952 | 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 | dccp=dc.getControlPoints() |

960 | 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 | self.failUnlessRaises(ValueError,BSpline,p0) |

974 | 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 | 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 | 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 | 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 | cpcp=cp.getControlPoints() |

1013 | self.failUnless(not cp == c, "copy returns same spline curve.") |

1014 | 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 | |

1020 | c.modifyBy(Dilation(-1.)) |

1021 | cp=c.getControlPoints() |

1022 | 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 | dccp=dc.getControlPoints() |

1030 | 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 | self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.") |

1033 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |

1034 | self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.") |

1035 | self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") |

1036 | self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.") |

1037 | self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") |

1038 | self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.") |

1039 | |

1040 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | cpcp=cp.getControlPoints() |

1154 | self.failUnless(not cp == c, "copy returns same spline curve.") |

1155 | 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 | |

1159 | c.modifyBy(Dilation(-1.)) |

1160 | cp=c.getControlPoints() |

1161 | 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 | dccp=dc.getControlPoints() |

1167 | 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 | self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.") |

1170 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |

1171 | self.failUnless(dccp[1].isColocated(Point(1,1,1)),"2st point of Dilation is is wrongly located.") |

1172 | |

1173 | 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 | 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 | 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 | center=Point(0,0,0,0.1) |

1235 | p_start=Point(1,1,1,0.2) |

1236 | p_end=Point(1,2,3) |

1237 | p4=Point(10,2,3) |

1238 | |

1239 | self.failUnlessRaises(TypeError,Arc,Primitive()) |

1240 | |

1241 | 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 | 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 | 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 | 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 | 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 | |

1279 | c.modifyBy(Dilation(-1.)) |

1280 | 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 | |

1285 | dc=c.apply(Dilation(-1.)) |

1286 | 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 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |

1289 | self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.") |

1290 | self.failUnless(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.") |

1291 | self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.") |

1292 | self.failUnless(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.") |

1293 | |

1294 | 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 | 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 | 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 | 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 | p5=Point(10,20,3) |

1363 | p6=Point(1,2,30) |

1364 | |

1365 | 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 | # self.failUnlessRaises(ValueError,CurveLoop,l01,lx,l20) |

1374 | # self.failUnlessRaises(ValueError,CurveLoop,l01,l20,l20) |

1375 | # self.failUnlessRaises(ValueError,CurveLoop,l01,l20,ly) |

1376 | |

1377 | c=CurveLoop(l01,l20,l12) |

1378 | 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 | 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 | |

1397 | 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 | |

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 p, "l20 is missing") |

1408 | self.failUnless(p0 in p, "p0 is missing") |

1409 | self.failUnless(p1 in p, "p1 is missing") |

1410 | self.failUnless(p2 in p, "p2 is missing") |

1411 | self.failUnless(p3 in p, "p3 is missing") |

1412 | self.failUnless(p4 in p, "p4 is missing") |

1413 | |

1414 | cp=c.copy() |

1415 | self.failUnless(isinstance(cp,CurveLoop), "copy returns is not an arc.") |

1416 | self.failUnless(not cp == c, "copy equals source") |

1417 | self.failUnless(cp.isColocated(c),"copy is not colocated with its source.") |

1418 | cc=cp.getCurves() |

1419 | self.failUnless(len(cc) == 3, "too many primitives in copy.") |

1420 | self.failUnless(not l01 in cc,"copy uses l01.") |

1421 | self.failUnless(not l12 in cc,"copy uses l12.") |

1422 | self.failUnless(not l20 in cc,"copy uses l20.") |

1423 | |

1424 | p0_m=Point(0,0,0) |

1425 | p1_m=Point(-1,-1,-1) |

1426 | p2_m=Point(-2,-2,-2) |

1427 | p3_m=Point(-3,-3,-3) |

1428 | p4_m=Point(-1,-2,-3) |

1429 | |

1430 | l01_m=Line(p0_m,p1_m) |

1431 | l12_m=Arc(p3_m,p1_m,p2_m) |

1432 | l20_m=Spline(p2_m,p4_m,p0_m) |

1433 | |

1434 | dc=c.apply(Dilation(-1.)) |

1435 | self.failUnless(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.") |

1436 | cc=dc.getCurves() |

1437 | self.failUnless(len(cc) == 3, "too many primitives in dilation result.") |

1438 | self.failUnless(not l01 in cc,"l01 is in dilation result.") |

1439 | self.failUnless(not l12 in cc,"l12 is in dilation result.") |

1440 | self.failUnless(not l20 in cc,"l20 is in dilation result.") |

1441 | |

1442 | c.modifyBy(Dilation(-1.)) |

1443 | self.failUnless(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.") |

1444 | cc=c.getCurves() |

1445 | self.failUnless(len(cc) == 3, "too many primitives in modified object.") |

1446 | self.failUnless(l01 in cc,"l01 missed in modified object.") |

1447 | self.failUnless(cc[cc.index(l01)].hasSameOrientation(l01),"l01 in modified object has wrong orientation.") |

1448 | self.failUnless(l12 in cc,"l12 missed in modified object.") |

1449 | self.failUnless(cc[cc.index(l12)].hasSameOrientation(l12),"l12 in modified object has wrong orientation.") |

1450 | self.failUnless(l20 in cc,"l20 missed in modified object.") |

1451 | self.failUnless(cc[cc.index(l20)].hasSameOrientation(l20),"l20 in modified object has wrong orientation.") |

1452 | |

1453 | def test_ReverseCurveLoop(self): |

1454 | p0=Point(0,0,0,0.1) |

1455 | p1=Point(1,1,1,0.2) |

1456 | p2=Point(2,2,2,0.3) |

1457 | p3=Point(3,3,3,0.4) |

1458 | p4=Point(1,2,3) |

1459 | p5=Point(10,20,3) |

1460 | p6=Point(1,2,30) |

1461 | |

1462 | l01=Line(p0,p1) |

1463 | l12=Arc(p3,p1,p2) |

1464 | l20=Spline(p2,p4,p0) |

1465 | |

1466 | lx=Line(p2,p3) |

1467 | ly=Line(p3,p1) |

1468 | |

1469 | CC0=CurveLoop(l01,l20,l12) |

1470 | c=-CC0 |

1471 | |

1472 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1473 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1474 | |

1475 | self.failUnless(not c.isColocated(p4),"-CurveLoop is colocated with point.") |

1476 | self.failUnless(c.isColocated(c),"-CurveLoop is not colocated with its self.") |

1477 | self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"-CurveLoop is not colocated with its copy.") |

1478 | self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"-CurveLoop is not colocated with its copy with shifted points.") |

1479 | self.failUnless(c.isColocated(CurveLoop(l20,l12,l01)),"-CurveLoop is not colocated with its copy with shuffled points.") |

1480 | self.failUnless(not c.isColocated(CurveLoop(lx,ly,l12)),"-CurveLoop is colocated with different CurveLoop.") |

1481 | |

1482 | self.failUnless(len(c) == 3, "wrong length") |

1483 | |

1484 | c.setLocalScale(3.) |

1485 | self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.") |

1486 | self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.") |

1487 | self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.") |

1488 | self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.") |

1489 | |

1490 | |

1491 | cc=c.getCurves() |

1492 | self.failUnless(len(cc) == 3, "too many curves.") |

1493 | self.failUnless(l01 in cc, "l01 is missing") |

1494 | self.failUnless(l12 in cc, "l12 is missing") |

1495 | self.failUnless(l20 in cc, "l20 is missing") |

1496 | |

1497 | p=c.getPrimitives() |

1498 | self.failUnless(len(p) == 9, "too many primitives.") |

1499 | self.failUnless(l01 in p, "l01 is missing") |

1500 | self.failUnless(l12 in p, "l21 is missing") |

1501 | self.failUnless(l20 in p, "l20 is missing") |

1502 | self.failUnless(p0 in p, "p0 is missing") |

1503 | self.failUnless(p1 in p, "p1 is missing") |

1504 | self.failUnless(p2 in p, "p2 is missing") |

1505 | self.failUnless(p3 in p, "p3 is missing") |

1506 | self.failUnless(p4 in p, "p4 is missing") |

1507 | |

1508 | cp=c.copy() |

1509 | self.failUnless(isinstance(cp,ReverseCurveLoop), "copy returns is not an ReverseCurveLoop.") |

1510 | self.failUnless(not cp == c, "copy equals source") |

1511 | self.failUnless(cp.isColocated(c),"copy is not colocated with its source.") |

1512 | cc=cp.getCurves() |

1513 | self.failUnless(len(cc) == 3, "too many primitives in copy.") |

1514 | self.failUnless(not l01 in cc,"copy uses l01.") |

1515 | self.failUnless(not l12 in cc,"copy uses l12.") |

1516 | self.failUnless(not l20 in cc,"copy uses l20.") |

1517 | |

1518 | p0_m=Point(0,0,0) |

1519 | p1_m=Point(-1,-1,-1) |

1520 | p2_m=Point(-2,-2,-2) |

1521 | p3_m=Point(-3,-3,-3) |

1522 | p4_m=Point(-1,-2,-3) |

1523 | |

1524 | l01_m=Line(p0_m,p1_m) |

1525 | l12_m=Arc(p3_m,p1_m,p2_m) |

1526 | l20_m=Spline(p2_m,p4_m,p0_m) |

1527 | |

1528 | dc=c.apply(Dilation(-1.)) |

1529 | self.failUnless(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.") |

1530 | cc=dc.getCurves() |

1531 | self.failUnless(len(cc) == 3, "too many primitives in dilation result.") |

1532 | self.failUnless(not l01 in cc,"l01 is in dilation result.") |

1533 | self.failUnless(not l12 in cc,"l12 is in dilation result.") |

1534 | self.failUnless(not l20 in cc,"l20 is in dilation result.") |

1535 | |

1536 | c.modifyBy(Dilation(-1.)) |

1537 | self.failUnless(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.") |

1538 | cc=c.getCurves() |

1539 | self.failUnless(len(cc) == 3, "too many primitives in modified object.") |

1540 | self.failUnless(l01 in cc,"l01 missed in modified object.") |

1541 | self.failUnless(cc[cc.index(l01)].hasSameOrientation(-l01),"l01 in modified object has wrong orientation.") |

1542 | self.failUnless(l12 in cc,"l12 missed in modified object.") |

1543 | self.failUnless(cc[cc.index(l12)].hasSameOrientation(-l12),"l12 in modified object has wrong orientation.") |

1544 | self.failUnless(l20 in cc,"l20 missed in modified object.") |

1545 | self.failUnless(cc[cc.index(l20)].hasSameOrientation(-l20),"l20 in modified object has wrong orientation.") |

1546 | |

1547 | def test_RuledSurface(self): |

1548 | p0=Point(0,0,0,0.1) |

1549 | p1=Point(1,1,1,0.2) |

1550 | p2=Point(2,2,2,0.3) |

1551 | p3=Point(3,3,3,0.4) |

1552 | p4=Point(1,2,3) |

1553 | p5=Point(10,20,3) |

1554 | p6=Point(1,2,30) |

1555 | |

1556 | l01=Line(p0,p1) |

1557 | l12_1=Arc(p3,p1,p2) |

1558 | l12_2_1=Spline(p1,p3,p4) |

1559 | l12_2_2=Spline(p4,p5,p2) |

1560 | l12_3=Line(p1,p2) |

1561 | l20=Spline(p2,p4,p0) |

1562 | |

1563 | cl1=CurveLoop(l01,l12_1,l20) |

1564 | cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20) |

1565 | cl3=CurveLoop(l01,l12_3,l20) |

1566 | |

1567 | self.failUnlessRaises(TypeError,RuledSurface,l01) |

1568 | |

1569 | s=RuledSurface(cl1) |

1570 | |

1571 | cl=s.getBoundaryLoop() |

1572 | self.failUnless(cl == cl1, " wrong boundary loops") |

1573 | self.failUnless(cl.hasSameOrientation(cl1),"cl1 has incorrect orientation.") |

1574 | |

1575 | self.failUnless(s.hasSameOrientation(s),"has not same orientation like itself") |

1576 | self.failUnless(not s.hasSameOrientation(-s),"has same orientation like -itself") |

1577 | |

1578 | crvs=s.getBoundary() |

1579 | self.failUnless(len(crvs) == 3, "too many boundary corves.") |

1580 | self.failUnless(l01 in crvs, "l01 is missing in boundary") |

1581 | self.failUnless(crvs[crvs.index(l01)].hasSameOrientation(l01),"l01 has incorrect orientation.") |

1582 | self.failUnless(l12_1 in crvs, "l21 is missing in boundary") |

1583 | self.failUnless(crvs[crvs.index(l12_1)].hasSameOrientation(l12_1),"l12_1 has incorrect orientation.") |

1584 | self.failUnless(l20 in crvs, "l20 is missing in boundary") |

1585 | self.failUnless(crvs[crvs.index(l20)].hasSameOrientation(l20),"l12_1 has incorrect orientation.") |

1586 | |

1587 | |

1588 | self.failUnless(not s.isColocated(p4),"RuledSurface is colocated with point.") |

1589 | self.failUnless(s.isColocated(s),"RuledSurface is not colocated with its self.") |

1590 | self.failUnless(s.isColocated(RuledSurface(cl1)),"RuledSurface is not colocated with its copy.") |

1591 | self.failUnless(not s.isColocated(RuledSurface(cl2)),"RuledSurface is colocated with different length") |

1592 | self.failUnless(not s.isColocated(RuledSurface(cl3)),"RuledSurface is colocated with same length.") |

1593 | |

1594 | s.setLocalScale(3.) |

1595 | self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.") |

1596 | self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.") |

1597 | self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.") |

1598 | self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.") |

1599 | |

1600 | p=s.getPrimitives() |

1601 | self.failUnless(len(p) == 10, "too many primitives.") |

1602 | self.failUnless(cl1 in p, "cl1 is missing") |

1603 | self.failUnless(l01 in p, "l01 is missing") |

1604 | self.failUnless(l12_1 in p, "l21 is missing") |

1605 | self.failUnless(l20 in p, "l20 is missing") |

1606 | self.failUnless(p0 in p, "p0 is missing") |

1607 | self.failUnless(p1 in p, "p1 is missing") |

1608 | self.failUnless(p2 in p, "p2 is missing") |

1609 | self.failUnless(p3 in p, "p3 is missing") |

1610 | self.failUnless(p4 in p, "p4 is missing") |

1611 | |

1612 | sp=s.copy() |

1613 | self.failUnless(isinstance(sp,RuledSurface), "copy returns is not a RuledSurface.") |

1614 | self.failUnless(not sp == s, "copy equals source") |

1615 | self.failUnless(sp.isColocated(s),"copy is not colocated with its source.") |

1616 | cbl=sp.getBoundaryLoop() |

1617 | self.failUnless(not cbl == cl1,"copy uses cl1.") |

1618 | cp=sp.getPrimitives() |

1619 | self.failUnless(len(cp) == 10, "copy as too many primitives.") |

1620 | self.failUnless(not cl1 in cp, "copy is using cl1") |

1621 | self.failUnless(not l01 in cp, "copy is using l01") |

1622 | self.failUnless(not l12_1 in cp, "copy is using l21") |

1623 | self.failUnless(not l20 in cp, "copy is using l20") |

1624 | self.failUnless(not p0 in cp, "copy is using p0") |

1625 | self.failUnless(not p1 in cp, "copy is using p1") |

1626 | self.failUnless(not p2 in cp, "copy is using p2") |

1627 | self.failUnless(not p3 in cp, "copy is using p3") |

1628 | self.failUnless(not p4 in cp, "copy is using p4") |

1629 | del cp |

1630 | |

1631 | p0_m=Point(0,0,0) |

1632 | p1_m=Point(-1,-1,-1) |

1633 | p2_m=Point(-2,-2,-2) |

1634 | p3_m=Point(-3,-3,-3) |

1635 | p4_m=Point(-1,-2,-3) |

1636 | |

1637 | l01_m=Line(p0_m,p1_m) |

1638 | l12_m=Arc(p3_m,p1_m,p2_m) |

1639 | l20_m=Spline(p2_m,p4_m,p0_m) |

1640 | |

1641 | ds=s.apply(Dilation(-1.)) |

1642 | self.failUnless(ds.isColocated(RuledSurface(CurveLoop(l01_m,l12_m,l20_m))),"dilation is wrong.") |

1643 | cbl=ds.getBoundaryLoop() |

1644 | self.failUnless(not cbl == cl1,"dilation uses cl1.") |

1645 | cp=ds.getPrimitives() |

1646 | self.failUnless(len(cp) == 10, "dilation as too many primitives.") |

1647 | self.failUnless(not cl1 in cp, "dilation is using cl1") |

1648 | self.failUnless(not l01 in cp, "dilation is using l01") |

1649 | self.failUnless(not l12_1 in cp, "dilation is using l21") |

1650 | self.failUnless(not l20 in cp, "dilation is using l20") |

1651 | self.failUnless(not p0 in cp, "dilation is using p0") |

1652 | self.failUnless(not p1 in cp, "dilation is using p1") |

1653 | self.failUnless(not p2 in cp, "dilation is using p2") |

1654 | self.failUnless(not p3 in cp, "dilation is using p3") |

1655 | self.failUnless(not p4 in cp, "dilation is using p4") |

1656 | |

1657 | s.modifyBy(Dilation(-1.)) |

1658 | self.failUnless(s.isColocated(RuledSurface(CurveLoop(l01_m,l12_m,l20_m))),"inplace dilation is wrong.") |

1659 | |

1660 | p=s.getPrimitives() |

1661 | self.failUnless(len(p) == 10, "inplace dilation has too many primitives.") |

1662 | self.failUnless(cl1 in p, "inplace dilation cl1 is missing") |

1663 | self.failUnless(l01 in p, "inplace dilation l01 is missing") |

1664 | self.failUnless(l12_1 in p, "inplace dilation l21 is missing") |

1665 | self.failUnless(l20 in p, "inplace dilation l20 is missing") |

1666 | self.failUnless(p0 in p, "inplace dilation p0 is missing") |

1667 | self.failUnless(p1 in p, "inplace dilation p1 is missing") |

1668 | self.failUnless(p2 in p, "inplace dilation p2 is missing") |

1669 | self.failUnless(p3 in p, "inplace dilation p3 is missing") |

1670 | self.failUnless(p4 in p, "inplace dilation p4 is missing") |

1671 | |

1672 | p=s.getBoundary() |

1673 | self.failUnless(len(p) == 3, "inplace dilation has too many boundary curves.") |

1674 | self.failUnless(l01 in p, "inplace dilation l01 is missing in boundary curves.") |

1675 | self.failUnless(p[p.index(l01)].hasSameOrientation(l01),"l01 in getBoundary after dilation has incorrect orientation.") |

1676 | self.failUnless(l12_1 in p, "inplace dilation l21 is missing") |

1677 | self.failUnless(p[p.index(l12_1)].hasSameOrientation(l12_1),"l12_1 in getBoundary after dilation has incorrect orientation.") |

1678 | self.failUnless(l20 in p, "inplace dilation l20 is missing") |

1679 | self.failUnless(p[p.index(l20)].hasSameOrientation(l20),"l20 in getBoundary after dilation has incorrect orientation.") |

1680 | |

1681 | p=s.getBoundaryLoop() |

1682 | self.failUnless(cl1 == p, "inplace dilation s.getBoundaryLoop does not return cl1") |

1683 | self.failUnless(p.hasSameOrientation(cl1),"cl1 in getBoundaryLoop after dilation has incorrect orientation.") |

1684 | |

1685 | def test_ReverseRuledSurface(self): |

1686 | p0=Point(0,0,0,0.1) |

1687 | p1=Point(1,1,1,0.2) |

1688 | p2=Point(2,2,2,0.3) |

1689 | p3=Point(3,3,3,0.4) |

1690 | p4=Point(1,2,3) |

1691 | p5=Point(10,20,3) |

1692 | p6=Point(1,2,30) |

1693 | |

1694 | l01=Line(p0,p1) |

1695 | l12_1=Arc(p3,p1,p2) |

1696 | l12_2_1=Spline(p1,p3,p4) |

1697 | l12_2_2=Spline(p4,p5,p2) |

1698 | l12_3=Line(p1,p2) |

1699 | l20=Spline(p2,p4,p0) |

1700 | |

1701 | cl1=CurveLoop(l01,l12_1,l20) |

1702 | cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20) |

1703 | cl3=CurveLoop(l01,l12_3,l20) |

1704 | |

1705 | self.failUnlessRaises(TypeError,RuledSurface,l01) |

1706 | |

1707 | CC0=RuledSurface(cl1) |

1708 | s=-CC0 |

1709 | |

1710 | cl=s.getBoundaryLoop() |

1711 | self.failUnless(cl == cl1, " wrong boundary loops") |

1712 | self.failUnless(cl.hasSameOrientation(-cl1),"cl1 has incorrect orientation.") |

1713 | |

1714 | self.failUnless(s.hasSameOrientation(s),"has not same orientation like itself") |

1715 | self.failUnless(not s.hasSameOrientation(-s),"has same orientation like -itself") |

1716 | |

1717 | crvs=s.getBoundary() |

1718 | self.failUnless(len(crvs) == 3, "too many boundary corves.") |

1719 | self.failUnless(l01 in crvs, "l01 is missing in boundary") |

1720 | self.failUnless(crvs[crvs.index(l01)].hasSameOrientation(-l01),"l01 has incorrect orientation.") |

1721 | self.failUnless(l12_1 in crvs, "l21 is missing in boundary") |

1722 | self.failUnless(crvs[crvs. |