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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1381 - (show annotations)
Wed Jan 9 07:59:15 2008 UTC (11 years, 10 months ago) by gross
File MIME type: text/x-python
File size: 2086 byte(s)
import sys missing
1 from esys.pyvisi import DataCollector, Scene, Ellipsoid
2 from esys.pyvisi.constant import *
3 import unittest, os, sys
4 from stat import ST_SIZE
5
6 try:
7 PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
8 except KeyError:
9 PYVISI_WORKDIR='.'
10 try:
11 PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
12 except KeyError:
13 PYVISI_TEST_DATA_ROOT='.'
14
15 PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
16 PYVISI_TEST_ELLIPSOID_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
17 "data_sample_images", "ellipsoid")
18
19 MIN_IMAGE_SIZE = 100
20 FILE_3D = "interior_3D.xml"
21 X_SIZE = 400
22 Y_SIZE = 400
23 JPG_RENDERER = Renderer.OFFLINE_JPG
24
25 class TestEllipsoid(unittest.TestCase):
26 def setUp(self):
27 self.scene = \
28 Scene(renderer = JPG_RENDERER, num_viewport = 1,
29 x_size = X_SIZE, y_size = Y_SIZE)
30
31 self.data_collector = DataCollector(source = Source.XML)
32 self.data_collector.setFileName(file_name = \
33 os.path.join(PYVISI_TEST_MESHES_PATH, FILE_3D))
34
35 self.ellipsoid = Ellipsoid(scene = self.scene,
36 data_collector = self.data_collector,
37 viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
38 cell_to_point = False, outline = True)
39
40 def tearDown(self):
41 del self.scene
42 del self.data_collector
43 del self.ellipsoid
44
45 def render(self, file):
46 self.scene.render(image_name = \
47 os.path.join(PYVISI_TEST_ELLIPSOID_IMAGES_PATH, file))
48
49 self.failUnless(os.stat(os.path.join(PYVISI_TEST_ELLIPSOID_IMAGES_PATH,\
50 file))[ST_SIZE] > MIN_IMAGE_SIZE)
51
52 def testSphere(self):
53 self.ellipsoid.setThetaResolution(5)
54 self.ellipsoid.setPhiResolution(10)
55 self.render("TestEllipsoid_testSphere.jpg")
56
57 def testTensorGlyph(self):
58 self.ellipsoid.setScaleFactor(0.2)
59 self.ellipsoid.setMaxScaleFactor(3)
60 self.render("TestEllipsoid_testTensorGlyph.jpg")
61
62
63 ##############################################################################
64
65
66 if __name__ == '__main__':
67 suite = unittest.TestSuite()
68 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestEllipsoid))
69 s=unittest.TextTestRunner(verbosity=2).run(suite)
70 if not s.wasSuccessful(): sys.exit(1)
71

  ViewVC Help
Powered by ViewVC 1.1.26