Exporting Vector Graphics in ParaView 4.0

June 10, 2013

One of the most requested features for ParaView on the project’s UserVoice page is the ability to export visualizations in publication-quality vector graphics formats, such as postscript, SVG, or PDF. The ParaView 4.0 release is the first major release of the application that offers the ability to natively save these image formats.

What are Vector Graphics?

For those who may be unfamiliar, let’s explain why vector graphics are such a highly desired feature by contrasting them with the alternative: raster graphics formats.

A raster format, such as PNG, JPEG, or BMP, breaks an image into a grid of small pieces (pixels), and stores the color of each pixel in a file (the process of breaking an image into pixels is known as rasterization, hence the name “raster format”). While such formats are sufficient for most uses, their main disadvantage is that once an image has been rasterized at a given resolution, any features of the image that are smaller than a pixel are lost forever. This leads to visually unappealing results when zooming in on an image with software or printing an image at a high resolution (see image, below left).

Vector formats, on the other hand, store the image as a set of drawing primitives (shapes), such as polygons, ellipses, lines, Bézier curves, and text. The primitives are drawn by the viewing application or printer when the image is rendered, and the drawing is rasterized to match the resolution of the target device. This means that no matter how much a vector image is enlarged, the result is crisp and clear. The images below show the same region of a ParaView rendering that was exported to both formats, raster (left) and vector (right), each enlarged 400%.

Raster graphicsVector graphics


The difference is obvious — the vector image is much more appealing and shows far more detail. In addition to providing higher quality digitally enlargements, vector graphics are preferred by publishers, as the printed images are crisp at any print resolution.

Generating Vector Images in ParaView

To export a ParaView rendering as a vector format, click File >> Export Scene…, and then choose the desired format. The available formats are:

  • Postscript (.ps)

  • Encapsulated postscript (.eps)

  • Scalable vector graphics (.svg)

  • Portable document format (.pdf)

After selecting a format and filename, the export process can be configured:

  • Plot title: Set a descriptive title for the image. This only sets a value in the image’s metadata, and does not affect the resulting image.

  • Depth sort method: Method for sorting primitives by depth:

    • No sorting: Primitives are not sorted. The will be drawn in the order that they are rendered internally by ParaView. This will give bizarre results for 3D scenes, as ParaView does not sort 3D geometry prior to rendering. This is the setting to use when exporting charts, however, as the ParaView charts are rendered in the appropriate back-to-front order, with all primitives at the same depth. If a chart is being exported, ParaView will automatically use this setting, regardless of what is selected here.

    • Simple sorting: Perform a fast sort of the primitives using a reliable sorting method. This is usually sufficient for 3D scenes.

    • BSP sort: Use a binary-space-partitioning algorithm to sort the primitives. This gives the best results, but can be quite slow for large scenes. Use this when simple sorting fails to render the image properly.

  • Compress output file: Compress the output file with gzip, and append .gz to the filename.

  • Draw background: Use the background color from ParaView as the background for the image.

  • Cull hidden primitives: Remove primitives that are completely obscured from view in the exported image, reducing the file’s size.

  • Rasterize 3D geometry: Rasterize all 3D objects in the scene into the background of the image, overlaying 2D primitives and text. This is a workaround for a limitation of the vector graphics formats, some of which cannot handle texture-mapped or translucent 3D objects. This option also speeds up exporting of large scenes, but should be disabled when possible for the highest quality images.

  • Don’t rasterize cube axes: Exclude all cube axes instances from 3D geometry rasterization (when enabled).

  • Linewidth/point size scaling factors: Specify multiplicative scaling factors for line widths and point sizes. Users have reported that exported PDFs often have lines that are too thin, and this option provides a way to thicken them.

  • Render text as paths: Explicitly draw all text into the scene as a series of Bézier curves, rather than embedding the raw text and requiring the viewer to perform the text rendering. Setting this option ensures that the appearance of the exported text is consistent with the ParaView rendering, even if the same fonts aren’t available to the viewing application. This is especially recommended for PDF exports, as the format does not fully support all of the text styles available in ParaView.

Behind the Scenes

The vector graphics export in ParaView uses the GL2PS library to parse the OpenGL feedback buffer and compile the graphics file. The export process is coordinated by the vtkGL2PSExporter class in VTK, which has recently received an upgrade to add special cases to handle various corner-cases that GL2PS was unable to handle by itself.

<

p dir=”ltr”>To try this new feature out, download a copy of ParaView 4 today!

8 comments to Exporting Vector Graphics in ParaView 4.0

  1. Try disabling the “Rasterize 3D geometry” option in the export configuration.

    It is enabled by default because texture mapped surfaces are not exportable as vector primitives. Depending on how your surface is colored, you may end up with your exported object appearing grey/colorless. It will depend on whether the coloring is done per-cell or with a texture map.

    It looks like these colors are generated from point/cell attributes, in which case the exporter should be able to handle it once ‘Rasterize 3D geometry’ turned off.

  2. Hi, i would like to export the colored geometry to 3DSmax or Unity. Does someone have a tip on that? I’ve tried with several different options of extensions, and VRML seems to export correctly but when i import the colors are lost.

    Thanks in advance

Leave a Reply