GithubHelp home page GithubHelp logo

alecjacobson / gptoolbox Goto Github PK

View Code? Open in Web Editor NEW
616.0 43.0 166.0 28.67 MB

Matlab toolbox for Geometry Processing.

License: MIT License

MATLAB 86.02% M 0.02% C++ 10.05% C 0.31% Objective-C++ 0.08% Mathematica 0.33% CMake 3.19%

gptoolbox's Introduction

gptoolbox - Geometry Processing Toolbox

Build Status

https://github.com/alecjacobson/gptoolbox/

This is a toolbox of useful matlab functions for geometry processing. There are also tools related to constrainted optimization and image processing. Typically these are utility functions that are not stand alone applications.

Here's an incomplete list of cool features this matlab toolbox contains:

  • wrappers for TetGen, Triangle, QSlim, meshfix
  • mesh smoothing
  • mesh clean up (remove duplicates, remove unreferenced)
  • geodesic distances on triangle and tetrahedral meshes
  • mesh quantities and queries (normals, discrete gaussian curvature, list boundary edges, topology, angles, dihedral angles etc.)
  • mesh deformation (as-rigid-as-possible (ARAP), moving least-squares, etc.)
  • mesh parameterization (harmonic, least squares conformal, ARAP, etc.)
  • automatic skinning weight computation (bounded biharmonic weights, bone heat)
  • 2D triangle mesh from binary image
  • Input/Output for many mesh formats (.obj,.off,.stl,.wrl,.ply,.mesh,.node,.ele,.poly,.smf,.bdl,.face)
  • discrete differential geometry operators for triangle and tetrahedral meshes (cotangent Laplacian, gradient, divergence)
  • quadratic programming, active set solver
  • scribble-based image colorization, diffusion curves
  • exact (un)signed distance field computation for meshes
  • constructive solid geometry operations on meshes, booleans
  • accelerated point location in triangle and tetrahedral meshes
  • image dithering
  • deep matlab function dependency

The functions have been organized into folders based on their primary application:

  • external/
  • imageprocessing/
  • images/
  • matrix/
  • mesh/
  • mex/
  • utility/
  • wrappers/

Installation

The vast majority of this code is straight MATLAB (*.m files). Thus, only installing MATLAB and adding the qptoolbox directory and its subdirectories to your MATLAB path is needed for installation. Let's assume you cloned gptoolbox at /Users/ajx/Repos/gptoolbox/, then you could issue:

addpath(strjoin(strcat(['/Users/ajx/Repos/gptoolbox/'],{'external','imageprocessing', 'images', 'matrix', 'mesh', 'mex', 'quat','utility','wrappers'}),':'))

To make this change permanent, then issue:

savepath

There are some mex files, whose documentation for installation are included in respective mex/README.md file.

Full installation

This strives to be full installation instructions, but will no doubt remain incomplete for some time. Begin by adding paths as above.

As stated above, most files are straight matlab and will just run if you have gptoolbox in your path.

Compile /mex

Most of our mex files will depend on libigl. Some depend on cgal and embree. We recently switched to a cmake-based build.

See mex/README.md for details.

Compile external/toolbox_fast_marching/

In MATLAB issue:

cd external/toolbox_fast_marching/
compile_mex

Dependencies

gptoolbox depends on MATLAB and some of its toolbox extensions. Many functions should also work with Octave, though this has not been tested.

Functions that rely on quadprog have been tested and optimized assuming that the Mosek toolbox has been installed, but should also work with the quadprog in MATLAB's Optimization Toolbox.

Mex files may have other external dependencies (e.g. CGAL, Eigen, libigl). See their respective READMEs for more information. When installing mex libraries, you may need to modify the files in wrappers/ (such as path_to_libigl.m) so gptoolbox knows where to look.

Attribution

If you use gptoolbox in your academic projects, please cite the papers we implement as appropriate. To cite the library in general, you could use this BibTeX entry:

