Skip to content

Commit

Permalink
Merge branch 'master' of github.com:mtao/mandoline
Browse files Browse the repository at this point in the history
  • Loading branch information
mtao committed Nov 24, 2019
2 parents 40f3475 + d091d72 commit 62414cf
Show file tree
Hide file tree
Showing 43 changed files with 840 additions and 140 deletions.
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(MTAO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/extern/core" CACHE STRING "location of mtao core libs" )
SET(LIBIGL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/extern/libigl" CACHE STRING "location of libigl libs" )
OPTION(USE_OPENGL "Build opengl stuff" ON)
OPTION(USE_OPENMP "Use OpenMP stuff" ON)
IF(APPLE)
SET(USE_OPENMP_PRE OFF)
ELSE(APPLE)
SET(USE_OPENMP_PRE ON)
ENDIF(APPLE)
OPTION(USE_OPENMP "Use OpenMP stuff" ${USE_OPENMP_PRE})
OPTION(HANDLE_SELF_INTERSECTIONS "Handle Self-Intersections" ON)

MESSAGE(STATUS "MTAO Path: ${MTAO_PATH}")
Expand Down Expand Up @@ -55,6 +60,7 @@ option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF)
option(LIBIGL_WITH_PREDICATES "Use exact predicates" OFF)
option(LIBIGL_WITH_XML "Use XML" OFF)
option(LIBIGL_WITH_PYTHOFF "Use Python" OFF)
option(LIBIGL_SKIP_DOWNLOAD "Skip downloading external libraries" ON)
ADD_SUBDIRECTORY("${LIBIGL_PATH}" ${CMAKE_BINARY_DIR}/libigl EXCLUDE_FROM_ALL)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
Expand Down
56 changes: 53 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
# Mandoline
[![CircleCI](https://circleci.com/gh/mtao/mandoline/tree/master.svg?style=svg)](https://circleci.com/gh/mtao/mandoline/tree/master)

A robust cut-cell mesh generator for arbitrary triangle-mesh inputs

## Dependencies
In order to simplify the process of installing Mandoline scripts ```build-utils/setup_ubuntu.sh''' and ```build-utils/setup_osx.sh''' are provided.

Also, note that the scripts install a number of packages through apt/brew respectively, including version 2019.10 of
[Magnum](https://github.com/mosra/magnum),[Corrade](https://github.com/mosra/corrade), and [Magnum Integration](https://github.com/mosra/magnum-integration).
All this effort for Magnum is built around enabling [imgui](https://github.com/ocornut/imgui) support within Magnum.

If you're using a different system hopefully these the ```build-utils``` will still be useful.

### Compilation
Mandoline depends on a C++17 enabled compiler
- [gcc](https://gcc.gnu.org) with version >= 8.2.0 should work.
Mandoline depends on a C++17 enabled compiler
- [gcc](https://gcc.gnu.org) with version >= 8.2.0 or [clang](https://clang.llvm.org) with version >= 8 should work.
- [cmake](https://cmake.org) with version >= 3.10.1 .
```bash
apt install git cmake build-essential gcc
```

as well as a few other annoying things:

### Built-in Libraries
Mandoline depends on Michael Tao's messy ``[core](https://github.com/mtao/core)'' library, [libigl](https://github.com/libigl/libigl).
Expand All @@ -20,13 +34,49 @@ git submodule update --init --recursive
- A relatively new verison of [Eigen3](https://eigen.tuxfamily.org) is required (3.3.7 or the development branch?). The version provided by libigl will not suffice.
- [Boost](https://boost.org) is required for threads.
- [Google Protobuf](https://developers.google.com/protocol-buffers/) is required for the default cutmesh serialization format.
- [Eigen](https://eigen.tuxfamily.org) is required for almost every bit of linear algebra. With visualization it currently needs the dev branch (requires [mercurial](https://www.mercurial-scm.org) and check ```build-utils/setup_ubuntu.sh``` for more details on how to build)

```bash
apt install libboost-thread-dev libeigen3-dev protobuf-compiler
```



In order to handle self-intersections Mandoline requires, on top of libigl,
- [CGAL](https://www.cgal.org)
- [gmp](https://gmplib.org)
- [mpfr](https://www.mpfr.org).

```bash
apt install libboost-thread-dev libmpfr-dev libmpfrc++-dev libcgal-dev
libmpfr-dev libmpfrc++-dev libcgal-dev
```

### Optional Libraries
- [OpenMP](https://www.openmp.org) is a really good idea.
- [Magnum](https://github.com/mosra) and [Corrade](https://github.com/mosra/corrade) for visualization.
- [Magnum](https://github.com/mosra/magnum) and [Corrade](https://github.com/mosra/corrade) (version >= 2019.10) for visualization.
If Magnum and Corrade are available, targets that depend on visualization can be enabled by ```-DUSE_OPENGL ON``` when running cmake.
Installing Magnum and Corrade can be a pain, as I use the imgui plugin and default installations dont have that available. If you want to use it you might want to use the following script with MANDOLINE_DIR with the directory mandoline is stored in:

```bash
apt install debhelper libgl-dev libopenal-dev libglfw3-dev libsdl2-dev libbullet-dev libglm-dev

mkdir mosra; pushd mosra;
for repo in corrade magnum magnum-integration;
do git clone https://github.com/mosra/$repo; done

pushd magnum-integration;
pwd
sed "s|IMDIR|${IMGUI_DIR}|g" ${MANDOLINE_DIR}/build-utils/magnum_integration.patch > magnum_integration_imgui.patch
patch -b ./package/debian/rules magnum_integration_imgui.patch
popd #magnum integration

for repo in corrade magnum magnum-integration;
do pushd $repo;
ln -s package/debian .
# ignoring the dsc errors taht happen from magnum
dpkg-buildpackage || true
popd
done
popd
```
3 changes: 3 additions & 0 deletions build-utils/fetch_dependencies_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

brew install eigen mpfr cgal cmake boost protobuf libomp mercurial
4 changes: 4 additions & 0 deletions build-utils/fetch_dependencies_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash

sudo apt install -y git cmake libboost-thread-dev libmpfr-dev libmpfrc++-dev libcgal-dev libeigen3-dev protobuf-compiler mercurial debhelper libgl-dev libopenal-dev libglfw3-dev libsdl2-dev libbullet-dev libglm-dev

41 changes: 0 additions & 41 deletions build-utils/fetch_dependncies_ubuntu.sh

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
+ -DWITH_DART=OFF \
+ -DWITH_GLM=ON \
+ -DWITH_IMGUI=ON \
+ -DIMGUI_DIR=../../extern/core/extern/imgui
+ -DIMGUI_DIR=IMDIR
+
13 changes: 13 additions & 0 deletions build-utils/magnum_integration_homebrew.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/package/homebrew/magnum-integration.rb b/package/homebrew/magnum-integration.rb
index f49f5a0..0f7ca18 100644
--- a/package/homebrew/magnum-integration.rb
+++ b/package/homebrew/magnum-integration.rb
@@ -16,7 +16,7 @@ class MagnumIntegration < Formula
def install
system "mkdir build"
cd "build" do
- system "cmake", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_INSTALL_PREFIX=#{prefix}", "-DWITH_BULLET=ON", "-DWITH_DART=ON", "-DWITH_EIGEN=ON", "-DWITH_GLM=ON", "-DWITH_IMGUI=OFF", ".."
+ system "cmake", "-DCMAKE_BUILD_TYPE=Release", "-DCMAKE_INSTALL_PREFIX=#{prefix}", "-DWITH_BULLET=ON", "-DWITH_DART=ON", "-DWITH_EIGEN=ON", "-DWITH_GLM=ON", "-DWITH_IMGUI=ON", "-DIMGUI_DIR=IMDIR", ".."
system "cmake", "--build", "."
system "cmake", "--build", ".", "--target", "install"
end
14 changes: 14 additions & 0 deletions build-utils/magnum_setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

TMPDIR="$1"


mkdir -p ${TMPDIR}/mosra; pushd ${TMPDIR}/mosra;
for repo in corrade magnum magnum-integration;
do git clone https://github.com/mosra/$repo;
pushd $repo
git checkout tags/v2019.10
popd
done

popd #mosra
24 changes: 24 additions & 0 deletions build-utils/magnum_setup_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# http://stackoverflow.com/questions/3572030/bash-script-absolute-path-with-os-x
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

TMPDIR="$1"
IMGUI_DIR=$( realpath "$2" )
SCRIPT_DIR=$( realpath "$3" )
echo "SCRIPT DIR: ${SCRIPT_DIR}"
echo "TMPDIR DIR: ${SCRIPT_DIR}"
pushd "$TMPDIR/mosra"
pushd magnum-integration;

sed "s|IMDIR|${IMGUI_DIR}|g" ${SCRIPT_DIR}/magnum_integration_homebrew.patch > magnum_integration_imgui.patch
patch -b ./package/homebrew/magnum-integration magnum_integration_imgui.patch
popd #magnum integration

for repo in corrade magnum magnum-integration;
do pushd $repo;
brew install package/homebrew/${repo}.rb
popd
done
popd
24 changes: 24 additions & 0 deletions build-utils/magnum_setup_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
realpath() {
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

TMPDIR="$1"
IMGUI_DIR=$( realpath "$2" )
SCRIPT_DIR=$( realpath "$3" )
pushd "${TMPDIR}/mosra"
pushd magnum-integration;

sed "s|IMDIR|${IMGUI_DIR}|g" ${SCRIPT_DIR}/magnum_integration_deb.patch > magnum_integration_imgui.patch
patch -b ./package/debian/rules magnum_integration_imgui.patch
popd #magnum integration

for repo in corrade magnum magnum-integration;
do pushd $repo;
ln -s package/debian .
# ignoring the dsc errors taht happen from magnum
dpkg-buildpackage || true
popd
dpkg -i ${repo}*.deb
done
popd
28 changes: 28 additions & 0 deletions build-utils/setup_osx.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#/bin/bash

git submodule update --recursive --init

#https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

MANDOLINE_DIR="${SCRIPT_DIR}/../"
IMGUI_DIR="${MANDOLINE_DIR}/extern/core/extern/imgui"

CUR_DIR="$(pwd)"
BUILD_DIR="${MANDOLINE_DIR}/build"

mkdir -p "${BUILD_DIR}"

bash ${SCRIPT_DIR}/fetch_dependencies_osx.sh

bash ${SCRIPT_DIR}/magnum_setup.sh "${SCRIPT_DIR}" "${SCRIPT_DIR}"
bash ${SCRIPT_DIR}/magnum_setup_osx.sh "${SCRIPT_DIR}" "${IMGUI_DIR}" "${SCRIPT_DIR}"

pushd ${MANDOLINE_DIR}/extern
hg clone http://bitbucket.org/eigen/eigen
popd

pushd "${BUILD_DIR}"
cmake .. -DCMAKE_BUILD_TYPE=Release -DMTAO_CUSTOM_EIGEN_PATH=${MANDOLINE_DIR}/extern/eigen
make -j$( nproc ) make_cutmesh_gui exploded_mesh
popd
28 changes: 28 additions & 0 deletions build-utils/setup_ubuntu.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#/bin/bash

git submodule update --recursive --init

#https://stackoverflow.com/questions/59895/get-the-source-directory-of-a-bash-script-from-within-the-script-itself
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

MANDOLINE_DIR="${SCRIPT_DIR}/../"
IMGUI_DIR="${MANDOLINE_DIR}/extern/core/extern/imgui"

CUR_DIR="$(pwd)"
BUILD_DIR="${MANDOLINE_DIR}/build"

mkdir -p "${BUILD_DIR}"

bash ${SCRIPT_DIR}/fetch_dependencies_ubuntu.sh

bash ${SCRIPT_DIR}/magnum_setup.sh "${SCRIPT_DIR}" "${SCRIPT_DIR}"
sudo bash ${SCRIPT_DIR}/magnum_setup_ubuntu.sh "${SCRIPT_DIR}" "${IMGUI_DIR}" "${SCRIPT_DIR}"

pushd ${MANDOLINE_DIR}/extern
hg clone http://bitbucket.org/eigen/eigen
popd

pushd "${BUILD_DIR}"
cmake .. -DCMAKE_BUILD_TYPE=Release -DMTAO_CUSTOM_EIGEN_PATH=${MANDOLINE_DIR}/extern/eigen
make -j$( nproc ) make_cutmesh_gui exploded_mesh
popd
1 change: 1 addition & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ IF(${USE_OPENGL})
ADD_SUBDIRECTORY(viewer)
ADD_SUBDIRECTORY(slicer)
ADD_SUBDIRECTORY(exploded_mesh)
ADD_SUBDIRECTORY(point_chaser)
ENDIF(${USE_OPENGL})
ADD_SUBDIRECTORY(laplacian)
3 changes: 2 additions & 1 deletion examples/exploded_mesh/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
ADD_EXECUTABLE(exploded_mesh main.cpp)
find_package(Magnum REQUIRED GL Shaders GlxContext GlfwApplication SceneGraph MeshTools)
find_package(Magnum REQUIRED GL Shaders GlxContext GlfwApplication SceneGraph
MeshTools Trade)
find_package(MagnumIntegration REQUIRED ImGui)
TARGET_LINK_LIBRARIES(exploded_mesh mandoline mtao::visualization)
Loading

0 comments on commit 62414cf

Please sign in to comment.