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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1151 - (hide annotations)
Thu May 17 04:11:18 2007 UTC (13 years, 5 months ago) by jongui
File MIME type: text/x-python
File size: 4037 byte(s)
More update.
1 jongui 1148 from esys.pyvisi import DataCollector, Scene, Ellipsoid, EllipsoidOnPlaneCut
2     from esys.pyvisi import EllipsoidOnPlaneClip, 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_ELLIPSOID_REFERENCE_IMAGES_PATH = \
18     os.path.join(PYVISI_TEST_DATA_ROOT, "data_reference_images", \
19     "ellipsoid")
20     PYVISI_TEST_ELLIPSOID_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
21     "data_sample_images", "ellipsoid")
22    
23     MIN_IMAGE_SIZE = 100
24     FILE_3D = "interior_3D.xml"
25     X_SIZE = 400
26     Y_SIZE = 400
27     JPG_RENDERER = Renderer.OFFLINE_JPG
28    
29     class TestEllipsoidWithLazyEvaluation:
30     def tearDown(self):
31     self.scene
32    
33     def render(self, file):
34     self.scene.render(image_name = \
35     os.path.join(PYVISI_TEST_ELLIPSOID_IMAGES_PATH, file))
36    
37     self.failUnless(os.stat(os.path.join(PYVISI_TEST_ELLIPSOID_IMAGES_PATH,\
38     file))[ST_SIZE] > MIN_IMAGE_SIZE)
39    
40 jongui 1151 class TestEllipsoidScaleResolution(unittest.TestCase, TestEllipsoidWithLazyEvaluation):
41     def testEllipsoidScaleResolution(self):
42 jongui 1148 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
43     y_size = Y_SIZE)
44     self.scene = s
45    
46     dc1 = DataCollector(source = Source.XML)
47    
48     # Create one ellipsoid instance.
49     e1 = Ellipsoid(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
50     lut = Lut.COLOR, outline = True)
51     e1.setScaleFactor(scale_factor = 0.2)
52     e1.setPhiResolution(resolution = 20)
53     e1.setThetaResolution(resolution = 20)
54    
55     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
56     c1.isometricView()
57     c1.elevation(angle = -20)
58    
59     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
60     FILE_3D))
61     self.render("TestEllipsoidWithLazyEvaluation.jpg")
62    
63     class TestEllipsoidOnPlaneCut(unittest.TestCase, TestEllipsoidWithLazyEvaluation):
64     def testEllipsoidOnPlaneCut(self):
65     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
66     y_size = Y_SIZE)
67     self.scene = s
68    
69     dc1 = DataCollector(source = Source.XML)
70    
71     # Create one ellipsoid on plance cut instance.
72     eopc1 = EllipsoidOnPlaneCut(scene = s, data_collector = dc1,
73     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
74     eopc1.setScaleFactor(scale_factor = 0.1)
75     eopc1.setPlaneToXY()
76     eopc1.rotateX(angle = 10)
77    
78     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
79     c1.isometricView()
80     c1.elevation(angle = -20)
81    
82     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
83     FILE_3D))
84    
85     self.render("TestEllipsoidOnPlaneCutWithLazyEvaluation.jpg")
86    
87     class TestEllipsoidOnPlaneClip(unittest.TestCase, TestEllipsoidWithLazyEvaluation):
88     def testEllipsoidOnPlaneClip(self):
89     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
90     y_size = Y_SIZE)
91     self.scene = s
92    
93     dc1 = DataCollector(source = Source.XML)
94    
95     # Create on ellipsoid on plane clip instance.
96     eopc = EllipsoidOnPlaneClip(scene = s, data_collector = dc1,
97     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
98     eopc.setScaleFactor(scale_factor = 0.1)
99     eopc.setPlaneToXY()
100     eopc.rotateX(angle = 10)
101    
102     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
103     c1.bottomView()
104     c1.azimuth(angle = -90)
105     c1.elevation(angle = 20)
106    
107     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
108     FILE_3D))
109    
110     self.render("TestEllipsoidOnPlaneClipWithLazyEvaluation.jpg")
111    
112    
113     ##############################################################################
114    
115    
116     if __name__ == '__main__':
117     suite = unittest.TestSuite()
118 jongui 1151 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestEllipsoidScaleResolution))
119 jongui 1148 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestEllipsoidOnPlaneCut))
120     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestEllipsoidOnPlaneClip))
121     unittest.TextTestRunner(verbosity=2).run(suite)
122    

  ViewVC Help
Powered by ViewVC 1.1.26