How do visualization programs generate electron density meshes? How do visualization programs such Coot and PyMOL generate electron density meshes?
Example of an electron density mesh rendered in PyMOL:

Currently, there are no resources on the internet to answer this question at a non-expert level of detail (i.e. mathematical details but not programming details). I know the outline of the required sequence of data transformations, so I know there's some ambiguity in the question but I think pointing out and clarifying those ambiguities is an important part of the answer. Suppose someone with modest knowledge of crystallography has just given a visualization program an identifier for a publicly available structure and had the program draw an electron density mesh. How do you explain to them what just happened?
Since we're on the physics stackexchange, answers only need to cover the physical aspect of generating the mesh and can ignore the graphical aspect. If we had some rendering machine that knew nothing of crystallography but otherwise had every feature we might find useful, how could we use it to render an electron density mesh?
 A: Starting from the end:
map → isosurface
If you have electron density values in the form of 3D discrete scalar field
(i.e. values on a 3D grid) you can use a computer graphics algorithm,
such as Marching Cubes,
to extract polygonal mesh of an isosurface
corresponding to a selected value of el. den.
Coot uses MC, PyMOL uses
Marching Squares-like method
(MS extracts only iso-lines, but it's enough if the isosurface is to be presented as a wireframe).
You may also need to expand the map by symmetry operations if the data doesn't cover all the unit cell.
map coefficients → map
This is specific to macromolecular crystallography.
The most popular format of el. density in real space is a CCP4 map format. But nowadays most of MX programs can convert data from reciprocal space on-the-fly. Map files are rarely needed.
The advantage, in the context of visualization software, is that the data in reciprocal space is more compact and multiple maps can be stored in the same file (usually one wants to see both normal and difference maps together).
So programs for visualization of MX data (Coot, CCP4MG, incentive version of PyMOL, and many others) read MTZ files (a format for storing reflection data) and fourier-transform the data to real space.
The most commonly displayed map is 2mFo-DFc,
usually shown together with the difference map (mFo-DFc).
Each map is stored as one complex number per hkl reflection (two columns in the MTZ format, for example columns named FWT and PHWT).
structure factors → map coefficients
Map coefficients are generated from both structure factors and a model of the structure.
This is the ambiguous part. A map you'll get may differ from the map that was used to build the model. But it may be the same if you use the same version of the same (refinement) program to calculate map coefficients.
AFAIK no visualization program can calculate a map from structure factors, but some can automatically download maps from the Internet.
