The ChemContour and ChemContour2 nodes generate contour lines and the ChemIso node generates constant-valued surfaces through data that resides on a structured, 3D grid of points. This data and the grid of points is maintained in an instance of a ChemLattice3 node. This node is best used as a field in the ChemContour, ChemContour2, and ChemIso nodes instead of as a separate node in a scene graph. An example of the type of data that might be used by these nodes is the electron density of a molecule as calculated at a set of regularly-spaced, 3D grid points.
This chapter describes how to use ChemLattice3, ChemContour, ChemContour2, and ChemIso nodes in the following sections:
Sample applications which use these nodes can be found in /usr/share/src/MolInventor/examples in the contour, contour2, and isosurface subdirectories if you installed the sample source code.
![]() | Note: To use the ChemLattice3, ChemContour, ChemContour2, and ChemIso nodes, you must be using Open Inventor version 2.1.1 or later. |
ChemLattice3 has four fields: coord, dimension, nDataVar, and data. The following sections describe each of these fields.
The coord field defines a grid of regularly spaced coordinates in 3D Cartesian space. The number of entries in the coord field depends on its LatticeCoordType, which has valid values of LATTICE_COORD_UNIFORM and LATTICE_COORD_RECTLINEAR. If the LatticeCoordType is LATTICE_COORD_UNIFORM, only the minimum and maximum values of the XYZ coordinate data are stored in the coord field. Thus, there are six entries in this field arranged in the following order: minimum X value, maximum X, minimum Y, maximum Y, minimum Z, and maximum Z.
If the LatticeCoordType is LATTICE_COORD_RECTLINEAR, the data stored in the coord field consists of all X coordinates followed by all Y coordinates followed by all Z coordinates.
Working in conjunction with the coord field is the dimension field. It specifies the number of grid points in each of the three dimensions (X, Y, and Z). The following example, which works just in the X dimension, shows how these two fields work together.
The following settings:
the coord field is set to LATTICE_COORD_UNIFORM
the first entry (the X value) in the dimension field is 10
the minimum and maximum X values, as stored in the coord field, are 1.0 and 9.0
represent the following X coordinates:
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 |
If the coord field is set to LATTICE_COORD_RECTLINEAR, to represent the same X coordinates, the first entry in the dimension field would again be 10, but the first 10 entries of the coord field would be the values:
1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 |
In general, the only time you would use LATTICE_COORD_RECTLINEAR is when the grid points are not spaced equally along one or more of the axes. If the spacing is uniform in all 3 dimensions, the amount of storage space for the coordinates can be significantly reduced by using LATTICE_COORD_UNIFORM.
The data field holds a pointer to the data located in ChemLattice3's 3D grid. For more information, see “Setting Values in the ChemLattice3 Data Field.”
At each grid point defined by the coord and dimension fields, there are one or more sets of data. The data might be, for example, the value of the electron density, as calculated at each point in the 3D grid. The nDataVar tells how many sets of data are stored at each grid point, for example, each grid point might store values for electron density and electrostatic potential. The type of data that can be stored in a ChemLattice3 is given by the LatticeDataType enum, as shown below.
enum LatticeDataType {
LATTICE_DATA_INT8,
LATTICE_DATA_INT16,
LATTICE_DATA_INT32,
LATTICE_DATA_FLOAT32,
LATTICE_DATA_FLOAT64,
LATTICE_DATA_BAD_TYPE,
};
|
Each of these values defines the number of bits used to store the data and whether the data is of type integer or floating point. If there is more than one set of data at a grid point, the data must all be of the same LatticeDataType and the data is stored in an interleaved manner. For example, if each grid point stores values for electron density and electrostatic potential, the data field would be organized in the following manner:
data[0] == electron_density[0] data[1] == electrostatic_potential[0] data[2] == electron_density[1] data[3] == electrostatic_potential[1] |
To create an instance of ChemLattice3, the constructor is invoked in a manner similar to the following:
ChemLattice3 *theLattice =
new ChemLattice3(LATTICE_DATA_FLOAT32, LATTICE_COORD_UNIFORM);
|
where theLattice is an instance of ChemLattice3. The first argument is the data type (a value from the LatticeDataType enum) stored in the node, and the second argument is the manner in which the coordinate information is stored (a value from the LatticeCoordType enum).
Unlike most other Open Inventor and Molecular Inventor fields, the data field is a pointer to a standard Open Inventor multiple-valued field type. Because it is a pointer, it is referenced differently than the other fields. For example, suppose an instance of ChemLattice3 was generated with the following line:
ChemLattice3 *theLattice =
new ChemLattice3(LATTICE_DATA_FLOAT32, LATTICE_COORD_UNIFORM);
|
To set the value of the first (number 0) entry in the data field, the code would look like this, where value is the floating point number you wish to store in the data field::
((SoMFFloat *)(theLattice->data))->set1Value(0, value); |
In the case where two values are stored in the data field for every grid point, set the values in the following way:
((SoMFFloat *)(theLattice->data))->set1Value(0, electron_density[0]); ((SoMFFloat *)(theLattice->data))->set1Value(1, electrostatic_potential[0]); ((SoMFFloat *)(theLattice->data))->set1Value(2, electron_density[1]); ((SoMFFloat *)(theLattice->data))->set1Value(3, electrostatic_potential[1]); |
A ChemContour node creates sets of contour lines along the X, Y, and Z axes that represent specific values. For example, the contour lines could represent the electron density surrounding a molecule where the value equals one electron per cubic angstrom.
The following figure shows three views of a ChemContour shape.
The following sections describe the ChemContour fields.
If the iAxis field is set to TRUE, contour lines along the X axis and in the YZ plane are generated. If the jAxis field is set to TRUE, contour lines along the Y axis and in the XZ plane are generated. If the kAxis field is set to TRUE, contour lines along the Z axis and in the XY plane are generated.
If the ChemLattice3 instance specified in the lattice field contains more than one set of data, the dataVar field specifies which set of data should be used to generate the contour lines.
The levels field specifies the values in the ChemLattice3 instance through which the contour lines should be drawn. For example, if the ChemLattice3 instance specified in the lattice field contains electron density data, levels can be set to generate three sets of contour lines representing the locations where the values of electron density are 0.5, 0.75, and 1.0 electrons per cubic angstrom.
If the orderedRGBA field is not NULL and the number of colors in the orderedRGBA field matches the number of values in the levels field, the contours are colored by the values in orderedRGBA.
The orderedRGBA field specifies the colors used to render the contour lines. If the orderedRGBA field is not NULL and the number of colors in the orderedRGBA field matches the number of values in the levels field, the contours are colored by the values in orderedRGBA.
A ChemContour2 node renders a set of 3D contoured lines, like ChemContour. ChemContour2, however, allows you to color the contoured lines according to a second set of data using a color map that you supply in the orderedRGBA field.
The following figure shows three views of a ChemContour2 shape. Notice that there is only one set of contour lines, but they are colored according to the value of a second set of data.
The following sections describe the fields in ChemContour2.
If the iAxis field is set to TRUE, contour lines along the X axis and in the YZ plane are generated. If the jAxis field is set to TRUE, contour lines along the Y axis and in the XZ plane are generated. If the kAxis field is set to TRUE, contour lines along the Z axis and in the XY plane are generated.
The threshold field specifies the value in a ChemLattice3 instance through which the contour lines are generated. For example, if the instance of ChemLattice3 specified in the data field contains electron density data, setting the threshold to 1.0 tells ChemContour2 to generate a set of contour lines representing those points in space where the electron density is one electron per cubic angstrom.
The threshold field in ChemContour2 has the same meaning as the levels field in ChemContour except that only one value can be displayed in ChemContour2.
If an instance of ChemLattice3 specified in the data field contains more than one set of data, the dataVar field specifies which set of data should be used when generating the contour lines.
If the ChemLattice3 instance specified in the color field contains more than one set of data, the colorVar field determines which set of data should be used when coloring the contour lines.
The data field is an instance of ChemLattice3 that contains the data through which the contour lines are drawn.
The color field is an instance of ChemLattice3 that contains the data that is used to color the contour lines. Note that the same ChemLattice3 instance can be used for the data and color fields with the dataVar and colorVar fields specifying which sets of data in the ChemLattice3 instance should be used for contouring and coloring.
In order to color the contour lines by a second set of data, a color map must be supplied. The actual colors are stored in the orderedRGBA field.
minValue and maxValue specify the values of the second set of data (stored in the color field) that should be colored by the first and last entries in the color map (stored in orderedRGBA), respectively. All points where the value of the color field is less than or equal to minValue are colored by the first entry in orderedRGBA. All points at which the value of the color field is greater than or equal to maxValue are colored by the last entry in orderedRGBA. All points at which the value of the color field is between minValue and maxValue use interpolated colors from the entries in orderedRGBA.
The ChemIso node uses the data in a ChemLattice3 node to generate a solid surface which passes through a specified value, such as the electron density surrounding a molecule where the value equals one electron per cubic angstrom. An isosurface can be colored by a second set of data by providing a color map in the orderedRGBA field. This color map can also provide a transparency value to make the surface more or less visible.
The following figure shows a ChemIso shape.
The following sections describe the fields in ChemIso.
The threshold field specifies the data value through which the surface should be generated. For example, if the instance of ChemLattice3 specified in the data field contains electron density data, setting the threshold to 1.0 tells ChemIso to generate a surface representing those locations in space where the electron density is 1 electron per cubic angstrom.
The threshold field in ChemIso has the same meaning as the levels field in ChemContour except that only one value can be displayed in ChemIso.
If the generateNormals field is TRUE, the default, the surface is smooth-shaded; otherwise it is flat-shaded.
If the ChemLattice3 node specified in the data field contains more than one set of data, the dataVar field specifies which set of data should be used to generate the surface.
If the ChemLattice3 data node specified in the color field contains more than one set of data, the colorVar field determines which set of data should be used when coloring the surface.
The data field is an instance of ChemLattice3 containing the data through which the surface should be generated.
The color field is a ChemLattice3 node that contains the data used to color the surface. Note that the same ChemLattice3 instance can be used for the data and color fields with the dataVar and colorVar fields specifying which sets of data in the ChemLattice3 instance should be used for contouring and coloring.
In order to color a surface by a second set of data, a color map must be supplied. The actual colors are stored in the orderedRGBA field. minValue and maxValue specify the values of the second set of data (stored in the color field) that should be colored by the first and last entries in the color map (stored in orderedRGBA), respectively. All points where the value of the color field is less than or equal to minValue are colored by the first entry in orderedRGBA. All points at which the value of the color field is greater than or equal to maxValue are colored by the last entry in orderedRGBA. All points at which the value of the color field is between minValue and maxValue use interpolated colors from the entries in orderedRGBA.