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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269
|
// iges.cmd
// Surface Evolver script to write IGES file for surface, using IGES
// parametric patches, type 114.
/*
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 all facets, regardless of "show" criterion.
Facet color is frontcolor on both sides.
*/
// usage: iges >>> "filename.igs"
// Set up color translation array
define iges_colors integer [16];
iges_black := 1
//iges_colors[black] := 1
iges_colors[red] := 2
iges_colors[green] := 3
iges_colors[blue] := 4
iges_colors[yellow] := 5
iges_colors[magenta] := 6
iges_colors[cyan] := 7
iges_colors[white] := 8
iges_colors[brown] := 2 // red
iges_colors[lightgray] := 8 // white
iges_colors[darkgray] := 1 // black
iges_colors[lightblue] := 4 // blue
iges_colors[lightcyan] := 7 // cyan
iges_colors[lightred] := 2 // red
iges_colors[lightmagenta] := 7
iges := {
local start_counter,global_counter,message,xmax,ymax,zmax;
local maxsize,entype,paramdata,structure,linefont,level,view;
local transmat,label,status,directory_counter,lineweight;
local colornum,paramcount,form,reserved,entlabel,entsubscr;
local parameter_counter,ctype,ptype,mvalue,nvalue,minu,maxu;
local minv,maxv,co00,co10,co01,co11,line,subcount;
// Check assumptions
if torus then
{ errprintf "Cannot run 'iges' command in torus mode. Do 'detorus' first.\n";
abort;
};
if space_dimension != 3 then
{ errprintf "The 'iges' command must be run in three-dimensional space.\n";
abort;
};
if surface_dimension == 1 then
{ errprintf "The 'iges' command is not meant for the string model.\n";
abort;
};
if simplex_representation then
{ errprintf "The 'iges' command is not meant for the simplex model.\n";
abort;
};
if lagrange_order >= 2 then
{ errprintf "The 'iges' command is meant for the linear model, not quadratic or Lagrange.\n";
abort;
};
if rgb_colors then
{ errprintf "The 'iges' command does not do RGB colors; do rgb_colors off.\n";
abort;
};
// Flag section
// Don't need this since not doing binary or compressed format.
// Start section
start_counter := 0;
start_counter += 1;
printf "%-72sS%07d\n","IGES version of Surface Evolver surface",start_counter;
start_counter += 1;
printf " %-69sS%07d\n",datafilename,start_counter;
start_counter += 1;
printf "%-72sS%07d\n","Created using iges.cmd Evolver script.",
start_counter;
// Global section
global_counter := 0;
global_counter += 1;
printf "%-72sG%07d\n","1H,,1H;,",global_counter;
global_counter += 1;
printf "%02dH%-69sG%07d\n",sizeof("Surface Evolver"),"Surface Evolver,",
global_counter;
global_counter += 1;
message := sprintf "%s,",datafilename;
printf "%02dH%-69sG%07d\n",sizeof(datafilename),message,global_counter;
global_counter += 1;
printf "%02dH%-69sG%07d\n",sizeof("Surface Evolver"),"Surface Evolver,",
global_counter;
global_counter += 1;
printf "%02dH%-69sG%07d\n",sizeof("Surface Evolver"),"Surface Evolver,",
global_counter;
global_counter += 1;
printf "%-72sG%07d\n","32,75,6,75,15,,1.0,1,2HIN,32768,0.0394,",
global_counter;
global_counter += 1;
printf "%-72sG%07d\n","15H00000000.000000,", global_counter; // date
xmax := max(vertex,abs(x));
ymax := max(vertex,abs(y));
zmax := max(vertex,abs(z));
maxsize := (xmax > ymax) ? xmax : ymax;
maxsize := (zmax > maxsize) ? zmax : maxsize;
message := sprintf "%g,%g,",maxsize/10000000,maxsize;
global_counter += 1;
printf "%-72sG%07d\n",message, global_counter;
global_counter += 1;
printf "%02dH%-69sG%07d\n",sizeof("Name of author"),"Name of author,",
global_counter;
global_counter += 1;
printf "%02dH%-69sG%07d\n",sizeof("Author's organization"),
"Author's organization,", global_counter;
global_counter += 1;
printf "%-72sG%07d\n","15H00000000.000000;", global_counter; // date
// Directory entry section. Each entry 20 8-char fields on two lines.
// Fields with default values
entype := 0; // 1 and 11
paramdata := 1; // 2
structure := 0; // 3
linefont := 0; // 4
level := 0; // 5
view := 0; // 6
transmat := 0; // 7
label := 0; // 8
status := "00000000"; // 9; actually 4 two-digit numbers
directory_counter := 0; // 10 and 20
lineweight := 0; // 12
colornum := 0; // 13
paramcount := 0; // 14
form := 0; // 15
reserved := " "; // 16 and 17
entlabel := "entity"; // 18
entsubscr := 0; // 19
// Facets as "parametric surface" types
entype := 114;
status := "00010001";
paramcount := 1;
entlabel := " FACET";
define facet attribute fpdata integer;
define facet attribute fdir integer;
foreach facet ff where show and color >= 0 do
{ ff.fpdata := paramdata;
entsubscr := ff.id;
directory_counter += 1; ff.fdir := directory_counter;
printf "%8d%8d%8d%8d%8d%8d%8d%8d%8sD%7d\n",entype,paramdata,
structure,linefont,level,view,transmat,label,status,
directory_counter;
directory_counter += 1;
printf "%8d%8d%8d%8d%8d%8s%8s%8s%8dD%7d\n",entype,lineweight,
(ff.color == BLACK ? iges_black : iges_colors[ff.color]),
paramcount,form,reserved,reserved,
entlabel,entsubscr,directory_counter;
paramdata += 7;
};
// Geometry element
entype := 402;
status := "00000301";
paramcount := ceil(facet_count/10);
form := 7;
entlabel := " SURFACE";
entsubscr := 1;
directory_counter += 1;
printf "%8d%8d%8d%8d%8d%8d%8d%8d%8sD%7d\n",entype,paramdata,structure,
linefont,level,view,transmat,label,status,directory_counter;
directory_counter += 1;
printf "%8d%8d%8d%8d%8d%8s%8s%8s%8dD%7d\n",entype,lineweight,colornum,
paramcount,form,reserved,reserved,entlabel,entsubscr,directory_counter;
// Parameter data section
parameter_counter := 0;
// Facets
entype := 114;
ctype := 1; // linear
ptype := 0; // unspecified
mvalue := 1; // number of u segments
nvalue := 1; // number of v segments
minu := 0;
maxu := 1;
minv := 0;
maxv := 1;
foreach facet ff where show and color >= 0 do
{ parameter_counter += 1;
if ff.fpdata != parameter_counter then
errprintf
"ERROR: bad facet parameter line number, facet %d. Is %d, should be %d.\n",
ff.id,parameter_counter,ff.fpdata;
message := sprintf "%d,%d,%d,%d,%d,%g,%g,%g,%g,",entype,ctype,ptype,
mvalue,nvalue,minu,maxu,minv,maxv;
printf "%-64s%8dP%7d\n",message,ff.fdir,parameter_counter;
co00 := ff.vertex[1].x;
co10 := ff.vertex[2].x-ff.vertex[1].x;
co01 := ff.vertex[3].x-ff.vertex[1].x;
co11 := ff.vertex[1].x-ff.vertex[2].x;
message := sprintf "%10.7f,%10.7f,0,0,%10.7f,%10.7f,0,0,",
co00,co10,co01,co11;
parameter_counter += 1;
printf "%-64s%8dP%7d\n",message,ff.fdir,parameter_counter;
message := "0,0,0,0,0,0,0,0,";
parameter_counter += 1;
printf "%-64s%8dP%7d\n",message,ff.fdir,parameter_counter;
co00 := ff.vertex[1].y;
co10 := ff.vertex[2].y-ff.vertex[1].y;
co01 := ff.vertex[3].y-ff.vertex[1].y;
co11 := ff.vertex[1].y-ff.vertex[2].y;
message := sprintf "%10.7f,%10.7f,0,0,%10.7f,%10.7f,0,0,",
co00,co10,co01,co11;
parameter_counter += 1;
printf "%-64s%8dP%7d\n",message,ff.fdir,parameter_counter;
message := "0,0,0,0,0,0,0,0,";
parameter_counter += 1;
printf "%-64s%8dP%7d\n",message,ff.fdir,parameter_counter;
co00 := ff.vertex[1].z;
co10 := ff.vertex[2].z-ff.vertex[1].z;
co01 := ff.vertex[3].z-ff.vertex[1].z;
co11 := ff.vertex[1].z-ff.vertex[2].z;
message := sprintf "%10.7f,%10.7f,0,0,%10.7f,%10.7f,0,0,",
co00,co10,co01,co11;
parameter_counter += 1;
printf "%-64s%8dP%7d\n",message,ff.fdir,parameter_counter;
message := "0,0,0,0,0,0,0,0,";
parameter_counter += 1;
printf "%-64s%8dP%7d\n",message,ff.fdir,parameter_counter;
};
// Geometry element
line := sprintf "402,%d,",facet_count;
subcount := 0;
foreach facet ff where show and color >= 0 do
{ if subcount == 10 then
{
parameter_counter += 1;
printf "%-64s%8dP%7d\n",line,directory_counter-1,parameter_counter;
line := "" ;
subcount := 0;
};
line := sprintf"%s%d,",line,ff.fdir;
subcount += 1;
};
line := sprintf "%s0,0;",line; // sample files ended with 2 extra 0's
parameter_counter += 1;
printf "%-64s%8dP%7d\n",line,directory_counter-1,parameter_counter;
// Terminate section
printf "S%07dG%07dD%07dP%07d%40sT0000001\n",start_counter,global_counter,
directory_counter,parameter_counter," ";
}
// End iges.cmd
// Usage: iges >>> "filename.igs"
|