// jvx.cmd // Create jvx file for JavaView. /* 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 on both sides. */ // Usage: jvx >>> "filename.jvx" define vertex attribute jvx_number integer; // for implicit vertex order define facet attribute fjvxnum integer; // for implicit facet order define rgb_jvx integer[16][3]; // color definitions rgb_jvx[1][1] := 0; rgb_jvx[1][2] := 0; rgb_jvx[1][3] := 0; rgb_jvx[2][1] := 0; rgb_jvx[2][2] := 0; rgb_jvx[2][3] := 255; rgb_jvx[3][1] := 0; rgb_jvx[3][2] := 255; rgb_jvx[3][3] := 0; rgb_jvx[4][1] := 0; rgb_jvx[4][2] := 255; rgb_jvx[4][3] := 255; rgb_jvx[5][1] := 255; rgb_jvx[5][2] := 0; rgb_jvx[5][3] := 0; rgb_jvx[6][1] := 255; rgb_jvx[6][2] := 0; rgb_jvx[6][3] := 255; rgb_jvx[7][1] := 255; rgb_jvx[7][2] := 127; rgb_jvx[7][3] := 0; rgb_jvx[8][1] := 160; rgb_jvx[8][2] := 160; rgb_jvx[8][3] := 160; rgb_jvx[9][1] := 80; rgb_jvx[9][2] := 80; rgb_jvx[9][3] := 80; rgb_jvx[10][1] := 80; rgb_jvx[10][2] := 200; rgb_jvx[10][3] := 255; rgb_jvx[11][1] := 127; rgb_jvx[11][2] := 255; rgb_jvx[11][3] := 127; rgb_jvx[12][1] := 127; rgb_jvx[12][2] := 255; rgb_jvx[12][3] := 255; rgb_jvx[13][1] := 255; rgb_jvx[13][2] := 127; rgb_jvx[13][3] := 127; rgb_jvx[14][1] := 255; rgb_jvx[13][2] := 127; rgb_jvx[13][3] := 255; rgb_jvx[15][1] := 255; rgb_jvx[15][2] := 255; rgb_jvx[15][3] := 0; rgb_jvx[16][1] := 255; rgb_jvx[16][2] := 255; rgb_jvx[16][3] := 255; jvx := { local maxx,minx,maxy,miny,maxz,minz,jvxnum,facetnum; local colornum,numcolors; local facetcolorcount,edgecolorcount; define facetcolorcount integer[16]; // to see which color facets are present define edgecolorcount integer[16]; // to see which color edges are present if torus then { errprintf "Cannot run 'jvx' command in torus mode. Do 'detorus' before 'jvx'.\n"; errprintf " WARNING: 'detorus' alters the surface, so save it first!\n"; abort; }; if symmetry_group then { errprintf "Cannot run 'jvx' command in symmetry group mode. Do 'detorus' before 'jvx'.\n"; errprintf " WARNING: 'detorus' alters the surface, so save it first!\n"; abort; }; if space_dimension != 3 then { errprintf "The 'jvx' command must be run in three-dimensional space.\n"; abort; }; if surface_dimension == 1 then { errprintf "The 'jvx' command is not meant for the string model.\n"; abort; }; if simplex_representation then { errprintf "The 'jvx' command is not meant for the simplex model.\n"; abort; }; if lagrange_order >= 2 then { errprintf "The 'jvx' command is meant for the linear model, not quadratic or Lagrange.\n"; abort; }; if rgb_colors then { errprintf "The 'jvx' command does not do RGB colors; do rgb_colors off.\n"; abort; }; // First, bounding box. maxx := max(vertex,x); minx := min(vertex,x); maxy := max(vertex,y); miny := min(vertex,y); maxz := max(vertex,z); minz := min(vertex,z); printf "\n"; printf "\n"; printf "\n"; // printf "\n",date_and_time; printf " %s \n",datafilename; printf "1.0\n"; /* printf "\n"; printf " \n"; printf " Kenneth\n"; printf " Brakke\n"; printf " \n"; printf " Susquehanna University\n"; printf "
\n"; printf " Mathematics Department\n"; printf " Susquehanna University\n"; printf " Selinsgrove, PA 17870\n"; printf " USA\n"; printf "
\n"; printf "
\n"; printf " brakke@susqu.edu\n"; printf " http://www.susqu.edu/brakke\n"; printf "
\n"; printf "
\n"; printf "\n"; printf " One-line description of surface.\n"; printf " \n"; printf " Paragraph of description here.\n"; printf " \n"; printf " \n"; printf " minimal surface\n"; printf " \n"; printf " \n"; printf " 49Q20\n"; printf " optional \n"; printf " optional \n"; printf " \n"; printf " Surface Evolver 2.16\n"; printf "\n"; */ printf "\n"; printf " \n"; printf " \n"; printf " \n",vertex_count; jvxnum := 0; foreach vertex vv do { printf "

