Parent Directory | Revision Log

Revision **933** -
(**show annotations**)

*Mon Jan 22 07:20:25 2007 UTC*
(16 years, 2 months ago)
by *gross*

File MIME type: text/x-python

File size: 182186 byte(s)

File MIME type: text/x-python

File size: 182186 byte(s)

test for generation of gmsh script added

1 | # $Id: run_visualization_interface.py 798 2006-08-04 01:05:36Z gross $ |

2 | |

3 | __copyright__=""" Copyright (c) 2006 by ACcESS MNRF |

4 | http://www.access.edu.au |

5 | Primary Business: Queensland, Australia""" |

6 | __license__="""Licensed under the Open Software License version 3.0 |

7 | http://www.opensource.org/licenses/osl-3.0.php""" |

8 | |

9 | import os |

10 | import sys |

11 | import unittest |

12 | import math |

13 | import numarray |

14 | from esys.pycad import * |

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

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

17 | |

18 | try: |

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

20 | except KeyError: |

21 | PYCAD_TEST_DATA='.' |

22 | |

23 | try: |

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

25 | except KeyError: |

26 | PYCAD_WORKDIR='.' |

27 | |

28 | PYCAD_TEST_MESH_PATH=PYCAD_TEST_DATA+os.sep+"data_meshes"+os.sep |

29 | PYCAD_WORKDIR_PATH=PYCAD_WORKDIR+os.sep |

30 | |

31 | def _cross(x, y): |

32 | return numarray.array([x[1] * y[2] - x[2] * y[1], x[2] * y[0] - x[0] * y[2], x[0] * y[1] - x[1] * y[0]]) |

33 | |

34 | |

35 | class Test_PyCAD_Transformations(unittest.TestCase): |

36 | ABS_TOL=1.e-8 |

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

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

39 | def test_Translation_x(self): |

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

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

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

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

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

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

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

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

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

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

50 | def test_Translation_y(self): |

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

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

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

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

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

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

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

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

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

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

61 | def test_Translation_z(self): |

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

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

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

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

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

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

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

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

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

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

72 | def test_Dilation_0_two(self): |

73 | t=Dilation(2.) |

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

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

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

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

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

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

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

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

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

83 | def test_Dilation_0_half(self): |

84 | t=Dilation(0.5) |

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

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

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

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

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

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

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

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

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

