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

Annotation of /trunk/pyvisi/test/python/run_image_with_lazy_evaluation.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1381 - (hide annotations)
Wed Jan 9 07:59:15 2008 UTC (12 years ago) by gross
File MIME type: text/x-python
File size: 2258 byte(s)
import sys missing
1 jongui 1148 from esys.pyvisi import DataCollector, Scene, Map, Image, Image, ImageReader
2     from esys.pyvisi import GlobalPosition
3     from esys.pyvisi.constant import *
4 gross 1381 import unittest, os, sys
5 jongui 1148 from stat import ST_SIZE
6    
7     try:
8     PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
9     except KeyError:
10     PYVISI_WORKDIR='.'
11     try:
12     PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
13     except KeyError:
14     PYVISI_TEST_DATA_ROOT='.'
15    
16     PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
17     PYVISI_TEST_IMAGE_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18     "data_sample_images", "image")
19    
20     MIN_IMAGE_SIZE = 100
21     FILE_3D = "interior_3D.xml"
22     IMAGE = "flinders.jpg"
23     X_SIZE = 400
24     Y_SIZE = 400
25     JPG_RENDERER = Renderer.OFFLINE_JPG
26    
27     class TestImageWithLazyEvaluation:
28     def render(self, file):
29     self.scene.render(image_name = \
30     os.path.join(PYVISI_TEST_IMAGE_IMAGES_PATH, file))
31    
32     self.failUnless(os.stat(os.path.join(PYVISI_TEST_IMAGE_IMAGES_PATH, \
33     file))[ST_SIZE] > MIN_IMAGE_SIZE)
34    
35     class TestImage(unittest.TestCase, TestImageWithLazyEvaluation):
36 jongui 1158 def tearDown(self):
37     del self.scene
38    
39 jongui 1148 def testImage(self):
40     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
41     y_size = Y_SIZE)
42     self.scene = s
43    
44     dc1 = DataCollector(source = Source.XML)
45    
46     # Create a map instance for the first viewport.
47     m1 = Map(scene = s, data_collector = dc1,
48     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
49    
50     # Create one image reader instance (used in place of data collector).
51     ir = ImageReader(ImageFormat.JPG)
52    
53    
54     # Create one image instance.
55     i = Image(scene = s, image_reader = ir)
56     i.setOpacity(opacity = 0.9)
57     i.translate(0,0,-1.)
58     i.setPoint1(GlobalPosition(2,0,0))
59     i.setPoint2(GlobalPosition(0,2,0))
60    
61     ir.setImageName(image_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
62     IMAGE))
63     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
64     FILE_3D))
65    
66     self.render("TestImageWithLazyEvaluation.jpg")
67    
68    
69     ###############################################################################
70    
71    
72     if __name__ == '__main__':
73     suite = unittest.TestSuite()
74     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestImage))
75 gross 1376 s=unittest.TextTestRunner(verbosity=2).run(suite)
76     if not s.wasSuccessful(): sys.exit(1)
77 jongui 1148

  ViewVC Help
Powered by ViewVC 1.1.26