Skip to content

NeoGeographyToolkit/cgal_tools

 
 

Repository files navigation

This repository contains tools that use CGAL to smoothe, fill holes, and remove connected components in meshes in .ply format, and also to simplify them. They can be used under the same terms as CGAL itself, which is usually some mix of GPL and LGPL. Anything in this repository not strictly derived from CGAL (which does not amount to much) can be used under the Apache II license.

Prerequisites

CGAL (>= 6.0), Boost, Eigen3, GMP, MPFR, cmake, and a C++ compiler. Install with conda:

conda install -c conda-forge cgal eigen boost gmp mpfr cmake cxx-compiler

Build

git clone https://github.com/NeoGeographyToolkit/cgal_tools.git
cd cgal_tools
mkdir -p build && cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j 10

To install to a specific location:

cmake .. -DCMAKE_BUILD_TYPE=Release \
  -DCGAL_TOOLS_INSTALL_DIR=/your/install/dir
make -j 10 install

The compiled programs will be in the bin subdirectory of the install path.

Using the tools

Remove small connected components from the mesh:

num_min_faces_in_component=1000
num_components_to_keep=1
rm_connected_components                  \
  $num_min_faces_in_component            \
  $num_components_to_keep                \
  <input_mesh.ply> <output_mesh.ply>

Mesh smoothing:

num_iter=1; smoothing_time=0.00005; smoothe_boundary=1
smoothe_mesh                              \
  $num_iter $smoothing_time $smoothe_boundary \
  <input_mesh.ply> <output_mesh.ply>

Note that the above command may remove too much of the mesh if being overly aggressive with parameters.

Hole-filling:

max_hole_diameter=0.4
max_num_hole_edges=1000
fill_holes                               \
  $max_hole_diameter $max_num_hole_edges \
  <input_mesh.ply> <output_mesh.ply>

Mesh simplification:

edge_keep_ratio=0.2
simplify_mesh $edge_keep_ratio           \
  <input_mesh.ply> <output_mesh.ply>

It is very strongly recommended to first run these tools on small meshes to get a feel for how they work. Meshlab can be used to inspect the results.

About

Simple tools that use CGAL to remesh, smoothe, and fill holes in meshes

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 97.2%
  • CMake 2.8%