94 | def test_Dilation_x_two(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

108 | def test_Dilation_x_half(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

122 | def test_Dilation_y_two(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

136 | def test_Dilation_y_half(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

150 | def test_Dilation_z_two(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

164 | def test_Dilation_z_half(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

178 | def test_Reflection_x_offset0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

192 | def test_Reflection_x_offset2(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

206 | def test_Reflection_x_offset2_vector(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

220 | def test_Reflection_y_offset0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

234 | def test_Reflection_y_offset2(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

248 | def test_Reflection_y_offset2_vector(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

262 | def test_Reflection_z_offset0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

276 | def test_Reflection_z_offset2(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

290 | def test_Reflection_z_offset2_vector(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

304 | def test_Rotatation_x_90_0(self): |

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

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

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

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

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

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

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

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

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

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

315 | def test_Rotatation_x_30_0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

330 | def test_Rotatation_x_330_0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

345 | def test_Rotatation_x_90(self): |

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

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

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

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

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

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

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

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

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

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

356 | def test_Rotatation_x_30(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

371 | def test_Rotatation_x_330(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

386 | def test_Rotatation_y_90_0(self): |

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

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

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

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

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

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

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

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

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

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

397 | def test_Rotatation_y_30_0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

412 | def test_Rotatation_y_330_0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

427 | def test_Rotatation_y_90(self): |

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

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

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

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

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

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

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

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

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

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

438 | def test_Rotatation_y_30(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

453 | def test_Rotatation_y_330(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

468 | def test_Rotatation_z_90_0(self): |

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

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

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

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

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

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

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

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

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

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

479 | def test_Rotatation_z_30_0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

494 | def test_Rotatation_z_330_0(self): |

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

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

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

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

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

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

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

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

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

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

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

506 | def test_Rotatation_z_90(self): |

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

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

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

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

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

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

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

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

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

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

517 | def test_Rotatation_z_30(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

532 | def test_Rotatation_z_330(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

547 | def test_Rotatation_x_90_1(self): |

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

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

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

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

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

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

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

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

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

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

558 | def test_Rotatation_y_90_1(self): |

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

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

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

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

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

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

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

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

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

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

569 | def test_Rotatation_z_90_1(self): |

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

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

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

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

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

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

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

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

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

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

580 | def test_Rotatation_diag_90_0(self): |

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

600 | |

601 | class Test_PyCAD_Primitives(unittest.TestCase): |

602 | def setUp(self): |

603 | resetGlobalPrimitiveIdCounter() |

604 | |

605 | def test_Primitive(self): |

606 | p=Primitive() |

607 | |

608 | id=p.getID() |

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

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

611 | |

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

613 | |

614 | def test_ReversePrimitive(self): |

615 | p=Primitive() |

616 | |

617 | rp=ReversePrimitive(p) |

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

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

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

621 | |

622 | def test_Point(self): |

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

624 | |

625 | id=p.getID() |

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

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

628 | |

629 | # check reverse point |

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

631 | |

632 | # check history: |

633 | hs=p.getPrimitives() |

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

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

636 | |

637 | # check incolved points: |

638 | ps=p.getConstructionPoints() |

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

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

641 | |

642 | # check coordinates: |

643 | c=p.getCoordinates() |

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

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

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

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

648 | |

649 | # reset coordinates: |

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

651 | c=p.getCoordinates() |

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

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

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

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

656 | |

657 | # check for a colocated point: |

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

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

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

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

662 | |

663 | # check for local length scale |

664 | l=p.getLocalScale() |

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

666 | |

667 | # check for new local length scale |

668 | p.setLocalScale(3.) |

669 | l=p.getLocalScale() |

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

671 | |

672 | # negative value shouldn't work. |

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

674 | |

675 | # copy: |

676 | an_other_p=p.copy() |

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

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

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

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

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

682 | |

683 | # modify by Transformation: |

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

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

686 | |

687 | # apply Transformation: |

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

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

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

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

692 | |

693 | # overloaded add: |

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

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

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

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

698 | |

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

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

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

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

703 | # overloaded minus |

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

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

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

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

708 | |

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

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

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

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

713 | # overloaded inplace add: |

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

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

716 | |

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

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

719 | |

720 | # overloaded inplace add: |

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

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

723 | |

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

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

726 | |

727 | #overloaded multiplication: |

728 | mult_p=2*p |

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

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

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

732 | |

733 | mult_p=2.*p |

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

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

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

737 | |

738 | mult_p=Dilation(2)*p |

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

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

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

742 | |

743 | #overloaded inplace multiplication: |

744 | p*=2 |

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

746 | |

747 | p*=2. |

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

749 | |

750 | p*=Dilation(2) |

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

752 | |

753 | # get gmsh code |

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

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

756 | |

757 | def test_Spline(self): |

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

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

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

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

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

763 | |

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

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

766 | |

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

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

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

770 | |

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

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

773 | |

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

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

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

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

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

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

780 | |

781 | co=c.getControlPoints() |

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

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

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

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

786 | |

787 | c.setLocalScale(3.) |

788 | co=c.getControlPoints() |

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

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

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

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

793 | |

794 | code=c.getGmshCommand() |

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

796 | |

797 | h=c.getPrimitives() |

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

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

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

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

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

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

804 | |

805 | cp=c.copy() |

806 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

813 | |

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

815 | cp=c.getControlPoints() |

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

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

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

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

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

821 | |

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

823 | dccp=dc.getControlPoints() |

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

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

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

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

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

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

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

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

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

833 | |

834 | def test_ReverseSpline(self): |

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

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

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

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

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

840 | |

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

842 | c=-CC0 |

843 | |

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

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

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

847 | |

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

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

850 | |

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

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

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

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

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

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

857 | |

858 | co=c.getControlPoints() |

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

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

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

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

863 | |

864 | c.setLocalScale(3.) |

865 | co=c.getControlPoints() |

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

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

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

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

870 | |

871 | code=c.getGmshCommand() |

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

873 | |

874 | h=c.getPrimitives() |

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

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

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

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

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

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

881 | |

882 | cp=c.copy() |

883 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

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

891 | |

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

893 | cp=c.getControlPoints() |

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

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

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

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

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

899 | |

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

901 | dccp=dc.getControlPoints() |

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

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

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

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

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

907 | |

908 | def test_BezierCurve(self): |

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

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

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

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

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

914 | |

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

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

917 | |

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

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

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

921 | |

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

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

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

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

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

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

928 | |

929 | co=c.getControlPoints() |

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

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

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

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

934 | |

935 | c.setLocalScale(3.) |

936 | co=c.getControlPoints() |

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

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

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

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

941 | |

942 | code=c.getGmshCommand() |

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

944 | |

945 | h=c.getPrimitives() |

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

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

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

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

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

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

952 | |

953 | cp=c.copy() |

954 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

961 | |

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

963 | cp=c.getControlPoints() |

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

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

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

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

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

969 | |

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

971 | dccp=dc.getControlPoints() |

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

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

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

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

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

977 | |

978 | def test_BSpline(self): |

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

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

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

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

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

984 | |

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

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

987 | |

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

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

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

991 | |

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

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

994 | |

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

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

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

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

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

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

1001 | |

1002 | co=c.getControlPoints() |

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

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

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

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

1007 | |

1008 | c.setLocalScale(3.) |

1009 | co=c.getControlPoints() |

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

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

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

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

1014 | |

1015 | code=c.getGmshCommand() |

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

1017 | |

1018 | h=c.getPrimitives() |

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

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

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

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

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

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

1025 | |

1026 | cp=c.copy() |

1027 | cpcp=cp.getControlPoints() |

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

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

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

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

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

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

1034 | |

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

1036 | cp=c.getControlPoints() |

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

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

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

1040 | self.failUnless(p2 == cp[2],"3rd new point after Dilation.") |

1041 | self.failUnless(p3 == cp[3],"4th new point after Dilation.") |

1042 | |

1043 | dc=c.apply(Dilation(-1.)) |

1044 | dccp=dc.getControlPoints() |

1045 | self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |

1046 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

1047 | self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.") |

1048 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |

1049 | self.failUnless(dccp[1].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.") |

1050 | self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") |

1051 | self.failUnless(dccp[2].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.") |

1052 | self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") |

1053 | self.failUnless(dccp[3].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.") |

1054 | |

1055 | def test_ReverseBSpline(self): |

1056 | p0=Point(0,0,0,0.1) |

1057 | p1=Point(1,1,1,0.2) |

1058 | p2=Point(2,2,2,0.3) |

1059 | p3=Point(3,3,3,0.4) |

1060 | p4=Point(1,2,3) |

1061 | |

1062 | CC0=BSpline(p0,p1,p2,p3) |

1063 | c=-CC0 |

1064 | |

1065 | self.failUnless(len(c) == 4, "wrong spline curve length") |

1066 | self.failUnless(c.getStartPoint()==p3, "wrong start point of spline curve") |

1067 | self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve") |

1068 | |

1069 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1070 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1071 | |

1072 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

1073 | self.failUnless(not c.isColocated(BSpline(p0,p1,p2)),"spline is colocated with spline of different length.") |

1074 | self.failUnless(not c.isColocated(BSpline(p0,p1,p4,p3)),"spline is colocated with spline with different point.") |

1075 | self.failUnless(c.isColocated(BSpline(p0,p1,p2,p3)),"spline is not colocated with spline with same points.") |

1076 | self.failUnless(c.isColocated(BSpline(p3,p2,p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1077 | self.failUnless(not c.isColocated(Curve(p0,p1,p2,p3)),"spline curve is identified with curve.") |

1078 | |

1079 | co=c.getControlPoints() |

1080 | self.failUnless(co[0]==p3, "1st control point is wrong.") |

1081 | self.failUnless(co[1]==p2, "2nd control point is wrong.") |

1082 | self.failUnless(co[2]==p1, "3rd control point is wrong.") |

1083 | self.failUnless(co[3]==p0, "4th control point is wrong.") |

1084 | |

1085 | c.setLocalScale(3.) |

1086 | co=c.getControlPoints() |

1087 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

1088 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

1089 | self.failUnless(co[2].getLocalScale() == 3., "new local scale of 3rd control point is wrong.") |

1090 | self.failUnless(co[3].getLocalScale() == 3., "new local scale of 4th control point is wrong.") |

1091 | |

1092 | code=c.getGmshCommand() |

1093 | self.failUnless(code == "BSpline(6) = {1, 2, 3, 4};", "gmsh command wrong.") |

1094 | |

1095 | h=c.getPrimitives() |

1096 | self.failUnless(len(h) == 5, "number of primitives in history is wrong.") |

1097 | self.failUnless(p0 in h, "missing p0 in history.") |

1098 | self.failUnless(p1 in h, "missing p1 in history.") |

1099 | self.failUnless(p2 in h, "missing p2 in history.") |

1100 | self.failUnless(p3 in h, "missing p3 in history.") |

1101 | self.failUnless(CC0 in h, "missing spline curve in history.") |

1102 | |

1103 | cp=c.copy() |

1104 | cpcp=cp.getControlPoints() |

1105 | self.failUnless(not cp == c, "copy returns same spline curve.") |

1106 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

1107 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

1108 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

1109 | self.failUnless(not p2 == cpcp[2],"3st point of deep copy and source are the same.") |

1110 | self.failUnless(not p3 == cpcp[3],"4st point of deep copy and source are the same.") |

1111 | |

1112 | c.modifyBy(Dilation(-1.)) |

1113 | cp=c.getControlPoints() |

1114 | 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.") |

1115 | self.failUnless(p3 == cp[0],"1st new point after Dilation.") |

1116 | self.failUnless(p2 == cp[1],"2nd new point after Dilation.") |

1117 | self.failUnless(p1 == cp[2],"3rd new point after Dilation.") |

1118 | self.failUnless(p0 == cp[3],"4th new point after Dilation.") |

1119 | |

1120 | dc=c.apply(Dilation(-1.)) |

1121 | dccp=dc.getControlPoints() |

1122 | self.failUnless(dc.isColocated(BSpline(Point(0,0,0),Point(1,1,1),Point(2,2,2),Point(3,3,3))),"dilation is wrong.") |

1123 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

1124 | self.failUnless(dccp[0].isColocated(Point(3,3,3)),"1st point of Dilation is is wrongly located.") |

1125 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |

1126 | self.failUnless(dccp[1].isColocated(Point(2,2,2)),"1st point of Dilation is is wrongly located.") |

1127 | self.failUnless(not p2 == dccp[2],"3rd point of Dilation is identical to source.") |

1128 | self.failUnless(dccp[2].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.") |

1129 | self.failUnless(not p3 == dccp[3],"4th point of Dilation is identical to source.") |

1130 | self.failUnless(dccp[3].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.") |

1131 | |

1132 | def test_LineSegment(self): |

1133 | p0=Point(0,0,0,0.1) |

1134 | p1=Point(1,1,1,0.2) |

1135 | p4=Point(1,2,3) |

1136 | |

1137 | self.failUnlessRaises(TypeError,Line,p0) |

1138 | self.failUnlessRaises(TypeError,Line,p0,p1,p4) |

1139 | |

1140 | c=Line(p0,p1) |

1141 | |

1142 | self.failUnless(len(c) == 2, "wrong spline curve length") |

1143 | self.failUnless(c.getStartPoint()==p0, "wrong start point of spline curve") |

1144 | self.failUnless(c.getEndPoint()==p1, "wrong end point of spline curve") |

1145 | |

1146 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1147 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1148 | |

1149 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

1150 | self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.") |

1151 | self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.") |

1152 | self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1153 | self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.") |

1154 | |

1155 | co=c.getControlPoints() |

1156 | self.failUnless(co[0]==p0, "1st control point is wrong.") |

1157 | self.failUnless(co[1]==p1, "2nd control point is wrong.") |

1158 | |

1159 | c.setLocalScale(3.) |

1160 | co=c.getControlPoints() |

1161 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

1162 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

1163 | |

1164 | code=c.getGmshCommand() |

1165 | self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") |

1166 | |

1167 | h=c.getPrimitives() |

1168 | self.failUnless(len(h) == 3, "number of primitives in history is wrong.") |

1169 | self.failUnless(p0 in h, "missing p0 in history.") |

1170 | self.failUnless(p1 in h, "missing p1 in history.") |

1171 | self.failUnless(c in h, "missing spline curve in history.") |

1172 | |

1173 | cp=c.copy() |

1174 | cpcp=cp.getControlPoints() |

1175 | self.failUnless(not cp == c, "copy returns same spline curve.") |

1176 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

1177 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

1178 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

1179 | |

1180 | c.modifyBy(Dilation(-1.)) |

1181 | cp=c.getControlPoints() |

1182 | self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") |

1183 | self.failUnless(p0 == cp[0],"1st new point after Dilation.") |

1184 | self.failUnless(p1 == cp[1],"2nd new point after Dilation.") |

1185 | |

1186 | dc=c.apply(Dilation(-1.)) |

1187 | dccp=dc.getControlPoints() |

1188 | self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") |

1189 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

1190 | self.failUnless(dccp[0].isColocated(Point(0,0,0)),"1st point of Dilation is is wrongly located.") |

1191 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |

1192 | self.failUnless(dccp[1].isColocated(Point(1,1,1)),"2st point of Dilation is is wrongly located.") |

1193 | |

1194 | def test_ReverseLineSegment(self): |

1195 | p0=Point(0,0,0,0.1) |

1196 | p1=Point(1,1,1,0.2) |

1197 | p4=Point(1,2,3) |

1198 | |

1199 | self.failUnlessRaises(TypeError,Line,p0) |

1200 | self.failUnlessRaises(TypeError,Line,p0,p1,p4) |

1201 | |

1202 | CC0=Line(p0,p1) |

1203 | c=-CC0 |

1204 | |

1205 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1206 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1207 | |

1208 | self.failUnless(len(c) == 2, "wrong spline curve length") |

1209 | self.failUnless(c.getStartPoint()==p1, "wrong start point of spline curve") |

1210 | self.failUnless(c.getEndPoint()==p0, "wrong end point of spline curve") |

1211 | |

1212 | self.failUnless(not c.isColocated(p1),"spline is colocated with point.") |

1213 | self.failUnless(not c.isColocated(Line(p0,p4)),"spline is colocated with spline with different point.") |

1214 | self.failUnless(c.isColocated(Line(p0,p1)),"spline is not colocated with spline with same points.") |

1215 | self.failUnless(c.isColocated(Line(p1,p0)),"spline is not colocated with spline with same points but opposite direction.") |

1216 | self.failUnless(not c.isColocated(Curve(p0,p1,p4)),"spline curve is identified with curve.") |

1217 | |

1218 | co=c.getControlPoints() |

1219 | self.failUnless(co[0]==p1, "1st control point is wrong.") |

1220 | self.failUnless(co[1]==p0, "2nd control point is wrong.") |

1221 | |

1222 | c.setLocalScale(3.) |

1223 | co=c.getControlPoints() |

1224 | self.failUnless(co[0].getLocalScale() == 3., "new local scale of 1st control point is wrong.") |

1225 | self.failUnless(co[1].getLocalScale() == 3., "new local scale of 2nd control point is wrong.") |

1226 | |

1227 | code=c.getGmshCommand() |

1228 | self.failUnless(code == "Line(4) = {1, 2};", "gmsh command wrong.") |

1229 | |

1230 | h=c.getPrimitives() |

1231 | self.failUnless(len(h) == 3, "number of primitives in history is wrong.") |

1232 | self.failUnless(p0 in h, "missing p0 in history.") |

1233 | self.failUnless(p1 in h, "missing p1 in history.") |

1234 | self.failUnless(CC0 in h, "missing spline curve in history.") |

1235 | |

1236 | cp=c.copy() |

1237 | cpcp=cp.getControlPoints() |

1238 | self.failUnless(not cp == c, "copy returns same spline curve.") |

1239 | self.failUnless(c.isColocated(cp),"spline curve is not colocated with its copy.") |

1240 | self.failUnless(not p0 == cpcp[0],"1st point of deep copy and source are the same.") |

1241 | self.failUnless(not p1 == cpcp[1],"2st point of deep copy and source are the same.") |

1242 | |

1243 | c.modifyBy(Dilation(-1.)) |

1244 | cp=c.getControlPoints() |

1245 | self.failUnless(c.isColocated(Line(Point(0,0,0),Point(-1,-1,-1))),"inplace dilation is wrong.") |

1246 | self.failUnless(p1 == cp[0],"1st new point after Dilation.") |

1247 | self.failUnless(p0 == cp[1],"2nd new point after Dilation.") |

1248 | |

1249 | dc=c.apply(Dilation(-1.)) |

1250 | dccp=dc.getControlPoints() |

1251 | self.failUnless(dc.isColocated(Line(Point(0,0,0),Point(1,1,1))),"dilation is wrong.") |

1252 | self.failUnless(not p0 == dccp[0],"1st point of Dilation is identical to source.") |

1253 | self.failUnless(dccp[0].isColocated(Point(1,1,1)),"1st point of Dilation is is wrongly located.") |

1254 | self.failUnless(not p1 == dccp[1],"2nd point of Dilation is identical to source.") |

1255 | self.failUnless(dccp[1].isColocated(Point(0,0,0)),"2st point of Dilation is is wrongly located.") |

1256 | |

1257 | def test_Arc(self): |

1258 | center=Point(0,0,0,0.1) |

1259 | p_start=Point(1,1,1,0.2) |

1260 | p_end=Point(1,2,3) |

1261 | p4=Point(10,2,3) |

1262 | |

1263 | self.failUnlessRaises(TypeError,Arc,Primitive()) |

1264 | |

1265 | c=Arc(center,p_start,p_end) |

1266 | |

1267 | self.failUnless(c.getCenterPoint()==center, "wrong center point") |

1268 | self.failUnless(c.getStartPoint()==p_start, "wrong start point") |

1269 | self.failUnless(c.getEndPoint()==p_end, "wrong end point") |

1270 | |

1271 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1272 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1273 | |

1274 | code=c.getGmshCommand() |

1275 | self.failUnless(code == "Circle(6) = {2, 1, 3};", "gmsh command wrong.") |

1276 | |

1277 | self.failUnless(not c.isColocated(p4),"spline is colocated with point.") |

1278 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") |

1279 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") |

1280 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") |

1281 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") |

1282 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") |

1283 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") |

1284 | |

1285 | h=c.getPrimitives() |

1286 | self.failUnless(len(h) == 4, "number of primitives in history is wrong.") |

1287 | self.failUnless(center in h, "missing center in history.") |

1288 | self.failUnless(p_start in h, "missing p_start in history.") |

1289 | self.failUnless(p_end in h, "missing p_end in history.") |

1290 | self.failUnless(c in h, "missing spline curve in history.") |

1291 | |

1292 | |

1293 | c.setLocalScale(3.) |

1294 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") |

1295 | self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") |

1296 | self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") |

1297 | |

1298 | cp=c.copy() |

1299 | self.failUnless(isinstance(cp,Arc), "copy returns is not an arc.") |

1300 | self.failUnless(not cp == c, "copy returns same arc.") |

1301 | self.failUnless(cp.isColocated(Arc(center,p_start,p_end)),"arc is not colocated with its copy.") |

1302 | self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source") |

1303 | self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source") |

1304 | self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source") |

1305 | |

1306 | c.modifyBy(Dilation(-1.)) |

1307 | self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.") |

1308 | self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.") |

1309 | self.failUnless(c.getStartPoint() == p_start,"wrong start point after dilation.") |

1310 | self.failUnless(c.getEndPoint() == p_end,"wrong end point after dilation.") |

1311 | |

1312 | dc=c.apply(Dilation(-1.)) |

1313 | self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.") |

1314 | self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.") |

1315 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |

1316 | self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.") |

1317 | self.failUnless(dc.getStartPoint().isColocated(Point(1,1,1)),"start point of dilation is wrong.") |

1318 | self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.") |

1319 | self.failUnless(dc.getEndPoint().isColocated(Point(1,2,3)),"end point of dilation is wrong.") |

1320 | |

1321 | def test_ReverseArc(self): |

1322 | center=Point(0,0,0,0.1) |

1323 | p_start=Point(1,1,1,0.2) |

1324 | p_end=Point(1,2,3) |

1325 | p4=Point(10,2,3) |

1326 | |

1327 | self.failUnlessRaises(TypeError,Arc,Primitive()) |

1328 | |

1329 | CC0=Arc(center,p_start,p_end) |

1330 | c=-CC0 |

1331 | |

1332 | self.failUnless(c.getCenterPoint()==center, "wrong center point") |

1333 | self.failUnless(c.getStartPoint()==p_end, "wrong start point") |

1334 | self.failUnless(c.getEndPoint()==p_start, "wrong end point") |

1335 | |

1336 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1337 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1338 | |

1339 | code=c.getGmshCommand() |

1340 | self.failUnless(code == "Circle(6) = {2, 1, 3};", "gmsh command wrong.") |

1341 | |

1342 | self.failUnless(not c.isColocated(p4),"spline is colocated with point.") |

1343 | self.failUnless(not c.isColocated(Arc(p4,p_start,p_end)),"spline is colocated with spline with differnt center point.") |

1344 | self.failUnless(not c.isColocated(Arc(center,p4,p_end)),"spline is colocated with spline with differnt start point.") |

1345 | self.failUnless(not c.isColocated(Arc(center,p_start,p4)),"spline is colocated with spline with differnt end point.") |

1346 | self.failUnless(c.isColocated(Arc(center,p_start,p_end)),"spline is not colocated with spline with same points.") |

1347 | self.failUnless(c.isColocated(Arc(center,p_end,p_start)),"spline is not colocated with spline with same points but opposite direction.") |

1348 | self.failUnless(not c.isColocated(Curve(center,p_start,p_end)),"spline curve is identified with curve.") |

1349 | |

1350 | h=c.getPrimitives() |

1351 | self.failUnless(len(h) == 4, "number of primitives in history is wrong.") |

1352 | self.failUnless(center in h, "missing center in history.") |

1353 | self.failUnless(p_start in h, "missing p_start in history.") |

1354 | self.failUnless(p_end in h, "missing p_end in history.") |

1355 | self.failUnless(CC0 in h, "missing spline curve in history.") |

1356 | |

1357 | |

1358 | c.setLocalScale(3.) |

1359 | self.failUnless(c.getCenterPoint().getLocalScale() == 3., "new local scale of center point is wrong.") |

1360 | self.failUnless(c.getStartPoint().getLocalScale() == 3., "new local scale of start point is wrong.") |

1361 | self.failUnless(c.getEndPoint().getLocalScale() == 3., "new local scale of end point is wrong.") |

1362 | |

1363 | cp=c.copy() |

1364 | self.failUnless(isinstance(cp,ReverseArc), "copy returns is not an arc.") |

1365 | self.failUnless(not cp == c, "copy returns same arc.") |

1366 | self.failUnless(cp.isColocated(Arc(center,p_end,p_start)),"arc is not colocated with its copy.") |

1367 | self.failUnless(not cp.getCenterPoint()==center, "deep copy has same center point like source") |

1368 | self.failUnless(not cp.getStartPoint()==p_start, "deep copy has same start point like source") |

1369 | self.failUnless(not cp.getEndPoint()==p_end, "deep copy has same end point like source") |

1370 | |

1371 | c.modifyBy(Dilation(-1.)) |

1372 | self.failUnless(c.isColocated(Arc(Point(0,0,0),Point(-1,-1,-1),Point(-1,-2,-3))),"inplace dilation is wrong.") |

1373 | self.failUnless(c.getCenterPoint() == center,"wrong center point after dilation.") |

1374 | self.failUnless(c.getStartPoint() == p_end,"wrong start point after dilation.") |

1375 | self.failUnless(c.getEndPoint() == p_start,"wrong end point after dilation.") |

1376 | |

1377 | dc=c.apply(Dilation(-1.)) |

1378 | self.failUnless(dc.isColocated(Arc(Point(0,0,0),Point(1,1,1),Point(1,2,3))),"dilation is wrong.") |

1379 | self.failUnless(not dc.getCenterPoint() == center,"center point of dilation is identical to source.") |

1380 | self.failUnless(dc.getCenterPoint().isColocated(Point(0,0,0)),"center point of dilation is wrong.") |

1381 | self.failUnless(not dc.getStartPoint() == p_start,"start point of dilation is identical to source.") |

1382 | self.failUnless(dc.getStartPoint().isColocated(Point(1,2,3)),"start point of dilation is wrong.") |

1383 | self.failUnless(not dc.getEndPoint() == p_end,"end point of dilation is identical to source.") |

1384 | self.failUnless(dc.getEndPoint().isColocated(Point(1,1,1)),"end point of dilation is wrong.") |

1385 | |

1386 | def test_CurveLoop(self): |

1387 | p0=Point(0,0,0,0.1) |

1388 | p1=Point(1,1,1,0.2) |

1389 | p2=Point(2,2,2,0.3) |

1390 | p3=Point(3,3,3,0.4) |

1391 | p4=Point(1,2,3) |

1392 | p5=Point(10,20,3) |

1393 | p6=Point(1,2,30) |

1394 | |

1395 | l01=Line(p0,p1) |

1396 | l12=Arc(p3,p1,p2) |

1397 | l20=Spline(p2,p4,p0) |

1398 | |

1399 | lx=Line(p2,p3) |

1400 | ly=Line(p3,p1) |

1401 | |

1402 | c=CurveLoop(l01,l12,l20) |

1403 | # self.failUnlessRaises(ValueError,CurveLoop,l01,lx,l20) |

1404 | # self.failUnlessRaises(ValueError,CurveLoop,l01,l20,l20) |

1405 | # self.failUnlessRaises(ValueError,CurveLoop,l01,l20,ly) |

1406 | |

1407 | c=CurveLoop(l01,l20,l12) |

1408 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1409 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1410 | |

1411 | code=c.getGmshCommand() |

1412 | self.failUnless(code == "Line Loop(14) = {8, 10, 9};", "gmsh command wrong.") |

1413 | |

1414 | self.failUnless(not c.isColocated(p4),"CurveLoop is colocated with point.") |

1415 | self.failUnless(c.isColocated(c),"CurveLoop is not colocated with its self.") |

1416 | self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"CurveLoop is not colocated with its copy.") |

1417 | self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"CurveLoop is not colocated with its copy with shifted points.") |

1418 | self.failUnless(c.isColocated(CurveLoop(l20,l12,l01)),"CurveLoop is not colocated with its copy with shuffled points.") |

1419 | self.failUnless(not c.isColocated(CurveLoop(lx,ly,l12)),"CurveLoop is colocated with different CurveLoop.") |

1420 | |

1421 | self.failUnless(len(c) == 3, "wrong length") |

1422 | |

1423 | c.setLocalScale(3.) |

1424 | self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.") |

1425 | self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.") |

1426 | self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.") |

1427 | self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.") |

1428 | |

1429 | |

1430 | cc=c.getCurves() |

1431 | self.failUnless(len(cc) == 3, "too many curves.") |

1432 | self.failUnless(l01 in cc, "l01 is missing") |

1433 | self.failUnless(l12 in cc, "l12 is missing") |

1434 | self.failUnless(l20 in cc, "l20 is missing") |

1435 | |

1436 | p=c.getPrimitives() |

1437 | self.failUnless(len(p) == 9, "too many primitives.") |

1438 | self.failUnless(l01 in p, "l01 is missing") |

1439 | self.failUnless(l12 in p, "l21 is missing") |

1440 | self.failUnless(l20 in p, "l20 is missing") |

1441 | self.failUnless(p0 in p, "p0 is missing") |

1442 | self.failUnless(p1 in p, "p1 is missing") |

1443 | self.failUnless(p2 in p, "p2 is missing") |

1444 | self.failUnless(p3 in p, "p3 is missing") |

1445 | self.failUnless(p4 in p, "p4 is missing") |

1446 | |

1447 | cp=c.copy() |

1448 | self.failUnless(isinstance(cp,CurveLoop), "copy returns is not an arc.") |

1449 | self.failUnless(not cp == c, "copy equals source") |

1450 | self.failUnless(cp.isColocated(c),"copy is not colocated with its source.") |

1451 | cc=cp.getCurves() |

1452 | self.failUnless(len(cc) == 3, "too many primitives in copy.") |

1453 | self.failUnless(not l01 in cc,"copy uses l01.") |

1454 | self.failUnless(not l12 in cc,"copy uses l12.") |

1455 | self.failUnless(not l20 in cc,"copy uses l20.") |

1456 | |

1457 | p0_m=Point(0,0,0) |

1458 | p1_m=Point(-1,-1,-1) |

1459 | p2_m=Point(-2,-2,-2) |

1460 | p3_m=Point(-3,-3,-3) |

1461 | p4_m=Point(-1,-2,-3) |

1462 | |

1463 | l01_m=Line(p0_m,p1_m) |

1464 | l12_m=Arc(p3_m,p1_m,p2_m) |

1465 | l20_m=Spline(p2_m,p4_m,p0_m) |

1466 | |

1467 | dc=c.apply(Dilation(-1.)) |

1468 | self.failUnless(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.") |

1469 | cc=dc.getCurves() |

1470 | self.failUnless(len(cc) == 3, "too many primitives in dilation result.") |

1471 | self.failUnless(not l01 in cc,"l01 is in dilation result.") |

1472 | self.failUnless(not l12 in cc,"l12 is in dilation result.") |

1473 | self.failUnless(not l20 in cc,"l20 is in dilation result.") |

1474 | |

1475 | c.modifyBy(Dilation(-1.)) |

1476 | self.failUnless(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.") |

1477 | cc=c.getCurves() |

1478 | self.failUnless(len(cc) == 3, "too many primitives in modified object.") |

1479 | self.failUnless(l01 in cc,"l01 missed in modified object.") |

1480 | self.failUnless(cc[cc.index(l01)].hasSameOrientation(l01),"l01 in modified object has wrong orientation.") |

1481 | self.failUnless(l12 in cc,"l12 missed in modified object.") |

1482 | self.failUnless(cc[cc.index(l12)].hasSameOrientation(l12),"l12 in modified object has wrong orientation.") |

1483 | self.failUnless(l20 in cc,"l20 missed in modified object.") |

1484 | self.failUnless(cc[cc.index(l20)].hasSameOrientation(l20),"l20 in modified object has wrong orientation.") |

1485 | |

1486 | def test_ReverseCurveLoop(self): |

1487 | p0=Point(0,0,0,0.1) |

1488 | p1=Point(1,1,1,0.2) |

1489 | p2=Point(2,2,2,0.3) |

1490 | p3=Point(3,3,3,0.4) |

1491 | p4=Point(1,2,3) |

1492 | p5=Point(10,20,3) |

1493 | p6=Point(1,2,30) |

1494 | |

1495 | l01=Line(p0,p1) |

1496 | l12=Arc(p3,p1,p2) |

1497 | l20=Spline(p2,p4,p0) |

1498 | |

1499 | lx=Line(p2,p3) |

1500 | ly=Line(p3,p1) |

1501 | |

1502 | CC0=CurveLoop(l01,l20,l12) |

1503 | c=-CC0 |

1504 | |

1505 | self.failUnless(c.hasSameOrientation(c),"has not same orientation like itself") |

1506 | self.failUnless(not c.hasSameOrientation(-c),"has same orientation like -itself") |

1507 | |

1508 | code=c.getGmshCommand() |

1509 | self.failUnless(code == "Line Loop(13) = {8, 10, 9};", "gmsh command wrong.") |

1510 | |

1511 | |

1512 | self.failUnless(not c.isColocated(p4),"-CurveLoop is colocated with point.") |

1513 | self.failUnless(c.isColocated(c),"-CurveLoop is not colocated with its self.") |

1514 | self.failUnless(c.isColocated(CurveLoop(l01,l12,l20)),"-CurveLoop is not colocated with its copy.") |

1515 | self.failUnless(c.isColocated(CurveLoop(l20,l01,l12)),"-CurveLoop is not colocated with its copy with shifted points.") |

1516 | self.failUnless(c.isColocated(CurveLoop(l20,l12,l01)),"-CurveLoop is not colocated with its copy with shuffled points.") |

1517 | self.failUnless(not c.isColocated(CurveLoop(lx,ly,l12)),"-CurveLoop is colocated with different CurveLoop.") |

1518 | |

1519 | self.failUnless(len(c) == 3, "wrong length") |

1520 | |

1521 | c.setLocalScale(3.) |

1522 | self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.") |

1523 | self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.") |

1524 | self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.") |

1525 | self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.") |

1526 | |

1527 | |

1528 | cc=c.getCurves() |

1529 | self.failUnless(len(cc) == 3, "too many curves.") |

1530 | self.failUnless(l01 in cc, "l01 is missing") |

1531 | self.failUnless(l12 in cc, "l12 is missing") |

1532 | self.failUnless(l20 in cc, "l20 is missing") |

1533 | |

1534 | p=c.getPrimitives() |

1535 | self.failUnless(len(p) == 9, "too many primitives.") |

1536 | self.failUnless(l01 in p, "l01 is missing") |

1537 | self.failUnless(l12 in p, "l21 is missing") |

1538 | self.failUnless(l20 in p, "l20 is missing") |

1539 | self.failUnless(p0 in p, "p0 is missing") |

1540 | self.failUnless(p1 in p, "p1 is missing") |

1541 | self.failUnless(p2 in p, "p2 is missing") |

1542 | self.failUnless(p3 in p, "p3 is missing") |

1543 | self.failUnless(p4 in p, "p4 is missing") |

1544 | |

1545 | cp=c.copy() |

1546 | self.failUnless(isinstance(cp,ReverseCurveLoop), "copy returns is not an ReverseCurveLoop.") |

1547 | self.failUnless(not cp == c, "copy equals source") |

1548 | self.failUnless(cp.isColocated(c),"copy is not colocated with its source.") |

1549 | cc=cp.getCurves() |

1550 | self.failUnless(len(cc) == 3, "too many primitives in copy.") |

1551 | self.failUnless(not l01 in cc,"copy uses l01.") |

1552 | self.failUnless(not l12 in cc,"copy uses l12.") |

1553 | self.failUnless(not l20 in cc,"copy uses l20.") |

1554 | |

1555 | p0_m=Point(0,0,0) |

1556 | p1_m=Point(-1,-1,-1) |

1557 | p2_m=Point(-2,-2,-2) |

1558 | p3_m=Point(-3,-3,-3) |

1559 | p4_m=Point(-1,-2,-3) |

1560 | |

1561 | l01_m=Line(p0_m,p1_m) |

1562 | l12_m=Arc(p3_m,p1_m,p2_m) |

1563 | l20_m=Spline(p2_m,p4_m,p0_m) |

1564 | |

1565 | dc=c.apply(Dilation(-1.)) |

1566 | self.failUnless(dc.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"dilation is wrong.") |

1567 | cc=dc.getCurves() |

1568 | self.failUnless(len(cc) == 3, "too many primitives in dilation result.") |

1569 | self.failUnless(not l01 in cc,"l01 is in dilation result.") |

1570 | self.failUnless(not l12 in cc,"l12 is in dilation result.") |

1571 | self.failUnless(not l20 in cc,"l20 is in dilation result.") |

1572 | |

1573 | c.modifyBy(Dilation(-1.)) |

1574 | self.failUnless(c.isColocated(CurveLoop(l01_m,l12_m,l20_m)),"inplace dilation is wrong.") |

1575 | cc=c.getCurves() |

1576 | self.failUnless(len(cc) == 3, "too many primitives in modified object.") |

1577 | self.failUnless(l01 in cc,"l01 missed in modified object.") |

1578 | self.failUnless(cc[cc.index(l01)].hasSameOrientation(-l01),"l01 in modified object has wrong orientation.") |

1579 | self.failUnless(l12 in cc,"l12 missed in modified object.") |

1580 | self.failUnless(cc[cc.index(l12)].hasSameOrientation(-l12),"l12 in modified object has wrong orientation.") |

1581 | self.failUnless(l20 in cc,"l20 missed in modified object.") |

1582 | self.failUnless(cc[cc.index(l20)].hasSameOrientation(-l20),"l20 in modified object has wrong orientation.") |

1583 | |

1584 | def test_RuledSurface(self): |

1585 | p0=Point(0,0,0,0.1) |

1586 | p1=Point(1,1,1,0.2) |

1587 | p2=Point(2,2,2,0.3) |

1588 | p3=Point(3,3,3,0.4) |

1589 | p4=Point(1,2,3) |

1590 | p5=Point(10,20,3) |

1591 | p6=Point(1,2,30) |

1592 | |

1593 | l01=Line(p0,p1) |

1594 | l12_1=Arc(p3,p1,p2) |

1595 | l12_2_1=Spline(p1,p3,p4) |

1596 | l12_2_2=Spline(p4,p5,p2) |

1597 | l12_3=Line(p1,p2) |

1598 | l20=Spline(p2,p4,p0) |

1599 | |

1600 | cl1=CurveLoop(l01,l12_1,l20) |

1601 | cl2=CurveLoop(l01,l12_2_1,l12_2_2,l20) |

1602 | cl3=CurveLoop(l01,l12_3,l20) |

1603 | |

1604 | self.failUnlessRaises(TypeError,RuledSurface,l01) |

1605 | |

1606 | s=RuledSurface(cl1) |

1607 | |

1608 | cl=s.getBoundaryLoop() |

1609 | self.failUnless(cl == cl1, " wrong boundary loops") |

1610 | self.failUnless(cl.hasSameOrientation(cl1),"cl1 has incorrect orientation.") |

1611 | |

1612 | self.failUnless(s.hasSameOrientation(s),"has not same orientation like itself") |

1613 | self.failUnless(not s.hasSameOrientation(-s),"has same orientation like -itself") |

1614 | |

1615 | crvs=s.getBoundary() |

1616 | self.failUnless(len(crvs) == 3, "too many boundary corves.") |

1617 | self.failUnless(l01 in crvs, "l01 is missing in boundary") |

1618 | self.failUnless(crvs[crvs.index(l01)].hasSameOrientation(l01),"l01 has incorrect orientation.") |

1619 | self.failUnless(l12_1 in crvs, "l21 is missing in boundary") |

1620 | self.failUnless(crvs[crvs.index(l12_1)].hasSameOrientation(l12_1),"l12_1 has incorrect orientation.") |

1621 | self.failUnless(l20 in crvs, "l20 is missing in boundary") |

1622 | self.failUnless(crvs[crvs.index(l20)].hasSameOrientation(l20),"l12_1 has incorrect orientation.") |

1623 | |

1624 | |

1625 | code=s.getGmshCommand() |

1626 | self.failUnless(code == "Ruled Surface(17) = {14};", "gmsh command wrong.") |

1627 | |

1628 | self.failUnless(not s.isColocated(p4),"RuledSurface is colocated with point.") |

1629 | self.failUnless(s.isColocated(s),"RuledSurface is not colocated with its self.") |

1630 | self.failUnless(s.isColocated(RuledSurface(cl1)),"RuledSurface is not colocated with its copy.") |

1631 | self.failUnless(not s.isColocated(RuledSurface(cl2)),"RuledSurface is colocated with different length") |

1632 | self.failUnless(not s.isColocated(RuledSurface(cl3)),"RuledSurface is colocated with same length.") |

1633 | |

1634 | s.setLocalScale(3.) |

1635 | self.failUnless(p0.getLocalScale()==3., "p0 has wrong local scale.") |

1636 | self.failUnless(p1.getLocalScale()==3., "p1 has wrong local scale.") |

1637 | self.failUnless(p2.getLocalScale()==3., "p2 has wrong local scale.") |

1638 | self.failUnless(p4.getLocalScale()==3., "p4 has wrong local scale.") |

1639 | |

1640 | p=s.getPrimitives() |

1641 | self.failUnless(len(p) == 10, "too many primitives.") |

1642 | self.failUnless(cl1 in p, "cl1 is missing") |

1643 | self.failUnless(l01 in p, "l01 is missing") |

1644 | self.failUnless(l12_1 in p, "l21 is missing") |

1645 | self.failUnless(l20 in p, "l20 is missing") |

1646 | self.failUnless(p0 in p, "p0 is missing") |

1647 | self.failUnless(p1 in p, "p1 is missing") |

1648 | self.failUnless(p2 in p, "p2 is missing") |

1649 | self.failUnless(p3 in p, "p3 is missing") |

1650 | self.failUnless(p4 in p, "p4 is missing") |

1651 | |

1652 | sp=s.copy() |

1653 | self.failUnless(isinstance(sp,RuledSurface), "copy returns is not a RuledSurface.") |

1654 | self.failUnless(not sp == s, "copy equals source") |

1655 | self.failUnless(sp.isColocated(s),"copy is not colocated with its source.") |

1656 | cbl=sp.getBoundaryLoop() |

1657 | self.failUnless(not cbl == cl1,"copy uses cl1.") |

1658 | cp=sp.getPrimitives() |

1659 | self.failUnless(len(cp) == 10, "copy as too many primitives.") |

1660 | self.failUnless(not cl1 in cp, "copy is using cl1") |

1661 | self.failUnless(not l01 in cp, "copy is using l01") |

1662 | self.failUnless(not l12_1 in cp, "copy is using l21") |

1663 | self.failUnless(not l20 in cp, "copy is using l20") |

1664 | self.failUnless(not p0 in cp, "copy is using p0") |

1665 | self.failUnless(not p1 in cp, "copy is using p1") |

1666 | self.failUnless(not p2 in cp, "copy is using p2") |

1667 | self.failUnless(not p3 in cp, "copy is using p3") |

1668 | self.failUnless(not p4 in cp, "copy is using p4") |

1669 | del cp |

1670 | |

1671 | p0_m=Point(0,0,0) |

1672 | p1_m=Point(-1,-1,-1) |

1673 | p2_m=Point(-2,-2,-2) |

1674 | p3_m=Point(-3,-3,-3) |

1675 | p4_m=Point(-1,-2,-3) |

1676 | |

1677 | l01_m=Line(p0_m,p1_m) |

1678 | l12_m=Arc(p3_m,p1_m,p2_m) |

1679 | l20_m=Spline(p2_m,p4_m,p0_m) |

1680 | |

1681 | ds=s.apply(Dilation(-1.)) |

1682 | self.failUnless(ds.isColocated(RuledSurface(CurveLoop(l01_m,l12_m,l20_m))),"dilation is wrong.") |

1683 | cbl=ds.getBoundaryLoop() |

1684 | self.failUnless(not cbl == cl1,"dilation uses cl1.") |

1685 | cp=ds.getPrimitives() |

1686 | self.failUnless(len(cp) == 10, "dilation as too many primitives.") |

1687 | self.failUnless(not cl1 in cp, "dilation is using cl1") |

1688 | self.failUnless(not l01 in cp, "dilation is using l01") |

1689 | self.failUnless(not l12_1 in cp, "dilation is using l21") |

1690 | self.failUnless(not l20 in cp, "dilation is using l20") |

1691 | self.failUnless(not p0 in cp, "dilation is using p0") |

1692 | self.failUnless(not p1 in cp, "dilation is using p1") |

1693 | self.failUnless(not p2 in cp, "dilation is using p2") |

1694 | self.failUnless(not p3 in cp, "dilation is using p3") |

1695 | self.failUnless(not p4 in cp, "dilation is using p4") |

1696 | |

1697 | s.modifyBy(Dilation(-1.)) |

1698 | self.failUnless(s.isColocated(RuledSurface(CurveLoop(l01_m,l12_m,l20_m))),"inplace dilation is wrong.") |

1699 | |

1700 | p=s.getPrimitives() |

1701 | self.failUnless(len(p) == 10, "inplace dilation has too many primitives.") |

1702 | self.failUnless(cl1 in p, "inplace dilation cl1 is missing") |

1703 | self.failUnless(l01 in p, "inplace dilation l01 is missing") |

1704 | self.failUnless(l12_1 in p, "inplace dilation l21 is missing") |

1705 | self.failUnless(l20 in p, "inplace dilation l20 is missing") |

1706 | self.failUnless(p0 in p, "inplace dilation p0 is missing") |

1707 | self.failUnless(p1 in p, "inplace dilation p1 is missing") |

1708 | self.failUnless(p2 in p, "inplace dilation p2 is missing") |

1709 | self.failUnless(p3 in p, "inplace dilation p3 is missing") |

1710 | self.failUnless(p4 in p, "inplace dilation p4 is missing") |

1711 | |

1712 | p=s.getBoundary() |

1713 | self.failUnless(len(p) == 3, "inplace dilation has too many boundary curves.") |

1714 | self.failUnless(l01 in p, "inplace dilation l01 is missing in boundary curves.") |

1715 | self.failUnless(p[p.index(l01)].hasSameOrientation(l01),"l01 in getBoundary after dilation has incorrect orientation.") |

1716 | self.failUnless(l12_1 in p, "inplace dilation l21 is missing") |

1717 | self.failUnless(p[p.index(l12_1)].hasSameOrientation(l12_1),"l12_1 in getBoundary after dilation has incorrect orientation.") |

1718 | self.failUnless(l20 in p, "inplace dilation l20 is missing") |

1719 | self.failUnless(p[p.index(l20)].hasSameOrientation(l20),"l20 in getBoundary after dilation has incorrect orientation.") |

1720 | |

1721 | p=s.getBoundaryLoop() |

1722 | self.failUnless(cl1 == p, "inplace dilation s.getBoundaryLoop does not return cl1") |

1723 | self.failUnless(p.hasSameOrientation(cl1),"cl1 in getBoundaryLoop after dilation has incorrect orientation.") |

1724 | |

1725 | def test_ReverseRuledSurface(self): |

1726 | p0=Point(0,0,0,0.1) |

1727 | p1=Point(1,1,1,0.2) |

1728 | p2=Point(2,2,2,0.3) |

1729 | p3=Point(3,3,3,0.4) |

1730 | p4=Point( |