@misc{gptoolbox,
  title = {{gptoolbox}: Geometry Processing Toolbox},
  author = {Alec Jacobson and others},
  note = {http://github.com/alecjacobson/gptoolbox},
  year = {2021},
}

License

This work is dual licensed under MIT and Apache 2.

Please take extra note that the external/ directory contains code from elsewhere with potentially more restricted licenses.

Most of the mex/ directory includes libigl and Eigen (and some include CGAL), each with their own licenses.

Contact

The Geometry Processing Toolbox grew out of Alec Jacobson's private codebase during his PhD, but has benefited a lot from various collaborators at NYU, ETH Zurich, Columbia, University of Toronto and elsewhere. Now, the Geometry Processing Toolbox is a group endeavour. If you're intersted in contributing, please contact Alec Jacobson ([email protected]) or submit a pull request on github.

Documentation

For now, documentation is limited to a per-function basis. For example, to find documentation for cotmatrix, in MATLAB issue:

help cotmatrix

gptoolbox's People

Contributors

abhimadan avatar alecjacobson avatar alexandremercieraubin avatar bbrrck avatar daniel-frisch-kit avatar dingzeyuli avatar ianykey avatar lvrma avatar maxfrei750 avatar melissa2661 avatar mtao avatar nkh0472 avatar oqilipo avatar otmanon avatar paulkry avatar paulroetzer avatar per-ivar avatar rachael-wang avatar rarora7777 avatar schuellc avatar sgsellan avatar tiagosf00 avatar vibe007 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gptoolbox's Issues

Mex files dependencies problem

This is rather a help request than an issue with gptoolbox.

I want to use your blue noise code here: http://www.alecjacobson.com/weblog/?p=4111.
For that I compiled the mex file "ambient_occlusion.cpp". I got that working smoothly and here is the output:

compile_gptoolbox_mex
Warning: This is **VERY** experimental. In principle, this should compile all of the mex functions in this
directory. In practice, users will surely have to adjust paths and flags at the top of this file. 
> In compile_gptoolbox_mex (line 73) 
Hit any key to continue...
Verbose mode is on.
No MEX options file identified; looking for an implicit selection.
... Looking for compiler 'g++' ...
... Executing command 'which g++' ...Yes ('/usr/bin/g++').
... Executing command 'g++ -print-file-name=libstdc++.so' ...Yes ('/usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so').
Found installed compiler 'g++'.
Options file details
-------------------------------------------------------------------
    Compiler location: $GCC_DIR
    Options file: /usr/local/MATLAB/R2015a/bin/glnxa64/mexopts/g++_glnxa64.xml
    CMDLINE1 : /usr/bin/g++ -c -DMEX  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I/home/kareem/libigl/libigl/include -I/usr/include/eigen3 -I/home/kareem/libigl/libigl/external/embree -I/home/kareem/libigl/libigl/external/embree/include/  -I"/usr/local/MATLAB/R2015a/extern/include" -I"/usr/local/MATLAB/R2015a/simulink/include" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -msse4.2 -std=c++11 -O -DNDEBUG /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.cpp -o /tmp/mex_27949599571242_14566/ambient_occlusion.o
    CMDLINE2 : /usr/bin/g++ -pthread -Wl,--no-undefined  -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2015a/extern/lib/glnxa64/mexFunction.map" /tmp/mex_27949599571242_14566/ambient_occlusion.o   -lembree  -lsys   -L/home/kareem/libigl/libigl/external/embree/build   -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L"/usr/local/MATLAB/R2015a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o ambient_occlusion.mexa64
    CMDLINE3 : rm -f /tmp/mex_27949599571242_14566/ambient_occlusion.o
    CXX : /usr/bin/g++
    DEFINES : -DMEX  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP   -D_GNU_SOURCE -DMATLAB_MEX_FILE 
    MATLABMEX : -DMATLAB_MEX_FILE 
    CXXFLAGS : -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -msse4.2 -std=c++11
    INCLUDE : -I/home/kareem/libigl/libigl/include -I/usr/include/eigen3 -I/home/kareem/libigl/libigl/external/embree -I/home/kareem/libigl/libigl/external/embree/include/  -I"/usr/local/MATLAB/R2015a/extern/include" -I"/usr/local/MATLAB/R2015a/simulink/include"
    CXXOPTIMFLAGS : -O -DNDEBUG
    CXXDEBUGFLAGS : -g
    LDXX : /usr/bin/g++
    LDFLAGS : -pthread -Wl,--no-undefined 
    LDTYPE : -shared
    LINKEXPORT : -Wl,--version-script,"/usr/local/MATLAB/R2015a/extern/lib/glnxa64/mexFunction.map"
    LINKLIBS : -lembree  -lsys   -L/home/kareem/libigl/libigl/external/embree/build   -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L"/usr/local/MATLAB/R2015a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++
    LDOPTIMFLAGS : -O
    LDDEBUGFLAGS : -g
    OBJEXT : .o
    LDEXT : .mexa64
    GCC : /usr/bin/g++
    CPPLIB_DIR : /usr/lib/gcc/x86_64-linux-gnu/4.7/libstdc++.so
    MATLABROOT : /usr/local/MATLAB/R2015a
    ARCH : glnxa64
    SRC : /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.cpp
    OBJ : /tmp/mex_27949599571242_14566/ambient_occlusion.o
    OBJS : /tmp/mex_27949599571242_14566/ambient_occlusion.o 
    SRCROOT : /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion
    DEF : /tmp/mex_27949599571242_14566/ambient_occlusion.def
    EXP : ambient_occlusion.exp
    LIB : ambient_occlusion.lib
    EXE : ambient_occlusion.mexa64
    ILK : ambient_occlusion.ilk
    MANIFEST : ambient_occlusion.mexa64.manifest
    TEMPNAME : ambient_occlusion
    EXEDIR : 
    EXENAME : ambient_occlusion
    OPTIM : -O -DNDEBUG
    LINKOPTIM : -O
-------------------------------------------------------------------
Building with 'g++'.
/usr/bin/g++ -c -DMEX  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP  -DIGL_SKIP   -D_GNU_SOURCE -DMATLAB_MEX_FILE  -I/home/kareem/libigl/libigl/include -I/usr/include/eigen3 -I/home/kareem/libigl/libigl/external/embree -I/home/kareem/libigl/libigl/external/embree/include/  -I"/usr/local/MATLAB/R2015a/extern/include" -I"/usr/local/MATLAB/R2015a/simulink/include" -ansi -fexceptions -fPIC -fno-omit-frame-pointer -pthread -std=c++11 -msse4.2 -std=c++11 -O -DNDEBUG /home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.cpp -o /tmp/mex_27949599571242_14566/ambient_occlusion.o
/usr/bin/g++ -pthread -Wl,--no-undefined  -shared -O -Wl,--version-script,"/usr/local/MATLAB/R2015a/extern/lib/glnxa64/mexFunction.map" /tmp/mex_27949599571242_14566/ambient_occlusion.o   -lembree  -lsys   -L/home/kareem/libigl/libigl/external/embree/build   -Wl,-rpath-link,/usr/local/MATLAB/R2015a/bin/glnxa64 -L"/usr/local/MATLAB/R2015a/bin/glnxa64" -lmx -lmex -lmat -lm -lstdc++ -o ambient_occlusion.mexa64
rm -f /tmp/mex_27949599571242_14566/ambient_occlusion.o
MEX completed successfully.

I also appended the path to embree to the LD_LIBRARY_PATH and here is the full path:

/usr/local/MATLAB/R2015a/sys/os/glnxa64:/usr/local/MATLAB/R2015a/bin/glnxa64:/usr/local/MATLAB/R2015a/extern/lib/glnxa64:/usr/local/MATLAB/R2015a/runtime/glnxa64:/usr/local/MATLAB/R2015a/sys/java/jre/glnxa64/jre/lib/amd64/native_threads:/usr/local/MATLAB/R2015a/sys/java/jre/glnxa64/jre/lib/amd64/server:/opt/AMDAPPSDK-3.0/lib/x86_64/:/home/kareem/libigl/libigl/external/embree/build

However, when I try to run your blue noise code, I get the following error:

Invalid MEX-file '/home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.mexa64': libembree.so.2:
cannot open shared object file: No such file or directory

To check the dependencies of ambient_occlusion.mexa64, I ran !ldd and here is what I got:

/home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.mexa64: /usr/local/MATLAB/R2015a/sys/os/glnxa64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by /home/kareem/libigl/libigl/external/embree/build/libembree.so.2)
/home/kareem/hiwi/gptoolbox/gptoolbox/mex/ambient_occlusion.mexa64: /usr/local/MATLAB/R2015a/sys/os/glnxa64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /home/kareem/libigl/libigl/external/embree/build/libembree.so.2)
    linux-vdso.so.1 =>  (0x00007fff4b140000)
    libembree.so.2 => /home/kareem/libigl/libigl/external/embree/build/libembree.so.2 (0x00007f3dd8cdf000)
    libmx.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmx.so (0x00007f3dd8907000)
    libmex.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmex.so (0x00007f3dd86d8000)
    libstdc++.so.6 => /usr/local/MATLAB/R2015a/sys/os/glnxa64/libstdc++.so.6 (0x00007f3dd83d1000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3dd80c9000)
    libgcc_s.so.1 => /usr/local/MATLAB/R2015a/sys/os/glnxa64/libgcc_s.so.1 (0x00007f3dd7eb4000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3dd7aea000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3dd78cc000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3dd94d8000)
    libmwresource_core.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwresource_core.so (0x00007f3dd76ca000)
    libmwi18n.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwi18n.so (0x00007f3dd73dc000)
    libut.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libut.so (0x00007f3dd711d000)
    libmwfl.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwfl.so (0x00007f3dd6d19000)
    libmwMATLAB_res.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwMATLAB_res.so (0x00007f3dd6674000)
    libboost_date_time.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_date_time.so.1.49.0 (0x00007f3dd6463000)
    libboost_filesystem.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_filesystem.so.1.49.0 (0x00007f3dd6244000)
    libboost_log.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_log.so.1.49.0 (0x00007f3dd5f6c000)
    libboost_signals.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_signals.so.1.49.0 (0x00007f3dd5d54000)
    libboost_system.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_system.so.1.49.0 (0x00007f3dd5b51000)
    libboost_thread.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_thread.so.1.49.0 (0x00007f3dd5936000)
    libmwcpp11compat.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwcpp11compat.so (0x00007f3dd5729000)
    libicudata.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicudata.so.52 (0x00007f3dd3ec0000)
    libicuuc.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicuuc.so.52 (0x00007f3dd3b35000)
    libicui18n.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicui18n.so.52 (0x00007f3dd3712000)
    libicuio.so.52 => /usr/local/MATLAB/R2015a/bin/glnxa64/libicuio.so.52 (0x00007f3dd3505000)
    libtbb.so.2 => /usr/local/MATLAB/R2015a/bin/glnxa64/libtbb.so.2 (0x00007f3dd32ba000)
    libtbbmalloc.so.2 => /usr/local/MATLAB/R2015a/bin/glnxa64/libtbbmalloc.so.2 (0x00007f3dd3068000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f3dd2e4d000)
    libmwservices.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwservices.so (0x00007f3dd2818000)
    libmwmpath.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwmpath.so (0x00007f3dd25d4000)
    libmwm_dispatcher.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwm_dispatcher.so (0x00007f3dd22d0000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3dd20cc000)
    libexpat.so.1 => /usr/local/MATLAB/R2015a/bin/glnxa64/libexpat.so.1 (0x00007f3dd1ea4000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3dd1c9c000)
    libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f3dd1a64000)
    libboost_chrono.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_chrono.so.1.49.0 (0x00007f3dd185d000)
    libboost_regex.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_regex.so.1.49.0 (0x00007f3dd1542000)
    libboost_serialization.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_serialization.so.1.49.0 (0x00007f3dd12ca000)
    libunwind.so.8 => /usr/local/MATLAB/R2015a/bin/glnxa64/libunwind.so.8 (0x00007f3dd10ab000)
    libmwdisplay_device.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwdisplay_device.so (0x00007f3dd0ea6000)
    libmwregexp.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwregexp.so (0x00007f3dd0c5e000)
    libmwmlutil.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwmlutil.so (0x00007f3dd058b000)
    libmwsettingscore.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwsettingscore.so (0x00007f3dd0121000)
    libmwms.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwms.so (0x00007f3dcfb4e000)
    libmwMATLAB_settings_res.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwMATLAB_settings_res.so (0x00007f3dcf92c000)
    libmwnativedisplay.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwnativedisplay.so (0x00007f3dcf723000)
    libmwopccore.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopccore.so (0x00007f3dcf4c3000)
    libmwopcmodel.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopcmodel.so (0x00007f3dcf23d000)
    libmwopczippackage.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopczippackage.so (0x00007f3dcf01b000)
    libmwopcmwservices.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwopcmwservices.so (0x00007f3dceb33000)
    libboost_iostreams.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_iostreams.so.1.49.0 (0x00007f3dce91e000)
    libncurses.so.5 => /lib/x86_64-linux-gnu/libncurses.so.5 (0x00007f3dce6fa000)
    libssl.so.1.0.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libssl.so.1.0.0 (0x00007f3dce490000)
    libcrypto.so.1.0.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libcrypto.so.1.0.0 (0x00007f3dce0ae000)
    libPocoCrypto.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoCrypto.so.23 (0x00007f3dcde8c000)
    libPocoFoundation.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoFoundation.so.23 (0x00007f3dcdad7000)
    libPocoJSON.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoJSON.so.23 (0x00007f3dcd88a000)
    libPocoNet.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoNet.so.23 (0x00007f3dcd580000)
    libPocoNetSSL.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoNetSSL.so.23 (0x00007f3dcd33f000)
    libPocoUtil.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoUtil.so.23 (0x00007f3dcd0d4000)
    libPocoXML.so.23 => /usr/local/MATLAB/R2015a/bin/glnxa64/libPocoXML.so.23 (0x00007f3dcce46000)
    libxerces-c-3.1.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libxerces-c-3.1.so (0x00007f3dcc7c1000)
    libmwxmlcore.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwxmlcore.so (0x00007f3dcc54d000)
    libavrocpp.so.1.7.5.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libavrocpp.so.1.7.5.0 (0x00007f3dcc26f000)
    libmwflnetwork.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libmwflnetwork.so (0x00007f3dcbf8d000)
    libminizip.so => /usr/local/MATLAB/R2015a/bin/glnxa64/libminizip.so (0x00007f3dcbd81000)
    libtinfo.so.5 => /lib/x86_64-linux-gnu/libtinfo.so.5 (0x00007f3dcbb58000)
    libboost_program_options.so.1.49.0 => /usr/local/MATLAB/R2015a/bin/glnxa64/libboost_program_options.so.1.49.0 (0x00007f3dcb8fa000)

