Parent Directory | Revision Log

Revision **931** -
(**show annotations**)

*Fri Jan 19 03:06:33 2007 UTC*
(14 years, 5 months ago)
by *gross*

File MIME type: text/x-python

File size: 178190 byte(s)

File MIME type: text/x-python

File size: 178190 byte(s)

pycad supports volumes now.

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 | import sys |

9 | import unittest |

10 | import math |

11 | import numarray |

12 | from esys.pycad import * |

13 | |

14 | try: |

15 | PYCAD_TEST_DATA=os.environ['PYCAD_TEST_DATA'] |

16 | except KeyError: |

17 | PYCAD_TEST_DATA='.' |

18 | |

19 | try: |

20 | PYCAD_WORKDIR=os.environ['PYCAD_WORKDIR'] |

21 | except KeyError: |

22 | PYCAD_WORKDIR='.' |

23 | |

24 | PYCAD_TEST_MESH_PATH=PYCAD_TEST_DATA+"/data_meshes/" |

25 | PYCAD_WORKDIR_PATH=PYCAD_WORKDIR+"/" |

26 | |

27 | def _cross(x, y): |

28 | 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]]) |

29 | |

30 | |

31 | class Test_PyCAD_Transformations(unittest.TestCase): |

32 | ABS_TOL=1.e-8 |

33 | def __distance(self,x,y): |

34 | return math.sqrt(numarray.dot(x-y,x-y)) |

35 | def test_Translation_x(self): |

36 | t=Translation([1,0,0]) |

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

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

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

40 | s1=t([0,1,0]) |

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

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

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

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

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

46 | def test_Translation_y(self): |

47 | t=Translation([0,1,0]) |

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

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

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

51 | s1=t([0,1,0]) |

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

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

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

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

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

57 | def test_Translation_z(self): |

58 | t=Translation([0,0,1]) |

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

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

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

62 | s1=t([0,1,0]) |

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

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

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

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

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

68 | def test_Dilation_0_two(self): |

69 | t=Dilation(2.) |

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

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

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

73 | s1=t([0,1,0]) |

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

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

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

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

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

79 | def test_Dilation_0_half(self): |

80 | t=Dilation(0.5) |

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

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

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

84 | s1=t([0,1,0]) |

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

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

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

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

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

90 | def test_Dilation_x_two(self): |

91 | t=Dilation(2.,[1.,0.,0.]) |

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

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

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

95 | s0_1=t([0,0,0]) |

96 | self.failUnless(isinstance(s0_1,numarray.NumArray),"s0_1 is not a numarray object.") |

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

98 | s1=t([0,1,0]) |

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

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

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

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

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

104 | def test_Dilation_x_half(self): |

105 | t=Dilation(0.5,[1.,0.,0.]) |

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

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

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

109 | s0_1=t([0,0,0]) |

110 | self.failUnless(isinstance(s0_1,numarray.NumArray),"s0_1 is not a numarray object.") |

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

112 | s1=t([0,1,0]) |

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

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

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

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

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

118 | def test_Dilation_y_two(self): |

119 | t=Dilation(2.,[0.,1.,0.]) |

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

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

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

123 | s1_1=t([0,0,0]) |

124 | self.failUnless(isinstance(s1_1,numarray.NumArray),"s1_1 is not a numarray object.") |

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

126 | s1=t([0,1,0]) |

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

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

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

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

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

132 | def test_Dilation_y_half(self): |

133 | t=Dilation(0.5,[0.,1.,0.]) |

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

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

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

137 | s1_1=t([0,0,0]) |

138 | self.failUnless(isinstance(s1_1,numarray.NumArray),"s1_1 is not a numarray object.") |

139 | self.failUnless(self.__distance(s1_1,numarray.array([0,0.5,0]))<self.ABS_TOL,"s1_1 is wrong.") |

140 | s1=t([0,1,0]) |

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

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

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

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

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

146 | def test_Dilation_z_two(self): |

147 | t=Dilation(2.,[0.,0.,1.]) |

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

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

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

151 | s2_1=t([0,0,0]) |

152 | self.failUnless(isinstance(s2_1,numarray.NumArray),"s2_1 is not a numarray object.") |

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

154 | s1=t([0,1,0]) |

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

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

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

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

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

160 | def test_Dilation_z_half(self): |

161 | t=Dilation(0.5,[0.,0.,1.]) |

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

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

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

165 | s2_1=t([0,0,0]) |

166 | self.failUnless(isinstance(s2_1,numarray.NumArray),"s2_1 is not a numarray object.") |

167 | self.failUnless(self.__distance(s2_1,numarray.array([0,0,0.5]))<self.ABS_TOL,"s2_1 is wrong.") |

168 | s1=t([0,1,0]) |

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

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

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

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

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

174 | def test_Reflection_x_offset0(self): |

175 | t=Reflection([1.,0.,0.]) |

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

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

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

179 | s1=t([0,1,0]) |

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

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

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

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

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

185 | s=t([1,2,3]) |

186 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

187 | self.failUnless(self.__distance(s,numarray.array([-1.,2,3]))<self.ABS_TOL,"s is wrong.") |

188 | def test_Reflection_x_offset2(self): |

189 | t=Reflection([-2.,0.,0.],offset=-4) |

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

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

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

193 | s1=t([0,1,0]) |

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

