home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / PLOT / SURFUTI3.ZIP / REFLECT.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1988-01-23  |  4.1 KB  |  115 lines

  1. program REFLECT;
  2. uses crt;
  3.  
  4. { Read an existing SOLMODL data file, and reflect all the data across
  5.   the X axis. }
  6.  
  7. const MAXNODES = 1000;      { maximum # of nodes in the entire solid }
  8.       MAXCONNECT = 3000;    { maximum # of connections in entire solid }
  9.       MAXSURF = 1000;       { maximum # of surfaces in entire solid }
  10.                             { (MAXSURF = MAXCONNECT / 3) }
  11.       MAXMATL = 30;         { maximum # of materials in entire solid }
  12.       MAXVAR = 20;          { maximum # of numeric inputs on a line }
  13.       MAXLITE = 20;         { maximum # of light sources }
  14.  
  15. type  text80 = string[80];
  16.       vartype = array[1..MAXVAR] of real;
  17.       nodearray = array[1..MAXNODES] of real;
  18.  
  19. var   Xworld, Yworld, Zworld: nodearray;
  20.       { world coordinates of each node }
  21.       Connect: array[1..MAXCONNECT] of integer;
  22.       { surface connectivity data }
  23.       Nvert: array[1..MAXSURF] of integer;
  24.       { # vertices per surface }
  25.       Matl: array[1..MAXSURF] of integer;
  26.       { material number of each surface }
  27.       R1, R2, R3: array[1..MAXMATL] of real;
  28.       { material reflectivity constants }
  29.       Color: array[1..MAXMATL] of integer;
  30.       { material color number }
  31.       Ambient: array[1..MAXMATL] of real;
  32.       { ambient light intensity }
  33.       Xlite, Ylite, Zlite: array[1..MAXLITE] of real;
  34.       { coords of light sources }
  35.       Intensity: array[1..MAXLITE] of real;
  36.       { light source intensities }
  37.  
  38.       Flpurpose: string[127];              { title for plot }
  39.       Maxvert: integer;                    { max # vertices per surface }
  40.       Nsurf: integer;                      { # surfaces }
  41.       Nnodes: integer;                     { # nodes }
  42.       Nlite: integer;                      { # light sources }
  43.       Nmatl: integer;                      { number of materials }
  44.       Nsides: integer;                     { #sides of surface used (1 or 2)}
  45.       Fileread: boolean;                   { flag that a file was read }
  46.  
  47. { Two important functions for decoding the Connect array: }
  48.  
  49. function KONNEC (Surf, Vert: integer): integer;
  50. { Decode the Connect array to yield the connection data: Vertex Vert of
  51. surface Surf. This function returns an index to the global Xtran, Ytran,
  52. and Ztran arrays (i.e., a node number) }
  53. begin
  54.   Konnec := Connect[(Surf-1) * Maxvert + Vert];
  55. end; { function Konnec }
  56.  
  57. { null procedure READINI }
  58. procedure READINI (Flnm: text80);
  59. begin
  60. end;
  61.  
  62. { Procedure include files }
  63. {$I INREAL.INC }                         { procedure INREAL }
  64. {$I READFILE.INC }                       { procedure READFILE }
  65.  
  66. { variables local to the main procedure }
  67.  
  68. var Outfile: text;
  69.     Mat: integer;
  70.     Node: integer;
  71.     Surf: integer;
  72.     Vert: integer;
  73.  
  74. begin
  75.   Fileread := FALSE;
  76.   writeln ('Reading file ', paramstr(1));
  77.   readfile (paramstr(1));
  78.   assign (Outfile, paramstr(2));
  79.   writeln ('Writing file ', paramstr(2));
  80.   rewrite (Outfile);
  81.   writeln (Outfile, Flpurpose);
  82.   writeln (Outfile, 4);
  83.   writeln (Outfile, Nmatl:3, Nnodes*2:5, Nsurf*2:5, Maxvert:3, Nsides:3);
  84.   for Mat := 1 to Nmatl do
  85.     writeln (Outfile, R1[Mat]:7:3, R2[Mat]:7:3, R3[Mat]:7:3, ' ',Color[Mat]:3,
  86.              ' ', Ambient[Mat]:7:3);
  87.   for Node := 1 to Nnodes do
  88.     writeln (Outfile, Xworld[Node]:7:3, Yworld[Node]:7:3, Zworld[Node]:7:3);
  89.  
  90. { Reflecting Nodes }
  91.   for Node := 1 to Nnodes do
  92.     writeln (Outfile, -Xworld[Node]:7:3, Yworld[Node]:7:3, Zworld[Node]:7:3);
  93.   for Surf := 1 to Nsurf do begin
  94.     write (Outfile, Nvert[Surf]:3, Matl[Surf]:3);
  95.     for Vert := 1 to Nvert[Surf] do
  96.       write (Outfile, konnec (Surf, Vert):5);
  97.     writeln (Outfile);
  98.   end;
  99. { Reflecting Surfaces }
  100.   for Surf := 1 to Nsurf do begin
  101.     write (Outfile, Nvert[Surf]:3, Matl[Surf]:3);
  102.     for Vert := 1 to Nvert[Surf] do begin
  103.       Node := konnec (Surf, Nvert[Surf]-Vert+1);
  104. { If node has X=0 then use the old node number instead of the new.
  105.   Makes interpolation across X=0 possible. }
  106.       if (Xworld[Node] <> 0.0) then
  107.         write (Outfile, (Node + Nnodes):5)
  108.       else
  109.         write (Outfile, Node:5);
  110.     end;
  111.     writeln (Outfile);
  112.   end;
  113.   close (Outfile);
  114. end. { Program Reflect }
  115.