Please note the first 2 lines of the above !ldd output. This is strange to me and I tried to solve it using the suggestions here: http://stackoverflow.com/questions/23494103/version-cxxabi-1-3-8-not-found-required-by with no success.

Any pointers on how can I solve this?

heat_geodesic underestimating distance

Hi Alec,
I'm having trouble computing geodesic distance on a surface with heat_geodesic. The initial point is the bottom right blue dot. I'm expecting a distance of sqrt(2) for the flat diagonal where I'm getting ~.36 as seen in the following image. The non-legacy heat geodesic implementation flips everything around. I've also included an image of the gradient for the plane.

Thanks!

pasted image at 2017_07_06 12_40 pm

pasted image at 2017_07_06 01_39 pm

clear;
cla;

gridSize = 100;
sourcePt = 1;

[x,y] = meshgrid(0:gridSize,0:gridSize);

% z = peaks(gridSize+1);
z = zeros(gridSize+1);

V = [x(:)./gridSize y(:)./gridSize z(:)];

tri = delaunay(V(:,1),V(:,2));

D = heat_geodesic(V,tri,sourcePt);
% D = biharmonic_distance(V,tri,sourcePt,2);

hold on
trisurf(tri,V(:,1),V(:,2),V(:,3),D);
scatter3(V(sourcePt,1),V(sourcePt,2),V(sourcePt,3),'filled')

colormap hot
shading flat

a little question about grad()

Hi, Alec

Nice to see again here. Here is my situation, I want to use grad to compute the gradient on each vertices of a mesh, but I found the grad() function solving the gradient on each faces only. So my question is:

how do we compute the gradient on each vertex? Do you think it is reasonable if we just accumulate the gradient of each triangle which connected to that vertex to get the result?

Many thanks
Tao

Typo in icp.m

in the help text of icp.m:

   13 %     'MaxRNorm'  followed by minimum norm on diff entries of R {1e-5}
   14 %     'MaxTNorm'  followed by minimum norm on diff entries of t {1e-5}

should be

   13 %     'MinRNorm'  followed by minimum norm on diff entries of R {1e-5}
   14 %     'MinTNorm'  followed by minimum norm on diff entries of t {1e-5}

Great toolbox!
thank you

Windows?

From personal email:

I am very much interested in your work which is gptoolbox. I found it very interesting but it seems that it is tedious to have it on windows. Does it work also on Windows? Do you have any help for that.

build for win7x64 and matlab

I used for build this (alecjacobson branch)
https://ci.appveyor.com/project/danielepanozzo/libigl-6hjk1

git clone -q --branch=alecjacobson https://github.com/libigl/libigl.git
git checkout -qf 3887cdd
git submodule update --init --recursive

image
OK!

cd tutorial
mkdir build
cd build
cmake -D "LIBIGL_USE_STATIC_LIBRARY=ON" -G "Visual Studio 14 2015 Win64" ../
image

MATLAB_MAT_LIBRARY - NOT FOUND
MATLAB_MEX_LIBRARY - NOT FOUND
MATLAB_MX_LIBRARY - NOT FOUND
MATLAB_ENF_LIBRARY - NOT FOUND

and in CMakeError.log

D:\alecjacobson\libigl\tutorial\build\CMakeFiles\CMakeTmp\CheckIncludeFile.c(1): fatal error C1083: ## Cannot open include file: 'pthread.h': No such file or directory [D:\alecjacobson\libigl\tutorial\build\CMakeFiles\CMakeTmp\cmTC_8d429.vcxproj]

Try use cmale-gui
CGAL_DIR-NOTFOUND
image

and Matlab_ROOT_DIR D:\MATLAB/R2017a
image

Push configure

-- libigl includes:
D:/tmp/libbb/shared/cmake/../../external/nanogui/ext/eigen
D:/tmp/libbb/shared/cmake/../../include
D:/tmp/libbb/shared/cmake/../../external/CoMISo/ext/gmm-4.2/include
D:/tmp/libbb/shared/cmake/../../external/CoMISo/../
D:/tmp/libbb/shared/cmake/../../external/embree/include
D:/tmp/libbb/shared/cmake/../../external/lim
MATLAB_INCLUDE_DIR-NOTFOUND
D:/tmp/libbb/shared/cmake/../../external/nanogui/ext/glew/include
D:/tmp/libbb/shared/cmake/../../external/nanogui/ext/glfw/include
D:/tmp/libbb/shared/cmake/../../external/nanogui/ext/glew/include
D:/tmp/libbb/shared/cmake/../../external/nanogui/ext/glfw/include
D:/tmp/libbb/shared/cmake/../../external/nanogui/ext/glfw/include
D:/tmp/libbb/shared/cmake/../../external/nanogui/ext/glew/include
D:/tmp/libbb/shared/cmake/../../external/stb_image
D:/tmp/libbb/shared/cmake/../../external/tetgen
D:/tmp/libbb/shared/cmake/../../external/triangle
D:/tmp/libbb/shared/cmake/../../external/tinyxml2
-- libigl libraries:
igl_xml
igl_triangle
igl_tetgen
igl_png
igl_viewer
igl_opengl_glfw
igl_opengl2
igl_opengl
igl_matlab
igl_lim
igl_embree
igl_comiso
igl
-- libigl extra libraries:
CoMISo
D:/tmp/libbb/shared/cmake/../../external/CoMISo/ext/OpenBLAS-v0.2.14-Win64-int64/lib/libopenblas.dll.a.lib
embree
lim
MATLAB_MAT_LIBRARY-NOTFOUND
MATLAB_MEX_LIBRARY-NOTFOUND
MATLAB_MX_LIBRARY-NOTFOUND
MATLAB_ENG_LIBRARY-NOTFOUND
opengl32
glew
opengl32
glew
glfw
stb_image
tetgen
triangle
tinyxml2
-- libigl definitions:
-DIGL_STATIC_LIBRARY
-DINCLUDE_TEMPLATES
-DIGL_NO_MOSEK
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.

Problem on calling min_quad_with_fixed

Hi,

I tried to call [Z,F,Lambda,Lambda_known] = min_quad_with_fixed(A,B,[],[],Aeq,Beq) but got some error at
[F.L,p,F.S] = chol(QRAuu,'lower','vector');
which stated that 'Too many output arguments.'

Then I found the problem maybe stem from
AeqTQ2 = AeqTQ(:,(nc+1):end);
which gave empty matrix for AeqTQ2.

Any suggestion for this problem would be appreciated.

Here are the matrices for A, B, Aeq, Beq:
https://drive.google.com/open?id=16f3IIlOStRp6bshGoPAoPiMqRDo0Xefg

Is this toolbox linux compatible?

I'm having some trouble getting this toolbox up and running on a linux-based server. Should I expect it to work? (Running Matlab R2016a on Ubuntu Trusty.)

The issue seems to be related to loading the necessary libraries. I noticed that some bits of the code (e.g. geodesic_new_mesh.m) look to load libraries by testing ispc and ismac first, but both of these return false on a linux system, so it seems that nothing will be loaded as a result.

Any advice gratefully received! :-)

cotmatrix and direction of mean curvature normal

image
image
Hello there,
I had computed discrete cotangent Laplacian matrix of a surface by using cotmatrix.m. In above, the directions of discrete mean curvature normal(Orange arrow) of several points are not in the opposite direction of vertex normal direction(Blue arrow). It occurs for several points marked as red in the first figure. Does this problem come from mesh structure?

Compilation Problem

Hi @alecjacobson,

Thank you for sharing your code.
I am currently having a problem with the installation of the gptoolbox library. I tried to compile the code through Matlab by calling "compile_gptoolbox_mex" and the Matlab got stuck in compiling the "ambient_occlusion" for a long time. After that, I tried to compile using cmake and I got another error message that libigl could not be found.
I am working on Linux Mint 17.2 and my Matlab version is R2016a.

Could you help with the installation?
Thanx

re-triangulate mesh

Hi @alecjacobson

Thanks for the great work. Can you help me modify the triangulation of my mesh if possible. I am loading a CAD file as an .stl by getting the F, faces and V, vertices of it

[V,F] = load_mesh('lab.STL');
However, this mesh has a really strange pre-triangulation format as you can see in the image below:

image

My intention is if possible to remove this triangulation and apply another one. Do you know if that is possible?

Thanks.

Best regards,
Theo

Crash using mex file: 'mesh_boolean' with Windows7 / MATLAB 2015b / VS2015

Compilation of the mex file works fine but if I run the following example MATLAB crashes.

mesh_boolean_compile_windows.m:

%% Settings

arch = '64';
msvc = '14';

boost_version ='1_61';
path_to_boost=['C:\dev\boost_' boost_version '_0'];

cgal_version='4.8.1';
path_to_cgal=['C:\dev\CGAL-' cgal_version];

eigen_version='07105f7124f9';
path_to_eigen=['C:\dev\eigen-eigen-' eigen_version];

path_to_libigl='C:\dev\libigl';

path_to_gmp = ['C:\dev\CGAL-' cgal_version '\auxiliary\gmp'];

%%

MEXOPTS={'-v','-largeArrayDims','-DMEX'};
MSSE42='CXXFLAGS=$CXXFLAGS -msse4.2';
STDCPP11='CXXFLAGS=$CXXFLAGS -std=c++11';