195 | self.failUnless(self.__distance(s1,numarray.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.") |

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

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

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

199 | s=t([1,2,3]) |

200 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

201 | self.failUnless(self.__distance(s,numarray.array([3.,2,3]))<self.ABS_TOL,"s is wrong.") |

202 | def test_Reflection_x_offset2_vector(self): |

203 | t=Reflection([1.,0.,0.],offset=[2,0,0]) |

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

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

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

207 | s1=t([0,1,0]) |

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

209 | self.failUnless(self.__distance(s1,numarray.array([4,1,0]))<self.ABS_TOL,"s1 is wrong.") |

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

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

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

213 | s=t([1,2,3]) |

214 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

215 | self.failUnless(self.__distance(s,numarray.array([3.,2,3]))<self.ABS_TOL,"s is wrong.") |

216 | def test_Reflection_y_offset0(self): |

217 | t=Reflection([0.,1.,0.]) |

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

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

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

221 | s1=t([0,1,0]) |

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

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

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

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

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

227 | s=t([1,2,3]) |

228 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

229 | self.failUnless(self.__distance(s,numarray.array([1.,-2,3]))<self.ABS_TOL,"s is wrong.") |

230 | def test_Reflection_y_offset2(self): |

231 | t=Reflection([0.,-2.,0.],offset=-4) |

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

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

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

235 | s1=t([0,1,0]) |

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

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

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

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

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

241 | s=t([1,2,3]) |

242 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

243 | self.failUnless(self.__distance(s,numarray.array([1.,2,3]))<self.ABS_TOL,"s is wrong.") |

244 | def test_Reflection_y_offset2_vector(self): |

245 | t=Reflection([0.,1.,0.],offset=[0,2,0]) |

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

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

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

249 | s1=t([0,1,0]) |

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

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

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

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

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

255 | s=t([1,2,3]) |

256 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

257 | self.failUnless(self.__distance(s,numarray.array([1.,2,3]))<self.ABS_TOL,"s is wrong.") |

258 | def test_Reflection_z_offset0(self): |

259 | t=Reflection([0.,0.,1.]) |

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

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

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

263 | s1=t([0,1,0]) |

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

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

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

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

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

269 | s=t([1,2,3]) |

270 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

271 | self.failUnless(self.__distance(s,numarray.array([1.,2,-3]))<self.ABS_TOL,"s is wrong.") |

272 | def test_Reflection_z_offset2(self): |

273 | t=Reflection([0.,0.,-2.],offset=-4) |

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

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

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

277 | s1=t([0,1,0]) |

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

279 | self.failUnless(self.__distance(s1,numarray.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.") |

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

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

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

283 | s=t([1,2,3]) |

284 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

285 | self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.") |

286 | def test_Reflection_z_offset2_vector(self): |

287 | t=Reflection([0.,0.,1.],offset=[0,0,2]) |

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

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

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

291 | s1=t([0,1,0]) |

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

293 | self.failUnless(self.__distance(s1,numarray.array([0,1,4]))<self.ABS_TOL,"s1 is wrong.") |

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

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

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

297 | s=t([1,2,3]) |

298 | self.failUnless(isinstance(s,numarray.NumArray),"s is not a numarray object.") |

299 | self.failUnless(self.__distance(s,numarray.array([1.,2,1]))<self.ABS_TOL,"s is wrong.") |

300 | def test_Rotatation_x_90_0(self): |

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

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

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

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

305 | s1=t([0,1,0]) |

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

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

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

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

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

311 | def test_Rotatation_x_30_0(self): |

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

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

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

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

316 | s1=t([0,1,0]) |

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

318 | self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") |

319 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

320 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))<0.,"s1 has wrong orientation.") |

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

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

323 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

324 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

325 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))<0.,"s2 has wrong orientation.") |

326 | def test_Rotatation_x_330_0(self): |

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

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

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

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

331 | s1=t([0,1,0]) |

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

333 | self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") |

334 | self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

335 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([1.,0.,0.]))>0.,"s1 has wrong orientation.") |

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

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

338 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

339 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

340 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([1.,0.,0.]))>0.,"s2 has wrong orientation.") |

341 | def test_Rotatation_x_90(self): |

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

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

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

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

346 | s1=t([0,1,0]) |

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

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

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

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

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

352 | def test_Rotatation_x_30(self): |

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

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

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

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

357 | s1=t([0,1,0]) |

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

359 | self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") |

360 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

361 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))<0.,"s1 has wrong orientation.") |

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

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

364 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

365 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

366 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))<0.,"s2 has wrong orientation.") |

367 | def test_Rotatation_x_330(self): |

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

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

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

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

372 | s1=t([0,1,0]) |

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

374 | self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") |

375 | self.failUnless(abs(s1[1]-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

376 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([-1.,0.,0.]))>0.,"s1 has wrong orientation.") |

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

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

379 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

380 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

381 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([-1.,0.,0.]))>0.,"s2 has wrong orientation.") |

382 | def test_Rotatation_y_90_0(self): |

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

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

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

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

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

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

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

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

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

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

393 | def test_Rotatation_y_30_0(self): |

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

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

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

397 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

398 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

399 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))<0.,"s0 has wrong orientation.") |

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

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

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

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

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

405 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

406 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

407 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))<0.,"s2 has wrong orientation.") |

408 | def test_Rotatation_y_330_0(self): |

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

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

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

412 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

413 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

414 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,1.,0.]))>0.,"s0 has wrong orientation.") |

415 | s1=t([0,1,0]) |

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

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

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

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

420 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

421 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

422 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,1.,0.]))>0.,"s2 has wrong orientation.") |

423 | def test_Rotatation_y_90(self): |

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

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

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

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

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

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

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

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

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

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

434 | def test_Rotatation_y_30(self): |

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

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

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

438 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

439 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

440 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))<0.,"s0 has wrong orientation.") |

441 | s1=t([0,1,0]) |

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

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

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

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

446 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

447 | self.failUnless(abs(s2[2]-math.cos(30*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

448 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))<0.,"s2 has wrong orientation.") |

449 | def test_Rotatation_y_330(self): |

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

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

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

453 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

454 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

455 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,-1.,0.]))>0.,"s0 has wrong orientation.") |

456 | s1=t([0,1,0]) |

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

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

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

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

461 | self.failUnless(abs(numarray.dot(s2,s2)-1.)<self.ABS_TOL,"s2 length is wrong.") |

462 | self.failUnless(abs(s2[2]-math.cos(330*DEG))<self.ABS_TOL,"s2 angle is wrong.") |

463 | self.failUnless(numarray.dot(_cross(s2,[0,0,1]),numarray.array([0.,-1.,0.]))>0.,"s2 has wrong orientation.") |

464 | def test_Rotatation_z_90_0(self): |

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

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

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

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

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

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

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

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

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

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

475 | def test_Rotatation_z_30_0(self): |

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

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

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

479 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

480 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

481 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))<0.,"s0 has wrong orientation.") |

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

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

484 | self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.") |

485 | self.failUnless(abs(s1[1]/5.-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

486 | self.failUnless(numarray.dot(_cross(s1,[0,5,0]),numarray.array([0.,0.,1.]))<0.,"s1 has wrong orientation.") |

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

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

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

490 | def test_Rotatation_z_330_0(self): |

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

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

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

494 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

495 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

496 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,1.]))>0.,"s0 has wrong orientation.") |

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

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

