home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / GRAPHICS / PLOT / SURFUTI3.ZIP / PATCH.INC < prev    next >
Encoding:
Text File  |  1990-09-03  |  2.2 KB  |  62 lines

  1. procedure PATCH;
  2. { option to break all 16-node surfaces into 9 4-node surfaces
  3.   NOTE: When time allows, this routine needs to be extended to properly
  4.   treat a spline.
  5. }
  6.  
  7. var Node:                integer;      { node # }
  8.     Surf:                integer;      { surface # }
  9.     Tnsurf:              integer;      { temp for Nsurf }
  10.     Nvertex:             integer;      { # vertices in Surf }
  11.  
  12. procedure BREAKPATCH (Oldsurf, Vert1, Vert2, Vert3, Vert4, Newsurf: integer);
  13. { Makes a new quadrilateral surface using the four vertices specifed from
  14.   the old 16-sided surface }
  15.  
  16. begin
  17. {$ifdef BIGMEM}
  18. with ptrb^ do with ptrc^ do
  19. begin
  20. {$endif}
  21.   Connect[(Newsurf-1) * Maxvert + 1] := konnec (Oldsurf, Vert1);
  22.   Connect[(Newsurf-1) * Maxvert + 2] := konnec (Oldsurf, Vert2);
  23.   Connect[(Newsurf-1) * Maxvert + 3] := konnec (Oldsurf, Vert3);
  24.   Connect[(Newsurf-1) * Maxvert + 4] := konnec (Oldsurf, Vert4);
  25.   Connect[(Newsurf-1) * Maxvert + 5] := 0;
  26.   Matl[Newsurf] := Matl[Oldsurf];
  27. {$ifdef BIGMEM}
  28. end; {with}
  29. {$endif}
  30. end; { procedure BREAKPATCH }
  31.  
  32. begin
  33.   Tnsurf := Nsurf;
  34.   for Surf := 1 to Nsurf do begin
  35.     Nvertex := Nvert(Surf);
  36.     if (Nvertex = 16) then begin
  37.       if ((Tnsurf+8) * Maxvert > MAXCONNECT) then begin
  38.         writeln ('Error: Too many surfaces.');
  39.         writeln ('Can"t break the patch into quads.');
  40.         halt;
  41.       end;
  42.       breakpatch (Surf, 1, 2, 6, 5, Tnsurf+1);
  43.       breakpatch (Surf, 2, 3, 7, 6, Tnsurf+2);
  44.       breakpatch (Surf, 3, 4, 8, 7, Tnsurf+3);
  45.       breakpatch (Surf, 5, 6, 10, 9, Tnsurf+4);
  46.       breakpatch (Surf, 6, 7, 11, 10, Tnsurf+5);
  47.       breakpatch (Surf, 7, 8, 12, 11, Tnsurf+6);
  48.       breakpatch (Surf, 9, 10, 14, 13, Tnsurf+7);
  49.       breakpatch (Surf, 10, 11, 15, 14, Tnsurf+8);
  50. { Note: It's important that the last quad not use the first five nodes
  51.   or else there could be a conflict. }
  52.       breakpatch (Surf, 11, 12, 16, 15, Surf);
  53.       Tnsurf := Tnsurf + 8;
  54.     end; { if Nvertex }
  55.   end; { for Surf }
  56.   Nsurf := Tnsurf;
  57.   { Flag the patch break so WRITEFILE will check all the surfaces before
  58.     writing the data and see if Maxvert can be reduced
  59.   }
  60.   Checkmax := TRUE;
  61. end; { procedure PATCH }
  62.