Parent Directory | Revision Log

Revision **929** -
(**show annotations**)

*Wed Jan 17 07:41:13 2007 UTC*
(13 years, 8 months ago)
by *gross*

File MIME type: text/x-python

File size: 107793 byte(s)

File MIME type: text/x-python

File size: 107793 byte(s)

reverse orientation added but does not work for 2D yet.

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(TypeError,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(not c.isColocated(p1),"spline is colocated with point.") |

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

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

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

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

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

773 | |

774 | co=c.getControlPoints() |

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

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

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

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

779 | |

780 | c.setLocalScale(3.) |

781 | co=c.getControlPoints() |

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

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

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

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

786 | |

787 | code=c.getGmshCommand() |

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

789 | |

790 | h=c.getPrimitives() |

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

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

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

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

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

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

797 | |

798 | cp=c.copy() |

799 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

806 | |

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

808 | cp=c.getControlPoints() |

809 | self.failUnless(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.") |

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

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

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

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

814 | |

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

816 | dccp=dc.getControlPoints() |

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

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

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

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

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

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

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

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

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

826 | |

827 | def test_ReverseSpline(self): |

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

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

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

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

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

833 | |

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

835 | c=-CC0 |

836 | |

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

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

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

840 | |

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

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

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

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

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

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

847 | |

848 | co=c.getControlPoints() |

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

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

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

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

853 | |

854 | c.setLocalScale(3.) |

855 | co=c.getControlPoints() |

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

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

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

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

860 | |

861 | code=c.getGmshCommand() |

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

863 | |

864 | h=c.getPrimitives() |

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

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

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

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

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

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

871 | |

872 | cp=c.copy() |

873 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

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

881 | |

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

883 | cp=c.getControlPoints() |

884 | self.failUnless(c.isColocated(Spline(Point(0,0,0),Point(-1,-1,-1),Point(-2,-2,-2),Point(-3,-3,-3))),"inplace dilation is wrong.") |

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

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

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

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

889 | |

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

891 | dccp=dc.getControlPoints() |

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

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

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

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

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

897 | |

898 | def test_BezierCurve(self): |

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

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

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

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

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

904 | |

905 | self.failUnlessRaises(TypeError,BezierCurve,p0) |

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

907 | |

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

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

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

911 | |

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

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

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

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

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

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

918 | |

919 | co=c.getControlPoints() |

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

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

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

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

924 | |

925 | c.setLocalScale(3.) |

926 | co=c.getControlPoints() |

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

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

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

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

931 | |

932 | code=c.getGmshCommand() |

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

934 | |

935 | h=c.getPrimitives() |

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

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

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

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

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

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

942 | |

943 | cp=c.copy() |

944 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

951 | |

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

953 | cp=c.getControlPoints() |

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

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

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

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

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

959 | |

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

961 | dccp=dc.getControlPoints() |

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

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

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

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

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

967 | |

968 | def test_BSpline(self): |

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

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

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

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

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

974 | |

975 | self.failUnlessRaises(TypeError,BSpline,p0) |

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

977 | |

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

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

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

981 | |

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

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

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

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

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

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

988 | |

989 | co=c.getControlPoints() |

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

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

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

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

994 | |

995 | c.setLocalScale(3.) |

996 | co=c.getControlPoints() |

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

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

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

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

1001 | |

1002 | code=c.getGmshCommand() |

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

1004 | |

1005 | h=c.getPrimitives() |

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

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

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

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

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

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

1012 | |

1013 | cp=c.copy() |

1014 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

1021 | |

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

1023 | cp=c.getControlPoints() |

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

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

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

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

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

1029 | |

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

1031 | dccp=dc.getControlPoints() |

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

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

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

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

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

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

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

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

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

1041 | |

1042 | def test_ReverseBSpline(self): |

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

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

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

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

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

1048 | |

1049 | CC0=BSpline(p0,p1,p2,p3) |

1050 | c=-CC0 |

1051 | |

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

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

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

1055 | |

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

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

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

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

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

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

1062 | |

1063 | co=c.getControlPoints() |

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

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

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

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

1068 | |

1069 | c.setLocalScale(3.) |

1070 | co=c.getControlPoints() |

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

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

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

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

1075 | |

1076 | code=c.getGmshCommand() |

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

1078 | |

1079 | h=c.getPrimitives() |

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

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

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

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

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

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

1086 | |

1087 | cp=c.copy() |

1088 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

1095 | |

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

1097 | cp=c.getControlPoints() |

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

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

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

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

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

1103 | |

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

1105 | dccp=dc.getControlPoints() |

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

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

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

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

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

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

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

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

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

1115 | |

1116 | def test_LineSegment(self): |

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

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

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

1120 | |

1121 | self.failUnlessRaises(TypeError,Line,p0) |

1122 | self.failUnlessRaises(TypeError,Line,p0,p1,p4) |

1123 | |

1124 | c=Line(p0,p1) |

1125 | |

1126 | self.failUnless(len(c) == 2, "wrong spline curve length") |

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

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

1129 | |

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

1131 | self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.") |

1132 | self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.") |

1133 | self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1134 | self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.") |

1135 | |

1136 | co=c.getControlPoints() |

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

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

1139 | |

1140 | c.setLocalScale(3.) |

1141 | co=c.getControlPoints() |

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

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

1144 | |

1145 | code=c.getGmshCommand() |

1146 | self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") |

1147 | |

1148 | h=c.getPrimitives() |

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

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

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

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

1153 | |

1154 | cp=c.copy() |

1155 | cpcp=cp.getControlPoints() |

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

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

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

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

1160 | |

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

1162 | cp=c.getControlPoints() |

1163 | self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") |

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

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

1166 | |

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

1168 | dccp=dc.getControlPoints() |

1169 | self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") |

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

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

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

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

1174 | |

1175 | def test_ReverseLineSegment(self): |

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

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

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

1179 | |

1180 | self.failUnlessRaises(TypeError,Line,p0) |

1181 | self.failUnlessRaises(TypeError,Line,p0,p1,p4) |

1182 | |

1183 | CC0=Line(p0,p1) |

1184 | c=-CC0 |

1185 | |

1186 | self.failUnless(len(c) == 2, "wrong spline curve length") |

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

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

1189 | |

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

1191 | self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.") |

1192 | self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.") |

1193 | self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1194 | self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.") |

1195 | |

1196 | co=c.getControlPoints() |

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

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

1199 | |

1200 | c.setLocalScale(3.) |

1201 | co=c.getControlPoints() |

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

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

1204 | |

1205 | code=c.getGmshCommand() |

1206 | self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") |

1207 | |

1208 | h=c.getPrimitives() |

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

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

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

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

1213 | |

1214 | cp=c.copy() |

1215 | cpcp=cp.getControlPoints() |

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

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

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

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

1220 | |

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

1222 | cp=c.getControlPoints() |

1223 | self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") |

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

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

1226 | |

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

1228 | dccp=dc.getControlPoints() |

1229 | self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") |

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

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

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

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

1234 | |

1235 | def test_Arc(self): |

1236 | center=Point(0,0,0,0.1) |

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

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

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

1240 | |

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

1242 | |

1243 | c=Arc(center,p_start,p_end) |

1244 | |

1245 | self.failUnless(c.getCenterPoint()==center, "wrong center point") |

1246 | self.failUnless(c.getStartPoint()==p_start, "wrong start point") |

1247 | self.failUnless(c.getEndPoint()==p_end, "wrong end point") |

1248 | |

1249 | code=c.getGmshCommand() |

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

1251 | |

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

1253 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") |

1254 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") |

1255 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") |

1256 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") |

1257 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") |

1258 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") |

1259 | |

1260 | h=c.getPrimitives() |

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

1262 | self.failUnless(center in h, "missing center in history.") |

1263 | self.failUnless(p_start in h, "missing p_start in history.") |

1264 | self.failUnless(p_end in h, "missing p_end in history.") |

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

1266 | |

1267 | |

1268 | c.setLocalScale(3.) |

1269 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") |

1270 | self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") |

1271 | self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") |

1272 | |

1273 | cp=c.copy() |

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

1275 | self.failUnless(not cp == c, "copy returns same arc.") |

1276 | self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.") |

1277 | self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source") |

1278 | self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source") |

1279 | self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source") |

1280 | |

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

1282 | self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.") |

1283 | self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.") |

1284 | self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.") |

1285 | self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.") |

1286 | |

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

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

1289 | self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.") |

1290 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |

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

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

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

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

1295 | |

1296 | def test_ReverseArc(self): |

1297 | center=Point(0,0,0,0.1) |

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

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

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

1301 | |

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

1303 | |

1304 | CC0=Arc(center,p_start,p_end) |

1305 | c=-CC0 |

1306 | |

1307 | self.failUnless(c.getCenterPoint()==center, "wrong center point") |

1308 | self.failUnless(c.getStartPoint()==p_end, "wrong start point") |

1309 | self.failUnless(c.getEndPoint()==p_start, "wrong end point") |

1310 | |

1311 | code=c.getGmshCommand() |

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

1313 | |

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

1315 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") |

1316 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") |

1317 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") |

1318 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") |

1319 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") |

1320 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") |

1321 | |

1322 | h=c.getPrimitives() |

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

1324 | self.failUnless(center in h, "missing center in history.") |

1325 | self.failUnless(p_start in h, "missing p_start in history.") |

1326 | self.failUnless(p_end in h, "missing p_end in history.") |

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

1328 | |

1329 | |

1330 | c.setLocalScale(3.) |

1331 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") |

1332 | self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") |

1333 | self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") |

1334 | |

1335 | cp=c.copy() |

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

1337 | self.failUnless(not cp == c, "copy returns same arc.") |

1338 | self.failUnless(cp.isColocated(Arc(center,p_end,p_start)),"arc is not colocated with its copy.") |

1339 | self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source") |

1340 | self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source") |

1341 | self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source") |

1342 | |

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

1344 | self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.") |

1345 | self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.") |

1346 | self.failUnless(c.getStartPoint() == p_end,"wrong start point after dilation.") |

1347 | self.failUnless(c.getEndPoint() == p_start,"wrong end point after dilation.") |

1348 | |

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

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

1351 | self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.") |

1352 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |

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

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

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

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

1357 | |

1358 | def test_CurveLoop(self): |

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

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

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

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

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

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

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

1366 | |

1367 | l01=Line(p0,p1) |

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

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

1370 | |

1371 | lx=Line(p2,p3) |

1372 | ly=Line(p3,p1) |

1373 | |

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

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

1376 | self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,lx,l20,msg="loop detected.") |

1377 | self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,l20,msg="douple not detected.") |

