A "smooth closest point" operator for projecting points near a triangle mesh onto the mesh, while avoiding undesirable projection onto edges.
Code to compute offset-surfaces around a manifold triangle mesh, tetrahedral mesh the space between the inner and outer offset surfaces (the shell), and embed the tetrahedral mesh in a higher-dimensional space. This higher-dimensional embedding can then be used for smooth closest-point queries for object within the shell.
Adapted from [Panozzo et al. 2013], see below.
Dependencies: OpenMesh (7.1 or higher), Eigen3, libigl. TetWild is also recommended, but is not required for building the application.
Please modify the paths below based on your machine. LIBIGL_DIR
should point to the libigl root folder and Eigen3_DIR
should point to the folder containing Eigen3Config.cmake
.
mkdir build
cd build
cmake .. -DLIBIGL_DIR="D:/dev/libigl" -DEigen3_DIR="D:/dev/eigen3/build"
cmake --build . --config Release
mkdir build
cd build
cmake .. -DLIBIGL_DIR="/usr/local/libigl" -DEigen3_DIR="/usr/local/eigen3/build" -DCMAKE_BUILD_TYPE=Release
cmake --build .
For pre-processing (compute and embed shell tet mesh), the main point of entry is computeAndSaveOffsetSurfaces
followed by computeAndSaveEmbedding
.
./
, ./matlab/
, and ./decimator/
../data/
. Let’s call it bunny.obj
.computeAndSaveEmbedding("bunny")
../data/bunny_out_cgal.obj
and ./data/bunny_in_cgal.obj
. For objects that are thin everywhere, the inner offset surface may be absent. Please ensure that the TetWild-processed surfaces are located at ./data/bunny_out.obj
and ./data/bunny_in.obj
(if inner surface exists). If not using TetWild, simply rename the files (remove _cgal
).computeAndSaveEmbedding("bunny", 1000)
. This may take a while. Higher the value of the second parameter, better the embedding quality but higher the runtime for this step. The triangle and tetrahedral meshes are created in a simple text format at ./data/bunny_tri.txt
and ./data/bunny_tet.txt
. Use readMesh("./data/bunny_tri.txt", 3, 8)
and readMesh("./data/bunny_tet.txt", 4, 8)
to read and view these meshes, if required.Note that the main technical component is embedMeshAndSpace.m
. The rest is boilerplate code.
Call functions in Phong.dll
(Phong.so
/Phong.dylib
on Linux/MacOS). Typical usage:
Phong
object using createPhongObject()
.project()
or projectBruteForce()
.Phong
object using deletePhongObject()
.Please see src/phong/Phong.h
for details. The exported functions are at the bottom of the file in an extern "C"
block.
splineOnSurface
. Add ./bspline/
to MATLAB path to use this.generateCurveOnMesh
. Requires geodesic_matlab.computeKeypoints
. These keypoints lie at curvature extrema and are generally well-spaced (not too close or too far from each other).In accordance with the license associated with Panozzo et al.’s original repo, this code is free to use for non-commercial applications, including my changes and additions.
——— Introduction
Reference implementation for the paper Weighted Averages on Surfaces
Daniele Panozzo, Ilya Baran, Olga Diamanti, Olga Sorkine
SIGGRAPH 2013
This code is free to use for non-commercial applications, please cite our paper if you use it in your project.
@article{Panozzo2013,
author = {Daniele Panozzo and Ilya Baran and Olga Diamanti and Olga Sorkine-Hornung},
title = {Weighted Averages on Surfaces},
journal = {ACM Transactions on Graphics (proceedings of ACM SIGGRAPH)},
volume = {32},
number = {4},
year = {2013},
}
——— Content of the package:
The code is divided into three parts:
1) Euclidean embedding metric computation (matlab) Section 3.5
This can be used independently, the script that contains the implementation is WA_precompute.m.
It depends on the fast_marching toolbox from Gabriel Peyre (http://www.mathworks.com/matlabcentral/fileexchange/6110-toolbox-fast-marching) and on OpenMesh(http://www.openmesh.org).
2) Phong Projection (C++)
This can be used independently, it is contained two files (TrianglePhong.h and TrianglePhong.cpp) and it only requires Eigen to be compiled. See the comments in the header file for more details.
3) Weighted Averages (C++)
It depends on Eigen and on the libigl 0.2.1 (http://igl.ethz.ch/projects/libigl/).
4) Matlab wrapper for the entire system
While the C++ code in 2) and 3) should be called directly from your C++ application to achieve good performances, we also provide two simple matlab wrappers that can be used to experiment with the method.
The two main methods are WA_forward.m and WA_inverse.m that solve the forward and inverse problem respectively. We also included a simple command-line test application WA_check.m and an interactive application that locally parametrize a mesh WA_starthere.m.
——— Dependencies
Matlab: Fast-marching toolbox (http://www.mathworks.com/matlabcentral/fileexchange/6110-toolbox-fast-marching), OpenMesh(http://www.openmesh.org).
C++: Eigen 3.2.0 (http://eigen.tuxfamily.org/), libigl(http://igl.ethz.ch/projects/libigl/)
All the dependencies (except OpenMesh) are included in the package for convenience.
Version 1.0 - August 14th 2013