NAME Isoline Slice: draw a set of contour levels on a slice through a field AUTHOR Mike French (Evans & Sutherland) SUMMARY Name: Isoline Slice Type: mapper Inputs: data field field 2D scalar real 3-space uniform or irregular maximum dimensions 100x100 colormap colormap (optional) levels field 1D uniform scalar float (optional) Outputs: contours geometry name type default choice list ---- ---- ------- ----------- Parameters: offset flag choice 'no offset' 'no offset' '+' '-' '+ & -' min max --- --- offset value real 0.0035 0.0005 0.0050 N contours integer 10 2 20 DESCRIPTION A set of contour levels are drawn on a slice through a field. The field input must be a slice through a uniform or irregular 3D grid. If the field is uniform, the plane of the output contour geometry will have its correct position in 3D space. The data values for the contours are taken from the 'levels' input field. If this input is not present, then the range of the data field input is divided equally to generate N contour levels. There are always at least two contours. If the levels are generated locally then the first and last contour levels are always at the minimum and maximum data values, so these will never be seen. This method is used for compatability with the ISOBAND SLICE module. If the levels are generated in an INTERVALS FIELD module, the local 'N' control parameter is removed. If the colourmap input is not connected the contours will be black. If a colour map is present then the field data range is mapped on to the colour value range. If the colour value range has been set using the 'color range' module on the same data input field, the ranges will match exactly: the lowest valued contour line is given the first colour index; and the highest valued contour line given the last colour index. If the colour value range is completely within the field data range, there may be duplicated colours at the bottom and top of the range. If the field data range is completely within the colour value range, the contour colours will be a restricted subset of the full gamut of colours. If the input field is uniform, the displacement will be perpendicular to the slice, if it is irregular, each vertex of the contour will be offset along the local vertex normal. The vertex normal is approximated by the normal of a virtual patch comprising the four nearest neighbour vertices. The offsets allow contour to be superimposed on a polygonal representation of the slice. The contour lines can be offset in either direction, or in both directions by drawing a duplicate set. The magnitude of the offset can also be controlled, this is expressed as a fraction of the geometrical extent of the data input field. The default value (0.0035) will be generous for most viewing conditions, when zooming on a small region the offset should be reduced, when viewing the whole slice tilted at a shallow angle, the offset should be increased. If the flag is set to 'no offset' the offset value parameter dial is removed. [ Always have the camera z-buffer of the Geometry Viewer switched to multipass (light-blue ball) when viewing anti-aliased contour lines over polygons. ] Here is a schematic representation of the offset parameters : +ve direction perpendicular to the slice OR vertex normal ^ | ======= ======= /\ offset plane of ----+----- ========= - - - - - - - - - - - - - - \/ value the slice | ======= ======= | 'no offset' '+' '-' '+&-' contour position There is a bug in the standard DOWNSIZE. The problem arises when using DOWNSIZE for uniform fields when the downsize value is not an exact factor of all the (dimension-1) values in X, Y and Z. The result is that spatial positions within field slices will be slightly wrong. This will be most noticeable when two contour surfaces intersect - the bands will not match exactly. A fixed version of the DOWNSIZE module is supplied with the contouring suite, it's module name is 'Downsize', the upper case initial is used to distinguish it from the standard version. ************************************************************* * THE NEW DOWNSIZE MODULE MUST BE USED WITH UNIFORM FIELDS * * FOR CORRECT SPATIAL OUTPUT FROM CONTOURING MODULES * ************************************************************* METHOD The contouring is performed independently for every contour level and every cell. The method is a variation of the 'marching cube' approach to 3D isosurface generation: a look-up table is maintained for all possible configurations of cells. For each cell-level combination an index can be calculated, the index is used to read an entry from the table. The entry will contain the number of lines to be drawn and the pairs of cell vertices which are to be interpolated to provide each contour line vertex. Here is a summary of the algorithm : for every contour calulate level calulate colour for every cell calculate index read number of lines (from look-up table) for each line for each vertex read cell vertices to interpolate (from look-up table) interpolate along cell edge add point to the contour line end vertex end line end cell end contour Only the simplest interpolations are performed, so each contour segment is a single vector. Only in the case of saddle points are two disjoint lines drawn. The saddle points are resolved by calculating the average value at the centre of the cell and using this to determine the direction of the contours. Here is an illustration, the cell vertices and the centre of the cell are marked with a 'x' if their value is above the contour level and a 'o' if their value is below the contour: o o no contour o o x/ o o \x o o o o / \ \ / o o o o x\ o o /x o o x | o o | x x x ----- | | ----- x x x | o o | x o o x o x/ o x \o ? ---> / o / OR \ x \ test central value o x o /x o\ x o x o/ x o \x ? ---> / x / OR \ o \ test central value x o x /o x\ o o/ x x \o x x x x / \ \ / x x x x o\ x x /o x x no contour x x The implementation is not well optimized, each interpolation is performed twice, once for each cell to which the edge belongs. See the man page for ISOBAND_SLICE for more information on how the algorithm could be optimized. The total time taken for the ISOLINE modules is generally much lower than that for the ISOBAND modules, so optimization effort should be concentrated on the ISOBAND modules - unless you only want isolines ! EXAMPLES a) colour contours with reference to local data range (on the slice) GENERATE COLORMAP READ FIELD [3D scalar float 3-space] | | | ORTHOGONAL SLICER | | | .-------------------o | | | COLOR RANGE | | | `---------------. | . | | ISOLINE SLICE [no offset] | GEOMETRY VIEWER b) colour contours with reference to global data range (on the whole grid) GENERATE COLORMAP READ FIELD [3D scalar float 3-space] | | | .---------------------o | | | COLOR RANGE ORTHOGONAL SLICER | | `-----------------. | . | | ISOLINE SLICE [no offset] | | GEOMETRY VIEWER c) black contours over a polygon mesh READ FIELD [3D scalar float 3-space] | ORTHOGONAL SLICER | .------------------o . . | | ISOLINE SLICE FIELD TO MESH ['+&-'] [Z-scale = 0] | | `------------------o | GEOMETRY VIEWER d) black contours over coloured ISOBANDs (local colour range). GENERATE COLORMAP READ FIELD [3D uniform scalar float] | | | ORTHOGONAL SLICER | | | .-------------------o | | | COLOR RANGE | | | | .---------------o . | | . . | ISOBAND SLICE ISOLINE SLICE [N=10] [N=10]['+&-'] ' | | `---------------o | GEOMETRY VIEWER The positions of the contour levels in the data range can be shown using a FIELD LEGEND module in conjunction with the ISOBAND SLICE module ORTHOGONAL SLICER | : .---------------o . | | | ISOBAND SLICE | | | | | : | | | | .---------------o | | | FIELD LEGEND ISOLINE SLICE | : e) The contour levels can be coordinated with other contour modules, either ISOBAND SLICE or ISOLINE SLICE, by using the INTERVALS FIELD module. It generates a set of equally spaced data values given a data field input: READ FIELD [3D uniform scalar float] | ORTHOGONAL SLICER | .-----------------------o | | INTERVALS FIELD | | .---------------o | | | o---------------. | | . | | . | ISOBAND SLICE ISOLINE SLICE [N=10] [N=10]['+&-'] | | `---------------o | GEOMETRY VIEWER ISOLINE SLICE and ISOBAND SLICE modules with the same data input can also be jointly controlled using an INTEGER module, make the 'N' parameter ports visible first : | | INTEGER | | .---------------o | | | o---------------. | | . . | | . . | ISOBAND SLICE ISOLINE SLICE [N=10] [N=10]['+&-'] | |