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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1148 - (hide annotations)
Wed May 16 22:45:33 2007 UTC (12 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 3796 byte(s)
Added the updated files for pyvisi and removed some incorrect reference images.
1 jongui 1148 from esys.pyvisi import DataCollector, Scene, Contour, ContourOnPlaneCut
2     from esys.pyvisi import ContourOnPlaneClip, Camera
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_CONTOUR_REFERENCE_IMAGES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT,\
18     "data_reference_images", "contour")
19     PYVISI_TEST_CONTOUR_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
20     "data_sample_images", "contour")
21    
22     MIN_IMAGE_SIZE = 100
23     FILE_3D = "interior_3D.xml"
24     X_SIZE = 400
25     Y_SIZE = 400
26     JPG_RENDERER = Renderer.OFFLINE_JPG
27    
28     class TestContourWithLazyEvaluation:
29     def tearDown(self):
30     self.scene
31    
32     def render(self, file):
33     self.scene.render(image_name = \
34     os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, file))
35    
36     self.failUnless(os.stat(os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, \
37     file))[ST_SIZE] > MIN_IMAGE_SIZE)
38    
39     class TestContour(unittest.TestCase, TestContourWithLazyEvaluation):
40     def testContour(self):
41     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
42     y_size = Y_SIZE)
43     self.scene = s
44    
45     dc1 = DataCollector(source = Source.XML)
46    
47     # Create one contour instance.
48     ctr1 = Contour(scene = s, data_collector = dc1,
49     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
50     ctr1.generateContours(contours = 6, lower_range = 0, upper_range = 0.5)
51    
52     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
53     cam1.elevation(angle = -40)
54    
55     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
56     FILE_3D))
57     self.render("TestContourWithLazyEvaluation.jpg")
58    
59    
60     class TestContourOnPlaneCut(unittest.TestCase, TestContourWithLazyEvaluation):
61     def testContourOnPlaneCut(self):
62     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
63     y_size = Y_SIZE)
64     self.scene = s
65    
66     dc1 = DataCollector(source = Source.XML)
67    
68     # Create one contour on plane cut instance.
69     ctropc1 = ContourOnPlaneCut(scene = s, data_collector = dc1,
70     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
71     ctropc1.setPlaneToXY(offset = 0.2)
72    
73     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
74     c1.elevation(angle = -45)
75    
76     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
77     FILE_3D))
78     ctropc1.generateContours(contours = 8)
79    
80     self.render("TestContourOnPlaneCutWithLazyEvaluation.jpg")
81    
82     class TestContourOnPlaneClip(unittest.TestCase, TestContourWithLazyEvaluation):
83     def testContourOnPlaneClip(self):
84     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
85     y_size = Y_SIZE)
86     self.scene = s
87    
88     dc1 = DataCollector(source = Source.XML)
89    
90     # Create one contour on plance clip instance.
91     ctropc1 = ContourOnPlaneClip(scene = s, data_collector = dc1,
92     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
93     outline = True)
94     ctropc1.setPlaneToXY()
95     ctropc1.rotateY(angle = 10)
96     ctropc1.generateContours(contours = 8)
97    
98     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
99     c1.elevation(angle = -40)
100    
101     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH,
102     FILE_3D))
103     self.render("TestContourOnPlaneClipWithLazyEvaluation.jpg")
104    
105    
106     ##############################################################################
107    
108    
109     if __name__ == '__main__':
110     suite = unittest.TestSuite()
111     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContour))
112     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContourOnPlaneCut))
113     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContourOnPlaneClip))
114     unittest.TextTestRunner(verbosity=2).run(suite)
115    

  ViewVC Help
Powered by ViewVC 1.1.26