/[escript]/trunk/pyvisi/test/python/run_carpet.py
ViewVC logotype

Contents of /trunk/pyvisi/test/python/run_carpet.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1138 - (show annotations)
Mon May 14 04:15:04 2007 UTC (13 years, 6 months ago) by gross
File MIME type: text/x-python
File size: 2729 byte(s)
 * some of the sys.exit calls removed.
 * some modifications on the test (and more work needs to be done, use test/python/run_carpet.py as an example) to get them going with scons 

-> things seems to run on windows XP.
1 from esys.pyvisi import DataCollector, Scene, Carpet
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 try:
7 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
8 except KeyError:
9 PYVISI_WORKDIR='.'
10 try:
11 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
12 except KeyError:
13 PYVISI_TEST_DATA_ROOT='.'
14
15 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT,"data_meshes")
16 PYVISI_TEST_CARPET_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT,"data_sample_images","carpet")
17 MIN_IMAGE_SIZE = 100
18 FILE_3D = "interior_3D.xml"
19
20 X_SIZE = 400
21 Y_SIZE = 400
22
23 JPG_RENDERER = Renderer.OFFLINE_JPG
24
25 class TestCarpet:
26 def tearDown(self):
27 self.scene
28 self.data_collector
29 self.contour
30
31 def render(self, file):
32 self.scene.render(image_name = \
33 PYVISI_TEST_CARPET_IMAGES_PATH + file)
34
35 self.failUnless(os.stat(PYVISI_TEST_CARPET_IMAGES_PATH + \
36 file)[ST_SIZE] > MIN_IMAGE_SIZE)
37
38 class TestCarpetScalarWarp(unittest.TestCase, TestCarpet):
39 def setUp(self):
40 self.scene = \
41 Scene(renderer = JPG_RENDERER, num_viewport = 1,
42 x_size = X_SIZE, y_size = Y_SIZE)
43
44 self.data_collector = DataCollector(source = Source.XML)
45 self.data_collector.setFileName(file_name = \
46 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
47
48 self.carpet = Carpet(scene = self.scene,
49 data_collector = self.data_collector,
50 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR,
51 lut = Lut.COLOR, cell_to_point = False, outline = True)
52
53
54 def testScalarWarp(self):
55 self.carpet.setScaleFactor(1)
56 self.carpet.setPlaneToXY()
57 self.render(os.path.join(PYVISI_WORKDIR,"TestCarpetScalarWarp.jpg"))
58
59 class TestCarpetVectorWarp(unittest.TestCase, TestCarpet):
60 def setUp(self):
61 self.scene = \
62 Scene(renderer = JPG_RENDERER, num_viewport = 1,
63 x_size = X_SIZE, y_size = Y_SIZE)
64
65 self.data_collector = DataCollector(source = Source.XML)
66 self.data_collector.setFileName(file_name = \
67 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
68
69 self.carpet = Carpet(scene = self.scene,
70 data_collector = self.data_collector,
71 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.VECTOR,
72 lut = Lut.COLOR, cell_to_point = False, outline = True)
73
74
75 def testVectorWarp(self):
76 self.carpet.setScaleFactor(1)
77 self.carpet.setPlaneToXY()
78 self.render(os.path.join(PYVISI_WORKDIR,"TestCarpetVectorWarp.jpg"))
79
80
81
82 ##############################################################################
83
84
85 if __name__ == '__main__':
86 suite = unittest.TestSuite()
87 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetScalarWarp))
88 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetVectorWarp))
89 unittest.TextTestRunner(verbosity=2).run(suite)
90

  ViewVC Help
Powered by ViewVC 1.1.26