Surface Evolver Documentation

Back to top of Surface Evolver documentation.       Index.

Surface Evolver Script Examples

This page lists some sample command script files. Fuller descriptions are below. The files are included in the Evolver distribution in the fe folder, and thus should be on the EVOLVERPATH so Evolver can find them.

You read a script file into Evolver with the read command, for example

   Enter command: read "3ds.cmd"
In general, each script contains one main command, whose name is the same as the file name, e.g. adjoint.cmd contains the adjoint command, except for when this would result in an illegal name or a conflict with an Evolver keyword. Each file has usage instructions in the comments in the top of the file.

A list of the script files:

Of these, many people are particularly interested in scripts that can export files that other software can read, so here is a list of file export scripts. These generally work by running the command with the output re-directed to a file, for example

   Enter command: read "collada.cmd"
   Enter command: collada >>> "filename.cda"
Note that >>> results in over-writing any existing file of the same name.
The export script files:

3ds.cmd

Script to produce Autodesk 3DS format file.

Usage: do_3ds >>> "filename.3ds"

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).
Limited to 65535 facets.
Does facets only, not edges.
Facet color is frontcolor on both sides.


adjoint.cmd

Script for the calculation of the adjoint minimal surface using Konrad Polthier's discrete conjugate method of Bonnet rotation. See

Ulrich Pinkall and Konrad Polthier, Computing Discrete Minimal Surfacee and Their Conjugates, Experim. Math. 2(1) (1993) 15-36

and

Konrad Polthier, Conjugate Harmonic Maps and Minimal Surfaces.

The "adjoint" of a smooth minimal surface is another minimal surface isometric to the first that has normals in the same direction at each point but the infinitesimal surface element rotated 90 degrees about the normal. Schwartz' P and D surfaces are adjoints of each other.

A "discrete minimal surface" is made up of flat triangles. It is called "conforming" if the vertices of adjacent triangles coincide, and "nonconforming" if adjacent triangles only meet at their midpoints. Polthier shows that if a conforming discrete minimal surface minimizes area, then it has an exact nonconforming adjoint.

The adjoint command in this file takes a conforming surface and calculates the nonconforming adjoint, then tweaks vertices to make it conforming, so it is a legal Surface Evolver surface.

Assumptions:

Usage: adjoint

After adjoint has been run, you can flip back and forth between the original and the adjoint with the flip command.

Usage: flip

Before running adjoint, you can set the variable starte to the number of the edge whose midpoint will remain fixed in place; default is edge[1].

The angle of the Bonnet rotation is set by the variable bangle, which you may set to any degree value before doing adjoint. The default value of bangle is 90 degrees.

Also this file has the command write_conjugate to write a datafile to stdout that is the nonconforming discrete adjoint, with separated vertices. Use this to see Polthier's idea in its true form.

Usage: write_conjugate >>> "filename.fe"

For a slightly more elaborate approach using complex numbers for the adjoint coordinates, which is faster for doing multiple arbitrary rotations, see adjointc.cmd. This file and adjointc.cmd have non-overlapping namespaces, so both can be loaded simultaneously.

See my page on triply periodic minimal surface for examples created with adjoint.


adjointc.cmd

Another script for the calculation of the adjoint minimal surface using Konrad Polthier's discrete conjugate method of Bonnet rotation. See

Ulrich Pinkall and Konrad Polthier, Computing Discrete Minimal Surfacee and Their Conjugates, Experim. Math. 2(1) (1993) 15-36

and

Konrad Polthier, Conjugate Harmonic Maps and Minimal Surfaces.

The "adjoint" of a smooth minimal surface is another minimal surface isometric to the first that has normals in the same direction at each point but the infinitesimal surface element rotated 90 degrees about the normal. Schwartz' P and D surfaces are adjoints of each other.

A "discrete minimal surface" is made up of flat triangles. It is called "conforming" if the vertices of adjacent triangles coincide, and "nonconforming" if adjacent triangles only meet at their midpoints. Polthier shows that if a conforming discrete minimal surface minimizes area, then it has an exact nonconforming adjoint.

The adjointc procedure in this file takes a conforming surface and calculates the nonconforming adjoint, then tweaks vertices to make it conforming, so it is a legal Surface Evolver surface.

Assumptions:

Usage: adjointc( real bangle, integer origin_vertex )
Arguments:

After adjointc has been run, one may do other Bonnet rotations more quickly by calling bonnet_rotation()

Usage: bonnet_rotation(real bangle, integer origin_vertex )
Arguments:

Also this file has the command "write_conj" to write a datafile to stdout that is the nonconforming discrete adjoint, with separated vertices. Use this to see Polthier's idea in its true form.

