X.volume
/**
* Create a displayable volume which consists of X.slices in X,Y and Z direction
* and can also be volume rendered.
*
* @constructor
* @param {X.volume=} volume Another X.volume to use as a template.
* @extends X.object
* @mixin X.loadable
* @mixin X.thresholdable
*/
var v = new X.volume();
/**
* Flag to show borders or not.
*
* @type {boolean}
* @protected
*/
v._borders = $_BORDERS;
/**
* The caption of this object.
*
* @type {?string}
* @protected
*/
v._caption = $_CAPTION;
/**
* The center of this volume.
*
* @type {!Array}
* @protected
*/
v._center = $_CENTER;
/**
* The children of this object.
*
* @type {!Array}
* @protected
*/
v._children = $_CHILDREN;
/**
* The className of this class.
*
* @type {string}
* @protected
*/
v._classname = $_CLASSNAME;
/**
* The object color. By default, this is white.
*
* @type {!Array}
* @public
*/
v._color = $_COLOR;
/**
* The point colors of this object.
*
* @type {?X.triplets}
* @protected
*/
v._colors = $_COLORS;
/**
* The color table of this object.
*
* @type {?X.colortable}
* @protected
*/
v._colortable = $_COLORTABLE;
/**
* The dimensions of this volume.
*
* @type {!Array}
* @protected
*/
v._dimensions = $_DIMENSIONS;
/**
* The 'dirty' flag of this object.
*
* @type {boolean}
* @protected
*/
v._dirty = $_DIRTY;
/**
* This distance of this object to the viewer's eye.
*
* @type {number}
* @protected
*/
v._distance = $_DISTANCE;
/**
* The file of this loadable object.
*
* @type {?X.file}
* @protected
*/
v._file = $_FILE;
/**
* The file data.
*
* @type {?ArrayBuffer}
* @protected
*/
v._filedata = $_FILEDATA;
/**
* The uniqueId of this instance. Each class instance in XTK has a uniqueId.
*
* @type {number}
* @protected
*/
v._id = $_ID;
/**
* The image data as a 3D array.
*
* @type {!Array}
* @protected
*/
v._image = $_IMAGE;
/**
* The index of the currently shown slice in X-direction.
*
* @type {!number}
* @public
*/
v._indexX = $_INDEXX;
/**
* The index of the formerly shown slice in X-direction.
*
* @type {!number}
* @protected
*/
v._indexXold = $_INDEXXOLD;
/**
* The index of the currently shown slice in Y-direction.
*
* @type {!number}
* @public
*/
v._indexY = $_INDEXY;
/**
* The index of the formerly shown slice in Y-direction.
*
* @type {!number}
* @protected
*/
v._indexYold = $_INDEXYOLD;
/**
* The index of the currently shown slice in Z-direction.
*
* @type {!number}
* @public
*/
v._indexZ = $_INDEXZ;
/**
* The index of the formerly shown slice in Z-direction.
*
* @type {!number}
* @protected
*/
v._indexZold = $_INDEXZOLD;
/**
* The label map of this volume.
*
* @type {?X.volume}
* @private
*/
v._labelmap = $_LABELMAP;
/**
* The line width, only used in X.displayable.types.LINES mode.
*
* @type {number}
* @protected
*/
v._linewidth = $_LINEWIDTH;
/**
* The lower threshold.
*
* @type {number}
* @protected
*/
v._lowerThreshold = $_LOWERTHRESHOLD;
/**
* The flag for the magic mode.
*
* @type {!boolean}
* @protected
*/
v._magicmode = $_MAGICMODE;
/**
* The upper threshold border.
*
* @type {number}
* @protected
*/
v._max = $_MAX;
/**
* The color to map the max. scalar.
*
* @type {!Array}
* @protected
*/
v._maxColor = $_MAXCOLOR;
/**
* The lower threshold border.
*
* @type {number}
* @protected
*/
v._min = $_MIN;
/**
* The color to map the min. scalar.
*
* @type {!Array}
* @protected
*/
v._minColor = $_MINCOLOR;
/**
* The normals of this object.
*
* @type {?X.triplets}
* @protected
*/
v._normals = $_NORMALS;
/**
* The opacity of this object.
*
* @type {number}
* @protected
*/
v._opacity = $_OPACITY;
/**
* An array reflecting the point or vertex indices.
*
* @type {!Array}
* @protected
*/
v._pointIndices = $_POINTINDICES;
/**
* The points of this object.
*
* @type {?X.triplets}
* @protected
*/
v._points = $_POINTS;
/**
* The point size, only used in X.displayable.types.POINTS mode.
*
* @type {number}
* @protected
*/
v._pointsize = $_POINTSIZE;
/**
* The reslicing flag.
*
* @type {!boolean}
* @protected
*/
v._reslicing = $_RESLICING;
/**
* The scalars of this object.
*
* @type {?X.scalars}
* @protected
*/
v._scalars = $_SCALARS;
/**
* The X.object holding the slices in X-direction.
*
* @type {!X.object}
* @protected
*/
v._slicesX = $_SLICESX;
/**
* The X.object holding the slices in Y-direction.
*
* @type {!X.object}
* @protected
*/
v._slicesY = $_SLICESY;
/**
* The X.object holding the slices in Z-direction.
*
* @type {!X.object}
* @protected
*/
v._slicesZ = $_SLICESZ;
/**
* The spacing of this volume.
*
* @type {!Array}
* @protected
*/
v._spacing = $_SPACING;
/**
* The texture of this object.
*
* @type {?X.texture}
* @protected
*/
v._texture = $_TEXTURE;
/**
* The mapping between object and texture coordinates.
*
* @type {?Array}
* @protected
*/
v._textureCoordinateMap = $_TEXTURECOORDINATEMAP;
/**
* The rendering type of this object, default is
* {X.displayable.types.TRIANGLES}.
*
* @type {X.displayable.types}
* @protected
*/
v._type = $_TYPE;
/**
* The upper threshold.
*
* @type {number}
* @protected
*/
v._upperThreshold = $_UPPERTHRESHOLD;
/**
* The visibility of this object.
*
* @type {boolean}
* @public
*/
v._visible = $_VISIBLE;
/**
* The toggle for volume rendering or cross-sectional slicing.
*
* @type {boolean}
* @public
*/
v._volumeRendering = $_VOLUMERENDERING;
/**
* The direction for the volume rendering. This is used for caching.
*
* @type {!number}
* @private
*/
v._volumeRenderingDirection = $_VOLUMERENDERINGDIRECTION;
/**
* The cached toggle for volume rendering or cross-sectional slicing.
*
* @type {boolean}
* @public
*/
v._volumeRenderingOld = $_VOLUMERENDERINGOLD;
/**
* The upper window border.
*
* @type {!number}
* @private
*/
v._windowHigh = $_WINDOWHIGH;
/**
* The lower window border.
*
* @type {!number}
* @private
*/
v._windowLow = $_WINDOWLOW;
/**
* Return the borders flag.
*
* @return {boolean} TRUE if borders are enabled, FALSE otherwise.
* @public
*/
var _borders = v.borders;
/**
* Set the borders flag. Must be called before the volume gets created
* internally. After that, the borders can be modified using the children of
* each slice.
*
* @param {boolean} borders TRUE to enable borders, FALSE to disable them.
* @public
*/
v.borders = $BORDERS;
/**
* Get the caption of this object.
*
* @return {?string} The caption of this object.
* @public
*/
var _caption = v.caption;
/**
* Set the caption for this object.
*
* @param {?string} caption The caption for this object.
* @public
*/
v.caption = $CAPTION;
/**
* Get the center of this X.volume.
*
* @return {!Array} The center.
* @public
*/
var _center = v.center;
/**
* Set the center of this X.volume. This has to be called (for now) before a
* volume data gets loaded aka. before the first X.renderer.render() call.
*
* @param {!Array} center The new center.
* @throws {Error} If the center is invalid.
* @public
*/
v.center = $CENTER;
/**
* Get the children of this object. Each object can have N children which get
* automatically rendered when the top level object gets rendered.
*
* @return {!Array} The children of this object which are again objects.
*/
var _children = v.children;
/**
* Get the className of this object.
*
* @return {string} The className of this object.
* @public
*/
var _classname = v.classname;
/**
* Get the object color.
*
* @return {!Array} The object color.
*/
var _color = v.color;
/**
* Set the object color. This overrides any point colors.
*
* @param {!Array} color The object color as an array with length 3 and values
* between 0..1.
* @throws {Error} An exception if the given color is invalid.
*/
v.color = $COLOR;
/**
* Get the point colors of this object.
*
* @return {!X.triplets} The point colors.
*/
var _colors = v.colors;
/**
* Set the colors of this object.
*
* @param {!X.triplets} colors The colors.
*/
v.colors = $COLORS;
/**
* The color table associated with this object.
*
* @return {?X.colortable} The color table.
*/
var _colortable = v.colortable;
/**
* Get the dimensions of this volume.
*
* @return {!Array} The dimensions of this volume.
* @public
*/
var _dimensions = v.dimensions;
/**
* Get the associated X.file for this object.
*
* @return {string} The associated file path or null if no file is associated.
*/
var _file = v.file;
/**
* Load this object from a file path or reset the associated file path.
*
* @param {?string|Array} filepath The file path/URL to load. If null, reset the
* associated file. If an array is given, load multiple files (this
* only works for DICOM so far).
*/
v.file = $FILEPATH;
/**
* Get the possibly attached file data for this object.
*
* @return {?string} The associated file data or null if none is attached.
*/
var _filedata = v.filedata;
/**
* Set raw file data for this object. Doing so, skips any additional loading and
* just parses this raw data.
*
* @param {?string|Array} filedata The raw file data to parse.
*/
v.filedata = $FILEDATA;
/**
* Get the id of this instance.
*
* @return {string} The className of this object.
* @public
*/
var _id = v.id;
/**
* Get the original image data of this volume.
*
* @return {!Array} A 3D array containing the pixel (image) data.
* @public
*/
var _image = v.image;
/**
* Get the slice index in X-direction.
*
* @return {!number} The slice index in X-direction.
* @public
*/
var _indexX = v.indexX;
/**
* Set the slice index in X-direction.
*
* @param {!number} indexX The slice index in X-direction.
* @public
*/
v.indexX = $INDEXX;
/**
* Get the slice index in Y-direction.
*
* @return {!number} The slice index in Y-direction.
* @public
*/
var _indexY = v.indexY;
/**
* Set the slice index in Y-direction.
*
* @param {!number} indexY The slice index in Y-direction.
* @public
*/
v.indexY = $INDEXY;
/**
* Get the slice index in Z-direction.
*
* @return {!number} The slice index in Z-direction.
* @public
*/
var _indexZ = v.indexZ;
/**
* Set the slice index in Z-direction.
*
* @param {!number} indexZ The slice index in Z-direction.
* @public
*/
v.indexZ = $INDEXZ;
/**
* Get the label map of this volume. A new label map gets created if required
* (Singleton).
*
* @return {!X.volume}
* @public
*/
var _labelmap = v.labelmap;
/**
* Get the line width of this object. The line width is only used in
* X.displayable.types.LINES rendering mode.
*
* @return {!number} The line width.
*/
var _linewidth = v.linewidth;
/**
* Set the line width for this object. The line width is only used in
* X.displayable.types.LINES rendering mode.
*
* @param {!number} width The line width.
* @throws {Error} An exception if the given width is invalid.
*/
v.linewidth = $WIDTH;
/**
* Get the lower threshold.
*
* @return {number} The lower threshold.
* @public
*/
var _lowerThreshold = v.lowerThreshold;
/**
* Set the lower threshold if it is inside the min-max range.
*
* @param {number} lowerThreshold
* @public
*/
v.lowerThreshold = $LOWERTHRESHOLD;
/**
* Get the magic mode flag.
*
* @return {!boolean} The magic mode flag.
*/
var _magicmode = v.magicmode;
/**
* Set the magic mode flag.
*
* @param {!boolean} magicmode The magic mode flag.
*/
v.magicmode = $MAGICMODE;
/**
* Get the max color which is used to map the scalars to colors in a linear
* fashion.
*
* @return {!Array} An array holding the r,g,b components of the color.
* @public
*/
var _maxColor = v.maxColor;
/**
* Set the max color to linear map the scalars to colors.
*
* @param {!Array} maxColor The color corresponding to the min. scalar value.
* @public
*/
v.maxColor = $MAXCOLOR;
/**
* Get the upper threshold border.
*
* @return {number} The upper threshold border.
* @public
*/
var _max = v.max;
/**
* Get the min color which is used to map the scalars to colors in a linear
* fashion.
*
* @return {!Array} An array holding the r,g,b components of the color.
* @public
*/
var _minColor = v.minColor;
/**
* Set the min color to linear map the scalars to colors.
*
* @param {!Array} minColor The color corresponding to the min. scalar value.
* @public
*/
v.minColor = $MINCOLOR;
/**
* Get the lower threshold border.
*
* @return {number} The lower threshold border.
* @public
*/
var _min = v.min;
/**
* Get the normals of this object.
*
* @return {!X.triplets} The normals.
*/
var _normals = v.normals;
/**
* Set the normals of this object.
*
* @param {!X.triplets} normals The normals.
*/
v.normals = $NORMALS;
/**
* Get the opacity of this object. If the object is fully opaque, this returns
* 1.
*
* @return {number} The opacity in the range 0..1.
*/
var _opacity = v.opacity;
/**
* Set the opacity of this object.
*
* @param {number} opacity The opacity value in the range 0..1.
*/
v.opacity = $OPACITY;
/**
* Get the points of this object.
*
* @return {!X.triplets} The points.
*/
var _points = v.points;
/**
* Set the points of this object.
*
* @param {!X.triplets} points The points.
*/
v.points = $POINTS;
/**
* Get the point size of this object. The point size is only used in
* X.displayable.types.POINTS rendering mode.
*
* @return {!number} The point size.
*/
var _pointsize = v.pointsize;
/**
* Set the point size for this object. The point size is only used in
* X.displayable.types.POINTS rendering mode.
*
* @param {!number} size The point size.
* @throws {Error} An exception if the given size is invalid.
*/
v.pointsize = $SIZE;
/**
* Return the reslicing flag.
*
* @return {boolean} TRUE if reslicing is enabled, FALSE otherwise.
* @public
*/
var _reslicing = v.reslicing;
/**
* Set the borders flag. Must be called before the volume gets created
* internally. After that, the borders can be modified using the children of
* each slice.
*
* @param {boolean} reslicing TRUE to enable reslicing, FALSE to disable it.
* @public
*/
v.reslicing = $RESLICING;
/**
* The scalars associated with this object.
*
* @return {?X.scalars} The scalars.
*/
var _scalars = v.scalars;
/**
* Get the texture of this object.
*
* @return {!X.texture} The texture.
*/
var _texture = v.texture;
/**
* Get the render type of this object.
*
* @return {!string} The render type.
*/
var _type = v.type;
/**
* Set the render type of this object. Valid types are: TRIANGLES,
* TRIANGLE_STRIPS, LINES, POINTS, POLYGONS
*
* @param {!string} type The render type.
*/
v.type = $TYPE;
/**
* Get the upper threshold.
*
* @return {number} The upper threshold.
* @public
*/
var _upperThreshold = v.upperThreshold;
/**
* Set the upper threshold if it is inside the min-max range.
*
* @param {number} upperThreshold
* @public
*/
v.upperThreshold = $UPPERTHRESHOLD;
/**
* Get the visibility of this object.
*
* @return {boolean} TRUE if the object is visible, FALSE otherwise.
* @public
*/
var _visible = v.visible;
/**
* Set the visibility of this object.
*
* @param {boolean} visible The object's new visibility.
* @public
*/
v.visible = $VISIBLE;
/**
* Get the volume rendering setting of this X.volume.
*
* @public
*/
var _volumeRendering = v.volumeRendering;
/**
* Toggle volume rendering or cross-sectional slicing of this X.volume.
*
* @param {boolean} volumeRendering If TRUE, display volume rendering, if FALSE
* display cross-sectional slices.
* @public
*/
v.volumeRendering = $VOLUMERENDERING;
/**
* Return the upper window border for window/level adjustment.
*
* @return {!number} The upper window border.
* @public
*/
var _windowHigh = v.windowHigh;
/**
* Set the upper window border for window/level adjustment.
*
* @param {!number} windowHigh The new upper window border.
* @public
*/
v.windowHigh = $WINDOWHIGH;
/**
* Return the lower window border for window/level adjustment.
*
* @return {!number} The lower window border.
* @public
*/
var _windowLow = v.windowLow;
/**
* Set the lower window border for window/level adjustment.
*
* @param {!number} windowLow The new lower window border.
* @public
*/
v.windowLow = $WINDOWLOW;
/**
* Copies the properties from a given volume to this volume.
*
* @param {*} volume The given volume.
* @protected
*/
v.copy_($VOLUME);
/**
* Create the volume.
*
* @private
*/
v.create_();
/**
* Fire a modified event for this object.
*
* @param {?boolean=} propagateEvent An optional flag to stop propagating down to child classes.
*/
v.modified($PROPAGATEEVENT);
/**
* Show the current slices which are set by this._indexX, this._indexY and
* this._indexZ and hide all others.
*/
v.slicing_();
/**
* Perform volume rendering of this volume along a specific direction. The
* direction is important since we show tiled 2d textures along the direction
* for a clean rendering experience.
*
* @param {number} direction The direction of the volume rendering
* (0==x,1==y,2==z).
* @protected
*/
v.volumeRendering_($DIRECTION);
/**
* Compare two X.objects by their opacity values and their distance to the
* viewer's eye. Fully opaque objects should be always ordered before
* transparent ones, and the transparent ones should be ordered back-to-front in
* terms of the distance to the viewer's eye.
*
* @param {X.object} object1 Object1 to compare against Object2.
* @param {X.object} object2 Object2 to compare against Object1.
* @return {!number} 1, if Object1 should be ordered after Object2. -1, if
* Object1 should be ordered before Object2
*/
var OPACITY_COMPARATOR = X.volume.OPACITY_COMPARATOR($OBJECT1, $OBJECT2);
/**
* Different render types for any displayable objects.
*
* @enum {string}
*/
X.volume.types();