/[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 1811 - (hide annotations)
Thu Sep 25 23:11:13 2008 UTC (11 years ago) by ksteube
File MIME type: text/x-python
File size: 4601 byte(s)
Copyright updated in all files

1 ksteube 1811
2     ########################################################
3     #
4     # Copyright (c) 2003-2008 by University of Queensland
5     # Earth Systems Science Computational Center (ESSCC)
6     # http://www.uq.edu.au/esscc
7     #
8     # Primary Business: Queensland, Australia
9     # Licensed under the Open Software License version 3.0
10     # http://www.opensource.org/licenses/osl-3.0.php
11     #
12     ########################################################
13    
14     __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15     Earth Systems Science Computational Center (ESSCC)
16     http://www.uq.edu.au/esscc
17     Primary Business: Queensland, Australia"""
18     __license__="""Licensed under the Open Software License version 3.0
19     http://www.opensource.org/licenses/osl-3.0.php"""
20     __url__="http://www.uq.edu.au/esscc/escript-finley"
21    
22 jongui 1148 from esys.pyvisi import DataCollector, Scene, Contour, ContourOnPlaneCut
23     from esys.pyvisi import ContourOnPlaneClip, Camera
24     from esys.pyvisi.constant import *
25 gross 1381 import unittest, os, sys
26 jongui 1148 from stat import ST_SIZE
27    
28     try:
29     PYVISI_WORKDIR=os.environ['PYVISI_WORKDIR']
30     except KeyError:
31     PYVISI_WORKDIR='.'
32     try:
33     PYVISI_TEST_DATA_ROOT=os.environ['PYVISI_TEST_DATA_ROOT']
34     except KeyError:
35     PYVISI_TEST_DATA_ROOT='.'
36    
37     PYVISI_TEST_MESHES_PATH = os.path.join(PYVISI_TEST_DATA_ROOT, "data_meshes")
38     PYVISI_TEST_CONTOUR_IMAGES_PATH = os.path.join(PYVISI_WORKDIR, \
39     "data_sample_images", "contour")
40    
41     MIN_IMAGE_SIZE = 100
42     FILE_3D = "interior_3D.xml"
43     X_SIZE = 400
44     Y_SIZE = 400
45     JPG_RENDERER = Renderer.OFFLINE_JPG
46    
47     class TestContourWithLazyEvaluation:
48     def render(self, file):
49     self.scene.render(image_name = \
50     os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, file))
51    
52     self.failUnless(os.stat(os.path.join(PYVISI_TEST_CONTOUR_IMAGES_PATH, \
53     file))[ST_SIZE] > MIN_IMAGE_SIZE)
54    
55 jongui 1151 class TestContourGenerate(unittest.TestCase, TestContourWithLazyEvaluation):
56 jongui 1158 def tearDown(self):
57     del self.scene
58    
59 jongui 1151 def testContourGenerate(self):
60 jongui 1148 s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
61     y_size = Y_SIZE)
62     self.scene = s
63    
64     dc1 = DataCollector(source = Source.XML)
65    
66     # Create one contour instance.
67     ctr1 = Contour(scene = s, data_collector = dc1,
68     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
69     ctr1.generateContours(contours = 6, lower_range = 0, upper_range = 0.5)
70    
71     cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
72     cam1.elevation(angle = -40)
73    
74     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
75     FILE_3D))
76     self.render("TestContourWithLazyEvaluation.jpg")
77    
78    
79     class TestContourOnPlaneCut(unittest.TestCase, TestContourWithLazyEvaluation):
80 jongui 1158 def tearDown(self):
81     del self.scene
82    
83 jongui 1148 def testContourOnPlaneCut(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 plane cut instance.
91     ctropc1 = ContourOnPlaneCut(scene = s, data_collector = dc1,
92     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, outline = True)
93     ctropc1.setPlaneToXY(offset = 0.2)
94    
95     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
96     c1.elevation(angle = -45)
97    
98     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH, \
99     FILE_3D))
100     ctropc1.generateContours(contours = 8)
101    
102     self.render("TestContourOnPlaneCutWithLazyEvaluation.jpg")
103    
104     class TestContourOnPlaneClip(unittest.TestCase, TestContourWithLazyEvaluation):
105 jongui 1158 def tearDown(self):
106     del self.scene
107    
108 jongui 1148 def testContourOnPlaneClip(self):
109     s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
110     y_size = Y_SIZE)
111     self.scene = s
112    
113     dc1 = DataCollector(source = Source.XML)
114    
115     # Create one contour on plance clip instance.
116     ctropc1 = ContourOnPlaneClip(scene = s, data_collector = dc1,
117     viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR,
118     outline = True)
119     ctropc1.setPlaneToXY()
120     ctropc1.rotateY(angle = 10)
121     ctropc1.generateContours(contours = 8)
122    
123     c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST)
124     c1.elevation(angle = -40)
125    
126     dc1.setFileName(file_name = os.path.join(PYVISI_TEST_MESHES_PATH,
127     FILE_3D))
128     self.render("TestContourOnPlaneClipWithLazyEvaluation.jpg")
129    
130    
131     ##############################################################################
132    
133    
134     if __name__ == '__main__':
135     suite = unittest.TestSuite()
136 jongui 1151 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContourGenerate))
137 jongui 1148 suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContourOnPlaneCut))
138     suite.addTest(unittest.TestLoader().loadTestsFromTestCase(TestContourOnPlaneClip))
139 gross 1376 s=unittest.TextTestRunner(verbosity=2).run(suite)
140     if not s.wasSuccessful(): sys.exit(1)
141 jongui 1148

  ViewVC Help
Powered by ViewVC 1.1.26