1378 | self.failUnlessRaises(TypeError,ValueError,CurveLoop,l01,l20,ly,msg="loop detected.") |

1379 | |

1380 | code=c.getGmshCommand() |

1381 | self.failUnless(code == "Line Loop(14) = {8, 9, 10};", "gmsh command wrong.") |

1382 | |

1383 | |

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

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

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

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

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

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

1390 | |

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

1392 | |

1393 | c.setLocalScale(3.) |

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

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

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

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

1398 | |

1399 | |

1400 | cc=c.getCurves() |

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

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

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

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

1405 | |

1406 | p=c.getPrimitives() |

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

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

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

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

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

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

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

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

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

1416 | |

1417 | cp=c.copy() |

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

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

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

1421 | cc=cp.getCurves() |

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

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

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

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

1426 | |

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

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

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

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

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

1432 | |

1433 | l01_m=Line(p0_m,p1_m) |

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

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

1436 | |

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

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

1439 | cc=dc.getCurves() |

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

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

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

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

1444 | |

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

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

1447 | cc=c.getCurves() |

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

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

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

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

1452 | |

1453 | def test_ReverseCurveLoop(self): |

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

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

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

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

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

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

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

1461 | |

1462 | l01=Line(p0,p1) |

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

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

1465 | |

1466 | lx=Line(p2,p3) |

