2.3.3. 3DdataMaster

3DdataMaster defines extension nodes to Open Inventor primarily for the development of scientific visualizations. Before going any further it is very important to have read Section 2.1, “ What You Must Know about MeshViz XLM: ”.

Important note:

  • The C++ implementation of 3DdataMaster is kept for compatibility with older versions. You should use MeshViz Interface instead of 3DdataMaster.

  • For Java and .NET developers, since implementing C++ interfaces in other languages is not possible without writing heavy cross language bridges, we recommand to continue to use 3DdataMaster.

As a visualization node kit depends, of course, on the data describing the mesh, you must also define a relationship between the PoMesh( C++ | Java | .NET ) instance and the PbMesh( C++ | Java | .NET )instance. MeshViz provides two ways to specify this relation:

The following code fragments define the objects necessary to visualize the skin and a cross-section of a volume mesh. This example uses the Pbxxxobjects and the PoMesh::setxxx(Pbxxx*pb) methods.



The values of a mesh can be located either at the cells of the mesh or at the nodes of the mesh.

Values at cells:

When the values are located at a cell, each cell is drawn with only one color. For instance when drawing a cross-section, the shape used to draw the intersection between the plane and a cell is colored with one color. When drawing the skin of a mesh, the face of a cell that “belongs” to the skin is also colored with one color. The color used depends on the value of this cell.

[Warning]

At this time, value sets with per-cell data can only be used by the classes PoMeshLevelSurf( C++ | Java | .NET ), PoMeshSkin( C++ | Java | .NET ), and PoMeshCrossSection( C++ | Java | .NET ).

To define a value set with values located at the cells of the mesh, use the following method:


C++
my_mesh->addValuesSet(set_index, cell_values, PER_CELL);

Values at nodes:

When the values are located at the nodes of the mesh, each cell is drawn using the values of each node of the cell. How these nodes’ values are used to draw the cell depends on the coloring mode. (see the section called “Mesh coloring”).

To define a values set located at node, use the following method:


C++
my_mesh->addValuesSet(set_index, cell_values, PER_NODE);

Filtering cells is a way to specify which cells are used to build the mesh representation. A cell filter is based only on the method acceptCell() of the class PoCellFilter( C++ | Java | .NET ) . When acceptCell() returns TRUE, the cell given as the argument is used for the representation, otherwise the cell is not taken into account by the representation.

A cell filter does not apply any transparency to a rejected cell. When a cell is not accepted, it is as if the mesh did not contain this cell. A transparency applied to a cell of mesh skin would create a hole in the surface, whereas the cell filter actually modifies the geometry of the skin.

In order to define a custom cell filter, you must create a class derived from PoCellFilter( C++ | Java | .NET ) and implement the method acceptCell() per your needs. It has two arguments, the index of the cell, and the float value at this cell. This allows you to filter the cell based on its index or a property at this cell. For instance, a filter could eliminate all cells having a value greater than a specified value, or eliminate the last 100 cells of the mesh.

The value passed as the second argument to acceptCell() is an element of the scalar data set currently selected by the representation. This data set is selected by setting the field PoMesh::valuesIndexForCellFilter .

The class PoIntervalCellFilter( C++ | Java | .NET )is a predefined implementation of a cell filter. It implements the acceptCell() method by simply checking if the value of a cell is between a given min and max range.


[Warning]

PoMeshSkin( C++ | Java | .NET ), PoMeshCrossSection( C++ | Java | .NET ), PoMeshLevelSurf( C++ | Java | .NET ), PoMeshCrossContour( C++ | Java | .NET ), PoMeshSkeleton( C++ | Java | .NET ), PoMeshProbePoint( C++ | Java | .NET ), PoBaseStreamLine( C++ | Java | .NET ) (and derived classes), as well as PoMesh3DVecCrossSection( C++ | Java | .NET ), use the cell filter (PoCellFilter( C++ | Java | .NET )) inherited from the scene graph.

3DdataMaster provides the following types to deal with your 2D and 3D surface meshes (the indentation shows class derivations):


