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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1199 - (show annotations)
Wed Jun 20 05:01:30 2007 UTC (12 years, 1 month ago) by jongui
File MIME type: text/x-python
File size: 2795 byte(s)
- Updated the epydocs and guide.
Deleted redundant files and methods.
Tidied up the codes.
1 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_EXPORTER_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
18 "data_sample_images", "exporter")
19
20 MIN_IMAGE_SIZE = 100
21 FILE_3D = "interior_3D.xml"
22 X_SIZE = 400
23 Y_SIZE = 400
24 VRML_RENDERER = Renderer.OFFLINE_VRML
25 IV_RENDERER = Renderer.OFFLINE_IV
26
27 class TestExporter:
28 def render(self, file):
29 self.scene.render(image_name = \
30 os.path.join(PYVISI_TEST_EXPORTER_IMAGES_PATH, file))
31
32 self.failUnless(os.stat(os.path.join \
33 (PYVISI_TEST_EXPORTER_IMAGES_PATH, \
34 file))[ST_SIZE] > MIN_IMAGE_SIZE)
35
36 class TestVRMLExporter(unittest.TestCase, TestExporter):
37 def tearDown(self):
38 del self.scene
39
40 def testVRMLExporter(self):
41 s = Scene(renderer = VRML_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("TestVRMLExporter.wrl")
58
59 class TestIVExporter(unittest.TestCase, TestExporter):
60 def tearDown(self): del self.scene
61
62 def testIVExporter(self):
63 s = Scene(renderer = IV_RENDERER, num_viewport = 1, x_size = X_SIZE,
64 y_size = Y_SIZE)
65 self.scene = s
66
67 dc1 = DataCollector(source = Source.XML)
68
69 # Create one contour on plane cut instance.
70 ctropc1 = ContourOnPlaneCut(scene = s, data_collector = dc1,
71 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
72 ctropc1.setPlaneToXY(offset = 0.2)
73
74 c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
75 c1.elevation(angle = -45)
76
77 dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
78 FILE_3D))
79 ctropc1.generateContours(contours = 8)
80
81 self.render("TestIVExporter.iv")
82
83
84 ##############################################################################
85
86
87 if __name__ == '__main__':
88 suite = unittest.TestSuite()
89 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestVRMLExporter))
90 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestIVExporter))
91 unittest.TextTestRunner(verbosity=2).run(suite)
92

  ViewVC Help
Powered by ViewVC 1.1.26