20 D_base(dimIn,nameIn,unitsIn)
52 ofstream outfile(filename);
56 outfile <<
"#vertices" << endl;
57 outfile <<
"4 2 0 0 " << endl;
58 outfile <<
"1" <<
" " <<
x[0] <<
" " <<
x[1] <<
" 1" << endl;
59 outfile <<
"2" <<
" " <<
x[0]+
L[0] <<
" " <<
x[1] <<
" " <<
"2" << endl;
60 outfile <<
"3" <<
" " <<
x[0]+
L[0] <<
" " <<
x[1]+
L[1] <<
" " <<
"3" << endl;
61 outfile <<
"4" <<
" " <<
x[0] <<
" " <<
x[1]+
L[1] <<
" " <<
"4" << endl;
62 outfile <<
"#segments" << endl;
63 outfile <<
"4 1" << endl;
64 outfile <<
"1 1 2 1" << endl;
65 outfile <<
"2 2 3 2" << endl;
66 outfile <<
"3 3 4 3" << endl;
67 outfile <<
"4 4 1 4" << endl;
68 outfile <<
"#holes" << endl;
69 outfile <<
"0" << endl;
70 outfile <<
"#regions" << endl;
71 outfile <<
"1" << endl;
72 outfile <<
"1" <<
" " << (
x[0]+
L[0])/2 <<
" " << (
x[1]+
L[1])/2 <<
" " <<
"1" << endl;
78 outfile <<
"#vertices" << endl;
79 outfile <<
"8 3 0 0" << endl;
80 outfile <<
"1" <<
" " <<
x[0] <<
" " <<
x[1] <<
" " <<
x[2] <<
" 1" << endl;
81 outfile <<
"2" <<
" " <<
x[0] <<
" " <<
x[1]+
L[1] <<
" " <<
x[2] <<
" 2" << endl;
82 outfile <<
"3" <<
" " <<
x[0]+
L[0] <<
" " <<
x[1]+
L[1] <<
" " <<
x[2] <<
" 3" << endl;
83 outfile <<
"4" <<
" " <<
x[0]+
L[0] <<
" " <<
x[1] <<
" " <<
x[2] <<
" 4" << endl;
84 outfile <<
"5" <<
" " <<
x[0] <<
" " <<
x[1] <<
" " <<
x[2]+
L[2] <<
" 5" << endl;
85 outfile <<
"6" <<
" " <<
x[0] <<
" " <<
x[1]+
L[1] <<
" " <<
x[2]+
L[2] <<
" 6" << endl;
86 outfile <<
"7" <<
" " <<
x[0]+
L[0] <<
" " <<
x[1]+
L[1] <<
" " <<
x[2]+
L[2] <<
" 7" << endl;
87 outfile <<
"8" <<
" " <<
x[0]+
L[0] <<
" " <<
x[1] <<
" " <<
x[2]+
L[2] <<
" 8" << endl;
88 outfile <<
"#facets" << endl;
89 outfile <<
"6 1" << endl;
90 outfile <<
"1 0 1" << endl;
91 outfile <<
"4 1 2 3 4\t\t#bottom" << endl;
92 outfile <<
"1 0 2" << endl;
93 outfile <<
"4 1 5 8 4\t\t#front" << endl;
94 outfile <<
"1 0 3" << endl;
95 outfile <<
"4 1 5 6 2\t\t#left" << endl;
96 outfile <<
"1 0 4" << endl;
97 outfile <<
"4 5 6 7 8\t\t#top" << endl;
98 outfile <<
"1 0 5" << endl;
99 outfile <<
"4 4 8 7 3\t\t#right" << endl;
100 outfile <<
"1 0 6" << endl;
101 outfile <<
"4 3 7 6 2\t\t#back" << endl;
102 outfile <<
"#holes" << endl;
103 outfile <<
"0" << endl;
104 outfile <<
"#regions" << endl;
105 outfile <<
"1" << endl;
106 outfile <<
"1" <<
" " << (
x[0]+
L[0])/2.0 <<
" " << (
x[1]+
L[1])/2.0 <<
" " << (
x[2]+
L[2])/2.9 <<
" 1" << endl;
115 ofstream outfile(filename);
120 outfile <<
"unitsize(4.0 inches/" <<
L[0] <<
");" << endl;
121 outfile <<
"size(6 inches);" << endl;
122 outfile <<
"real L=" <<
L[0] <<
";" << endl;
123 outfile <<
"real offset=.0125L;" << endl;
124 outfile <<
"real x=" <<
x[0] <<
";" << endl;
125 outfile <<
"string str=\"$" <<
L[0] <<
"\\mbox{" <<
units <<
"}$\";" << endl;
126 outfile <<
"import graph;" << endl;
127 outfile <<
"import palette;" << endl;
128 outfile <<
"pen[] allPens=Wheel();" << endl;
129 outfile <<
"pen[] myPens = new pen[3];" << endl;
130 outfile <<
"for(int i=0;i< 3;++i)" << endl;
131 outfile <<
"{" << endl;
132 outfile <<
" int iPen = round(i*allPens.length/3);" << endl;
133 outfile <<
" myPens[i] = allPens[iPen];" << endl;
134 outfile <<
" }" << endl;
135 outfile <<
"draw((x,0)--(x+L,0)^^(x,offset)--(x+L,offset),myPens[0]);" << endl;
136 outfile <<
"draw((x,0)--(x,offset),myPens[1]);" << endl;
137 outfile <<
"draw((x+L,0)--(x+L,offset),myPens[2]);" << endl;
138 outfile <<
"draw(str,(x,-offset)--(x+L,-offset),black,Bars,Arrows,PenMargins)" <<
";" << endl;
143 outfile <<
"import math;" << endl;
144 outfile <<
"import graph;" << endl;
145 outfile <<
"unitsize(4.0 inches /" <<
L[0] <<
");" << endl;
146 outfile <<
"size(6 inches);" << endl;
147 outfile <<
"real Lx = " <<
L[0] <<
";" << endl;
148 outfile <<
"real Ly = " <<
L[1] <<
";" << endl;
149 outfile <<
"real offset = 0.0125Lx;" << endl;
150 outfile <<
"real x = " <<
x[0] <<
";" << endl;
151 outfile <<
"real y = " <<
x[1] <<
";" << endl;
152 outfile <<
"string strx=\"$" <<
L[0]<<
"\\mbox{" <<
units <<
"}$\";" << endl;
153 outfile <<
"string stry=\"$" <<
L[1]<<
"\\mbox{" <<
units <<
"}$\";" << endl;
154 outfile <<
"import graph;" << endl;
155 outfile <<
"import palette;" << endl;
156 outfile <<
"pen[] allPens=Wheel();" << endl;
157 outfile <<
"pen[] myPens = new pen[4];" << endl;
158 outfile <<
"for(int i=0;i< 4;++i)" << endl;
159 outfile <<
"{" << endl;
160 outfile <<
"int iPen = round(i*allPens.length/4);" << endl;
161 outfile <<
" myPens[i] = allPens[iPen];" << endl;
162 outfile <<
"}" << endl;
163 outfile <<
"draw((x,y)--(x+Lx,y),myPens[0]);" << endl;
164 outfile <<
"draw((x,y+Ly)--(x+Lx,y+Ly),myPens[1]);" << endl;
165 outfile <<
"draw((x,y)--(x,y+Ly),myPens[2]);" << endl;
166 outfile <<
"draw((x+Lx,y)--(x+Lx,y+Ly),myPens[3]);" << endl;
167 outfile <<
"draw(strx,(x,y-offset)--(x+Lx,y-offset),S,black,Bars,Arrows,PenMargins);" << endl;
168 outfile <<
"draw(stry,(x-offset,y)--(x-offset,y+Ly),W,black,Bars,Arrows,PenMargins);" << endl;
171 outfile <<
"import three;" << endl;
172 outfile <<
"currentlight=adobe;" << endl;
173 outfile <<
"currentprojection=perspective(-2,-2,1,up=Z,target=O,showtarget=true,autoadjust=true,center=false);" << endl;
174 outfile <<
"unitsize(4.0 inches/" <<
L[0] <<
");" << endl;
175 outfile <<
"size(6 inches);" << endl;
176 outfile <<
"real Lx=" <<
L[0] <<
";" << endl;
177 outfile <<
"real Ly=" <<
L[1] <<
";" << endl;
178 outfile <<
"real Lz=" <<
L[2] <<
";" << endl;
179 outfile <<
"real offset=.0125Lx;" << endl;
180 outfile <<
"real x=" <<
x[0] <<
";" << endl;
181 outfile <<
"real y=" <<
x[1] <<
";" << endl;
182 outfile <<
"real z=" <<
x[2]<<
";" << endl;
183 outfile <<
"triple p0=(" <<
x[0] <<
"," <<
x[1] <<
","<<
x[2] <<
");" << endl;
184 outfile <<
"triple p1=(" <<
x[0] <<
"," <<
x[1]+
L[1] <<
","<<
x[2] <<
");" << endl;
185 outfile <<
"triple p2=(" <<
x[0]+
L[0] <<
"," <<
x[1]+
L[1] <<
"," <<
x[2] <<
");" << endl;
186 outfile <<
"triple p3=(" <<
x[0]+
L[0] <<
"," <<
x[1] <<
"," <<
x[2] <<
");" << endl;
187 outfile <<
"triple p4=(" <<
x[0] <<
"," <<
x[1] <<
","<<
x[2]+
L[2] <<
");" << endl;
188 outfile <<
"triple p5=(" <<
x[0] <<
"," <<
x[1]+
L[1] <<
"," <<
x[2]+
L[2] <<
");" << endl;
189 outfile <<
"triple p6=(x+Lx,y+Ly,z+Lz);" << endl;
190 outfile <<
"triple p7=(x+Lx,y,z+Lz);" << endl;
191 outfile <<
"string strx=\"$" <<
L[0] <<
"\\mbox{" <<
units <<
"}$\";"<< endl;
192 outfile <<
"string stry=\"$" <<
L[1] <<
"\\mbox{" <<
units <<
"}$\";" << endl;
193 outfile <<
"string strz=\"$" <<
L[2] <<
"\\mbox{" <<
units <<
"}$\";" << endl;
194 outfile <<
"draw(surface(p0--p1--p2--p3--cycle),red);" << endl;
195 outfile <<
"draw(surface(p4--p5--p6--p7--cycle),blue);" << endl;
196 outfile <<
"draw(surface(p0--p1--p5--p4--cycle),green);" << endl;
197 outfile <<
"draw(surface(p1--p2--p6--p5--cycle),orange);" << endl;
198 outfile <<
"draw(surface(p2--p3--p7--p6--cycle),purple);" << endl;
199 outfile <<
"draw(surface(p3--p0--p4--p7--cycle),yellow);" << endl;
200 outfile <<
"draw(strx,(x,y-offset,z-offset)--(x+Lx,y-offset,z-offset),-(Y+Z),black,Bars3(Z),Arrows3);" << endl;
201 outfile <<
"draw(stry,(x-offset,y,z-offset)--(x-offset,y+Ly,z-offset),-(X+Z),black,Bars3(Z),Arrows3);" << endl;
202 outfile <<
"draw(strz,(x-offset,y-offset,z)--(x-offset,y-offset,z+Lz),-(X+Z),black,Bars3(Z),Arrows3);" << endl;
203 outfile <<
"shipout();" << endl;
210 D_base(dimIn,nameIn,unitsIn)
215 vertices(verticesIn),
216 segments(segmentsIn),
219 vertexFlags(vertexFlagsIn),
220 segmentFlags(segmentFlagsIn),
229 ofstream outfile(filename);
243 for(
int i = 0; i <
vertices.size(); i++)
244 for(
int j =0; j < 3; j++)
247 outfile <<
vN.size()+1 <<
"\t" <<
v[0] <<
"\t" <<
v[1] << endl;
296 cout <<
"File already exists, not writing polyfile: " << filename << endl;
301 ofstream outfile(filename);
304 outfile <<
"unitsize(4.0 inches/ " <<
L[0] <<
");" << endl;
305 outfile <<
"size(6 inches);" << endl;
306 outfile <<
"real Lx=" <<
L[0] <<
";" << endl;
307 outfile <<
"real Ly=" <<
L[1]<<
";" << endl;
308 outfile <<
"real offset=0.0125Lx;" << endl;
309 outfile <<
"real x=" <<
x[0] <<
";" << endl;
310 outfile <<
"real y=" <<
x[1] <<
";" << endl;
311 outfile <<
"string strx=\"$" <<
L[0] <<
"\\mbox{" <<
units <<
"}$\";" << endl;
312 outfile <<
"string stry=\"$" <<
L[1] <<
"\\mbox{" <<
units <<
"}$\";" << endl;
313 outfile <<
"draw(strx,(x,y-offset)--(x+Lx,y-offset),S,black,Bars,Arrows,PenMargins);" << endl;
314 outfile <<
"draw(stry,(x-offset,y)--(x-offset,y+Ly),W,black,Bars,Arrows,PenMargins);" << endl;
315 outfile <<
"import graph;" << endl;
316 outfile <<
"import palette;" << endl;
317 outfile <<
"pen[] allPens=wheel();" << endl;
318 outfile <<
"pen[] myPens = new pen[" <<
segmentFlags.size() + 1 <<
"];" << endl;
319 outfile <<
"for(int i= 0; i<" <<
segmentFlags.size() +1 <<
";++i)" << endl;
320 outfile <<
"{" << endl;
321 outfile <<
"int iPen = round(i*allPens.length//" <<
segmentFlags.size() + 1 <<
");" << endl;
322 outfile <<
"myPens[i] = allPens[iPen];" << endl;
323 outfile <<
"}" << endl;
324 outfile <<
"shipout();" << endl;
325 for(
int i = 0; i<
segments.size();i++)
326 for(
int j = 0; j < 3; j++)
364 for(
int i =0; i <
vertices.size(); i++)
365 for(
int j = 0; j <3; j++)
438 D_base(dimIn,nameIn,unitsIn)
442 vertices(verticesIn),
446 vertexFlags(vertexFlagsIn),
447 facetFlags(facetFlagsIn),
455 ofstream outfile(filename);
458 outfile <<
"import three;" << endl;
459 outfile <<
"currentlight=adobe;" << endl;
460 outfile <<
"currentprojection=perspective(-2,-2,1,up=Z,target=(%(xc)f,%(yc)f,%(zc)f),showtarget=true,autoadjust=true,center=false);" << endl;
461 outfile <<
"unitsize(4.0 inches/%(Lx)f);" << endl;
462 outfile <<
"size(6 inches);" << endl;
463 outfile <<
"real Lx=%(Lx)f;" << endl;
464 outfile <<
"real Ly=%(Ly)f;" << endl;
465 outfile <<
"real Lz=%(Lz)f;" << endl;
466 outfile <<
"real offset=.0125Lx;" << endl;
467 outfile <<
"real x=%(x)f;" << endl;
468 outfile <<
"real y=%(y)f;" << endl;
469 outfile <<
"real z=%(z)f;" << endl;
470 outfile <<
"triple p0=(x,y,z);" << endl;
471 outfile <<
"triple p1=(x,y+Ly,z);" << endl;
472 outfile <<
"triple p2=(x+Lx,y+Ly,z);" << endl;
473 outfile <<
"triple p3=(x+Lx,y,z);" << endl;
474 outfile <<
"triple p4=(x,y,z+Lz);" << endl;
475 outfile <<
"triple p5=(x,y+Ly,z+Lz);" << endl;
476 outfile <<
"triple p6=(x+Lx,y+Ly,z+Lz);" << endl;
477 outfile <<
"triple p7=(x+Lx,y,z+Lz);" << endl;
478 outfile <<
"string strx=\"$%(Lx)2.2f\\mbox{%(units)s}$\";" << endl;
479 outfile <<
"string stry=\"$%(Ly)2.2f\\mbox{%(units)s}$\";" << endl;
480 outfile <<
"string strz=\"$%(Lz)2.2f\\mbox{%(units)s}$\";" << endl;
481 outfile <<
"draw(strx,(x,y-offset,z-offset)--(x+Lx,y-offset,z-offset),-(Y+Z),black,Bars3(Z),Arrows3);" << endl;
482 outfile <<
"draw(stry,(x-offset,y,z-offset)--(x-offset,y+Ly,z-offset),-(X+Z),black,Bars3(Z),Arrows3);" << endl;
483 outfile <<
"draw(strz,(x-offset,y-offset,z)--(x-offset,y-offset,z+Lz),-(X+Y),black,Bars3(X),Arrows3);" << endl;
528 for(
int i = 0; i <
vertices.size(); i++)
529 for(
int j =0; j < 3; j++)
532 outfile <<
vN.size()+1 <<
"\t" <<
v[0] <<
"\t" <<
v[1] << endl;
540 for(
int i = 0; i <
facets.size(); i++)
541 for(
int j = 0; j < 3; j++)
550 outfile <<
f.size() <<
" " << nFacetHoles <<
" " <<
facetFlags[
fN] << endl;
552 outfile <<
fN.size()+1 <<
" " << nFacetHoles << endl;
553 for(
int i = 0; i <
f.size(); i++)
556 outfile << segmentList.size()+1 << endl;
559 for(
int j = 0; j < segmentList.size(); j++)
562 outfile <<
vN+1 <<
" ";
574 outfile <<
holes.size() << endl;
575 for(
int i = 0; i <
holes.size(); i++)
576 for(
int j = 0; j < 3; j++)
578 hN[i*3+j] =
holes[i][j];
579 outfile << hN+1 <<
" " << h[0] <<
" " << h[1] << endl;
581 outfile << regionFlags[rN] << endl;
589 outfile <<
"0" << endl;
596 cout <<
"File already exits, not writing polyfile: " << filename << endl;