1 | #!/usr/bin/env python |
---|
2 | # |
---|
3 | |
---|
4 | import sys |
---|
5 | |
---|
6 | import unittest |
---|
7 | import mesh_engine.triang as triang |
---|
8 | |
---|
9 | """ |
---|
10 | Note, this test is seperated from the other tests because if it is added |
---|
11 | the triangle code seg faults. Don't know why |
---|
12 | """ |
---|
13 | class triangTestCase(unittest.TestCase): |
---|
14 | |
---|
15 | def setUp(self): |
---|
16 | pass |
---|
17 | |
---|
18 | def tearDown(self): |
---|
19 | pass |
---|
20 | |
---|
21 | def BAD_test_lone_vertsII(self): |
---|
22 | |
---|
23 | points = [] |
---|
24 | seglist = [] |
---|
25 | holelist = [] |
---|
26 | regionlist = [] |
---|
27 | |
---|
28 | points = [(0.0,0.0),(0.0,0.0),(0.0,10.0),(0.0,10.0),(10.0,10.0), |
---|
29 | (10.0,10.0),(0.0,10.0),(10.0,0.0)] |
---|
30 | |
---|
31 | pointattlist = [] |
---|
32 | for point in points: |
---|
33 | pointattlist.append([]) |
---|
34 | seglist = [(0,1),(1,2),(2,3),(3,4),(4,5),(5,7),(7,0)] |
---|
35 | segattlist = [] |
---|
36 | for seg in seglist: |
---|
37 | segattlist.append(0) |
---|
38 | trilist = [] |
---|
39 | mode = "QpznAa2000.1a" |
---|
40 | data = triang.genMesh(points,seglist,holelist,regionlist, |
---|
41 | pointattlist,segattlist,trilist, mode) |
---|
42 | #print "data['generatedtrianglelist']", data['generatedtrianglelist'] |
---|
43 | self.failUnless(data['generatedtrianglelist'] ==[(6, 1, 7), (7, 5, 6)], |
---|
44 | 'trianglelist is wrong!') |
---|
45 | self.failUnless(data['generatedsegmentlist'] ==[(1, 6), (6, 5), |
---|
46 | (5, 7), (7, 1)], |
---|
47 | 'segmentlist is wrong!') |
---|
48 | self.failUnless(data['generatedpointlist'] ==[(0.0,0.0),(0.0,0.0), |
---|
49 | (0.0,10.0),(0.0,10.0), |
---|
50 | (10.0,10.0), |
---|
51 | (10.0,10.0),(0.0,10.0), |
---|
52 | (10.0,0.0)], |
---|
53 | ' is wrong!') |
---|
54 | self.failUnless(data['lonepointlist'] ==[0,2,3,4], |
---|
55 | 'lonepointlist is wrong!') |
---|
56 | |
---|
57 | def test_lone_vertsIII(self): |
---|
58 | |
---|
59 | points = [] |
---|
60 | seglist = [] |
---|
61 | holelist = [] |
---|
62 | regionlist = [] |
---|
63 | |
---|
64 | points = [(0.0,0.0),(0.0,0.0),(0.0,10.0),(0.0,10.0),(10.0,10.0), |
---|
65 | (10.0,10.0),(0.0,10.0),(10.0,0.0)] |
---|
66 | |
---|
67 | pointattlist = [] |
---|
68 | for point in points: |
---|
69 | pointattlist.append([]) |
---|
70 | seglist = [] |
---|
71 | segattlist = [] |
---|
72 | for seg in seglist: |
---|
73 | segattlist.append(0) |
---|
74 | trilist = [] |
---|
75 | mode = "Qzp" |
---|
76 | data = triang.genMesh(points,seglist,holelist,regionlist, |
---|
77 | pointattlist,segattlist,trilist, mode) |
---|
78 | |
---|
79 | self.failUnless(data['lonepointlist'] ==[0,1,2,3,4,5,6,7], |
---|
80 | 'lonepointlist is wrong!') |
---|
81 | if __name__ == "__main__": |
---|
82 | |
---|
83 | suite = unittest.makeSuite(triangTestCase,'test') |
---|
84 | runner = unittest.TextTestRunner() |
---|
85 | runner.run(suite) |
---|