499 | self.failUnless(abs(numarray.dot(s1,s1)-5.**2)<self.ABS_TOL,"s1 length is wrong.") |

500 | self.failUnless(abs(s1[1]/5.-math.cos(330*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

501 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,1.]))>0.,"s1 has wrong orientation.") |

502 | def test_Rotatation_z_90(self): |

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

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

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

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

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

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

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

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

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

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

513 | def test_Rotatation_z_30(self): |

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

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

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

517 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

518 | self.failUnless(abs(s0[0]-math.cos(30*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

519 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))<0.,"s0 has wrong orientation.") |

520 | s1=t([0,1,0]) |

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

522 | self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") |

523 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

524 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))<0.,"s1 has wrong orientation.") |

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

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

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

528 | def test_Rotatation_z_330(self): |

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

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

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

532 | self.failUnless(abs(numarray.dot(s0,s0)-1.)<self.ABS_TOL,"s0 length is wrong.") |

533 | self.failUnless(abs(s0[0]-math.cos(330*DEG))<self.ABS_TOL,"s0 angle is wrong.") |

534 | self.failUnless(numarray.dot(_cross(s0,[1,0,0]),numarray.array([0.,0.,-1.]))>0.,"s0 has wrong orientation.") |

535 | s1=t([0,1,0]) |

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

537 | self.failUnless(abs(numarray.dot(s1,s1)-1.)<self.ABS_TOL,"s1 length is wrong.") |

538 | self.failUnless(abs(s1[1]-math.cos(30*DEG))<self.ABS_TOL,"s1 angle is wrong.") |

539 | self.failUnless(numarray.dot(_cross(s1,[0,1,0]),numarray.array([0.,0.,-1.]))>0.,"s1 has wrong orientation.") |

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

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

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

543 | def test_Rotatation_x_90_1(self): |

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

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

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

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

548 | s1=t([0,1,0]) |

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

550 | self.failUnless(self.__distance(s1,numarray.array([0.,1,2.]))<self.ABS_TOL,"s1 is wrong.") |

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

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

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

554 | def test_Rotatation_y_90_1(self): |

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

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

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

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

559 | s1=t([0,1,0]) |

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

561 | self.failUnless(self.__distance(s1,numarray.array([1.,1,1.]))<self.ABS_TOL,"s1 is wrong.") |

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

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

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

565 | def test_Rotatation_z_90_1(self): |

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

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

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

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

570 | s1=t([0,1,0]) |

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

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

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

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

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

576 | def test_Rotatation_diag_90_0(self): |

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

578 | s0=t([1,-1,0]) |

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

580 | self.failUnless(abs(numarray.dot(s0,s0)-2.)<self.ABS_TOL,"s0 length is wrong.") |

581 | self.failUnless(abs(numarray.dot(s0,numarray.array([1,-1,0])))<self.ABS_TOL,"s0 angle is wrong.") |

582 | self.failUnless(numarray.dot(_cross(s0,[1,-1,0]),numarray.array([1.,1.,1.]))<0.,"s0 has wrong orientation.") |

583 | s1=t([0,1,-1]) |

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

585 | self.failUnless(abs(numarray.dot(s1,s1)-2.)<self.ABS_TOL,"s1 length is wrong.") |

586 | self.failUnless(abs(numarray.dot(s1,numarray.array([0,1,-1])))<self.ABS_TOL,"s1 angle is wrong.") |

587 | self.failUnless(numarray.dot(_cross(s1,[0,1,-1]),numarray.array([1.,1.,1.]))<0.,"s1 has wrong orientation.") |

588 | s2=t([-1,0,1]) |

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

590 | self.failUnless(abs(numarray.dot(s2,s2)-2.)<self.ABS_TOL,"s2 length is wrong.") |

591 | self.failUnless(abs(numarray.dot(s2,numarray.array([-1,0,1])))<self.ABS_TOL,"s2 angle is wrong.") |

592 | self.failUnless(numarray.dot(_cross(s2,[-1,0,1]),numarray.array([1.,1.,1.]))<0.,"s2 has wrong orientation.") |

593 | s3=t([1,1,1]) |

594 | self.failUnless(isinstance(s3,numarray.NumArray),"s3 is not a numarray object.") |

595 | self.failUnless(self.__distance(s3,numarray.array([1.,1,1.]))<self.ABS_TOL,"s3 is wrong.") |

596 | |

597 | class Test_PyCAD_Primitives(unittest.TestCase): |

598 | def setUp(self): |

599 | resetGlobalPrimitiveIdCounter() |

600 | |

601 | def test_Primitive(self): |

602 | p=Primitive() |

603 | |

604 | id=p.getID() |

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

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

607 | |

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

609 | |

610 | def test_ReversePrimitive(self): |

611 | p=Primitive() |

612 | |

613 | rp=ReversePrimitive(p) |

614 | self.failUnless(p.getID()==rp.getID(),"reverse primitive does not have same id like source") |

615 | self.failUnless(p==rp.getUnderlyingPrimitive(),"getUnderlyingPrimitive does return source.") |

616 | self.failUnless(p == -rp,"reverse or reverse does not return source.") |

617 | |

618 | def test_Point(self): |

619 | p=Point(1.,2.,3.,local_scale=9.) |

620 | |

621 | id=p.getID() |

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

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

624 | |

625 | # check reverse point |

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

627 | |

628 | # check history: |

629 | hs=p.getPrimitives() |

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

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

632 | |

633 | # check incolved points: |

634 | ps=p.getConstructionPoints() |

635 | self.failUnless(len(ps)==1,"point set must have length 1.") |

636 | self.failUnless(p in ps,"point set must contain point p") |

637 | |

638 | # check coordinates: |

639 | c=p.getCoordinates() |

640 | self.failUnless(isinstance(c,numarray.NumArray),"coordinates are not a numarray object.") |

641 | self.failUnless(c[0]==1.,"x coordinate is not 1.") |

642 | self.failUnless(c[1]==2.,"y coordinate is not 2.") |

643 | self.failUnless(c[2]==3.,"z coordinate is not 3.") |

644 | |

645 | # reset coordinates: |

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

647 | c=p.getCoordinates() |

