/[escript]/trunk/doc/user/pyvisi.tex
ViewVC logotype

Diff of /trunk/doc/user/pyvisi.tex

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1079 by jongui, Tue Apr 10 04:27:31 2007 UTC revision 1081 by jongui, Wed Apr 11 06:13:46 2007 UTC
# Line 29  lighting effects. Line 29  lighting effects.
29  \end{enumerate}  \end{enumerate}
30  \begin{center}  \begin{center}
31  \begin{math}  \begin{math}
32  scene \rightarrow data input \rightarrow data visualization \rightarrow  scene \rightarrow data \; input \rightarrow data \; visualization \rightarrow
33  camera/light \rightarrow render  camer \, / \, light \rightarrow render
34  \end{math}  \end{math}
35  \end{center}  \end{center}
36    
# Line 253  can either be colored or grey-scaled, de Line 253  can either be colored or grey-scaled, de
253  The following are some of the methods available:\\  The following are some of the methods available:\\
254  Methods from \ActorThreeD.  Methods from \ActorThreeD.
255    
256    A typical usage of \Map is shown below, which can be found in
257    \texttt{\PyvisiExampleDirectory}.
258    
259    \begin{python}
260    # Import the necessary modules.
261    from esys.pyvisi import Scene, DataCollector, Map, Camera
262    from esys.pyvisi.constant import *
263    
264    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
265    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
266    X_SIZE = 800
267    Y_SIZE = 800
268    
269    SCALAR_FIELD_POINT_DATA = "temperature"
270    SCALAR_FIELD_CELL_DATA = "temperature_cell"
271    FILE_3D = "interior_3D.xml"
272    IMAGE_NAME = "map.jpg"
273    JPG_RENDERER = Renderer.ONLINE_JPG
274    
275    
276    # Create a Scene with four viewports.
277    s = Scene(renderer = JPG_RENDERER, num_viewport = 4, x_size = X_SIZE,
278            y_size = Y_SIZE)
279    
280    # Create a DataCollector reading from a XML file.
281    dc1 = DataCollector(source = Source.XML)
282    dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
283    dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
284    
285    # Create a  Map for the first viewport.
286    m1 = Map(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
287            lut = Lut.COLOR, cell_to_point = False, outline = True)
288    m1.setRepresentationToWireframe()
289    
290    # Create a Camera for the first viewport
291    c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
292    c1.isometricView()
293    
294    # Create a second DataCollector reading from the same XML file but specifying
295    # a different scalar field.
296    dc2 = DataCollector(source = Source.XML)
297    dc2.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
298    dc2.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA)
299    
300    # Create a Map for the third viewport.
301    m2 = Map(scene = s, data_collector = dc2, viewport = Viewport.NORTH_EAST,
302            lut = Lut.COLOR, cell_to_point = True, outline = True)
303    
304    # Render the object.
305    s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME)
306    \end{python}
307    
308  \subsubsection{\MapOnPlaneCut class}  \subsubsection{\MapOnPlaneCut class}
309    
310  \begin{classdesc}{MapOnPlaneCut}{scene, data_collector,  \begin{classdesc}{MapOnPlaneCut}{scene, data_collector,
# Line 318  it shows a vector field using arrows cut Line 370  it shows a vector field using arrows cut
370  The following are some of the methods available:\\  The following are some of the methods available:\\
371  Methods from \ActorThreeD, \GlyphThreeD, \Transform and \MaskPoints.  Methods from \ActorThreeD, \GlyphThreeD, \Transform and \MaskPoints.
372    
373    A typical usage of \VelocityOnPlaneCut is shown below, which can be found in
374    \texttt{\PyvisiExampleDirectory}.
375    
376    \begin{python}
377    # Import the necessary modules
378    from esys.pyvisi import Scene, DataCollector, VelocityOnPlaneCut, Camera
379    from esys.pyvisi.constant import *
380    
381    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
382    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
383    X_SIZE = 400
384    Y_SIZE = 400
385    
386    VECTOR_FIELD_CELL_DATA = "velocity"
387    FILE_3D = "interior_3D.xml"
388    IMAGE_NAME = "velocity.jpg"
389    JPG_RENDERER = Renderer.ONLINE_JPG
390    
391    
392    # Create a Scene with four viewports
393    s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
394            y_size = Y_SIZE)
395    
396    # Create a DataCollector reading from a XML file.
397    dc1 = DataCollector(source = Source.XML)
398    dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
399    dc1.setActiveVector(vector = VECTOR_FIELD_CELL_DATA)
400    
401    # Create VelocityOnPlaneCut.
402    vopc1 = VelocityOnPlaneCut(scene = s, data_collector = dc1,
403            viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.VECTOR,
404            arrow = Arrow.THREE_D, lut = Lut.COLOR, cell_to_point = False,
405            outline = True)
406    vopc1.setScaleFactor(scale_factor = 0.5)
407    vopc1.setPlaneToXY(offset = 0.5)
408    vopc1.setRatio(2)
409    vopc1.randomOn()
410    
411    # Create a Camera.
412    c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
413    c1.isometricView()
414    c1.elevation(angle = -20)
415    
416    # Render the object.
417    s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME)
418    \end{python}
419    
420  \subsubsection{\VelocityOnPlaneClip class}  \subsubsection{\VelocityOnPlaneClip class}
421    
422  \begin{classdesc}{VelocityOnPlaneClip}{scene, data_collector,  \begin{classdesc}{VelocityOnPlaneClip}{scene, data_collector,
# Line 370  The following are some of the methods av Line 469  The following are some of the methods av
469  Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform, \Clipper  Methods from \ActorThreeD, \Sphere, \TensorGlyph, \Transform, \Clipper
470  and \MaskPoints.  and \MaskPoints.
471    
472    A typical usage of \EllipsoidOnPlaneClip is shown below, which can be found in
473    \texttt{\PyvisiExampleDirectory}.
474    
475    \begin{python}
476    # Import the necessary modules
477    from esys.pyvisi import Scene, DataCollector, EllipsoidOnPlaneClip, Camera
478    from esys.pyvisi.constant import *
479    
480    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
481    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
482    X_SIZE = 400
483    Y_SIZE = 400
484    
485    TENSOR_FIELD_CELL_DATA = "stress_cell"
486    FILE_3D = "interior_3D.xml"
487    IMAGE_NAME = "ellipsoid.jpg"
488    JPG_RENDERER = Renderer.ONLINE_JPG
489    
490    # Create a Scene.
491    s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
492            y_size = Y_SIZE)
493    
494    # Create a DataCollector reading from a XML file.
495    dc1 = DataCollector(source = Source.XML)
496    dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
497    dc1.setActiveTensor(tensor = TENSOR_FIELD_CELL_DATA)
498    
499    # Create a EllipsoidOnPlaneClip.
500    eopc1 = EllipsoidOnPlaneClip(scene = s, data_collector = dc1,
501            viewport = Viewport.SOUTH_WEST, lut = Lut.COLOR, cell_to_point = True,
502            outline = True)
503    eopc1.setPlaneToXY()
504    eopc1.setScaleFactor(scale_factor = 0.2)
505    eopc1.rotateX(angle = 10)
506    
507    # Create a camera.
508    c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
509    c1.bottomView()
510    c1.azimuth(angle = -90)
511    c1.elevation(angle = 10)
512    
513    # Render the object.
514    s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME)
515    \end{python}
516    
517  \subsubsection{\Contour class}  \subsubsection{\Contour class}
518    
519  \begin{classdesc}{Contour}{scene, data_collector,  \begin{classdesc}{Contour}{scene, data_collector,
# Line 383  class can also be used to generate iso s Line 527  class can also be used to generate iso s
527  The following are some of the methods available:\\  The following are some of the methods available:\\
528  Methods from \ActorThreeD and \ContourModule.  Methods from \ActorThreeD and \ContourModule.
529    
530    A typical usage of \Contour is shown below, which can be found in
531    \texttt{\PyvisiExampleDirectory}.
532    
533    \begin{python}
534    # Import the necessary modules
535    from esys.pyvisi import Scene, DataCollector, Contour, Camera
536    from esys.pyvisi.constant import *
537    
538    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
539    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
540    X_SIZE = 400
541    Y_SIZE = 400
542    
543    SCALAR_FIELD_POINT_DATA = "temperature"
544    FILE_3D = "interior_3D.xml"
545    IMAGE_NAME = "contour.jpg"
546    JPG_RENDERER = Renderer.ONLINE_JPG
547    
548    
549    # Create a Scene.
550    s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
551            y_size = Y_SIZE)
552    
553    # Create a DataCollector reading a XML file.
554    dc1 = DataCollector(source = Source.XML)
555    dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
556    dc1.setActiveScalar(scalar = SCALAR_FIELD_POINT_DATA)
557    
558    # Create a Contour.
559    ctr1 = Contour(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
560            lut = Lut.COLOR, cell_to_point = False, outline = True)
561    ctr1.generateContours(contours = 3)
562    
563    # Create a Camera.
564    cam1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
565    cam1.elevation(angle = -40)
566    
567    # Render the object.
568    s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME)
569    \end{python}
570    
571  \subsubsection{\ContourOnPlaneCut class}  \subsubsection{\ContourOnPlaneCut class}
572    
573  \begin{classdesc}{ContourOnPlaneCut}{scene, data_collector,  \begin{classdesc}{ContourOnPlaneCut}{scene, data_collector,
# Line 421  modes, either using vector data or scala Line 606  modes, either using vector data or scala
606  The following are some of the methods available:\\  The following are some of the methods available:\\
607  Methods from \ActorThreeD, \PointSource, \StreamLineModule and \Tube.  Methods from \ActorThreeD, \PointSource, \StreamLineModule and \Tube.
608    
609    A typical usage of \StreamLine is shown below, which can be found in
610    \texttt{\PyvisiExampleDirectory}.
611    
612    \begin{python}
613    # Import the necessary modules.
614    from esys.pyvisi import Scene, DataCollector, StreamLine, Camera
615    from esys.pyvisi.constant import *
616    
617    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
618    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
619    X_SIZE = 400
620    Y_SIZE = 400
621    
622    VECTOR_FIELD_CELL_DATA = "temperature"
623    FILE_3D = "interior_3D.xml"
624    IMAGE_NAME = "streamline.jpg"
625    JPG_RENDERER = Renderer.ONLINE_JPG
626    
627    
628    # Create a Scene.
629    s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
630            y_size = Y_SIZE)
631    
632    # Create a DataCollector reading from a XML file.
633    dc1 = DataCollector(source = Source.XML)
634    dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
635    
636    # Create a Streamline.
637    sl1 = StreamLine(scene = s, data_collector = dc1,
638            viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,
639            lut = Lut.COLOR, cell_to_point = False, outline = True)
640    sl1.setTubeRadius(radius = 0.02)
641    
642    # Create a Camera.
643    c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
644    c1.isometricView()
645    
646    # Render the object.
647    s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME)
648    \end{python}
649    
650  \subsubsection{\Carpet class}  \subsubsection{\Carpet class}
651    
652  \begin{classdesc}{Carpet}{scene, data_collector,  \begin{classdesc}{Carpet}{scene, data_collector,
# Line 435  Similarly, the plane can be deformated e Line 661  Similarly, the plane can be deformated e
661  The following are some of the methods available:\\  The following are some of the methods available:\\
662  Methods from \ActorThreeD, \Warp and \Transform.  Methods from \ActorThreeD, \Warp and \Transform.
663    
664    A typical usage of \Carpet is shown below, which can be found in
665    \texttt{\PyvisiExampleDirectory}.
666    
667    \begin{python}
668    # Import the necessary modules.
669    from esys.pyvisi import Scene, DataCollector, Carpet, Camera
670    from esys.pyvisi.constant import *
671    
672    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
673    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
674    X_SIZE = 400
675    Y_SIZE = 400
676    
677    SCALAR_FIELD_CELL_DATA = "temperature_cell"
678    FILE_3D = "interior_3D.xml"
679    IMAGE_NAME = "carpet.jpg"
680    JPG_RENDERER = Renderer.ONLINE_JPG
681    
682    # Create a Scene.
683    s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
684            y_size = Y_SIZE)
685    
686    # Create a DataCollector reading from a XML file.
687    dc1 = DataCollector(source = Source.XML)
688    dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
689    dc1.setActiveScalar(scalar = SCALAR_FIELD_CELL_DATA)
690    
691    # Create a Carpet.
692    cpt1 = Carpet(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST,
693            warp_mode = WarpMode.SCALAR, lut = Lut.COLOR, cell_to_point = True,
694            outline = True)
695    cpt1.setPlaneToXY(0.2)
696    cpt1.setScaleFactor(1.9)
697    
698    # Create a Camera.
699    c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
700    c1.isometricView()
701    
702    # Render the object.
703    s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME)
704    \end{python}
705    
706  \subsubsection{\Image class}  \subsubsection{\Image class}
707    
708  \begin{classdesc}{Image}{scene, image_reader, viewport = Viewport.SOUTH_WEST}  \begin{classdesc}{Image}{scene, image_reader, viewport = Viewport.SOUTH_WEST}
# Line 445  image can also be translated and rotated Line 713  image can also be translated and rotated
713  The following are some of the methods available:\\  The following are some of the methods available:\\
714  Methods from \ActorThreeD, \PlaneSource and \Transform.  Methods from \ActorThreeD, \PlaneSource and \Transform.
715    
716    A typical usage of \Image is shown below, which can be found in
717    \texttt{\PyvisiExampleDirectory}.
718    
719    \begin{python}
720    # Import the necessary modules.
721    from esys.pyvisi import Scene, DataCollector, StreamLine, Camera
722    from esys.pyvisi.constant import *
723    
724    PYVISI_EXAMPLE_MESHES_PATH = "data_meshes/"
725    PYVISI_EXAMPLE_IMAGES_PATH = "data_sample_images/"
726    X_SIZE = 400
727    Y_SIZE = 400
728    
729    VECTOR_FIELD_CELL_DATA = "temperature"
730    FILE_3D = "interior_3D.xml"
731    IMAGE_NAME = "streamline.jpg"
732    JPG_RENDERER = Renderer.ONLINE_JPG
733    
734    
735    # Create a Scene.
736    s = Scene(renderer = JPG_RENDERER, num_viewport = 1, x_size = X_SIZE,
737            y_size = Y_SIZE)
738    
739    # Create a DataCollector reading from a XML file.
740    dc1 = DataCollector(source = Source.XML)
741    dc1.setFileName(file_name = PYVISI_EXAMPLE_MESHES_PATH + FILE_3D)
742    
743    # Create a Streamline.
744    sl1 = StreamLine(scene = s, data_collector = dc1,
745            viewport = Viewport.SOUTH_WEST, color_mode = ColorMode.SCALAR,
746            lut = Lut.COLOR, cell_to_point = False, outline = True)
747    sl1.setTubeRadius(radius = 0.02)
748    
749    # Create a Camera.
750    c1 = Camera(scene = s, data_collector = dc1, viewport = Viewport.SOUTH_WEST)
751    c1.isometricView()
752    
753    # Render the object.
754    s.render(PYVISI_EXAMPLE_IMAGES_PATH + IMAGE_NAME)
755    \end{python}
756    
757    
758  %##############################################################################  %##############################################################################
759    
# Line 668  Enables the randomization of the points Line 977  Enables the randomization of the points
977    
978  \section{Online Rendering Mechnism}  \section{Online Rendering Mechnism}
979    
980    \begin{figure}
981    \begin{tabular}{c c c}
982    \includegraphics[width=\thumbnailwidth]{figures/Map} &
983    \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneCut} &
984    \includegraphics[width=\thumbnailwidth]{figures/MapOnPlaneClip} \\
985    1 & 2 & 3 \\
986    \includegraphics[width=\thumbnailwidth]{figures/MapOnScalarClip}  \\
987    4
988    \end{tabular}
989    \end{figure}
990    
991    
992    
993    %\begin{tabular}{c c c c}
994    %\includegraphics[scale = 0.1]{figures/EscriptDiagram1} &
995    %\includegraphics[scale = 0.1]{figures/EscriptDiagram1} &
996    %\includegraphics[scale = 0.1]{figures/EscriptDiagram1} &
997    %\includegraphics[scale = 0.1]{figures/EscriptDiagram1} \\
998    %1 & 2 & 3 & 4
999    %\end{tabular}
1000    
1001    
1002  same word on rendering, off-line, on-line, how to rotate, zoom, close the window, ...  same word on rendering, off-line, on-line, how to rotate, zoom, close the window, ...

Legend:
Removed from v.1079  
changed lines
  Added in v.1081

  ViewVC Help
Powered by ViewVC 1.1.26