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

Contents of /trunk/pyvisi/test/python/run_streamline_with_lazy_evaluation.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: 2052 byte(s)
import sys missing
1 from esys.pyvisi import DataCollector, Scene, StreamLine, GlobalPosition
2 from esys.pyvisi import Camera
3 from esys.pyvisi.constant import *
4 import unittest, os, sys
5 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_STREAMLINE_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18 "data_sample_images", "streamline")
19
20 MIN_IMAGE_SIZE = 100
21 FILE_3D = "results.xml"
22 X_SIZE = 400
23 Y_SIZE = 400
24 JPG_RENDERER = Renderer.OFFLINE_JPG
25
26 class TestStreamLineWithLazyEvaluation:
27 def render(self, file):
28 self.scene.render(image_name = \
29 os.path.join(PYVISI_TEST_STREAMLINE_IMAGES_PATH, file))
30
31 self.failUnless(os.stat(\
32 os.path.join(PYVISI_TEST_STREAMLINE_IMAGES_PATH, \
33 file))[ST_SIZE] > MIN_IMAGE_SIZE)
34
35 class TestStreamLine(unittest.TestCase, TestStreamLineWithLazyEvaluation):
36 def tearDown(self):
37 del self.scene
38
39 def testStreamLine(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 one streamline instance for the first viewport.
47 sl1 = StreamLine(scene = s, data_collector = dc1,
48 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
49 outline = True, color_mode = ColorMode.VECTOR)
50 sl1.setTubeRadius(radius = 0.01)
51
52 cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
53 cam1.elevation(angle = -40)
54 dc1.setFileName(file_name = \
55 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
56
57 self.render("TestStreamLineWithLazyEvaluation.jpg")
58
59
60 ##############################################################################
61 if __name__ == '__main__':
62 suite = unittest.TestSuite()
63 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestStreamLine))
64 s=unittest.TextTestRunner(verbosity=2).run(suite)
65 if not s.wasSuccessful(): sys.exit(1)
66
67

  ViewVC Help
Powered by ViewVC 1.1.26