1467 | ly=Line(p3,p1) |

1468 | |

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

1470 | c=-CC0 |

1471 | |

1472 | code=c.getGmshCommand() |

1473 | print code |

1474 | self.failUnless(code == "Line Loop(13) = {8, 9, 10};", "gmsh command wrong.") |

1475 | |

1476 | |

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

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

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

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

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

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

1483 | |

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

1485 | |

1486 | c.setLocalScale(3.) |

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

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

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

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

1491 | |

1492 | |

1493 | cc=c.getCurves() |

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

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

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

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

1498 | |

1499 | p=c.getPrimitives() |

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

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

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

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

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

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

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

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

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

1509 | |

1510 | cp=c.copy() |

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

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

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

1514 | cc=cp.getCurves() |

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

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

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

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

1519 | |

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

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

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

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

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

1525 | |

1526 | l01_m=Line(p0_m,p1_m) |

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

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

1529 | |

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

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

1532 | cc=dc.getCurves() |

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

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

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

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

1537 | |

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

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

1540 | cc=c.getCurves() |

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

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

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

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

1545 | |

1546 | def test_RuledSurface(self): |

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

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

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

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

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

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

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

1554 | |

1555 | l01=Line(p0,p1) |

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

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

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

1559 | l12_3=Line(p1,p2) |

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

1561 | |

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

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

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

1565 | |

1566 | self.failUnlessRaises(TypeError,ValueError,RuledSurface,l01,msg="non CurveLoop argument accepted.") |

1567 | |

1568 | s=RuledSurface(cl1) |

1569 | |

1570 | cl=s.getBoundaryLoop() |

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

1572 | |

1573 | h=s.getHoles() |

1574 | self.failUnless(len(h) == 0, "too many holes.") |

1575 | |

1576 | crvs=s.getBoundary() |

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

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

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

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

1581 | |

1582 | |

1583 | code=s.getGmshCommand() |

1584 | self.failUnless(code == "Ruled Surface(17) = {14};", "gmsh command wrong.") |