648 | self.failUnless(isinstance(c,numarray.NumArray),"new coordinates are not a numarray object.") |

649 | self.failUnless(c[0]==-1.,"new x coordinate is not -1.") |

650 | self.failUnless(c[1]==-2.,"new y coordinate is not -2.") |

651 | self.failUnless(c[2]==-3.,"new z coordinate is not -3.") |

652 | |

653 | # check for a colocated point: |

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

655 | self.failUnless(not p.isColocated(numarray.array([-1.,-2.,-3.])),"colocation with numarray representation not detected.") |

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

657 | self.failUnless(not p.isColocated(Point(0.,0.,0.)),"false colocation with origin detected.") |

658 | |

659 | # check for local length scale |

660 | l=p.getLocalScale() |

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

662 | |

663 | # check for new local length scale |

664 | p.setLocalScale(3.) |

665 | l=p.getLocalScale() |

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

667 | |

668 | # negative value shouldn't work. |

669 | self.failUnlessRaises(ValueError,p.setLocalScale,-3.) |

670 | |

671 | # copy: |

672 | an_other_p=p.copy() |

673 | self.failUnless(isinstance(an_other_p ,Point),"copy is not a point") |

674 | self.failUnless(not an_other_p.getID() == p.getID(),"copy has same Id") |

675 | self.failUnless(p.isColocated(an_other_p),"p is not colocated with its copy.") |

676 | self.failUnless(an_other_p.isColocated(p),"the copy is not colocated with p.") |

677 | self.failUnless(an_other_p.getLocalScale()==3.,"copy has wrong local scale.") |

678 | |

679 | # modify by Transformation: |

680 | p.modifyBy(Dilation(-1)) |

681 | self.failUnless(p.isColocated(Point(1.,2.,3.)),"in-place transformation failed") |

682 | |

683 | # apply Transformation: |

684 | dil_p=p.apply(Dilation(4)) |

685 | self.failUnless(dil_p.isColocated(Point(4.,8.,12.)),"applying transformation failed") |

686 | self.failUnless(not dil_p.getID() == p.getID(),"transformed point has same Id") |

687 | self.failUnless(dil_p.getLocalScale()==3.,"transformed point has wrong local scale.") |

688 | |

689 | # overloaded add: |

690 | shift_p=p+[1,1,1] |

691 | self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by list failed") |

692 | self.failUnless(not shift_p.getID() == p.getID(),"shift by list has same Id") |

693 | self.failUnless(shift_p.getLocalScale()==3.,"shift by list has wrong local scale.") |

694 | |

695 | shift_p=p+numarray.array([1,1,1]) |

696 | self.failUnless(shift_p.isColocated(Point(2,3.,4)),"applying shift by numarray failed") |

697 | self.failUnless(not shift_p.getID() == p.getID(),"shift by numarray has same Id") |

698 | self.failUnless(shift_p.getLocalScale()==3.,"shift by numarray has wrong local scale.") |

699 | # overloaded minus |

700 | shift_p=p-[1,1,1] |

701 | self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -list failed") |

702 | self.failUnless(not shift_p.getID() == p.getID(),"shift by -list has same Id") |

703 | self.failUnless(shift_p.getLocalScale()==3.,"shift by -list has wrong local scale.") |

704 | |

705 | shift_p=p-numarray.array([1,1,1]) |

706 | self.failUnless(shift_p.isColocated(Point(0,1,2.)),"applying shift by -numarray failed") |

707 | self.failUnless(not shift_p.getID() == p.getID(),"shift by -numarray has same Id") |

708 | self.failUnless(shift_p.getLocalScale()==3.,"shift by -numarray has wrong local scale.") |

709 | # overloaded inplace add: |

710 | p+=[1,1,1] |

711 | self.failUnless(p.isColocated(Point(2,3.,4)),"modification by list shift failed") |

712 | |

713 | p+=numarray.array([1,1,1]) |

714 | self.failUnless(p.isColocated(Point(3,4,5)),"modification by numarray shift failed") |

715 | |

716 | # overloaded inplace add: |

717 | p-=[1,1,1] |

718 | self.failUnless(p.isColocated(Point(2,3,4)),"modification by -list shift failed") |

719 | |

720 | p-=numarray.array([1,1,1]) |

721 | self.failUnless(p.isColocated(Point(1,2.,3)),"modification by -numarray shift failed") |

722 | |

723 | #overloaded multiplication: |

724 | mult_p=2*p |

725 | self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying int factor failed") |

726 | self.failUnless(not mult_p.getID() == p.getID(),"shift by int factor has same Id") |

727 | self.failUnless(mult_p.getLocalScale()==3.,"shift by int factor has wrong local scale.") |

728 | |

729 | mult_p=2.*p |

730 | self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying float factor failed") |

731 | self.failUnless(not mult_p.getID() == p.getID(),"shift by float factor has same Id") |

732 | self.failUnless(mult_p.getLocalScale()==3.,"shift by float factor has wrong local scale.") |

733 | |

734 | mult_p=Dilation(2)*p |

735 | self.failUnless(mult_p.isColocated(Point(2,4,6)),"applying Dilation factor failed") |

736 | self.failUnless(not mult_p.getID() == p.getID(),"shift by Dilation factor has same Id") |

737 | self.failUnless(mult_p.getLocalScale()==3.,"shift by Dilation factor has wrong local scale.") |

738 | |

739 | #overloaded inplace multiplication: |

740 | p*=2 |

741 | self.failUnless(p.isColocated(Point(2,4,6)),"applying in-place int factor failed") |

742 | |

743 | p*=2. |

744 | self.failUnless(p.isColocated(Point(4,8,12)),"applying in-place float factor failed") |

745 | |

746 | p*=Dilation(2) |

747 | self.failUnless(p.isColocated(Point(8,16,24)),"applying in-place Dilation factor failed") |

748 | |

749 | # get gmsh code |

750 | code=p.getGmshCommand(2.) |

751 | self.failUnless("Point(1) = {8.0 , 16.0, 24.0 , 6.0 };"== code, "wrong gmsh code") |

752 | |

753 | def test_Spline(self): |

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

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

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

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

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

759 | |

760 | self.failUnlessRaises(ValueError,Spline,p0) |

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

762 | |

763 | self.failUnless(len(c) == 4, "wrong spline curve length") |

