2.2.6. Mesh Extraction

The OpenInventor mesh representation nodes described in Section 2.2.4, “Data Mapping” create a graphical representation of features such as isosurface or skin. But it may be necessary to retrieve these features as a data structure suitable for computation. This process is called Mesh Extraction and is availabe as an independent API described below.

[Tip]

Note: The mesh extraction API is used internally by the Data Mapping API to extract the features from the input mesh before rendering it. Most data mapping nodes return an extractor containing the extracted mesh usable for any post processing task.

Once all the required interface methods have been implemented in your application’s classes as described in Section 2.2.3, “The abstract mesh interface”, you are ready to start the mesh extraction step.

Mesh Extraction creates a mesh of lower (or equal) dimension from a higher dimension one. For instance, when extracting a surface mesh (2D) representing an isosurface from a volume mesh (3D).

For each type of extraction, a set of extractors are provided usually one per supported mes type. For instance, Isosurface extraction can be done with MiIsosurfExtractUnstructured( C++ | Java ) for unstructured meshes and MiIsosurfExtractRegular for regular meshes. In some cases, the same extractor will work for several mesh types. In this case, several getNewInstance() methods are provided for convenience.

Extractors are also interfaces but they are implemented internally by MeshViz. Thus they cannot be created as normal classes. To create a new extractor, each extractor contains a getNewInstance() method returning a pointer to an extractor interface.

The following example shows how to create an isosurface extractor for an unstructured mesh.


C++
MiIsosurfExtractUnstructured* isosurfExtract =
    MiIsosurfExtractUnstructured::getNewInstance(mesh);

The returned extractor interface object can then be used to extract one or more meshes from the original one. Using the previously created isosurface extractor, we can now perform the extraction:


C++
const MeXSurfaceMeshUnstructured& isosurf =
    isosurfExtract->extractIsovalue(isoValue,scalarSet);

As you can see from this example, the result of a mesh extraction is also a mesh but the dimension of the resulting mesh is lower than or equal to the dimension of the original mesh. The isosurface extraction creates a MeXSurfaceMeshUnstructured( C++ | Java ) (2D) set from a MeXVolumeMeshUnstructured( C++ ) (3D).

All extractors return meshes prefixed with MeX (for Extracted Mesh) which are very similar to their Mi parent class but with some additional information such as cell surfaces, face normal, ...

When using structured mesh extractors, you will notice that some extractors create structured meshes similar to the original mesh but some other extractors always create unstructured meshes. This is because some of the algorithms such as isosurface extraction produce irregular toplogies that is not simply a reduction of the original mesh like a logical slice whatever input mesh they are applied on.

Each instance of an extractor contains a single extracted mesh returned by reference. After each extraction, for instance when changing the isovalue, the content of the extracted mesh is replaced by the new one. If you need to keep the old mesh for any reason, you can either create another instance of an extractor or use the getNewClone() method of the extracted mesh to duplicate it. After modifying the input mesh, assuming that the associated time stamps have been updated, calling the extractor with the same parameters as the first time will recompute the topology, geometry and data set extracts. When only the geometry has changed, the topology and data set extracts will not be recomputed. When nothing has changed in the input mesh and cell filter, calling the extract method does nothing.

Two mechanisms are available for detecting that the result of an extract has changed during the last call to extract:

Before using any of the extraction classes, the MeshViz Extraction toolkit must be initialized by calling the following static method:


C++
MiMeshViz::init();

Similarly, before ending the program, call the following method:


C++
MiMeshViz::finish();

This cleans-up all the resources used.

Notice that this initialization is done automatically when using MeshViz Data Mapping by the MoMeshViz( C++ ) class.