Data input

Fluxmagdata

Needs["Histograms`"]

fluxmagdata = Import["/Users/ccarter/People/Neri/MeshSubject_03/vertical_results/jmag.csv","CSV"];

Length[fluxmagdata]

flux scaled so that min - max is 0,1

fluxvalues = Rescale[Transpose[fluxmagdata][[3]]];

Length[fluxvalues]

Histogram[fluxvalues]

jmagmax =Max[fluxvalues]

jmagmin =Min[fluxvalues]

Use Log Flux

Histogram[Log[fluxvalues+.00000001]]

ChopMaxMin[vals_, min_, max_] := vals/.{a_/;a<min->min,b_/;b>max->max}

Histogram[ChopMaxMin[Log[fluxvalues+.00000001],-12,-0.5]]

scaledfluxmagvalues= Rescale[ChopMaxMin[Log[fluxvalues+.00000001],-12,-0.5]];

Histogram[scaledfluxmagvalues]

scaledfluxmagdata=Transpose[ Append[Most[Transpose[fluxmagdata]],scaledfluxmagvalues]];

fluxmagdata[[123]]
scaledfluxmagdata[[123]]

stressdata

stressdata = Import["/Users/ccarter/People/Neri/MeshSubject_03/vertical_results/stress.csv","CSV"];

Length[stressdata]

stressvalues = Rescale[Transpose[stressdata][[3]]];

Histogram[stressvalues]

strain scaled so that min - max is 0.5 , 4 (for line widths) (chopped data between 0.35 and 0.6)

scaledstressvalues=0.5 + 3.5Rescale[ChopMaxMin[stressvalues,0.35,0.6]];

Min[scaledstressvalues]
Max[scaledstressvalues]

Histogram[scaledstressvalues]

scaledstressdata=Transpose[ Append[Most[Transpose[stressdata]],scaledstressvalues]];

stressdata[[123]]
scaledstressdata[[123]]

straindata

straindata = Import["/Users/ccarter/People/Neri/MeshSubject_03/vertical_results/strainyy.csv","CSV"];

Length[straindata]

strainvalues = Rescale[Transpose[straindata][[3]]];

Histogram[strainvalues]

strain scaled so that min - max is 0.5 , 4 (for line widths) (chopped data between 0.05 and 0.7)

scaledstrainvalues=0.5 + 3.5Rescale[ChopMaxMin[strainvalues,0.05,0.7]];

Min[scaledstrainvalues]
Max[scaledstrainvalues]

Histogram[scaledstrainvalues]

Histogram[Log[scaledstrainvalues]]

scaledstraindata=Transpose[ Append[Most[Transpose[straindata]],scaledstrainvalues]];

straindata[[153]]
scaledstraindata[[153]]

energydata

energydata = Import["/Users/ccarter/People/Neri/MeshSubject_03/vertical_results/energy.csv","CSV"];

Length[energydata]

energyvalues = Rescale[Transpose[energydata][[3]]];

Histogram[energyvalues]

Use Log Energy

Histogram[Log[energyvalues+.00000001]]

energy scaled so that min - max is 0,100 (for numbers)

scaledenergyvalues= 100*Rescale[ChopMaxMin[Log[energyvalues+.00000001],-12,0]];

Histogram[scaledfluxmagvalues]

scaledenergydata=Transpose[ Append[Most[Transpose[energydata]],scaledenergyvalues]];

energydata[[153]]
scaledenergydata[[153]]

zdata

zdata = Import["/Users/ccarter/People/Neri/MeshSubject_03/vertical_results/z.csv","CSV"];

Length[zdata]

zvalues = Rescale[Transpose[zdata][[3]]];

Histogram[zvalues]

z scaled so that min - max is 0,3 (roughly 10%)(chopped 0.5,0.9)

scaledzvalues= 70*Rescale[ChopMaxMin[zvalues,0.5,0.9]];;

Histogram[scaledzvalues]

scaledzdata=Transpose[ Append[Most[Transpose[zdata]],scaledzvalues]];

zdata[[513]]
scaledzdata[[513]]

Interpolation of Data

fluxfunc

fluxfunc = Interpolation[scaledfluxmagdata/.{a_,b_,c_}->{{b,a},c}];

{{xmin,xmax},{ymin,ymax}}=fluxfunc[[1]]

Plot3D[fluxfunc[x,y],{x,xmin,xmax},{y,ymin,ymax},PlotRange-> All,PlotPoints->64]