Usage: write_conj >>> "filename.fe"

For a slightly simpler approach using just real numbers for the adjoint coordinates, see adjoint.cmd. This file and adjoint.cmd have non-overlapping namespaces, so both can be loaded simultaneously.

See my page on triply periodic minimal surfaces for examples of files adjointc can be used with.


ansys.cmd

Command to produce file of ANSYS input for vertices, edges, and faces to produce a surface for ANSYS meshing. Beware this is a very simple-minded translation to ANSYS format.

Assumptions and limitations:

Usage: ansys >>> "filename"


band.cmd

Command script to create triangulated bands bordering deisgnated edges and vertices. The purpose is to make extremely accurate borders on surfaces in PostScript files, since just drawing thick edges can lead to notching where interior facets are drawn afterwards.

WARNING: This command modifies the surface by creating a lot of tiny facets. You should use only on a disposable copy of your surface.

Assumptions:

Usage:

  1. Set bandcolor and bandwidth to desired values; bandwidth is the width of the band in surface coordinates on one side of an edge.
  2. Set the edge attribute inband to nonzero for those edges to have band drawn along them.
  3. Run makeband.
Example:
   read "band.cmd";
   bandwidth := 0.003;
   bandcolor := black;
   set edge inband on_constraint topcon;
   makeband
   set edge inband on_constraint leftcon;
   makeband
   set edge inband original==1;
   makeband
Note: If makeband has problems in corners and other tricky spots, run makeband several times on separate sets of edges. When setting inband for the later runs, make sure you zero out inband on the edges of the previous run. Notice the conditions in the example are Boolean, applied to all edges.

bonnet_movie.cmd

Makes in-memory movie of Bonnet rotation of minimal surface, one frame per degree for 360 degrees. Uses adjoint.cmd, so has the same assumptions.

Usage:

  1. Evolve initial minimal surface, remove all level-set constraints and boundaries, get nice view in graphics window.
  2. Run make_movie to calculate rotations.
  3. Run show_movie to see screen display of Bonnet rotation.
  4. Run movie to see endlessly repeating display of Bonnet rotation.
  5. Run postscript_movie to create sequence of PostScript files. The names of the PostScript files will be the datafilename with the frame number appended.

cmccousin.cmd

A constant mean curvature (CMC) surface in R^3 has a "cousin" minimal surface in S^3, which is isometric to it and has tangent planes rotated by 90 degrees. In S^3, the translation is done through the quaternion group.

This representation uses the 4th coordinate as the quaternion scalar component, for better mapping between R^3 and S^3 at quaternion unit.

Datafiles should be set up in 4 dimensions, with S^3 implemented as the level set constraint x^2 + y^2 + z^2 + w^2 = 1

Works best if starting edge starte is toward the center of the surface rather than on the outside.

Contained in this file:

s3_to_r3:
Converts minimal surface in S^3 to CMC 1 surface in R^3. Remove all constraints and boundaries before invoking.
r3_to_s3:
Converts CMC 1 surface in R^3 to minimal surface in S^3. Remove all constraints and boundaries before invoking.
centralize(integer v_id):
Procedure that translates S^3 so given vertex is at (0,0,0,1).

coff.cmd

Command script to print a Geomview color OFF file in ascii format.

Assumptions and limitations:

Usage:

  1. Read in the command file.
  2. Set the "show facets" criterion (optional).
  3. Run coff and redirect output to a file.
Example:
  Enter command: read "coff.cmd"
  Enter command: show facet where not fixed
  Enter command: coff >>> "filename.coff"

collada.cmd

Command script for creating Collada format file for a surface.

Assumptions and limitations:

Usage:

  1. Read in the command file.
  2. Set the show facets expression (optional).
  3. Run collada and redirect output to a file.
Example:
  Enter command: read "collada.cmd"
  Enter command: show facet where not fixed
  Enter command: collada >>> "filename.col"

complex.cmd

Some complex functions of complex arguments, mostly for use with Weierstrass representation of minimal surfaces. Each function has two versions, for returning the real and imaginary parts.

Contents:

Arguments:
rex,imx: real and imaginary parts of the complex argument.
Additional information on incompleteEllipticF: Have to beware branch points at +/- arcsin(1/sqrt(m)) + 2*pi*k, so the nbr_value input argument is for picking the proper branch by continuity; if 0, then the principle branch is picked. Branch values differ by 2*ellipticK(m). nbr_test is a boolean flag for whether to apply the aforementioned continuity test.
Reference: Abramowitz and Stegun 17.4.11


dirichlet_to_disk.cmd

