/mesh_sampling

Samplers to obtain pointclouds from CAD meshes

Primary LanguageC++BSD 2-Clause "Simplified" LicenseBSD-2-Clause

mesh_sampling

License CI of mesh_sampling Package mesh_sampling

C++ Implementation of pointcloud generation from mesh sampling methods.

Sampling example

So far, the following samplers have been implemented:

  • Weighted random sampling: generates a given number of points uniformely distributed according to triangle areas. See this blog post for details on the method.

It is provided as-is, and could probably be optimized should the need arise. Feel free to submit merge requests.

Installation

From Ubunu packages (bionic and focal)

# Make sure you have required tools
sudo apt install apt-transport-https lsb-release ca-certificates gnupg
# Add our key
sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key F6D3710D0B5016967A994DFFA650E12EFF6D3EDE
# Add our repository
echo "deb https://dl.bintray.com/arntanguy/ppa-head $(lsb_release -sc) main" | sudo tee -a /etc/apt/sources.list.d/arntanguy-head.list
# Install packages
sudo apt install libmesh-sampling-dev

From source

Requirements:

  • cmake >3.11
  • Eigen3
  • PCL 1.7
  • Boost (program_options and filesystem)

If you do not already have a recent cmake installation (>3.11), you will need to install it. On Ubuntu bionic, this can be done by adding the official Kitware PPA, and updating cmake

For bionic:

wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main'
sudo apt-get update

For xenial:

wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | sudo apt-key add -
sudo apt-add-repository 'deb https://apt.kitware.com/ubuntu/ xenial-rc main'
sudo apt-get update

Then install cmake

sudo apt install cmake

You can now build and install this package

git clone --recursive https://github.com/arntanguy/mesh_sampling.git
cd mesh_sampling
mkdir build && cd build
cmake ..
make
sudo make install

Usage

Command-line tool

A simple binary executable mesh_sampling is provided. It'll convert any model supported by ASSIMP into its corresponding pointcloud with a given number of points. The command line is of the general form:

mesh_sampling /path/to/model.<supported_mesh_format> /path/to/cloud/cloud.<supported_cloud_format> --type xyz_rgb_normal --samples 10000 --binary

Where:

  • supported_mesh_format is one of the mesh format supported by ASSIMP (commonly DAE, STL, OBJ)
  • supported_cloud_format is a PCL formal (pcd or ply), or qhull's format (qc)

See mesh_sampling --help for more options.

Example:

mesh_sampling /path/to/model.dae /tmp/cloud.pcd --type xyz_rgb_normal --samples 10000 --binary
pcl_viewer /tmp/cloud.pcd -normals_scale 5 -normals 1

Generating convex files using qhull

To generate convex files, you will first need to convex your mesh to qhull's .qc format, then use qconvex to generate the convex hull.

mesh_sampling /path/to/model.<supported_mesh_format> /tmp/test.qc --type xyz --samples 10000
qconvex TI /tmp/test.qc TO /tmp/test-ch.txt Qt o f