BOOST_INC=['-I' path_to_boost];
BOOST_LIB={['-L' path_to_boost '\lib' arch '-msvc-' msvc '.0'], ...
    ['-lboost_thread-vc' msvc '0-mt-' boost_version '.lib'], ...
    ['-lboost_system-vc' msvc '0-mt-' boost_version '.lib']};

CGAL_INC={['-I' path_to_cgal '\build\include'], ...
    ['-I' path_to_cgal '\include']};
CGAL_LIB={['-L' path_to_cgal '\build\lib'],...
    ['-lCGAL-vc' msvc '0-mt-' cgal_version '.lib'],...
    ['-lCGAL_Core-vc' msvc '0-mt-' cgal_version '.lib']};

CGAL_FLAGS='CXXFLAGS=\$CXXFLAGS -frounding-math';

EIGEN_INC= ['-I' path_to_eigen];

GMP_INC=['-I' path_to_gmp '\include'];
GMP_LIB=strsplit(sprintf('-L%s/lib  -llibgmp-10.lib -llibmpfr-4.lib',path_to_gmp));

LIBIGL_INC=sprintf('-I%s/include',path_to_libigl);
LIBIGL_FLAGS='-DIGL_SKIP';
LIBIGL_LIB={'-DIGL_SKIP'};
LIBIGL_LIBMATLAB='-DIGL_SKIP';
LIBIGL_LIBCGAL='-DIGL_SKIP';
LIBIGL_LIBCORK='-DIGL_NO_CORK';
LIBIGL_BASE={LIBIGL_INC,LIBIGL_FLAGS,LIBIGL_LIB{:},LIBIGL_LIBMATLAB};

mex( ...
  MEXOPTS{:}, MSSE42, STDCPP11, ...
  LIBIGL_BASE{:},EIGEN_INC, ...
  CGAL_INC{:},CGAL_LIB{:},CGAL_FLAGS, ...
  LIBIGL_LIBCGAL, LIBIGL_LIBCORK, ...
  BOOST_INC,BOOST_LIB{:}, ...
  GMP_INC, GMP_LIB{:},...
  'mesh_boolean.cpp');

mex compilation log:
mesh_boolean_compile_windows.txt

mesh_boolean_example.m:

close all; clearvars; opengl hardware;

addpath(genpath('../'));
addpath(genpath('../../../matGeom'));

V1=[0 0 0;1 1 0;1 0 1;0 1 1];

F1=[1 2 3;1 3 4;1 4 2;4 3 2];

V2=[0.2770         0    1.1710;...
   -0.1710    1.0000    0.2770;...
    0.7230         0   -0.1710;...
    1.1710    1.0000    0.7230];

F2=F1;


%% Plotting
PatchProps.EdgeColor = 'none';

PatchProps.FaceAlpha = 0.5;
PatchProps.EdgeLighting = 'none';
PatchProps.FaceLighting = 'gouraud';

figure('Units','pixels','Color','w','ToolBar','figure','renderer','opengl',...
    'position', [1 1 800 600]);

subplot(2,2,1)
PatchProps.FaceColor = 'g';
patch('Faces', F1, 'Vertices',V1, PatchProps)
PatchProps.FaceColor = 'y';
patch('Faces', F2, 'Vertices',V2, PatchProps)


[W,H] = mesh_boolean(V1,F1,V2,F2, 'union');
subplot(2,2,2)
title('MB: union')
PatchProps.FaceColor = 'r';
patch('Faces', H, 'Vertices', W, PatchProps)

[W,H] = mesh_boolean(V1,F1,V2,F2, 'intersect');
subplot(2,2,3)
title('MB: intersect')
PatchProps.FaceColor = 'r';
patch('Faces', H, 'Vertices', W, PatchProps)

[W,H] = mesh_boolean(V1,F1,V2,F2, 'minus');
subplot(2,2,4)
title('MB: minus')
PatchProps.FaceColor = 'r';
patch('Faces', H, 'Vertices', W, PatchProps)

for i=1:4
    subplot(2,2,i)
    axis on; axis equal
    H_Light(1) = light; H_Light(2) = light('Position', -1*(get(H_Light(1),'Position')));
    view(3)
end

matlab crash log

MATLAB crash file:C:\Users\USER\AppData\Local\Temp\matlab_crash_dump.2188-1:


------------------------------------------------------------------------
          Access violation detected at Fri Jun 24 21:17:59 2016
------------------------------------------------------------------------

Configuration:
  Crash Decoding      : Disabled
  Crash Mode          : continue (default)
  Current Graphics Driver: Unknown hardware 
  Default Encoding    : windows-1252
  Graphics card 1     : NVIDIA ( 0x10de ) NVIDIA GeForce GTX 645 Version 9.18.13.3182
  Host Name           : COMPUTER
  MATLAB Architecture : win64
  MATLAB Root         : C:\Program Files\MATLAB\R2015b
  MATLAB Version      : 8.6.0.267246 (R2015b)
  OpenGL              : hardware
  Operating System    : Microsoft Windows 7 Enterprise 
  Processor ID        : x86 Family 6 Model 60 Stepping 3, GenuineIntel
  Virtual Machine     : Java 1.7.0_60-b19 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
  Window System       : Version 6.1 (Build 7601: Service Pack 1)

Fault Count: 1


Abnormal termination:
Access violation

Register State (from fault):
  RAX = 0000000000000000  RBX = 00000000f77d01c0
  RCX = 000000003ddf4070  RDX = 00000000f77d01b0
  RSP = 00000000d3ffc1f8  RBP = 00000000d3fffa00
  RSI = 0000000000000088  RDI = 00000000f77d01c0

   R8 = fffffffffffffffe   R9 = 00000000f77d01c0
  R10 = 000007fee20f9be8  R11 = 0000000d0043000e
  R12 = 00000000d3ffd858  R13 = 000007fee211d778
  R14 = 00000000d3ffc588  R15 = 000007fee20b9790

  RIP = 0000000019f1a5e3  EFL = 00010246

   CS = 0033   FS = 0053   GS = 002b

Stack Trace (from fault):
[  0] 0x0000000019f1a5e3                     C:\WinBuilds\bin\libgmp-10.dll+00108003 _gmpn_sub_nc+00000035
[  1] 0x0000000073cbce40                                   <unknown-module>+00000000
[  2] 0x000000005e5b6c60                                   <unknown-module>+00000000
[  3] 0x000007fee20b531f D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00414495
[  4] 0x000007fee20f1f43 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00663363
[  5] 0x000007fee20f6302 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00680706
[  6] 0x000007fee20f6546 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00681286
[  7] 0x000007fee2078a3c D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00166460
[  8] 0x000007fee2101919 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00727321 mexFunction+00038633
[  9] 0x000007fef54cc710  C:\Program Files\TortoiseSVN\bin\VCRUNTIME140.dll+00050960 _C_specific_handler+00000544
[ 10] 0x000007fef54c2ac2  C:\Program Files\TortoiseSVN\bin\VCRUNTIME140.dll+00010946 _FrameUnwindFilter+00001074
[ 11] 0x00000000777db4d1                      C:\Windows\SYSTEM32\ntdll.dll+00308433 RtlRestoreContext+00000738
[ 12] 0x000007fee205a3e7 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00041959
[ 13] 0x000007fee2083f34 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00212788
[ 14] 0x000007fee20e4fbe D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00610238
[ 15] 0x000007fee20c6051 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00483409
[ 16] 0x000007fee20d615f D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00549215
[ 17] 0x000007fee20d0f79 D:\Knee\Code\#Extern\#Mesh\gptoolbox\mex\mesh_boolean.mexw64+00528249
[ 18] 0x000007fef40abe1d                   C:\Windows\system32\ucrtbase.DLL+00441885 crt_at_quick_exit+00000125
[ 19] 0x00000000776859bd                   C:\Windows\system32\kernel32.dll+00088509 BaseThreadInitThunk+00000013
[ 20] 0x00000000777ba2e1                      C:\Windows\SYSTEM32\ntdll.dll+00172769 RtlUserThreadStart+00000033


If this problem is reproducible, please submit a Service Request via:
    http://www.mathworks.com/support/contact_us/

A technical support engineer might contact you with further information.

Thank you for your help.

Thanks in advance.

skeleton_extraction - wrong mesh or bug?

I tried to run skeleton_extraction with this triangle mesh:
Femur_L.zip

[V, F] = readPLY('Femur_L.ply');
[W,E,U] = skeleton_extraction(V,F);

But I get the following error

Index exceeds matrix dimensions.

Error in adjacency_matrix (line 25)
  A = sparse([E(:,1) E(:,2)],[E(:,2) E(:,1)],1);

Error in skeleton_extraction (line 160)
    A = adjacency_matrix(E)+speye(size(W,1));

Error in skeleton_example (line 16)
[W,E,U] = skeleton_extraction(V,F)

Is there a problem with the mesh or is it a bug?

Thanks in advance

Diff operation

From personal email:

I have been using mesh_boolean from gptoolbox. The difference operation is working fine, but i am getting some small pieces/segments of unwanted triangles apart from the main object. Below is the screenshot. Are there any methods to remove those spurious triangles, maybe some segmentation method? Thanks in advance for your help.
aa

GPtoolbox - Exact geodesics (missing)

From personal email:

I have to use the exact geodesics code from Danil Kirsanov. I saw you got a wrapper for it already in GPtoolbox which is great!. However, the comment says that it depends on igl_external.

Where are the binaries? I couldn't find them in GPtoolbox/external or libigl/external ...

Compiling ambient_occlusion function with Windows