Command script for mapping simply connected regions to unit disk minimizing Dirichlet energy to get conformal mappings.

Prerequisites: 2D soapfilm model with simply connected surface. Dirichlet_elastic energy defined using a named quantity, but no others, i.e. all facets given tension 0.

Usage: Remove all constraints and boundaries. Run to_disk or to_triangle. Then evolve.

Sample datafile: dirichlet_E.fe


dxf.cmd

Command script to produce AutoCad DXF files.

Assumptions and features:

Usage: dxf >>> "filename.dxf"


dxf_thick.cmd

Command script to produce AutoCad DXF files with separate facet frontcolor and backcolor.

Assumptions and features:

Usage: dxf_thick >>> "filename.dxf"


embox.cmd

Command script to create body-enclosing facets around outside of a foam section created by using the detorus command on a foam that's being displayed in clipped mode.
Assumptions:

Usage: set torus mode view to clipped, run detorus, then embox.

WARNING: embox does not nicely handle facets that are exactly on the bounding box walls, so if there are any such facets, it is advised to move the surface BEFORE doing detorus, i.e.

     clipped;
     set vertex x x+0.1;
     set vertex y y+0.1;
     set vertex z z+0.1;
     detorus;
     embox;

foamface.cmd

This file contains several command scripts useful in analyzing 3D foams in terms of full foam faces rather than Evolver facets.

Assumptions:

There are five useful commands:


foamface_jvx.cmd

Produces JavaView jvx file with foam cell faces as single jvx faces.

Assumptions and features:

Usage: foamface_jvx >>> "filename.jvx"

fourier.cmd

Procedure to print Fourier components for a closed curve. The curve is deemed to be the image of a unit circle into 3D, with the vertices being images of points uniformly spread around the circle. The sin and cos Fourier coefficients of the given order are computed and printed. The results are also stored in the variables x_sin_coeff, y_sin_coeff, z_sin_coeff, x_sin_coeff, y_sin_coeff, and z_sin_coeff for your convenience.

Assumptions:

Usage: f_component(integer order)

gaussequi.cmd

Command script to do edge equiangulation using the Gauss map for swap criterion. The Gauss map maps a surface to the unit sphere, each point being mapped to its unit normal vector. The facets of the original surface induce a triangulation of the Gauss sphere, and equiangulation can be calculated for the sphere triangulation. This command does that and does the indicated edge swaps. The idea is to make facets better follow curvature. But it has potential problems; it can produce zero area facets. Also, swapping an edge changes the Gauss map, so maybe things don't improve.

Assumptions:

Usage: gaussequi

gaussmap.cmd

The Gauss map maps a surface to the unit sphere, each point being mapped to its unit normal vector. This command script physically converts a surface to a spherical surface. It converts each vertex coordinate to its unit normal. The original coordinates are saved in the vertex vector attribute oldx so the revert command defined herein restores the original surface.

Assumptions:

Usage: gaussmap

gaussref.cmd

Procedure to refine edges using the Gauss map for the refinement criterion. The Gauss map maps a surface to the unit sphere, each point being mapped to its unit normal vector. The facets of the original surface induce a triangulation of the Gauss sphere, and edge length can be calculated for the sphere triangulation. The idea is to refine edges on the basis of curvature rather than length, and keep the number of edges needed to a minimum.

Assumptions:

Usage: gaussequi(real maxarc)
where maxarc is the cutoff arclength for refinement, in radians.

iges.cmd

Command script to write IGES file for surface, using IGES parametric patch entity (type 114).

Assumptions and features:

Usage: iges >>> "filename.igs"


iges114.cmd

Command script to write IGES file for surface, using IGES parametric patch entity (type 114). Different from iges.cmd in that it obeys the show facets criterion and also does quadratic and cubic models.

Assumptions and features:

Usage: iges114 >>> "filename.igs"


iges128.cmd

Command script to write IGES file for surface, using IGES rational B-spline entity (type 128).

Assumptions and features:

Usage: iges128 >>> "filename.igs"


iges144.cmd

Command script to write IGES file for surface, using IGES trimmed parametric surface entity (type 144).

Assumptions and features:

Usage: iges144 >>> "filename.igs"


intersect.cmd

Command script to detect intersection of linear edges and facets. For each facet, finds if any edge intersects in its interior.

Assumptions and features:

Usage: detect
Output: prints ids of facets and edges that intersect. Will not work in Lagrange model.


jvx.cmd

Command script to create a JavaView jvx file.

Assumptions and features:

Usage: jvx >>> "filename.jvx"


maya.cmd

