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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1070 - (hide annotations)
Thu Mar 29 04:20:50 2007 UTC (15 years, 4 months ago) by jongui
File MIME type: text/x-python
File size: 3722 byte(s)
Added tests for the camera, carpet, contouir, ellipsoid, light, streamline and velocity modules.
1 jongui 1070 from esys.pyvisi import DataCollector, Scene, StreamLine, GlobalPosition
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_STREAMLINE_IMAGES_PATH = "data_sample_images/streamline/"
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 TestStreamLine:
17     def tearDown(self):
18     self.scene
19     self.data_collector
20     self.streamline
21    
22     def render(self, file):
23     self.scene.render(image_name = \
24     PYVISI_TEST_STREAMLINE_IMAGES_PATH + file)
25    
26     self.failUnless(os.stat(PYVISI_TEST_STREAMLINE_IMAGES_PATH + \
27     file)[ST_SIZE] > MIN_IMAGE_SIZE)
28    
29     class TestStreamLinePointSource(unittest.TestCase, TestStreamLine):
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.streamline = StreamLine(scene = self.scene,
40     data_collector = self.data_collector,
41     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR,
42     lut = Lut.COLOR, cell_to_point = False, outline = True)
43    
44     def testPointSource(self):
45     self.streamline.setPointSourceRadius(0.3)
46     self.streamline.setPointSourceCenter(GlobalPosition(1.3, 1.3, 0.4))
47     self.streamline.setPointSourceNumberOfPoints(5)
48     self.render("TestStreamLinePointSource.jpg")
49    
50     class TestStreamLineModule(unittest.TestCase, TestStreamLine):
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.streamline = StreamLine(scene = self.scene,
61     data_collector = self.data_collector,
62     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR,
63     lut = Lut.COLOR, cell_to_point = False, outline = True)
64    
65     def testStreamLineModule(self):
66     self.streamline.setMaximumPropagationTime(20)
67     self.streamline.setStepLength(0.1)
68     self.streamline.setIntegrationStepLength(0.1)
69     self.streamline.setIntegrationToBothDirections()
70     self.render("TestStreamLineModule.jpg")
71    
72     class TestStreamLineTube(unittest.TestCase, TestStreamLine):
73     def setUp(self):
74     self.scene = \
75     Scene(renderer = JPG_RENDERER, num_viewport = 1,
76     x_size = X_SIZE, y_size = Y_SIZE)
77    
78     self.data_collector = DataCollector(source = Source.XML)
79     self.data_collector.setFileName(file_name = \
80     PYVISI_TEST_MESHES_PATH + FILE_3D)
81    
82     self.streamline = StreamLine(scene = self.scene,
83     data_collector = self.data_collector,
84     viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR,
85     lut = Lut.COLOR, cell_to_point = False, outline = True)
86    
87     def testSetTubeRadiusToVaryByVector(self):
88     self.streamline.setTubeRadius(0.05)
89     self.streamline.setTubeNumberOfSides(3)
90     self.streamline.setTubeRadiusToVaryByVector()
91     self.render("TestStreamLineTube_testSetTubeRadiusToVaryByVector.jpg")
92    
93     def testSetTubeRadiusToVaryBeScalar(self):
94     self.streamline.setTubeRadiusToVaryByScalar()
95     self.render("TestStreamLineTube_testSetTubeRadiusToVaryByScalar.jpg")
96    
97    
98     ##############################################################################
99    
100    
101     if __name__ == '__main__':
102     suite = unittest.TestSuite()
103     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestStreamLinePointSource))
104     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestStreamLineModule))
105     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestStreamLineTube))
106     unittest.TextTestRunner(verbosity=2).run(suite)
107    

  ViewVC Help
Powered by ViewVC 1.1.26