764 | self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |

765 | self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") |

766 | |

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

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

769 | |

770 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

771 | self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"spline is colocated with spline of different length.") |

772 | self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"spline is colocated with spline with different point.") |

773 | self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.") |

774 | self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

775 | self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |

776 | |

777 | co=c.getControlPoints() |

778 | self.failUnless(co[0]==p0, "1st control point is wrong.") |

779 | self.failUnless(co[1]==p1, "2nd control point is wrong.") |

780 | self.failUnless(co[2]==p2, "3rd control point is wrong.") |

781 | self.failUnless(co[3]==p3, "4th control point is wrong.") |

782 | |

783 | c.setLocalScale(3.) |

784 | co=c.getControlPoints() |

785 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

786 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

787 | self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |

788 | self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |

789 | |

790 | code=c.getGmshCommand() |

791 | self.failUnless(code == "Spline(6) = {1, 2, 3, 4};", "gmsh command wrong.") |

792 | |

793 | h=c.getPrimitives() |

794 | self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |

795 | self.failUnless(p0 in h, "missing p0 in history.") |

796 | self.failUnless(p1 in h, "missing p1 in history.") |

797 | self.failUnless(p2 in h, "missing p2 in history.") |

798 | self.failUnless(p3 in h, "missing p3 in history.") |

799 | self.failUnless(c in h, "missing spline curve in history.") |

800 | |

801 | cp=c.copy() |

802 | cpcp=cp.getControlPoints() |

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

804 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

805 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

806 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

807 | self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.") |

808 | self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.") |

809 | |

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

811 | cp=c.getControlPoints() |

812 | 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.") |

813 | self.failUnless(p0 == cp[0],"1st new point after Dilation.") |

814 | self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |

815 | self.failUnless(p2 == cp[2],"3rd new point after Dilation.") |

816 | self.failUnless(p3 == cp[3],"4th new point after Dilation.") |

817 | |

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

819 | dccp=dc.getControlPoints() |

820 | self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |

821 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

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

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

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

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

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

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

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

829 | |

830 | def test_ReverseSpline(self): |

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

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

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

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

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

836 | |

837 | CC0=Spline(p0,p1,p2,p3) |

838 | c=-CC0 |

839 | |

840 | self.failUnless(len(c) == 4, "wrong reverse spline curve length") |

841 | self.failUnless(c.getStartPoint()==p3, "wrong start point of reverse spline curve") |

842 | self.failUnless(c.getEndPoint()==p0, "wrong end point of reverse spline curve") |

843 | |

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

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

846 | |

847 | self.failUnless(not c.isColocated(p1),"reverse spline is colocated with point.") |

848 | self.failUnless(not c.isColocated(Spline(p0,p1,p2)),"reverse spline is colocated with spline of different length.") |

849 | self.failUnless(not c.isColocated(Spline(p0,p1,p4,p3)),"reverse spline is colocated with spline with different point.") |

850 | self.failUnless(c.isColocated(Spline(p0,p1,p2,p3)),"reverse spline is not colocated with spline with same points but opposite direction.") |

851 | self.failUnless(c.isColocated(Spline(p3,p2,p1,p0)),"reverse spline is not colocated with spline with same points.") |

852 | self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |

853 | |

854 | co=c.getControlPoints() |

855 | self.failUnless(co[0]==p3, "1st control point is wrong.") |

856 | self.failUnless(co[1]==p2, "2nd control point is wrong.") |

857 | self.failUnless(co[2]==p1, "3rd control point is wrong.") |

858 | self.failUnless(co[3]==p0, "4th control point is wrong.") |

859 | |

860 | c.setLocalScale(3.) |

861 | co=c.getControlPoints() |

862 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

863 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

864 | self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |

865 | self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |

866 | |

867 | code=c.getGmshCommand() |

868 | self.failUnless(code == "Spline(6) = {1, 2, 3, 4};", "gmsh command wrong.") |

869 | |

870 | h=c.getPrimitives() |

871 | self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |

872 | self.failUnless(p0 in h, "missing p0 in history.") |

873 | self.failUnless(p1 in h, "missing p1 in history.") |

874 | self.failUnless(p2 in h, "missing p2 in history.") |

875 | self.failUnless(p3 in h, "missing p3 in history.") |

876 | self.failUnless(CC0 in h, "missing spline curve in history.") |

877 | |

878 | cp=c.copy() |

879 | cpcp=cp.getControlPoints() |

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

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

882 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

883 | self.failUnless(not p3 == cpcp[0],"1st point of deep copy and souce are the same.") |

884 | self.failUnless(not p2 == cpcp[1],"2st point of deep copy and source are the same.") |

885 | self.failUnless(not p1 == cpcp[2],"3st point of deep copy and source are the same.") |

886 | self.failUnless(not p0 == cpcp[3],"4st point of deep copy and source are the same.") |

887 | |

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

889 | cp=c.getControlPoints() |

890 | 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.") |

891 | self.failUnless(p3 == cp[0],"1st new point after Dilation.") |

892 | self.failUnless(p2 == cp[1],"2nd new point after Dilation.") |

893 | self.failUnless(p1 == cp[2],"3rd new point after Dilation.") |

894 | self.failUnless(p0 == cp[3],"4th new point after Dilation.") |

895 | |

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

897 | dccp=dc.getControlPoints() |