Command script to write Maya ASCII file using one mesh for the whole surface. Reference: http://caad.arch.ethz.ch/info/maya/manual/FileFormats/index.html Also in Maya documentation: Developer Resources > File Formats > Maya ASCII file format > Maya ASCII f format > Organizationof Maya Ascii files

Assumptions and features:

Usage: maya >>> "filename.ma"

Note: The default length unit is cm, but if you want to use something different, then set the maya_length_unit variable to the appropriate string after loading maya.cmd and before running the maya command, e.g.

   maya_length_unit := "in"
   maya >>> "filename.ma"
Valid length unit strings are: "mm", "millimeter", "cm", "centimeter", "m", "meter", "km", "kilometer", "in", "inch", "ft", "foot", "yd", "yard", "mi", "mile".

Note: To prevent names generated by this script from conflicting with existing maya names or names from another datafile, there is a string variable maya_name that is prepended to all names generated by this script. There is a maya namespace feature that probably could be used in place of this, but I do not understand it yet. The maya_name default is "AAA"; I didn't use the datafilename since this may contain illegal characters and also would prevent generating multiple maya objects from the same datafile. So if you are going to use multiple surfaces simultaneously, change maya_name before executing the maya command.


maya1.cmd

Command script to write Maya ASCII file using separate mesh object for each facet. Reference: http://caad.arch.ethz.ch/info/maya/manual/FileFormats/index.html Also in Maya documentation: Developer Resources > File Formats > Maya ASCII file format > Maya ASCII f format > Organizationof Maya Ascii files

Assumptions and features:

Usage: maya1 >>> "filename.ma"

Note: The default length unit is cm, but if you want to use something different, then set the maya_length_unit variable to the appropriate string after loading maya.cmd and before running the maya command, e.g.

   maya_length_unit := "in"
   maya >>> "filename.ma"
Valid length unit strings are: "mm", "millimeter", "cm", "centimeter", "m", "meter", "km", "kilometer", "in", "inch", "ft", "foot", "yd", "yard", "mi", "mile".

Note: To prevent names generated by this script from conflicting with existing maya names or names from another datafile, there is a string variable maya_name that is prepended to all names generated by this script. There is a maya namespace feature that probably could be used in place of this, but I do not understand it yet. The maya_name default is "AAA"; I didn't use the datafilename since this may contain illegal characters and also would prevent generating multiple maya objects from the same datafile. So if you are going to use multiple surfaces simultaneously, change maya_name before executing the maya command.


neville.cmd

Procedures for Neville's algorithm for computing B-spline values. Several interpolations of distinct data can be done in one call.

Contents:

Usage of neville1: The global array neville1_data should be set up by caller, redimensioning if necessary.
  define neville1_data real[order+1][dim];
  // fill in node data in neville1_data
  ...
  neville1(order,dim,u);
where u is the value between 0 and 1 where the interpolation is desired. The input array neville1_data is not modified. The interpolated values and derivatives with respect to u are returned in the one-dimensional arrays neville1_value[dim] and neville1_deriv[dim].

Usage of neville2: The global array neville2_data should be set up by caller, redimensioning if necessary.

  define neville2_data real[order+1][order+1][dim];
  // fill in node data in neville2_data
  ...
  // fille in the array nevill2_u[2] with the coordinates of the interpolation spot
  neville2_u[1] := 0.3;
  neville2_u[2] := 0.56;
  neville2(order,dim);
The input array neville2_data is not modified. The interpolated values and partial derivatives with respect to u are returned in the one-dimensional array neville1_value[dim] and the two-dimensional array neville1_deriv[dim][2].

obj.cmd

Command script for creating OBJ format 3D graphics file. The resulting OBJ file requires the file EvolverOBJcolors.mtl (included in the Evolver distribution fe folder) to be in the same folder to provide color information in same directory.

Assumptions and features:

Usage:

  1. Set which edges and facets you want to show with the "show edge where ..." and "show facet where ..." commands.
  2. Set obj_double_sided to 1 if you want back sides of facets.
  3. Set obj_edge_flag to 0 if you want no edges shown.
  4. Run obj and redirect output to file, for example
    obj >>> "filename.obj"

off.cmd

Command script to print a Geomview OFF file in ascii format.

Assumptions and limitations:

Usage: do_off >>> "filename.off"


offn.cmd

Command script to write a Geomview OFF file with normals. To permit sane handling of corners and junctions, multiple OFF vertices are created at such points, each with their different normals. The criterion for deciding whether a bend in the surface merits separate normals is the variable cosine_cutoff (default 0.8). Adjacent facets with normals whose angle between them has cosine less than the cutoff get separate vertices.

Assumptions and limitations:

