Installing the Polygon Mesh Processing Library in Ubuntu

December 10, 2022 · 5 mins read

The Polygon Mesh Processing Library (PMP) is a modern cross-platform C++ open-source library for processing and visualizing polygon surface meshes.

As stated in PMP’s GitHub repo, its main features are:

  • An efficient and easy-to-use mesh data structure
  • Standard algorithms such as decimation, remeshing, subdivision, or smoothing
  • Ready-to-use visualization tools
  • Seamless cross-compilation to JavaScript

The PMP library was developed by Daniel Sieger and Mario Botsch having in mind research, educational and industrial applications.

PMP is light-weight and easy-to-use alternative to well-known libraries such as CGAL and MeshLab. PMP comes under the MIT license, currently has 886 stars on GitHub and its last release was published in August 2022. For further details, take a look at this video.

All the steps necessary to install and run PMP on Ubuntu 22.04 are listed below. You can also try to install it leveraging the Windows Subsystem for Linux (WSL) however, as clarified here, the WSL is not tested by the developers, so if you are in trouble it may be not easy to get around the issues encountered. If you are interested in the WSL, take a look at this previous post. PMP can be installed on MacOS and Windows as well.

To provide detailed instructions, I assume that you have never run C/C++ code in Ubuntu. If you don’t have Ubuntu already installed on your machine, you can find a plethora of online tutorials on how to dual boot Ubuntu with Windows 10.

  1. Open a terminal (CTRL+ALT+T).

  2. Install git by typing in the terminal (you will be asked to enter your password):
     sudo apt install git-all
    

    and type

     git --version
    

    to check if the installation is successful.

  3. Install the GNU complier collection and other utilities necessary to compile programs:
     sudo apt install build-essential
    
  4. Install cmake:
     sudo apt install cmake
    
  5. Install the following packages:
     sudo apt install libx11-dev
     sudo apt install -y libxrandr-dev
     sudo apt install -y libxinerama-dev
     sudo apt install -y libxcursor-dev
     sudo apt install libxi-dev
    
  6. Install OpenGL to use the viewer classes.
     sudo apt update
     sudo apt install libglu1-mesa-dev freeglut3-dev mesa-common-dev
    
  7. Download PMP:
     git clone --recursive https://github.com/pmp-library/pmp-library.git 
    
  8. Checkout the latest release:
     cd pmp-library && git checkout 2.0.1 
    
  9. Configure and build
     mkdir build && cd build && cmake .. && make
    
  10. Install PMP:
    sudo make install
    
  11. Run the viewer application and load the Stanford bunny (as an OFF file):
    ./mpview ../external/pmp-data/off/bunny.off
    

Further installation details can be found here.

Let’s take a closer look at the mesh processing viewer. I’ve uploaded the vripped reconstruction of the Stanford Dragon that you can download here, which has 437k vertices and 871k faces:

The spacebar allows to change the drawing mode:

Let’s perform a uniform remeshing:

The decimation feature allows to reduce the number of triangles:

The program can also draw a few curvature maps (mean curvature in the image below):

The W key allows to export the processed mesh as an OFF file.

To perform more complex operations, you can write your own programs (API reference here):

#include <pmp/SurfaceMesh.h>
using namespace pmp;

int main()
{
    SurfaceMesh mesh;
    mesh.read(mesh,"dragon.ply");
    // do stuff
    mesh.write(mesh,"dragon_smoothed.ply");
}

If you are interested in understanding the math behind mesh processing algorithms, I highly recommend reading the Polygon Mesh Processing book by Mario Botsch.