Skip to content

jrl-umi3218/mesh_sampling

 
 

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 Ubuntu packages (20.04, 22.04, 24.04)

# Setup the mirror
curl -1sLf 'https://dl.cloudsmith.io/public/mc-rtc/stable/setup.deb.sh' | sudo -E bash
# Install packages
sudo apt install libmesh-sampling-dev

From source

Requirements:

  • cmake >3.11
  • Eigen3
  • libqhull-dev

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/jrl-umi3218/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:

  • From file to file
mesh_sampling /path/to/model.<supported_mesh_format> --out /path/to/cloud/cloud.<supported_cloud_format> --type xyz_rgb_normal --samples 10000 --binary
  • From folder to folder

Here the default cloud format is .qc. For all files in /path/to/models a file /path/to/cloud/filename.qc will be generated.

mesh_sampling /path/to/models --out /path/to/cloud --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 --in /path/to/model.dae --out /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 need to add --convex option to the command line. The convex file will be generated in the specified folder as filename-ch.txt.

  • From file
mesh_sampling --in /path/to/model.<supported_mesh_format> --out /tmp/test.qc --convex /path --type xyz --samples 10000
  • From folder (check all files with respect to the supported extensions ".ply", ".pcd", ".qc", ".stl")
mesh_sampling --in /path/to/models --out /tmp --convex /tmp --type xyz --samples 10000

Cloud saving is optional, you can remove --out option to avoid it.

About

Samplers to obtain pointclouds from CAD meshes

Resources

License

BSD-2-Clause, GPL-3.0 licenses found

Licenses found

BSD-2-Clause
LICENSE
GPL-3.0
COPYING

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 94.8%
  • CMake 4.7%
  • Shell 0.5%