New Mesh Selection and Extrusion Capabilities in VTK

May 14, 2012

This blog entry is the second in a series of articles reporting on the results of our ongoing collaboration with Commissariat à l’Energie Atomique (CEA), Direction des Applications Militaires Île-de-France (DIF), France, where a domain-specific visualization tool based on VTK and ParaView server is developed. In the first article, we explained how we extended the annotation capabilities of VTK by either integrating into VTK routines that had been developed in-house at CEA/DIF, or by writing new functionalities altogether.

In this second article, we are reporting on new capabilities added in VTK 5.10, specifically in the field of mesh manipulation:

  1. Element selection along a line or a broken line.
  2. Broken line widget for interactive element selection with a mesh.
  3. Quadrangle-generating mesh extrusion from a multi-block polygonal input.

In this article, we briefly report on these new capabilities, available since VTK 5.10.

Linear Selector

A class for the selection of cells along a segment defined by its endpoints, within a composite data set, had been developed at CEA/DIF. In the context of this current collaboration, we developed a new subclass of vtkSelectionAlgorithm, called vtkLinearSelector,  which extends the method to support selection along broken lines within an input composite dataset. In particular, the API of this new selection algorithm allows for 2 different ways of defining a broken line: either  by passing a list of vtkPoints, or by only specifying two endpoints in order to preserve backwards-compatibility for the CEA/DIF visualization application.

In addition, we enhanced the original method by allowing for the exclusion of line endpoints in the selection process; i.e., selection along open segments. We noticed with early experiments that typical use cases with CEA/DIF datasets were leading to numerous unwanted cells being selected in cases where a segment endpoint coincides (numerically) with a cell vertex within the input mesh. This exclusion method is based on an IncludeVertices option, which when turned off, makes use of a user-defined relative tolerance; thus defining a closed segment contained within, and numerically approaching the actual open segment.

Incidentally, we discovered that the current implementation of the IntersectWithLine() method of vtkTriangle does not specifically handle the case of degenerate intersection; i.e., the (unstable) case where a segment is both coplanar and secant to a triangle. The current implementation works effectively as a dichotomy between either secant or coplanar, with the degenerate intersection belonging to the former case. This design is not faulty per se, for it was conceived as such for speed in the context of facet picking within a mesh. However, when using VTK in the context of topological/geometric manipulation, this becomes a problem as we discovered here. We initiated a discussion amongst VTK developers as to whether a modification of vtkTriangle::IntersectWithLine() is warranted in order to support the ternary division between generic intersection, non-intersecting coplanarity, and degenerate (co-planar) intersection. Due to the potential ramifications of such a change, we have decided to not not modify vtkTriangle::IntersectWithLine() until a consensus is reached in this regard. In the meantime however, this degeneracy does not cause any trouble for our CEA/DIF partners, for their visualisation application uses a version of vtkTriangle which they modified to handle this numerical issue in particular.

Broken Line Widget

Following the development of the broken line selection mechanism, we implemented a broken line widget to allow for interactive selection of cells within an input mesh. For consistency within VTK, we devised the API and behavior of the new vtkBrokenLineWidget to be similar to those of the vtkSplineWidget, so the developer already familiar with the latter will find it natural to use the former. In particular, mouse/button events produce the same results in terms of handle addition/deletion, panning, zooming, etc.


The behaviour of the new selection mechanism combined with broken line widget interaction can be interactively tested with the script which we put under Examples/Graphichs/Python/ in VTK 5.10. It demonstrates the operation of the widget and lets the user interactively select cells within an example mesh, chosen for its peculiarity at the apex with multiple coincident pyramids, thus illustrating the use of endpoint elimination during the selection process.

Rotational Extrusion in Quadrangles

Among the modeling capabilities of VTK is the class called vtkRotationalExtrusionFilter, which takes polygonal data as input and sweeps it around the z-axis to create new polygonal primitives. These primitives form a “skirt” or swept surface. For example, sweeping a line results in a cylindrical shell, and sweeping a circle creates a torus. A number of control parameters are available: for instance, one can decide whether the skirt sweep of a 2D object (i.e., polygon or triangle strip) is to be capped with the generating geometry. It is also possible to control the angle of the rotation, and whether translation should be performed at the same time as rotation (screw action). The output skirt is generated by locating certain topological features: free edges (edges of polygons or triangle strips only used by one polygon or triangle strips), lines; and polylines generate surfaces, whereas vertices generate lines.

This class however has the following limitations:

  1. It can only generate triangle strips as output.
  2. It can only sweep around the z-axis.
  3. It does not allow to natively process multi-block inputs, with independent rotation angles specified for each block.


In order to address these limitations, a new class called vtkQuadRotationalExtrusionFilter has been developed at CEA/DIF. In particular,  the output of this new filter is a skirt made of quadrangles, as illustrated above: left, the result of a rotational extrusion in triangles from a polyline containing 10 segments using vtkQuadExtrusionFilter; right, the output of vtkQuadRotationalExtrusionFilter applied to the same input, with the same parameters.

As part of this collaboration with CEA/DIF, we ported the new class to VTK 5.10. We made a number of changes to make it easier to maintain and extend. In particular, we decided to keep it separate from vtkRotationalExtrusion, as opposed to merging the capabilities of both classes into a single new one; as illustrated above, vtkQuadRotationalExtrusionFilter is intrinsically a vtkMultiBlockDataSet algorithm, so we thought that for backwards-compatibility it was desirable to keep the triangle strip generating class as a vtkPolyDataAlgorithm, at least until a compelling reason to do otherwise would become manifest. The new, quadrangle-generating, multi-block filter is now fully-available with VTK 5.10.


This work was made possible thanks to a contract with CEA, Direction des Applications Militaires Île-de-France (DIF),  Bruyères-le-Châtel, 91297 Arpajon, France. We extend special thanks to Daniel Aguilera, Thierry Carrard, and Claire Guilbaud for this fruitful collaboration. We are looking forward to continued collaboration with CEA/DIF in this and other areas of scientific visualization.

Leave a Reply