7 |
\pyvisi is a Python module that is used to generate 2D and 3D visualization |
\pyvisi is a Python module that is used to generate 2D and 3D visualization |
8 |
for escript and its PDE solvers: finley and bruce. This module provides |
for escript and its PDE solvers: finley and bruce. This module provides |
9 |
an easy to use interface to the \VTK library (\VTKUrl). There are three |
an easy to use interface to the \VTK library (\VTKUrl). There are three |
10 |
approaches of rendering an object. (1) Online - object is rendered on-screen |
approaches for rendering an object. (1) Online - object is rendered on-screen |
11 |
with interaction (i.e. zoom and rotate) capability, (2) Offline - object is |
with interaction capability (i.e. zoom and rotate), (2) Offline - object is |
12 |
rendered off-screen (no window comes up) and (3) Display - object is rendered |
rendered off-screen (no pop-up window) and (3) Display - object is rendered |
13 |
on-screen but with no interaction capability (able to produce on-the-fly |
on-screen but with no interaction capability (able to produce on-the-fly |
14 |
animation). All three approaches have the option to save the rendered object |
animation). All three approaches have the option to save the rendered object |
15 |
as an image. |
as an image (i.e. jpg). |
16 |
|
|
17 |
The following points outline the general guidelines when using \pyvisi: |
The following outlines the general guidelines when using Pyvisi: |
18 |
|
|
19 |
\begin{enumerate} |
\begin{enumerate} |
20 |
\item Create a \Scene instance, a window in which objects are to be rendered on. |
\item Create a \Scene instance, a window in which objects are to be rendered on. |
52 |
x_size = 1152, y_size = 864} |
x_size = 1152, y_size = 864} |
53 |
A scene is a window in which objects are to be rendered on. Only |
A scene is a window in which objects are to be rendered on. Only |
54 |
one scene needs to be created. However, a scene may be divided into four |
one scene needs to be created. However, a scene may be divided into four |
55 |
smaller windows called viewports (if needed). Each viewport can |
smaller windows called viewports (if needed). Each viewport in turn can |
56 |
render a different object. |
render a different object. |
57 |
\end{classdesc} |
\end{classdesc} |
58 |
|
|
121 |
|
|
122 |
\subsubsection{\Light class} |
\subsubsection{\Light class} |
123 |
|
|
124 |
\begin{classdesc}{Light}{scene, data_collector, viewport = Viewport.SOUTH_WEST} |
\begin{classdesc}{Light}{scene, viewport = Viewport.SOUTH_WEST} |
125 |
A light controls the lighting for the rendered object and works in |
A light controls the lighting effect for the rendered object and works in |
126 |
a similar way to \Camera. |
a similar way to \Camera. |
127 |
\end{classdesc} |
\end{classdesc} |
128 |
|
|
153 |
for visualization. |
for visualization. |
154 |
|
|
155 |
\subsubsection{\DataCollector class} |
\subsubsection{\DataCollector class} |
156 |
|
\label{DATACOLLECTOR SEC} |
157 |
\begin{classdesc}{DataCollector}{source = Source.XML} |
\begin{classdesc}{DataCollector}{source = Source.XML} |
158 |
A data collector is used to read data either from an XML file (using |
A data collector is used to read data either from a XML file (using |
159 |
\texttt{setFileName()}) or from an escript object directly (using |
\texttt{setFileName()}) or from an escript object directly (using |
160 |
\texttt{setData()}). Writing XML files are expensive, but this approach has |
\texttt{setData()}). Writing XML files are expensive, but this approach has |
161 |
the advantage given that the results can be analyzed easily after the |
the advantage given that the results can be analyzed easily after the |
200 |
|
|
201 |
\begin{classdesc}{Text2D}{scene, text, viewport = Viewport.SOUTH_WEST} |
\begin{classdesc}{Text2D}{scene, text, viewport = Viewport.SOUTH_WEST} |
202 |
A two-dimensional text is used to annotate the rendered object |
A two-dimensional text is used to annotate the rendered object |
203 |
(i.e. adding titles, authors and labels). |
(i.e. inserting titles, authors and labels). |
204 |
\end{classdesc} |
\end{classdesc} |
205 |
|
|
206 |
The following are some of the methods available: |
The following are some of the methods available: |
224 |
|
|
225 |
\subsection{Data Visualization Classes} |
\subsection{Data Visualization Classes} |
226 |
This subsection details the instances used to process and manipulate the source |
This subsection details the instances used to process and manipulate the source |
227 |
data. The typical usage of the classes is also shown. |
data. The typical usage of some of the classes are also shown. |
228 |
|
|
229 |
One point to note is that the source can either be point or cell data. If the |
One point to note is that the source can either be point or cell data. If the |
230 |
source is cell data, a conversion to point data may or may not be |
source is cell data, a conversion to point data may or may not be |
231 |
required, in order for the object to be rendered correctly. |
required, in order for the object to be rendered correctly. |
232 |
If a conversion is needed, the 'cell_to_point' flag (see below) must be set to |
If a conversion is needed, the 'cell_to_point' flag (see below) must |
233 |
'True', otherwise 'False' (which is the default). |
be set to 'True', otherwise 'False' (which is the default). |
234 |
|
|
235 |
\subsubsection{\Map class} |
\subsubsection{\Map class} |
236 |
|
|
250 |
# Import the necessary modules. |
# Import the necessary modules. |
251 |
from esys.pyvisi import Scene, DataCollector, Map, Camera |
from esys.pyvisi import Scene, DataCollector, Map, Camera |
252 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
253 |
|
import os |
254 |
|
|
255 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
256 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
257 |
X_SIZE = 800 |
X_SIZE = 800 |
258 |
Y_SIZE = 800 |
Y_SIZE = 800 |
259 |
|
|
263 |
IMAGE_NAME = "map.jpg" |
IMAGE_NAME = "map.jpg" |
264 |
JPG_RENDERER = Renderer.ONLINE_JPG |
JPG_RENDERER = Renderer.ONLINE_JPG |
265 |
|
|
|
|
|
266 |
# Create a Scene with four viewports. |
# Create a Scene with four viewports. |
267 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = X_SIZE, |
s = Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = X_SIZE, |
268 |
y_size = Y_SIZE) |
y_size = Y_SIZE) |
269 |
|
|
270 |
# Create a DataCollector reading from a XML file. |
# Create a DataCollector reading from a XML file. |
271 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
272 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
273 |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA) |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA) |
274 |
|
|
275 |
# Create a Map for the first viewport. |
# Create a Map for the first viewport. |
278 |
m1.setRepresentationToWireframe() |
m1.setRepresentationToWireframe() |
279 |
|
|
280 |
# Create a Camera for the first viewport |
# Create a Camera for the first viewport |
281 |
c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
282 |
c1.isometricView() |
c1.isometricView() |
283 |
|
|
284 |
# Create a second DataCollector reading from the same XML file but specifying |
# Create a second DataCollector reading from the same XML file but specifying |
285 |
# a different scalar field. |
# a different scalar field. |
286 |
dc2 = DataCollector(source = Source.XML) |
dc2 = DataCollector(source = Source.XML) |
287 |
dc2.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
288 |
dc2.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA) |
dc2.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA) |
289 |
|
|
290 |
# Create a Map for the third viewport. |
# Create a Map for the third viewport. |
291 |
m2 = Map(scene = s, data_collector = dc2, viewport = Viewport.NORTH_EAST, |
m2 = Map(scene = s, data_collector = dc2, viewport = Viewport.NORTH_EAST, |
292 |
lut = Lut.COLOR, cell_to_point = True, outline = True) |
lut = Lut.COLOR, cell_to_point = True, outline = True) |
293 |
|
|
294 |
|
# Create a Camera for the third viewport |
295 |
|
c1 = Camera(scene = s, viewport = Viewport.NORTH_EAST) |
296 |
|
|
297 |
# Render the object. |
# Render the object. |
298 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME)) |
299 |
\end{python} |
\end{python} |
300 |
|
|
301 |
\subsubsection{\MapOnPlaneCut class} |
\subsubsection{\MapOnPlaneCut class} |
337 |
|
|
338 |
\subsubsection{\Velocity class} |
\subsubsection{\Velocity class} |
339 |
|
|
340 |
\begin{classdesc}{Velocity}{scene, data_collector, |
\begin{classdesc}{Velocity}{scene, data_collector, arrow = Arrow.TWO_D, |
341 |
viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR, |
color_mode = ColorMode.VECTOR, viewport = Viewport.SOUTH_WEST, |
342 |
arrow = Arrow.TWO_D, lut = Lut.COLOR, cell_to_point = False, outline = True} |
lut = Lut.COLOR, cell_to_point = False, outline = True} |
343 |
Class that shows a vector field using arrows. The arrows can either be |
Class that shows a vector field using arrows. The arrows can either be |
344 |
colored or grey-scaled, depending on the lookup table used. If the arrows |
colored or grey-scaled, depending on the lookup table used. If the arrows |
345 |
are colored, there are two possible coloring modes, either using vector data or |
are colored, there are two possible coloring modes, either using vector data or |
369 |
# Import the necessary modules |
# Import the necessary modules |
370 |
from esys.pyvisi import Scene, DataCollector, VelocityOnPlaneCut, Camera |
from esys.pyvisi import Scene, DataCollector, VelocityOnPlaneCut, Camera |
371 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
372 |
|
import os |
373 |
|
|
374 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
375 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
376 |
X_SIZE = 400 |
X_SIZE = 400 |
377 |
Y_SIZE = 400 |
Y_SIZE = 400 |
378 |
|
|
381 |
IMAGE_NAME = "velocity.jpg" |
IMAGE_NAME = "velocity.jpg" |
382 |
JPG_RENDERER = Renderer.ONLINE_JPG |
JPG_RENDERER = Renderer.ONLINE_JPG |
383 |
|
|
|
|
|
384 |
# Create a Scene with four viewports |
# Create a Scene with four viewports |
385 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
386 |
y_size = Y_SIZE) |
y_size = Y_SIZE) |
387 |
|
|
388 |
# Create a DataCollector reading from a XML file. |
# Create a DataCollector reading from a XML file. |
389 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
390 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
391 |
dc1.setActiveVector(vector = VECTOR_FIELD_CELL_DATA) |
dc1.setActiveVector(vector = VECTOR_FIELD_CELL_DATA) |
392 |
|
|
393 |
# Create VelocityOnPlaneCut. |
# Create VelocityOnPlaneCut. |
401 |
vopc1.randomOn() |
vopc1.randomOn() |
402 |
|
|
403 |
# Create a Camera. |
# Create a Camera. |
404 |
c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
405 |
c1.isometricView() |
c1.isometricView() |
406 |
c1.elevation(angle = -20) |
c1.elevation(angle = -20) |
407 |
|
|
408 |
# Render the object. |
# Render the object. |
409 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME)) |
410 |
\end{python} |
\end{python} |
411 |
|
|
412 |
\subsubsection{\VelocityOnPlaneClip class} |
\subsubsection{\VelocityOnPlaneClip class} |
467 |
# Import the necessary modules |
# Import the necessary modules |
468 |
from esys.pyvisi import Scene, DataCollector, EllipsoidOnPlaneClip, Camera |
from esys.pyvisi import Scene, DataCollector, EllipsoidOnPlaneClip, Camera |
469 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
470 |
|
import os |
471 |
|
|
472 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
473 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
474 |
X_SIZE = 400 |
X_SIZE = 400 |
475 |
Y_SIZE = 400 |
Y_SIZE = 400 |
476 |
|
|
485 |
|
|
486 |
# Create a DataCollector reading from a XML file. |
# Create a DataCollector reading from a XML file. |
487 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
488 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
489 |
dc1.setActiveTensor(tensor = TENSOR_FIELD_CELL_DATA) |
dc1.setActiveTensor(tensor = TENSOR_FIELD_CELL_DATA) |
490 |
|
|
491 |
# Create a EllipsoidOnPlaneClip. |
# Create a EllipsoidOnPlaneClip. |
497 |
eopc1.rotateX(angle = 10) |
eopc1.rotateX(angle = 10) |
498 |
|
|
499 |
# Create a camera. |
# Create a camera. |
500 |
c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
501 |
c1.bottomView() |
c1.bottomView() |
502 |
c1.azimuth(angle = -90) |
c1.azimuth(angle = -90) |
503 |
c1.elevation(angle = 10) |
c1.elevation(angle = 10) |
504 |
|
|
505 |
# Render the object. |
# Render the object. |
506 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME)) |
507 |
\end{python} |
\end{python} |
508 |
|
|
509 |
\subsubsection{\Contour class} |
\subsubsection{\Contour class} |
525 |
# Import the necessary modules |
# Import the necessary modules |
526 |
from esys.pyvisi import Scene, DataCollector, Contour, Camera |
from esys.pyvisi import Scene, DataCollector, Contour, Camera |
527 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
528 |
|
import os |
529 |
|
|
530 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
531 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
532 |
X_SIZE = 400 |
X_SIZE = 400 |
533 |
Y_SIZE = 400 |
Y_SIZE = 400 |
534 |
|
|
537 |
IMAGE_NAME = "contour.jpg" |
IMAGE_NAME = "contour.jpg" |
538 |
JPG_RENDERER = Renderer.ONLINE_JPG |
JPG_RENDERER = Renderer.ONLINE_JPG |
539 |
|
|
|
|
|
540 |
# Create a Scene. |
# Create a Scene. |
541 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
542 |
y_size = Y_SIZE) |
y_size = Y_SIZE) |
543 |
|
|
544 |
# Create a DataCollector reading a XML file. |
# Create a DataCollector reading a XML file. |
545 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
546 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
547 |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA) |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA) |
548 |
|
|
549 |
# Create a Contour. |
# Create a Contour. |
552 |
ctr1.generateContours(contours = 3) |
ctr1.generateContours(contours = 3) |
553 |
|
|
554 |
# Create a Camera. |
# Create a Camera. |
555 |
cam1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
556 |
cam1.elevation(angle = -40) |
cam1.elevation(angle = -40) |
557 |
|
|
558 |
# Render the object. |
# Render the object. |
559 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME)) |
560 |
\end{python} |
\end{python} |
561 |
|
|
562 |
\subsubsection{\ContourOnPlaneCut class} |
\subsubsection{\ContourOnPlaneCut class} |
587 |
|
|
588 |
\begin{classdesc}{StreamLine}{scene, data_collector, |
\begin{classdesc}{StreamLine}{scene, data_collector, |
589 |
viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR, lut = Lut.COLOR, |
viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR, lut = Lut.COLOR, |
590 |
outline = True} |
cell_to_point = False, outline = True} |
591 |
Class that shows the direction of particles of a vector field using streamlines. |
Class that shows the direction of particles of a vector field using streamlines. |
592 |
The streamlines can either be colored or grey-scaled, depending on the lookup |
The streamlines can either be colored or grey-scaled, depending on the lookup |
593 |
table used. If the streamlines are colored, there are two possible coloring |
table used. If the streamlines are colored, there are two possible coloring |
603 |
# Import the necessary modules. |
# Import the necessary modules. |
604 |
from esys.pyvisi import Scene, DataCollector, StreamLine, Camera |
from esys.pyvisi import Scene, DataCollector, StreamLine, Camera |
605 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
606 |
|
import os |
607 |
|
|
608 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
609 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
610 |
X_SIZE = 400 |
X_SIZE = 400 |
611 |
Y_SIZE = 400 |
Y_SIZE = 400 |
612 |
|
|
615 |
IMAGE_NAME = "streamline.jpg" |
IMAGE_NAME = "streamline.jpg" |
616 |
JPG_RENDERER = Renderer.ONLINE_JPG |
JPG_RENDERER = Renderer.ONLINE_JPG |
617 |
|
|
|
|
|
618 |
# Create a Scene. |
# Create a Scene. |
619 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
620 |
y_size = Y_SIZE) |
y_size = Y_SIZE) |
621 |
|
|
622 |
# Create a DataCollector reading from a XML file. |
# Create a DataCollector reading from a XML file. |
623 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
624 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
625 |
|
|
626 |
# Create a Streamline. |
# Create a Streamline. |
627 |
sl1 = StreamLine(scene = s, data_collector = dc1, |
sl1 = StreamLine(scene = s, data_collector = dc1, |
630 |
sl1.setTubeRadius(radius = 0.02) |
sl1.setTubeRadius(radius = 0.02) |
631 |
|
|
632 |
# Create a Camera. |
# Create a Camera. |
633 |
c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
634 |
c1.isometricView() |
c1.isometricView() |
635 |
|
|
636 |
# Render the object. |
# Render the object. |
637 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME)) |
638 |
\end{python} |
\end{python} |
639 |
|
|
640 |
\subsubsection{\Carpet class} |
\subsubsection{\Carpet class} |
641 |
|
|
642 |
\begin{classdesc}{Carpet}{scene, data_collector, |
\begin{classdesc}{Carpet}{scene, data_collector, |
643 |
viewport = Viewport.Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR, |
viewport = Viewport.Viewport.SOUTH_WEST, warp_mode = WarpMode.SCALAR, |
644 |
lut = Lut.COLOR, outline = True} |
lut = Lut.COLOR, cell_to_point = False, outline = True} |
645 |
This class works in a similar way to \MapOnPlaneCut, except that it shows a |
This class works in a similar way to \MapOnPlaneCut, except that it shows a |
646 |
scalar field cut on a plane and deformated (warp) along the normal. The |
scalar field cut on a plane and deformated (warp) along the normal. The |
647 |
plane can either be colored or grey-scaled, depending on the lookup table used. |
plane can either be colored or grey-scaled, depending on the lookup table used. |
657 |
# Import the necessary modules. |
# Import the necessary modules. |
658 |
from esys.pyvisi import Scene, DataCollector, Carpet, Camera |
from esys.pyvisi import Scene, DataCollector, Carpet, Camera |
659 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
660 |
|
import os |
661 |
|
|
662 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
663 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
664 |
X_SIZE = 400 |
X_SIZE = 400 |
665 |
Y_SIZE = 400 |
Y_SIZE = 400 |
666 |
|
|
675 |
|
|
676 |
# Create a DataCollector reading from a XML file. |
# Create a DataCollector reading from a XML file. |
677 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
678 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
679 |
dc1.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA) |
dc1.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA) |
680 |
|
|
681 |
# Create a Carpet. |
# Create a Carpet. |
686 |
cpt1.setScaleFactor(1.9) |
cpt1.setScaleFactor(1.9) |
687 |
|
|
688 |
# Create a Camera. |
# Create a Camera. |
689 |
c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
690 |
c1.isometricView() |
c1.isometricView() |
691 |
|
|
692 |
# Render the object. |
# Render the object. |
693 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME)) |
694 |
\end{python} |
\end{python} |
695 |
|
|
696 |
\subsubsection{\Image class} |
\subsubsection{\Image class} |
709 |
|
|
710 |
\begin{python} |
\begin{python} |
711 |
# Import the necessary modules. |
# Import the necessary modules. |
712 |
from esys.pyvisi import Scene, DataCollector, StreamLine, Camera |
from esys.pyvisi import Scene, DataCollector, Map, ImageReader, Image, Camera |
713 |
|
from esys.pyvisi import GlobalPosition |
714 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
715 |
|
import os |
716 |
|
|
717 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
718 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
719 |
X_SIZE = 400 |
X_SIZE = 400 |
720 |
Y_SIZE = 400 |
Y_SIZE = 400 |
721 |
|
|
722 |
VECTOR_FIELD_CELL_DATA = "temperature" |
SCALAR_FIELD_POINT_DATA = "temperature" |
723 |
FILE_3D = "interior_3D.xml" |
FILE_3D = "interior_3D.xml" |
724 |
IMAGE_NAME = "streamline.jpg" |
LOAD_IMAGE_NAME = "flinders.jpg" |
725 |
|
SAVE_IMAGE_NAME = "image.jpg" |
726 |
JPG_RENDERER = Renderer.ONLINE_JPG |
JPG_RENDERER = Renderer.ONLINE_JPG |
727 |
|
|
|
|
|
728 |
# Create a Scene. |
# Create a Scene. |
729 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
730 |
y_size = Y_SIZE) |
y_size = Y_SIZE) |
731 |
|
|
732 |
# Create a DataCollector reading from a XML file. |
# Create a DataCollector reading from a XML file. |
733 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
734 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
735 |
|
|
736 |
# Create a Streamline. |
# Create a Map. |
737 |
sl1 = StreamLine(scene = s, data_collector = dc1, |
m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST, |
|
viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR, |
|
738 |
lut = Lut.COLOR, cell_to_point = False, outline = True) |
lut = Lut.COLOR, cell_to_point = False, outline = True) |
739 |
sl1.setTubeRadius(radius = 0.02) |
m1.setOpacity(0.3) |
740 |
|
|
741 |
# Create a Camera. |
# Create an ImageReader (in place of DataCollector). |
742 |
c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
ir = ImageReader(ImageFormat.JPG) |
743 |
c1.isometricView() |
ir.setImageName(image_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \ |
744 |
|
LOAD_IMAGE_NAME)) |
745 |
|
|
746 |
|
# Create an Image. |
747 |
|
i = Image(scene = s, image_reader = ir, viewport = Viewport.SOUTH_WEST) |
748 |
|
i.setOpacity(opacity = 0.9) |
749 |
|
i.translate(0,0,-1) |
750 |
|
i.setPoint1(GlobalPosition(2,0,0)) |
751 |
|
i.setPoint2(GlobalPosition(0,2,0)) |
752 |
|
|
753 |
# Render the object. |
# Create a Camera. |
754 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME) |
c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
755 |
|
|
756 |
|
# Render the image. |
757 |
|
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, SAVE_IMAGE_NAME)) |
758 |
\end{python} |
\end{python} |
759 |
|
|
760 |
\subsubsection{\Logo class} |
\subsubsection{\Logo class} |
761 |
|
|
762 |
\begin{classdesc}{Logo}{scene, image_reader, viewport = Viewport.SOUTH_WEST} |
\begin{classdesc}{Logo}{scene, image_reader, viewport = Viewport.SOUTH_WEST} |
763 |
Class that displays a static image in particular a logo |
Class that displays a static image, in particular a logo |
764 |
(i.e. company symbol) and has NO interaction capability. |
(i.e. company symbol) and has NO interaction capability. The position and size |
765 |
|
of the logo can be specified. |
766 |
\end{classdesc} |
\end{classdesc} |
767 |
|
|
768 |
The following are some of the methods available:\\ |
The following are some of the methods available:\\ |
789 |
|
|
790 |
\subsection{Supporting Classes} |
\subsection{Supporting Classes} |
791 |
This subsection details the supporting classes inherited by the data |
This subsection details the supporting classes inherited by the data |
792 |
visualization classes and their available methods. |
visualization classes (see Section \ref{DATACOLLECTOR SEC}) and their |
793 |
|
available methods. |
794 |
|
|
795 |
\subsubsection{\ActorThreeD class} |
\subsubsection{\ActorThreeD class} |
796 |
|
|
910 |
\end{methoddesc} |
\end{methoddesc} |
911 |
|
|
912 |
\begin{methoddesc}[Sphere]{setPhiResolution}{resolution} |
\begin{methoddesc}[Sphere]{setPhiResolution}{resolution} |
913 |
Set the phi resoluton of the sphere. |
Set the phi resolution of the sphere. |
914 |
\end{methoddesc} |
\end{methoddesc} |
915 |
|
|
916 |
\subsubsection{\StreamLineModule class} |
\subsubsection{\StreamLineModule class} |
999 |
The following are some of the methods available: |
The following are some of the methods available: |
1000 |
|
|
1001 |
\begin{methoddesc}[ImageReslice]{setSize}{size} |
\begin{methoddesc}[ImageReslice]{setSize}{size} |
1002 |
Set the size of the image, between 0 and 2. Size 1 (one) displays the |
Set the size of the image (logo in particular), between 0 and 2. Size 1 (one) |
1003 |
image in its original size (which is the default). |
displays the image in its original size (which is the default). |
1004 |
\end{methoddesc} |
\end{methoddesc} |
1005 |
|
|
1006 |
|
|
1016 |
# Import the necessary modules. |
# Import the necessary modules. |
1017 |
from esys.pyvisi import Scene, DataCollector, Contour, Camera |
from esys.pyvisi import Scene, DataCollector, Contour, Camera |
1018 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
1019 |
|
import os |
1020 |
|
|
1021 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
1022 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
1023 |
X_SIZE = 400 |
X_SIZE = 400 |
1024 |
Y_SIZE = 300 |
Y_SIZE = 300 |
1025 |
|
|
1031 |
IMAGE_NAME = "seriesofreads" |
IMAGE_NAME = "seriesofreads" |
1032 |
JPG_RENDERER = Renderer.ONLINE_JPG |
JPG_RENDERER = Renderer.ONLINE_JPG |
1033 |
|
|
|
|
|
1034 |
# Create a Scene. |
# Create a Scene. |
1035 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
1036 |
y_size = Y_SIZE) |
y_size = Y_SIZE) |
1039 |
# be assigned when the DataCollector is created, although the same file is |
# be assigned when the DataCollector is created, although the same file is |
1040 |
# read again in the for-loop. |
# read again in the for-loop. |
1041 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
1042 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FIRST_FILE_NAME) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \ |
1043 |
|
FIRST_FILE_NAME)) |
1044 |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1) |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_1) |
1045 |
|
|
1046 |
# Create a Contour. |
# Create a Contour. |
1049 |
outline = True) |
outline = True) |
1050 |
mosc1.generateContours(0) |
mosc1.generateContours(0) |
1051 |
|
|
1052 |
# Create a second DataCollector reading from the same XML file. An initial |
# Create a second DataCollector reading from the same XML file. |
|
# file must always be assigned when the DataCollector is created, |
|
|
# although the same file is read again in the for-loop. |
|
1053 |
dc2 = DataCollector(source = Source.XML) |
dc2 = DataCollector(source = Source.XML) |
1054 |
dc2.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FIRST_FILE_NAME) |
dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \ |
1055 |
|
FIRST_FILE_NAME)) |
1056 |
dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2) |
dc2.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA_2) |
1057 |
|
|
1058 |
# Create a second Contour. |
# Create a second Contour. |
1064 |
# Create a Camera. |
# Create a Camera. |
1065 |
cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
cam1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
1066 |
|
|
1067 |
# Read in one file one after another and render the object. |
# Read in one file one after another and render the object. |
1068 |
for i in range(99, 104): |
for i in range(99, 104): |
1069 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_2D + |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \ |
1070 |
"%04d.vtu" % i) |
FILE_2D + "%04d.vtu") % i) |
1071 |
dc2.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_2D + |
dc2.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, \ |
1072 |
"%04d.vtu" % i) |
FILE_2D + "%04d.vtu") % i) |
1073 |
|
|
1074 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME + "%04d.jpg" % i) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, \ |
1075 |
|
IMAGE_NAME + "%04d.jpg") % i) |
1076 |
\end{python} |
\end{python} |
1077 |
|
|
1078 |
\textsf{Manipulating A Single File with A Series of Translation} |
\textsf{Manipulating A Single File with A Series of Translation} |
1081 |
# Import the necessary modules. |
# Import the necessary modules. |
1082 |
from esys.pyvisi import Scene, DataCollector, MapOnPlaneCut, Camera |
from esys.pyvisi import Scene, DataCollector, MapOnPlaneCut, Camera |
1083 |
from esys.pyvisi.constant import * |
from esys.pyvisi.constant import * |
1084 |
|
import os |
1085 |
|
|
1086 |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/" |
PYVISI_EXAMPLE_MESHES_PATH = "data_meshes" |
1087 |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/" |
PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images" |
1088 |
X_SIZE = 400 |
X_SIZE = 400 |
1089 |
Y_SIZE = 400 |
Y_SIZE = 400 |
1090 |
|
|
1093 |
IMAGE_NAME = "seriesofcuts" |
IMAGE_NAME = "seriesofcuts" |
1094 |
JPG_RENDERER = Renderer.ONLINE_JPG |
JPG_RENDERER = Renderer.ONLINE_JPG |
1095 |
|
|
|
|
|
1096 |
# Create a Scene. |
# Create a Scene. |
1097 |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE, |
1098 |
y_size = Y_SIZE) |
y_size = Y_SIZE) |
1099 |
|
|
1100 |
# Create a DataCollector reading from a XML file. |
# Create a DataCollector reading from a XML file. |
1101 |
dc1 = DataCollector(source = Source.XML) |
dc1 = DataCollector(source = Source.XML) |
1102 |
dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D) |
dc1.setFileName(file_name = os.path.join(PYVISI_EXAMPLE_MESHES_PATH, FILE_3D)) |
1103 |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA) |
dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA) |
1104 |
|
|
1105 |
# Create a MapOnPlaneCut. |
# Create a MapOnPlaneCut. |
1109 |
mopc1.setPlaneToYZ(offset = 0.1) |
mopc1.setPlaneToYZ(offset = 0.1) |
1110 |
|
|
1111 |
# Create a Camera. |
# Create a Camera. |
1112 |
c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST) |
c1 = Camera(scene = s, viewport = Viewport.SOUTH_WEST) |
1113 |
c1.isometricView() |
c1.isometricView() |
1114 |
|
|
1115 |
# Render the object with multiple cuts from a series of translation. |
# Render the object with multiple cuts from a series of translation. |
1116 |
for i in range(0, 5): |
for i in range(0, 5): |
1117 |
s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME + "%02d.jpg" % i) |
s.render(image_name = os.path.join(PYVISI_EXAMPLE_IMAGES_PATH, IMAGE_NAME + |
1118 |
|
"%02d.jpg") % i) |
1119 |
mopc1.translate(0.6,0,0) |
mopc1.translate(0.6,0,0) |
1120 |
\end{python} |
\end{python} |
1121 |
|
|
1123 |
This section shows some of the useful keys when interacting with the rendered |
This section shows some of the useful keys when interacting with the rendered |
1124 |
object. |
object. |
1125 |
|
|
1126 |
\begin{table} |
\begin{table}[h] |
1127 |
\begin{center} |
\begin{center} |
1128 |
\begin{tabular}{| c | p{13cm} |} |
\begin{tabular}{| c | p{13cm} |} |
1129 |
\hline |
\hline |
1141 |
object's element (if in object mode). \\ \hline |
object's element (if in object mode). \\ \hline |
1142 |
Keypress 3 & Toggle the render window in and out of stereo mode. By default, |
Keypress 3 & Toggle the render window in and out of stereo mode. By default, |
1143 |
red-blue stereo pairs are created. \\ \hline |
red-blue stereo pairs are created. \\ \hline |
1144 |
Keypress 'e' / 'q' & Exit the application if only one file is to be read or |
Keypress 'e' / 'q' & Exit the application if only one file is to be read, or |
1145 |
read and display the next file if multiple files are to be read. \\ \hline |
read and display the next file if multiple files are to be read. \\ \hline |
1146 |
Keypress 's' & Modify the representation of the rendered object to surfaces. |
Keypress 's' & Modify the representation of the rendered object to surfaces. |
1147 |
\\ \hline |
\\ \hline |
1156 |
|
|
1157 |
|
|
1158 |
\section{Sample Output} |
\section{Sample Output} |
1159 |
The following section displays a list of sample outputs. |
This section displays thumbnails of sample output. |
1160 |
|
|
1161 |
\begin{table}[h] |
\begin{table}[h] |
1162 |
\begin{tabular}{c c c} |
\begin{tabular}{c c c} |