I'm trying to compile the function ambient_occlusion with Microsoft Visual C++ 2015 and Matlab 2017b on Windows 7 as following:

clearvars

clc
path_to_eigen='C:\Users\faa23\Desktop\3D_DiskTop\MatlabCodes\iges (original)\eigen-eigen-';
% Check if the eigen path is correct
assert(exist([path_to_eigen '\Eigen\Core'],'file')==2)

path_to_libigl='C:\Users\faa23\Desktop\3D_DiskTop\MatlabCodes\iges (original)\libigl';
 %Check if the libig path is correct
assert(exist([path_to_libigl '\include\igl\embree\EmbreeIntersector.h'],'file')==2)
%%

MEXOPTS={'-v','-largeArrayDims','-DMEX'};

EIGEN_INC= ['-I' path_to_eigen];

LIBIGL_INC=['-I' path_to_libigl '\include'];
LIBIGL_FLAGS='-DIGL_SKIP';
LIBIGL_LIB={'-DIGL_SKIP'};
LIBIGL_LIBMATLAB='-DIGL_SKIP';
LIBIGL_LIBCGAL='-DIGL_SKIP';
LIBIGL_LIBCORK='-DIGL_NO_CORK';
LIBIGL_BASE={LIBIGL_INC, LIBIGL_FLAGS,LIBIGL_LIB{:}, LIBIGL_LIBMATLAB};

mex( ...
  MEXOPTS{:}, ...
  LIBIGL_BASE{:},EIGEN_INC, ...
  'ambient_occlusion.cpp');

But I got this error:

Error using mex
ambient_occlusion.cpp
c:\users\faa23\desktop\3d_disktop\matlabcodes\iges (original)\libigl\include\igl\EPS.h(16): warning C4305: 'initializing': truncation from 'double' to 'float'
c:\users\faa23\desktop\3d_disktop\matlabcodes\iges (original)\libigl\include\igl\EPS.h(17): warning C4305: 'initializing': truncation from 'double' to 'float'
c:\users\faa23\desktop\3d_disktop\matlabcodes\iges (original)\libigl\include\igl\embree\EmbreeIntersector.h(24): fatal error C1083: Cannot open include file: 'embree2/rtcore.h': No such file or directory