stressfunc

stressfunc = Interpolation[scaledstressdata/.{a_,b_,c_}->{{b,a},c}];
Plot3D[stressfunc[x,y],{x,xmin,xmax},{y,ymin,ymax},PlotRange->All,PlotPoints-> 64]

strainfunc

strainfunc = Interpolation[scaledstraindata/.{a_,b_,c_}->{{b,a},c}];
Plot3D[strainfunc[x,y],{x,xmin,xmax},{y,ymin,ymax},PlotRange->All,PlotPoints-> 64]

energyfunc

energyfunc = Interpolation[scaledenergydata/.{a_,b_,c_}->{{b,a},c},InterpolationOrder-> 3];
Plot3D[energyfunc[x,y],{x,xmin,xmax},{y,ymin,ymax},PlotRange->All,PlotPoints->75]

zfunc

zfunc = Interpolation[scaledzdata/.{a_,b_,c_}->{{b,a},c},InterpolationOrder-> 3];
Plot3D[zfunc[x,y],{x,xmin,xmax},{y,ymin,ymax},PlotRange->All]

Skeleton Structure

read data

pts = Import["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh.points.csv","CSV"];

pgons = Import["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh.nodes.csv","CSV"]+1;

Length[pts]
Length[pgons]

pts[[123]]
pgons[[123]]

reconcile data structure: make edges

currentedge=1;
edgesOfVertex= Table[{},{Length[pts]}];
UniqueEdge[va_, vb_] :=Which[
ValueQ[edge[va,vb]],edge[va,vb],
ValueQ[edge[vb,va]],-edge[vb,va],
True,edge[va,vb] = currentedge;edgevertices[currentedge]={va,vb};AppendTo[edgesOfVertex[[va]],currentedge]; AppendTo[edgesOfVertex[[vb]],currentedge];currentedge++]

MakeEdges[ v_List] :=Module[{len=Length[v]},
Return[
Append[
 Table[UniqueEdge[v[[i]],v[[i+1]]],{i,1,len-1}],
UniqueEdge[v[[len]],v[[1]]]
]

]
]

Map[MakeEdges,pgons];

currentedge

edgevertices[1234]

