/[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 1381 - (show annotations)
Wed Jan 9 07:59:15 2008 UTC (11 years, 11 months ago) by gross
File MIME type: text/x-python
File size: 2820 byte(s)
import sys missing
1 from esys.pyvisi import DataCollector, Scene, Carpet
2 from esys.pyvisi.constant import *
3 import unittest, os, sys
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_WORKDIR, \
17 "data_sample_images", "carpet")
18
19 MIN_IMAGE_SIZE = 100
20 FILE_3D = "interior_3D.xml"
21 X_SIZE = 400
22 Y_SIZE = 400
23 JPG_RENDERER = Renderer.OFFLINE_JPG
24
25 class TestCarpet:
26 def render(self, file):
27 self.scene.render(image_name = \
28 os.path.join(PYVISI_TEST_CARPET_IMAGES_PATH, file))
29
30 self.failUnless(os.stat(os.path.join(PYVISI_TEST_CARPET_IMAGES_PATH,\
31 file))[ST_SIZE] > MIN_IMAGE_SIZE)
32
33 class TestCarpetScalarWarp(unittest.TestCase, TestCarpet):
34 def setUp(self):
35 self.scene = \
36 Scene(renderer = JPG_RENDERER, num_viewport = 1,
37 x_size = X_SIZE, y_size = Y_SIZE)
38
39 self.data_collector = DataCollector(source = Source.XML)
40 self.data_collector.setFileName(file_name = \
41 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
42
43 self.carpet = Carpet(scene = self.scene,
44 data_collector = self.data_collector,
45 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR,
46 lut = Lut.COLOR, cell_to_point = False, outline = True)
47
48 def tearDown(self):
49 del self.scene
50 del self.data_collector
51 del self.carpet
52
53 def testScalarWarp(self):
54 self.carpet.setScaleFactor(1)
55 self.carpet.setPlaneToXY()
56 self.render("TestCarpetScalarWarp.jpg")
57
58 class TestCarpetVectorWarp(unittest.TestCase, TestCarpet):
59 def setUp(self):
60 self.scene = \
61 Scene(renderer = JPG_RENDERER, num_viewport = 1,
62 x_size = X_SIZE, y_size = Y_SIZE)
63
64 self.data_collector = DataCollector(source = Source.XML)
65 self.data_collector.setFileName(file_name = \
66 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
67
68 self.carpet = Carpet(scene = self.scene,
69 data_collector = self.data_collector,
70 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.VECTOR,
71 lut = Lut.COLOR, cell_to_point = False, outline = True)
72
73 def tearDown(self):
74 del self.scene
75 del self.data_collector
76 del self.carpet
77
78 def testVectorWarp(self):
79 self.carpet.setScaleFactor(1)
80 self.carpet.setPlaneToXY()
81 self.render("TestCarpetVectorWarp.jpg")
82
83
84
85 ##############################################################################
86
87
88 if __name__ == '__main__':
89 suite = unittest.TestSuite()
90 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetScalarWarp))
91 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetVectorWarp))
92 s=unittest.TextTestRunner(verbosity=2).run(suite)
93 if not s.wasSuccessful(): sys.exit(1)
94

  ViewVC Help
Powered by ViewVC 1.1.26