Error in STLoffset (line 25)
mex( ...

The thing is there is no folder called embree2 in libigl
Hope someone can help with this.
Thank you all

Shrink wrap mesh?

Hello

My question is if something similar could be done with this toolbox?

There is a function in Materialise Magics to Shrink Wrap a mesh:
You can define:

  • Sample Interval [mm]
  • Gap Fill [mm]
  • Organic Shape [True/False]
  • Add extra thickness [mm]

Here is an example:
Original:
original
Shrink Wrap with 2mm Sample Interval, 20mm Gap Fill and Organic Shape True:
shrinkwrap_sampleinterval-2mm_gapfill-20mm_organicshape-true

Thanks in advance
oqilipo

Error in tsurf function

In this example
http://www.alecjacobson.com/weblog/?p=4708

I was able to get SV and SF.
But when i run the second section of the script to plot the STL and see it as follow:

clf;
hold on;
t = tsurf(F,V,'EdgeColor','none',fsoft, 'FaceVertexCData',repmat(blue,size(V,1),1),'FaceAlpha',1+(iso<0)(0.35-1),fphong);
ts = tsurf(SF,SV,'EdgeAlpha',0.2+(iso<0)(0-0.2),fsoft,'FaceVertexCData',repmat(orange,size(SV,1),1),fphong,'FaceAlpha',1+(iso>0)(0.2-1));
apply_ambient_occlusion(ts);
hold off;
axis equal;
view(-20,20)
camlight;
t.SpecularStrength = 0.04;
l = light('Position',[5 -5 10],'Style','local');
add_shadow(t,l,'Color',0.8[1 1 1],'Fade','local','Ground',[0 0 -1 min([V(:,3);SV(:,3)])]);
set(gca,'pos',[0 0 1 1])
set(gca,'Visible','off');
set(gcf,'Color','w');
drawnow;

I get the following error:

Error using matlab.graphics.primitive.Patch/set
Error setting property 'FaceVertexCData' of class 'Patch':
Value must be an Nx1 or Nx3 array of numeric type

Error in tsurf (line 130)
set(t_copy,varargin{v:end});

Error in Untitled (line 29)
t = tsurf(F,V,'EdgeColor','none',fsoft, 'FaceVertexCData',repmat('blue',size(V,1),1),'FaceAlpha',1+(iso<0)*(0.35-1),fphong);

Thought V,F,SV and SF are all Nx3 array of type double
Does any any one have an idea what would be the problem???

Thank you

STL-offset issue

Hello Professor Jacobson,
First of all, I would like to thank you for making the great gptoolbox.

I have a surface in STL file format and would like to offset it as in the following example:

(Offset surface of triangle mesh in matlab)
http://www.alecjacobson.com/weblog/?p=4708

The thing is, when I run the example I get the following error:

Attempt to execute SCRIPT signed_distance as a function:
C:\Users\faa23\Desktop\MatlabCodes\signed_distance.m

Error in Untitled4 (line 16)
D = signed_distance(BC,V,F);

Can you please tell me what should I do to make it work?

Thank you so much

given command for MATLAB path expansion does not work

I have an issue with the commands from https://github.com/alecjacobson/gptoolbox#installation :

  1. gp_subdirs = split(genpath('/usr/local/gptoolbox/'),':');
  2. addpath(strjoin(gp_subdirs(~contains(gp_subdirs,'.git')),':'));
    are given for expansion of MATLAB's path.

Command 1 works fine.
Command 2 does not with MATLAB R2016b on a GNU/Linux host. I cannot figure out the problem. Error message is:

Error using catdirs (line 25)
All arguments must be character vectors.

Error in addpath (line 63)
p = catdirs(mfilename, varargin{1:n});

My workaround, either:

  1. run 'pathtool' and use 'Add with Subfolders...'

or

  1. From command 2 execute: strjoin(gp_subdirs(~contains(gp_subdirs,'.git')),':')
    That will return a long string, like "/path/to/folder1:/path/to/folder2".
  2. copy and paste the content of the string without the quotation marks (") into the "addpath('')" command, like: addpath('/path/to/folder1:/path/to/folder2')
  3. run the command

Clarification of license?

Thanks for making this! But I’m confused by the wording at https://github.com/alecjacobson/gptoolbox#license because it doesn’t list a license. All published code is copyrighted by someone or something, whether its MPL2 or BSD or GPL licensed, right? So what‘s the license right now? (I.e., specific questions someone might have include, “if I make changes to this, do I have to share them with upstream?” Also, “Can I use this at work?”)

Error-limited Mesh decimation

Hi @alecjacobson

thanks for the great work and your help so far.

I need to decimate meshes until a certain error-treshhold is reached. The meshes have a high precision and I cannot afford to lose too much details. Is there anything in your Toolbox that could help me with that?

As I understand your proposed point_mesh_squared_distance(P,V,F)-Function (Point, Vertices, Faces?) computes the distance to the nearest point...I need to compare the original mesh with a decimated mesh or something similar.

Common High-precision Data defines the error as max. distance of mesh patches to original surface or min distance of two vertices to be allowed to create a Patch between them.

Thanks in advance.

Best regards
TheBlune

mex problems of gptoolbox

I'm using the gptoolbox to generate some sdf data from 'off' files. However, the gptoolbox would make MATLAB crash. First, I compiled the signed_distance_isosurface.cpp in 'mex' dir using next command:

' mex -g -largeArrayDims -DMEX CXXFLAGS="$CXXFLAGS -std=c++11"...
-I/usr/local/igl/libigl/include ...
-I/usr/include/eigen3 ...
-I/usr/include ...
-L/usr/lib ...
-lCGAL -lCGAL_Core -lgmp -lmpfr...
-lboost_thread -lboost_system ...
signed_distance_isosurface.cpp'

This process would not generate any errors. However, MATLAB would crash when I tried to run a demo. The demo code is:

addpath('mesh');
addpath('mex');
[V,F,UV,C,N] = readOFF( 'bed.off');
[OV,OF] = signed_distance_isosurface(V,F);

The error is shown in next fig. Could you please help me? Thanks.

image

Typo in schur_complement.m

BABTFUN is not defined on this line:

%y = minres(BABTFUN,BAif-g,tol,max_iter);

I suppose you should rather use BABTCFUN.

Other: On a sparse system of total size 3108x3108, with A being indefinite but symmetric, this function is considerably slower than \. I have tried using Factorize, which is only 3 times slower in my case than \ (but it has the advantage that the factors can be precomputed, so they are usable with different right-hand-sides).

Compilation of mesh_boolean, issues with CGAL

Hello,

I am struggling with compilation of the mesh_boolean mex function (on Linux), and thus ask for a kind help. I have already found that I need to set LIBIGL_WITH_CORK in ./gptoolbox/mex/CMakeLists.txt to ON. Regarding CGAL compilation: Without any changes into CGAL or gptoolbox files, I receive an error ... can not be used when making a shared object; recompile with -fPIC. Thus, I tried to recompile CGAL with this flag by putting -DCMAKE_POSITION_INDEPENDENT=ON into CMAKE_ARGS of the ./libigl/external/CMakeLists.txt. Although the compliation went fine then, Matlab showed an error indicating that the resulting mex file is not valid.

Do you have any suggestions? What is the proper way to build the mesh_boolean and other CGAL-dependent functions?

Thanks for help.

Marek

Points projection on an object

Hello Alec,

I was just wondering if you have made a function that works like the function (projpartIGES) from igestoolbox by Per Bergström
https://www.mathworks.com/matlabcentral/fileexchange/13253-iges-toolbox

As shown in the attached pictures,this function creates grid points in 2D (green color)and project them onto the surface of an object in IGS file format,and return points in 3D (Red color) with dimensions according to the object surface.

For my application:
I'm looking for a function that does exactly the same thing BUT for a body made of triangle mesh (V and F). And has the ability to make two different grid spacing one for Primary direction (dp) and the other for Secondary direction (ds).

Here I'm also attaching the code for the example with small modifications:
I'm not sure if you need to compile makeIGESmex for this example.

As usual, Thank you so much for the great help.

% exampleProjection.m plots an IGES CAD-object and project points on its surface

% Compile the c-files (if necessary)
 %makeIGESmex;
%%
% Load parameter data from IGES-file.
[ParameterData,EntityType,numEntityType,unknownEntityType,numunknownEntityType]=iges2matlab('IGESfiles/example.igs');

% Project a set of points in a regular grid on the surface

% Projection data

R=[2000;0;600]; % Grid origin
normal=[0;0;-1]; % Direction of projection
normal=normal/norm(normal);
% pdir=randn(3,1); % First (primary) direction of grid
% pdir=pdir-dot(pdir,normal)*normal;
% pdir=pdir/norm(pdir);
% sdir=cross(pdir,normal); % Second (secondary) direction of grid
% sdir=sdir/norm(sdir);
        pdir=[0;1;0];%pdir/norm(pdir);
        %pdir=pdir-dot(pdir,normal)*normal;
        sdir=cross(-pdir,normal); % Second (secondary) direction of grid
dp=80; % Grid spacing
nppos=60; % Number of positive grids in primary direction
npneg=80; % Number of negative grids in primary direction
nspos=65; % Number of positive grids in secondary direction
nsneg=75; % Number of negative grids in secondary direction

% Do the projection
[model,UV,srfind,srfDerivind,srfDer,numpoints]=projpartIGES(ParameterData,R,normal,pdir,sdir,dp,nppos,npneg,nspos,nsneg);

% Plots

% Plot the IGES object
figno=1;
plotIGES(ParameterData,1,figno,[],0);

Pnts=zeros(3,(npneg+1+nppos)*(nsneg+1+nspos));

ind=0;
for i=-npneg:nppos
    for j=-nsneg:nspos
        ind=ind+1;
        Pnts(:,ind)=R+i*dp*pdir+j*dp*sdir;
    end
end

plot3(Pnts(1,:),Pnts(2,:),Pnts(3,:),'.','Color',[0.1 0.5 0.4]);

% Plot normal, starting at grid origin
lines=[R R+15*dp*normal];
plot3(lines(1,:),lines(2,:),lines(3,:),'r-');

% Plot pdir, starting at grid origin
lines=[R R+15*dp*pdir];
plot3(lines(1,:),lines(2,:),lines(3,:),'g-');

% Plot sdir, starting at grid origin
lines=[R R+15*dp*sdir];
plot3(lines(1,:),lines(2,:),lines(3,:),'b-');

% Plot projected points
plot3(model(1,srfind>0),model(2,srfind>0),model(3,srfind>0),'.','Color','r');

axis auto

hold off;

Top View

top view

3D View

3d view

Problem on compiling '/mex' on windows

Hi Alec:
I'm tring to compile '/mex' on Win10,vs2015 and Matlab2016b. I use cmake3.3.2, CGAL-4.11.1, boost_1_66_0-msvc-14.0-32.
I have used boost_1_66_0-msvc-14.0-32 to build CGAL-4.11.1 and run its demo. But when I use cmake to build '/mex', it shows that:
“CMake Error at C:/My Program Files/CMake3.3.2x86/share/cmake-3.3/Modules/FindBoost.cmake:1245 (message):
Unable to find the requested Boost libraries.
Boost version: 1.66.0
Boost include path: F:/boost_1_66_0
Could not find the following static Boost libraries:
boost_thread
boost_system
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.”
I have checked my folder(F:\boost_1_66_0\lib32-msvc-14.0 ) has "boost_thread-vc140-mt-gd-x32-1_66.dll","boost_thread-vc140-mt-gd-x32-1_66.lib","boost_thread-vc140-mt-x32-1_66.dll","boost_thread-vc140-mt-x32-1_66.lib","boost_system-vc140-mt-gd-x32-1_66.dll","boost_system-vc140-mt-gd-x32-1_66.lib","boost_system-vc140-mt-x32-1_66.dll","boost_system-vc140-mt-x32-1_66.lib".

Have you met this problem? could you please give me suggestion?
thanks in advance!

Tab completion error in Matlab 2017a

Hi Alec,
When I use add_gptoolbox_tab_completion in my Matlab 2017a environment, a failure occurs as:

Error tabcomplete>getCurrentXmlDefs (line 170)
E:\Program Files\MATLAB\R2017a\toolbox\local\TC.xml was not found - cannot set tab-completions

Error tabcomplete (line 106)
    [defs,tcXmlFilename] = getCurrentXmlDefs;

Error add_gptoolbox_tab_completion>@(x)tabcomplete(x{1},x{2})

Error add_gptoolbox_tab_completion (line 75)
  cellfun(@(x) tabcomplete(x{1},x{2}),L,'UniformOutput',false);

How to fix this error? Thanks.

Choice of signs/constants in cotmatrix / lscm ?

From personal email:

Your cotmatrix returns -1/(4A_i)(cot + cot)?
(negative sign and an extra 2, why this choice?)
Just to be clear. My cotmatrix returns: L(i,j) = 1/4 * (cot(alpha) + cot(beta)) for an internal edge (i,j) with opposite angles alpha and beta. This means the off-diagonal entries are positive for an (intrinsically) Delaunay mesh and the diagonal (L(i,i) = -sum_j!=i L(i,j)) is negative.

I think the minus sign (w.r.t. what other people use) is reasonable justified.

Consider the discrete Dirichlet energy for piecewise linear function u on a 3D triangle mesh:

1/2*u'*G'*A*G*u

where G is a #3F by #V matrix that computes the piecewise constant gradient xyz-components per-triangle, and A is a diagonal matrix repeating triangle areas (integrating the gradients).

Green's first identity tells us that in the continuous world: 1/2*<∇u,∇u> = -1/2*<u,∆u> + boundary term.

So if we repeat this in the discrete world, we'd expect that:

1/2*u'*G'*A*G*u = = -u'*M*(M\L)*u = -u'*L*u

where M is a per vertex mass matrix (that immediately gets cancelled out), M\L computes the "point wise" or "integral average" Laplacian value and L is the Laplacian from cotmatrix.

[You can actually verify this equality using G = grad(V,F); and A = repdiag(diag(sparse(doublearea(V,F)/2)),size(F,2))]

The one-half just got swallowed into L, I guess. It's here to stay for legacy reasons.

One important consequence: is that my L is negative semi-definite. Solvers like, chol will vomit on just L, but you just have to hit the right and left sides of your solve with a minus sign.

I am comparing your stuff with [Mullen et al. SGP’08] as in that paper: L_c = L_d - A,

while in your case you have:
L_c = -L_d + 2*A.

This is a direct consequence of the "-1/2" above and the fix below.

(haven’t looked at the reason for the extra 2 on A yet)

Also, why did you need to do this flip?

% Flip XY
P = sparse(1:2*n,[n+(1:n) 1:n],1,2*n,2*n);
Q = -repdiag(L,2) + 2*A;
Q = P’*Q*P;

Seems this was a very silly way of negating the area. It should have been and now (ba8d1e5) is just:

Q = -L - 2*A;

mexw64 compiling 'signed_distance' [persistent precomputation data feature request]

Alec: pasted from email:

Dear Alec Jacobson,

I would like to use the function signed_distance of your matlab toolbox gptoolbox for my research. Unfortunately, I have been unsuccessful in mexw64 compiling. Hopefully you can give me some help.

If you already have a mexw64 compiled version of this function, it is probably easiest to just send me this file. Otherwise, this is in short what I have done so far:

  •      I followed the standard installation instructions on the gptoolbox github site;
    
  •      I tried to follow the full installation instructions on the gptoolbox github as well though didn’t succeed:
    

o I downloaded and extracted libigl and eigen3;

o I followed the instructions for compiling libigl as a static library with visual studio. Compilation failed with many errors. Though, I am uncertain if it is necessary to compile a static library of libigl for the function signed_distance.

  •      In matlab, I tried the following line and got multiple errors:
    

o mex -v -largeArrayDims -DMEX -IC:\libigl\include -IC:\eigen3 -O signed_distance.m signed_distance.cpp

Kind Regards,
JM

Compiling mex file: 'intersect_other.cpp' with Windows7 / MATLAB 2015b / VS2013

Hello

I'm trying to compile 'intersect_other.cpp' & 'mesh_boolean.cpp' on:
Windows 7
MATLAB 2015b
VS2013

with the following code "compile_gptoolbox_mex_adjusted.m":

path_to_eigen='C:\dev\eigen';
path_to_eltopo='C:\dev\eltopo';
path_to_libigl='C:\dev\libigl';
CGAL='C:\dev\CGAL-4.8-beta1\build';
BOOST='C:\dev\boost_1_60_0';

MEXOPTS={'-v','-largeArrayDims','-DMEX'};
MSSE42='CXXFLAGS=$CXXFLAGS -msse4.2';
STDCPP11='CXXFLAGS=$CXXFLAGS -std=c++11';

% if exist('/usr/local/include/eigen3')
%   EIGEN_INC='-I/usr/local/include/eigen3';
% elseif exist('/opt/local/include/eigen3')
%   EIGEN_INC='-I/opt/local/include/eigen3';
% end
EIGEN_INC=sprintf('-I%s/',path_to_eigen);

ELTOPO_INC= sprintf('-I%s/',path_to_eltopo);
ELTOPO_LIB= strsplit(sprintf('-L%s/eltopo3d -leltopo_release',path_to_eltopo));
CLANG={'CXX=/usr/bin/clang++','LD=/usr/bin/clang++'};
FRAMEWORK_LDFLAGS='LDFLAGS=\$LDFLAGS -framework Foundation -framework AppKit -framework Accelerate';
NOOPT_LDOPTIMFLAGS='LDOPTIMFLAGS="-O "';

% See libigl documentation. In short, Libigl is a header-only library by
% default: no compilation needed (like Eigen). There's an advanced **option**
% to precompile libigl as a static library. This cuts down on compilation time.
% It is optional and more difficult to set up. Set this to true only if you
% know what you're doing.
use_libigl_static_library = false;
LIBIGL_INC=sprintf('-I%s/include',path_to_libigl);
if use_libigl_static_library
  LIBIGL_FLAGS='-DIGL_STATIC_LIBRARY';
  LIBIGL_LIB=sprintf('-L%s/lib -ligl',path_to_libigl);
  LIBIGL_LIBEMBREE='-liglembree';
  LIBIGL_LIBMATLAB='-liglmatlab';
  LIBIGL_LIBCGAL='-liglcgal';
  LIBIGL_LIBBOOLEAN='-liglboolean';
  LIBIGL_LIBSVD3X3='-liglsvd3x3';
else
  % `mex` has a silly requirement that arguments be non-empty, hence the NOOP
  % defines
  LIBIGL_FLAGS='-DIGL_SKIP';
  LIBIGL_LIB='-DIGL_SKIP';
  LIBIGL_LIBMATLAB='-DIGL_SKIP';
  LIBIGL_LIBEMBREE='-DIGL_SKIP';
  LIBIGL_LIBCGAL='-DIGL_SKIP';
  LIBIGL_LIBBOOLEAN='-DIGL_SKIP';
  LIBIGL_LIBSVD3X3='-DIGL_SKIP';
end
LIBIGL_BASE={LIBIGL_INC,LIBIGL_FLAGS,LIBIGL_LIB,LIBIGL_LIBMATLAB};

SVD_INC=sprintf('-I%s/external/Singular_Value_Decomposition/',path_to_libigl);

EMBREE=[path_to_libigl '/external/embree'];
EMBREE_INC=strsplit(sprintf('-I%s -I%s/include/',EMBREE,EMBREE));
EMBREE_LIB=strsplit(sprintf('-L%s/build -lembree -lsys',EMBREE));

CORK=[path_to_libigl '/external/cork'];
CORK_INC=sprintf('-I%s/include',CORK);
CORK_LIB=strsplit(sprintf('-L%s/lib -lcork',CORK));

% if exist('/usr/local/include/CGAL')
%   CGAL='/usr/local/';
% elseif exist('/opt/local/include/CGAL')
%   CGAL='/opt/local/';
% end

CGAL_INC=sprintf('-I%s/include',CGAL);
CGAL_LIB=strsplit(sprintf('-L%s/lib -lCGAL -lCGAL_Core -lgmp -lmpfr',CGAL));
CGAL_FLAGS='CXXFLAGS=\$CXXFLAGS -frounding-math';

% BOOST='/opt/local/';
BOOST_INC=sprintf('-I%s/include',BOOST);
BOOST_LIB=strsplit(sprintf('-L%s/lib -lboost_thread-mt -lboost_system-mt',BOOST));

mex( ...
  MEXOPTS{:}, MSSE42, STDCPP11, ...
  LIBIGL_BASE{:},EIGEN_INC, ...
  LIBIGL_LIBCGAL, ...
  CGAL_INC,CGAL_LIB{:},CGAL_FLAGS, ...
  BOOST_INC,BOOST_LIB{:}, ...
  'intersect_other.cpp');

mex( ...
  MEXOPTS{:}, MSSE42, STDCPP11, ...
  LIBIGL_BASE{:},EIGEN_INC, ...
  CGAL_INC,CGAL_LIB{:},CGAL_FLAGS, ...
  LIBIGL_LIBCGAL, LIBIGL_LIBBOOLEAN, ...
  CORK_INC,CORK_LIB{:}, ...
  BOOST_INC,BOOST_LIB{:}, ...
  'mesh_boolean.cpp');

But I get the following error:

Verbose mode is on.
... Looking for compiler 'Microsoft Windows SDK 7.1 (C++)' ...
... Looking for registry setting 'HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1' InstallationFolder ...Yes ('C:\Program Files\Microsoft SDKs\Windows\v7.1\').
... Looking for registry setting 'HKLM\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VC7' 10.0 ...Yes ('C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\').
... Looking for file 'C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\cl.exe' ...Yes.
... Looking for folder 'C:\Program Files (x86)\Microsoft Visual Studio 10.0' ...Yes.
Found installed compiler 'Microsoft Windows SDK 7.1 (C++)'.
Set PATH = C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE;C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Tools;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\amd64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Bin\VCPackages;C:\Program Files\Microsoft SDKs\Windows\v7.1\\Bin\x64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\Bin;;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MATLAB\R2015b\runtime\win64;C:\Program Files\MATLAB\R2015b\bin;C:\Program Files\MATLAB\R2015a\runtime\win64;C:\Program Files\MATLAB\R2015a\bin;C:\Program Files\Microsoft Windows Performance Toolkit\;C:\Program Files\Microsoft\Web Platform Installer\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\WinBuilds\bin;C:\Program Files\MITK 2015.5.2\bin;C:\Program Files\TortoiseGit\bin;C:\ndigital\programs;C:\Program Files\TortoiseSVN\bin;C:\Program Files (x86)\CMake\bin;C:\dev\boost_1_60_0\lib64-msvc-11.0;C:\dev\CGAL-4.8-beta1\auxiliary\gmp\lib;C:\Program Files\TortoiseHg\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\
Set INCLUDE = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\\INCLUDE;C:\Program Files\Microsoft SDKs\Windows\v7.1\\INCLUDE\gl;C:\Program Files\MATLAB\R2015b\extern\include;;
Set LIB = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib\amd64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\Lib\X64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB\AMD64;C:\Program Files\MATLAB\R2015b\lib\win64;C:\Program Files\MATLAB\R2015b\extern\lib\win64;
Set LIBPATH = C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\Lib\amd64;C:\Program Files\Microsoft SDKs\Windows\v7.1\\LIB\X64;C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\ATLMFC\LIB\AMD64;C:\Program Files\MATLAB\R2015b\extern\lib\win64;
Error using mex
MEX cannot find library 'CGAL' specified with the -l option.
 MEX looks for a file with one of the names:
 CGAL.lib
 libCGAL.lib
 Please specify the path to this library with the -L option.


Error in compile_gptoolbox_mex_adjusted (line 77)
mex( ...

Would appreciate any help

Thanks in advance

Question about the backface culling point cloud extraction

Hello,

Thanks for the great code. I tried to implement the code to my project and it works good for backface culling. However, I cannot find the way to find the output of the pointcloud of the visible and invisible and I can only get the indexes of the surface normals. Is there a way to get the output for the point cloud indexes for the invisible and visible region?

Here is the code I used to test the algorithm:

Load = LoadData();
pt_brain = Load.LoadBrain('brain_slice.stl','stl');

V = pt_brain.vertices;
F = pt_brain.faces;

N = normals(V,F);
BC = barycenter(V,F);
back_facing = sum(N.*bsxfun(@minus,BC,campos),2)<=0;

t = tsurf(F,V,'EdgeColor','none','FaceLighting','phong');view(2);
axis equal;
camproj('persp');
t.FaceVertexCData = 1*(sum(N.*bsxfun(@minus,BC,campos),2)<=0);
t.FaceVertexCData(sum(N.bsxfun(@minus,BC,campos),2)>0) = nan;
test_idx = 1
(sum(N.*bsxfun(@minus,BC,campos),2)<=0);
rotate3d on;
apply_ambient_occlusion();

The test_idx is the index for the surface normal but not for the point cloud.

Thanks

Example in ordered_outline documentation

The example in ordered_outline works with a mesh, but for the example in the documentation, it generates an assert

V = [0 0; 1 0; 1 1 ; 0 1; 4 0; 4 4; 0 4];
F = [1 2 3; 1 2 4; 6 5 7];
[B,L] = ordered_outline(F);
hold on
for l = 1:(numel(L)-1)
plot(V([B(L(l):(L(l+1)-1)) B(L(l))],1),V([B(L(l):(L(l+1)-1)) B(L(l))],2));
end
hold off

p.s. You can bake examples/testcases so that they run whenever the function is called with no arguments, e.g.

%--- Example
if nargin==0
    load camelhead.mat;
    V = M.vertices;
    F = M.faces;
    % V = [0 0; 1 0; 1 1 ; 0 1; 4 0; 4 4; 0 4];
    % F = [1 2 3; 1 2 4; 6 5 7];
    [B,L] = ordered_outline(F);
    hold on
    for l = 1:(numel(L)-1)
    plot(V([B(L(l):(L(l+1)-1)) B(L(l))],1),V([B(L(l):(L(l+1)-1)) B(L(l))],2));
    end
    hold off
    return;
end

[Question] Are points inside a triangle mesh?

I'm looking for a fast way (mex) to detect if points are inside a closed triangle mesh.

I saw "in_element_aabb", but this seems to be for tet meshes only?

Is there another function for triangle meshes in the toolbox that I may have missed?

Thanks in advance

Compiling mex file: 'mesh_boolean.cpp' with Windows10 / MATLAB 2015a / VS2015

I thought it would be better to open a another issue for this because the errors are different.

Hope this is OK for you.

At the moment I only have access to another windows machine with a different setup:
Windows10
MATLAB 2015a
VS2015

Version:
Boost: 1.60
CGAL: 4.8
Eigen: https://github.com/RLovelett/eigen/tree/aa826f047e42ce239c9b6887fbb0f709844805f1
libigl: https://github.com/libigl/libigl/tree/4ccac53005994f695eea123cd85e92be27caecb2

code looks like:

arch = '64';
msvc = '14';

boost_version = '1_60';
path_to_boost='C:\dev\boost';
cgal_version='4.8';
path_to_cgal=['C:\dev\CGAL-' cgal_version];
path_to_cork='C:\dev\cork';
path_to_eigen='C:\dev\eigen';
path_to_gmp =['C:\dev\CGAL-' cgal_version '\auxiliary\gmp'];
path_to_libigl = 'C:\dev\libigl';


MEXOPTS={'-v','-largeArrayDims','-DMEX'};
MSSE42='CXXFLAGS=$CXXFLAGS -msse4.2';
STDCPP11='CXXFLAGS=$CXXFLAGS -std=c++11';


BOOST_INC=sprintf('-I%s',path_to_boost);
BOOST_LIB=strsplit(sprintf('-L%s/lib%s-msvc-%s.0 -lboost_thread-vc%s0-mt-%s.lib -lboost_system-vc%s0-mt-%s.lib',...
    path_to_boost, arch, msvc, msvc,boost_version, msvc,boost_version));

CGAL_INC=sprintf('-I%s/include',path_to_cgal);
CGAL_LIB=strsplit(sprintf('-L%s/lib -lCGAL-vc%s0-mt-%s.lib -lCGAL_Core-vc%s0-mt-%s.lib',...
    path_to_cgal, msvc,cgal_version, msvc,cgal_version));
CGAL_FLAGS='CXXFLAGS=\$CXXFLAGS -frounding-math';

CORK_INC=sprintf('-I%s/src',path_to_cork);

EIGEN_INC=sprintf('-I%s',path_to_eigen);

GMP_INC=sprintf('-I%s/include',path_to_gmp);
GMP_LIB=strsplit(sprintf('-L%s/lib  -llibgmp-10.lib -llibmpfr-4.lib',path_to_gmp));

LIBIGL_INC=sprintf('-I%s/include',path_to_libigl);
LIBIGL_FLAGS='-DIGL_SKIP';
LIBIGL_LIB={'-DIGL_SKIP'};
LIBIGL_LIBMATLAB='-DIGL_SKIP';
LIBIGL_LIBEMBREE='-DIGL_SKIP';
LIBIGL_LIBCGAL='-DIGL_SKIP';
LIBIGL_LIBCORK='-DIGL_NO_CORK';
LIBIGL_BASE={LIBIGL_INC,LIBIGL_FLAGS,LIBIGL_LIB{:},LIBIGL_LIBMATLAB};

mex( ...
  MEXOPTS{:}, MSSE42, STDCPP11, ...
  BOOST_INC,BOOST_LIB{:}, ...
  CGAL_INC,CGAL_LIB{:},CGAL_FLAGS, ...
  EIGEN_INC, ...
  GMP_INC, GMP_LIB{:},...
  LIBIGL_BASE{:}, LIBIGL_LIBCGAL, LIBIGL_LIBCORK, ...
  'mesh_boolean.cpp');

produces error C2248

c:\dev\libigl\include\igl\copyleft\cgal\order_facets_around_edge.cpp(203): error C2248:
'Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1>>::PlainObjectBase': cannot access protected member
declared in class 'Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1>>'
c:\dev\eigen\eigen\src/Core/PlainObjectBase.h(457): note: see declaration of
'Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1>>::PlainObjectBase'
c:\dev\eigen\eigen\src/Core/Matrix.h(179): note: see declaration of
'Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1>>'
c:\dev\libigl\include\igl\copyleft\cgal\extract_cells.cpp(484): note: see reference to function template
instantiation 'void
igl::copyleft::cgal::order_facets_around_edge<Eigen::Matrix<ExactScalar,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,1,0,-1,1>>(const
Eigen::PlainObjectBase<Eigen::Matrix<ExactScalar,-1,-1,0,-1,-1>> &,const
Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1>> &,size_t,size_t,const
std::vector<int,std::allocator<_Ty>> &,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1>> &,bool)' being
compiled
        with
        [
            _Ty=int
        ]
c:\dev\libigl\include\igl\copyleft\cgal\extract_cells.cpp(129): note: see reference to function template
instantiation 'size_t
igl::copyleft::cgal::extract_cells_single_component<Eigen::Matrix<ExactScalar,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,-1,0,-1,-1>,Eigen::Matrix<int,-1,1,0,-1,1>,Eigen::Matrix<int,-1,-1,0,-1,-1>,size_t,Eigen::Matrix<int,-1,1,0,-1,1>,Eigen::Matrix<int,-1,-1,0,-1,-1>>(const
Eigen::PlainObjectBase<Eigen::Matrix<ExactScalar,-1,-1,0,-1,-1>> &,const
Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1>> &,const
Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1>> &,const
Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1>> &,const
std::vector<std::vector<size_t,std::allocator<_Ty>>,std::allocator<std::vector<_Ty,std::allocator<_Ty>>>>
&,const Eigen::PlainObjectBase<Eigen::Matrix<int,-1,1,0,-1,1>>
&,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1>> &)' being compiled
        with
        [
            _Ty=size_t
        ]

Full mex log:
mesh_boolean_error.txt

Many thanks in advance

Mesh parameterization in gptoolbox

From personal email...

Hey, I am now an undergraduate student majoring in mathematics, and my thesis is about mesh parameterization. I found your project on github and it is really helpful! But I have some questions about the gptoolbox which I cannot find the answer on both README.md and the documents, I sincerely hope that you can help me with that.

In the lscm.m, you said:
% first need to convert each triangle to its orthonormal basis, if coming from 3D
assert(dim == 2);
But I have no idea how to convert an 3D mesh(V,F) into a 2D mesh, how to convert an n_3 matrix V into an n_2 matrix? Which function should I use to implement that?

Another question is about the boundary_conditions.m

% Compute boundary and boundary conditions for solving for correspondences
%weights over a set of mesh (V,F) with control points C(p,:) and control
% bones C(E(:,1),:) --> C(E(:,2),:) 

What principle should I obey when I am selecting the control points?

Ordered boundaries in matlab

I am not sure when they added these, but it's quite neat!
(these: graph and dfsearch)
ordered_boundary

clc; clear; close all;
load myoutline.mat M;
V = M.vertices;
F = M.faces;
B = mesh_boundary(F);

%--- Order
nv = max(B(:));
is = B(:,1);
js = B(:,2);
vs = ones(size(is,1),1);
A = sparse(is,js,vs,nv,nv);
A = A+A'; %< undirected
G = graph(A);
O = dfsearch(G,B(1,1));

point2 = @(P,varargin) plot(P(:,1), P(:,2), varargin{:});
figure(2); patch(M,'facecolor','none'); axis equal; hold on;
xlim([-0.5 +1.5]); axis off; set(gcf,'color','white');
for i=1:size(O,1)
    point2(V(O(i),:), '.r', 'markersize',10);
    gif_add_frame(gca,'ordered_boundary.gif');
end

mex doesn't support custom boost versions

Hi Alec:

I'm trying to use this code to preprocess some meshes from the Thingi10k database.

I tried to compile the gptoolbox code on ubuntu 16.04 by running gptoolbox/mex/compile_gptoolbox_mex.m, with the following methods:

'ambient_occlusion', ...
'bone_visible', ...
'bone_visible_embree', ...
'collapse_small_triangles', ...
'decimate_cgal', ...
'fit_rotations_mex', ...
'in_element_aabb', ...
'decimate_libigl', ...
'ray_mesh_intersect', ...
'reorient_facets', ...
'segment_graph', ...
'signed_distance', ...
'simplify_polyhedron', ...
'slim', ...
'solid_angle', ...
'winding_number', ...
'intersect_other', ...
'point_mesh_squared_distance', ...
'read_mesh_from_xml', ...
'selfintersect', ...
'signed_distance_isosurface', ...
'trim_with_solid', ...

and specifying libboost version 1.65, mex refuses to use my version of downloaded boost and just used boost from /usr/lib/x86_64-linux-gnu/libboost_system.so.1.58.0.

In fact, in gptoolbox/mex/gptoolbox_mexopts.m, even if I passed in garbage value for variable BOOST_INC and BOOST_LIB, the code will still compile and link to version 1.58. Is there a way around this problem?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.