edgevertexlist= Map[edgevertices[#]&,Range[currentedge-1]];

edgevertexlist[[1234]]

temp=Map[Union,edgesOfVertex];

temp[[1234]]

edgesOfVertex[[1234]]

Dimensions[edgesOfVertex]

Dimensions[temp]

Dimensions[Flatten@edgesOfVertex]
Dimensions[Flatten@edgesOfVertex]

edgesOfVertex//Short

Union[{66901,66902,66903,66904,66905,66907}]

Length[edgevertexlist]
currentedge-1

starEdgesVertices[v_] := Select[edgevertexlist,MemberQ[#,v]&] (*slow, don't use)*)

starEdges[v_] := Map[UniqueEdge[First[#],Last[#]]& ,starEdgesVertices[v]] (*slow don't use*)

currentedgerange= Range[currentedge-1];

starEdges[v_] := (*slow don't use*)
Pick[currentedgerange,Map[MemberQ[#,v]&,edgevertexlist]]
(*Map[UniqueEdge[First[#],Last[#]]& ,starEdgesVertices[v,edgevertices]]*)

starEdgesVertices[5228]

starEdges[5228]

edgesOfVertex[[5228]]

UniqueEdge[5228,5230]

pts[[234]]

Max[pts]

Min[pts]

scaledzdata[[234]]

zht[vtx_] :=Module[{pt=pts[[vtx]]},zfunc[pt[[2]],pt[[1]]]]

pts//Short

maxx=Max[ Map[First,pts]]
maxy=Max[ Map[Last,pts]]
minx=Min[ Map[First,pts]]
miny=Min[ Map[Last,pts]]

ptsscaled= pts*30/500;

ptsscaled//Short

zhts= Table[zht[i],{i,1,Length[pts]}];

zmax = Max[zhts]
zmin=Min[zhts]

ptszhtscaled=Table[
{
30(First[pts[[i]]]-xmin)/(xmax-xmin),
30(Last[pts[[i]]]-ymin)/(ymax-ymin),
 6(zht[i]-zmin)/(zmax-zmin)
} ,{i,1,Length[pts]}];

ptszhtscaled[[245]]

Max[Last/@ptszhtscaled]

Min[Last/@ptszhtscaled]

Max[First/@ptszhtscaled]

Min[First/@ptszhtscaled]

MidPoint[edge_] := Mean[pts[[edgevertices[edge]]]]

strainmag[edge_] :=strainmag[edge]=Module[{pt=MidPoint[edge]},strainfunc[pt[[2]],pt[[1]]]]

jmag[edge_] :=Module[{pt=MidPoint[edge]},fluxfunc[pt[[2]],pt[[1]]]]

temp = Table[strainmag[i],{i,1,currentedge-1}];
strainmin = Min[Table[strainmag[i],{i,1,currentedge-1}]]
strainmax = Max[Table[strainmag[i],{i,1,currentedge-1}]]

strainmax = Max[Table[strainmag[i],{i,1,currentedge-1}]]

Histogram[temp]

strainmagdata= Table[0.06 +  (.4 - 0.06)strainmag[i]/(strainmax-strainmin), {i,1,currentedge-1}];

Histogram[strainmagdata]

jmagdata= Table[jmag[i], {i,1,currentedge-1}];

Histogram[temp]

maxedgevalue[vertex_, edgevaluelist_]:= Module[
{edges,vals,max},
edges = edgesOfVertex[[vertex]];
vals=Map[edgevaluelist[[#]]&, edges];
Flatten@{max = Max[vals],
Pick[edges,vals, max]}
]

avededgevalue[vertex_, edgevaluelist_]:= Module[
{edges,vals,max},
edges = edgesOfVertex[[vertex]];
vals=Map[edgevaluelist[[#]]&, edges];
Flatten@{max = Mean[vals],
Pick[edges,vals, max]}
]

ptszhtscaled[[451]]

Here are the dimensions

Writing Panels

xl=0.0; xr=7.5; yd= 0; yu= 7.5;
AcceptedVertexCoords= Select[ptszhtscaled,((xl≤ #[[1]] ≤xr)&& (yd≤ #[[2]] ≤ yu))&];
Length[AcceptedVertexCoords]
AcceptedVertexCoords[[1;;10]]

Length[ptszhtscaled]/16//N

currentedge

Length[ptszhtscaled]

VertexIndices =
Pick[Range[Length[ptszhtscaled]],Map[((xl≤ #[[1]] ≤xr)&& (yd≤ #[[2]] ≤ yu))&,ptszhtscaled]];
Length[AcceptedVertexIndices]
AcceptedVertexIndices[[1;;10]]

xl 
xr
yd
yu

InteriorPointQ[x_,y_] := xl ≤ x ≤  xr && yd≤ y ≤ yu
ExteriorPointQ[x_,y_] := x < xl || x > xr || y < yd || y > yu

InteriorEdgeQ[edge_] := Module[{v1,v2,p1x,p1y,p1z,p2x,p2y,p2z},{v1,v2}= edgevertices[edge];
{p1x,p1y,p1z}= ptszhtscaled[[v1]];
{p2x,p2y,p2z}= ptszhtscaled[[v2]];
InteriorPointQ[p1x,p1y] && InteriorPointQ[p2x,p2y]
]

BorderEdgeQ[edge_] := Module[{v1,v2,p1x,p1y,p1z,p2x,p2y,p2z,t1,t2},{v1,v2}= edgevertices[edge];
{p1x,p1y,p1z}= ptszhtscaled[[v1]];
{p2x,p2y,p2z}= ptszhtscaled[[v2]];
t1= InteriorPointQ[p1x,p1y];
t2=InteriorPointQ[p2x,p2y];
(t1 && !t2) || (!t1 && t2)
]

ExteriorEdgeQ[edge_] :=  Module[{v1,v2,p1x,p1y,p1z,p2x,p2y,p2z},{v1,v2}= edgevertices[edge];
{p1x,p1y,p1z}= ptszhtscaled[[v1]];
{p2x,p2y,p2z}= ptszhtscaled[[v2]];
ExteriorPointQ[p1x,p1y] && ExteriorPointQ[p2x,p2y]
]

InteriorEdges= Select[Range[currentedge-1],
InteriorEdgeQ[#]&];
InteriorEdges//Short
InteriorEdges//Length

ptszhtscaled[[23,1;;2]]

InteriorVertexIndices= Select[Range[Length[ptszhtscaled]],
(InteriorPointQ@@ptszhtscaled[[#,1;;2]])&];
InteriorVertexIndices//Short
InteriorVertexIndices//Length

ExteriorEdges= Select[Range[currentedge-1],
ExteriorEdgeQ[#]&];
ExteriorEdges//Short
ExteriorEdges//Length

currentedge-1 - Length[ExteriorEdges] - Length[InteriorEdges]

BorderEdges= Select[Range[currentedge-1],
BorderEdgeQ[#]&];
BorderEdges//Short
BorderEdges//Length

Map[ptszhtscaled[[#]]&,(edgevertices[InteriorEdges[[1]]])]
Map[ptszhtscaled[[#]]&,(edgevertices[ExteriorEdges[[1]]])]
Map[ptszhtscaled[[#]]&,(edgevertices[BorderEdges[[1]]])]

CutEdge[borderedge_] := Module[{inside, outside, e1,e2,trx,tlx,tdy,tuy,tmin,pin,pout,dx,dy},
{e1,e2}= edgevertices[borderedge];

{inside,outside}=
If[
MemberQ[AcceptedVertexIndices,e1],
{e1,e2},
{e2,e1}
];
pin=ptszhtscaled[[inside]];
pout=ptszhtscaled[[outside]];
(*Print[{pin,pout}];*)
dx=(pin[[1]]-pout[[1]]);
dy = (pin[[2]]-pout[[2]]);

(*Print[{pin,pout,dx,dy}];*)
If[PossibleZeroQ[dx],dx=10^(-12)];
If[PossibleZeroQ[dy],dy=10^(-12)];
trx= (xr-pout[[1]])/dx;
tlx= (xl-pout[[1]])/dx;

tuy= (yu-pout[[2]])/dy;
tdy= (yd-pout[[2]])/dy;

tmin = Min[Select[{trx,tlx,tuy,tdy},(0< #<1)&]];
(*Print[{tmin,tlx,tlx,tuy,tdy}];*)
{pin, tmin pin + (1-tmin)pout}
]

CutEdge[BorderEdges[[34]]]

CutEdge[798]

(*SelectedEdgeVertices[i_] :=Map[PlaceInAcceptedList[#,AcceptedVertexIndices]&,edgevertices[i]]*)

interiorlistEdges =
Table[
{
Hue[0.66jmag[i]],
AbsoluteThickness[strainmagdata[[i]]],
Line[edgevertices[i]]
}
,
{i,InteriorEdges}];
interiorlistEdges//Short

BorderEdges[[2]]

CutEdge[BorderEdges[[2]]]

CutEdge[BorderEdges[[24]]]

ProgressIndicator[Dynamic[n],{1,currentedge-1}]

InteriorEdgeQ[798]

InteriorPointQ[5069]

InteriorPointQ[9.059605618953016`,0.`]
InteriorPointQ[8.905509599718043`,0.`]

edgevertices[798]

ptszhtscaled[[5069]]
ptszhtscaled[[5070]]

edgevertices[2]

Map[ptszhtscaled[[#]]&,edgevertices[2]]

interiorlistCylinders =Table[{
Hue[0.66jmag[i]],(*EdgeForm[],*)
Cylinder[Map[ptszhtscaled[[#]]&,edgevertices[i]],strainmagdata[[i]]]},{i,InteriorEdges}];
borderlistCylinders={EdgeForm[],Table[{
Hue[0.66jmag[i]],
Cylinder[CutEdge[i],strainmagdata[[i]]]},{i,BorderEdges}]};
Dimensions[borderlistCylinders]

Dimensions[interiorlistCylinders]

interiorlistCylinders[[2,1;;2]]

(*borderlistCylinders*)

(*Length[clistSelected]
clistSelected[[1;;23]]*)

slist=Table[n=i;em = maxedgevalue[i,strainmagdata];
{Hue[0.66First[avededgevalue[i,jmagdata]]],EdgeForm[],Sphere[i,First[em]]},{i,1,Length[pts]}];

slistSelected=
Table[{Hue[0.66First[avededgevalue[i,jmagdata]]],Sphere[i,First[maxedgevalue[i,strainmagdata]]]},
{i,InteriorVertexIndices}];
slistSelected//Short
slistSelected//Length

slistSelected=
Table[{Hue[0.66First[avededgevalue[i,jmagdata]]],Sphere[ptszhtscaled[[i]],First[maxedgevalue[i,strainmagdata]]]},
{i,InteriorVertexIndices}];
slistSelected//Short
slistSelected//Length

clist[[12]]

slist[[12]]

slistSelected[[1;;12]]

Min[Table[strainmagdata[[i]],{i,1,currentedge-1}]]

Max[Table[strainmagdata[[i]],{i,1,currentedge-1}]]

interiormeshgraphic=Graphics3D[{EdgeForm[],interiorlistCylinders,slistSelected},Boxed->False(*,Method-> {"CylinderPoints"->6, "SpherePoints"-> 6}*)]

borderlistCylinders[[1]]

bordermeshgraphic=Graphics3D[borderlistCylinders,Boxed->False (*,Method-> {"CylinderPoints"->6, "SpherePoints"-> 6}*)]

panelgraphic=Show[interiormeshgraphic,bordermeshgraphic]

Export["/Users/ccarter/People/Neri/Butterfly/Panels/Vertical/Vertical__"<>ToString[Round@xl]<>"-"<>ToString[Round@xr]<> "__"<> ToString[Round@yd]<> "-"<> ToString[Round@yu]<>".wrl",interiormeshgraphic,"VRML"]

Sound[{SoundNote["C"],SoundNote["G"]}]

Beep[]

WriteCylinder[{v1_,v2_}, rad_, hue_]:=
Module[{axis, angle, midpoint,color,height},
angle = VectorAngle[{0,1,0},v2-v1];
axis = Normalize[Cross[{0,1,0},v2-v1]];
midpoint = (v1+v2)/2;
height = Norm[v2-v1];
color = Blend[{Red,Blue},hue];
WriteString[outstream,"Transform {\n translation ", midpoint[[1]]," ", midpoint[[2]], " ",midpoint[[3]], "\n rotation ", axis[[1]], " " , axis[[2]], " ", axis[[3]], " ", angle,"\n children\n  Shape {\n   appearance Appearance {material Material { diffuseColor " , color[[1]], " ", color[[2]]," ", color[[3]]," }}\n geometry Cylinder {radius ",rad, " height ", height, "  }\n}\n}\n"];
]

WriteSphere[v1_, rad_, hue_]:=
Module[{color},
color = Blend[{Red,Blue},hue];
WriteString[outstream,"Transform {\n translation ", v1[[1]]," ", v1[[2]], " ",v1[[3]], "\n children\n  Shape {\n appearance Appearance {material Material { diffuseColor " , color[[1]], " ", color[[2]]," ", color[[3]]," }}\n geometry Sphere {radius ",rad, " }\n }\n}\n"];
]

Clear[outstream]

outstream =OpenWrite["dvlpmat3.wrl"]
WriteString[outstream,"#VRML V2.0 utf8\n\n"];

Table[WriteCylinder[
Map[ptszhtscaled[[#]]&,edgevertices[i]],strainmagdata[[i]],jmag[i]],{i,InteriorEdges}];

Table[WriteCylinder[
CutEdge[i],strainmagdata[[i]],jmag[i]],{i,BorderEdges}];

Table[WriteSphere[ptszhtscaled[[i]],First[maxedgevalue[i,strainmagdata]],
First[avededgevalue[i,jmagdata]]],{i,InteriorVertexIndices}];

Close[outstream]

WriteSphere[{1,2,3},2,.5]

First[maxedgevalue[1,strainmagdata]]

ptszhtscaled[[1]]

CutEdge[232]

0.66First[avededgevalue[1,jmagdata]]

WriteCylinder[{.1,.2,.3},{1,4,2},1,.2]

WriteCylinder[{.2,-1,.1},{2,1,0},1.5,.7]

q

VectorAngle[{0,0,1},{1,0,0}]

jmagdata= Table[jmag[i], {i,1,currentedge-1}];

Histogram[temp]

maxedgevalue[vertex_, edgevaluelist_]:= Module[
{edges,vals,max},
edges = edgesOfVertex[[vertex]];
vals=Map[edgevaluelist[[#]]&, edges];
Flatten@{max = Max[vals],
Pick[edges,vals, max]}
]

avededgevalue[vertex_, edgevaluelist_]:= Module[
{edges,vals,max},
edges = edgesOfVertex[[vertex]];
vals=Map[edgevaluelist[[#]]&, edges];
Flatten@{max = Mean[vals],
Pick[edges,vals, max]}
]

ptszhtscaled[[451]]

Length[ptszhtscaled]/16//N

currentedge

xl=9; xr=18; yd=9; yu=18;
AcceptedVertexIndices =
Pick[Range[Length[ptszhtscaled]],Map[((xl≤ #[[1]] ≤xr)&& (yd≤ #[[2]] ≤ yu))&,ptszhtscaled]];
Length[AcceptedVertexIndices]
AcceptedVertexIndices[[1;;10]]

RejectedVertexIndices =
Complement[Range[Length[ptszhtscaled]],AcceptedVertexIndices];
Length[RejectedVertexIndices]
RejectedVertexIndices[[1;;10]]

PlaceInAcceptedList[arbitraryVertex_, AcceptedList_] := Position[AcceptedVertexIndices,arbitraryVertex][[1,1]]

Position[AcceptedVertexIndices,313]

PlaceInAcceptedList[arbitraryVertex_, AcceptedList_] := Position[AcceptedVertexIndices,arbitraryVertex][[1,1]]

PlaceInAcceptedList[457,AcceptedVertexIndices]

ptszhtscaled[[452]]

edgevertexlist[[2]]

AcceptedEdges=
Map[
(MemberQ[AcceptedVertexIndices,First[#]]&& MemberQ[AcceptedVertexIndices,Last[#]])&,
Table[edgevertexlist[[i]],{i,1,currentedge-1}]];

BorderEdges= (*true false for every edge*)
Map[
(
(MemberQ[AcceptedVertexIndices,First[#]]&& !MemberQ[AcceptedVertexIndices,Last[#]])
||
(!MemberQ[AcceptedVertexIndices,First[#]]&& MemberQ[AcceptedVertexIndices,Last[#]])
)&,
Table[edgevertexlist[[i]],{i,1,currentedge-1}]];

Length[AcceptedEdges]
AcceptedEdges[[1;;35]]

Length[BorderEdges]
BorderEdges[[1;;35]]

SelectedEdges= Pick[Range[currentedge-1],AcceptedEdges];

Length[SelectedEdges]
SelectedEdges[[1;;35]]

SelectedBorderEdges= Pick[Range[currentedge-1],BorderEdges];

Length[SelectedBorderEdges]
SelectedBorderEdges[[1;;35]]

AcceptedVertexCoords= Select[ptszhtscaled,((xl≤  #[[1]] ≤ xr)&& (yd≤  #[[2]] ≤  yu))&];
Length[AcceptedVertexCoords]
AcceptedVertexCoords[[1;;10]]

RejectedVertexCoords= Select[ptszhtscaled,!((xl< #[[1]] <xr)&& (yd< #[[2]] < yu))&];
Length[RejectedVertexCoords]
RejectedVertexCoords[[1;;10]]

edgevertexlist[[24661]]

ptszhtscaled[[15169]]
ptszhtscaled[[2430]]

edgevertices[38586]

SelectedEdgeVertices[i_] :=Map[PlaceInAcceptedList[#,AcceptedVertexIndices]&,edgevertices[i]]

SelectedEdgeVertices[24700]

edgevertices[12]

AcceptedVertexIndices[[1]]

CutEdge[borderedge_] := Module[{inside, outside, e1,e2,trx,tlx,tdy,tuy,tmin,pin,pout,dx,dy},
{e1,e2}= edgevertices[borderedge];

{inside,outside}=
If[
MemberQ[AcceptedVertexIndices,e1],
{e1,e2},
{e2,e1}
];
pin=ptszhtscaled[[inside]];
pout=ptszhtscaled[[outside]];
dx=(pin[[1]]-pout[[1]]);
dy = (pin[[2]]-pout[[2]]);
Print[{pin,pout,dx,dy}];
trx= (xr-pout[[1]])/(pin[[1]]-pout[[1]]);
tlx= (xl-pout[[1]])/(pin[[1]]-pout[[1]]);

tuy= (yu-pout[[2]])/(pin[[2]]-pout[[2]]);
tdy= (yd-pout[[2]])/(pin[[2]]-pout[[2]]);

tmin = Min[Select[{trx,tlx,tuy,tdy},(0< #<1)&]];
Print[{tmin,tlx,tlx,tuy,tdy}];
{pin, tmin pin + (1-tmin)pout}
]

CutEdge[24659]

edgevertices//Short

Print[{1,edgevertices[[1]],MemberQ[edgevertices[[1]],AcceptedVertexIndices]}];
Print[{2,edgevertices[[2]],MemberQ[edgevertices[[2]],AcceptedVertexIndices]}];

elist =
Table[
{
Hue[0.66jmag[i]],
AbsoluteThickness[strainmagdata[[i]]],
Line[edgevertices[i]]
}
,
{i,1,currentedge-1}];

Length[elist]
elist[[23]]

Length[elist]/16//N

ProgressIndicator[Dynamic[n],{1,currentedge-1}]

clist =Table[{
Hue[0.66jmag[i]],EdgeForm[],
Cylinder[edgevertices[i],strainmagdata[[i]]]},{i,1,currentedge-1}];
clistSelected=Map[{
Hue[0.66jmag[#]],
Cylinder[SelectedEdgeVertices[#],strainmagdata[[#]]]}&,SelectedEdges];

Length[clistSelected]
clistSelected[[1;;23]]

slist=Table[n=i;em = maxedgevalue[i,strainmagdata];
{Hue[0.66First[avededgevalue[i,jmagdata]]],EdgeForm[],Sphere[i,First[em]]},{i,1,Length[pts]}];

slistSelected=Map[{Hue[0.66First[avededgevalue[#,jmagdata]]],Sphere[PlaceInAcceptedList[#,AcceptedVertexIndices],First[maxedgevalue[#,strainmagdata]]]}&,AcceptedVertexIndices];

clist[[12]]

slist[[12]]

slistSelected[[1;;12]]

Min[Table[strainmagdata[[i]],{i,1,currentedge-1}]]

Max[Table[strainmagdata[[i]],{i,1,currentedge-1}]]

meshgraphic=Graphics3D[{EdgeForm[],GraphicsComplex[ptszhtscaled,Join[clistSelected,slistSelected]]},Boxed->False,Method->{"CylinderPoints"->6,"SpherePoints"-> 6}];

meshgraphic=Graphics3D[{EdgeForm[],GraphicsComplex[AcceptedVertexCoords,Join[clistSelected,slistSelected]]}(*Join[clistSelected,slistSelected]]*),Boxed->False,Method->{"CylinderPoints"->6,"SpherePoints"-> 6}];

Show[meshgraphic,ImageSize-> Large]

(*meshgraphic*)

Export["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh/subject_03_horizontal_cylinders_spheres_14June_17-28_8-19.dxf",meshgraphic,"DXF"]

(*Export["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh/subject_03_vertical_cylinders.stl",meshgraphic,"STL"]*)

postscript mesh for 2d with lines no lines and text

PolygonCenters=Table[Mean[Map[pts[[#]]&,pgons[[i]]]],{i,1,Length[pgons]}];
PolygonCoords = Table[Map[pts[[#]]&,pgons[[i]]],{i,1,Length[pgons]}];

PolygonMeanCoords= Table[Table[PolygonCoords[[i,j]]-PolygonCenters[[i]],{j,1,Length[PolygonCoords[[i]]]}],{i,1,Length[pgons]}];

PolygonAreaApprox=Table[Norm[StandardDeviation[PolygonMeanCoords[[i]]]],{i,1,Length[pgons]}];

PolygonAreaExact[i_]:=Module[{pg=PolygonMeanCoords[[i]],nsides,v1,v2,v3,area1, area2},nsides=Length[pg];
If[nsides ≠ 3 ,nsides ≠ 4, Return[0]];

v1=pg[[2]]-pg[[1]]; v2=pg[[3]]-pg[[1]];
area1= Abs[v1 [[1]] v2[[2]] - v1[[2]]v2[[1]]];

If[nsides==3,Return[area1]];

If[nsides==4,v3=pg[[4]]-pg[[1]];Return[area1 + Abs[v2[[1]] v3[[2]] - v2[[2]] v3[[1]]]]] 
]

PolygonAreaExact[124]

PolygonAreas = Table[PolygonAreaExact[i],{i,1,Length[pgons]}];

Min[PolygonAreas]

PolygonAreas[[12]]

Sort[PolygonAreas]//Short

Max[PolygonAreas]

Mean[PolygonAreas]

StandardDeviation[PolygonAreas]

InverseAspectRatios= Table[StandardDeviation[PolygonMeanCoords[[i]]][[1]]/(StandardDeviation[PolygonMeanCoords[[i]]][[2]] + 0.00001),{i,1,Length[pgons]}];

Min[InverseAspectRatios]
Max[InverseAspectRatios]
Mean[InverseAspectRatios]
StandardDeviation[InverseAspectRatios]

AspectRatios= Table[StandardDeviation[PolygonMeanCoords[[i]]][[2]]/(StandardDeviation[PolygonMeanCoords[[i]]][[1]] + 0.00001),{i,1,Length[pgons]}];

Min[AspectRatios]
Max[AspectRatios]
Mean[AspectRatios]
StandardDeviation[AspectRatios]

PolygonMeanCoords[[23]]

Length[PolygonMeanCoords[[23]]]

StandardDeviation[PolygonMeanCoords[[23]]]

Angle[edge_] := Module[{dx,dy,p=pts[[edgevertices[edge]]]},{dx,dy} = p[[2]]-p[[1]]; ArcTan[dx,dy]]

MidPoint3D[edge_] := Module[{v1,v2,xave,yave,zave}, {v1,v2}=edgevertices[edge];{xave,yave}= MidPoint[edge]; zave =(10000) 0.5 (zht[v1] + zht[v2]); 
{xave,yave,zave}]

energyxy[{x_,y_}] := energyfunc[x,y]

elisttext =Table[{
GrayLevel[1-energyxy[PolygonCenters[[i]]]],
Text[Style[smag[i],FontSize->4,FontFamily->"Helvetica"],PolygonCenters[[i]]]
},{i,1,Length[pgons]}];

elisttext[[23]]

PolygonAreas[[23]]

ReducedPolygonAreas= Select[PolygonAreas,# > 48 &];

Length[ReducedPolygonAreas]

PolygonAreas[[23]]≤  200

elisttextlimit6=Table[{If[PolygonAreas[[iii]]≥  6 ,
GrayLevel[1-energyxy[PolygonCenters[[iii]]]],
Text[Style[smag[iii],FontSize->4,FontFamily->"Helvetica"],PolygonCenters[[iii]]]]
},{iii,1,Length[pgons]}];

elisttextlimit6={};
For[iii=1, iii≤ Length[pgons],iii++,
If[PolygonAreas[[iii]]≥  6  && InverseAspectRatios[[iii]] ≥ 3,AppendTo[elisttextlimit6,{GrayLevel[1-energyxy[PolygonCenters[[iii]]]],
Text[Style[smag[iii],FontSize->4,FontFamily->"Helvetica"],PolygonCenters[[iii]]]}]]]

elisttextlimit8={};
For[iii=1, iii≤ Length[pgons],iii++,
If[PolygonAreas[[iii]]≥  8 && InverseAspectRatios[[iii]] ≥ 2,AppendTo[elisttextlimit8,{GrayLevel[1-energyxy[PolygonCenters[[iii]]]],
Text[Style[smag[iii],FontSize->4,FontFamily->"Helvetica"],PolygonCenters[[iii]]]}]]]

Length[pgons]

Length[elisttext]
Length[elisttextlimit6]
Length[elisttextlimit8]

(*elist =Table[{
Hue[0.66jmag[i]],
AbsoluteThickness[smag[i]],
Line[edgevertices[i]]},{i,1,currentedge-1}];*)

(*elistlines =Table[{
Hue[0.66(energy[i])],
AbsoluteThickness[smag[i]],
Line[edgevertices[i]]
},{i,1,currentedge-1}];*)

graphtext=Graphics[Flatten[elisttext],ImageSize-> {72 7, 72 10}];

graphtextlimit6=Graphics[Flatten[elisttextlimit6],ImageSize-> {72 7, 72 10}];

graphtextlimit8=Graphics[Flatten[elisttextlimit8],ImageSize-> {72 7, 72 10}];

graphlines=Graphics[GraphicsComplex[pts,elist],ImageSize-> {72 7, 72 10}];

Export["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh/vertical_mesh_with_no_text.eps",graphlines,"eps"]

(*graphtext*)

Export["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh/vertical_alltext_with_no_mesh.eps",graphtext,"eps"]

graphtextlimit6

Export["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh/vertical_text_with_no_mesh_area=6_limit.eps",graphtextlimit6,"eps"]

graphtextlimit8

Export["/Users/ccarter/People/Neri/MeshSubject_03/Medium_Fine_Mesh/vertical_text_with_no_mesh_area=8_limit.eps",graphtextlimit8,"eps"]