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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1194 - (show annotations)
Thu Jun 14 05:53:49 2007 UTC (13 years, 2 months ago) by jongui
File MIME type: text/x-python
File size: 2944 byte(s)
- Fixed a minor bug in the Camera module.
- Added some extra capability to the Movie module.
- The Camera module now has the capability to perform parallel projection by calling the 'parallelProjectionOn' method.
- The Camera at this stage is only capable of zooming towards the rendered object using 'dolly'. However, it appears that 'dolly' cannot be used to perform zooming out.
1 from esys.pyvisi import Scene, DataCollector, Map, Camera, Velocity, Legend
2 from esys.pyvisi import Movie, LocalPosition
3 from esys.pyvisi.constant import *
4 import unittest, os
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_MOVIE_REFERENCE_IMAGES_PATH = \
18 os.path.join(PYVISI_TEST_DATA_ROOT, \
19 "data_reference_images", "movie")
20 PYVISI_TEST_MOVIE_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
21 "data_sample_images", "movie")
22
23 MIN_IMAGE_SIZE = 100
24 X_SIZE = 400
25 Y_SIZE = 400
26
27 SCALAR_FIELD_POINT_DATA = "temp"
28 FILE_2D = "tempvel-"
29 IMAGE_NAME = "TestMovie"
30 JPG_RENDERER = Renderer.OFFLINE_JPG
31
32 class TestMovie:
33 def render(self, file):
34 self.scene.render(image_name = \
35 os.path.join(PYVISI_TEST_MOVIE_IMAGES_PATH, file))
36
37 self.failUnless(os.stat(os.path.join(PYVISI_TEST_MOVIE_IMAGES_PATH,\
38 file))[ST_SIZE] > MIN_IMAGE_SIZE)
39
40 class TestGenerateMovie(unittest.TestCase, TestMovie):
41 def setUp(self):
42 self.scene = \
43 Scene(renderer = JPG_RENDERER, num_viewport = 1,
44 x_size = X_SIZE, y_size = Y_SIZE)
45
46 self.data_collector = DataCollector(source = Source.XML)
47 self.data_collector.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
48
49
50 # Create a Contour.
51 self.map = Map(scene = self.scene,
52 data_collector = self.data_collector,
53 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
54 cell_to_point = False, outline = True)
55
56 self.velocity = Velocity(scene = self.scene,
57 data_collector = self.data_collector,
58 viewport = Viewport.SOUTH_WEST, arrow = Arrow.TWO_D,
59 color_mode = ColorMode.VECTOR, lut = Lut.COLOR,
60 cell_to_point = False, outline = True)
61
62 self.velocity.setScaleFactor(scale_factor = 0.07)
63 self.velocity.setRatio(ratio = 8)
64 self.velocity.setColor(color = Color.BLACK)
65
66 self.mov = Movie()
67 self.cam = Camera(scene = self.scene, viewport = Viewport.SOUTH_WEST)
68
69 def tearDown(self):
70 del self.scene
71 del self.data_collector
72 del self.velocity
73 del self.map
74 del self.cam
75 del self.mov
76
77 def testMovie(self):
78
79 for i in range(938, 949):
80 self.data_collector.setFileName(file_name = \
81 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_2D + "%06d.vtu")
82 % i)
83
84 self.render(IMAGE_NAME + "%06d.jpg" % i)
85
86 self.mov.makeMovie(input_directory = PYVISI_TEST_MOVIE_IMAGES_PATH,
87 first_image = IMAGE_NAME + "000938.jpg",
88 last_image = IMAGE_NAME + "000948.jpg",
89 movie = os.path.join(PYVISI_TEST_MOVIE_IMAGES_PATH, "movie.mpg"))
90
91 ###############################################################################
92
93
94 if __name__ == '__main__':
95 suite = unittest.TestSuite()
96 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestGenerateMovie))
97 unittest.TextTestRunner(verbosity=2).run(suite)

  ViewVC Help
Powered by ViewVC 1.1.26