With 2D or 3D surface meshes you can choose to have a simple representation with either solid contouring or line contouring (annotated or not). With 2D meshes you can also choose, using the same representation, a 3D visualization by selecting one of your value sets to define an altitude. You can select a scalar data set as an altitude by using the field PoMesh2D::zValuesIndex .

The following visualization nodes may apply to surface meshes (the indentation shows class derivations):

Figure 2.49. Surface mesh representation node classes


The following visualization nodes may apply to 3D meshes (indentation shows class derivation):

Figure 2.51. Volume mesh representation node classes


The following visualization nodes may apply to surface or volume meshes (indentation shows class derivation):

Figure 2.52. Common mesh representation node classes


MeshViz includes the following property classes which allow you to map a floating value to a color, or to map a set of floating values to a color ramp or several color ramps. Two ways are available to define a data-to-color mapping:

The data mapping nodes also allow you to specify threshold values associated with colors. You can specify a minimum threshold or a maximum one using PoDataMapping::minThresholdand PoDataMapping::maxThresholdfields. All values smaller than the minimum threshold are associated with the specified color and, in the same way, values greater than the maximum threshold will be associated with the color of this maximum value.

The threshold effect can be activated and deactivated using the PoDataMapping::maxThresholdEnabledand PoDataMapping::minThresholdEnabledfields.

Sometime it can be useful to visualize meshes that contain some nodes which have a very large or very small value compared to the range of the other nodes’ values. It can be nodes where no calculation, measurement, or probe has been realized. It can be a way to indicate that the scalar value at a node is not assigned, or is not significant for visualization. In the following discussion, we call these special values “undefined values.”

MeshViz provides two ways of handling theses undefined values using the PoDataMapping( C++ | Java | .NET ) nodes (or PbDataMapping( C++ | Java | .NET ) ):

To do that, you must specify in the data-mapping object what are “undefined values.” MeshViz considers any value to be undefined if it is greater than an upper threshold or less than a lower threshold. The upper threshold is set by the field PoDataMapping::maxThresholdand the lower one is set by PoDataMapping::minThreshold . Furthermore, a threshold is activated only if PoDataMapping::maxThresholdEnabledor minThresholdEnabled is TRUE (FALSE by default).

To summarize, a value V is undefined in the following cases:

To visualize an undefined value with a specific color, just assign the fields PoDataMapping( C++ | Java | .NET )::maxThresholdColor or PoDataMapping::minThresholdColor .

To visualize an undefined value with a specific transparency, just assign the fields:

PoDataMapping::maxThresholdTransparencyor PoDataMapping::minThresholdTransparency , and assign the field transparencyEnabled to TRUE.

[Important]

If you want to discard from the scene graph each cell or shape that contains an undefined value, set these transparencies to a full value, i.e. a value greater than PoDataMapping::transparencyValueDeletedParts(0.95 by default).

The following example (located in $OIVHOME/src/MeshViz/Mentor) visualizes a rectangular mesh; each cell that contains one or more undefined nodes will be discarded.

Example 2.30. A rectangular mesh with undefined values


To visualize undefined cells in gray, just replace the two lines:


C++
myDataMapping->maxThresholdTransparency = 1.0;
myDataMapping->transparencyEnabled = TRUE;

by:


C++
myDataMapping->maxThresholdColor =
    SbColor(0.2,0.2,0.2);

If you want to do solid or line contouring, you must specify which values you want to display. MeshViz provides the PbIsovaluesList( C++ | Java | .NET ) and PoIsovaluesList( C++ | Java | .NET )classes that allow you to do so. There are two ways to define a list of isovalues:

A list of isovalues can be a list of any floats. However, convenience methods are available to define a regular list. In a regular list, the step size between two consecutive isovalues is a constant. For example, the following methods are available for creating lists:


or:


C++
PoIsovaluesList *myIsoList = new PoIsovaluesList; 
myIsoList->setRegularIsoList(0.,10.,25);

or:


C++
float values[3] = {0,8,12};
PoIsovaluesList *myIsoList = new PoIsovaluesList; 
myIsoList->isovaluesList.setValues(0,3,values);