/[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 1070 - (show annotations)
Thu Mar 29 04:20:50 2007 UTC (12 years, 3 months ago) by jongui
File MIME type: text/x-python
File size: 2356 byte(s)
Added tests for the camera, carpet, contouir, ellipsoid, light, streamline and velocity modules.
1 from esys.pyvisi import DataCollector, Scene, Carpet
2 from esys.pyvisi.constant import *
3 import unittest, os
4 from stat import ST_SIZE
5
6 PYVISI_TEST_MESHES_PATH = "data_meshes/"
7 PYVISI_TEST_CARPET_IMAGES_PATH = "data_sample_images/carpet/"
8 MIN_IMAGE_SIZE = 100
9 FILE_3D = "interior_3D.xml"
10
11 X_SIZE = 400
12 Y_SIZE = 400
13
14 JPG_RENDERER = Renderer.OFFLINE_JPG
15
16 class TestCarpet:
17 def tearDown(self):
18 self.scene
19 self.data_collector
20 self.contour
21
22 def render(self, file):
23 self.scene.render(image_name = \
24 PYVISI_TEST_CARPET_IMAGES_PATH + file)
25
26 self.failUnless(os.stat(PYVISI_TEST_CARPET_IMAGES_PATH + \
27 file)[ST_SIZE] > MIN_IMAGE_SIZE)
28
29 class TestCarpetScalarWarp(unittest.TestCase, TestCarpet):
30 def setUp(self):
31 self.scene = \
32 Scene(renderer = JPG_RENDERER, num_viewport = 1,
33 x_size = X_SIZE, y_size = Y_SIZE)
34
35 self.data_collector = DataCollector(source = Source.XML)
36 self.data_collector.setFileName(file_name = \
37 PYVISI_TEST_MESHES_PATH + FILE_3D)
38
39 self.carpet = Carpet(scene = self.scene,
40 data_collector = self.data_collector,
41 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR,
42 lut = Lut.COLOR, cell_to_point = False, outline = True)
43
44
45 def testScalarWarp(self):
46 self.carpet.setScaleFactor(1)
47 self.carpet.setPlaneToXY()
48 self.render("TestCarpetScalarWarp.jpg")
49
50 class TestCarpetVectorWarp(unittest.TestCase, TestCarpet):
51 def setUp(self):
52 self.scene = \
53 Scene(renderer = JPG_RENDERER, num_viewport = 1,
54 x_size = X_SIZE, y_size = Y_SIZE)
55
56 self.data_collector = DataCollector(source = Source.XML)
57 self.data_collector.setFileName(file_name = \
58 PYVISI_TEST_MESHES_PATH + FILE_3D)
59
60 self.carpet = Carpet(scene = self.scene,
61 data_collector = self.data_collector,
62 viewport = Viewport.SOUTH_WEST, warp_mode = WarpMode.VECTOR,
63 lut = Lut.COLOR, cell_to_point = False, outline = True)
64
65
66 def testVectorWarp(self):
67 self.carpet.setScaleFactor(1)
68 self.carpet.setPlaneToXY()
69 self.render("TestCarpetVectorWarp.jpg")
70
71
72
73 ##############################################################################
74
75
76 if __name__ == '__main__':
77 suite = unittest.TestSuite()
78 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetScalarWarp))
79 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestCarpetVectorWarp))
80 unittest.TextTestRunner(verbosity=2).run(suite)
81

  ViewVC Help
Powered by ViewVC 1.1.26