898 | self.failUnless(dc.isColocated(Spline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |

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

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

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

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

903 | |

904 | def test_BezierCurve(self): |

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

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

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

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

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

910 | |

911 | self.failUnlessRaises(ValueError,BezierCurve,p0) |

912 | c=BezierCurve(p0,p1,p2,p3) |

913 | |

914 | self.failUnless(len(c) == 4, "wrong spline curve length") |

915 | self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |

916 | self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") |

917 | |

918 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

919 | self.failUnless(not c.isColocated(BezierCurve(p0,p1,p2)),"spline is colocated with spline of different length.") |

920 | self.failUnless(not c.isColocated(BezierCurve(p0,p1,p4,p3)),"spline is colocated with spline with different point.") |

921 | self.failUnless(c.isColocated(BezierCurve(p0,p1,p2,p3)),"spline is not colocated with spline with same points.") |

922 | self.failUnless(c.isColocated(BezierCurve(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

923 | self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |

924 | |

925 | co=c.getControlPoints() |

926 | self.failUnless(co[0]==p0, "1st control point is wrong.") |

927 | self.failUnless(co[1]==p1, "2nd control point is wrong.") |

928 | self.failUnless(co[2]==p2, "3rd control point is wrong.") |

929 | self.failUnless(co[3]==p3, "4th control point is wrong.") |

930 | |

931 | c.setLocalScale(3.) |

932 | co=c.getControlPoints() |

933 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

934 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

935 | self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |

936 | self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |

937 | |

938 | code=c.getGmshCommand() |

939 | self.failUnless(code == "Bezier(6) = {1, 2, 3, 4};", "gmsh command wrong.") |

940 | |

941 | h=c.getPrimitives() |

942 | self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |

943 | self.failUnless(p0 in h, "missing p0 in history.") |

944 | self.failUnless(p1 in h, "missing p1 in history.") |

945 | self.failUnless(p2 in h, "missing p2 in history.") |

946 | self.failUnless(p3 in h, "missing p3 in history.") |

947 | self.failUnless(c in h, "missing spline curve in history.") |

948 | |

949 | cp=c.copy() |

950 | cpcp=cp.getControlPoints() |

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

952 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

953 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

954 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

955 | self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.") |

956 | self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.") |

957 | |

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

959 | cp=c.getControlPoints() |

960 | 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.") |

961 | self.failUnless(p0 == cp[0],"1st new point after Dilation.") |

962 | self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |

963 | self.failUnless(p2 == cp[2],"3rd new point after Dilation.") |

964 | self.failUnless(p3 == cp[3],"4th new point after Dilation.") |

965 | |

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

967 | dccp=dc.getControlPoints() |

968 | self.failUnless(dc.isColocated(BezierCurve(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |

969 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

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

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

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

973 | |

974 | def test_BSpline(self): |

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

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

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

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

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

980 | |

981 | self.failUnlessRaises(ValueError,BSpline,p0) |

982 | c=BSpline(p0,p1,p2,p3) |

983 | |

984 | self.failUnless(len(c) == 4, "wrong spline curve length") |

985 | self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |

986 | self.failUnless(c.getEndPoint()==p3, "wrong end point of spline curve") |

987 | |

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

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

990 | |

991 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

992 | self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.") |

993 | self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.") |

994 | self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.") |

995 | self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

996 | self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |

997 | |

998 | co=c.getControlPoints() |

999 | self.failUnless(co[0]==p0, "1st control point is wrong.") |

1000 | self.failUnless(co[1]==p1, "2nd control point is wrong.") |

1001 | self.failUnless(co[2]==p2, "3rd control point is wrong.") |

1002 | self.failUnless(co[3]==p3, "4th control point is wrong.") |

1003 | |

1004 | c.setLocalScale(3.) |

1005 | co=c.getControlPoints() |

1006 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

1007 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

1008 | self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |

1009 | self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |

1010 | |

1011 | code=c.getGmshCommand() |

1012 | self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.") |

1013 | |

1014 | h=c.getPrimitives() |

1015 | self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |

1016 | self.failUnless(p0 in h, "missing p0 in history.") |

1017 | self.failUnless(p1 in h, "missing p1 in history.") |

1018 | self.failUnless(p2 in h, "missing p2 in history.") |

1019 | self.failUnless(p3 in h, "missing p3 in history.") |

1020 | self.failUnless(c in h, "missing spline curve in history.") |

1021 | |

1022 | cp=c.copy() |

1023 | cpcp=cp.getControlPoints() |

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

1025 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

1026 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

1027 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

1028 | self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.") |

1029 | self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.") |

1030 | |

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

1032 | cp=c.getControlPoints() |

1033 | 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.") |

1034 | self.failUnless(p0 == cp[0],"1st new point after Dilation.") |

1035 | self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |

1036 | self.failUnless(p2 == cp[2],"3rd new point after Dilation.") |

1037 | self.failUnless(p3 == cp[3],"4th new point after Dilation.") |

1038 | |

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

1040 | dccp=dc.getControlPoints() |

1041 | self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |

1042 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

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

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

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

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

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

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

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

1050 | |

1051 | def test_ReverseBSpline(self): |

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

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

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

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

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

1057 | |

1058 | CC0=BSpline(p0,p1,p2,p3) |

1059 | c=-CC0 |

1060 | |

1061 | self.failUnless(len(c) == 4, "wrong spline curve length") |

1062 | self.failUnless(c.getStartPoint()==p3, "wrong start point of spline curve") |

1063 | self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve") |

1064 | |

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

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

1067 | |

1068 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

1069 | self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.") |

1070 | self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.") |

1071 | self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.") |

1072 | self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1073 | self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |

1074 | |

1075 | co=c.getControlPoints() |

1076 | self.failUnless(co[0]==p3, "1st control point is wrong.") |

1077 | self.failUnless(co[1]==p2, "2nd control point is wrong.") |

1078 | self.failUnless(co[2]==p1, "3rd control point is wrong.") |

1079 | self.failUnless(co[3]==p0, "4th control point is wrong.") |

1080 | |

1081 | c.setLocalScale(3.) |

1082 | co=c.getControlPoints() |

1083 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

1084 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

1085 | self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |

1086 | self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |

1087 | |

1088 | code=c.getGmshCommand() |

1089 | self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.") |

1090 | |

1091 | h=c.getPrimitives() |

1092 | self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |

1093 | self.failUnless(p0 in h, "missing p0 in history.") |

1094 | self.failUnless(p1 in h, "missing p1 in history.") |

1095 | self.failUnless(p2 in h, "missing p2 in history.") |

1096 | self.failUnless(p3 in h, "missing p3 in history.") |

1097 | self.failUnless(CC0 in h, "missing spline curve in history.") |

1098 | |

1099 | cp=c.copy() |

1100 | cpcp=cp.getControlPoints() |

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

1102 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

1103 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

1104 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

1105 | self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.") |

1106 | self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.") |

1107 | |

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

1109 | cp=c.getControlPoints() |

1110 | 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.") |

1111 | self.failUnless(p3 == cp[0],"1st new point after Dilation.") |

1112 | self.failUnless(p2 == cp[1],"2nd new point after Dilation.") |

1113 | self.failUnless(p1 == cp[2],"3rd new point after Dilation.") |

1114 | self.failUnless(p0 == cp[3],"4th new point after Dilation.") |

1115 | |

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

1117 | dccp=dc.getControlPoints() |

1118 | self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |

1119 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

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

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

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

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

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

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

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

1127 | |

1128 | def test_LineSegment(self): |

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

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

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

1132 | |

1133 | self.failUnlessRaises(TypeError,Line,p0) |

1134 | self.failUnlessRaises(TypeError,Line,p0,p1,p4) |

1135 | |

1136 | c=Line(p0,p1) |

1137 | |

1138 | self.failUnless(len(c) == 2, "wrong spline curve length") |

1139 | self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |

1140 | self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve") |

1141 | |

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

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

1144 | |

1145 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

1146 | self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.") |

1147 | self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.") |

1148 | self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1149 | self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.") |

1150 | |

1151 | co=c.getControlPoints() |

1152 | self.failUnless(co[0]==p0, "1st control point is wrong.") |

1153 | self.failUnless(co[1]==p1, "2nd control point is wrong.") |

1154 | |

1155 | c.setLocalScale(3.) |

1156 | co=c.getControlPoints() |

1157 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

1158 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

1159 | |

1160 | code=c.getGmshCommand() |

1161 | self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") |

1162 | |

1163 | h=c.getPrimitives() |

1164 | self.failUnless(len(h) == 3, "number of primitives in history is wrong.") |

1165 | self.failUnless(p0 in h, "missing p0 in history.") |

1166 | self.failUnless(p1 in h, "missing p1 in history.") |

1167 | self.failUnless(c in h, "missing spline curve in history.") |

1168 | |

1169 | cp=c.copy() |

1170 | cpcp=cp.getControlPoints() |

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

1172 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

1173 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

1174 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

1175 | |

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

1177 | cp=c.getControlPoints() |

1178 | self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") |

1179 | self.failUnless(p0 == cp[0],"1st new point after Dilation.") |

1180 | self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |

1181 | |

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

1183 | dccp=dc.getControlPoints() |

1184 | self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") |

1185 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

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

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

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

1189 | |

1190 | def test_ReverseLineSegment(self): |

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

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

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

1194 | |

1195 | self.failUnlessRaises(TypeError,Line,p0) |

1196 | self.failUnlessRaises(TypeError,Line,p0,p1,p4) |

1197 | |

1198 | CC0=Line(p0,p1) |

1199 | c=-CC0 |

1200 | |

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

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

1203 | |

1204 | self.failUnless(len(c) == 2, "wrong spline curve length") |

1205 | self.failUnless(c.getStartPoint()==p1, "wrong start point of spline curve") |

1206 | self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve") |

1207 | |

1208 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

1209 | self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.") |

1210 | self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.") |

1211 | self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1212 | self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.") |

1213 | |

1214 | co=c.getControlPoints() |

1215 | self.failUnless(co[0]==p1, "1st control point is wrong.") |

1216 | self.failUnless(co[1]==p0, "2nd control point is wrong.") |

1217 | |

1218 | c.setLocalScale(3.) |

1219 | co=c.getControlPoints() |

1220 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

1221 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

1222 | |

1223 | code=c.getGmshCommand() |

1224 | self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") |

1225 | |

1226 | h=c.getPrimitives() |

1227 | self.failUnless(len(h) == 3, "number of primitives in history is wrong.") |

1228 | self.failUnless(p0 in h, "missing p0 in history.") |

1229 | self.failUnless(p1 in h, "missing p1 in history.") |

1230 | self.failUnless(CC0 in h, "missing spline curve in history.") |

1231 | |

1232 | cp=c.copy() |

1233 | cpcp=cp.getControlPoints() |

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

1235 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

1236 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

1237 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

1238 | |

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

1240 | cp=c.getControlPoints() |

1241 | self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") |

1242 | self.failUnless(p1 == cp[0],"1st new point after Dilation.") |

1243 | self.failUnless(p0 == cp[1],"2nd new point after Dilation.") |

1244 | |

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

1246 | dccp=dc.getControlPoints() |

1247 | self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") |

1248 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

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

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

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

1252 | |

1253 | def test_Arc(self): |

1254 | center=Point(0,0,0,0.1) |

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

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

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

1258 | |

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

1260 | |

1261 | c=Arc(center,p_start,p_end) |

1262 | |

1263 | self.failUnless(c.getCenterPoint()==center, "wrong center point") |

1264 | self.failUnless(c.getStartPoint()==p_start, "wrong start point") |

1265 | self.failUnless(c.getEndPoint()==p_end, "wrong end point") |

1266 | |

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

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

1269 | |

1270 | code=c.getGmshCommand() |

1271 | self.failUnless(code == "Circle(6) = {2, 1, 3};", "gmsh command wrong.") |

1272 | |

1273 | self.failUnless(not c.isColocated(p4),"spline is colocated with point.") |

1274 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") |

1275 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") |

1276 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") |

1277 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") |

1278 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") |

1279 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") |

1280 | |

1281 | h=c.getPrimitives() |

1282 | self.failUnless(len(h) == 4, "number of primitives in history is wrong.") |

1283 | self.failUnless(center in h, "missing center in history.") |

1284 | self.failUnless(p_start in h, "missing p_start in history.") |

1285 | self.failUnless(p_end in h, "missing p_end in history.") |

1286 | self.failUnless(c in h, "missing spline curve in history.") |

1287 | |

1288 | |

1289 | c.setLocalScale(3.) |

1290 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") |

1291 | self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") |

1292 | self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") |

1293 | |

1294 | cp=c.copy() |

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

1296 | self.failUnless(not cp == c, "copy returns same arc.") |

1297 | self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.") |

1298 | self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source") |

1299 | self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source") |

1300 | self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source") |

1301 | |

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

1303 | self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.") |

1304 | self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.") |

1305 | self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.") |

1306 | self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.") |

1307 | |

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

1309 | self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.") |

1310 | self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.") |

1311 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |

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

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

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

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

1316 | |

1317 | def test_ReverseArc(self): |

1318 | center=Point(0,0,0,0.1) |

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

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

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

1322 | |

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

1324 | |

1325 | CC0=Arc(center,p_start,p_end) |

1326 | c=-CC0 |

1327 | |

1328 | self.failUnless(c.getCenterPoint()==center, "wrong center point") |

1329 | self.failUnless(c.getStartPoint()==p_end, "wrong start point") |

1330 | self.failUnless(c.getEndPoint()==p_start, "wrong end point") |

1331 | |

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

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

1334 | |

1335 | code=c.getGmshCommand() |

1336 | self.failUnless(code == "Circle(6) = {2, 1, 3};", "gmsh command wrong.") |

1337 | |

1338 | self.failUnless(not c.isColocated(p4),"spline is colocated with point.") |

1339 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") |

1340 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") |

1341 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") |

1342 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") |

1343 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") |

1344 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") |

1345 | |

1346 | h=c.getPrimitives() |

1347 | self.failUnless(len(h) == 4, "number of primitives in history is wrong.") |

1348 | self.failUnless(center in h, "missing center in history.") |

1349 | self.failUnless(p_start in h, "missing p_start in history.") |

1350 | self.failUnless(p_end in h, "missing p_end in history.") |

1351 | self.failUnless(CC0 in h, "missing spline curve in history.") |

1352 | |

1353 | |

1354 | c.setLocalScale(3.) |

1355 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") |

1356 | self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") |

1357 | self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") |

1358 | |

1359 | cp=c.copy() |

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

1361 | self.failUnless(not cp == c, "copy returns same arc.") |

1362 | self.failUnless(cp.isColocated(Arc(center,p_end,p_start)),"arc is not colocated with its copy.") |

1363 | self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source") |

1364 | self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source") |

1365 | self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source") |

1366 | |

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

1368 | self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.") |

1369 | self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.") |

1370 | self.failUnless(c.getStartPoint() == p_end,"wrong start point after dilation.") |

1371 | self.failUnless(c.getEndPoint() == p_start,"wrong end point after dilation.") |

1372 | |

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

1374 | self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.") |

1375 | self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.") |

1376 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |

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

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

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

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

1381 | |

1382 | def test_CurveLoop(self): |

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

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

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

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

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

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

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

1390 | |

1391 | l01=Line(p0,p1) |

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

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

1394 | |

1395 | lx=Line(p2,p3) |

1396 | ly=Line(p3,p1) |

1397 | |

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

1399 | self.failUnlessRaises(ValueError,CurveLoop,l01,lx,l20) |

1400 | self.failUnlessRaises(ValueError,CurveLoop,l01,l20,l20) |

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

1402 | |

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

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

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

1406 | |

1407 | code=c.getGmshCommand() |

1408 | self.failUnless(code == "Line Loop(14) = {8, 9, 10};", "gmsh command wrong.") |

1409 | |

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

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

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

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

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

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

1416 | |

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

1418 | |

1419 | c.setLocalScale(3.) |

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

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

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

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

1424 | |

1425 | |

1426 | cc=c.getCurves() |

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

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

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

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

1431 | |

1432 | p=c.getPrimitives() |

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

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

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

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

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

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

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

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

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

1442 | |

1443 | cp=c.copy() |

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

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

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

1447 | cc=cp.getCurves() |

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

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

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

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

1452 | |

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

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

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

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

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

1458 | |

1459 | l01_m=Line(p0_m,p1_m) |

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

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

1462 | |

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

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

1465 | cc=dc.getCurves() |

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

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

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

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

1470 | |

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

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

1473 | cc=c.getCurves() |

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

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

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

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

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

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

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

1481 | |

1482 | def test_ReverseCurveLoop(self): |

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

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

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

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

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

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

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

1490 | |

1491 | l01=Line(p0,p1) |

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

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

1494 | |

1495 | lx=Line(p2,p3) |

1496 | ly=Line(p3,p1) |

1497 | |

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

1499 | c=-CC0 |

1500 | |

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

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

1503 | |

1504 | code=c.getGmshCommand() |

1505 | self.failUnless(code == "Line Loop(13) = {8, 9, 10};", "gmsh command wrong.") |

1506 | |

1507 | |

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

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

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

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

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

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

1514 | |

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

1516 | |

1517 | c.setLocalScale(3.) |

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

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

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

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

1522 | |

1523 | |

1524 | cc=c.getCurves() |

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

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

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

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

1529 | |

1530 | p=c.getPrimitives() |

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

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

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

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

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

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

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

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

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

1540 | |

1541 | cp=c.copy() |

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

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

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

1545 | cc=cp.getCurves() |

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

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

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

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

1550 | |

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

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

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

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

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

1556 | |

1557 | l01_m=Line(p0_m,p1_m) |

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

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

1560 | |

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

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

1563 | cc=dc.getCurves() |

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

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

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

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

1568 | |

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

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

1571 | cc=c.getCurves() |

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

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

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

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

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

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

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

1579 | |

1580 | def test_RuledSurface(self): |

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

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

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

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

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

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

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

1588 | |

1589 | l01=Line(p0,p1) |

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

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

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

1593 | l12_3=Line(p1,p2) |

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

1595 | |

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

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

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

1599 | |

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

1601 | |

1602 | s=RuledSurface(cl1) |

1603 | |

1604 | cl=s.getBoundaryLoop() |

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

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

1607 | |

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

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

1610 | |

1611 | crvs=s.getBoundary() |

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

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

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

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

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

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

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

1619 | |

1620 | |

1621 | code=s.getGmshCommand() |

1622 | self.failUnless(code == "Ruled Surface(17) = {14};", "gmsh command wrong.") |

1623 | |

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

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

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

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

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

1629 | |

1630 | s.setLocalScale(3.) |

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

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

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

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

1635 | |

1636 | p=s.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1647 | |

1648 | sp=s.copy() |

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

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

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

1652 | cbl=sp.getBoundaryLoop() |

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

1654 | cp=sp.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1665 | del cp |

1666 | |

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

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

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

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

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

1672 | |

1673 | l01_m=Line(p0_m,p1_m) |

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

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

1676 | |

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

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

1679 | cbl=ds.getBoundaryLoop() |

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

1681 | cp=ds.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1692 | |

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

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

1695 | |

1696 | p=s.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1707 | |

1708 | p=s.getBoundary() |

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

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

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

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

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

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

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

1716 | |

1717 | p=s.getBoundaryLoop() |

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

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

1720 | |

1721 | def test_ReverseRuledSurface(self): |

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

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

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

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

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