%f %f %f

\n",vv.x,vv.y,vv.z; vv.jvx_number := jvxnum; jvxnum += 1; }; printf "
\n"; printf "
\n"; facetnum := 0; foreach facet ff where ff.show and color != clear do { ff.fjvxnum := facetnum; facetnum += 1; }; colornum := 1; while colornum <= 16 do { facetcolorcount[colornum] := 0; colornum += 1; }; foreach facet ff where ff.show and color != clear do facetcolorcount[ff.color+1] += 1; colornum := 1; numcolors := 0; while colornum <= 16 do { if facetcolorcount[colornum] > 0 then numcolors += 1; colornum += 1; }; if numcolors > 1 then printf " \n" else printf " \n"; printf " \n",sum(facets,show); foreach facet ff where ff.show and color != clear do { printf " %d %d %d \n",ff.vertex[1].jvx_number, ff.vertex[2].jvx_number, ff.vertex[3].jvx_number; }; if numcolors <= 1 then { colornum := 1; while colornum <= 16 do { if facetcolorcount[colornum] > 0 then printf " %d %d %d \n",rgb_jvx[colornum][1], rgb_jvx[colornum][2],rgb_jvx[colornum][3]; colornum += 1; }; }; printf " \n"; if numcolors > 1 then { printf " \n"; foreach facet ff where ff.show and color != clear do { printf " %d %d %d \n",rgb_jvx[ff.color+1][1], rgb_jvx[ff.color+1][2],rgb_jvx[ff.color+1][3]; }; printf " \n"; }; printf " \n",sum(facets,show); foreach facet ff where ff.show and color != clear do printf " %d %d %d \n", ff.edge[2].valence == 2 ? max(ff.edge[2].facet where id != ff.id,fjvxnum) : -1, ff.edge[3].valence == 2 ? max(ff.edge[3].facet where id != ff.id,fjvxnum) : -1, ff.edge[1].valence == 2 ? max(ff.edge[1].facet where id != ff.id,fjvxnum) : -1; printf " \n"; // printf " \n",sum(edges,show); // foreach edge ee where ee.show do // { printf " %d %d \n",ee.vertex[1].jvx_number, // ee.vertex[2].jvx_number; // }; // printf " 0 0 0 \n"; // printf " \n"; printf " \n"; printf " 1.0 \n"; printf " 0 0 0\n"; printf " \n"; printf " \n"; printf " \n"; printf "

%f %f %f

\n",minx,miny,minz; printf "

%f %f %f

\n",maxx,maxy,maxz; printf "
\n"; printf "
\n"; printf "

%f %f %f

\n",(maxx+minx)/2,(maxy+miny)/2, (maxz+minz)/2; printf "
\n"; printf "
\n"; colornum := 1; while colornum <= 16 do { edgecolorcount[colornum] := 0; colornum += 1; }; foreach edge ee where ee.show do edgecolorcount[ee.color+1] += 1; colornum := 1; numcolors := 0; while colornum <= 16 do { if edgecolorcount[colornum] > 0 then numcolors += 1; colornum += 1; }; printf " \n"; printf " \n"; printf " \n",2*sum(edges,show); foreach edge ee where ee.show do { printf "

%f %f %f

\n",ee.vertex[1].x,ee.vertex[1].y,ee.vertex[1].z; printf "

%f %f %f

\n",ee.vertex[2].x,ee.vertex[2].y,ee.vertex[2].z; }; printf "
\n"; printf "
\n"; if numcolors > 1 then printf " \n" else printf " \n"; printf " \n",sum(edges,show); jvxnum := 0; foreach edge ee where ee.show do { printf " %d %d \n",jvxnum,jvxnum+1; jvxnum += 2; }; printf " 2 \n"; if numcolors <= 1 then { colornum := 1; while colornum <= 16 do { if edgecolorcount[colornum] > 0 then printf " %d %d %d \n",rgb_jvx[colornum][1], rgb_jvx[colornum][2],rgb_jvx[colornum][3]; colornum += 1; }; }; printf " \n"; if ( numcolors > 1 ) then { printf " \n"; foreach edge ee where ee.show do { printf " %d %d %d \n", rgb_jvx[ee.color+1][1], rgb_jvx[ee.color+1][2],rgb_jvx[ee.color+1][3]; }; printf " \n"; }; printf " \n"; printf " \n"; printf "

%f %f %f

\n",minx,miny,minz; printf "

%f %f %f

\n",maxx,maxy,maxz; printf "
\n"; printf "
\n"; printf "

%f %f %f

\n",(maxx+minx)/2,(maxy+miny)/2, (maxz+minz)/2; printf "
\n"; printf "
\n"; printf "
\n"; printf "
\n"; } // End jvx.cmd /* Usage: Set "show" criterion for edges and facets, if you want, and do jvx >>> "filename.jvx" */