Usage: offn >>> "filename.off"


off_show.cmd

Command script to print a Geomview OFF file in ascii format. Different from off.cmd in obeying the facet show criterion.

Assumptions and limitations:

Usage: do_off >>> "filename.off"


order.cmd

Ccommand script to number string-model vertices consecutively. The result is an order number for each vertex in the vertex extra attribute order_number, which the script creates itself. It does not modify vertex or edge id numbers.

Assumptions:

Usage: order
Example to use order and reorder_storage and renumber_all to get id numbering consecutive around a loop:

   define vertex attribute vertex_order_key real;
   define edge attribute edge_order_key real;
   define facet attribute facet_order_key real;
   define body attribute body_order_key real;
   define facetedge attribute facetedge_order_key real;

   read "order.cmd";

   renumber := {
     order;
     set vertex vertex_order_key order_number;
     set edge ee edge_order_key ee.vertex[1].vertex_order_key;
     set facetedge fe facetedge_order_key fe.edge[1].edge_order_key;
     set facet ff facet_order_key min(ff.vertex,vertex_order_key);
     set body bb body_order_key min(bb.facet,facet_order_key);
     reorder_storage;
     renumber_all;
     }

percolate.cmd

Command scripts for percolation calculation on surfaces. "Percolation" refers to the connected of subnets of a network, as in water percolating through porous stone. Each edge of the network is deemed to be in an "on" or "off" state. A set of nodes that can be connected together with "on" edges is called a "cluster". Thus a particular choice of "on" edges partitions the original network into a set of disjoint clusters. The interesting phenomenon is that when edges are set "on" at random with a particular probability, there is a critical probability above which most of the network falls in one big cluster.

Assumptions and features:

Contents: Usage:
  1. Set the state attribute of each edge to 0 for "off" or 1 for "on", for example
    set edge state (random > 0.3).
  2. Do percolate or slow_percolate.
  3. Do color_clusters to see the clusters. In the string model, you should do "show facets where 1" to see the facets.

ply.cmd

Command script to create PLY file (Stanford Polygon File Format) in ASCII ply format; does only front color of each facet. Format documentation: http://local.wasp.uwa.edu.au/~pbourke/dataformats/ply/

Assumptions and features:

Usage:

  1. Set the edges and facets you want to output using the "show edges where ... " and "show facets where ... " commands.
  2. Run ply and redirect to a file, like this:
    ply >>> "filename.ply"

polyfilm.cmd

Command script to produce a Polycut format file.

Assumptions and features:

Usage: polyfilm >>> "filename.poly"


povray.cmd

Command script for producing POV-Ray input file.

Assumptions and features:

Usage:

  1. Use the "show edge where ..." command to declare which edges are to be depicted as thin cylinders.
  2. Set edge_radius to the desired radius of edge cylinders.
  3. Use the "show facet where ..." command to set which facets to do.
  4. Run povray and redirect to desired file, e.g.
    povray >>> "something.pov"

povrays.cmd

Command script for producing POV-Ray input file. Like povray.cmd but with vertex normals for a smooth surface.

Assumptions and features:

Usage:

  1. Use the "show edge where ..." command to declare which edges are to be depicted as thin cylinders.
  2. Set edge_radius to the desired radius of edge cylinders.
  3. Use the "show facet where ..." command to set which facets to do.
  4. Set critcos to the cosine of the critical angle between normals for facets to be regarded as smoothly joined.
  5. Run povray and redirect to desired file, e.g.
    povray >>> "something.pov"

quadbbox.cmd

Command scripts eboxes and fboxes for finding the bounding box for each facet or edge in the quadratic model. This is useful since quadratic facets and edges may extend beyond the vertices.

Assumptions and features:

Usage: fboxes

quadmeet.cmd

Command script for detecting intersection of quadratic facets in 3D.

Assumptions and features:

Usage: quadmeet

quadtbox.cmd

Command scripts eboxes and fboxes for finding the bounding box for each facet or edge in the quadratic torus model. This is useful since quadratic facets and edges may extend beyond the vertices. The bounding box is calculated in terms of normalized unit cell coordinates, i.e. the edge vectors of the unit cell are the basis vectors for the normalized coordinates.

Assumptions and features:

Usage: fboxes

reorder.cmd

Command script illustrating how to re-order element storage in memory, using the reorder_storage command, to test the effect of memory storage on execution speed. Also, in preparation for using the renumber_all command to re-number elements.

This example reorders vertices in diagonal order, by their distance along the (1,1,1) direction. Other elements are reordered according to their vertices.

Usage: reorder


rewrap.cmd

Command to rewrap torus vertices and ed