File: dxf.cmd

package info (click to toggle)
evolver 2.70+ds-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 17,148 kB
  • sloc: ansic: 127,395; makefile: 209; sh: 98
file content (101 lines) | stat: -rw-r--r-- 2,933 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// dxf.cmd

// Evolver command to produce AutoCad DXF files

/*
   Assumptions: 3D soapfilm model, linear model, not torus or symmetry group
    (use the "detorus" command if necessary to convert torus or symmetry
     to unwrapped surface, but remember that detorus alters the surface)
   Does facets only, not edges. 
   Does facets satisfying "show" criterion.
   Facet color is frontcolor only.
*/

// Programmer: Ken Brakke, brakke@susqu.edu

// References:
// http://en.wikipedia.org/wiki/AutoCAD_DXF
// http://images.autodesk.com/adsk/files/acad_dxf.pdf

// Usage:
//     dxf >>> "filename.dxf"

define dxf_colors integer[16];
dxf_colors[1] := 5 // blue
dxf_colors[2] := 3 // green
dxf_colors[3] := 4 // cyan
dxf_colors[4] := 10 // red
dxf_colors[5] := 6 // magenta
dxf_colors[6] := 1 // brown
dxf_colors[7] := 9 // lightgray
dxf_colors[8] := 8 // darkgray
dxf_colors[9] := 8 // lightblue
dxf_colors[10] := 3 // lightgreen
dxf_colors[11] := 4 // lightcyan
dxf_colors[12] := 14 // lightred
dxf_colors[13] := 6 // lightmagenta
dxf_colors[14] := 2 // yellow
dxf_colors[15] := 7 // white

dxf := {

  if torus then
  { errprintf "Cannot run 'dxf' command in torus mode. Do 'detorus' first.\n";
    errprintf "    WARNING: 'detorus' will modify the surface; save it!\n";
    abort;
  };

  if symmetry_group then
  { errprintf "Cannot run 'dxf' command in symmetry group mode. Do 'detorus' first.\n";
    errprintf "    WARNING: 'detorus' will modify the surface; save it!\n";
    abort;
  };

  if space_dimension != 3 then
  { errprintf "The 'dxf' command must be run in three-dimensional space.\n";
    abort;
  };


  if surface_dimension == 1 then
  { errprintf "The 'dxf' command is not meant for the string model.\n";
    abort;
  };

  if simplex_representation then
  { errprintf "The 'dxf' command is not meant for the simplex model.\n";
    abort;
  };

  if lagrange_order >= 2 then
  { errprintf "The 'dxf' command is meant for the linear model, not quadratic or Lagrange.\n";
    abort;
  };



 printf "  0\nSECTION\n  2\nENTITIES\n";
 foreach facet ff where show  and color >= 0 do
 { printf "  0\n3DFACE\n  8\n0main\n";
   printf " 10\n%8.6f\n 20\n%8.6f\n 30\n%8.6f\n",ff.vertex[1].x,
             ff.vertex[1].y,ff.vertex[1].z;
   printf " 11\n%8.6f\n 21\n%8.6f\n 31\n%8.6f\n",ff.vertex[2].x,
             ff.vertex[2].y,ff.vertex[2].z;
   printf " 12\n%8.6f\n 22\n%8.6f\n 32\n%8.6f\n",ff.vertex[3].x,
             ff.vertex[3].y,ff.vertex[3].z;
   printf " 13\n%8.6f\n 23\n%8.6f\n 33\n%8.6f\n",ff.vertex[3].x,
             ff.vertex[3].y,ff.vertex[3].z;
   // try color
   if ff.color > 0 and ff.color < 16 then
     printf " 62\n%3d\n",dxf_colors[ff.color]
   else
     printf " 62\n%3d\n",dxf_colors[8];  // black?
 };
 printf "  0\nENDSEC\n  0\nEOF\n";
}

// End dxf.cmd

// Usage:  dxf >>> "filename.dxf"