VESPA: Advanced Mesh Processing Based on CGAL for VTK and ParaView

November 22, 2022

In this blog post, Kitware is pleased to introduce VESPA: VTK Enhanced with Surface Processing Algorithms. This project aims to bring state-of-the-art mesh processing from the CGAL library to VTK and ParaView through a transparent wrapping for the users. The CGAL (Computational Geometry Algorithms Library) C++ library offers various advanced geometry algorithms, such as mesh generation, subdivision, smoothing, and more. To suit your needs, VESPA is available as both a VTK based library and a ParaView plugin. The source code and complete build instructions for each of them are available at this Gitlab repository.

By default, VESPA filters are available inside VTK modules which can be easily used with your own projects like usual VTK filters, in both C++ or Python. If you would like to try these filters in ParaView instead, simply activate the plugin build with the CMake option VESPA_BUILD_PV_PLUGIN set to ON. You can then load the plugin via “Tools > Manage Plugins…” in ParaView.

Lastly, note that VESPA is under BSD-3 license. However, since the CGAL library is under dual licensing, with the free version being under GPLv3, binaries generated with VESPA are also under GPLv3 licensing, unless you own a CGAL commercial license (from Geometry Factory).

Left: Original mesh. Right: Mesh after isotropic remeshing, shape smoothing and mesh subdivision.

Bridge Between CGAL and VTK

The base class in VESPA used to define other filters is vtkCGALPolyDataAlgorithm. This class builds upon the VTK class vtkPolyDataAlgorithm by adding convenience methods to convert meshes from VTK to CGAL and vice versa.

The basic steps for VESPA filters are usually the following:

  1. Preprocessing the input VTK dataset (transformation, options)
  2. Converting from VTK to CGAL
  3. Applying CGAL filter
  4. Converting from CGAL back to VTK
  5. Postprocessing the VTK dataset (attributes interpolation, cleaning)

In the case of simple operations that do not require particular processing (such as the shape smoothing filter), steps 2 to 4 are sufficient and constitute the core of VESPA filters. Note that VESPA currently only supports triangulated polygonal meshes.

A Selection of VESPA Filters

Boolean Operations

Boolean operations take two polygonal meshes as input to produce their union, intersection or difference. The resulting dataset is a new closed triangulated mesh. Note that values for the result mesh can be interpolated from the input.

The CGAL methods used for this filter are corefine_and_compute_union(), corefine_and_compute_intersection() and corefine_and_compute_difference(), respectively.

Boolean operations between a sphere and a dragon. The shape of the sphere can clearly be seen after the difference and intersection operations. Top left: Superimposed original meshes. Top right: Difference. Bottom left: Intersection. Bottom right: Union.

Shape Smoothing

The Shape Smoothing filter transforms a polygonal mesh by progressively converging towards a sphere using the mean curvature flow. The number of iterations as well as the smoothing speed (called time step) can be entered as parameters to influence the strength of the smoothing process.

This filter is based on the CGAL operation smooth_shape().

Shape smoothing on a polygonal mesh. Left: Original mesh. Center: 1 iteration, time step 1e-6. Right: 1 iteration, time step 1e-5.

Mesh Deformation

Unlike most other filters, the Mesh Deformation filter takes three inputs:

  • Original polygonal mesh
  • Control points defined at the target positions. These points must have an array specifying the IDs of the corresponding points from the original mesh.
  • Region of interest (ROI) containing the IDs of the points that can be moved by the algorithm. Other points (except for targets) are left unchanged.

While the control points are defined as a vtkPointSet (e.g. polygonal mesh with vertices), the ROI is defined as a selection. This is convenient when using the ParaView plugin since many tools are available to create selections.

The filter uses the CGAL Surface_mesh_deformation class.

Mesh deformation in ParaView. Top: Original mesh with ROI highlighted as a selection. Bottom left: Original mesh with ROI highlighted and control points (blue spheres) for the tips of the horns. Bottom right: Deformed mesh.

Alpha Wrapping

The alpha wrapping algorithm is a 3D meshing process inspired by the alpha shapes. It always produces watertight meshes without self intersections. The input can be a point cloud, a triangle mesh or a triangle soup. The parameters are the alpha radius and an offset (thickness of an added layer around the input). The smaller these values, the finer the result, at the cost of computation time.

The CGAL operation used for this filter is alpha_wrap_3(). Note that the CGAL version must be at least 5.5 to use this filter. More details on the algorithm are available here.

Alpha wrapping in ParaView. Top left: alpha 2, offset 1. Top right: alpha 1, offset 1. Bottom left: alpha 2, offset 0.1. Bottom right: alpha 1, offset 0.1.

Complete List of Filters

More interesting filters are available in VESPA to cover different needs. The current list (in alphabetical order) includes:

  • Alpha Wrapping
  • Boolean Operations
  • Hole Filling
  • Isotropic Remesher
  • Mesh Deformation
  • Mesh Subdivision
  • Region Fairing
  • Shape Smoothing
  • 2D Delaunay

What’s Next?

VESPA is a young and growing project with a lot of potential. Further steps include:

  • New filters: The CGAL library offers a large number of mesh processing operations, many of which are not yet available in VESPA. Keep an eye out for new algorithms!
  • Improvement of existing filters: Currently available filters can become even better with additional parameters, enhanced ParaView integration and so on.
  • External contributions: Is there a CGAL algorithm you would like to see in VESPA? Contributions are welcome, so feel free to step in! By using one of the existing filters as a template, you will be able to wrap CGAL methods really quickly.

About Kitware

Kitware Europe’s Scientific Visualization Department has extensive expertise in meshing algorithms, but also in multiple other fields such as massive datasets processing and visualization, in-situ visualization of simulation data, various rendering techniques, and much more.

Whether you are from a research organization or a commercial product company, feel free to reach out at kitware@kitware.com to discuss regarding technical needs or collaboration opportunities.

Leave a Reply