例子 8

目录前一页后一页

/********************************************************************* 
 *
 *  Gmsh tutorial 8
 * 
 *  后处理、脚本、动画、选项
 *
 *********************************************************************/

// 先包含进来例 1,以及一些后处理视图(请参看 FORMATS 文件关于后处理
// 文件的格式):

Include "t1.geo" ;
Include "view1.pos" ;
Include "view1.pos" ;
Include "view4.pos" ;

// 设定一些共同的选项:

General.Trackball = 0 ;
General.RotationX = 0 ;
General.RotationY = 0 ;
General.RotationZ = 0 ;
General.Color.Background = White ;
General.Color.Foreground = Black ;
General.Color.Text = Black ;
General.Orthographic = 0 ;
General.Axes = 0 ;
General.SmallAxes = 0 ;

// 每个后处理视图还有一些各自的选项:

View[0].IntervalsType = 2 ;
View[0].OffsetZ = 0.05 ;
View[0].RaiseZ = 0 ;
View[0].Light = 1 ;
View[0].ShowScale = 0;
View[0].SmoothNormals = 1;

View[1].IntervalsType = 1 ;
View[1].ColorTable = { Green, Blue } ;
View[1].NbIso = 10 ;
View[1].ShowScale = 0;

View[2].Name = "Test..." ;
View[2].IntervalsType = 2 ;
View[2].Type = 2;
View[2].IntervalsType = 2 ;
View[2].AutoPosition = 0;
View[2].PositionX = 85;
View[2].PositionY = 50;
View[2].Width = 200;
View[2].Height = 150;

View[3].Type = 3;
View[3].RangeType = 2;
View[3].IntervalsType = 4 ;
View[3].ShowScale = 0;
View[3].Grid = 0;
View[3].CustomMin = View[2].CustomMin;
View[3].CustomMax = View[2].CustomMax;
View[3].AutoPosition = 0;
View[3].PositionX = View[2].PositionX;
View[3].PositionY = View[2].PositionY;
View[3].Width = View[2].Width;
View[3].Height = View[2].Height;

// 从 1 到 255 做循环,这里的语法和 Matlab 是相似的,您还可以
// 使用 {0.5:1.5:0.1} 表示从 0.5 到 1.5 做循环,步长为 0.1。

t = 0 ;

For num In {1:255}

  View[0].TimeStep = t ;
  View[1].TimeStep = t ;
  View[2].TimeStep = t ;
  View[3].TimeStep = t ;

  t = (View[0].TimeStep < View[0].NbTimeStep-1) ? t+1 : 0 ;
  
  View[0].RaiseZ += 0.01*t ;

  If (num == 3)
    // 当 num == 3 的时候,我们使得图形的大小为 320x240 :
    General.GraphicsWidth = 320 ; 
    General.GraphicsHeight = 240 ;
  EndIf

  // 循环是可以嵌套的:
  For num2 In {1:50}

    General.RotationX += 10 ;
    General.RotationY = General.RotationX / 3 ;
    General.RotationZ += 0.1 ;
 
    Sleep 0.01; // 等待 0.01 秒钟
    Draw; // 重画

    If ((num == 3) && (num2 < 10))
      // Sprintf 函数能够用变量来产生复杂的字符串:
      Print Sprintf("t8-0%g.gif", num2);
      Print Sprintf("t8-0%g.jpg", num2);
    EndIf

    If ((num == 3) && (num2 >= 10))
       Print Sprintf("t8-%g.gif", num2);
       Print Sprintf("t8-%g.jpg", num2);
    EndIf

  EndFor

  If(num == 3)
    // System 命令能够使用一个系统调用。下面这行能用来
    // 产生一个 mpeg 文件(如果您安装有 mpeg_encode 的话)。
    // System "mpeg_encode t8.par" ;
  EndIf

EndFor

// 下面是支持的脚本命令列表:
//  
//  Merge string;     (合并一个文件)
//  Draw;             (重画)
//  Mesh int;         (产生网格; 'int' = 0, 1, 2 or 3)
//  Save string;      (存储网格)
//  Print string;     (打印图形窗口)
//  Sleep expr;       (睡眠给定的秒数)
//  Delete View[int]; (释放视图 int)
//  Delete Meshes;    (释放所有网格)
//  System string;    (执行一个系统调用)

目录前一页后一页