1585 | |

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

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

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

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

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

1591 | |

1592 | s.setLocalScale(3.) |

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

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

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

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

1597 | |

1598 | p=s.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1609 | |

1610 | sp=s.copy() |

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

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

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

1614 | cbl=sp.getBoundaryLoop() |

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

1616 | cp=sp.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1627 | del cp |

1628 | |

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

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

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

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

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

1634 | |

1635 | l01_m=Line(p0_m,p1_m) |

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

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

1638 | |

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

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

1641 | cbl=ds.getBoundaryLoop() |

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

1643 | cp=ds.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1654 | |

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

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

1657 | |

1658 | p=s.getPrimitives() |

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

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

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

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

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

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

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

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

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

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

1669 | |

1670 | def test_PlaneSurface(self): |

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

1672 | p1=Point(10,0,0,0.2) |

1673 | p2=Point(10,10,0,0.3) |

1674 | p3=Point(0,10,3,0.4) |

1675 | p4=Point(5,5,0,0.001) |

1676 | p5=Point(7,5,0,0.001) |

1677 | p6=Point(5,7,0,0.001) |

1678 | p7=Point(8,8,0,0.001) |

1679 | p8=Point(9,9,0,0.001) |

1680 | |

1681 | l0=Line(p0,p1) |

1682 | l1=Line(p1,p2) |

1683 | l2=Line(p2,p3) |

1684 | l3=Line(p3,p0) |

1685 | |

1686 | l9=Line(p1,p8) |

1687 | l10=Line(p8,p3) |

1688 | |

1689 | l4=Line(p4,p5) |

1690 | l5=Line(p5,p6) |

1691 | l6=Line(p6,p4) |

1692 | l7=Line(p6,p7) |

1693 | l8=Line(p7,p4) |

1694 | |

1695 | a1=Arc(p4,p3,p1) |

1696 | a2=Arc(p7,p5,p6) |

1697 | |

1698 | cl=CurveLoop(l0,l1,l2,l3) |

1699 | h=CurveLoop(l4,l5,l6) |

1700 | cl_s=CurveLoop(l0,l9,l10,l3) |

1701 | h2=CurveLoop(l4,l5,l7,l8) |

1702 | cl_a=CurveLoop(a1,l1,l2) |

1703 | h_a=CurveLoop(a2,l6,l4) |

1704 | |

1705 | self.failUnlessRaises(TypeError,ValueError,PlaneSurface,l4,msg="non CurveLoop argument accepted.") |

1706 | self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl_a,h,msg="CurveLoop with no line curves accepted.") |

1707 | self.failUnlessRaises(TypeError,ValueError,PlaneSurface,cl,[h_a],msg="CurveLoop with no line curves as holes accepted.") |

1708 | |

1709 | s=PlaneSurface(cl,holes=[h]) |

1710 | |

1711 | cl=s.getBoundaryLoop() |

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

1713 | |

1714 | hs=s.getHoles() |

1715 | self.failUnless(len(hs) == 1, "one holes expected.") |

1716 | self.failUnless(h in hs, "h is not defined as hole.") |

1717 | |

1718 | crvs=s.getBoundary() |

1719 | self.failUnless(len(crvs) == 7, "too many boundary corves.") |

1720 | self.failUnless(l0 in crvs, "l0 is missing in boundary") |

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

1722 | self.failUnless(l2 in crvs, "l2 is missing in boundary") |

1723 | self.failUnless(l3 in crvs, "l3 is missing in boundary") |

1724 | self.failUnless(l4 in crvs, "l4 is missing in boundary") |

1725 | self.failUnless(l5 in crvs, "l5 is missing in boundary") |

1726 | self.failUnless(l6 in crvs, "l6 is missing in boundary") |

1727 | |

1728 | code=s.getGmshCommand() |

1729 | self.failUnless(code == "Plane Surface(29) = {23, 24};", "gmsh command wrong.") |

1730 | |

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

1732 | self.failUnless(s.isColocated(s),"PlaneSurface is not colocated with its self.") |

1733 | self.failUnless(s.isColocated(PlaneSurface(cl,holes=[h])),"PlaneSurface is not colocated with its copy.") |

1734 | self.failUnless(not s.isColocated(PlaneSurface(cl)),"PlaneSurface is colocated with PlaneSurface with same boundary but no hole") |

1735 | self.failUnless(not s.isColocated(PlaneSurface(cl_s,holes=[h])),"PlaneSurface is colocated with PlaneSurface with deformed boundary") |

1736 | self.failUnless(not s.isColocated(PlaneSurface(cl,holes=[h2])),"PlaneSurface is colocated with modified hole") |

1737 | |

1738 | s.setLocalScale(3.) |

1739 | self.failUnless(p0. |