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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (show annotations)
Wed Jun 20 05:01:30 2007 UTC (12 years ago) by jongui
File MIME type: text/x-python
File size: 1833 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 from esys.pyvisi import DataCollector, Scene, Carpet, Camera
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_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 TestCarpetWithLazyEvaluation:
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 TestCarpet(unittest.TestCase, TestCarpetWithLazyEvaluation):
34 def tearDown(self):
35 del self.scene
36
37 def testCarpet(self):
38 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
39 y_size = Y_SIZE)
40 self.scene = s
41
42 dc1 = DataCollector(source = Source.XML)
43
44 # Create one carpet instance.
45 cpt1 = Carpet(scene = s, data_collector = dc1,
46 warp_mode = WarpMode.SCALAR, lut = Lut.COLOR)
47 cpt1.setScaleFactor(0.5)
48
49 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
50 c1.isometricView()
51
52 cpt1.setPlaneToXY(0.5)
53 dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH,\
54 FILE_3D))
55
56 self.render("TestCarpetWithLazyEvaluation.jpg")
57
58
59 ##############################################################################
60 if __name__ == '__main__':
61 suite = unittest.TestSuite()
62 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpet))
63 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26