mirror of
https://github.com/lucaspalomodevelop/meshlab.git
synced 2026-03-20 11:26:11 +00:00
remove libigl source and download it using cmake
This commit is contained in:
parent
2d555e7744
commit
0a1b5c25eb
12
.gitignore
vendored
12
.gitignore
vendored
@ -17,14 +17,20 @@
|
||||
*.db-wal
|
||||
*.AppImage
|
||||
.DS_Store
|
||||
|
||||
# build and install directories
|
||||
build/*
|
||||
install/*
|
||||
src/external/boost_1_75_0
|
||||
src/external/CGAL-5.2.1
|
||||
|
||||
# external libraries automatically downloaded by cmake
|
||||
src/external/boost*
|
||||
src/external/CGAL*
|
||||
src/external/libigl*
|
||||
|
||||
# files created/modified during deploy stage
|
||||
install/macos/resources/meshlab_dmg_final.json
|
||||
install/windows/resources/meshlab_final.nsi
|
||||
install/windows/resources/MeshLab*.exe
|
||||
src/common/generated_version_header.h
|
||||
|
||||
##Standard cmake gitignore##
|
||||
CMakeLists.txt.user
|
||||
|
||||
@ -1,18 +0,0 @@
|
||||
---
|
||||
name: 🐛 Bug Report
|
||||
about: If something isn't working as expected
|
||||
title: ''
|
||||
labels: bug, pending verification
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Describe the bug
|
||||
<!-- A clear and concise description of what the bug is. -->
|
||||
|
||||
#### Platform
|
||||
<!-- Check all that apply (change to `[x]`) -->
|
||||
|
||||
- [ ] Windows
|
||||
- [ ] macOS
|
||||
- [ ] Linux
|
||||
@ -1,25 +0,0 @@
|
||||
---
|
||||
name: 😱 Compilation issue
|
||||
about: Report a problem when compiling the code
|
||||
title: ''
|
||||
labels: 'compilation'
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
#### Describe your issue
|
||||
<!-- Be sure to include any log file that may help use diagnose the issue -->
|
||||
|
||||
|
||||
#### Checklist
|
||||
<!-- Check all that apply (change to `[x]`) -->
|
||||
|
||||
- [ ] I have read the [bug report](https://libigl.github.io/bug-report/)
|
||||
- [ ] CMake issue: I have tried with a fresh clone/empty build directory
|
||||
|
||||
#### Platform
|
||||
<!-- Check all that apply (change to `[x]`) -->
|
||||
|
||||
- [ ] Windows
|
||||
- [ ] macOS
|
||||
- [ ] Linux
|
||||
@ -1,8 +0,0 @@
|
||||
blank_issues_enabled: false
|
||||
contact_links:
|
||||
- name: 🚀 Feature Request
|
||||
url: https://github.com/libigl/libigl/discussions/new?category_id=32617689
|
||||
about: Share ideas for new features
|
||||
- name: ❓ Ask a Question
|
||||
url: https://github.com/libigl/libigl/discussions/new?category_id=32617688
|
||||
about: Ask the community for help
|
||||
@ -1,12 +0,0 @@
|
||||
Fixes # .
|
||||
|
||||
<!-- Describe your changes and what you've already done to test it. -->
|
||||
|
||||
|
||||
#### Checklist
|
||||
<!-- Check all that apply (change to `[x]`) -->
|
||||
|
||||
- [ ] All changes meet [libigl style-guidelines](https://libigl.github.io/style-guidelines/).
|
||||
- [ ] Adds new .cpp file.
|
||||
- [ ] Adds corresponding unit test.
|
||||
- [ ] This is a minor change.
|
||||
@ -1,153 +0,0 @@
|
||||
name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- stable
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
- stable
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: ON
|
||||
CTEST_PARALLEL_LEVEL: 2
|
||||
|
||||
jobs:
|
||||
####################
|
||||
# Linux / macOS
|
||||
####################
|
||||
|
||||
Unix:
|
||||
name: ${{ matrix.name }} (${{ matrix.config }}, ${{ fromJSON('["Static", "HeaderOnly"]')[matrix.static == 'ON'] }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-20.04, macos-latest]
|
||||
config: [Release]
|
||||
static: [ON, OFF]
|
||||
include:
|
||||
- os: macos-latest
|
||||
name: macOS
|
||||
- os: ubuntu-20.04
|
||||
name: Linux
|
||||
env:
|
||||
LIBIGL_NUM_THREADS: 1 # See https://github.com/libigl/libigl/pull/996
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 10
|
||||
|
||||
- name: Dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install \
|
||||
libblas-dev \
|
||||
libboost-filesystem-dev \
|
||||
libboost-system-dev \
|
||||
libboost-thread-dev \
|
||||
libglu1-mesa-dev \
|
||||
liblapack-dev \
|
||||
libmpfr-dev \
|
||||
xorg-dev \
|
||||
ccache
|
||||
|
||||
- name: Dependencies (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install boost gmp mpfr ccache
|
||||
|
||||
- name: Cache Build
|
||||
id: cache-build
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.static }}-cache
|
||||
|
||||
- name: Prepare ccache
|
||||
run: |
|
||||
ccache --max-size=1.0G
|
||||
ccache -V && ccache --show-stats && ccache --zero-stats
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
|
||||
-DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} \
|
||||
-DLIBIGL_WITH_CGAL=ON \
|
||||
-DLIBIGL_WITH_COMISO=ON
|
||||
|
||||
- name: Build
|
||||
run: cd build; make -j2; ccache --show-stats
|
||||
|
||||
- name: Tests
|
||||
run: cd build; ctest --verbose
|
||||
|
||||
####################
|
||||
# Windows
|
||||
####################
|
||||
|
||||
Windows:
|
||||
name: Windows (${{ matrix.config }}, ${{ fromJSON('["Static", "HeaderOnly"]')[matrix.static == 'ON'] }})
|
||||
runs-on: windows-2019
|
||||
env:
|
||||
CC: cl.exe
|
||||
CXX: cl.exe
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config: [Release]
|
||||
static: [ON, OFF]
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 10
|
||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
- name: Set env
|
||||
run: |
|
||||
echo "BOOST_ROOT=$env:BOOST_ROOT_1_72_0" >> ${env:GITHUB_ENV}
|
||||
echo "appdata=$env:LOCALAPPDATA" >> ${env:GITHUB_ENV}
|
||||
|
||||
- name: Cache build
|
||||
id: cache-build
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ env.appdata }}\Mozilla\sccache
|
||||
key: ${{ runner.os }}-${{ matrix.config }}-${{ matrix.static }}-cache
|
||||
|
||||
- name: Prepare sccache
|
||||
run: |
|
||||
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
|
||||
scoop install sccache --global
|
||||
# Scoop modifies the PATH so we make it available for the next steps of the job
|
||||
echo "${env:PATH}" >> ${env:GITHUB_PATH}
|
||||
|
||||
# We run configure + build in the same step, since they both need to call VsDevCmd
|
||||
# Also, cmd uses ^ to break commands into multiple lines (in powershell this is `)
|
||||
- name: Configure and build
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
|
||||
cmake -G Ninja ^
|
||||
-DCMAKE_CXX_COMPILER_LAUNCHER=sccache ^
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
|
||||
-DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} ^
|
||||
-DLIBIGL_WITH_CGAL=ON ^
|
||||
-DLIBIGL_WITH_COMISO=OFF ^
|
||||
-DCMAKE_JOB_POOLS=pool-linking=1;pool-compilation=2 ^
|
||||
-DCMAKE_JOB_POOL_COMPILE:STRING=pool-compilation ^
|
||||
-DCMAKE_JOB_POOL_LINK:STRING=pool-linking ^
|
||||
-B build ^
|
||||
-S .
|
||||
cmake --build build
|
||||
|
||||
- name: Tests
|
||||
run: cd build; ctest --verbose
|
||||
@ -1,190 +0,0 @@
|
||||
name: Nightly
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 4 * * *'
|
||||
|
||||
env:
|
||||
CTEST_OUTPUT_ON_FAILURE: ON
|
||||
CTEST_PARALLEL_LEVEL: 2
|
||||
|
||||
jobs:
|
||||
####################
|
||||
# Linux / macOS
|
||||
####################
|
||||
|
||||
# Part of this file is inspired from
|
||||
# https://github.com/onqtam/doctest/blob/dev/.github/workflows/main.yml
|
||||
|
||||
Unix:
|
||||
name: ${{ matrix.name }} (${{ matrix.config }}, ${{ fromJSON('["Static", "HeaderOnly"]')[matrix.static == 'ON'] }})
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
name: [
|
||||
ubuntu-20.04-gcc-8,
|
||||
ubuntu-20.04-gcc-9,
|
||||
ubuntu-20.04-gcc-10,
|
||||
ubuntu-20.04-clang-8,
|
||||
ubuntu-20.04-clang-9,
|
||||
ubuntu-20.04-clang-10,
|
||||
macOS-latest,
|
||||
]
|
||||
config: [Debug, Release]
|
||||
static: [ON, OFF]
|
||||
include:
|
||||
- name: ubuntu-20.04-gcc-8
|
||||
os: ubuntu-20.04
|
||||
compiler: gcc
|
||||
version: "8"
|
||||
|
||||
- name: ubuntu-20.04-gcc-9
|
||||
os: ubuntu-20.04
|
||||
compiler: gcc
|
||||
version: "9"
|
||||
|
||||
- name: ubuntu-20.04-gcc-10
|
||||
os: ubuntu-20.04
|
||||
compiler: gcc
|
||||
version: "10"
|
||||
|
||||
- name: ubuntu-20.04-clang-8
|
||||
os: ubuntu-20.04
|
||||
compiler: clang
|
||||
version: "8"
|
||||
|
||||
- name: ubuntu-20.04-clang-9
|
||||
os: ubuntu-20.04
|
||||
compiler: clang
|
||||
version: "9"
|
||||
|
||||
- name: ubuntu-20.04-clang-10
|
||||
os: ubuntu-20.04
|
||||
compiler: clang
|
||||
version: "10"
|
||||
|
||||
- name: macOS-latest
|
||||
os: macOS-latest
|
||||
|
||||
# Build tutorials for most configurations
|
||||
- tutorials: ON
|
||||
|
||||
# Except with Debug mode
|
||||
- config: Debug
|
||||
tutorials: OFF
|
||||
env:
|
||||
LIBIGL_NUM_THREADS: 1 # See https://github.com/libigl/libigl/pull/996
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 10
|
||||
|
||||
- name: Dependencies (Linux)
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo apt-get update
|
||||
|
||||
if [ "${{ matrix.compiler }}" = "gcc" ]; then
|
||||
sudo apt-get install -y g++-${{ matrix.version }}
|
||||
echo "CC=gcc-${{ matrix.version }}" >> $GITHUB_ENV
|
||||
echo "CXX=g++-${{ matrix.version }}" >> $GITHUB_ENV
|
||||
else
|
||||
sudo apt-get install -y clang-${{ matrix.version }}
|
||||
echo "CC=clang-${{ matrix.version }}" >> $GITHUB_ENV
|
||||
echo "CXX=clang++-${{ matrix.version }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
sudo apt-get install \
|
||||
libblas-dev \
|
||||
libboost-filesystem-dev \
|
||||
libboost-system-dev \
|
||||
libboost-thread-dev \
|
||||
libglu1-mesa-dev \
|
||||
liblapack-dev \
|
||||
libmpfr-dev \
|
||||
xorg-dev
|
||||
|
||||
- name: Dependencies (macOS)
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install boost gmp mpfr
|
||||
|
||||
- name: Configure
|
||||
run: |
|
||||
mkdir -p build
|
||||
cd build
|
||||
cmake .. \
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.config }} \
|
||||
-DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} \
|
||||
-DLIBIGL_BUILD_TUTORIALS=${{ matrix.tutorials }} \
|
||||
-DLIBIGL_WITH_CGAL=ON \
|
||||
-DLIBIGL_WITH_COMISO=ON
|
||||
|
||||
- name: Free Disk Space
|
||||
if: runner.os == 'Linux'
|
||||
run: |
|
||||
sudo swapoff -a
|
||||
sudo apt clean
|
||||
sudo rm -rf /swapfile /usr/share/dotnet /usr/local/lib/android /opt/ghc
|
||||
df -h
|
||||
|
||||
- name: Build
|
||||
run: cd build; make -j1
|
||||
|
||||
- name: Tests
|
||||
run: cd build; ctest --verbose
|
||||
|
||||
####################
|
||||
# Windows
|
||||
####################
|
||||
|
||||
Windows:
|
||||
name: Windows (${{ matrix.config }}, ${{ fromJSON('["Static", "HeaderOnly"]')[matrix.static == 'ON'] }})
|
||||
runs-on: windows-2019
|
||||
env:
|
||||
CC: cl.exe
|
||||
CXX: cl.exe
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
config: [Debug, Release]
|
||||
static: [ON, OFF]
|
||||
include:
|
||||
- config: Debug
|
||||
tutorials: OFF
|
||||
- config: Release
|
||||
tutorials: ON
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v1
|
||||
with:
|
||||
fetch-depth: 10
|
||||
- uses: seanmiddleditch/gha-setup-ninja@master
|
||||
|
||||
- name: Set env
|
||||
run: |
|
||||
echo "BOOST_ROOT=$env:BOOST_ROOT_1_72_0" >> ${env:GITHUB_ENV}
|
||||
|
||||
# We run configure + build in the same step, since they both need to call VsDevCmd
|
||||
# Also, cmd uses ^ to break commands into multiple lines (in powershell this is `)
|
||||
- name: Configure and build
|
||||
shell: cmd
|
||||
run: |
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\Tools\VsDevCmd.bat" -arch=x64
|
||||
cmake -G Ninja ^
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.config }} ^
|
||||
-DLIBIGL_USE_STATIC_LIBRARY=${{ matrix.static }} ^
|
||||
-DLIBIGL_BUILD_TUTORIALS=${{ matrix.tutorials }} ^
|
||||
-DLIBIGL_WITH_CGAL=ON ^
|
||||
-DLIBIGL_WITH_COMISO=OFF ^
|
||||
-DCMAKE_JOB_POOLS=job-pool=1 ^
|
||||
-DCMAKE_JOB_POOL_COMPILE:STRING=job-pool ^
|
||||
-DCMAKE_JOB_POOL_LINK:STRING=job-pool ^
|
||||
-B build ^
|
||||
-S .
|
||||
cd build
|
||||
ninja -j 1 -k 10
|
||||
|
||||
- name: Tests
|
||||
run: cd build; ctest --verbose
|
||||
100
src/external/libigl-2.3.0/.gitignore
vendored
100
src/external/libigl-2.3.0/.gitignore
vendored
@ -1,100 +0,0 @@
|
||||
# use glob syntax.
|
||||
*.a
|
||||
*.dylib
|
||||
*.egg-info/
|
||||
*.exe
|
||||
*.ilk
|
||||
*.log
|
||||
*.o
|
||||
*.opensdf
|
||||
*.orig
|
||||
*.pdb
|
||||
*.psess
|
||||
*.pyc
|
||||
*.sdf
|
||||
*.so
|
||||
*.so.[0123456789]
|
||||
*.so.[0123456789].[0123456789]
|
||||
*.suo
|
||||
*.swo
|
||||
*.swp
|
||||
*.tlog
|
||||
*.user
|
||||
*.vsp
|
||||
*CMakeFiles*
|
||||
*buildXcode*
|
||||
*tags
|
||||
*~
|
||||
.DS_Store
|
||||
.idea/
|
||||
.vs/
|
||||
.vscode/
|
||||
/external
|
||||
Debug/
|
||||
README.html
|
||||
Release/
|
||||
Untitled.ipynb
|
||||
build
|
||||
doc.html
|
||||
documentation/*.aux
|
||||
documentation/*.log
|
||||
documentation/*.out
|
||||
example
|
||||
example1
|
||||
example_header_only
|
||||
example_static
|
||||
examples/*/*.mexmaci64
|
||||
examples/*/*.rbr
|
||||
examples/bbw/bbw_demo
|
||||
examples/bbw/bbw_demo_selfcontained.zip
|
||||
examples/bbw/bbw_demo_selfcontained/*
|
||||
examples/bbw/examples/*-volume.dmat
|
||||
examples/bbw/examples/*-volume.mesh
|
||||
examples/principal_curvature/curvature
|
||||
examples/quicklook-mesh/Mesh.qlgenerator/*
|
||||
examples/upright/upright
|
||||
external/MeshFix/meshfix
|
||||
external/embree/build/*
|
||||
external/glew/build
|
||||
external/glfw/build
|
||||
external/libpng/build
|
||||
external/medit/rebar.rbr
|
||||
external/tetgen/tetgen
|
||||
external/tinyxml2/build
|
||||
external/tinyxml2/test
|
||||
external/tinyxml2/tinyxml2.pc
|
||||
external/yimg/showpng
|
||||
iglhelpers.pyc
|
||||
lib
|
||||
libigl.zip
|
||||
optional/build
|
||||
python/.idea
|
||||
python/.ipynb_checkpoints
|
||||
python/__pycache__
|
||||
python/build
|
||||
python/build2
|
||||
python/build3
|
||||
python/build4
|
||||
python/builddebug
|
||||
python/buildstatic
|
||||
python/py_igl/todo
|
||||
python/py_igl/todo
|
||||
python/scripts/generated
|
||||
scripts/change_name.sh
|
||||
site/
|
||||
syntax: glob
|
||||
tests/bin
|
||||
tests/build
|
||||
tests/data
|
||||
tutorial/*/*.mexmaci64
|
||||
tutorial/*/Makefile
|
||||
tutorial/*/build/*
|
||||
tutorial/.idea
|
||||
tutorial/XXX_test/CMakeLists.txt
|
||||
tutorial/XXX_test/main.cpp
|
||||
tutorial/build
|
||||
tutorial/cmake-build-debug
|
||||
tutorial/data
|
||||
tutorial/readme.html
|
||||
untitled
|
||||
scripts
|
||||
19
src/external/libigl-2.3.0/.mailmap
vendored
19
src/external/libigl-2.3.0/.mailmap
vendored
@ -1,19 +0,0 @@
|
||||
#
|
||||
# This list is used by git-shortlog to fix a few botched name translations
|
||||
# in the libigl archive, either because the author's full name was messed up
|
||||
# and/or not always written the same way, making contributions from the
|
||||
# same person appearing not to be so.
|
||||
#
|
||||
Alec Jacobson <alecjacobson@gmail.com> Alec Jacobson (jalec <Alec Jacobson (jalec@inf.ethz.ch)>
|
||||
Alec Jacobson <alecjacobson@gmail.com> jalec <devnull@localhost>
|
||||
Alec Jacobson <alecjacobson@gmail.com> Alec Jacobson <ajx@Luftmatratze.local>
|
||||
Alec Jacobson <alecjacobson@gmail.com> ajx <devnull@localhost>
|
||||
Alec Jacobson <alecjacobson@gmail.com> mangledorf <alecjacobson@gmail.com>
|
||||
Daniele Panozzo <panozzo@inf.ethz.ch> Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
Daniele Panozzo <panozzo@inf.ethz.ch> dpanozzo <devnull@localhost>
|
||||
Wenzel Jakob <wenzel@inf.ethz.ch> Wenzel Jakob <wenzel@cs.cornell.edu>
|
||||
Olga Diamanti <olga.diamanti@inf.ethz.ch> dolga <devnull@localhost>
|
||||
schuellc <schuellchr@gmail.com> schuellc <devnull@localhost>
|
||||
Kenshi Takayama <kenshi84@gmail.com> Kenshi Takayama (kenshi <Kenshi Takayama (kenshi@gmail.com)>
|
||||
Kenshi Takayama <kenshi84@gmail.com> kenshi <kenshi@jackal.ethz.ch>
|
||||
Kenshi Takayama <kenshi84@gmail.com> kenshi84 <kenshi84@gmail.com>
|
||||
74
src/external/libigl-2.3.0/CMakeLists.txt
vendored
74
src/external/libigl-2.3.0/CMakeLists.txt
vendored
@ -1,74 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
# Toggles the use of the hunter package manager
|
||||
option(HUNTER_ENABLED "Enable Hunter package manager support" OFF)
|
||||
|
||||
include("cmake/HunterGate.cmake")
|
||||
HunterGate(
|
||||
URL "https://github.com/ruslo/hunter/archive/v0.23.171.tar.gz"
|
||||
SHA1 "5d68bcca78eee347239ca5f4d34f4b6c12683154"
|
||||
)
|
||||
|
||||
project(libigl)
|
||||
|
||||
# Detects whether this is a top-level project
|
||||
get_directory_property(LIBIGL_PARENT_DIR PARENT_DIRECTORY)
|
||||
if(NOT LIBIGL_PARENT_DIR)
|
||||
set(LIBIGL_TOPLEVEL_PROJECT ON)
|
||||
else()
|
||||
set(LIBIGL_TOPLEVEL_PROJECT OFF)
|
||||
endif()
|
||||
|
||||
# Build tests and tutorials
|
||||
option(LIBIGL_BUILD_TESTS "Build libigl unit test" ${LIBIGL_TOPLEVEL_PROJECT})
|
||||
option(LIBIGL_BUILD_TUTORIALS "Build libigl tutorial" ${LIBIGL_TOPLEVEL_PROJECT})
|
||||
option(LIBIGL_EXPORT_TARGETS "Export libigl CMake targets" ${LIBIGL_TOPLEVEL_PROJECT})
|
||||
|
||||
# USE_STATIC_LIBRARY speeds up the generation of multiple binaries,
|
||||
# at the cost of a longer initial compilation time
|
||||
# (by default, static build is off since libigl is a header-only library)
|
||||
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" ON)
|
||||
|
||||
# All dependencies that are downloaded as cmake projects and tested on the auto-builds are ON
|
||||
# (by default, all build options are off)
|
||||
option(LIBIGL_WITH_COMISO "Use CoMiso" ON)
|
||||
option(LIBIGL_WITH_EMBREE "Use Embree" ON)
|
||||
option(LIBIGL_WITH_OPENGL "Use OpenGL" ON)
|
||||
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" ON)
|
||||
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" ON)
|
||||
option(LIBIGL_WITH_PNG "Use PNG" ON)
|
||||
option(LIBIGL_WITH_TETGEN "Use Tetgen" ON)
|
||||
option(LIBIGL_WITH_TRIANGLE "Use Triangle" ON)
|
||||
option(LIBIGL_WITH_PREDICATES "Use exact predicates" ON)
|
||||
option(LIBIGL_WITH_XML "Use XML" ON)
|
||||
option(LIBIGL_WITH_PYTHON "Use Python" OFF)
|
||||
### End
|
||||
|
||||
if(${LIBIGL_WITH_PYTHON})
|
||||
message(FATAL_ERROR "Python binding are in the process of being redone. Please use the master branch or refer to https://github.com/geometryprocessing/libigl-python-bindings for the developement version or https://anaconda.org/conda-forge/igl for the stable version.")
|
||||
endif()
|
||||
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
### conditionally compile certain modules depending on libraries found on the system
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
||||
|
||||
### Adding libIGL: choose the path to your local copy libIGL
|
||||
include(libigl)
|
||||
|
||||
if(LIBIGL_BUILD_TUTORIALS)
|
||||
add_subdirectory(tutorial)
|
||||
endif()
|
||||
|
||||
if(LIBIGL_BUILD_TESTS)
|
||||
include(CTest)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
endif()
|
||||
|
||||
if(LIBIGL_TOPLEVEL_PROJECT)
|
||||
# Set folders for Visual Studio/Xcode
|
||||
igl_set_folders()
|
||||
endif()
|
||||
674
src/external/libigl-2.3.0/LICENSE.GPL
vendored
674
src/external/libigl-2.3.0/LICENSE.GPL
vendored
@ -1,674 +0,0 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
373
src/external/libigl-2.3.0/LICENSE.MPL2
vendored
373
src/external/libigl-2.3.0/LICENSE.MPL2
vendored
@ -1,373 +0,0 @@
|
||||
Mozilla Public License Version 2.0
|
||||
==================================
|
||||
|
||||
1. Definitions
|
||||
--------------
|
||||
|
||||
1.1. "Contributor"
|
||||
means each individual or legal entity that creates, contributes to
|
||||
the creation of, or owns Covered Software.
|
||||
|
||||
1.2. "Contributor Version"
|
||||
means the combination of the Contributions of others (if any) used
|
||||
by a Contributor and that particular Contributor's Contribution.
|
||||
|
||||
1.3. "Contribution"
|
||||
means Covered Software of a particular Contributor.
|
||||
|
||||
1.4. "Covered Software"
|
||||
means Source Code Form to which the initial Contributor has attached
|
||||
the notice in Exhibit A, the Executable Form of such Source Code
|
||||
Form, and Modifications of such Source Code Form, in each case
|
||||
including portions thereof.
|
||||
|
||||
1.5. "Incompatible With Secondary Licenses"
|
||||
means
|
||||
|
||||
(a) that the initial Contributor has attached the notice described
|
||||
in Exhibit B to the Covered Software; or
|
||||
|
||||
(b) that the Covered Software was made available under the terms of
|
||||
version 1.1 or earlier of the License, but not also under the
|
||||
terms of a Secondary License.
|
||||
|
||||
1.6. "Executable Form"
|
||||
means any form of the work other than Source Code Form.
|
||||
|
||||
1.7. "Larger Work"
|
||||
means a work that combines Covered Software with other material, in
|
||||
a separate file or files, that is not Covered Software.
|
||||
|
||||
1.8. "License"
|
||||
means this document.
|
||||
|
||||
1.9. "Licensable"
|
||||
means having the right to grant, to the maximum extent possible,
|
||||
whether at the time of the initial grant or subsequently, any and
|
||||
all of the rights conveyed by this License.
|
||||
|
||||
1.10. "Modifications"
|
||||
means any of the following:
|
||||
|
||||
(a) any file in Source Code Form that results from an addition to,
|
||||
deletion from, or modification of the contents of Covered
|
||||
Software; or
|
||||
|
||||
(b) any new file in Source Code Form that contains any Covered
|
||||
Software.
|
||||
|
||||
1.11. "Patent Claims" of a Contributor
|
||||
means any patent claim(s), including without limitation, method,
|
||||
process, and apparatus claims, in any patent Licensable by such
|
||||
Contributor that would be infringed, but for the grant of the
|
||||
License, by the making, using, selling, offering for sale, having
|
||||
made, import, or transfer of either its Contributions or its
|
||||
Contributor Version.
|
||||
|
||||
1.12. "Secondary License"
|
||||
means either the GNU General Public License, Version 2.0, the GNU
|
||||
Lesser General Public License, Version 2.1, the GNU Affero General
|
||||
Public License, Version 3.0, or any later versions of those
|
||||
licenses.
|
||||
|
||||
1.13. "Source Code Form"
|
||||
means the form of the work preferred for making modifications.
|
||||
|
||||
1.14. "You" (or "Your")
|
||||
means an individual or a legal entity exercising rights under this
|
||||
License. For legal entities, "You" includes any entity that
|
||||
controls, is controlled by, or is under common control with You. For
|
||||
purposes of this definition, "control" means (a) the power, direct
|
||||
or indirect, to cause the direction or management of such entity,
|
||||
whether by contract or otherwise, or (b) ownership of more than
|
||||
fifty percent (50%) of the outstanding shares or beneficial
|
||||
ownership of such entity.
|
||||
|
||||
2. License Grants and Conditions
|
||||
--------------------------------
|
||||
|
||||
2.1. Grants
|
||||
|
||||
Each Contributor hereby grants You a world-wide, royalty-free,
|
||||
non-exclusive license:
|
||||
|
||||
(a) under intellectual property rights (other than patent or trademark)
|
||||
Licensable by such Contributor to use, reproduce, make available,
|
||||
modify, display, perform, distribute, and otherwise exploit its
|
||||
Contributions, either on an unmodified basis, with Modifications, or
|
||||
as part of a Larger Work; and
|
||||
|
||||
(b) under Patent Claims of such Contributor to make, use, sell, offer
|
||||
for sale, have made, import, and otherwise transfer either its
|
||||
Contributions or its Contributor Version.
|
||||
|
||||
2.2. Effective Date
|
||||
|
||||
The licenses granted in Section 2.1 with respect to any Contribution
|
||||
become effective for each Contribution on the date the Contributor first
|
||||
distributes such Contribution.
|
||||
|
||||
2.3. Limitations on Grant Scope
|
||||
|
||||
The licenses granted in this Section 2 are the only rights granted under
|
||||
this License. No additional rights or licenses will be implied from the
|
||||
distribution or licensing of Covered Software under this License.
|
||||
Notwithstanding Section 2.1(b) above, no patent license is granted by a
|
||||
Contributor:
|
||||
|
||||
(a) for any code that a Contributor has removed from Covered Software;
|
||||
or
|
||||
|
||||
(b) for infringements caused by: (i) Your and any other third party's
|
||||
modifications of Covered Software, or (ii) the combination of its
|
||||
Contributions with other software (except as part of its Contributor
|
||||
Version); or
|
||||
|
||||
(c) under Patent Claims infringed by Covered Software in the absence of
|
||||
its Contributions.
|
||||
|
||||
This License does not grant any rights in the trademarks, service marks,
|
||||
or logos of any Contributor (except as may be necessary to comply with
|
||||
the notice requirements in Section 3.4).
|
||||
|
||||
2.4. Subsequent Licenses
|
||||
|
||||
No Contributor makes additional grants as a result of Your choice to
|
||||
distribute the Covered Software under a subsequent version of this
|
||||
License (see Section 10.2) or under the terms of a Secondary License (if
|
||||
permitted under the terms of Section 3.3).
|
||||
|
||||
2.5. Representation
|
||||
|
||||
Each Contributor represents that the Contributor believes its
|
||||
Contributions are its original creation(s) or it has sufficient rights
|
||||
to grant the rights to its Contributions conveyed by this License.
|
||||
|
||||
2.6. Fair Use
|
||||
|
||||
This License is not intended to limit any rights You have under
|
||||
applicable copyright doctrines of fair use, fair dealing, or other
|
||||
equivalents.
|
||||
|
||||
2.7. Conditions
|
||||
|
||||
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
|
||||
in Section 2.1.
|
||||
|
||||
3. Responsibilities
|
||||
-------------------
|
||||
|
||||
3.1. Distribution of Source Form
|
||||
|
||||
All distribution of Covered Software in Source Code Form, including any
|
||||
Modifications that You create or to which You contribute, must be under
|
||||
the terms of this License. You must inform recipients that the Source
|
||||
Code Form of the Covered Software is governed by the terms of this
|
||||
License, and how they can obtain a copy of this License. You may not
|
||||
attempt to alter or restrict the recipients' rights in the Source Code
|
||||
Form.
|
||||
|
||||
3.2. Distribution of Executable Form
|
||||
|
||||
If You distribute Covered Software in Executable Form then:
|
||||
|
||||
(a) such Covered Software must also be made available in Source Code
|
||||
Form, as described in Section 3.1, and You must inform recipients of
|
||||
the Executable Form how they can obtain a copy of such Source Code
|
||||
Form by reasonable means in a timely manner, at a charge no more
|
||||
than the cost of distribution to the recipient; and
|
||||
|
||||
(b) You may distribute such Executable Form under the terms of this
|
||||
License, or sublicense it under different terms, provided that the
|
||||
license for the Executable Form does not attempt to limit or alter
|
||||
the recipients' rights in the Source Code Form under this License.
|
||||
|
||||
3.3. Distribution of a Larger Work
|
||||
|
||||
You may create and distribute a Larger Work under terms of Your choice,
|
||||
provided that You also comply with the requirements of this License for
|
||||
the Covered Software. If the Larger Work is a combination of Covered
|
||||
Software with a work governed by one or more Secondary Licenses, and the
|
||||
Covered Software is not Incompatible With Secondary Licenses, this
|
||||
License permits You to additionally distribute such Covered Software
|
||||
under the terms of such Secondary License(s), so that the recipient of
|
||||
the Larger Work may, at their option, further distribute the Covered
|
||||
Software under the terms of either this License or such Secondary
|
||||
License(s).
|
||||
|
||||
3.4. Notices
|
||||
|
||||
You may not remove or alter the substance of any license notices
|
||||
(including copyright notices, patent notices, disclaimers of warranty,
|
||||
or limitations of liability) contained within the Source Code Form of
|
||||
the Covered Software, except that You may alter any license notices to
|
||||
the extent required to remedy known factual inaccuracies.
|
||||
|
||||
3.5. Application of Additional Terms
|
||||
|
||||
You may choose to offer, and to charge a fee for, warranty, support,
|
||||
indemnity or liability obligations to one or more recipients of Covered
|
||||
Software. However, You may do so only on Your own behalf, and not on
|
||||
behalf of any Contributor. You must make it absolutely clear that any
|
||||
such warranty, support, indemnity, or liability obligation is offered by
|
||||
You alone, and You hereby agree to indemnify every Contributor for any
|
||||
liability incurred by such Contributor as a result of warranty, support,
|
||||
indemnity or liability terms You offer. You may include additional
|
||||
disclaimers of warranty and limitations of liability specific to any
|
||||
jurisdiction.
|
||||
|
||||
4. Inability to Comply Due to Statute or Regulation
|
||||
---------------------------------------------------
|
||||
|
||||
If it is impossible for You to comply with any of the terms of this
|
||||
License with respect to some or all of the Covered Software due to
|
||||
statute, judicial order, or regulation then You must: (a) comply with
|
||||
the terms of this License to the maximum extent possible; and (b)
|
||||
describe the limitations and the code they affect. Such description must
|
||||
be placed in a text file included with all distributions of the Covered
|
||||
Software under this License. Except to the extent prohibited by statute
|
||||
or regulation, such description must be sufficiently detailed for a
|
||||
recipient of ordinary skill to be able to understand it.
|
||||
|
||||
5. Termination
|
||||
--------------
|
||||
|
||||
5.1. The rights granted under this License will terminate automatically
|
||||
if You fail to comply with any of its terms. However, if You become
|
||||
compliant, then the rights granted under this License from a particular
|
||||
Contributor are reinstated (a) provisionally, unless and until such
|
||||
Contributor explicitly and finally terminates Your grants, and (b) on an
|
||||
ongoing basis, if such Contributor fails to notify You of the
|
||||
non-compliance by some reasonable means prior to 60 days after You have
|
||||
come back into compliance. Moreover, Your grants from a particular
|
||||
Contributor are reinstated on an ongoing basis if such Contributor
|
||||
notifies You of the non-compliance by some reasonable means, this is the
|
||||
first time You have received notice of non-compliance with this License
|
||||
from such Contributor, and You become compliant prior to 30 days after
|
||||
Your receipt of the notice.
|
||||
|
||||
5.2. If You initiate litigation against any entity by asserting a patent
|
||||
infringement claim (excluding declaratory judgment actions,
|
||||
counter-claims, and cross-claims) alleging that a Contributor Version
|
||||
directly or indirectly infringes any patent, then the rights granted to
|
||||
You by any and all Contributors for the Covered Software under Section
|
||||
2.1 of this License shall terminate.
|
||||
|
||||
5.3. In the event of termination under Sections 5.1 or 5.2 above, all
|
||||
end user license agreements (excluding distributors and resellers) which
|
||||
have been validly granted by You or Your distributors under this License
|
||||
prior to termination shall survive termination.
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 6. Disclaimer of Warranty *
|
||||
* ------------------------- *
|
||||
* *
|
||||
* Covered Software is provided under this License on an "as is" *
|
||||
* basis, without warranty of any kind, either expressed, implied, or *
|
||||
* statutory, including, without limitation, warranties that the *
|
||||
* Covered Software is free of defects, merchantable, fit for a *
|
||||
* particular purpose or non-infringing. The entire risk as to the *
|
||||
* quality and performance of the Covered Software is with You. *
|
||||
* Should any Covered Software prove defective in any respect, You *
|
||||
* (not any Contributor) assume the cost of any necessary servicing, *
|
||||
* repair, or correction. This disclaimer of warranty constitutes an *
|
||||
* essential part of this License. No use of any Covered Software is *
|
||||
* authorized under this License except under this disclaimer. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
************************************************************************
|
||||
* *
|
||||
* 7. Limitation of Liability *
|
||||
* -------------------------- *
|
||||
* *
|
||||
* Under no circumstances and under no legal theory, whether tort *
|
||||
* (including negligence), contract, or otherwise, shall any *
|
||||
* Contributor, or anyone who distributes Covered Software as *
|
||||
* permitted above, be liable to You for any direct, indirect, *
|
||||
* special, incidental, or consequential damages of any character *
|
||||
* including, without limitation, damages for lost profits, loss of *
|
||||
* goodwill, work stoppage, computer failure or malfunction, or any *
|
||||
* and all other commercial damages or losses, even if such party *
|
||||
* shall have been informed of the possibility of such damages. This *
|
||||
* limitation of liability shall not apply to liability for death or *
|
||||
* personal injury resulting from such party's negligence to the *
|
||||
* extent applicable law prohibits such limitation. Some *
|
||||
* jurisdictions do not allow the exclusion or limitation of *
|
||||
* incidental or consequential damages, so this exclusion and *
|
||||
* limitation may not apply to You. *
|
||||
* *
|
||||
************************************************************************
|
||||
|
||||
8. Litigation
|
||||
-------------
|
||||
|
||||
Any litigation relating to this License may be brought only in the
|
||||
courts of a jurisdiction where the defendant maintains its principal
|
||||
place of business and such litigation shall be governed by laws of that
|
||||
jurisdiction, without reference to its conflict-of-law provisions.
|
||||
Nothing in this Section shall prevent a party's ability to bring
|
||||
cross-claims or counter-claims.
|
||||
|
||||
9. Miscellaneous
|
||||
----------------
|
||||
|
||||
This License represents the complete agreement concerning the subject
|
||||
matter hereof. If any provision of this License is held to be
|
||||
unenforceable, such provision shall be reformed only to the extent
|
||||
necessary to make it enforceable. Any law or regulation which provides
|
||||
that the language of a contract shall be construed against the drafter
|
||||
shall not be used to construe this License against a Contributor.
|
||||
|
||||
10. Versions of the License
|
||||
---------------------------
|
||||
|
||||
10.1. New Versions
|
||||
|
||||
Mozilla Foundation is the license steward. Except as provided in Section
|
||||
10.3, no one other than the license steward has the right to modify or
|
||||
publish new versions of this License. Each version will be given a
|
||||
distinguishing version number.
|
||||
|
||||
10.2. Effect of New Versions
|
||||
|
||||
You may distribute the Covered Software under the terms of the version
|
||||
of the License under which You originally received the Covered Software,
|
||||
or under the terms of any subsequent version published by the license
|
||||
steward.
|
||||
|
||||
10.3. Modified Versions
|
||||
|
||||
If you create software not governed by this License, and you want to
|
||||
create a new license for such software, you may create and use a
|
||||
modified version of this License if you rename the license and remove
|
||||
any references to the name of the license steward (except to note that
|
||||
such modified license differs from this License).
|
||||
|
||||
10.4. Distributing Source Code Form that is Incompatible With Secondary
|
||||
Licenses
|
||||
|
||||
If You choose to distribute Source Code Form that is Incompatible With
|
||||
Secondary Licenses under the terms of this version of the License, the
|
||||
notice described in Exhibit B of this License must be attached.
|
||||
|
||||
Exhibit A - Source Code Form License Notice
|
||||
-------------------------------------------
|
||||
|
||||
This Source Code Form is subject to the terms of the Mozilla Public
|
||||
License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
If it is not possible or desirable to put the notice in a particular
|
||||
file, then You may include the notice in a location (such as a LICENSE
|
||||
file in a relevant directory) where a recipient would be likely to look
|
||||
for such a notice.
|
||||
|
||||
You may add additional accurate notices of copyright ownership.
|
||||
|
||||
Exhibit B - "Incompatible With Secondary Licenses" Notice
|
||||
---------------------------------------------------------
|
||||
|
||||
This Source Code Form is "Incompatible With Secondary Licenses", as
|
||||
defined by the Mozilla Public License, v. 2.0.
|
||||
8
src/external/libigl-2.3.0/README.md
vendored
8
src/external/libigl-2.3.0/README.md
vendored
@ -1,8 +0,0 @@
|
||||
# libigl - A simple C++ geometry processing library
|
||||
[](https://github.com/libigl/libigl/actions?query=workflow%3ABuild+branch%3Amaster+event%3Apush)
|
||||
[](https://github.com/libigl/libigl/actions?query=workflow%3ANightly+branch%3Amaster+event%3Aschedule)
|
||||
[](https://anaconda.org/conda-forge/igl)
|
||||
|
||||

|
||||
|
||||
Documentation, tutorial, and instructions at <https://libigl.github.io>.
|
||||
@ -1,85 +0,0 @@
|
||||
################################################################################
|
||||
|
||||
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.8.0"))
|
||||
# For CMake 3.8 and above, we can use meta features directly provided by CMake itself
|
||||
set(CXX11_FEATURES cxx_std_11)
|
||||
set(CXX14_FEATURES cxx_std_14)
|
||||
set(CXX17_FEATURES cxx_std_17)
|
||||
return()
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
|
||||
set(CXX11_FEATURES
|
||||
cxx_auto_type
|
||||
cxx_constexpr
|
||||
)
|
||||
|
||||
set(CXX14_FEATURES
|
||||
cxx_generic_lambdas
|
||||
)
|
||||
|
||||
set(CXX17_FEATURES
|
||||
|
||||
)
|
||||
|
||||
################################################################################
|
||||
|
||||
# https://cmake.org/cmake/help/v3.1/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.html
|
||||
# cxx_aggregate_default_initializers Aggregate default initializers, as defined in N3605.
|
||||
# cxx_alias_templates Template aliases, as defined in N2258.
|
||||
# cxx_alignas Alignment control alignas, as defined in N2341.
|
||||
# cxx_alignof Alignment control alignof, as defined in N2341.
|
||||
# cxx_attributes Generic attributes, as defined in N2761.
|
||||
# cxx_attribute_deprecated deprecated]] attribute, as defined in N3760.
|
||||
# cxx_auto_type Automatic type deduction, as defined in N1984.
|
||||
# cxx_binary_literals Binary literals, as defined in N3472.
|
||||
# cxx_constexpr Constant expressions, as defined in N2235.
|
||||
# cxx_contextual_conversions Contextual conversions, as defined in N3323.
|
||||
# cxx_decltype_incomplete_return_types Decltype on incomplete return types, as defined in N3276.
|
||||
# cxx_decltype Decltype, as defined in N2343.
|
||||
# cxx_decltype_auto decltype(auto) semantics, as defined in N3638.
|
||||
# cxx_default_function_template_args Default template arguments for function templates, as defined in DR226
|
||||
# cxx_defaulted_functions Defaulted functions, as defined in N2346.
|
||||
# cxx_defaulted_move_initializers Defaulted move initializers, as defined in N3053.
|
||||
# cxx_delegating_constructors Delegating constructors, as defined in N1986.
|
||||
# cxx_deleted_functions Deleted functions, as defined in N2346.
|
||||
# cxx_digit_separators Digit separators, as defined in N3781.
|
||||
# cxx_enum_forward_declarations Enum forward declarations, as defined in N2764.
|
||||
# cxx_explicit_conversions Explicit conversion operators, as defined in N2437.
|
||||
# cxx_extended_friend_declarations Extended friend declarations, as defined in N1791.
|
||||
# cxx_extern_templates Extern templates, as defined in N1987.
|
||||
# cxx_final Override control final keyword, as defined in N2928, N3206 and N3272.
|
||||
# cxx_func_identifier Predefined __func__ identifier, as defined in N2340.
|
||||
# cxx_generalized_initializers Initializer lists, as defined in N2672.
|
||||
# cxx_generic_lambdas Generic lambdas, as defined in N3649.
|
||||
# cxx_inheriting_constructors Inheriting constructors, as defined in N2540.
|
||||
# cxx_inline_namespaces Inline namespaces, as defined in N2535.
|
||||
# cxx_lambdas Lambda functions, as defined in N2927.
|
||||
# cxx_lambda_init_captures Initialized lambda captures, as defined in N3648.
|
||||
# cxx_local_type_template_args Local and unnamed types as template arguments, as defined in N2657.
|
||||
# cxx_long_long_type long long type, as defined in N1811.
|
||||
# cxx_noexcept Exception specifications, as defined in N3050.
|
||||
# cxx_nonstatic_member_init Non-static data member initialization, as defined in N2756.
|
||||
# cxx_nullptr Null pointer, as defined in N2431.
|
||||
# cxx_override Override control override keyword, as defined in N2928, N3206 and N3272.
|
||||
# cxx_range_for Range-based for, as defined in N2930.
|
||||
# cxx_raw_string_literals Raw string literals, as defined in N2442.
|
||||
# cxx_reference_qualified_functions Reference qualified functions, as defined in N2439.
|
||||
# cxx_relaxed_constexpr Relaxed constexpr, as defined in N3652.
|
||||
# cxx_return_type_deduction Return type deduction on normal functions, as defined in N3386.
|
||||
# cxx_right_angle_brackets Right angle bracket parsing, as defined in N1757.
|
||||
# cxx_rvalue_references R-value references, as defined in N2118.
|
||||
# cxx_sizeof_member Size of non-static data members, as defined in N2253.
|
||||
# cxx_static_assert Static assert, as defined in N1720.
|
||||
# cxx_strong_enums Strongly typed enums, as defined in N2347.
|
||||
# cxx_thread_local Thread-local variables, as defined in N2659.
|
||||
# cxx_trailing_return_types Automatic function return type, as defined in N2541.
|
||||
# cxx_unicode_literals Unicode string literals, as defined in N2442.
|
||||
# cxx_uniform_initialization Uniform initialization, as defined in N2640.
|
||||
# cxx_unrestricted_unions Unrestricted unions, as defined in N2544.
|
||||
# cxx_user_literals User-defined literals, as defined in N2765.
|
||||
# cxx_variable_templates Variable templates, as defined in N3651.
|
||||
# cxx_variadic_macros Variadic macros, as defined in N1653.
|
||||
# cxx_variadic_templates Variadic templates, as defined in N2242.
|
||||
# cxx_template_template_parameters Template template parameters, as defined in ISO/IEC 14882:1998.
|
||||
@ -1,17 +0,0 @@
|
||||
# Distributed under the OSI-approved MIT License. See accompanying
|
||||
# file LICENSE or https://github.com/Crascit/DownloadProject for details.
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
project(${DL_ARGS_PROJ}-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(${DL_ARGS_PROJ}-download
|
||||
${DL_ARGS_UNPARSED_ARGUMENTS}
|
||||
SOURCE_DIR "${DL_ARGS_SOURCE_DIR}"
|
||||
BINARY_DIR "${DL_ARGS_BINARY_DIR}"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
)
|
||||
@ -1,182 +0,0 @@
|
||||
# Distributed under the OSI-approved MIT License. See accompanying
|
||||
# file LICENSE or https://github.com/Crascit/DownloadProject for details.
|
||||
#
|
||||
# MODULE: DownloadProject
|
||||
#
|
||||
# PROVIDES:
|
||||
# download_project( PROJ projectName
|
||||
# [PREFIX prefixDir]
|
||||
# [DOWNLOAD_DIR downloadDir]
|
||||
# [SOURCE_DIR srcDir]
|
||||
# [BINARY_DIR binDir]
|
||||
# [QUIET]
|
||||
# ...
|
||||
# )
|
||||
#
|
||||
# Provides the ability to download and unpack a tarball, zip file, git repository,
|
||||
# etc. at configure time (i.e. when the cmake command is run). How the downloaded
|
||||
# and unpacked contents are used is up to the caller, but the motivating case is
|
||||
# to download source code which can then be included directly in the build with
|
||||
# add_subdirectory() after the call to download_project(). Source and build
|
||||
# directories are set up with this in mind.
|
||||
#
|
||||
# The PROJ argument is required. The projectName value will be used to construct
|
||||
# the following variables upon exit (obviously replace projectName with its actual
|
||||
# value):
|
||||
#
|
||||
# projectName_SOURCE_DIR
|
||||
# projectName_BINARY_DIR
|
||||
#
|
||||
# The SOURCE_DIR and BINARY_DIR arguments are optional and would not typically
|
||||
# need to be provided. They can be specified if you want the downloaded source
|
||||
# and build directories to be located in a specific place. The contents of
|
||||
# projectName_SOURCE_DIR and projectName_BINARY_DIR will be populated with the
|
||||
# locations used whether you provide SOURCE_DIR/BINARY_DIR or not.
|
||||
#
|
||||
# The DOWNLOAD_DIR argument does not normally need to be set. It controls the
|
||||
# location of the temporary CMake build used to perform the download.
|
||||
#
|
||||
# The PREFIX argument can be provided to change the base location of the default
|
||||
# values of DOWNLOAD_DIR, SOURCE_DIR and BINARY_DIR. If all of those three arguments
|
||||
# are provided, then PREFIX will have no effect. The default value for PREFIX is
|
||||
# CMAKE_BINARY_DIR.
|
||||
#
|
||||
# The QUIET option can be given if you do not want to show the output associated
|
||||
# with downloading the specified project.
|
||||
#
|
||||
# In addition to the above, any other options are passed through unmodified to
|
||||
# ExternalProject_Add() to perform the actual download, patch and update steps.
|
||||
# The following ExternalProject_Add() options are explicitly prohibited (they
|
||||
# are reserved for use by the download_project() command):
|
||||
#
|
||||
# CONFIGURE_COMMAND
|
||||
# BUILD_COMMAND
|
||||
# INSTALL_COMMAND
|
||||
# TEST_COMMAND
|
||||
#
|
||||
# Only those ExternalProject_Add() arguments which relate to downloading, patching
|
||||
# and updating of the project sources are intended to be used. Also note that at
|
||||
# least one set of download-related arguments are required.
|
||||
#
|
||||
# If using CMake 3.2 or later, the UPDATE_DISCONNECTED option can be used to
|
||||
# prevent a check at the remote end for changes every time CMake is run
|
||||
# after the first successful download. See the documentation of the ExternalProject
|
||||
# module for more information. It is likely you will want to use this option if it
|
||||
# is available to you. Note, however, that the ExternalProject implementation contains
|
||||
# bugs which result in incorrect handling of the UPDATE_DISCONNECTED option when
|
||||
# using the URL download method or when specifying a SOURCE_DIR with no download
|
||||
# method. Fixes for these have been created, the last of which is scheduled for
|
||||
# inclusion in CMake 3.8.0. Details can be found here:
|
||||
#
|
||||
# https://gitlab.kitware.com/cmake/cmake/commit/bdca68388bd57f8302d3c1d83d691034b7ffa70c
|
||||
# https://gitlab.kitware.com/cmake/cmake/issues/16428
|
||||
#
|
||||
# If you experience build errors related to the update step, consider avoiding
|
||||
# the use of UPDATE_DISCONNECTED.
|
||||
#
|
||||
# EXAMPLE USAGE:
|
||||
#
|
||||
# include(DownloadProject)
|
||||
# download_project(PROJ googletest
|
||||
# GIT_REPOSITORY https://github.com/google/googletest.git
|
||||
# GIT_TAG master
|
||||
# UPDATE_DISCONNECTED 1
|
||||
# QUIET
|
||||
# )
|
||||
#
|
||||
# add_subdirectory(${googletest_SOURCE_DIR} ${googletest_BINARY_DIR})
|
||||
#
|
||||
#========================================================================================
|
||||
|
||||
|
||||
set(_DownloadProjectDir "${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(download_project)
|
||||
|
||||
set(options QUIET)
|
||||
set(oneValueArgs
|
||||
PROJ
|
||||
PREFIX
|
||||
DOWNLOAD_DIR
|
||||
SOURCE_DIR
|
||||
BINARY_DIR
|
||||
# Prevent the following from being passed through
|
||||
CONFIGURE_COMMAND
|
||||
BUILD_COMMAND
|
||||
INSTALL_COMMAND
|
||||
TEST_COMMAND
|
||||
)
|
||||
set(multiValueArgs "")
|
||||
|
||||
cmake_parse_arguments(DL_ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
# Hide output if requested
|
||||
if (DL_ARGS_QUIET)
|
||||
set(OUTPUT_QUIET "OUTPUT_QUIET")
|
||||
else()
|
||||
unset(OUTPUT_QUIET)
|
||||
message(STATUS "Downloading/updating ${DL_ARGS_PROJ}")
|
||||
endif()
|
||||
|
||||
# Set up where we will put our temporary CMakeLists.txt file and also
|
||||
# the base point below which the default source and binary dirs will be.
|
||||
# The prefix must always be an absolute path.
|
||||
if (NOT DL_ARGS_PREFIX)
|
||||
set(DL_ARGS_PREFIX "${CMAKE_BINARY_DIR}")
|
||||
else()
|
||||
get_filename_component(DL_ARGS_PREFIX "${DL_ARGS_PREFIX}" ABSOLUTE
|
||||
BASE_DIR "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
endif()
|
||||
if (NOT DL_ARGS_DOWNLOAD_DIR)
|
||||
set(DL_ARGS_DOWNLOAD_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-download")
|
||||
endif()
|
||||
|
||||
# Ensure the caller can know where to find the source and build directories
|
||||
if (NOT DL_ARGS_SOURCE_DIR)
|
||||
set(DL_ARGS_SOURCE_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-src")
|
||||
endif()
|
||||
if (NOT DL_ARGS_BINARY_DIR)
|
||||
set(DL_ARGS_BINARY_DIR "${DL_ARGS_PREFIX}/${DL_ARGS_PROJ}-build")
|
||||
endif()
|
||||
set(${DL_ARGS_PROJ}_SOURCE_DIR "${DL_ARGS_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set(${DL_ARGS_PROJ}_BINARY_DIR "${DL_ARGS_BINARY_DIR}" PARENT_SCOPE)
|
||||
|
||||
# The way that CLion manages multiple configurations, it causes a copy of
|
||||
# the CMakeCache.txt to be copied across due to it not expecting there to
|
||||
# be a project within a project. This causes the hard-coded paths in the
|
||||
# cache to be copied and builds to fail. To mitigate this, we simply
|
||||
# remove the cache if it exists before we configure the new project. It
|
||||
# is safe to do so because it will be re-generated. Since this is only
|
||||
# executed at the configure step, it should not cause additional builds or
|
||||
# downloads.
|
||||
file(REMOVE "${DL_ARGS_DOWNLOAD_DIR}/CMakeCache.txt")
|
||||
|
||||
# Create and build a separate CMake project to carry out the download.
|
||||
# If we've already previously done these steps, they will not cause
|
||||
# anything to be updated, so extra rebuilds of the project won't occur.
|
||||
# Make sure to pass through CMAKE_MAKE_PROGRAM in case the main project
|
||||
# has this set to something not findable on the PATH.
|
||||
configure_file("${_DownloadProjectDir}/DownloadProject.CMakeLists.cmake.in"
|
||||
"${DL_ARGS_DOWNLOAD_DIR}/CMakeLists.txt")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}"
|
||||
-D "CMAKE_MAKE_PROGRAM:FILE=${CMAKE_MAKE_PROGRAM}"
|
||||
.
|
||||
RESULT_VARIABLE result
|
||||
${OUTPUT_QUIET}
|
||||
WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}"
|
||||
)
|
||||
if(result)
|
||||
message(FATAL_ERROR "CMake step for ${DL_ARGS_PROJ} failed: ${result}")
|
||||
endif()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
${OUTPUT_QUIET}
|
||||
WORKING_DIRECTORY "${DL_ARGS_DOWNLOAD_DIR}"
|
||||
)
|
||||
if(result)
|
||||
message(FATAL_ERROR "Build step for ${DL_ARGS_PROJ} failed: ${result}")
|
||||
endif()
|
||||
|
||||
endfunction()
|
||||
52
src/external/libigl-2.3.0/cmake/FindCORK.cmake
vendored
52
src/external/libigl-2.3.0/cmake/FindCORK.cmake
vendored
@ -1,52 +0,0 @@
|
||||
#
|
||||
# Try to find CORK library and include path.
|
||||
# Once done this will define
|
||||
#
|
||||
# CORK_FOUND
|
||||
# CORK_INCLUDE_DIR
|
||||
# CORK_LIBRARIES
|
||||
#
|
||||
|
||||
if(NOT CORK_FOUND)
|
||||
|
||||
FIND_PATH(CORK_INCLUDE_DIR cork.h
|
||||
PATHS
|
||||
${PROJECT_SOURCE_DIR}/../../external/cork/include
|
||||
${PROJECT_SOURCE_DIR}/../external/cork/include
|
||||
${PROJECT_SOURCE_DIR}/external/cork/include
|
||||
/usr/local/include
|
||||
/usr/X11/include
|
||||
/usr/include
|
||||
/opt/local/include
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
FIND_LIBRARY( CORK_LIBRARIES NAMES cork
|
||||
PATHS
|
||||
${PROJECT_SOURCE_DIR}/../../external/cork/lib/
|
||||
${PROJECT_SOURCE_DIR}/../external/cork/lib/
|
||||
${PROJECT_SOURCE_DIR}/external/cork/lib/
|
||||
/usr/local
|
||||
/usr/X11
|
||||
/usr
|
||||
PATH_SUFFIXES
|
||||
a
|
||||
lib64
|
||||
lib
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
SET(CORK_FOUND "NO")
|
||||
IF (CORK_INCLUDE_DIR AND CORK_LIBRARIES)
|
||||
SET(CORK_FOUND "YES")
|
||||
ENDIF (CORK_INCLUDE_DIR AND CORK_LIBRARIES)
|
||||
|
||||
if(CORK_FOUND)
|
||||
message(STATUS "Found CORK: ${CORK_INCLUDE_DIR}")
|
||||
else(CORK_FOUND)
|
||||
if (NOT CORK_FIND_QUIETLY)
|
||||
message(FATAL_ERROR "could NOT find CORK")
|
||||
endif (NOT CORK_FIND_QUIETLY)
|
||||
endif(CORK_FOUND)
|
||||
|
||||
endif(NOT CORK_FOUND)
|
||||
1547
src/external/libigl-2.3.0/cmake/FindMATLAB.cmake
vendored
1547
src/external/libigl-2.3.0/cmake/FindMATLAB.cmake
vendored
File diff suppressed because it is too large
Load Diff
43
src/external/libigl-2.3.0/cmake/FindMOSEK.cmake
vendored
43
src/external/libigl-2.3.0/cmake/FindMOSEK.cmake
vendored
@ -1,43 +0,0 @@
|
||||
#
|
||||
# Try to find MOSEK
|
||||
# Once done this will define
|
||||
#
|
||||
# MOSEK_FOUND - system has MOSEK
|
||||
# MOSEK_INCLUDE_DIRS - the MOSEK include directories
|
||||
# MOSEK_LIBRARIES - Link these to use MOSEK
|
||||
#
|
||||
|
||||
# Hardcoded search paths
|
||||
set(SEARCH_PATHS
|
||||
${CMAKE_SOURCE_DIR}/mosek/9.2/tools/platform/osx64x86/
|
||||
/usr/local/mosek/7/tools/platform/osx64x86/
|
||||
/usr/local/mosek/8/tools/platform/osx64x86/
|
||||
/usr/local/mosek/9.2/tools/platform/osx64x86/
|
||||
/opt/mosek/7/tools/platform/linux64x86/
|
||||
)
|
||||
|
||||
find_path(MOSEK_INCLUDE_DIR mosek.h
|
||||
PATHS ${SEARCH_PATHS}
|
||||
PATH_SUFFIXES h
|
||||
)
|
||||
|
||||
set(MOSEK_LIBRARIES)
|
||||
find_library(MOSEK_LIBRARIES NAMES mosek64
|
||||
HINT
|
||||
"${MOSEK_INCLUDE_DIR}"
|
||||
"${MOSEK_INCLUDE_DIR}/../bin"
|
||||
"${MOSEK_INCLUDE_DIR}/lib"
|
||||
PATHS
|
||||
${SEARCH_PATHS}
|
||||
NO_DEFAULT_PATH
|
||||
PATH_SUFFIXES a bin lib dylib)
|
||||
|
||||
# Check that Mosek was successfully found
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
MOSEK DEFAULT_MSG MOSEK_LIBRARIES MOSEK_INCLUDE_DIR
|
||||
)
|
||||
set(MOSEK_INCLUDE_DIRS ${MOSEK_INCLUDE_DIR})
|
||||
|
||||
# Hide variables from CMake-Gui options
|
||||
mark_as_advanced(MOSEK_LIBRARIES MOSEK_INCLUDE_DIRS MOSEK_INCLUDE_DIR)
|
||||
540
src/external/libigl-2.3.0/cmake/HunterGate.cmake
vendored
540
src/external/libigl-2.3.0/cmake/HunterGate.cmake
vendored
@ -1,540 +0,0 @@
|
||||
# Copyright (c) 2013-2018, Ruslan Baratov
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice, this
|
||||
# list of conditions and the following disclaimer.
|
||||
#
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# This is a gate file to Hunter package manager.
|
||||
# Include this file using `include` command and add package you need, example:
|
||||
#
|
||||
# cmake_minimum_required(VERSION 3.2)
|
||||
#
|
||||
# include("cmake/HunterGate.cmake")
|
||||
# HunterGate(
|
||||
# URL "https://github.com/path/to/hunter/archive.tar.gz"
|
||||
# SHA1 "798501e983f14b28b10cda16afa4de69eee1da1d"
|
||||
# )
|
||||
#
|
||||
# project(MyProject)
|
||||
#
|
||||
# hunter_add_package(Foo)
|
||||
# hunter_add_package(Boo COMPONENTS Bar Baz)
|
||||
#
|
||||
# Projects:
|
||||
# * https://github.com/hunter-packages/gate/
|
||||
# * https://github.com/ruslo/hunter
|
||||
|
||||
option(HUNTER_ENABLED "Enable Hunter package manager support" ON)
|
||||
|
||||
if(HUNTER_ENABLED)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.2")
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"At least CMake version 3.2 required for Hunter dependency management."
|
||||
" Update CMake or set HUNTER_ENABLED to OFF."
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(CMakeParseArguments) # cmake_parse_arguments
|
||||
|
||||
option(HUNTER_STATUS_PRINT "Print working status" ON)
|
||||
option(HUNTER_STATUS_DEBUG "Print a lot info" OFF)
|
||||
option(HUNTER_TLS_VERIFY "Enable/disable TLS certificate checking on downloads" ON)
|
||||
|
||||
set(HUNTER_WIKI "https://github.com/ruslo/hunter/wiki")
|
||||
|
||||
function(hunter_gate_status_print)
|
||||
if(HUNTER_STATUS_PRINT OR HUNTER_STATUS_DEBUG)
|
||||
foreach(print_message ${ARGV})
|
||||
message(STATUS "[hunter] ${print_message}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_status_debug)
|
||||
if(HUNTER_STATUS_DEBUG)
|
||||
foreach(print_message ${ARGV})
|
||||
string(TIMESTAMP timestamp)
|
||||
message(STATUS "[hunter *** DEBUG *** ${timestamp}] ${print_message}")
|
||||
endforeach()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_wiki wiki_page)
|
||||
message("------------------------------ WIKI -------------------------------")
|
||||
message(" ${HUNTER_WIKI}/${wiki_page}")
|
||||
message("-------------------------------------------------------------------")
|
||||
message("")
|
||||
message(FATAL_ERROR "")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_internal_error)
|
||||
message("")
|
||||
foreach(print_message ${ARGV})
|
||||
message("[hunter ** INTERNAL **] ${print_message}")
|
||||
endforeach()
|
||||
message("[hunter ** INTERNAL **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
|
||||
message("")
|
||||
hunter_gate_wiki("error.internal")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_fatal_error)
|
||||
cmake_parse_arguments(hunter "" "WIKI" "" "${ARGV}")
|
||||
string(COMPARE EQUAL "${hunter_WIKI}" "" have_no_wiki)
|
||||
if(have_no_wiki)
|
||||
hunter_gate_internal_error("Expected wiki")
|
||||
endif()
|
||||
message("")
|
||||
foreach(x ${hunter_UNPARSED_ARGUMENTS})
|
||||
message("[hunter ** FATAL ERROR **] ${x}")
|
||||
endforeach()
|
||||
message("[hunter ** FATAL ERROR **] [Directory:${CMAKE_CURRENT_LIST_DIR}]")
|
||||
message("")
|
||||
hunter_gate_wiki("${hunter_WIKI}")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_user_error)
|
||||
hunter_gate_fatal_error(${ARGV} WIKI "error.incorrect.input.data")
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_self root version sha1 result)
|
||||
string(COMPARE EQUAL "${root}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("root is empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${version}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("version is empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${sha1}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("sha1 is empty")
|
||||
endif()
|
||||
|
||||
string(SUBSTRING "${sha1}" 0 7 archive_id)
|
||||
|
||||
if(EXISTS "${root}/cmake/Hunter")
|
||||
set(hunter_self "${root}")
|
||||
else()
|
||||
set(
|
||||
hunter_self
|
||||
"${root}/_Base/Download/Hunter/${version}/${archive_id}/Unpacked"
|
||||
)
|
||||
endif()
|
||||
|
||||
set("${result}" "${hunter_self}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Set HUNTER_GATE_ROOT cmake variable to suitable value.
|
||||
function(hunter_gate_detect_root)
|
||||
# Check CMake variable
|
||||
string(COMPARE NOTEQUAL "${HUNTER_ROOT}" "" not_empty)
|
||||
if(not_empty)
|
||||
set(HUNTER_GATE_ROOT "${HUNTER_ROOT}" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT detected by cmake variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check environment variable
|
||||
string(COMPARE NOTEQUAL "$ENV{HUNTER_ROOT}" "" not_empty)
|
||||
if(not_empty)
|
||||
set(HUNTER_GATE_ROOT "$ENV{HUNTER_ROOT}" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT detected by environment variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check HOME environment variable
|
||||
string(COMPARE NOTEQUAL "$ENV{HOME}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{HOME}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug("HUNTER_ROOT set using HOME environment variable")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Check SYSTEMDRIVE and USERPROFILE environment variable (windows only)
|
||||
if(WIN32)
|
||||
string(COMPARE NOTEQUAL "$ENV{SYSTEMDRIVE}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{SYSTEMDRIVE}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug(
|
||||
"HUNTER_ROOT set using SYSTEMDRIVE environment variable"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(COMPARE NOTEQUAL "$ENV{USERPROFILE}" "" result)
|
||||
if(result)
|
||||
set(HUNTER_GATE_ROOT "$ENV{USERPROFILE}/.hunter" PARENT_SCOPE)
|
||||
hunter_gate_status_debug(
|
||||
"HUNTER_ROOT set using USERPROFILE environment variable"
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
hunter_gate_fatal_error(
|
||||
"Can't detect HUNTER_ROOT"
|
||||
WIKI "error.detect.hunter.root"
|
||||
)
|
||||
endfunction()
|
||||
|
||||
function(hunter_gate_download dir)
|
||||
string(
|
||||
COMPARE
|
||||
NOTEQUAL
|
||||
"$ENV{HUNTER_DISABLE_AUTOINSTALL}"
|
||||
""
|
||||
disable_autoinstall
|
||||
)
|
||||
if(disable_autoinstall AND NOT HUNTER_RUN_INSTALL)
|
||||
hunter_gate_fatal_error(
|
||||
"Hunter not found in '${dir}'"
|
||||
"Set HUNTER_RUN_INSTALL=ON to auto-install it from '${HUNTER_GATE_URL}'"
|
||||
"Settings:"
|
||||
" HUNTER_ROOT: ${HUNTER_GATE_ROOT}"
|
||||
" HUNTER_SHA1: ${HUNTER_GATE_SHA1}"
|
||||
WIKI "error.run.install"
|
||||
)
|
||||
endif()
|
||||
string(COMPARE EQUAL "${dir}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("Empty 'dir' argument")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("HUNTER_GATE_SHA1 empty")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" is_bad)
|
||||
if(is_bad)
|
||||
hunter_gate_internal_error("HUNTER_GATE_URL empty")
|
||||
endif()
|
||||
|
||||
set(done_location "${dir}/DONE")
|
||||
set(sha1_location "${dir}/SHA1")
|
||||
|
||||
set(build_dir "${dir}/Build")
|
||||
set(cmakelists "${dir}/CMakeLists.txt")
|
||||
|
||||
hunter_gate_status_debug("Locking directory: ${dir}")
|
||||
file(LOCK "${dir}" DIRECTORY GUARD FUNCTION)
|
||||
hunter_gate_status_debug("Lock done")
|
||||
|
||||
if(EXISTS "${done_location}")
|
||||
# while waiting for lock other instance can do all the job
|
||||
hunter_gate_status_debug("File '${done_location}' found, skip install")
|
||||
return()
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${build_dir}")
|
||||
file(REMOVE_RECURSE "${cmakelists}")
|
||||
|
||||
file(MAKE_DIRECTORY "${build_dir}") # check directory permissions
|
||||
|
||||
# Disabling languages speeds up a little bit, reduces noise in the output
|
||||
# and avoids path too long windows error
|
||||
file(
|
||||
WRITE
|
||||
"${cmakelists}"
|
||||
"cmake_minimum_required(VERSION 3.2)\n"
|
||||
"project(HunterDownload LANGUAGES NONE)\n"
|
||||
"include(ExternalProject)\n"
|
||||
"ExternalProject_Add(\n"
|
||||
" Hunter\n"
|
||||
" URL\n"
|
||||
" \"${HUNTER_GATE_URL}\"\n"
|
||||
" URL_HASH\n"
|
||||
" SHA1=${HUNTER_GATE_SHA1}\n"
|
||||
" DOWNLOAD_DIR\n"
|
||||
" \"${dir}\"\n"
|
||||
" TLS_VERIFY\n"
|
||||
" ${HUNTER_TLS_VERIFY}\n"
|
||||
" SOURCE_DIR\n"
|
||||
" \"${dir}/Unpacked\"\n"
|
||||
" CONFIGURE_COMMAND\n"
|
||||
" \"\"\n"
|
||||
" BUILD_COMMAND\n"
|
||||
" \"\"\n"
|
||||
" INSTALL_COMMAND\n"
|
||||
" \"\"\n"
|
||||
")\n"
|
||||
)
|
||||
|
||||
if(HUNTER_STATUS_DEBUG)
|
||||
set(logging_params "")
|
||||
else()
|
||||
set(logging_params OUTPUT_QUIET)
|
||||
endif()
|
||||
|
||||
hunter_gate_status_debug("Run generate")
|
||||
|
||||
# Need to add toolchain file too.
|
||||
# Otherwise on Visual Studio + MDD this will fail with error:
|
||||
# "Could not find an appropriate version of the Windows 10 SDK installed on this machine"
|
||||
if(EXISTS "${CMAKE_TOOLCHAIN_FILE}")
|
||||
get_filename_component(absolute_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}" ABSOLUTE)
|
||||
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=${absolute_CMAKE_TOOLCHAIN_FILE}")
|
||||
else()
|
||||
# 'toolchain_arg' can't be empty
|
||||
set(toolchain_arg "-DCMAKE_TOOLCHAIN_FILE=")
|
||||
endif()
|
||||
|
||||
string(COMPARE EQUAL "${CMAKE_MAKE_PROGRAM}" "" no_make)
|
||||
if(no_make)
|
||||
set(make_arg "")
|
||||
else()
|
||||
# Test case: remove Ninja from PATH but set it via CMAKE_MAKE_PROGRAM
|
||||
set(make_arg "-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}")
|
||||
endif()
|
||||
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${CMAKE_COMMAND}"
|
||||
"-H${dir}"
|
||||
"-B${build_dir}"
|
||||
"-G${CMAKE_GENERATOR}"
|
||||
"${toolchain_arg}"
|
||||
${make_arg}
|
||||
WORKING_DIRECTORY "${dir}"
|
||||
RESULT_VARIABLE download_result
|
||||
${logging_params}
|
||||
)
|
||||
|
||||
if(NOT download_result EQUAL 0)
|
||||
hunter_gate_internal_error(
|
||||
"Configure project failed."
|
||||
"To reproduce the error run: ${CMAKE_COMMAND} -H${dir} -B${build_dir} -G${CMAKE_GENERATOR} ${toolchain_arg} ${make_arg}"
|
||||
"In directory ${dir}"
|
||||
)
|
||||
endif()
|
||||
|
||||
hunter_gate_status_print(
|
||||
"Initializing Hunter workspace (${HUNTER_GATE_SHA1})"
|
||||
" ${HUNTER_GATE_URL}"
|
||||
" -> ${dir}"
|
||||
)
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" --build "${build_dir}"
|
||||
WORKING_DIRECTORY "${dir}"
|
||||
RESULT_VARIABLE download_result
|
||||
${logging_params}
|
||||
)
|
||||
|
||||
if(NOT download_result EQUAL 0)
|
||||
hunter_gate_internal_error("Build project failed")
|
||||
endif()
|
||||
|
||||
file(REMOVE_RECURSE "${build_dir}")
|
||||
file(REMOVE_RECURSE "${cmakelists}")
|
||||
|
||||
file(WRITE "${sha1_location}" "${HUNTER_GATE_SHA1}")
|
||||
file(WRITE "${done_location}" "DONE")
|
||||
|
||||
hunter_gate_status_debug("Finished")
|
||||
endfunction()
|
||||
|
||||
# Must be a macro so master file 'cmake/Hunter' can
|
||||
# apply all variables easily just by 'include' command
|
||||
# (otherwise PARENT_SCOPE magic needed)
|
||||
macro(HunterGate)
|
||||
if(HUNTER_GATE_DONE)
|
||||
# variable HUNTER_GATE_DONE set explicitly for external project
|
||||
# (see `hunter_download`)
|
||||
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
|
||||
endif()
|
||||
|
||||
# First HunterGate command will init Hunter, others will be ignored
|
||||
get_property(_hunter_gate_done GLOBAL PROPERTY HUNTER_GATE_DONE SET)
|
||||
|
||||
if(NOT HUNTER_ENABLED)
|
||||
# Empty function to avoid error "unknown function"
|
||||
function(hunter_add_package)
|
||||
endfunction()
|
||||
|
||||
set(
|
||||
_hunter_gate_disabled_mode_dir
|
||||
"${CMAKE_CURRENT_LIST_DIR}/cmake/Hunter/disabled-mode"
|
||||
)
|
||||
if(EXISTS "${_hunter_gate_disabled_mode_dir}")
|
||||
hunter_gate_status_debug(
|
||||
"Adding \"disabled-mode\" modules: ${_hunter_gate_disabled_mode_dir}"
|
||||
)
|
||||
list(APPEND CMAKE_PREFIX_PATH "${_hunter_gate_disabled_mode_dir}")
|
||||
endif()
|
||||
elseif(_hunter_gate_done)
|
||||
hunter_gate_status_debug("Secondary HunterGate (use old settings)")
|
||||
hunter_gate_self(
|
||||
"${HUNTER_CACHED_ROOT}"
|
||||
"${HUNTER_VERSION}"
|
||||
"${HUNTER_SHA1}"
|
||||
_hunter_self
|
||||
)
|
||||
include("${_hunter_self}/cmake/Hunter")
|
||||
else()
|
||||
set(HUNTER_GATE_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}")
|
||||
|
||||
string(COMPARE NOTEQUAL "${PROJECT_NAME}" "" _have_project_name)
|
||||
if(_have_project_name)
|
||||
hunter_gate_fatal_error(
|
||||
"Please set HunterGate *before* 'project' command. "
|
||||
"Detected project: ${PROJECT_NAME}"
|
||||
WIKI "error.huntergate.before.project"
|
||||
)
|
||||
endif()
|
||||
|
||||
cmake_parse_arguments(
|
||||
HUNTER_GATE "LOCAL" "URL;SHA1;GLOBAL;FILEPATH" "" ${ARGV}
|
||||
)
|
||||
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_SHA1}" "" _empty_sha1)
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_URL}" "" _empty_url)
|
||||
string(
|
||||
COMPARE
|
||||
NOTEQUAL
|
||||
"${HUNTER_GATE_UNPARSED_ARGUMENTS}"
|
||||
""
|
||||
_have_unparsed
|
||||
)
|
||||
string(COMPARE NOTEQUAL "${HUNTER_GATE_GLOBAL}" "" _have_global)
|
||||
string(COMPARE NOTEQUAL "${HUNTER_GATE_FILEPATH}" "" _have_filepath)
|
||||
|
||||
if(_have_unparsed)
|
||||
hunter_gate_user_error(
|
||||
"HunterGate unparsed arguments: ${HUNTER_GATE_UNPARSED_ARGUMENTS}"
|
||||
)
|
||||
endif()
|
||||
if(_empty_sha1)
|
||||
hunter_gate_user_error("SHA1 suboption of HunterGate is mandatory")
|
||||
endif()
|
||||
if(_empty_url)
|
||||
hunter_gate_user_error("URL suboption of HunterGate is mandatory")
|
||||
endif()
|
||||
if(_have_global)
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
hunter_gate_user_error("Unexpected LOCAL (already has GLOBAL)")
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
hunter_gate_user_error("Unexpected FILEPATH (already has GLOBAL)")
|
||||
endif()
|
||||
endif()
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
if(_have_global)
|
||||
hunter_gate_user_error("Unexpected GLOBAL (already has LOCAL)")
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
hunter_gate_user_error("Unexpected FILEPATH (already has LOCAL)")
|
||||
endif()
|
||||
endif()
|
||||
if(_have_filepath)
|
||||
if(_have_global)
|
||||
hunter_gate_user_error("Unexpected GLOBAL (already has FILEPATH)")
|
||||
endif()
|
||||
if(HUNTER_GATE_LOCAL)
|
||||
hunter_gate_user_error("Unexpected LOCAL (already has FILEPATH)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
hunter_gate_detect_root() # set HUNTER_GATE_ROOT
|
||||
|
||||
# Beautify path, fix probable problems with windows path slashes
|
||||
get_filename_component(
|
||||
HUNTER_GATE_ROOT "${HUNTER_GATE_ROOT}" ABSOLUTE
|
||||
)
|
||||
hunter_gate_status_debug("HUNTER_ROOT: ${HUNTER_GATE_ROOT}")
|
||||
if(NOT HUNTER_ALLOW_SPACES_IN_PATH)
|
||||
string(FIND "${HUNTER_GATE_ROOT}" " " _contain_spaces)
|
||||
if(NOT _contain_spaces EQUAL -1)
|
||||
hunter_gate_fatal_error(
|
||||
"HUNTER_ROOT (${HUNTER_GATE_ROOT}) contains spaces."
|
||||
"Set HUNTER_ALLOW_SPACES_IN_PATH=ON to skip this error"
|
||||
"(Use at your own risk!)"
|
||||
WIKI "error.spaces.in.hunter.root"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(
|
||||
REGEX
|
||||
MATCH
|
||||
"[0-9]+\\.[0-9]+\\.[0-9]+[-_a-z0-9]*"
|
||||
HUNTER_GATE_VERSION
|
||||
"${HUNTER_GATE_URL}"
|
||||
)
|
||||
string(COMPARE EQUAL "${HUNTER_GATE_VERSION}" "" _is_empty)
|
||||
if(_is_empty)
|
||||
set(HUNTER_GATE_VERSION "unknown")
|
||||
endif()
|
||||
|
||||
hunter_gate_self(
|
||||
"${HUNTER_GATE_ROOT}"
|
||||
"${HUNTER_GATE_VERSION}"
|
||||
"${HUNTER_GATE_SHA1}"
|
||||
_hunter_self
|
||||
)
|
||||
|
||||
set(_master_location "${_hunter_self}/cmake/Hunter")
|
||||
if(EXISTS "${HUNTER_GATE_ROOT}/cmake/Hunter")
|
||||
# Hunter downloaded manually (e.g. by 'git clone')
|
||||
set(_unused "xxxxxxxxxx")
|
||||
set(HUNTER_GATE_SHA1 "${_unused}")
|
||||
set(HUNTER_GATE_VERSION "${_unused}")
|
||||
else()
|
||||
get_filename_component(_archive_id_location "${_hunter_self}/.." ABSOLUTE)
|
||||
set(_done_location "${_archive_id_location}/DONE")
|
||||
set(_sha1_location "${_archive_id_location}/SHA1")
|
||||
|
||||
# Check Hunter already downloaded by HunterGate
|
||||
if(NOT EXISTS "${_done_location}")
|
||||
hunter_gate_download("${_archive_id_location}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${_done_location}")
|
||||
hunter_gate_internal_error("hunter_gate_download failed")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${_sha1_location}")
|
||||
hunter_gate_internal_error("${_sha1_location} not found")
|
||||
endif()
|
||||
file(READ "${_sha1_location}" _sha1_value)
|
||||
string(COMPARE EQUAL "${_sha1_value}" "${HUNTER_GATE_SHA1}" _is_equal)
|
||||
if(NOT _is_equal)
|
||||
hunter_gate_internal_error(
|
||||
"Short SHA1 collision:"
|
||||
" ${_sha1_value} (from ${_sha1_location})"
|
||||
" ${HUNTER_GATE_SHA1} (HunterGate)"
|
||||
)
|
||||
endif()
|
||||
if(NOT EXISTS "${_master_location}")
|
||||
hunter_gate_user_error(
|
||||
"Master file not found:"
|
||||
" ${_master_location}"
|
||||
"try to update Hunter/HunterGate"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
include("${_master_location}")
|
||||
set_property(GLOBAL PROPERTY HUNTER_GATE_DONE YES)
|
||||
endif()
|
||||
endmacro()
|
||||
@ -1,198 +0,0 @@
|
||||
################################################################################
|
||||
include(DownloadProject)
|
||||
|
||||
# With CMake 3.8 and above, we can hide warnings about git being in a
|
||||
# detached head by passing an extra GIT_CONFIG option.
|
||||
set(LIBIGL_EXTRA_OPTIONS TLS_VERIFY OFF)
|
||||
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.8.0"))
|
||||
list(APPEND LIBIGL_EXTRA_OPTIONS GIT_CONFIG advice.detachedHead=false)
|
||||
endif()
|
||||
|
||||
# On CMake 3.6.3 and above, there is an option to use shallow clones of git repositories.
|
||||
# The shallow clone option only works with real tags, not SHA1, so we use a separate option.
|
||||
set(LIBIGL_BRANCH_OPTIONS)
|
||||
if(NOT (${CMAKE_VERSION} VERSION_LESS "3.6.3"))
|
||||
# Disabled for now until we can make sure that it has no adverse effects
|
||||
# (Downside is that the eigen mirror is huge again)
|
||||
# list(APPEND LIBIGL_BRANCH_OPTIONS GIT_SHALLOW 1)
|
||||
endif()
|
||||
|
||||
option(LIBIGL_SKIP_DOWNLOAD "Skip downloading external libraries" OFF)
|
||||
|
||||
# Shortcut functions
|
||||
function(igl_download_project_aux name source)
|
||||
if(NOT LIBIGL_SKIP_DOWNLOAD)
|
||||
download_project(
|
||||
PROJ ${name}
|
||||
SOURCE_DIR "${source}"
|
||||
DOWNLOAD_DIR "${LIBIGL_EXTERNAL}/.cache/${name}"
|
||||
QUIET
|
||||
${LIBIGL_EXTRA_OPTIONS}
|
||||
${ARGN}
|
||||
)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(igl_download_project name)
|
||||
igl_download_project_aux(${name} "${LIBIGL_EXTERNAL}/${name}" ${ARGN})
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
|
||||
## CGAL
|
||||
function(igl_download_cgal)
|
||||
igl_download_project(cgal
|
||||
GIT_REPOSITORY https://github.com/CGAL/cgal.git
|
||||
GIT_TAG f7c3c8212b56c0d6dae63787efc99093f4383415
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## CoMISo
|
||||
function(igl_download_comiso)
|
||||
igl_download_project(CoMISo
|
||||
GIT_REPOSITORY https://github.com/libigl/CoMISo.git
|
||||
GIT_TAG d60aa4759fba76b0b793b1efb090b7a771dd7c56
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Cork
|
||||
function(igl_download_cork)
|
||||
igl_download_project(cork
|
||||
GIT_REPOSITORY https://github.com/libigl/cork.git
|
||||
GIT_TAG 27ad8a285838f5a480d856429e39d3d56d4338f9
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Eigen
|
||||
set(LIBIGL_EIGEN_VERSION 3.3.7 CACHE STRING "Default version of Eigen used by libigl.")
|
||||
function(igl_download_eigen)
|
||||
igl_download_project(eigen
|
||||
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
|
||||
GIT_TAG ${LIBIGL_EIGEN_VERSION}
|
||||
${LIBIGL_BRANCH_OPTIONS}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Embree
|
||||
function(igl_download_embree)
|
||||
igl_download_project(embree
|
||||
GIT_REPOSITORY https://github.com/embree/embree.git
|
||||
GIT_TAG v3.12.1
|
||||
${LIBIGL_BRANCH_OPTIONS}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## glad
|
||||
function(igl_download_glad)
|
||||
igl_download_project(glad
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-glad.git
|
||||
GIT_TAG 09b4969c56779f7ddf8e6176ec1873184aec890f
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## GLFW
|
||||
function(igl_download_glfw)
|
||||
igl_download_project(glfw
|
||||
GIT_REPOSITORY https://github.com/glfw/glfw.git
|
||||
GIT_TAG 3327050ca66ad34426a82c217c2d60ced61526b7
|
||||
${LIBIGL_BRANCH_OPTIONS}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## ImGui
|
||||
function(igl_download_imgui)
|
||||
igl_download_project(imgui
|
||||
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
||||
GIT_TAG 61b19489f1ba35934d9114c034b24eb5bff149e7 # 1.81 + patch for #1669
|
||||
${LIBIGL_BRANCH_OPTIONS}
|
||||
)
|
||||
igl_download_project(libigl-imgui
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-imgui.git
|
||||
GIT_TAG 7e1053e750b0f4c129b046f4e455243cb7f804f3
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## ImGuizmo
|
||||
function(igl_download_imguizmo)
|
||||
igl_download_project(imguizmo
|
||||
GIT_REPOSITORY https://github.com/CedricGuillemet/ImGuizmo.git
|
||||
GIT_TAG a23567269f6617342bcc112394bdad937b54b2d7
|
||||
${LIBIGL_BRANCH_OPTIONS}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## pybind11
|
||||
function(igl_download_pybind11)
|
||||
igl_download_project(pybind11
|
||||
GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
||||
GIT_TAG 2d0507db43cd5a117f7843e053b17dffca114107
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## stb_image
|
||||
function(igl_download_stb)
|
||||
igl_download_project(stb
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-stb.git
|
||||
GIT_TAG cd0fa3fcd90325c83be4d697b00214e029f94ca3
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## TetGen
|
||||
function(igl_download_tetgen)
|
||||
igl_download_project(tetgen
|
||||
GIT_REPOSITORY https://github.com/jdumas/tetgen.git
|
||||
GIT_TAG c63e7a6434652b8a2065c835bd9d6d298db1a0bc
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## TinyXML
|
||||
function(igl_download_tinyxml2)
|
||||
igl_download_project(tinyxml2
|
||||
GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
|
||||
GIT_TAG d175e9de0be0d4db75d0a8cf065599a435a87eb6
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Triangle
|
||||
function(igl_download_triangle)
|
||||
igl_download_project(triangle
|
||||
GIT_REPOSITORY https://github.com/libigl/triangle.git
|
||||
GIT_TAG 5a70326574b34d6a51d9eaf6a9f78813657ee108
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Catch2
|
||||
function(igl_download_catch2)
|
||||
igl_download_project(catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG v2.11.0
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Predicates
|
||||
function(igl_download_predicates)
|
||||
igl_download_project(predicates
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-predicates.git
|
||||
GIT_TAG 488242fa2b1f98a9c5bd1441297fb4a99a6a9ae4
|
||||
)
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
|
||||
## Test data
|
||||
function(igl_download_test_data)
|
||||
igl_download_project_aux(test_data
|
||||
"${LIBIGL_EXTERNAL}/../tests/data"
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-tests-data
|
||||
GIT_TAG 19cedf96d70702d8b3a83eb27934780c542356fe
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Tutorial data
|
||||
function(igl_download_tutorial_data)
|
||||
igl_download_project_aux(tutorial_data
|
||||
"${LIBIGL_EXTERNAL}/../tutorial/data"
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-tutorial-data
|
||||
GIT_TAG c1f9ede366d02e3531ecbaec5e3769312f31cccd
|
||||
)
|
||||
endfunction()
|
||||
118
src/external/libigl-2.3.0/cmake/LibiglFolders.cmake
vendored
118
src/external/libigl-2.3.0/cmake/LibiglFolders.cmake
vendored
@ -1,118 +0,0 @@
|
||||
# Sort projects inside the solution
|
||||
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||
|
||||
function(igl_folder_targets FOLDER_NAME)
|
||||
foreach(target IN ITEMS ${ARGN})
|
||||
if(TARGET ${target})
|
||||
get_target_property(TYPE ${target} TYPE)
|
||||
if(NOT (TYPE STREQUAL "INTERFACE_LIBRARY"))
|
||||
set_target_properties(${target} PROPERTIES FOLDER "${FOLDER_NAME}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
function(igl_set_folders)
|
||||
|
||||
igl_folder_targets("ThirdParty/Embree"
|
||||
algorithms
|
||||
embree
|
||||
lexers
|
||||
math
|
||||
simd
|
||||
sys
|
||||
tasking
|
||||
)
|
||||
|
||||
igl_folder_targets("ThirdParty"
|
||||
CoMISo
|
||||
glad
|
||||
glfw
|
||||
imgui
|
||||
predicates
|
||||
tetgen
|
||||
tinyxml2
|
||||
triangle
|
||||
)
|
||||
|
||||
igl_folder_targets("Libigl"
|
||||
igl
|
||||
igl_comiso
|
||||
igl_embree
|
||||
igl_opengl
|
||||
igl_opengl_glfw
|
||||
igl_opengl_glfw_imgui
|
||||
igl_png
|
||||
igl_predicates
|
||||
igl_stb_image
|
||||
igl_tetgen
|
||||
igl_triangle
|
||||
igl_xml
|
||||
)
|
||||
|
||||
igl_folder_targets("Unit Tests"
|
||||
libigl_tests
|
||||
)
|
||||
|
||||
igl_folder_targets("Tutorials"
|
||||
101_FileIO_bin
|
||||
102_DrawMesh_bin
|
||||
103_Events_bin
|
||||
104_Colors_bin
|
||||
105_Overlays_bin
|
||||
106_ViewerMenu_bin
|
||||
107_MultipleMeshes_bin
|
||||
108_MultipleViews_bin
|
||||
201_Normals_bin
|
||||
202_GaussianCurvature_bin
|
||||
203_CurvatureDirections_bin
|
||||
204_Gradient_bin
|
||||
205_Laplacian_bin
|
||||
206_GeodesicDistance_bin
|
||||
301_Slice_bin
|
||||
302_Sort_bin
|
||||
303_LaplaceEquation_bin
|
||||
304_LinearEqualityConstraints_bin
|
||||
305_QuadraticProgramming_bin
|
||||
306_EigenDecomposition_bin
|
||||
401_BiharmonicDeformation_bin
|
||||
402_PolyharmonicDeformation_bin
|
||||
403_BoundedBiharmonicWeights_bin
|
||||
404_DualQuaternionSkinning_bin
|
||||
405_AsRigidAsPossible_bin
|
||||
406_FastAutomaticSkinningTransformations_bin
|
||||
407_BiharmonicCoordinates_bin
|
||||
408_DirectDeltaMush_bin
|
||||
501_HarmonicParam_bin
|
||||
502_LSCMParam_bin
|
||||
503_ARAPParam_bin
|
||||
504_NRosyDesign_bin
|
||||
505_MIQ_bin
|
||||
506_FrameField_bin
|
||||
507_Planarization_bin
|
||||
601_Serialization_bin
|
||||
604_Triangle_bin
|
||||
605_Tetgen_bin
|
||||
606_AmbientOcclusion_bin
|
||||
607_ScreenCapture_bin
|
||||
701_Statistics_bin
|
||||
702_WindingNumber_bin
|
||||
703_Decimation_bin
|
||||
704_SignedDistance_bin
|
||||
705_MarchingCubes_bin
|
||||
706_FacetOrientation_bin
|
||||
707_SweptVolume_bin
|
||||
708_Picking_bin
|
||||
709_SLIM_bin
|
||||
710_SCAF_bin
|
||||
711_Subdivision_bin
|
||||
712_DataSmoothing_bin
|
||||
713_ShapeUp_bin
|
||||
714_MarchingTets_bin
|
||||
715_MeshImplicitFunction_bin
|
||||
716_HeatGeodesics_bin
|
||||
718_IterativeClosestPoint_bin
|
||||
719_ExplodedView_bin
|
||||
)
|
||||
|
||||
endfunction()
|
||||
@ -1,26 +0,0 @@
|
||||
if(MSVC)
|
||||
option(IGL_STATIC_RUNTIME "Use libigl with the static MSVC runtime." OFF)
|
||||
if(IGL_STATIC_RUNTIME)
|
||||
message(STATUS "MSVC -> forcing use of statically-linked runtime.")
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${config} config)
|
||||
string(REPLACE /MD /MT CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}")
|
||||
string(REPLACE /MD /MT CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}")
|
||||
endforeach()
|
||||
string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
else()
|
||||
message(STATUS "MSVC -> forcing use of dynamically-linked runtime.")
|
||||
foreach(config ${CMAKE_CONFIGURATION_TYPES})
|
||||
string(TOUPPER ${config} config)
|
||||
string(REPLACE /MT /MD CMAKE_C_FLAGS_${config} "${CMAKE_C_FLAGS_${config}}")
|
||||
string(REPLACE /MT /MD CMAKE_CXX_FLAGS_${config} "${CMAKE_CXX_FLAGS_${config}}")
|
||||
endforeach()
|
||||
string(REPLACE "/MTd" "/MDd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
endif()
|
||||
|
||||
# https://github.com/mozilla/sccache/issues/242
|
||||
if(CMAKE_CXX_COMPILER_LAUNCHER STREQUAL "sccache")
|
||||
string(REGEX REPLACE "/Z[iI7]" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Z7")
|
||||
endif()
|
||||
endif()
|
||||
@ -1,151 +0,0 @@
|
||||
# OS X requires a Mach-O dynamic library to have a baked "install name", that is used by other modules to link to it. Depending
|
||||
# on how the library is built, the install name is not always an absolute path, nor necessarily the same as the name of the
|
||||
# library file itself. This macro takes as input the name of a target, and a list of libraries that it links to (the output of
|
||||
# FIND_PACKAGE or FIND_LIBRARY calls), and generates a set of custom, post-build commands that, for each linked dylib, changes
|
||||
# the name the target uses to refer to it with a fully-qualified (absolute) version of the library's own install name. This
|
||||
# helps ensure that the target can be used from any location while still being able to locate the linked dynamic libraries.
|
||||
#
|
||||
# Note that this script does NOT handle the case when a linked library itself refers to another library using a non-absolute
|
||||
# name (Boost is a notorious example). To avoid such issues, it is recommended to use a static library instead of a shared one
|
||||
# in a non-standard location. Alternatively, set DYLD_LIBRARY_PATH to include these non-standard locations when running the
|
||||
# program (not recommended).
|
||||
#
|
||||
# Author: Siddhartha Chaudhuri, 2009.
|
||||
#
|
||||
|
||||
# Set the minimum required CMake version
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
|
||||
|
||||
# See cmake --help-policy CMP0011 for details on this one
|
||||
IF(POLICY CMP0011)
|
||||
CMAKE_POLICY(SET CMP0011 NEW)
|
||||
ENDIF(POLICY CMP0011)
|
||||
|
||||
# See cmake --help-policy CMP0026 for details on this one
|
||||
IF(POLICY CMP0026)
|
||||
CMAKE_POLICY(SET CMP0026 NEW)
|
||||
ENDIF(POLICY CMP0026)
|
||||
|
||||
# See cmake --help-policy CMP0045 for details on this one
|
||||
IF(POLICY CMP0045)
|
||||
CMAKE_POLICY(SET CMP0045 NEW)
|
||||
ENDIF(POLICY CMP0045)
|
||||
|
||||
MACRO(OSX_FIX_DYLIB_REFERENCES target libraries)
|
||||
|
||||
IF(APPLE)
|
||||
SET(OFIN_${target}_RPATHS )
|
||||
|
||||
FOREACH(OFIN_${target}_Library ${libraries})
|
||||
IF(${OFIN_${target}_Library} MATCHES "[.]dylib$"
|
||||
OR ${OFIN_${target}_Library} MATCHES "[.]framework/.+")
|
||||
|
||||
# Resolve symlinks and get absolute location
|
||||
GET_FILENAME_COMPONENT(OFIN_${target}_LibraryAbsolute ${OFIN_${target}_Library} ABSOLUTE)
|
||||
|
||||
# Get the baked install name of the library
|
||||
EXECUTE_PROCESS(COMMAND otool -D ${OFIN_${target}_LibraryAbsolute}
|
||||
OUTPUT_VARIABLE OFIN_${target}_LibraryInstallNameOutput
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
STRING(REGEX REPLACE "[\r\n]" " " OFIN_${target}_LibraryInstallNameOutput ${OFIN_${target}_LibraryInstallNameOutput})
|
||||
SEPARATE_ARGUMENTS(OFIN_${target}_LibraryInstallNameOutput)
|
||||
LIST(GET OFIN_${target}_LibraryInstallNameOutput 1 OFIN_${target}_LibraryInstallName)
|
||||
|
||||
IF(${OFIN_${target}_LibraryInstallName} MATCHES "^[@]rpath/")
|
||||
|
||||
# Ideally, we want to eliminate the longest common suffix of the install name and the absolute path. Whatever's left
|
||||
# will be the desired rpath. But this is difficult to do (especially if there are naming variations, e.g.
|
||||
# "Versions/Current" vs "Versions/5" is a common culprit). So we'll add various candidate rpaths and hope at least one
|
||||
# is correct.
|
||||
|
||||
# Typically, the rpath to a library within a framework looks like this:
|
||||
# @rpath/A.framework/Versions/5/libFoo.dylib
|
||||
#
|
||||
# Hence, we'll extract for the path unit immediately following the @rpath (in this case A.framework) and then look for
|
||||
# it in the library's actual path. Everything before this location will be put in the rpath.
|
||||
SET(OFIN_${target}_PathPrefix ${OFIN_${target}_LibraryInstallName})
|
||||
SET(OFIN_${target}_RpathFirstChild )
|
||||
WHILE(NOT OFIN_${target}_PathPrefix STREQUAL "@rpath")
|
||||
GET_FILENAME_COMPONENT(OFIN_${target}_RpathFirstChild ${OFIN_${target}_PathPrefix} NAME)
|
||||
GET_FILENAME_COMPONENT(OFIN_${target}_PathPrefix ${OFIN_${target}_PathPrefix} PATH)
|
||||
|
||||
IF(NOT OFIN_${target}_PathPrefix) # should never happen but just in case
|
||||
BREAK()
|
||||
ENDIF(NOT OFIN_${target}_PathPrefix)
|
||||
|
||||
IF(OFIN_${target}_PathPrefix STREQUAL "/") # should never happen but just in case
|
||||
BREAK()
|
||||
ENDIF(OFIN_${target}_PathPrefix STREQUAL "/")
|
||||
ENDWHILE(NOT OFIN_${target}_PathPrefix STREQUAL "@rpath")
|
||||
|
||||
IF(OFIN_${target}_RpathFirstChild)
|
||||
SET(OFIN_${target}_PathPrefix ${OFIN_${target}_LibraryAbsolute})
|
||||
SET(OFIN_${target}_PathUnit )
|
||||
WHILE(NOT OFIN_${target}_PathUnit STREQUAL ${OFIN_${target}_RpathFirstChild})
|
||||
GET_FILENAME_COMPONENT(OFIN_${target}_PathUnit ${OFIN_${target}_PathPrefix} NAME)
|
||||
GET_FILENAME_COMPONENT(OFIN_${target}_PathPrefix ${OFIN_${target}_PathPrefix} PATH)
|
||||
|
||||
IF(NOT OFIN_${target}_PathPrefix)
|
||||
BREAK()
|
||||
ENDIF(NOT OFIN_${target}_PathPrefix)
|
||||
|
||||
IF(OFIN_${target}_PathPrefix STREQUAL "/")
|
||||
BREAK()
|
||||
ENDIF(OFIN_${target}_PathPrefix STREQUAL "/")
|
||||
ENDWHILE(NOT OFIN_${target}_PathUnit STREQUAL ${OFIN_${target}_RpathFirstChild})
|
||||
|
||||
IF(OFIN_${target}_PathPrefix)
|
||||
SET(OFIN_${target}_RPATHS ${OFIN_${target}_RPATHS} "${OFIN_${target}_PathPrefix}")
|
||||
ENDIF(OFIN_${target}_PathPrefix)
|
||||
ENDIF(OFIN_${target}_RpathFirstChild)
|
||||
|
||||
# Add the directory containing the library
|
||||
GET_FILENAME_COMPONENT(OFIN_${target}_LibraryAbsolutePath ${OFIN_${target}_LibraryAbsolute} PATH)
|
||||
SET(OFIN_${target}_RPATHS ${OFIN_${target}_RPATHS} "${OFIN_${target}_LibraryAbsolutePath}")
|
||||
|
||||
# Add paths specified as library search prefixes
|
||||
FOREACH(prefix ${CMAKE_PREFIX_PATH})
|
||||
SET(OFIN_${target}_RPATHS ${OFIN_${target}_RPATHS} "${CMAKE_PREFIX_PATH}")
|
||||
SET(OFIN_${target}_RPATHS ${OFIN_${target}_RPATHS} "${CMAKE_PREFIX_PATH}/lib")
|
||||
ENDFOREACH()
|
||||
|
||||
ELSEIF(NOT ${OFIN_${target}_LibraryInstallName} MATCHES "^[@/]") # just a relative path
|
||||
|
||||
# Replace the unqualified filename, if it appears, with the absolute location, either by directly changing the path or
|
||||
# by editing the rpath
|
||||
|
||||
# -- handle the case when the actual filename is baked in
|
||||
GET_FILENAME_COMPONENT(OFIN_${target}_LibraryFilename ${OFIN_${target}_LibraryAbsolute} NAME)
|
||||
ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD
|
||||
COMMAND install_name_tool
|
||||
ARGS -change
|
||||
${OFIN_${target}_LibraryFilename}
|
||||
${OFIN_${target}_LibraryAbsolute}
|
||||
$<TARGET_FILE:${target}>)
|
||||
|
||||
# -- handle the case when the install name is baked in
|
||||
ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD
|
||||
COMMAND install_name_tool
|
||||
ARGS -change
|
||||
${OFIN_${target}_LibraryInstallName}
|
||||
${OFIN_${target}_LibraryAbsolute}
|
||||
$<TARGET_FILE:${target}>)
|
||||
ENDIF()
|
||||
|
||||
ENDIF()
|
||||
ENDFOREACH(OFIN_${target}_Library)
|
||||
|
||||
# Add the collected rpaths
|
||||
IF(OFIN_${target}_RPATHS)
|
||||
LIST(REMOVE_DUPLICATES OFIN_${target}_RPATHS)
|
||||
|
||||
FOREACH(rpath ${OFIN_${target}_RPATHS})
|
||||
ADD_CUSTOM_COMMAND(TARGET ${target} POST_BUILD
|
||||
COMMAND bash
|
||||
ARGS -c "install_name_tool -add_rpath '${rpath}' '$<TARGET_FILE:${target}>' > /dev/null 2>&1 || true"
|
||||
VERBATIM)
|
||||
ENDFOREACH()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
ENDMACRO(OSX_FIX_DYLIB_REFERENCES)
|
||||
@ -1,8 +0,0 @@
|
||||
# This is a conda environment that can be used to compile libigl with CGAL on Windows
|
||||
# Only boost is required to be installed on the system, CGAL is automatically downloaded
|
||||
# by CMake and is built with libigl.
|
||||
name: libigl-cgal
|
||||
channels:
|
||||
- conda-forge
|
||||
dependencies:
|
||||
- boost-cpp=1.65.0
|
||||
@ -1,31 +0,0 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/libigl-export.cmake)
|
||||
|
||||
# Check if Eigen3 target is avaiable, if not try to locate it
|
||||
# with find_package.
|
||||
message(STATUS "[libigl] Looking for Eigen3")
|
||||
if (NOT TARGET Eigen3::Eigen)
|
||||
# Try if Eigen3 can be found with find_package
|
||||
find_package(Eigen3 CONFIG REQUIRED)
|
||||
endif()
|
||||
|
||||
|
||||
if (TARGET igl::core)
|
||||
if (TARGET Eigen3::Eigen)
|
||||
# Inject dependency
|
||||
set_target_properties(igl::core PROPERTIES INTERFACE_LINK_LIBRARIES Eigen3::Eigen)
|
||||
set(libigl_core_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (TARGET igl::common)
|
||||
if (TARGET Eigen3::Eigen)
|
||||
# Inject dependency
|
||||
set_target_properties(igl::common PROPERTIES INTERFACE_LINK_LIBRARIES Eigen3::Eigen)
|
||||
set(libigl_common_FOUND TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
check_required_components(libigl)
|
||||
|
||||
577
src/external/libigl-2.3.0/cmake/libigl.cmake
vendored
577
src/external/libigl-2.3.0/cmake/libigl.cmake
vendored
@ -1,577 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
# https://github.com/libigl/libigl/issues/751
|
||||
# http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160425/351643.html
|
||||
if(APPLE)
|
||||
if(NOT CMAKE_LIBTOOL)
|
||||
find_program(CMAKE_LIBTOOL NAMES libtool)
|
||||
endif()
|
||||
if(CMAKE_LIBTOOL)
|
||||
set(CMAKE_LIBTOOL ${CMAKE_LIBTOOL} CACHE PATH "libtool executable")
|
||||
message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")
|
||||
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
foreach(lang ${languages})
|
||||
# Added -c
|
||||
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
|
||||
"${CMAKE_LIBTOOL} -c -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
### Available options ###
|
||||
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF)
|
||||
option(LIBIGL_WITH_CGAL "Use CGAL" OFF)
|
||||
option(LIBIGL_WITH_COMISO "Use CoMiso" OFF)
|
||||
option(LIBIGL_WITH_CORK "Use Cork" OFF)
|
||||
option(LIBIGL_WITH_EMBREE "Use Embree" OFF)
|
||||
option(LIBIGL_WITH_MATLAB "Use Matlab" OFF)
|
||||
option(LIBIGL_WITH_MOSEK "Use MOSEK" OFF)
|
||||
option(LIBIGL_WITH_OPENGL "Use OpenGL" OFF)
|
||||
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" OFF)
|
||||
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" OFF)
|
||||
option(LIBIGL_WITH_PNG "Use PNG" OFF)
|
||||
option(LIBIGL_WITH_TETGEN "Use Tetgen" OFF)
|
||||
option(LIBIGL_WITH_TRIANGLE "Use Triangle" OFF)
|
||||
option(LIBIGL_WITH_PREDICATES "Use exact predicates" OFF)
|
||||
option(LIBIGL_WITH_XML "Use XML" OFF)
|
||||
option(LIBIGL_WITHOUT_COPYLEFT "Disable Copyleft libraries" OFF)
|
||||
option(LIBIGL_EXPORT_TARGETS "Export libigl CMake targets" OFF)
|
||||
|
||||
if(LIBIGL_BUILD_PYTHON)
|
||||
message(FATAL_ERROR "Python bindings have been removed in this version. Please use an older version of libigl, or wait for the new bindings to be released.")
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
|
||||
### Configuration
|
||||
set(LIBIGL_ROOT "${CMAKE_CURRENT_LIST_DIR}/..")
|
||||
set(LIBIGL_SOURCE_DIR "${LIBIGL_ROOT}/include")
|
||||
set(LIBIGL_EXTERNAL "${LIBIGL_ROOT}/external")
|
||||
|
||||
# Dependencies are linked as INTERFACE targets unless libigl is compiled as a static library
|
||||
if(LIBIGL_USE_STATIC_LIBRARY)
|
||||
set(IGL_SCOPE PUBLIC)
|
||||
else()
|
||||
set(IGL_SCOPE INTERFACE)
|
||||
endif()
|
||||
|
||||
# Download and update 3rdparty libraries
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include(LibiglDownloadExternal)
|
||||
|
||||
# Provides igl_set_folders() to set folders for Visual Studio/Xcode
|
||||
include(LibiglFolders)
|
||||
|
||||
################################################################################
|
||||
### IGL Common
|
||||
################################################################################
|
||||
|
||||
add_library(igl_common INTERFACE)
|
||||
target_include_directories(igl_common SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${LIBIGL_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
# Export igl_common as igl::common
|
||||
set_property(TARGET igl_common PROPERTY EXPORT_NAME igl::common)
|
||||
if(LIBIGL_USE_STATIC_LIBRARY)
|
||||
target_compile_definitions(igl_common INTERFACE -DIGL_STATIC_LIBRARY)
|
||||
endif()
|
||||
|
||||
# Transitive C++11 flags
|
||||
include(CXXFeatures)
|
||||
target_compile_features(igl_common INTERFACE ${CXX11_FEATURES})
|
||||
|
||||
# Other compilation flags
|
||||
if(MSVC)
|
||||
# Enable parallel compilation for Visual Studio
|
||||
target_compile_options(igl_common INTERFACE /MP /bigobj)
|
||||
target_compile_definitions(igl_common INTERFACE -DNOMINMAX)
|
||||
endif()
|
||||
|
||||
# Controls whether to use the static MSVC runtime or not
|
||||
include(LibiglWindows)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# Generate position independent code
|
||||
set_target_properties(igl_common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
if(UNIX AND NOT HUNTER_ENABLED)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
endif()
|
||||
|
||||
if(HUNTER_ENABLED)
|
||||
hunter_add_package(Eigen)
|
||||
find_package(Eigen3 CONFIG REQUIRED)
|
||||
endif()
|
||||
|
||||
# Eigen
|
||||
if(NOT TARGET Eigen3::Eigen)
|
||||
igl_download_eigen()
|
||||
add_library(igl_eigen INTERFACE)
|
||||
target_include_directories(igl_eigen SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${LIBIGL_EXTERNAL}/eigen>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
set_property(TARGET igl_eigen PROPERTY EXPORT_NAME Eigen3::Eigen)
|
||||
add_library(Eigen3::Eigen ALIAS igl_eigen)
|
||||
endif()
|
||||
target_link_libraries(igl_common INTERFACE Eigen3::Eigen)
|
||||
|
||||
# C++11 Thread library
|
||||
find_package(Threads REQUIRED)
|
||||
target_link_libraries(igl_common INTERFACE ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
################################################################################
|
||||
|
||||
## CGAL dependencies on Windows: GMP & MPFR
|
||||
function(igl_download_cgal_deps)
|
||||
if(WIN32)
|
||||
igl_download_project(gmp
|
||||
URL https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/GMP/5.0.1/gmp-all-CGAL-3.9.zip
|
||||
URL_MD5 508c1292319c832609329116a8234c9f
|
||||
)
|
||||
igl_download_project(mpfr
|
||||
URL https://cgal.geometryfactory.com/CGAL/precompiled_libs/auxiliary/x64/MPFR/3.0.0/mpfr-all-CGAL-3.9.zip
|
||||
URL_MD5 48840454eef0ff18730050c05028734b
|
||||
)
|
||||
set(ENV{GMP_DIR} "${LIBIGL_EXTERNAL}/gmp")
|
||||
set(ENV{MPFR_DIR} "${LIBIGL_EXTERNAL}/mpfr")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
|
||||
function(compile_igl_module module_dir)
|
||||
string(REPLACE "/" "_" module_name "${module_dir}")
|
||||
if(module_name STREQUAL "core")
|
||||
set(module_libname "igl")
|
||||
else()
|
||||
set(module_libname "igl_${module_name}")
|
||||
endif()
|
||||
if(LIBIGL_USE_STATIC_LIBRARY)
|
||||
file(GLOB SOURCES_IGL_${module_name}
|
||||
"${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.cpp"
|
||||
"${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.h*"
|
||||
)
|
||||
if(NOT LIBIGL_WITHOUT_COPYLEFT)
|
||||
file(GLOB COPYLEFT_SOURCES_IGL_${module_name}
|
||||
"${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.cpp"
|
||||
"${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.h*"
|
||||
)
|
||||
list(APPEND SOURCES_IGL_${module_name} ${COPYLEFT_SOURCES_IGL_${module_name}})
|
||||
endif()
|
||||
add_library(${module_libname} STATIC ${SOURCES_IGL_${module_name}} ${ARGN})
|
||||
if(MSVC)
|
||||
# Silencing some compile warnings
|
||||
target_compile_options(${module_libname} PRIVATE
|
||||
# Type conversion warnings. These can be fixed with some effort and possibly more verbose code.
|
||||
/wd4267 # conversion from 'size_t' to 'type', possible loss of data
|
||||
/wd4244 # conversion from 'type1' to 'type2', possible loss of data
|
||||
/wd4018 # signed/unsigned mismatch
|
||||
/wd4305 # truncation from 'double' to 'float'
|
||||
# This one is from template instantiations generated by autoexplicit.sh:
|
||||
/wd4667 # no function template defined that matches forced instantiation ()
|
||||
# This one is easy to fix, just need to switch to safe version of C functions
|
||||
/wd4996 # this function or variable may be unsafe
|
||||
# This one is when using bools in adjacency matrices
|
||||
/wd4804 #'+=': unsafe use of type 'bool' in operation
|
||||
)
|
||||
endif()
|
||||
else()
|
||||
add_library(${module_libname} INTERFACE)
|
||||
endif()
|
||||
|
||||
target_link_libraries(${module_libname} ${IGL_SCOPE} igl_common)
|
||||
if(NOT module_name STREQUAL "core")
|
||||
target_link_libraries(${module_libname} ${IGL_SCOPE} igl)
|
||||
endif()
|
||||
|
||||
# Alias target because it looks nicer
|
||||
message(STATUS "Creating target: igl::${module_name} (${module_libname})")
|
||||
add_library(igl::${module_name} ALIAS ${module_libname})
|
||||
# Export as igl::${module_name}
|
||||
set_property(TARGET ${module_libname} PROPERTY EXPORT_NAME igl::${module_name})
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
### IGL Core
|
||||
################################################################################
|
||||
|
||||
if(LIBIGL_USE_STATIC_LIBRARY)
|
||||
file(GLOB SOURCES_IGL
|
||||
"${LIBIGL_SOURCE_DIR}/igl/*.cpp"
|
||||
"${LIBIGL_SOURCE_DIR}/igl/*.h*"
|
||||
"${LIBIGL_SOURCE_DIR}/igl/copyleft/*.cpp"
|
||||
"${LIBIGL_SOURCE_DIR}/igl/copyleft/*.h*"
|
||||
)
|
||||
endif()
|
||||
compile_igl_module("core" ${SOURCES_IGL})
|
||||
|
||||
################################################################################
|
||||
### Download the python part ###
|
||||
if(LIBIGL_WITH_PYTHON)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the CGAL part ###
|
||||
if(LIBIGL_WITH_CGAL)
|
||||
# Try to find the CGAL library
|
||||
# CGAL Core is needed for
|
||||
# `Exact_predicates_exact_constructions_kernel_with_sqrt`
|
||||
if(NOT TARGET CGAL::CGAL)
|
||||
set(CGAL_DIR "${LIBIGL_EXTERNAL}/cgal")
|
||||
igl_download_cgal()
|
||||
igl_download_cgal_deps()
|
||||
message("BOOST_ROOT: ${BOOST_ROOT}")
|
||||
if(EXISTS ${LIBIGL_EXTERNAL}/boost)
|
||||
set(BOOST_ROOT "${LIBIGL_EXTERNAL}/boost")
|
||||
endif()
|
||||
option(CGAL_Boost_USE_STATIC_LIBS "Use static Boost libs with CGAL" ON)
|
||||
|
||||
find_package(CGAL CONFIG COMPONENTS Core PATHS ${CGAL_DIR} NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
# If CGAL has been found, then build the libigl module
|
||||
if(TARGET CGAL::CGAL AND TARGET CGAL::CGAL_Core)
|
||||
compile_igl_module("cgal")
|
||||
target_link_libraries(igl_cgal ${IGL_SCOPE} CGAL::CGAL CGAL::CGAL_Core)
|
||||
else()
|
||||
message(FATAL_ERROR "Could not define CGAL::CGAL and CGAL::CGAL_Core.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Helper function for `igl_copy_cgal_dll()`
|
||||
function(igl_copy_imported_dll src_target dst_target)
|
||||
get_target_property(other_libs ${src_target} INTERFACE_LINK_LIBRARIES)
|
||||
set(locations)
|
||||
list(APPEND locations ${main_lib} ${other_libs})
|
||||
foreach(location ${locations})
|
||||
string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${location})
|
||||
set(location "${CMAKE_MATCH_1}.dll")
|
||||
if(EXISTS "${location}" AND location MATCHES "^.*\\.dll$")
|
||||
add_custom_command(TARGET ${dst_target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${location}" $<TARGET_FILE_DIR:${dst_target}>)
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# Convenient functions to copy CGAL dlls into a target (executable) destination folder (for Windows)
|
||||
function(igl_copy_cgal_dll target)
|
||||
if(WIN32 AND LIBIGL_WITH_CGAL)
|
||||
igl_copy_imported_dll(CGAL::CGAL ${target})
|
||||
igl_copy_imported_dll(CGAL::CGAL_Core ${target})
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
### Compile the CoMISo part ###
|
||||
# NOTE: this cmakefile works only with the
|
||||
# comiso available here: https://github.com/libigl/CoMISo
|
||||
if(LIBIGL_WITH_COMISO)
|
||||
compile_igl_module("comiso")
|
||||
if(NOT TARGET CoMISo)
|
||||
igl_download_comiso()
|
||||
add_subdirectory("${LIBIGL_EXTERNAL}/CoMISo" CoMISo)
|
||||
endif()
|
||||
target_link_libraries(igl_comiso ${IGL_SCOPE} CoMISo)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the cork part ###
|
||||
if(LIBIGL_WITH_CORK)
|
||||
set(CORK_DIR "${LIBIGL_EXTERNAL}/cork")
|
||||
if(NOT TARGET cork)
|
||||
# call this "lib-cork" instead of "cork", otherwise cmake gets confused about
|
||||
# "cork" executable
|
||||
igl_download_cork()
|
||||
add_subdirectory("${CORK_DIR}" "lib-cork")
|
||||
endif()
|
||||
compile_igl_module("cork")
|
||||
target_include_directories(igl_cork ${IGL_SCOPE} cork)
|
||||
target_include_directories(igl_cork ${IGL_SCOPE} "${CORK_DIR}/src")
|
||||
target_link_libraries(igl_cork ${IGL_SCOPE} cork)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the embree part ###
|
||||
if(LIBIGL_WITH_EMBREE)
|
||||
set(EMBREE_DIR "${LIBIGL_EXTERNAL}/embree")
|
||||
|
||||
if(NOT TARGET embree)
|
||||
igl_download_embree()
|
||||
|
||||
# Note: On macOS, building embree as a static lib can only be done with a single ISA target.
|
||||
set(EMBREE_MAX_ISA "DEFAULT" CACHE STRING "Selects highest ISA to support.")
|
||||
set(EMBREE_TESTING_INTENSITY 0 CACHE STRING "")
|
||||
set(EMBREE_ISPC_SUPPORT OFF CACHE BOOL " ")
|
||||
set(EMBREE_TASKING_SYSTEM "INTERNAL" CACHE BOOL " ")
|
||||
set(EMBREE_TUTORIALS OFF CACHE BOOL " ")
|
||||
set(EMBREE_STATIC_LIB ON CACHE BOOL " ")
|
||||
if(MSVC)
|
||||
set(EMBREE_STATIC_RUNTIME ${IGL_STATIC_RUNTIME} CACHE BOOL "Use the static version of the C/C++ runtime library.")
|
||||
endif()
|
||||
|
||||
add_subdirectory("${EMBREE_DIR}" "embree" EXCLUDE_FROM_ALL)
|
||||
endif()
|
||||
|
||||
compile_igl_module("embree")
|
||||
target_link_libraries(igl_embree ${IGL_SCOPE} embree)
|
||||
target_include_directories(igl_embree ${IGL_SCOPE} ${EMBREE_DIR}/include)
|
||||
target_compile_definitions(igl_embree ${IGL_SCOPE} -DEMBREE_STATIC_LIB)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the matlab part ###
|
||||
if(LIBIGL_WITH_MATLAB)
|
||||
find_package(Matlab REQUIRED COMPONENTS MEX_COMPILER MX_LIBRARY ENG_LIBRARY MAT_LIBRARY)
|
||||
compile_igl_module("matlab")
|
||||
target_link_libraries(igl_matlab ${IGL_SCOPE} ${Matlab_LIBRARIES})
|
||||
target_include_directories(igl_matlab ${IGL_SCOPE} ${Matlab_INCLUDE_DIRS})
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the mosek part ###
|
||||
if(LIBIGL_WITH_MOSEK)
|
||||
find_package(MOSEK REQUIRED)
|
||||
compile_igl_module("mosek")
|
||||
target_link_libraries(igl_mosek ${IGL_SCOPE} ${MOSEK_LIBRARIES})
|
||||
target_include_directories(igl_mosek ${IGL_SCOPE} ${MOSEK_INCLUDE_DIRS})
|
||||
target_compile_definitions(igl_mosek ${IGL_SCOPE} -DLIBIGL_WITH_MOSEK)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the opengl part ###
|
||||
if(LIBIGL_WITH_OPENGL)
|
||||
# OpenGL module
|
||||
compile_igl_module("opengl")
|
||||
|
||||
# OpenGL library
|
||||
if (NOT CMAKE_VERSION VERSION_LESS "3.11")
|
||||
cmake_policy(SET CMP0072 NEW)
|
||||
endif()
|
||||
find_package(OpenGL REQUIRED)
|
||||
if(TARGET OpenGL::GL)
|
||||
target_link_libraries(igl_opengl ${IGL_SCOPE} OpenGL::GL)
|
||||
else()
|
||||
target_link_libraries(igl_opengl ${IGL_SCOPE} ${OPENGL_gl_LIBRARY})
|
||||
target_include_directories(igl_opengl SYSTEM ${IGL_SCOPE} ${OPENGL_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
# glad module
|
||||
if(NOT TARGET glad)
|
||||
igl_download_glad()
|
||||
add_subdirectory(${LIBIGL_EXTERNAL}/glad glad)
|
||||
endif()
|
||||
target_link_libraries(igl_opengl ${IGL_SCOPE} glad)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the GLFW part ###
|
||||
if(LIBIGL_WITH_OPENGL_GLFW)
|
||||
if(TARGET igl::opengl)
|
||||
# GLFW module
|
||||
compile_igl_module("opengl/glfw")
|
||||
if(NOT TARGET glfw)
|
||||
igl_download_glfw()
|
||||
option(GLFW_BUILD_EXAMPLES "Build the GLFW example programs" OFF)
|
||||
option(GLFW_BUILD_TESTS "Build the GLFW test programs" OFF)
|
||||
option(GLFW_BUILD_DOCS "Build the GLFW documentation" OFF)
|
||||
option(GLFW_INSTALL "Generate installation target" OFF)
|
||||
if(IGL_STATIC_RUNTIME)
|
||||
set(USE_MSVC_RUNTIME_LIBRARY_DLL OFF CACHE BOOL "Use MSVC runtime library DLL" FORCE)
|
||||
else()
|
||||
set(USE_MSVC_RUNTIME_LIBRARY_DLL ON CACHE BOOL "Use MSVC runtime library DLL" FORCE)
|
||||
endif()
|
||||
add_subdirectory(${LIBIGL_EXTERNAL}/glfw glfw)
|
||||
endif()
|
||||
target_link_libraries(igl_opengl_glfw ${IGL_SCOPE} igl_opengl glfw)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the ImGui part ###
|
||||
if(LIBIGL_WITH_OPENGL_GLFW_IMGUI)
|
||||
if(TARGET igl::opengl_glfw)
|
||||
# ImGui module
|
||||
compile_igl_module("opengl/glfw/imgui")
|
||||
if(NOT TARGET imgui)
|
||||
igl_download_imgui()
|
||||
add_subdirectory(${LIBIGL_EXTERNAL}/libigl-imgui imgui)
|
||||
endif()
|
||||
if(NOT TARGET imguizmo)
|
||||
igl_download_imguizmo()
|
||||
add_library(imguizmo ${LIBIGL_EXTERNAL}/imguizmo/ImGuizmo.cpp ${LIBIGL_EXTERNAL}/imguizmo/ImGuizmo.h)
|
||||
target_compile_features(imguizmo PUBLIC cxx_std_11)
|
||||
target_link_libraries(imguizmo PUBLIC imgui)
|
||||
endif()
|
||||
target_link_libraries(igl_opengl_glfw_imgui ${IGL_SCOPE} igl_opengl_glfw imgui imguizmo)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the png part ###
|
||||
if(LIBIGL_WITH_PNG)
|
||||
# png/ module is anomalous because it also depends on opengl it really should
|
||||
# be moved into the opengl/ directory and namespace ...
|
||||
if(TARGET igl_opengl)
|
||||
if(NOT TARGET stb_image)
|
||||
igl_download_stb()
|
||||
add_subdirectory(${LIBIGL_EXTERNAL}/stb stb_image)
|
||||
endif()
|
||||
compile_igl_module("png" "")
|
||||
target_link_libraries(igl_png ${IGL_SCOPE} igl_stb_image igl_opengl)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the tetgen part ###
|
||||
if(LIBIGL_WITH_TETGEN)
|
||||
set(TETGEN_DIR "${LIBIGL_EXTERNAL}/tetgen")
|
||||
if(NOT TARGET tetgen)
|
||||
igl_download_tetgen()
|
||||
add_subdirectory("${TETGEN_DIR}" "tetgen")
|
||||
endif()
|
||||
compile_igl_module("tetgen")
|
||||
target_link_libraries(igl_tetgen ${IGL_SCOPE} tetgen)
|
||||
target_include_directories(igl_tetgen ${IGL_SCOPE} ${TETGEN_DIR})
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the triangle part ###
|
||||
if(LIBIGL_WITH_TRIANGLE)
|
||||
set(TRIANGLE_DIR "${LIBIGL_EXTERNAL}/triangle")
|
||||
if(NOT TARGET triangle)
|
||||
igl_download_triangle()
|
||||
add_subdirectory("${TRIANGLE_DIR}" "triangle")
|
||||
endif()
|
||||
compile_igl_module("triangle")
|
||||
target_link_libraries(igl_triangle ${IGL_SCOPE} triangle)
|
||||
target_include_directories(igl_triangle ${IGL_SCOPE} ${TRIANGLE_DIR})
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the predicates part ###
|
||||
if(LIBIGL_WITH_PREDICATES)
|
||||
set(PREDICATES_DIR "${LIBIGL_EXTERNAL}/predicates")
|
||||
if(NOT TARGET predicates)
|
||||
igl_download_predicates()
|
||||
add_subdirectory("${PREDICATES_DIR}" "predicates")
|
||||
endif()
|
||||
compile_igl_module("predicates")
|
||||
target_link_libraries(igl_predicates ${IGL_SCOPE} predicates)
|
||||
target_include_directories(igl_predicates ${IGL_SCOPE} ${PREDICATES_DIR})
|
||||
target_compile_definitions(igl_predicates ${IGL_SCOPE} -DLIBIGL_WITH_PREDICATES)
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the xml part ###
|
||||
if(LIBIGL_WITH_XML)
|
||||
set(TINYXML2_DIR "${LIBIGL_EXTERNAL}/tinyxml2")
|
||||
if(NOT TARGET tinyxml2)
|
||||
igl_download_tinyxml2()
|
||||
add_library(tinyxml2 STATIC ${TINYXML2_DIR}/tinyxml2.cpp ${TINYXML2_DIR}/tinyxml2.h)
|
||||
target_include_directories(tinyxml2 PUBLIC ${TINYXML2_DIR})
|
||||
set_target_properties(tinyxml2 PROPERTIES
|
||||
COMPILE_DEFINITIONS "TINYXML2_EXPORT"
|
||||
VERSION "3.0.0"
|
||||
SOVERSION "3")
|
||||
endif()
|
||||
compile_igl_module("xml")
|
||||
target_link_libraries(igl_xml ${IGL_SCOPE} tinyxml2)
|
||||
target_include_directories(igl_xml ${IGL_SCOPE} ${TINYXML2_DIR})
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Install and export all modules
|
||||
|
||||
if(NOT LIBIGL_EXPORT_TARGETS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
function(install_dir_files dir_name)
|
||||
if (dir_name STREQUAL "core")
|
||||
set(subpath "")
|
||||
else()
|
||||
set(subpath "/${dir_name}")
|
||||
endif()
|
||||
|
||||
file(GLOB public_headers
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.h
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.hpp
|
||||
)
|
||||
|
||||
set(files_to_install ${public_headers})
|
||||
|
||||
if(NOT LIBIGL_USE_STATIC_LIBRARY)
|
||||
file(GLOB public_sources
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.cpp
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.c
|
||||
)
|
||||
endif()
|
||||
list(APPEND files_to_install ${public_sources})
|
||||
|
||||
install(
|
||||
FILES ${files_to_install}
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/igl${subpath}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
if(TARGET igl_eigen)
|
||||
set(IGL_EIGEN igl_eigen)
|
||||
else()
|
||||
set(IGL_EIGEN)
|
||||
message(WARNING "Trying to export igl targets while using an imported target for Eigen.")
|
||||
endif()
|
||||
|
||||
# Install and export core library
|
||||
install(
|
||||
TARGETS
|
||||
igl
|
||||
igl_common
|
||||
${IGL_EIGEN}
|
||||
EXPORT igl-export
|
||||
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
)
|
||||
export(
|
||||
TARGETS
|
||||
igl
|
||||
igl_common
|
||||
${IGL_EIGEN}
|
||||
FILE libigl-export.cmake
|
||||
)
|
||||
|
||||
# Install headers for core library
|
||||
install_dir_files(core)
|
||||
install_dir_files(copyleft)
|
||||
|
||||
# Write package configuration file
|
||||
configure_package_config_file(
|
||||
${CMAKE_CURRENT_LIST_DIR}/libigl-config.cmake.in
|
||||
${CMAKE_BINARY_DIR}/libigl-config.cmake
|
||||
INSTALL_DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/libigl/cmake
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
${CMAKE_BINARY_DIR}/libigl-config.cmake
|
||||
DESTINATION
|
||||
${CMAKE_INSTALL_DATADIR}/libigl/cmake
|
||||
)
|
||||
|
||||
# Write export file
|
||||
export(EXPORT igl-export
|
||||
FILE "${CMAKE_BINARY_DIR}/libigl-export.cmake"
|
||||
)
|
||||
install(EXPORT igl-export DESTINATION ${CMAKE_INSTALL_DATADIR}/libigl/cmake FILE libigl-export.cmake)
|
||||
|
||||
|
||||
export(PACKAGE libigl)
|
||||
|
||||
1070
src/external/libigl-2.3.0/include/igl/AABB.cpp
vendored
1070
src/external/libigl-2.3.0/include/igl/AABB.cpp
vendored
File diff suppressed because it is too large
Load Diff
413
src/external/libigl-2.3.0/include/igl/AABB.h
vendored
413
src/external/libigl-2.3.0/include/igl/AABB.h
vendored
@ -1,413 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_AABB_H
|
||||
#define IGL_AABB_H
|
||||
|
||||
#include "Hit.h"
|
||||
#include "igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Geometry>
|
||||
#include <vector>
|
||||
namespace igl
|
||||
{
|
||||
// Implementation of semi-general purpose axis-aligned bounding box hierarchy.
|
||||
// The mesh (V,Ele) is stored and managed by the caller and each routine here
|
||||
// simply takes it as references (it better not change between calls).
|
||||
//
|
||||
// It's a little annoying that the Dimension is a template parameter and not
|
||||
// picked up at run time from V. This leads to duplicated code for 2d/3d (up to
|
||||
// dim).
|
||||
template <typename DerivedV, int DIM>
|
||||
class AABB
|
||||
{
|
||||
public:
|
||||
typedef typename DerivedV::Scalar Scalar;
|
||||
typedef Eigen::Matrix<Scalar,1,DIM> RowVectorDIMS;
|
||||
typedef Eigen::Matrix<Scalar,DIM,1> VectorDIMS;
|
||||
typedef Eigen::Matrix<Scalar,Eigen::Dynamic,DIM> MatrixXDIMS;
|
||||
// Shared pointers are slower...
|
||||
AABB * m_left;
|
||||
AABB * m_right;
|
||||
Eigen::AlignedBox<Scalar,DIM> m_box;
|
||||
// -1 non-leaf
|
||||
int m_primitive;
|
||||
//Scalar m_low_sqr_d;
|
||||
//int m_depth;
|
||||
AABB():
|
||||
m_left(NULL), m_right(NULL),
|
||||
m_box(), m_primitive(-1)
|
||||
//m_low_sqr_d(std::numeric_limits<double>::infinity()),
|
||||
//m_depth(0)
|
||||
{}
|
||||
// http://stackoverflow.com/a/3279550/148668
|
||||
AABB(const AABB& other):
|
||||
m_left(other.m_left ? new AABB(*other.m_left) : NULL),
|
||||
m_right(other.m_right ? new AABB(*other.m_right) : NULL),
|
||||
m_box(other.m_box),
|
||||
m_primitive(other.m_primitive)
|
||||
//m_low_sqr_d(other.m_low_sqr_d),
|
||||
//m_depth(std::max(
|
||||
// m_left ? m_left->m_depth + 1 : 0,
|
||||
// m_right ? m_right->m_depth + 1 : 0))
|
||||
{
|
||||
}
|
||||
// copy-swap idiom
|
||||
friend void swap(AABB& first, AABB& second)
|
||||
{
|
||||
// Enable ADL
|
||||
using std::swap;
|
||||
swap(first.m_left,second.m_left);
|
||||
swap(first.m_right,second.m_right);
|
||||
swap(first.m_box,second.m_box);
|
||||
swap(first.m_primitive,second.m_primitive);
|
||||
//swap(first.m_low_sqr_d,second.m_low_sqr_d);
|
||||
//swap(first.m_depth,second.m_depth);
|
||||
}
|
||||
// Pass-by-value (aka copy)
|
||||
AABB& operator=(AABB other)
|
||||
{
|
||||
swap(*this,other);
|
||||
return *this;
|
||||
}
|
||||
AABB(AABB&& other):
|
||||
// initialize via default constructor
|
||||
AABB()
|
||||
{
|
||||
swap(*this,other);
|
||||
}
|
||||
// Seems like there should have been an elegant solution to this using
|
||||
// the copy-swap idiom above:
|
||||
IGL_INLINE void deinit()
|
||||
{
|
||||
m_primitive = -1;
|
||||
m_box = Eigen::AlignedBox<Scalar,DIM>();
|
||||
delete m_left;
|
||||
m_left = NULL;
|
||||
delete m_right;
|
||||
m_right = NULL;
|
||||
}
|
||||
~AABB()
|
||||
{
|
||||
deinit();
|
||||
}
|
||||
// Build an Axis-Aligned Bounding Box tree for a given mesh and given
|
||||
// serialization of a previous AABB tree.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of mesh vertex positions.
|
||||
// Ele #Ele by dim+1 list of mesh indices into #V.
|
||||
// bb_mins max_tree by dim list of bounding box min corner positions
|
||||
// bb_maxs max_tree by dim list of bounding box max corner positions
|
||||
// elements max_tree list of element or (not leaf id) indices into Ele
|
||||
// i recursive call index {0}
|
||||
template <
|
||||
typename DerivedEle,
|
||||
typename Derivedbb_mins,
|
||||
typename Derivedbb_maxs,
|
||||
typename Derivedelements>
|
||||
IGL_INLINE void init(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const Eigen::MatrixBase<Derivedbb_mins> & bb_mins,
|
||||
const Eigen::MatrixBase<Derivedbb_maxs> & bb_maxs,
|
||||
const Eigen::MatrixBase<Derivedelements> & elements,
|
||||
const int i = 0);
|
||||
// Wrapper for root with empty serialization
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE void init(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele);
|
||||
// Build an Axis-Aligned Bounding Box tree for a given mesh.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of mesh vertex positions.
|
||||
// Ele #Ele by dim+1 list of mesh indices into #V.
|
||||
// SI #Ele by dim list revealing for each coordinate where Ele's
|
||||
// barycenters would be sorted: SI(e,d) = i --> the dth coordinate of
|
||||
// the barycenter of the eth element would be placed at position i in a
|
||||
// sorted list.
|
||||
// I #I list of indices into Ele of elements to include (for recursive
|
||||
// calls)
|
||||
//
|
||||
template <typename DerivedEle, typename DerivedSI, typename DerivedI>
|
||||
IGL_INLINE void init(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const Eigen::MatrixBase<DerivedSI> & SI,
|
||||
const Eigen::MatrixBase<DerivedI>& I);
|
||||
// Return whether at leaf node
|
||||
IGL_INLINE bool is_leaf() const;
|
||||
// Find the indices of elements containing given point: this makes sense
|
||||
// when Ele is a co-dimension 0 simplex (tets in 3D, triangles in 2D).
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of mesh vertex positions. **Should be same as used to
|
||||
// construct mesh.**
|
||||
// Ele #Ele by dim+1 list of mesh indices into #V. **Should be same as used to
|
||||
// construct mesh.**
|
||||
// q dim row-vector query position
|
||||
// first whether to only return first element containing q
|
||||
// Returns:
|
||||
// list of indices of elements containing q
|
||||
template <typename DerivedEle, typename Derivedq>
|
||||
IGL_INLINE std::vector<int> find(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const Eigen::MatrixBase<Derivedq> & q,
|
||||
const bool first=false) const;
|
||||
|
||||
// If number of elements m then total tree size should be 2*h where h is
|
||||
// the deepest depth 2^ceil(log(#Ele*2-1))
|
||||
IGL_INLINE int subtree_size() const;
|
||||
|
||||
// Serialize this class into 3 arrays (so we can pass it pack to matlab)
|
||||
//
|
||||
// Outputs:
|
||||
// bb_mins max_tree by dim list of bounding box min corner positions
|
||||
// bb_maxs max_tree by dim list of bounding box max corner positions
|
||||
// elements max_tree list of element or (not leaf id) indices into Ele
|
||||
// i recursive call index into these arrays {0}
|
||||
template <
|
||||
typename Derivedbb_mins,
|
||||
typename Derivedbb_maxs,
|
||||
typename Derivedelements>
|
||||
IGL_INLINE void serialize(
|
||||
Eigen::PlainObjectBase<Derivedbb_mins> & bb_mins,
|
||||
Eigen::PlainObjectBase<Derivedbb_maxs> & bb_maxs,
|
||||
Eigen::PlainObjectBase<Derivedelements> & elements,
|
||||
const int i = 0) const;
|
||||
// Compute squared distance to a query point
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of vertex positions
|
||||
// Ele #Ele by dim list of simplex indices
|
||||
// p dim-long query point
|
||||
// Outputs:
|
||||
// i facet index corresponding to smallest distances
|
||||
// c closest point
|
||||
// Returns squared distance
|
||||
//
|
||||
// Known bugs: currently assumes Elements are triangles regardless of
|
||||
// dimension.
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE Scalar squared_distance(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & p,
|
||||
int & i,
|
||||
Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
|
||||
//private:
|
||||
// Compute squared distance to a query point
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of vertex positions
|
||||
// Ele #Ele by dim list of simplex indices
|
||||
// p dim-long query point
|
||||
// low_sqr_d lower bound on squared distance, specified maximum squared
|
||||
// distance
|
||||
// up_sqr_d current upper bounded on squared distance, current minimum
|
||||
// squared distance (only consider distances less than this), see
|
||||
// output.
|
||||
// Outputs:
|
||||
// up_sqr_d updated current minimum squared distance
|
||||
// i facet index corresponding to smallest distances
|
||||
// c closest point
|
||||
// Returns squared distance
|
||||
//
|
||||
// Known bugs: currently assumes Elements are triangles regardless of
|
||||
// dimension.
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE Scalar squared_distance(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & p,
|
||||
const Scalar low_sqr_d,
|
||||
const Scalar up_sqr_d,
|
||||
int & i,
|
||||
Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
|
||||
// Default low_sqr_d
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE Scalar squared_distance(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & p,
|
||||
const Scalar up_sqr_d,
|
||||
int & i,
|
||||
Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
|
||||
// All hits
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE bool intersect_ray(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & origin,
|
||||
const RowVectorDIMS & dir,
|
||||
std::vector<igl::Hit> & hits) const;
|
||||
// First hit
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE bool intersect_ray(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & origin,
|
||||
const RowVectorDIMS & dir,
|
||||
igl::Hit & hit) const;
|
||||
//private:
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE bool intersect_ray(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & origin,
|
||||
const RowVectorDIMS & dir,
|
||||
const Scalar min_t,
|
||||
igl::Hit & hit) const;
|
||||
|
||||
|
||||
public:
|
||||
// Compute the squared distance from all query points in P to the
|
||||
// _closest_ points on the primitives stored in the AABB hierarchy for
|
||||
// the mesh (V,Ele).
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of vertex positions
|
||||
// Ele #Ele by dim list of simplex indices
|
||||
// P #P by dim list of query points
|
||||
// Outputs:
|
||||
// sqrD #P list of squared distances
|
||||
// I #P list of indices into Ele of closest primitives
|
||||
// C #P by dim list of closest points
|
||||
template <
|
||||
typename DerivedEle,
|
||||
typename DerivedP,
|
||||
typename DerivedsqrD,
|
||||
typename DerivedI,
|
||||
typename DerivedC>
|
||||
IGL_INLINE void squared_distance(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
|
||||
Eigen::PlainObjectBase<DerivedI> & I,
|
||||
Eigen::PlainObjectBase<DerivedC> & C) const;
|
||||
|
||||
// Compute the squared distance from all query points in P already stored
|
||||
// in its own AABB hierarchy to the _closest_ points on the primitives
|
||||
// stored in the AABB hierarchy for the mesh (V,Ele).
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of vertex positions
|
||||
// Ele #Ele by dim list of simplex indices
|
||||
// other AABB hierarchy of another set of primitives (must be points)
|
||||
// other_V #other_V by dim list of query points
|
||||
// other_Ele #other_Ele by ss list of simplex indices into other_V
|
||||
// (must be simple list of points: ss == 1)
|
||||
// Outputs:
|
||||
// sqrD #P list of squared distances
|
||||
// I #P list of indices into Ele of closest primitives
|
||||
// C #P by dim list of closest points
|
||||
template <
|
||||
typename DerivedEle,
|
||||
typename Derivedother_V,
|
||||
typename Derivedother_Ele,
|
||||
typename DerivedsqrD,
|
||||
typename DerivedI,
|
||||
typename DerivedC>
|
||||
IGL_INLINE void squared_distance(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const AABB<Derivedother_V,DIM> & other,
|
||||
const Eigen::MatrixBase<Derivedother_V> & other_V,
|
||||
const Eigen::MatrixBase<Derivedother_Ele> & other_Ele,
|
||||
Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
|
||||
Eigen::PlainObjectBase<DerivedI> & I,
|
||||
Eigen::PlainObjectBase<DerivedC> & C) const;
|
||||
private:
|
||||
template <
|
||||
typename DerivedEle,
|
||||
typename Derivedother_V,
|
||||
typename Derivedother_Ele,
|
||||
typename DerivedsqrD,
|
||||
typename DerivedI,
|
||||
typename DerivedC>
|
||||
IGL_INLINE Scalar squared_distance_helper(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const AABB<Derivedother_V,DIM> * other,
|
||||
const Eigen::MatrixBase<Derivedother_V> & other_V,
|
||||
const Eigen::MatrixBase<Derivedother_Ele>& other_Ele,
|
||||
const Scalar up_sqr_d,
|
||||
Eigen::PlainObjectBase<DerivedsqrD> & sqrD,
|
||||
Eigen::PlainObjectBase<DerivedI> & I,
|
||||
Eigen::PlainObjectBase<DerivedC> & C) const;
|
||||
// Compute the squared distance to the primitive in this node: assumes
|
||||
// that this is indeed a leaf node.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of vertex positions
|
||||
// Ele #Ele by dim list of simplex indices
|
||||
// p dim-long query point
|
||||
// sqr_d current minimum distance for this query, see output
|
||||
// i current index into Ele of closest point, see output
|
||||
// c dim-long current closest point, see output
|
||||
// Outputs:
|
||||
// sqr_d minimum of initial value and squared distance to this
|
||||
// primitive
|
||||
// i possibly updated index into Ele of closest point
|
||||
// c dim-long possibly updated closest point
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE void leaf_squared_distance(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & p,
|
||||
const Scalar low_sqr_d,
|
||||
Scalar & sqr_d,
|
||||
int & i,
|
||||
Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
|
||||
// Default low_sqr_d
|
||||
template <typename DerivedEle>
|
||||
IGL_INLINE void leaf_squared_distance(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedEle> & Ele,
|
||||
const RowVectorDIMS & p,
|
||||
Scalar & sqr_d,
|
||||
int & i,
|
||||
Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
|
||||
// If new distance (sqr_d_candidate) is less than current distance
|
||||
// (sqr_d), then update this distance and its associated values
|
||||
// _in-place_:
|
||||
//
|
||||
// Inputs:
|
||||
// p dim-long query point (only used in DEBUG mode)
|
||||
// sqr_d candidate minimum distance for this query, see output
|
||||
// i candidate index into Ele of closest point, see output
|
||||
// c dim-long candidate closest point, see output
|
||||
// sqr_d current minimum distance for this query, see output
|
||||
// i current index into Ele of closest point, see output
|
||||
// c dim-long current closest point, see output
|
||||
// Outputs:
|
||||
// sqr_d minimum of initial value and squared distance to this
|
||||
// primitive
|
||||
// i possibly updated index into Ele of closest point
|
||||
// c dim-long possibly updated closest point
|
||||
IGL_INLINE void set_min(
|
||||
const RowVectorDIMS & p,
|
||||
const Scalar sqr_d_candidate,
|
||||
const int i_candidate,
|
||||
const RowVectorDIMS & c_candidate,
|
||||
Scalar & sqr_d,
|
||||
int & i,
|
||||
Eigen::PlainObjectBase<RowVectorDIMS> & c) const;
|
||||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "AABB.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,36 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ARAPENERGYTYPE_H
|
||||
#define IGL_ARAPENERGYTYPE_H
|
||||
namespace igl
|
||||
{
|
||||
// ARAP_ENERGY_TYPE_SPOKES "As-rigid-as-possible Surface Modeling" by [Sorkine and
|
||||
// Alexa 2007], rotations defined at vertices affecting incident edges,
|
||||
// default
|
||||
// ARAP_ENERGY_TYPE_SPOKES-AND-RIMS Adapted version of "As-rigid-as-possible Surface
|
||||
// Modeling" by [Sorkine and Alexa 2007] presented in section 4.2 of or
|
||||
// "A simple geometric model for elastic deformation" by [Chao et al.
|
||||
// 2010], rotations defined at vertices affecting incident edges and
|
||||
// opposite edges
|
||||
// ARAP_ENERGY_TYPE_ELEMENTS "A local-global approach to mesh parameterization" by
|
||||
// [Liu et al. 2010] or "A simple geometric model for elastic
|
||||
// deformation" by [Chao et al. 2010], rotations defined at elements
|
||||
// (triangles or tets)
|
||||
// ARAP_ENERGY_TYPE_DEFAULT Choose one automatically: spokes and rims
|
||||
// for surfaces, elements for planar meshes and tets (not fully
|
||||
// supported)
|
||||
enum ARAPEnergyType
|
||||
{
|
||||
ARAP_ENERGY_TYPE_SPOKES = 0,
|
||||
ARAP_ENERGY_TYPE_SPOKES_AND_RIMS = 1,
|
||||
ARAP_ENERGY_TYPE_ELEMENTS = 2,
|
||||
ARAP_ENERGY_TYPE_DEFAULT = 3,
|
||||
NUM_ARAP_ENERGY_TYPES = 4
|
||||
};
|
||||
}
|
||||
#endif
|
||||
130
src/external/libigl-2.3.0/include/igl/AtA_cached.cpp
vendored
130
src/external/libigl-2.3.0/include/igl/AtA_cached.cpp
vendored
@ -1,130 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2017 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "AtA_cached.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
|
||||
template <typename Scalar>
|
||||
IGL_INLINE void igl::AtA_cached_precompute(
|
||||
const Eigen::SparseMatrix<Scalar>& A,
|
||||
igl::AtA_cached_data& data,
|
||||
Eigen::SparseMatrix<Scalar>& AtA)
|
||||
{
|
||||
// 1 Compute At (this could be avoided, but performance-wise it will not make a difference)
|
||||
std::vector<std::vector<int> > Col_RowPtr;
|
||||
std::vector<std::vector<int> > Col_IndexPtr;
|
||||
|
||||
Col_RowPtr.resize(A.cols());
|
||||
Col_IndexPtr.resize(A.cols());
|
||||
|
||||
for (unsigned k=0; k<A.outerSize(); ++k)
|
||||
{
|
||||
unsigned outer_index = *(A.outerIndexPtr()+k);
|
||||
unsigned next_outer_index = (k+1 == A.outerSize()) ? A.nonZeros() : *(A.outerIndexPtr()+k+1);
|
||||
|
||||
for (unsigned l=outer_index; l<next_outer_index; ++l)
|
||||
{
|
||||
int col = k;
|
||||
int row = *(A.innerIndexPtr()+l);
|
||||
int value_index = l;
|
||||
assert(col < A.cols());
|
||||
assert(col >= 0);
|
||||
assert(row < A.rows());
|
||||
assert(row >= 0);
|
||||
assert(value_index >= 0);
|
||||
assert(value_index < A.nonZeros());
|
||||
|
||||
Col_RowPtr[col].push_back(row);
|
||||
Col_IndexPtr[col].push_back(value_index);
|
||||
}
|
||||
}
|
||||
|
||||
Eigen::SparseMatrix<Scalar> At = A.transpose();
|
||||
At.makeCompressed();
|
||||
AtA = At * A;
|
||||
AtA.makeCompressed();
|
||||
|
||||
assert(AtA.isCompressed());
|
||||
|
||||
// If weights are not provided, use 1
|
||||
if (data.W.size() == 0)
|
||||
data.W = Eigen::VectorXd::Ones(A.rows());
|
||||
assert(data.W.size() == A.rows());
|
||||
|
||||
data.I_outer.reserve(AtA.outerSize());
|
||||
data.I_row.reserve(2*AtA.nonZeros());
|
||||
data.I_col.reserve(2*AtA.nonZeros());
|
||||
data.I_w.reserve(2*AtA.nonZeros());
|
||||
|
||||
// 2 Construct the rules
|
||||
for (unsigned k=0; k<AtA.outerSize(); ++k)
|
||||
{
|
||||
unsigned outer_index = *(AtA.outerIndexPtr()+k);
|
||||
unsigned next_outer_index = (k+1 == AtA.outerSize()) ? AtA.nonZeros() : *(AtA.outerIndexPtr()+k+1);
|
||||
|
||||
for (unsigned l=outer_index; l<next_outer_index; ++l)
|
||||
{
|
||||
int col = k;
|
||||
int row = *(AtA.innerIndexPtr()+l);
|
||||
int value_index = l;
|
||||
assert(col < AtA.cols());
|
||||
assert(col >= 0);
|
||||
assert(row < AtA.rows());
|
||||
assert(row >= 0);
|
||||
assert(value_index >= 0);
|
||||
assert(value_index < AtA.nonZeros());
|
||||
|
||||
data.I_outer.push_back(data.I_row.size());
|
||||
|
||||
// Find correspondences
|
||||
unsigned i=0;
|
||||
unsigned j=0;
|
||||
while (i<Col_RowPtr[row].size() && j<Col_RowPtr[col].size())
|
||||
{
|
||||
if (Col_RowPtr[row][i] == Col_RowPtr[col][j])
|
||||
{
|
||||
data.I_row.push_back(Col_IndexPtr[row][i]);
|
||||
data.I_col.push_back(Col_IndexPtr[col][j]);
|
||||
data.I_w.push_back(Col_RowPtr[col][j]);
|
||||
++i;
|
||||
++j;
|
||||
} else
|
||||
if (Col_RowPtr[row][i] > Col_RowPtr[col][j])
|
||||
++j;
|
||||
else
|
||||
++i;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
data.I_outer.push_back(data.I_row.size()); // makes it more efficient to iterate later on
|
||||
|
||||
igl::AtA_cached(A,data,AtA);
|
||||
}
|
||||
|
||||
template <typename Scalar>
|
||||
IGL_INLINE void igl::AtA_cached(
|
||||
const Eigen::SparseMatrix<Scalar>& A,
|
||||
const igl::AtA_cached_data& data,
|
||||
Eigen::SparseMatrix<Scalar>& AtA)
|
||||
{
|
||||
for (unsigned i=0; i<data.I_outer.size()-1; ++i)
|
||||
{
|
||||
*(AtA.valuePtr() + i) = 0;
|
||||
for (unsigned j=data.I_outer[i]; j<data.I_outer[i+1]; ++j)
|
||||
*(AtA.valuePtr() + i) += *(A.valuePtr() + data.I_row[j]) * data.W[data.I_w[j]] * *(A.valuePtr() + data.I_col[j]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
template void igl::AtA_cached<double>(Eigen::SparseMatrix<double, 0, int> const&, igl::AtA_cached_data const&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
template void igl::AtA_cached_precompute<double>(Eigen::SparseMatrix<double, 0, int> const&, igl::AtA_cached_data&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
#endif
|
||||
@ -1,70 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2017 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ATA_CACHED_H
|
||||
#define IGL_ATA_CACHED_H
|
||||
#include "igl_inline.h"
|
||||
#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
namespace igl
|
||||
{
|
||||
struct AtA_cached_data
|
||||
{
|
||||
// Weights
|
||||
Eigen::VectorXd W;
|
||||
|
||||
// Flatten composition rules
|
||||
std::vector<int> I_row;
|
||||
std::vector<int> I_col;
|
||||
std::vector<int> I_w;
|
||||
|
||||
// For each entry of AtA, points to the beginning
|
||||
// of the composition rules
|
||||
std::vector<int> I_outer;
|
||||
};
|
||||
|
||||
// Computes At * W * A, where A is sparse and W is diagonal. Divides the
|
||||
// construction in two phases, one
|
||||
// for fixing the sparsity pattern, and one to populate it with values. Compared to
|
||||
// evaluating it directly, this version is slower for the first time (since it requires a
|
||||
// precomputation), but faster to the subsequent evaluations.
|
||||
//
|
||||
// Input:
|
||||
// A m x n sparse matrix
|
||||
// data stores the precomputed sparsity pattern, data.W contains the optional diagonal weights (stored as a dense vector). If W is not provided, it is replaced by the identity.
|
||||
// Outputs:
|
||||
// AtA m by m matrix computed as AtA * W * A
|
||||
//
|
||||
// Example:
|
||||
// AtA_data = igl::AtA_cached_data();
|
||||
// AtA_data.W = W;
|
||||
// if (s.AtA.rows() == 0)
|
||||
// igl::AtA_cached_precompute(s.A,s.AtA_data,s.AtA);
|
||||
// else
|
||||
// igl::AtA_cached(s.A,s.AtA_data,s.AtA);
|
||||
template <typename Scalar>
|
||||
IGL_INLINE void AtA_cached_precompute(
|
||||
const Eigen::SparseMatrix<Scalar>& A,
|
||||
AtA_cached_data& data,
|
||||
Eigen::SparseMatrix<Scalar>& AtA
|
||||
);
|
||||
|
||||
template <typename Scalar>
|
||||
IGL_INLINE void AtA_cached(
|
||||
const Eigen::SparseMatrix<Scalar>& A,
|
||||
const AtA_cached_data& data,
|
||||
Eigen::SparseMatrix<Scalar>& AtA
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "AtA_cached.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
18
src/external/libigl-2.3.0/include/igl/C_STR.h
vendored
18
src/external/libigl-2.3.0/include/igl/C_STR.h
vendored
@ -1,18 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_C_STR_H
|
||||
#define IGL_C_STR_H
|
||||
// http://stackoverflow.com/a/2433143/148668
|
||||
// Suppose you have a function:
|
||||
// void func(const char * c);
|
||||
// Then you can write:
|
||||
// func(C_STR("foo"<<1<<"bar"));
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#define C_STR(X) static_cast<std::ostringstream&>(std::ostringstream().flush() << X).str().c_str()
|
||||
#endif
|
||||
359
src/external/libigl-2.3.0/include/igl/Camera.h
vendored
359
src/external/libigl-2.3.0/include/igl/Camera.h
vendored
@ -1,359 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_CAMERA_H
|
||||
#define IGL_CAMERA_H
|
||||
|
||||
// you're idiot, M$!
|
||||
#if defined(_WIN32)
|
||||
#undef far
|
||||
#undef near
|
||||
#endif
|
||||
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/Core>
|
||||
#include "PI.h"
|
||||
|
||||
#define IGL_CAMERA_MIN_ANGLE 5.0
|
||||
namespace igl
|
||||
{
|
||||
|
||||
// A simple camera class. The camera stores projection parameters (field of
|
||||
// view angle, aspect ratio, near and far clips) as well as a rigid
|
||||
// transformation *of the camera as if it were also a scene object*. Thus, the
|
||||
// **inverse** of this rigid transformation is the modelview transformation.
|
||||
class Camera
|
||||
{
|
||||
public:
|
||||
// On windows you might need: -fno-delayed-template-parsing
|
||||
//static constexpr double IGL_CAMERA_MIN_ANGLE = 5.;
|
||||
// m_angle Field of view angle in degrees {45}
|
||||
// m_aspect Aspect ratio {1}
|
||||
// m_near near clipping plane {1e-2}
|
||||
// m_far far clipping plane {100}
|
||||
// m_at_dist distance of looking at point {1}
|
||||
// m_orthographic whether to use othrographic projection {false}
|
||||
// m_rotation_conj Conjugate of rotation part of rigid transformation of
|
||||
// camera {identity}. Note: we purposefully store the conjugate because
|
||||
// this is what TW_TYPE_QUAT4D is expecting.
|
||||
// m_translation Translation part of rigid transformation of camera
|
||||
// {(0,0,1)}
|
||||
double m_angle, m_aspect, m_near, m_far, m_at_dist;
|
||||
bool m_orthographic;
|
||||
Eigen::Quaterniond m_rotation_conj;
|
||||
Eigen::Vector3d m_translation;
|
||||
public:
|
||||
inline Camera();
|
||||
inline virtual ~Camera(){}
|
||||
// Return projection matrix that takes relative camera coordinates and
|
||||
// transforms it to viewport coordinates
|
||||
//
|
||||
// Note:
|
||||
//
|
||||
// if(m_angle > 0)
|
||||
// {
|
||||
// gluPerspective(m_angle,m_aspect,m_near,m_at_dist+m_far);
|
||||
// }else
|
||||
// {
|
||||
// gluOrtho(-0.5*aspect,0.5*aspect,-0.5,0.5,m_at_dist+m_near,m_far);
|
||||
// }
|
||||
//
|
||||
// Is equivalent to
|
||||
//
|
||||
// glMultMatrixd(projection().data());
|
||||
//
|
||||
inline Eigen::Matrix4d projection() const;
|
||||
// Return an Affine transformation (rigid actually) that
|
||||
// takes relative coordinates and tramsforms them into world 3d
|
||||
// coordinates: moves the camera into the scene.
|
||||
inline Eigen::Affine3d affine() const;
|
||||
// Return an Affine transformation (rigid actually) that puts the takes a
|
||||
// world 3d coordinate and transforms it into the relative camera
|
||||
// coordinates: moves the scene in front of the camera.
|
||||
//
|
||||
// Note:
|
||||
//
|
||||
// gluLookAt(
|
||||
// eye()(0), eye()(1), eye()(2),
|
||||
// at()(0), at()(1), at()(2),
|
||||
// up()(0), up()(1), up()(2));
|
||||
//
|
||||
// Is equivalent to
|
||||
//
|
||||
// glMultMatrixd(camera.inverse().matrix().data());
|
||||
//
|
||||
// See also: affine, eye, at, up
|
||||
inline Eigen::Affine3d inverse() const;
|
||||
// Returns world coordinates position of center or "eye" of camera.
|
||||
inline Eigen::Vector3d eye() const;
|
||||
// Returns world coordinate position of a point "eye" is looking at.
|
||||
inline Eigen::Vector3d at() const;
|
||||
// Returns world coordinate unit vector of "up" vector
|
||||
inline Eigen::Vector3d up() const;
|
||||
// Return top right corner of unit plane in relative coordinates, that is
|
||||
// (w/2,h/2,1)
|
||||
inline Eigen::Vector3d unit_plane() const;
|
||||
// Move dv in the relative coordinate frame of the camera (move the FPS)
|
||||
//
|
||||
// Inputs:
|
||||
// dv (x,y,z) displacement vector
|
||||
//
|
||||
inline void dolly(const Eigen::Vector3d & dv);
|
||||
// "Scale zoom": Move `eye`, but leave `at`
|
||||
//
|
||||
// Input:
|
||||
// s amount to scale distance to at
|
||||
inline void push_away(const double s);
|
||||
// Aka "Hitchcock", "Vertigo", "Spielberg" or "Trombone" zoom:
|
||||
// simultaneously dolly while changing angle so that `at` not only stays
|
||||
// put in relative coordinates but also projected coordinates. That is
|
||||
//
|
||||
// Inputs:
|
||||
// da change in angle in degrees
|
||||
inline void dolly_zoom(const double da);
|
||||
// Turn around eye so that rotation is now q
|
||||
//
|
||||
// Inputs:
|
||||
// q new rotation as quaternion
|
||||
inline void turn_eye(const Eigen::Quaterniond & q);
|
||||
// Orbit around at so that rotation is now q
|
||||
//
|
||||
// Inputs:
|
||||
// q new rotation as quaternion
|
||||
inline void orbit(const Eigen::Quaterniond & q);
|
||||
// Rotate and translate so that camera is situated at "eye" looking at "at"
|
||||
// with "up" pointing up.
|
||||
//
|
||||
// Inputs:
|
||||
// eye (x,y,z) coordinates of eye position
|
||||
// at (x,y,z) coordinates of at position
|
||||
// up (x,y,z) coordinates of up vector
|
||||
inline void look_at(
|
||||
const Eigen::Vector3d & eye,
|
||||
const Eigen::Vector3d & at,
|
||||
const Eigen::Vector3d & up);
|
||||
// Needed any time Eigen Structures are used as class members
|
||||
// http://eigen.tuxfamily.org/dox-devel/group__TopicStructHavingEigenMembers.html
|
||||
public:
|
||||
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
|
||||
};
|
||||
}
|
||||
|
||||
// Implementation
|
||||
#include "PI.h"
|
||||
#include "EPS.h"
|
||||
#include <cmath>
|
||||
#include <iostream>
|
||||
#include <cassert>
|
||||
|
||||
inline igl::Camera::Camera():
|
||||
m_angle(45.0),m_aspect(1),m_near(1e-2),m_far(100),m_at_dist(1),
|
||||
m_orthographic(false),
|
||||
m_rotation_conj(1,0,0,0),
|
||||
m_translation(0,0,1)
|
||||
{
|
||||
}
|
||||
|
||||
inline Eigen::Matrix4d igl::Camera::projection() const
|
||||
{
|
||||
Eigen::Matrix4d P;
|
||||
using namespace std;
|
||||
const double far = m_at_dist + m_far;
|
||||
const double near = m_near;
|
||||
// http://stackoverflow.com/a/3738696/148668
|
||||
if(m_orthographic)
|
||||
{
|
||||
const double f = 0.5;
|
||||
const double left = -f*m_aspect;
|
||||
const double right = f*m_aspect;
|
||||
const double bottom = -f;
|
||||
const double top = f;
|
||||
const double tx = (right+left)/(right-left);
|
||||
const double ty = (top+bottom)/(top-bottom);
|
||||
const double tz = (far+near)/(far-near);
|
||||
const double z_fix = 0.5 /m_at_dist / tan(m_angle*0.5 * (igl::PI/180.) );
|
||||
P<<
|
||||
z_fix*2./(right-left), 0, 0, -tx,
|
||||
0, z_fix*2./(top-bottom), 0, -ty,
|
||||
0, 0, -z_fix*2./(far-near), -tz,
|
||||
0, 0, 0, 1;
|
||||
}else
|
||||
{
|
||||
const double yScale = tan(PI*0.5 - 0.5*m_angle*PI/180.);
|
||||
// http://stackoverflow.com/a/14975139/148668
|
||||
const double xScale = yScale/m_aspect;
|
||||
P<<
|
||||
xScale, 0, 0, 0,
|
||||
0, yScale, 0, 0,
|
||||
0, 0, -(far+near)/(far-near), -1,
|
||||
0, 0, -2.*near*far/(far-near), 0;
|
||||
P = P.transpose().eval();
|
||||
}
|
||||
return P;
|
||||
}
|
||||
|
||||
inline Eigen::Affine3d igl::Camera::affine() const
|
||||
{
|
||||
using namespace Eigen;
|
||||
Affine3d t = Affine3d::Identity();
|
||||
t.rotate(m_rotation_conj.conjugate());
|
||||
t.translate(m_translation);
|
||||
return t;
|
||||
}
|
||||
|
||||
inline Eigen::Affine3d igl::Camera::inverse() const
|
||||
{
|
||||
using namespace Eigen;
|
||||
Affine3d t = Affine3d::Identity();
|
||||
t.translate(-m_translation);
|
||||
t.rotate(m_rotation_conj);
|
||||
return t;
|
||||
}
|
||||
|
||||
inline Eigen::Vector3d igl::Camera::eye() const
|
||||
{
|
||||
using namespace Eigen;
|
||||
return affine() * Vector3d(0,0,0);
|
||||
}
|
||||
|
||||
inline Eigen::Vector3d igl::Camera::at() const
|
||||
{
|
||||
using namespace Eigen;
|
||||
return affine() * (Vector3d(0,0,-1)*m_at_dist);
|
||||
}
|
||||
|
||||
inline Eigen::Vector3d igl::Camera::up() const
|
||||
{
|
||||
using namespace Eigen;
|
||||
Affine3d t = Affine3d::Identity();
|
||||
t.rotate(m_rotation_conj.conjugate());
|
||||
return t * Vector3d(0,1,0);
|
||||
}
|
||||
|
||||
inline Eigen::Vector3d igl::Camera::unit_plane() const
|
||||
{
|
||||
// Distance of center pixel to eye
|
||||
const double d = 1.0;
|
||||
const double a = m_aspect;
|
||||
const double theta = m_angle*PI/180.;
|
||||
const double w =
|
||||
2.*sqrt(-d*d/(a*a*pow(tan(0.5*theta),2.)-1.))*a*tan(0.5*theta);
|
||||
const double h = w/a;
|
||||
return Eigen::Vector3d(w*0.5,h*0.5,-d);
|
||||
}
|
||||
|
||||
inline void igl::Camera::dolly(const Eigen::Vector3d & dv)
|
||||
{
|
||||
m_translation += dv;
|
||||
}
|
||||
|
||||
inline void igl::Camera::push_away(const double s)
|
||||
{
|
||||
using namespace Eigen;
|
||||
#ifndef NDEBUG
|
||||
Vector3d old_at = at();
|
||||
#endif
|
||||
const double old_at_dist = m_at_dist;
|
||||
m_at_dist = old_at_dist * s;
|
||||
dolly(Vector3d(0,0,1)*(m_at_dist - old_at_dist));
|
||||
assert((old_at-at()).squaredNorm() < DOUBLE_EPS);
|
||||
}
|
||||
|
||||
inline void igl::Camera::dolly_zoom(const double da)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
#ifndef NDEBUG
|
||||
Vector3d old_at = at();
|
||||
#endif
|
||||
const double old_angle = m_angle;
|
||||
if(old_angle + da < IGL_CAMERA_MIN_ANGLE)
|
||||
{
|
||||
m_orthographic = true;
|
||||
}else if(old_angle + da > IGL_CAMERA_MIN_ANGLE)
|
||||
{
|
||||
m_orthographic = false;
|
||||
}
|
||||
if(!m_orthographic)
|
||||
{
|
||||
m_angle += da;
|
||||
m_angle = min(89.,max(IGL_CAMERA_MIN_ANGLE,m_angle));
|
||||
// change in distance
|
||||
const double s =
|
||||
(2.*tan(old_angle/2./180.*igl::PI)) /
|
||||
(2.*tan(m_angle/2./180.*igl::PI)) ;
|
||||
const double old_at_dist = m_at_dist;
|
||||
m_at_dist = old_at_dist * s;
|
||||
dolly(Vector3d(0,0,1)*(m_at_dist - old_at_dist));
|
||||
assert((old_at-at()).squaredNorm() < DOUBLE_EPS);
|
||||
}
|
||||
}
|
||||
|
||||
inline void igl::Camera::turn_eye(const Eigen::Quaterniond & q)
|
||||
{
|
||||
using namespace Eigen;
|
||||
Vector3d old_eye = eye();
|
||||
// eye should be fixed
|
||||
//
|
||||
// eye_1 = R_1 * t_1 = eye_0
|
||||
// t_1 = R_1' * eye_0
|
||||
m_rotation_conj = q.conjugate();
|
||||
m_translation = m_rotation_conj * old_eye;
|
||||
assert((old_eye - eye()).squaredNorm() < DOUBLE_EPS);
|
||||
}
|
||||
|
||||
inline void igl::Camera::orbit(const Eigen::Quaterniond & q)
|
||||
{
|
||||
using namespace Eigen;
|
||||
Vector3d old_at = at();
|
||||
// at should be fixed
|
||||
//
|
||||
// at_1 = R_1 * t_1 - R_1 * z = at_0
|
||||
// t_1 = R_1' * (at_0 + R_1 * z)
|
||||
m_rotation_conj = q.conjugate();
|
||||
m_translation =
|
||||
m_rotation_conj *
|
||||
(old_at +
|
||||
m_rotation_conj.conjugate() * Vector3d(0,0,1) * m_at_dist);
|
||||
assert((old_at - at()).squaredNorm() < DOUBLE_EPS);
|
||||
}
|
||||
|
||||
inline void igl::Camera::look_at(
|
||||
const Eigen::Vector3d & eye,
|
||||
const Eigen::Vector3d & at,
|
||||
const Eigen::Vector3d & up)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
// http://www.opengl.org/sdk/docs/man2/xhtml/gluLookAt.xml
|
||||
// Normalize vector from at to eye
|
||||
Vector3d F = eye-at;
|
||||
m_at_dist = F.norm();
|
||||
F.normalize();
|
||||
// Project up onto plane orthogonal to F and normalize
|
||||
assert(up.cross(F).norm() > DOUBLE_EPS && "(eye-at) x up ≈ 0");
|
||||
const Vector3d proj_up = (up-(up.dot(F))*F).normalized();
|
||||
Quaterniond a,b;
|
||||
a.setFromTwoVectors(Vector3d(0,0,-1),-F);
|
||||
b.setFromTwoVectors(a*Vector3d(0,1,0),proj_up);
|
||||
m_rotation_conj = (b*a).conjugate();
|
||||
m_translation = m_rotation_conj * eye;
|
||||
//cout<<"m_at_dist: "<<m_at_dist<<endl;
|
||||
//cout<<"proj_up: "<<proj_up.transpose()<<endl;
|
||||
//cout<<"F: "<<F.transpose()<<endl;
|
||||
//cout<<"eye(): "<<this->eye().transpose()<<endl;
|
||||
//cout<<"at(): "<<this->at().transpose()<<endl;
|
||||
//cout<<"eye()-at(): "<<(this->eye()-this->at()).normalized().transpose()<<endl;
|
||||
//cout<<"eye-this->eye(): "<<(eye-this->eye()).squaredNorm()<<endl;
|
||||
assert( (eye-this->eye()).squaredNorm() < DOUBLE_EPS);
|
||||
//assert((F-(this->eye()-this->at()).normalized()).squaredNorm() <
|
||||
// DOUBLE_EPS);
|
||||
assert( (at-this->at()).squaredNorm() < DOUBLE_EPS);
|
||||
//assert( (proj_up-this->up()).squaredNorm() < DOUBLE_EPS);
|
||||
}
|
||||
|
||||
#endif
|
||||
30
src/external/libigl-2.3.0/include/igl/EPS.cpp
vendored
30
src/external/libigl-2.3.0/include/igl/EPS.cpp
vendored
@ -1,30 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "EPS.h"
|
||||
|
||||
template <> IGL_INLINE float igl::EPS()
|
||||
{
|
||||
return igl::FLOAT_EPS;
|
||||
}
|
||||
template <> IGL_INLINE double igl::EPS()
|
||||
{
|
||||
return igl::DOUBLE_EPS;
|
||||
}
|
||||
|
||||
template <> IGL_INLINE float igl::EPS_SQ()
|
||||
{
|
||||
return igl::FLOAT_EPS_SQ;
|
||||
}
|
||||
template <> IGL_INLINE double igl::EPS_SQ()
|
||||
{
|
||||
return igl::DOUBLE_EPS_SQ;
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
#endif
|
||||
32
src/external/libigl-2.3.0/include/igl/EPS.h
vendored
32
src/external/libigl-2.3.0/include/igl/EPS.h
vendored
@ -1,32 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_EPS_H
|
||||
#define IGL_EPS_H
|
||||
#include "igl_inline.h"
|
||||
namespace igl
|
||||
{
|
||||
// Define a standard value for double epsilon
|
||||
const double DOUBLE_EPS = 1.0e-14;
|
||||
const double DOUBLE_EPS_SQ = 1.0e-28;
|
||||
const float FLOAT_EPS = 1.0e-7f;
|
||||
const float FLOAT_EPS_SQ = 1.0e-14f;
|
||||
// Function returning EPS for corresponding type
|
||||
template <typename S_type> IGL_INLINE S_type EPS();
|
||||
template <typename S_type> IGL_INLINE S_type EPS_SQ();
|
||||
// Template specializations for float and double
|
||||
template <> IGL_INLINE float EPS<float>();
|
||||
template <> IGL_INLINE double EPS<double>();
|
||||
template <> IGL_INLINE float EPS_SQ<float>();
|
||||
template <> IGL_INLINE double EPS_SQ<double>();
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "EPS.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,21 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2020 Jérémie Dumas <jeremie.dumas@ens-lyon.org>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_FILEENCODING_H
|
||||
#define IGL_FILEENCODING_H
|
||||
|
||||
namespace igl
|
||||
{
|
||||
|
||||
enum class FileEncoding {
|
||||
Binary,
|
||||
Ascii
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,162 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "HalfEdgeIterator.h"
|
||||
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::HalfEdgeIterator(
|
||||
const Eigen::MatrixBase<DerivedF>& _F,
|
||||
const Eigen::MatrixBase<DerivedFF>& _FF,
|
||||
const Eigen::MatrixBase<DerivedFFi>& _FFi,
|
||||
int _fi,
|
||||
int _ei,
|
||||
bool _reverse
|
||||
)
|
||||
: fi(_fi), ei(_ei), reverse(_reverse), F(_F), FF(_FF), FFi(_FFi)
|
||||
{}
|
||||
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE void igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::flipF()
|
||||
{
|
||||
if (isBorder())
|
||||
return;
|
||||
|
||||
int fin = (FF)(fi,ei);
|
||||
int ein = (FFi)(fi,ei);
|
||||
|
||||
fi = fin;
|
||||
ei = ein;
|
||||
reverse = !reverse;
|
||||
}
|
||||
|
||||
|
||||
// Change Edge
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE void igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::flipE()
|
||||
{
|
||||
if (!reverse)
|
||||
ei = (ei+2)%3; // ei-1
|
||||
else
|
||||
ei = (ei+1)%3;
|
||||
|
||||
reverse = !reverse;
|
||||
}
|
||||
|
||||
// Change Vertex
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE void igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::flipV()
|
||||
{
|
||||
reverse = !reverse;
|
||||
}
|
||||
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE bool igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::isBorder()
|
||||
{
|
||||
return (FF)(fi,ei) == -1;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the next edge skipping the border
|
||||
* _________
|
||||
* /\ c | b /\
|
||||
* / \ | / \
|
||||
* / d \ | / a \
|
||||
* /______\|/______\
|
||||
* v
|
||||
* In this example, if a and d are of-border and the pos is iterating counterclockwise, this method iterate through the faces incident on vertex v,
|
||||
* producing the sequence a, b, c, d, a, b, c, ...
|
||||
*/
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE bool igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::NextFE()
|
||||
{
|
||||
if ( isBorder() ) // we are on a border
|
||||
{
|
||||
do
|
||||
{
|
||||
flipF();
|
||||
flipE();
|
||||
} while (!isBorder());
|
||||
flipE();
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
flipF();
|
||||
flipE();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Get vertex index
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE int igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::Vi()
|
||||
{
|
||||
assert(fi >= 0);
|
||||
assert(fi < F.rows());
|
||||
assert(ei >= 0);
|
||||
assert(ei <= 2);
|
||||
|
||||
if (!reverse)
|
||||
return (F)(fi,ei);
|
||||
else
|
||||
return (F)(fi,(ei+1)%3);
|
||||
}
|
||||
|
||||
// Get face index
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE int igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::Fi()
|
||||
{
|
||||
return fi;
|
||||
}
|
||||
|
||||
// Get edge index
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE int igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::Ei()
|
||||
{
|
||||
return ei;
|
||||
}
|
||||
|
||||
|
||||
template <typename DerivedF, typename DerivedFF, typename DerivedFFi>
|
||||
IGL_INLINE bool igl::HalfEdgeIterator<DerivedF,DerivedFF,DerivedFFi>::operator==(HalfEdgeIterator& p2)
|
||||
{
|
||||
return
|
||||
(
|
||||
(fi == p2.fi) &&
|
||||
(ei == p2.ei) &&
|
||||
(reverse == p2.reverse) &&
|
||||
(F == p2.F) &&
|
||||
(FF == p2.FF) &&
|
||||
(FFi == p2.FFi)
|
||||
);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> >::HalfEdgeIterator(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, int, int, bool);
|
||||
template igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >::HalfEdgeIterator(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, int, bool);
|
||||
template bool igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::NextFE();
|
||||
template int igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::Ei();
|
||||
template int igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::Ei();
|
||||
template int igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> >::Ei();
|
||||
template int igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> >::Fi();
|
||||
template bool igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> ,Eigen::Matrix<int, -1, 3, 0, -1, 3> >::NextFE();
|
||||
template int igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::Vi();
|
||||
template igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::HalfEdgeIterator(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, int, bool);
|
||||
template int igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::Fi();
|
||||
template void igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::flipE();
|
||||
template void igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >::flipE();
|
||||
template void igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::flipF();
|
||||
template void igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >::flipF();
|
||||
template void igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::flipV();
|
||||
template bool igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >::operator==(igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template int igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >::Fi();
|
||||
template bool igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >::NextFE();
|
||||
template bool igl::HalfEdgeIterator<Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >::isBorder();
|
||||
template bool igl::HalfEdgeIterator<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >::isBorder();
|
||||
#endif
|
||||
@ -1,114 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_HALFEDGEITERATOR_H
|
||||
#define IGL_HALFEDGEITERATOR_H
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
||||
#include <vector>
|
||||
#include <igl/igl_inline.h>
|
||||
|
||||
// This file violates many of the libigl style guidelines.
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// HalfEdgeIterator - Fake halfedge for fast and easy navigation
|
||||
// on triangle meshes with vertex_triangle_adjacency and
|
||||
// triangle_triangle adjacency
|
||||
//
|
||||
// Note: this is different to classical Half Edge data structure.
|
||||
// Instead, it follows cell-tuple in [Brisson, 1989]
|
||||
// "Representing geometric structures in d dimensions: topology and order."
|
||||
// This class can achieve local navigation similar to half edge in OpenMesh
|
||||
// But the logic behind each atom operation is different.
|
||||
// So this should be more properly called TriangleTupleIterator.
|
||||
//
|
||||
// Each tuple contains information on (face, edge, vertex)
|
||||
// and encoded by (face, edge \in {0,1,2}, bool reverse)
|
||||
//
|
||||
// Inputs:
|
||||
// F #F by 3 list of "faces"
|
||||
// FF #F by 3 list of triangle-triangle adjacency.
|
||||
// FFi #F by 3 list of FF inverse. For FF and FFi, refer to
|
||||
// "triangle_triangle_adjacency.h"
|
||||
// Usages:
|
||||
// FlipF/E/V changes solely one actual face/edge/vertex resp.
|
||||
// NextFE iterates through one-ring of a vertex robustly.
|
||||
//
|
||||
template <
|
||||
typename DerivedF,
|
||||
typename DerivedFF,
|
||||
typename DerivedFFi>
|
||||
class HalfEdgeIterator
|
||||
{
|
||||
public:
|
||||
// Init the HalfEdgeIterator by specifying Face,Edge Index and Orientation
|
||||
IGL_INLINE HalfEdgeIterator(
|
||||
const Eigen::MatrixBase<DerivedF>& _F,
|
||||
const Eigen::MatrixBase<DerivedFF>& _FF,
|
||||
const Eigen::MatrixBase<DerivedFFi>& _FFi,
|
||||
int _fi,
|
||||
int _ei,
|
||||
bool _reverse = false
|
||||
);
|
||||
|
||||
// Change Face
|
||||
IGL_INLINE void flipF();
|
||||
|
||||
// Change Edge
|
||||
IGL_INLINE void flipE();
|
||||
|
||||
// Change Vertex
|
||||
IGL_INLINE void flipV();
|
||||
|
||||
IGL_INLINE bool isBorder();
|
||||
|
||||
/*!
|
||||
* Returns the next edge skipping the border
|
||||
* _________
|
||||
* /\ c | b /\
|
||||
* / \ | / \
|
||||
* / d \ | / a \
|
||||
* /______\|/______\
|
||||
* v
|
||||
* In this example, if a and d are of-border and the pos is iterating
|
||||
counterclockwise, this method iterate through the faces incident on vertex
|
||||
v,
|
||||
* producing the sequence a, b, c, d, a, b, c, ...
|
||||
*/
|
||||
IGL_INLINE bool NextFE();
|
||||
|
||||
// Get vertex index
|
||||
IGL_INLINE int Vi();
|
||||
|
||||
// Get face index
|
||||
IGL_INLINE int Fi();
|
||||
|
||||
// Get edge index
|
||||
IGL_INLINE int Ei();
|
||||
|
||||
IGL_INLINE bool operator==(HalfEdgeIterator& p2);
|
||||
|
||||
private:
|
||||
int fi;
|
||||
int ei;
|
||||
bool reverse;
|
||||
|
||||
// All the same type? This is likely to break.
|
||||
const Eigen::MatrixBase<DerivedF> & F;
|
||||
const Eigen::MatrixBase<DerivedFF> & FF;
|
||||
const Eigen::MatrixBase<DerivedFFi> & FFi;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "HalfEdgeIterator.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
29
src/external/libigl-2.3.0/include/igl/Hit.h
vendored
29
src/external/libigl-2.3.0/include/igl/Hit.h
vendored
@ -1,29 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// 2014 Christian Schüller <schuellchr@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_HIT_H
|
||||
#define IGL_HIT_H
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Reimplementation of the embree::Hit struct from embree1.0
|
||||
//
|
||||
// TODO: template on floating point type
|
||||
struct Hit
|
||||
{
|
||||
int id; // primitive id
|
||||
int gid; // geometry id (not used)
|
||||
// barycentric coordinates so that
|
||||
// pos = V.row(F(id,0))*(1-u-v)+V.row(F(id,1))*u+V.row(F(id,2))*v;
|
||||
float u,v;
|
||||
// parametric distance so that
|
||||
// pos = origin + t * dir
|
||||
float t;
|
||||
};
|
||||
}
|
||||
#endif
|
||||
28
src/external/libigl-2.3.0/include/igl/IO
vendored
28
src/external/libigl-2.3.0/include/igl/IO
vendored
@ -1,28 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_IO
|
||||
#define IGL_IO
|
||||
// Input and output functions
|
||||
#include "read_triangle_mesh.h"
|
||||
#include "readDMAT.h"
|
||||
#include "readMESH.h"
|
||||
#include "readNODE.h"
|
||||
#include "readOBJ.h"
|
||||
#include "readOFF.h"
|
||||
#include "readTGF.h"
|
||||
#include "readWRL.h"
|
||||
#include "readCSV.h"
|
||||
#include "file_contents_as_string.h"
|
||||
#include "write_triangle_mesh.h"
|
||||
#include "writeDMAT.h"
|
||||
#include "writeMESH.h"
|
||||
#include "writeOBJ.h"
|
||||
#include "writeOFF.h"
|
||||
#include "writeTGF.h"
|
||||
|
||||
#endif
|
||||
@ -1,117 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_INDEXCOMPARISON_H
|
||||
#define IGL_INDEXCOMPARISON_H
|
||||
#include <iostream>
|
||||
namespace igl{
|
||||
// Comparison struct used by sort
|
||||
// http://bytes.com/topic/c/answers/132045-sort-get-index
|
||||
|
||||
// For use with functions like std::sort
|
||||
template<class T> struct IndexLessThan
|
||||
{
|
||||
IndexLessThan(const T arr) : arr(arr) {}
|
||||
bool operator()(const size_t a, const size_t b) const
|
||||
{
|
||||
return arr[a] < arr[b];
|
||||
}
|
||||
const T arr;
|
||||
};
|
||||
|
||||
// For use with functions like std::unique
|
||||
template<class T> struct IndexEquals
|
||||
{
|
||||
IndexEquals(const T arr) : arr(arr) {}
|
||||
bool operator()(const size_t a, const size_t b) const
|
||||
{
|
||||
return arr[a] == arr[b];
|
||||
}
|
||||
const T arr;
|
||||
};
|
||||
|
||||
// For use with functions like std::sort
|
||||
template<class T> struct IndexVectorLessThan
|
||||
{
|
||||
IndexVectorLessThan(const T & vec) : vec ( vec) {}
|
||||
bool operator()(const size_t a, const size_t b) const
|
||||
{
|
||||
return vec(a) < vec(b);
|
||||
}
|
||||
const T & vec;
|
||||
};
|
||||
|
||||
// For use with functions like std::sort
|
||||
template<class T> struct IndexDimLessThan
|
||||
{
|
||||
IndexDimLessThan(const T & mat,const int & dim, const int & j) :
|
||||
mat(mat),
|
||||
dim(dim),
|
||||
j(j)
|
||||
{}
|
||||
bool operator()(const size_t a, const size_t b) const
|
||||
{
|
||||
if(dim == 1)
|
||||
{
|
||||
return mat(a,j) < mat(b,j);
|
||||
}else
|
||||
{
|
||||
return mat(j,a) < mat(j,b);
|
||||
}
|
||||
}
|
||||
const T & mat;
|
||||
const int & dim;
|
||||
const int & j;
|
||||
};
|
||||
|
||||
// For use with functions like std::sort
|
||||
template<class T> struct IndexRowLessThan
|
||||
{
|
||||
IndexRowLessThan(const T & mat) : mat ( mat) {}
|
||||
bool operator()(const size_t a, const size_t b) const
|
||||
{
|
||||
const int cols = mat.cols();
|
||||
// Lexicographical order
|
||||
for(int j = 0;j<cols;j++)
|
||||
{
|
||||
if(mat(a,j) > mat(b,j))
|
||||
{
|
||||
return false;
|
||||
} else if(mat(a,j) < mat(b,j))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// equality is false
|
||||
return false;
|
||||
}
|
||||
const T & mat;
|
||||
};
|
||||
|
||||
// For use with functions like std::sort
|
||||
template<class T> struct IndexRowEquals
|
||||
{
|
||||
IndexRowEquals(const T & mat) : mat ( mat) {}
|
||||
bool operator()(const size_t a, const size_t b) const
|
||||
{
|
||||
const int cols = mat.cols();
|
||||
// Lexicographical order
|
||||
for(int j = 0;j<cols;j++)
|
||||
{
|
||||
if(mat(a,j) != mat(b,j))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const T & mat;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,61 +0,0 @@
|
||||
#ifndef IGL_LINSPACED_H
|
||||
#define IGL_LINSPACED_H
|
||||
#include <Eigen/Core>
|
||||
// This function is not intended to be a permanent function of libigl. Rather
|
||||
// it is a "drop-in" workaround for documented bug in Eigen:
|
||||
// http://eigen.tuxfamily.org/bz/show_bug.cgi?id=1383
|
||||
//
|
||||
// Replace:
|
||||
//
|
||||
// Eigen::VectorXi::LinSpaced(size,low,high);
|
||||
//
|
||||
// With:
|
||||
//
|
||||
// igl::LinSpaced<Eigen::VectorXi>(size,low,high);
|
||||
//
|
||||
// Specifcally, this version will _always_ return an empty vector if size==0,
|
||||
// regardless of the values for low and high. If size != 0, then this simply
|
||||
// returns the result of Eigen::Derived::LinSpaced.
|
||||
//
|
||||
// Until this bug is fixed, we should also avoid calls to the member function
|
||||
// `.setLinSpaced`. This means replacing:
|
||||
//
|
||||
// a.setLinSpaced(size,low,high);
|
||||
//
|
||||
// with
|
||||
//
|
||||
// a = igl::LinSpaced<decltype(a) >(size,low,high);
|
||||
//
|
||||
namespace igl
|
||||
{
|
||||
template <typename Derived>
|
||||
//inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType
|
||||
inline Derived LinSpaced(
|
||||
typename Derived::Index size,
|
||||
const typename Derived::Scalar & low,
|
||||
const typename Derived::Scalar & high);
|
||||
}
|
||||
|
||||
// Implementation
|
||||
|
||||
template <typename Derived>
|
||||
//inline typename Eigen::DenseBase< Derived >::RandomAccessLinSpacedReturnType
|
||||
inline Derived
|
||||
igl::LinSpaced(
|
||||
typename Derived::Index size,
|
||||
const typename Derived::Scalar & low,
|
||||
const typename Derived::Scalar & high)
|
||||
{
|
||||
if(size == 0)
|
||||
{
|
||||
// Force empty vector with correct "RandomAccessLinSpacedReturnType" type.
|
||||
return Derived::LinSpaced(0,0,1);
|
||||
}else if(high < low)
|
||||
{
|
||||
return low-Derived::LinSpaced(size,low-low,low-high).array();
|
||||
}else{
|
||||
return Derived::LinSpaced(size,low,high);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,27 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2018 Zhongshi Jiang <jiangzs@nyu.edu>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_MAPPINGENERGYTYPE_H
|
||||
#define IGL_MAPPINGENERGYTYPE_H
|
||||
namespace igl
|
||||
{
|
||||
// Energy Types used for Parameterization/Mapping.
|
||||
// Refer to SLIM [Rabinovich et al. 2017] for more details
|
||||
// Todo: Integrate with ARAPEnergyType
|
||||
|
||||
enum MappingEnergyType
|
||||
{
|
||||
ARAP = 0,
|
||||
LOG_ARAP = 1,
|
||||
SYMMETRIC_DIRICHLET = 2,
|
||||
CONFORMAL = 3,
|
||||
EXP_CONFORMAL = 4,
|
||||
EXP_SYMMETRIC_DIRICHLET = 5,
|
||||
NUM_SLIM_ENERGY_TYPES = 6
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@ -1,23 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_MESH_BOOLEAN_TYPE_H
|
||||
#define IGL_MESH_BOOLEAN_TYPE_H
|
||||
namespace igl
|
||||
{
|
||||
enum MeshBooleanType
|
||||
{
|
||||
MESH_BOOLEAN_TYPE_UNION = 0,
|
||||
MESH_BOOLEAN_TYPE_INTERSECT = 1,
|
||||
MESH_BOOLEAN_TYPE_MINUS = 2,
|
||||
MESH_BOOLEAN_TYPE_XOR = 3,
|
||||
MESH_BOOLEAN_TYPE_RESOLVE = 4,
|
||||
NUM_MESH_BOOLEAN_TYPES = 5
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
497
src/external/libigl-2.3.0/include/igl/MshLoader.cpp
vendored
497
src/external/libigl-2.3.0/include/igl/MshLoader.cpp
vendored
@ -1,497 +0,0 @@
|
||||
// based on MSH reader from PyMesh
|
||||
|
||||
// Copyright (c) 2015 Qingnan Zhou <qzhou@adobe.com>
|
||||
// Copyright (C) 2020 Vladimir Fonov <vladimir.fonov@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "MshLoader.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
namespace igl {
|
||||
// helper function
|
||||
void inline _msh_eat_white_space(std::ifstream& fin) {
|
||||
char next = fin.peek();
|
||||
while (next == '\n' || next == ' ' || next == '\t' || next == '\r') {
|
||||
fin.get();
|
||||
next = fin.peek();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE igl::MshLoader::MshLoader(const std::string &filename) {
|
||||
std::ifstream fin(filename, std::ios::in | std::ios::binary);
|
||||
|
||||
if (!fin.is_open()) {
|
||||
std::stringstream err_msg;
|
||||
err_msg << "failed to open file \"" << filename << "\"";
|
||||
throw std::ios_base::failure(err_msg.str());
|
||||
}
|
||||
// Parse header
|
||||
std::string buf;
|
||||
double version;
|
||||
int type;
|
||||
fin >> buf;
|
||||
if (buf != "$MeshFormat") { throw std::runtime_error("Unexpected .msh format"); }
|
||||
|
||||
fin >> version >> type >> m_data_size;
|
||||
m_binary = (type == 1);
|
||||
if(version>2.2 || version<2.0)
|
||||
{
|
||||
// probably unsupported version
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Error: Unsupported file version:" << version << std::endl;
|
||||
throw std::runtime_error(err_msg.str());
|
||||
|
||||
}
|
||||
// Some sanity check.
|
||||
if (m_data_size != 8) {
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Error: data size must be 8 bytes." << std::endl;
|
||||
throw std::runtime_error(err_msg.str());
|
||||
}
|
||||
if (sizeof(int) != 4) {
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Error: code must be compiled with int size 4 bytes." << std::endl;
|
||||
throw std::runtime_error(err_msg.str());
|
||||
}
|
||||
|
||||
// Read in extra info from binary header.
|
||||
if (m_binary) {
|
||||
int one;
|
||||
igl::_msh_eat_white_space(fin);
|
||||
fin.read(reinterpret_cast<char*>(&one), sizeof(int));
|
||||
if (one != 1) {
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Binary msh file " << filename
|
||||
<< " is saved with different endianness than this machine."
|
||||
<< std::endl;
|
||||
throw std::runtime_error(err_msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
fin >> buf;
|
||||
if (buf != "$EndMeshFormat")
|
||||
{
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Unexpected contents in the file header." << std::endl;
|
||||
throw std::runtime_error(err_msg.str());
|
||||
}
|
||||
|
||||
while (!fin.eof()) {
|
||||
buf.clear();
|
||||
fin >> buf;
|
||||
if (buf == "$Nodes") {
|
||||
parse_nodes(fin);
|
||||
fin >> buf;
|
||||
if (buf != "$EndNodes") { throw std::runtime_error("Unexpected tag"); }
|
||||
} else if (buf == "$Elements") {
|
||||
parse_elements(fin);
|
||||
fin >> buf;
|
||||
if (buf != "$EndElements") { throw std::runtime_error("Unexpected tag"); }
|
||||
} else if (buf == "$NodeData") {
|
||||
parse_node_field(fin);
|
||||
fin >> buf;
|
||||
if (buf != "$EndNodeData") { throw std::runtime_error("Unexpected tag"); }
|
||||
} else if (buf == "$ElementData") {
|
||||
parse_element_field(fin);
|
||||
fin >> buf;
|
||||
if (buf != "$EndElementData") { throw std::runtime_error("Unexpected tag"); }
|
||||
} else if (fin.eof()) {
|
||||
break;
|
||||
} else {
|
||||
parse_unknown_field(fin, buf);
|
||||
}
|
||||
}
|
||||
fin.close();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshLoader::parse_nodes(std::ifstream& fin) {
|
||||
size_t num_nodes;
|
||||
fin >> num_nodes;
|
||||
m_nodes.resize(num_nodes*3);
|
||||
|
||||
if (m_binary) {
|
||||
size_t stride = (4+3*m_data_size);
|
||||
size_t num_bytes = stride * num_nodes;
|
||||
char* data = new char[num_bytes];
|
||||
igl::_msh_eat_white_space(fin);
|
||||
fin.read(data, num_bytes);
|
||||
|
||||
for (size_t i=0; i<num_nodes; i++) {
|
||||
int node_idx;
|
||||
memcpy(&node_idx, data+i*stride, sizeof(int));
|
||||
node_idx-=1;
|
||||
// directly move into vector storage
|
||||
// this works only when m_data_size==sizeof(Float)==sizeof(double)
|
||||
memcpy(&m_nodes[node_idx*3], data+i*stride + 4, m_data_size*3);
|
||||
}
|
||||
delete [] data;
|
||||
} else {
|
||||
int node_idx;
|
||||
for (size_t i=0; i<num_nodes; i++) {
|
||||
fin >> node_idx;
|
||||
node_idx -= 1;
|
||||
// here it's 3D node explicitly
|
||||
fin >> m_nodes[node_idx*3]
|
||||
>> m_nodes[node_idx*3+1]
|
||||
>> m_nodes[node_idx*3+2];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshLoader::parse_elements(std::ifstream& fin) {
|
||||
m_elements_tags.resize(2); //hardcoded to have 2 tags
|
||||
size_t num_elements;
|
||||
fin >> num_elements;
|
||||
|
||||
size_t nodes_per_element;
|
||||
|
||||
if (m_binary) {
|
||||
igl::_msh_eat_white_space(fin);
|
||||
int elem_read = 0;
|
||||
while (elem_read < num_elements) {
|
||||
// Parse element header.
|
||||
int elem_type, num_elems, num_tags;
|
||||
fin.read((char*)&elem_type, sizeof(int));
|
||||
fin.read((char*)&num_elems, sizeof(int));
|
||||
fin.read((char*)&num_tags, sizeof(int));
|
||||
nodes_per_element = num_nodes_per_elem_type(elem_type);
|
||||
|
||||
// store node info
|
||||
for (size_t i=0; i<num_elems; i++) {
|
||||
int elem_idx;
|
||||
|
||||
// all elements in the segment share the same elem_type and number of nodes per element
|
||||
m_elements_types.push_back(elem_type);
|
||||
m_elements_lengths.push_back(nodes_per_element);
|
||||
|
||||
fin.read((char*)&elem_idx, sizeof(int));
|
||||
elem_idx -= 1;
|
||||
m_elements_ids.push_back(elem_idx);
|
||||
|
||||
// read first two tags
|
||||
for (size_t j=0; j<num_tags; j++) {
|
||||
int tag;
|
||||
fin.read((char*)&tag, sizeof(int));
|
||||
if(j<2) m_elements_tags[j].push_back(tag);
|
||||
}
|
||||
|
||||
for (size_t j=num_tags; j<2; j++)
|
||||
m_elements_tags[j].push_back(-1); // fill up tags if less then 2
|
||||
|
||||
m_elements_nodes_idx.push_back(m_elements.size());
|
||||
// Element values.
|
||||
for (size_t j=0; j<nodes_per_element; j++) {
|
||||
int idx;
|
||||
fin.read((char*)&idx, sizeof(int));
|
||||
|
||||
m_elements.push_back(idx-1);
|
||||
}
|
||||
}
|
||||
elem_read += num_elems;
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<num_elements; i++) {
|
||||
// Parse per element header
|
||||
int elem_num, elem_type, num_tags;
|
||||
fin >> elem_num >> elem_type >> num_tags;
|
||||
|
||||
// read tags.
|
||||
for (size_t j=0; j<num_tags; j++) {
|
||||
int tag;
|
||||
fin >> tag;
|
||||
if(j<2) m_elements_tags[j].push_back(tag);
|
||||
}
|
||||
for (size_t j=num_tags; j<2; j++)
|
||||
m_elements_tags[j].push_back(-1); // fill up tags if less then 2
|
||||
|
||||
nodes_per_element = num_nodes_per_elem_type(elem_type);
|
||||
m_elements_types.push_back(elem_type);
|
||||
m_elements_lengths.push_back(nodes_per_element);
|
||||
|
||||
elem_num -= 1;
|
||||
m_elements_ids.push_back(elem_num);
|
||||
m_elements_nodes_idx.push_back(m_elements.size());
|
||||
// Parse node idx.
|
||||
for (size_t j=0; j<nodes_per_element; j++) {
|
||||
int idx;
|
||||
fin >> idx;
|
||||
m_elements.push_back(idx-1); // msh index starts from 1.
|
||||
}
|
||||
}
|
||||
}
|
||||
// debug
|
||||
assert(m_elements_types.size() == m_elements_ids.size());
|
||||
assert(m_elements_tags[0].size() == m_elements_ids.size());
|
||||
assert(m_elements_tags[1].size() == m_elements_ids.size());
|
||||
assert(m_elements_lengths.size() == m_elements_ids.size());
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshLoader::parse_node_field( std::ifstream& fin ) {
|
||||
size_t num_string_tags;
|
||||
size_t num_real_tags;
|
||||
size_t num_int_tags;
|
||||
|
||||
fin >> num_string_tags;
|
||||
std::vector<std::string> str_tags(num_string_tags);
|
||||
|
||||
for (size_t i=0; i<num_string_tags; i++) {
|
||||
igl::_msh_eat_white_space(fin);
|
||||
if (fin.peek() == '\"') {
|
||||
// Handle field name between quotes.
|
||||
char buf[128];
|
||||
fin.get(); // remove the quote at the beginning.
|
||||
fin.getline(buf, 128, '\"');
|
||||
str_tags[i] = std::string(buf);
|
||||
} else {
|
||||
fin >> str_tags[i];
|
||||
}
|
||||
}
|
||||
|
||||
fin >> num_real_tags;
|
||||
std::vector<Float> real_tags(num_real_tags);
|
||||
for (size_t i=0; i<num_real_tags; i++)
|
||||
fin >> real_tags[i];
|
||||
|
||||
fin >> num_int_tags;
|
||||
std::vector<int> int_tags(num_int_tags);
|
||||
for (size_t i=0; i<num_int_tags; i++)
|
||||
fin >> int_tags[i];
|
||||
|
||||
if (num_string_tags <= 0 || num_int_tags <= 2) {
|
||||
throw std::runtime_error("Unexpected number of field tags");
|
||||
}
|
||||
std::string fieldname = str_tags[0];
|
||||
int num_components = int_tags[1];
|
||||
int num_entries = int_tags[2];
|
||||
|
||||
std::vector<Float> field( num_entries*num_components );
|
||||
|
||||
if (m_binary) {
|
||||
size_t num_bytes = (num_components * m_data_size + 4) * num_entries;
|
||||
char* data = new char[num_bytes];
|
||||
igl::_msh_eat_white_space(fin);
|
||||
fin.read(data, num_bytes);
|
||||
for (size_t i=0; i<num_entries; i++) {
|
||||
int node_idx;
|
||||
memcpy(&node_idx,&data[i*(4+num_components*m_data_size)],4);
|
||||
|
||||
if(node_idx<1) throw std::runtime_error("Negative or zero index");
|
||||
node_idx -= 1;
|
||||
|
||||
if(node_idx>=num_entries) throw std::runtime_error("Index too big");
|
||||
size_t base_idx = i*(4+num_components*m_data_size) + 4;
|
||||
// TODO: make this work when m_data_size != sizeof(double) ?
|
||||
memcpy(&field[node_idx*num_components], &data[base_idx], num_components*m_data_size);
|
||||
}
|
||||
delete [] data;
|
||||
} else {
|
||||
int node_idx;
|
||||
for (size_t i=0; i<num_entries; i++) {
|
||||
fin >> node_idx;
|
||||
node_idx -= 1;
|
||||
for (size_t j=0; j<num_components; j++) {
|
||||
fin >> field[node_idx*num_components+j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
m_node_fields_names.push_back(fieldname);
|
||||
m_node_fields.push_back(field);
|
||||
m_node_fields_components.push_back(num_components);
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshLoader::parse_element_field(std::ifstream& fin) {
|
||||
size_t num_string_tags;
|
||||
size_t num_real_tags;
|
||||
size_t num_int_tags;
|
||||
|
||||
fin >> num_string_tags;
|
||||
std::vector<std::string> str_tags(num_string_tags);
|
||||
for (size_t i=0; i<num_string_tags; i++) {
|
||||
igl::_msh_eat_white_space(fin);
|
||||
if (fin.peek() == '\"') {
|
||||
// Handle field name between quoates.
|
||||
char buf[128];
|
||||
fin.get(); // remove the quote at the beginning.
|
||||
fin.getline(buf, 128, '\"');
|
||||
str_tags[i] = buf;
|
||||
} else {
|
||||
fin >> str_tags[i];
|
||||
}
|
||||
}
|
||||
|
||||
fin >> num_real_tags;
|
||||
std::vector<Float> real_tags(num_real_tags);
|
||||
for (size_t i=0; i<num_real_tags; i++)
|
||||
fin >> real_tags[i];
|
||||
|
||||
fin >> num_int_tags;
|
||||
std::vector<int> int_tags(num_int_tags);
|
||||
for (size_t i=0; i<num_int_tags; i++)
|
||||
fin >> int_tags[i];
|
||||
|
||||
if (num_string_tags <= 0 || num_int_tags <= 2) {
|
||||
throw std::runtime_error("Invalid file format");
|
||||
}
|
||||
std::string fieldname = str_tags[0];
|
||||
int num_components = int_tags[1];
|
||||
int num_entries = int_tags[2];
|
||||
std::vector<Float> field(num_entries*num_components);
|
||||
|
||||
if (m_binary) {
|
||||
size_t num_bytes = (num_components * m_data_size + 4) * num_entries;
|
||||
char* data = new char[num_bytes];
|
||||
igl::_msh_eat_white_space(fin);
|
||||
fin.read(data, num_bytes);
|
||||
for (int i=0; i<num_entries; i++) {
|
||||
int elem_idx;
|
||||
// works with sizeof(int)==4
|
||||
memcpy(&elem_idx, &data[i*(4+num_components*m_data_size)],4);
|
||||
elem_idx -= 1;
|
||||
|
||||
// directly copy data into vector storage space
|
||||
memcpy(&field[elem_idx*num_components], &data[i*(4+num_components*m_data_size) + 4], m_data_size*num_components);
|
||||
}
|
||||
delete [] data;
|
||||
} else {
|
||||
int elem_idx;
|
||||
for (size_t i=0; i<num_entries; i++) {
|
||||
fin >> elem_idx;
|
||||
elem_idx -= 1;
|
||||
for (size_t j=0; j<num_components; j++) {
|
||||
fin >> field[elem_idx*num_components+j];
|
||||
}
|
||||
}
|
||||
}
|
||||
m_element_fields_names.push_back(fieldname);
|
||||
m_element_fields.push_back(field);
|
||||
m_element_fields_components.push_back(num_components);
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshLoader::parse_unknown_field(std::ifstream& fin,
|
||||
const std::string& fieldname) {
|
||||
std::cerr << "Warning: \"" << fieldname << "\" not supported yet. Ignored." << std::endl;
|
||||
std::string endmark = fieldname.substr(0,1) + "End"
|
||||
+ fieldname.substr(1,fieldname.size()-1);
|
||||
|
||||
std::string buf("");
|
||||
while (buf != endmark && !fin.eof()) {
|
||||
fin >> buf;
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::MshLoader::num_nodes_per_elem_type(int elem_type) {
|
||||
int nodes_per_element = 0;
|
||||
switch (elem_type) {
|
||||
case ELEMENT_LINE: // 2-node line
|
||||
nodes_per_element = 2;
|
||||
break;
|
||||
case ELEMENT_TRI:
|
||||
nodes_per_element = 3; // 3-node triangle
|
||||
break;
|
||||
case ELEMENT_QUAD:
|
||||
nodes_per_element = 4; // 5-node quad
|
||||
break;
|
||||
case ELEMENT_TET:
|
||||
nodes_per_element = 4; // 4-node tetrahedra
|
||||
break;
|
||||
case ELEMENT_HEX: // 8-node hexahedron
|
||||
nodes_per_element = 8;
|
||||
break;
|
||||
case ELEMENT_PRISM: // 6-node prism
|
||||
nodes_per_element = 6;
|
||||
break;
|
||||
case ELEMENT_LINE_2ND_ORDER:
|
||||
nodes_per_element = 3;
|
||||
break;
|
||||
case ELEMENT_TRI_2ND_ORDER:
|
||||
nodes_per_element = 6;
|
||||
break;
|
||||
case ELEMENT_QUAD_2ND_ORDER:
|
||||
nodes_per_element = 9;
|
||||
break;
|
||||
case ELEMENT_TET_2ND_ORDER:
|
||||
nodes_per_element = 10;
|
||||
break;
|
||||
case ELEMENT_HEX_2ND_ORDER:
|
||||
nodes_per_element = 27;
|
||||
break;
|
||||
case ELEMENT_PRISM_2ND_ORDER:
|
||||
nodes_per_element = 18;
|
||||
break;
|
||||
case ELEMENT_PYRAMID_2ND_ORDER:
|
||||
nodes_per_element = 14;
|
||||
break;
|
||||
case ELEMENT_POINT: // 1-node point
|
||||
nodes_per_element = 1;
|
||||
break;
|
||||
default:
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Element type (" << elem_type << ") is not supported yet."
|
||||
<< std::endl;
|
||||
throw std::runtime_error(err_msg.str());
|
||||
}
|
||||
return nodes_per_element;
|
||||
}
|
||||
|
||||
|
||||
IGL_INLINE bool igl::MshLoader::is_element_map_identity() const
|
||||
{
|
||||
for(int i=0;i<m_elements_ids.size();i++) {
|
||||
int id=m_elements_ids[i];
|
||||
if (id!=i) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
IGL_INLINE void igl::MshLoader::index_structures(int tag_column)
|
||||
{
|
||||
//cleanup
|
||||
m_structure_index.clear();
|
||||
m_structures.clear();
|
||||
m_structure_length.clear();
|
||||
|
||||
//index structure tags
|
||||
for(auto i=0; i != m_elements_tags[tag_column].size(); ++i )
|
||||
{
|
||||
m_structure_index.insert(
|
||||
std::pair<msh_struct,int>(
|
||||
msh_struct( m_elements_tags[tag_column][i],
|
||||
m_elements_types[i]), i)
|
||||
);
|
||||
}
|
||||
|
||||
// identify unique structures
|
||||
std::vector<StructIndex::value_type> _unique_structs;
|
||||
std::unique_copy(std::begin(m_structure_index),
|
||||
std::end(m_structure_index),
|
||||
std::back_inserter(_unique_structs),
|
||||
[](const StructIndex::value_type &c1, const StructIndex::value_type &c2)
|
||||
{ return c1.first == c2.first; });
|
||||
|
||||
std::for_each( _unique_structs.begin(), _unique_structs.end(),
|
||||
[this](const StructIndex::value_type &n){ this->m_structures.push_back(n.first); });
|
||||
|
||||
for(auto t = m_structures.begin(); t != m_structures.end(); ++t)
|
||||
{
|
||||
// identify all elements corresponding to this tag
|
||||
auto structure_range = m_structure_index.equal_range( *t );
|
||||
int cnt=0;
|
||||
|
||||
for(auto i=structure_range.first; i!=structure_range.second; i++)
|
||||
cnt++;
|
||||
|
||||
m_structure_length.insert( std::pair<msh_struct,int>( *t, cnt));
|
||||
}
|
||||
}
|
||||
190
src/external/libigl-2.3.0/include/igl/MshLoader.h
vendored
190
src/external/libigl-2.3.0/include/igl/MshLoader.h
vendored
@ -1,190 +0,0 @@
|
||||
// based on MSH reader from PyMesh
|
||||
|
||||
// Copyright (c) 2015 Qingnan Zhou <qzhou@adobe.com>
|
||||
// Copyright (C) 2020 Vladimir Fonov <vladimir.fonov@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_MSH_LOADER_H
|
||||
#define IGL_MSH_LOADER_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
namespace igl {
|
||||
|
||||
// Class for loading information from .msh file
|
||||
// depends only on c++stl library
|
||||
class MshLoader {
|
||||
public:
|
||||
|
||||
struct msh_struct {
|
||||
int tag,el_type;
|
||||
msh_struct(int _tag=0,int _type=0):
|
||||
tag(_tag),el_type(_type){}
|
||||
bool operator== (const msh_struct& a) const {
|
||||
return this->tag==a.tag &&
|
||||
this->el_type==a.el_type;
|
||||
}
|
||||
|
||||
bool operator< (const msh_struct& a) const {
|
||||
return (this->tag*100+this->el_type) <
|
||||
(a.tag*100+a.el_type);
|
||||
}
|
||||
};
|
||||
|
||||
typedef double Float;
|
||||
|
||||
typedef std::vector<int> IndexVector;
|
||||
typedef std::vector<int> IntVector;
|
||||
typedef std::vector<Float> FloatVector;
|
||||
typedef std::vector<FloatVector> FloatField;
|
||||
typedef std::vector<IntVector> IntField;
|
||||
typedef std::vector<std::string> FieldNames;
|
||||
typedef std::multimap<msh_struct,int> StructIndex;
|
||||
typedef std::vector<msh_struct> StructVector;
|
||||
|
||||
enum {ELEMENT_LINE=1, ELEMENT_TRI=2, ELEMENT_QUAD=3,
|
||||
ELEMENT_TET=4, ELEMENT_HEX=5, ELEMENT_PRISM=6,
|
||||
ELEMENT_PYRAMID=7,
|
||||
// 2nd order elements
|
||||
ELEMENT_LINE_2ND_ORDER=8, ELEMENT_TRI_2ND_ORDER=9,
|
||||
ELEMENT_QUAD_2ND_ORDER=10,ELEMENT_TET_2ND_ORDER=11,
|
||||
ELEMENT_HEX_2ND_ORDER=12, ELEMENT_PRISM_2ND_ORDER=13,
|
||||
ELEMENT_PYRAMID_2ND_ORDER=14,
|
||||
// other elements
|
||||
ELEMENT_POINT=15 };
|
||||
public:
|
||||
MshLoader(const std::string &filename);
|
||||
|
||||
public:
|
||||
|
||||
// get nodes , x,y,z sequentially
|
||||
const FloatVector& get_nodes() const { return m_nodes; }
|
||||
// get elements , identifying nodes that create an element
|
||||
// variable length per element
|
||||
const IndexVector& get_elements() const { return m_elements; }
|
||||
|
||||
// get element types
|
||||
const IntVector& get_elements_types() const { return m_elements_types; }
|
||||
// get element lengths
|
||||
const IntVector& get_elements_lengths() const { return m_elements_lengths; }
|
||||
// get element tags ( physical (0) and elementary (1) )
|
||||
const IntField& get_elements_tags() const { return m_elements_tags; }
|
||||
// get element IDs
|
||||
const IntVector& get_elements_ids() const { return m_elements_ids; }
|
||||
|
||||
// get reverse index from node to element
|
||||
const IndexVector& get_elements_nodes_idx() const { return m_elements_nodes_idx; }
|
||||
|
||||
// get fields assigned per node, all fields and components sequentially
|
||||
const FloatField& get_node_fields() const { return m_node_fields;}
|
||||
// get node field names,
|
||||
const FieldNames& get_node_fields_names() const { return m_node_fields_names;}
|
||||
// get number of node field components
|
||||
const IntVector& get_node_fields_components() const {return m_node_fields_components;}
|
||||
|
||||
int get_node_field_components(size_t c) const
|
||||
{
|
||||
return m_node_fields_components[c];
|
||||
}
|
||||
|
||||
// get fields assigned per element, all fields and components sequentially
|
||||
const FloatField& get_element_fields() const { return m_element_fields;}
|
||||
// get element field names
|
||||
const FieldNames& get_element_fields_names() const { return m_element_fields_names;}
|
||||
// get number of element field components
|
||||
const IntVector& get_element_fields_components() const {return m_element_fields_components;}
|
||||
|
||||
int get_element_field_components(size_t c) const {
|
||||
return m_element_fields_components[c];
|
||||
}
|
||||
// check if field is present at node level
|
||||
bool is_node_field(const std::string& fieldname) const {
|
||||
return (std::find(std::begin(m_node_fields_names),
|
||||
std::end(m_node_fields_names),
|
||||
fieldname) != std::end(m_node_fields_names) );
|
||||
}
|
||||
// check if field is present at element level
|
||||
bool is_element_field(const std::string& fieldname) const {
|
||||
return (std::find(std::begin(m_element_fields_names),
|
||||
std::end(m_element_fields_names),
|
||||
fieldname) != std::end(m_node_fields_names) );
|
||||
}
|
||||
|
||||
// check if all elements have ids assigned sequentially
|
||||
bool is_element_map_identity() const ;
|
||||
|
||||
// create tag index
|
||||
// tag_column: ( physical (0) or elementary (1) ) specifying which tag to use
|
||||
void index_structures(int tag_column);
|
||||
|
||||
// get tag index, call index_structure_tags first
|
||||
const StructIndex& get_structure_index() const
|
||||
{
|
||||
return m_structure_index;
|
||||
}
|
||||
|
||||
// get size of a structure identified by tag and element type
|
||||
const StructIndex& get_structure_length() const
|
||||
{
|
||||
return m_structure_length;
|
||||
}
|
||||
|
||||
//! get list of structures
|
||||
const StructVector& get_structures() const
|
||||
{
|
||||
return m_structures;
|
||||
}
|
||||
|
||||
public:
|
||||
// helper function, calculate number of nodes associated with an element
|
||||
static int num_nodes_per_elem_type(int elem_type);
|
||||
|
||||
private:
|
||||
void parse_nodes(std::ifstream& fin);
|
||||
void parse_elements(std::ifstream& fin);
|
||||
void parse_node_field(std::ifstream& fin);
|
||||
void parse_element_field(std::ifstream& fin);
|
||||
void parse_unknown_field(std::ifstream& fin,
|
||||
const std::string& fieldname);
|
||||
|
||||
private:
|
||||
bool m_binary;
|
||||
size_t m_data_size;
|
||||
|
||||
FloatVector m_nodes; // len x 3 vector
|
||||
|
||||
IndexVector m_elements; // linear array for nodes corresponding to each element
|
||||
IndexVector m_elements_nodes_idx; // element indexes
|
||||
|
||||
IntVector m_elements_ids; // element id's
|
||||
IntVector m_elements_types; // Element types
|
||||
IntVector m_elements_lengths; // Element lengths
|
||||
IntField m_elements_tags; // Element tags, currently 2xtags per element
|
||||
|
||||
FloatField m_node_fields; // Float field defined at each node
|
||||
IntVector m_node_fields_components; // Number of components for node field
|
||||
FieldNames m_node_fields_names; // Node field name
|
||||
|
||||
FloatField m_element_fields; // Float field defined at each element
|
||||
IntVector m_element_fields_components; // Number of components for element field
|
||||
FieldNames m_element_fields_names; // Element field name
|
||||
|
||||
StructIndex m_structure_index; // index tag ids
|
||||
StructVector m_structures; // unique structures
|
||||
StructIndex m_structure_length; // length of structures with consistent element type
|
||||
};
|
||||
|
||||
} //igl
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "MshLoader.cpp"
|
||||
#endif
|
||||
|
||||
#endif //IGL_MSH_LOADER_H
|
||||
347
src/external/libigl-2.3.0/include/igl/MshSaver.cpp
vendored
347
src/external/libigl-2.3.0/include/igl/MshSaver.cpp
vendored
@ -1,347 +0,0 @@
|
||||
// based on MSH writer from PyMesh
|
||||
|
||||
// Copyright (c) 2015 Qingnan Zhou <qzhou@adobe.com>
|
||||
// Copyright (C) 2020 Vladimir Fonov <vladimir.fonov@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
#include "MshSaver.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
|
||||
|
||||
IGL_INLINE igl::MshSaver::MshSaver(const std::string& filename, bool binary) :
|
||||
m_binary(binary), m_num_nodes(0), m_num_elements(0) {
|
||||
if (!m_binary) {
|
||||
fout.open(filename.c_str(), std::fstream::out);
|
||||
} else {
|
||||
fout.open(filename.c_str(), std::fstream::binary);
|
||||
}
|
||||
if (!fout) {
|
||||
std::stringstream err_msg;
|
||||
err_msg << "Error opening " << filename << " to write msh file." << std::endl;
|
||||
throw std::ios_base::failure(err_msg.str());
|
||||
}
|
||||
}
|
||||
|
||||
IGL_INLINE igl::MshSaver::~MshSaver() {
|
||||
fout.close();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_mesh(
|
||||
const FloatVector& nodes,
|
||||
const IndexVector& elements,
|
||||
const IntVector& element_lengths,
|
||||
const IntVector& element_types,
|
||||
const IntVector& element_tags
|
||||
) {
|
||||
|
||||
save_header();
|
||||
|
||||
save_nodes(nodes);
|
||||
|
||||
save_elements(elements, element_lengths, element_types, element_tags );
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_header() {
|
||||
if (!m_binary) {
|
||||
fout << "$MeshFormat" << std::endl;
|
||||
fout << "2.2 0 " << sizeof(double) << std::endl;
|
||||
fout << "$EndMeshFormat" << std::endl;
|
||||
fout.precision(17);
|
||||
} else {
|
||||
fout << "$MeshFormat" << std::endl;
|
||||
fout << "2.2 1 " << sizeof(double) << std::endl;
|
||||
int one = 1;
|
||||
fout.write((char*)&one, sizeof(int));
|
||||
fout << "\n$EndMeshFormat" << std::endl;
|
||||
}
|
||||
fout.flush();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_nodes(const FloatVector& nodes) {
|
||||
// Save nodes.
|
||||
// 3D hadrcoded
|
||||
m_num_nodes = nodes.size() / 3;
|
||||
fout << "$Nodes" << std::endl;
|
||||
fout << m_num_nodes << std::endl;
|
||||
if (!m_binary) {
|
||||
for (size_t i=0; i<nodes.size(); i+=3) {
|
||||
//const VectorF& v = nodes.segment(i,m_dim);
|
||||
int node_idx = i/3 + 1;
|
||||
fout << node_idx << " " << nodes[i] << " " << nodes[i+1] << " " << nodes[i+2] << std::endl;
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<nodes.size(); i+=3) {
|
||||
//const VectorF& v = nodes.segment(i,m_dim);
|
||||
int node_idx = i/3 + 1;
|
||||
fout.write((const char*)&node_idx, sizeof(int));
|
||||
fout.write((const char*)&nodes[i], sizeof(Float)*3);
|
||||
}
|
||||
}
|
||||
fout << "$EndNodes" << std::endl;
|
||||
fout.flush();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_elements(const IndexVector& elements,
|
||||
const IntVector& element_lengths,
|
||||
const IntVector& element_types,
|
||||
const IntVector& element_tags)
|
||||
{
|
||||
|
||||
m_num_elements = element_tags.size();
|
||||
assert(element_lengths.size() == element_types.size() );
|
||||
assert(element_lengths.size() == element_tags.size() );
|
||||
// TODO: sum up all lengths
|
||||
// Save elements.
|
||||
// node inxes are 1-based
|
||||
fout << "$Elements" << std::endl;
|
||||
fout << m_num_elements << std::endl;
|
||||
|
||||
if (m_num_elements > 0) {
|
||||
//int elem_type = el_type;
|
||||
int num_elems = m_num_elements;
|
||||
//int tags = 0;
|
||||
if (!m_binary) {
|
||||
size_t el_ptr=0;
|
||||
for (size_t i=0;i<m_num_elements;++i) {
|
||||
|
||||
int elem_num = (int) i + 1;
|
||||
///VectorI elem = elements.segment(i, nodes_per_element) + VectorI::Ones(nodes_per_element);
|
||||
// hardcoded: duplicate tags (I don't know why)
|
||||
fout << elem_num << " " << element_types[i] << " " << 2 << " "<< element_tags[i] << " "<< element_tags[i] << " ";
|
||||
for (size_t j=0; j<element_lengths[i]; j++) {
|
||||
fout << elements[el_ptr + j] + 1 << " ";
|
||||
}
|
||||
fout << std::endl;
|
||||
el_ptr+=element_lengths[i];
|
||||
}
|
||||
} else {
|
||||
size_t el_ptr=0,i=0;
|
||||
while(i<m_num_elements) {
|
||||
|
||||
// write elements in consistent chunks
|
||||
// TODO: refactor this code to be able to specify different elements
|
||||
// more effeciently
|
||||
|
||||
int elem_type=-1;
|
||||
int elem_len=-1;
|
||||
size_t j=i;
|
||||
for(;j<m_num_elements;++j)
|
||||
{
|
||||
if( elem_type==-1 )
|
||||
{
|
||||
elem_type=element_types[j];
|
||||
elem_len=element_lengths[j];
|
||||
} else if( elem_type!=element_types[j] ||
|
||||
elem_len!=element_lengths[j]) {
|
||||
break; // found the edge of the segment
|
||||
}
|
||||
}
|
||||
|
||||
//hardcoded: 2 tags
|
||||
int num_elems=j-i, num_tags=2;
|
||||
|
||||
fout.write((const char*)& elem_type, sizeof(int));
|
||||
fout.write((const char*)& num_elems, sizeof(int));
|
||||
fout.write((const char*)& num_tags, sizeof(int));
|
||||
|
||||
for(int k=0;k<num_elems; ++k,++i){
|
||||
int elem_num = (int )i + 1;
|
||||
fout.write((const char*)&elem_num, sizeof(int));
|
||||
|
||||
// HACK: hardcoded 2 tags
|
||||
fout.write((const char*)& element_tags[i], sizeof(int));
|
||||
fout.write((const char*)& element_tags[i], sizeof(int));
|
||||
|
||||
for (size_t e=0; e<elem_len; e++) {
|
||||
int _elem = static_cast<int>( elements[el_ptr + e] )+1;
|
||||
fout.write((const char*)&_elem, sizeof(int));
|
||||
}
|
||||
el_ptr+=elem_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fout << "$EndElements" << std::endl;
|
||||
fout.flush();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_scalar_field(const std::string& fieldname, const FloatVector& field) {
|
||||
assert(field.size() == m_num_nodes);
|
||||
fout << "$NodeData" << std::endl;
|
||||
fout << "1" << std::endl; // num string tags.
|
||||
fout << "\"" << fieldname << "\"" << std::endl;
|
||||
fout << "1" << std::endl; // num real tags.
|
||||
fout << "0.0" << std::endl; // time value.
|
||||
fout << "3" << std::endl; // num int tags.
|
||||
fout << "0" << std::endl; // the time step
|
||||
fout << "1" << std::endl; // 1-component scalar field.
|
||||
fout << m_num_nodes << std::endl; // number of nodes
|
||||
|
||||
if (m_binary) {
|
||||
for (size_t i=0; i<m_num_nodes; i++) {
|
||||
int node_idx = i+1;
|
||||
fout.write((char*)&node_idx, sizeof(int));
|
||||
fout.write((char*)&field[i], sizeof(Float));
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<m_num_nodes; i++) {
|
||||
int node_idx = i+1;
|
||||
fout << node_idx << " " << field[i] << std::endl;
|
||||
}
|
||||
}
|
||||
fout << "$EndNodeData" << std::endl;
|
||||
fout.flush();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_vector_field(const std::string& fieldname, const FloatVector& field) {
|
||||
assert(field.size() == 3 * m_num_nodes);
|
||||
|
||||
fout << "$NodeData" << std::endl;
|
||||
fout << "1" << std::endl; // num string tags.
|
||||
fout << "\"" << fieldname << "\"" << std::endl;
|
||||
fout << "1" << std::endl; // num real tags.
|
||||
fout << "0.0" << std::endl; // time value.
|
||||
fout << "3" << std::endl; // num int tags.
|
||||
fout << "0" << std::endl; // the time step
|
||||
fout << "3" << std::endl; // 3-component vector field.
|
||||
fout << m_num_nodes << std::endl; // number of nodes
|
||||
|
||||
const Float zero = 0.0;
|
||||
if (m_binary) {
|
||||
for (size_t i=0; i<m_num_nodes; i++) {
|
||||
int node_idx = i+1;
|
||||
fout.write((const char*)&node_idx, sizeof(int));
|
||||
fout.write((const char*)&field[i*3], sizeof(Float)*3);
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<m_num_nodes; i++) {
|
||||
int node_idx = i+1;
|
||||
fout << node_idx
|
||||
<< " " << field[i*3]
|
||||
<< " " << field[i*3+1]
|
||||
<< " " << field[i*3+2]
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
fout << "$EndNodeData" << std::endl;
|
||||
fout.flush();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_elem_scalar_field(const std::string& fieldname, const FloatVector& field) {
|
||||
assert(field.size() == m_num_elements);
|
||||
fout << "$ElementData" << std::endl;
|
||||
fout << 1 << std::endl; // num string tags.
|
||||
fout << "\"" << fieldname << "\"" << std::endl;
|
||||
fout << "1" << std::endl; // num real tags.
|
||||
fout << "0.0" << std::endl; // time value.
|
||||
fout << "3" << std::endl; // num int tags.
|
||||
fout << "0" << std::endl; // the time step
|
||||
fout << "1" << std::endl; // 1-component scalar field.
|
||||
fout << m_num_elements << std::endl; // number of elements
|
||||
|
||||
if (m_binary) {
|
||||
for (size_t i=0; i<m_num_elements; i++) {
|
||||
int elem_idx = i+1;
|
||||
fout.write((const char*)&elem_idx, sizeof(int));
|
||||
fout.write((const char*)&field[i], sizeof(Float));
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<m_num_elements; i++) {
|
||||
int elem_idx = i+1;
|
||||
fout << elem_idx << " " << field[i] << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
fout << "$EndElementData" << std::endl;
|
||||
fout.flush();
|
||||
}
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_elem_vector_field(const std::string& fieldname, const FloatVector& field) {
|
||||
assert(field.size() == m_num_elements * 3);
|
||||
fout << "$ElementData" << std::endl;
|
||||
fout << 1 << std::endl; // num string tags.
|
||||
fout << "\"" << fieldname << "\"" << std::endl;
|
||||
fout << "1" << std::endl; // num real tags.
|
||||
fout << "0.0" << std::endl; // time value.
|
||||
fout << "3" << std::endl; // num int tags.
|
||||
fout << "0" << std::endl; // the time step
|
||||
fout << "3" << std::endl; // 3-component vector field.
|
||||
fout << m_num_elements << std::endl; // number of elements
|
||||
|
||||
const Float zero = 0.0;
|
||||
if (m_binary) {
|
||||
for (size_t i=0; i<m_num_elements; ++i) {
|
||||
int elem_idx = i+1;
|
||||
fout.write((const char*)&elem_idx, sizeof(int));
|
||||
fout.write((const char*)&field[i*3], sizeof(Float) * 3);
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<m_num_elements; ++i) {
|
||||
int elem_idx = i+1;
|
||||
fout << elem_idx
|
||||
<< " " << field[i*3]
|
||||
<< " " << field[i*3+1]
|
||||
<< " " << field[i*3+2]
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
fout << "$EndElementData" << std::endl;
|
||||
fout.flush();
|
||||
}
|
||||
|
||||
|
||||
IGL_INLINE void igl::MshSaver::save_elem_tensor_field(const std::string& fieldname, const FloatVector& field) {
|
||||
assert(field.size() == m_num_elements * 3 * (3 + 1) / 2);
|
||||
fout << "$ElementData" << std::endl;
|
||||
fout << 1 << std::endl; // num string tags.
|
||||
fout << "\"" << fieldname << "\"" << std::endl;
|
||||
fout << "1" << std::endl; // num real tags.
|
||||
fout << "0.0" << std::endl; // time value.
|
||||
fout << "3" << std::endl; // num int tags.
|
||||
fout << "0" << std::endl; // the time step
|
||||
fout << "9" << std::endl; // 9-component tensor field.
|
||||
fout << m_num_elements << std::endl; // number of elements
|
||||
|
||||
const Float zero = 0.0;
|
||||
|
||||
if (m_binary) {
|
||||
for (size_t i=0; i<m_num_elements; i++) {
|
||||
int elem_idx = i+1;
|
||||
fout.write((char*)&elem_idx, sizeof(int));
|
||||
//const VectorF& val = field.segment(i*6, 6);
|
||||
const Float* val = &field[i*6];
|
||||
Float tensor[9] = {
|
||||
val[0], val[5], val[4],
|
||||
val[5], val[1], val[3],
|
||||
val[4], val[3], val[2] };
|
||||
fout.write((char*)tensor, sizeof(Float) * 9);
|
||||
}
|
||||
} else {
|
||||
for (size_t i=0; i<m_num_elements; i++) {
|
||||
int elem_idx = i+1;
|
||||
const Float* val = &field[i*6];
|
||||
fout << elem_idx
|
||||
<< " " << val[0]
|
||||
<< " " << val[5]
|
||||
<< " " << val[4]
|
||||
<< " " << val[5]
|
||||
<< " " << val[1]
|
||||
<< " " << val[3]
|
||||
<< " " << val[4]
|
||||
<< " " << val[3]
|
||||
<< " " << val[2]
|
||||
<< std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
fout << "$EndElementData" << std::endl;
|
||||
fout.flush();
|
||||
}
|
||||
84
src/external/libigl-2.3.0/include/igl/MshSaver.h
vendored
84
src/external/libigl-2.3.0/include/igl/MshSaver.h
vendored
@ -1,84 +0,0 @@
|
||||
// based on MSH writer from PyMesh
|
||||
|
||||
// Copyright (c) 2015 Qingnan Zhou <qzhou@adobe.com>
|
||||
// Copyright (C) 2020 Vladimir Fonov <vladimir.fonov@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla
|
||||
// Public License v. 2.0. If a copy of the MPL was not distributed
|
||||
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_MSH_SAVER_H
|
||||
#define IGL_MSH_SAVER_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <fstream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace igl {
|
||||
|
||||
// Class for dumping information to .msh file
|
||||
// depends only on c++stl library
|
||||
// current implementation works only with 3D information
|
||||
class MshSaver {
|
||||
public:
|
||||
typedef double Float;
|
||||
|
||||
typedef std::vector<int> IndexVector;
|
||||
typedef std::vector<int> IntVector;
|
||||
typedef std::vector<Float> FloatVector;
|
||||
typedef std::vector<FloatVector> FloatField;
|
||||
typedef std::vector<IntVector> IntField;
|
||||
typedef std::vector<std::string> FieldNames;
|
||||
|
||||
MshSaver(const std::string& filename, bool binary=true);
|
||||
~MshSaver();
|
||||
|
||||
public:
|
||||
// Only these element types are supported right now
|
||||
enum {ELEMENT_LINE=1, ELEMENT_TRI=2, ELEMENT_QUAD=3,
|
||||
ELEMENT_TET=4, ELEMENT_HEX=5, ELEMENT_PRISM=6 };
|
||||
|
||||
public:
|
||||
// save mesh geometry
|
||||
void save_mesh(
|
||||
const FloatVector& nodes,
|
||||
const IndexVector& elements,
|
||||
const IntVector& element_lengths,
|
||||
const IntVector& element_type,
|
||||
const IntVector& element_tags );
|
||||
|
||||
// save additional fields associated with the mesh
|
||||
|
||||
// add node scalar field
|
||||
void save_scalar_field(const std::string& fieldname, const FloatVector& field);
|
||||
// add node vectot field
|
||||
void save_vector_field(const std::string& fieldname, const FloatVector& field);
|
||||
// add element scalar field
|
||||
void save_elem_scalar_field(const std::string& fieldname, const FloatVector& field);
|
||||
// add element vector field
|
||||
void save_elem_vector_field(const std::string& fieldname, const FloatVector& field);
|
||||
// add element tensor field
|
||||
void save_elem_tensor_field(const std::string& fieldname, const FloatVector& field);
|
||||
|
||||
protected:
|
||||
void save_header();
|
||||
void save_nodes(const FloatVector& nodes);
|
||||
void save_elements(const IndexVector& elements,
|
||||
const IntVector& element_lengths,
|
||||
const IntVector& element_type,
|
||||
const IntVector& element_tags);
|
||||
|
||||
private:
|
||||
bool m_binary;
|
||||
size_t m_num_nodes;
|
||||
size_t m_num_elements;
|
||||
|
||||
std::ofstream fout;
|
||||
};
|
||||
} //igl
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "MshSaver.cpp"
|
||||
#endif
|
||||
|
||||
#endif //MSH_SAVER_H
|
||||
@ -1,27 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_NORMALTYPE_H
|
||||
#define IGL_NORMALTYPE_H
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// PER_VERTEX_NORMALS Normals computed per vertex based on incident faces
|
||||
// PER_FACE_NORMALS Normals computed per face
|
||||
// PER_CORNER_NORMALS Normals computed per corner (aka wedge) based on
|
||||
// incident faces without sharp edge
|
||||
enum NormalType
|
||||
{
|
||||
PER_VERTEX_NORMALS,
|
||||
PER_FACE_NORMALS,
|
||||
PER_CORNER_NORMALS
|
||||
};
|
||||
# define NUM_NORMAL_TYPE 3
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
22
src/external/libigl-2.3.0/include/igl/ONE.h
vendored
22
src/external/libigl-2.3.0/include/igl/ONE.h
vendored
@ -1,22 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ONE_H
|
||||
#define IGL_ONE_H
|
||||
namespace igl
|
||||
{
|
||||
// Often one needs a reference to a dummy variable containing one as its
|
||||
// value, for example when using AntTweakBar's
|
||||
// TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ONE);
|
||||
const char CHAR_ONE = 1;
|
||||
const int INT_ONE = 1;
|
||||
const unsigned int UNSIGNED_INT_ONE = 1;
|
||||
const double DOUBLE_ONE = 1;
|
||||
const float FLOAT_ONE = 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
19
src/external/libigl-2.3.0/include/igl/PI.h
vendored
19
src/external/libigl-2.3.0/include/igl/PI.h
vendored
@ -1,19 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_PI_H
|
||||
#define IGL_PI_H
|
||||
namespace igl
|
||||
{
|
||||
// Use standard mathematical constants' M_PI if available
|
||||
#ifdef M_PI
|
||||
constexpr double PI = M_PI;
|
||||
#else
|
||||
constexpr double PI = 3.1415926535897932384626433832795;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
55
src/external/libigl-2.3.0/include/igl/REDRUM.h
vendored
55
src/external/libigl-2.3.0/include/igl/REDRUM.h
vendored
@ -1,55 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_REDRUM_H
|
||||
#define IGL_REDRUM_H
|
||||
|
||||
// Q: These should probably be inside the igl namespace. What's the correct
|
||||
// way to do that?
|
||||
// A: I guess the right way is to not use a macro but a proper function with
|
||||
// streams as input and output.
|
||||
|
||||
// ANSI color codes for formatting iostream style output
|
||||
|
||||
#ifdef IGL_REDRUM_NOOP
|
||||
|
||||
// Bold Red, etc.
|
||||
#define NORUM(X) X
|
||||
#define REDRUM(X) X
|
||||
#define GREENRUM(X) X
|
||||
#define YELLOWRUM(X) X
|
||||
#define BLUERUM(X) X
|
||||
#define MAGENTARUM(X) X
|
||||
#define CYANRUM(X) X
|
||||
// Regular Red, etc.
|
||||
#define REDGIN(X) X
|
||||
#define GREENGIN(X) X
|
||||
#define YELLOWGIN(X) X
|
||||
#define BLUEGIN(X) X
|
||||
#define MAGENTAGIN(X) X
|
||||
#define CYANGIN(X) X
|
||||
|
||||
#else
|
||||
|
||||
// Bold Red, etc.
|
||||
#define NORUM(X) ""<<X<<""
|
||||
#define REDRUM(X) "\e[1m\e[31m"<<X<<"\e[m"
|
||||
#define GREENRUM(X) "\e[1m\e[32m"<<X<<"\e[m"
|
||||
#define YELLOWRUM(X) "\e[1m\e[33m"<<X<<"\e[m"
|
||||
#define BLUERUM(X) "\e[1m\e[34m"<<X<<"\e[m"
|
||||
#define MAGENTARUM(X) "\e[1m\e[35m"<<X<<"\e[m"
|
||||
#define CYANRUM(X) "\e[1m\e[36m"<<X<<"\e[m"
|
||||
// Regular Red, etc.
|
||||
#define REDGIN(X) "\e[31m"<<X<<"\e[m"
|
||||
#define GREENGIN(X) "\e[32m"<<X<<"\e[m"
|
||||
#define YELLOWGIN(X) "\e[33m"<<X<<"\e[m"
|
||||
#define BLUEGIN(X) "\e[34m"<<X<<"\e[m"
|
||||
#define MAGENTAGIN(X) "\e[35m"<<X<<"\e[m"
|
||||
#define CYANGIN(X) "\e[36m"<<X<<"\e[m"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
18
src/external/libigl-2.3.0/include/igl/STR.h
vendored
18
src/external/libigl-2.3.0/include/igl/STR.h
vendored
@ -1,18 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_STR_H
|
||||
#define IGL_STR_H
|
||||
// http://stackoverflow.com/a/2433143/148668
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
// Suppose you have a function:
|
||||
// void func(std::string c);
|
||||
// Then you can write:
|
||||
// func(STR("foo"<<1<<"bar"));
|
||||
#define STR(X) static_cast<std::ostringstream&>(std::ostringstream().flush() << X).str()
|
||||
#endif
|
||||
@ -1,128 +0,0 @@
|
||||
//#####################################################################
|
||||
// Copyright (c) 2010-2011, Eftychios Sifakis.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
|
||||
// other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//#####################################################################
|
||||
|
||||
//###########################################################
|
||||
// Compute the Givens half-angle, construct the Givens quaternion and the rotation sine/cosine (for the full angle)
|
||||
//###########################################################
|
||||
|
||||
#ifdef _WIN32
|
||||
#undef max
|
||||
#undef min
|
||||
#endif
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=SANPIVOT.f*SANPIVOT.f;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(VANPIVOT,VANPIVOT);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(VANPIVOT,VANPIVOT);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=(Ssh.f>=Ssmall_number.f)?0xffffffff:0;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_cmpge_ps(Vsh,Vsmall_number);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_cmp_ps(Vsh,Vsmall_number, _CMP_GE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_cmpge_ps(Vsh,Vsmall_number);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Ssh.ui&SANPIVOT.ui;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_and_ps(Vsh,VANPIVOT);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_and_ps(Vsh,VANPIVOT);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp5.f=0.;) ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_xor_ps(Vtmp5,Vtmp5);) ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_xor_ps(Vtmp5,Vtmp5);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Stmp5.f-SAPIVOT.f;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_sub_ps(Vtmp5,VAPIVOT);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_sub_ps(Vtmp5,VAPIVOT);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.f=std::max(Sch.f,SAPIVOT.f);) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_max_ps(Vch,VAPIVOT);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_max_ps(Vch,VAPIVOT);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.f=std::max(Sch.f,Ssmall_number.f);) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_max_ps(Vch,Vsmall_number);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_max_ps(Vch,Vsmall_number);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp5.ui=(SAPIVOT.f>=Stmp5.f)?0xffffffff:0;) ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_cmpge_ps(VAPIVOT,Vtmp5);) ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_cmp_ps(VAPIVOT,Vtmp5, _CMP_GE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_cmpge_ps(VAPIVOT,Vtmp5);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Sch.f*Sch.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vch,Vch);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vch,Vch);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Stmp1.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_add_ps(Vtmp1,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_add_ps(Vtmp1,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=rsqrt(Stmp2.f);) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_rsqrt_ps(Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_rsqrt_ps(Vtmp2);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp1.f*Sone_half.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vtmp1,Vone_half);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vtmp1,Vone_half);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp2.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp2,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp2,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f+Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_add_ps(Vtmp1,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_add_ps(Vtmp1,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f-Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_sub_ps(Vtmp1,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_sub_ps(Vtmp1,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f*Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vtmp1,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vtmp1,Vtmp2);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Sch.f+Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_add_ps(Vch,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_add_ps(Vch,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.ui=~Stmp5.ui&Ssh.ui;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_andnot_ps(Vtmp5,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=Vch;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=~Stmp5.ui&Sch.ui;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_andnot_ps(Vtmp5,Vch);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_blendv_ps(Vsh,Vch,Vtmp5);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Stmp5.ui&Sch.ui;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_and_ps(Vtmp5,Vch);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_blendv_ps(Vtmp1,Vsh,Vtmp5);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Stmp5.ui&Ssh.ui;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_and_ps(Vtmp5,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Sch.ui|Stmp1.ui;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_or_ps(Vch,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Ssh.ui|Stmp2.ui;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_or_ps(Vsh,Vtmp2);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Sch.f*Sch.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vch,Vch);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vch,Vch);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Stmp1.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_add_ps(Vtmp1,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_add_ps(Vtmp1,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=rsqrt(Stmp2.f);) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_rsqrt_ps(Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_rsqrt_ps(Vtmp2);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp1.f*Sone_half.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vtmp1,Vone_half);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vtmp1,Vone_half);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp1,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp1,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp2.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vtmp2,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vtmp2,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f+Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_add_ps(Vtmp1,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_add_ps(Vtmp1,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Stmp1.f-Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_sub_ps(Vtmp1,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_sub_ps(Vtmp1,Vtmp3);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Sch.f*Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_mul_ps(Vch,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_mul_ps(Vch,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=Ssh.f*Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(Vsh,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(Vsh,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Sch.f*Sch.f;) ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vch,Vch);) ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vch,Vch);)ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ssh.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vsh,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vsh,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Sc.f-Ss.f;) ENABLE_SSE_IMPLEMENTATION(Vc=_mm_sub_ps(Vc,Vs);) ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_sub_ps(Vc,Vs);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ssh.f*Sch.f;) ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vsh,Vch);) ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vsh,Vch);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ss.f+Ss.f;) ENABLE_SSE_IMPLEMENTATION(Vs=_mm_add_ps(Vs,Vs);) ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_add_ps(Vs,Vs);)
|
||||
|
||||
//###########################################################
|
||||
// Rotate matrix A
|
||||
//###########################################################
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SA11.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VA11);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VA11);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SA21.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VA21);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VA21);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA11.f=Sc.f*SA11.f;) ENABLE_SSE_IMPLEMENTATION(VA11=_mm_mul_ps(Vc,VA11);) ENABLE_AVX_IMPLEMENTATION(VA11=_mm256_mul_ps(Vc,VA11);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA21.f=Sc.f*SA21.f;) ENABLE_SSE_IMPLEMENTATION(VA21=_mm_mul_ps(Vc,VA21);) ENABLE_AVX_IMPLEMENTATION(VA21=_mm256_mul_ps(Vc,VA21);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA11.f=SA11.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VA11=_mm_add_ps(VA11,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VA11=_mm256_add_ps(VA11,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA21.f=SA21.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VA21=_mm_sub_ps(VA21,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VA21=_mm256_sub_ps(VA21,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SA12.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VA12);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VA12);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SA22.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VA22);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VA22);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA12.f=Sc.f*SA12.f;) ENABLE_SSE_IMPLEMENTATION(VA12=_mm_mul_ps(Vc,VA12);) ENABLE_AVX_IMPLEMENTATION(VA12=_mm256_mul_ps(Vc,VA12);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA22.f=Sc.f*SA22.f;) ENABLE_SSE_IMPLEMENTATION(VA22=_mm_mul_ps(Vc,VA22);) ENABLE_AVX_IMPLEMENTATION(VA22=_mm256_mul_ps(Vc,VA22);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA12.f=SA12.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VA12=_mm_add_ps(VA12,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VA12=_mm256_add_ps(VA12,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA22.f=SA22.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VA22=_mm_sub_ps(VA22,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VA22=_mm256_sub_ps(VA22,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SA13.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VA13);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VA13);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SA23.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VA23);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VA23);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA13.f=Sc.f*SA13.f;) ENABLE_SSE_IMPLEMENTATION(VA13=_mm_mul_ps(Vc,VA13);) ENABLE_AVX_IMPLEMENTATION(VA13=_mm256_mul_ps(Vc,VA13);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA23.f=Sc.f*SA23.f;) ENABLE_SSE_IMPLEMENTATION(VA23=_mm_mul_ps(Vc,VA23);) ENABLE_AVX_IMPLEMENTATION(VA23=_mm256_mul_ps(Vc,VA23);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA13.f=SA13.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VA13=_mm_add_ps(VA13,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VA13=_mm256_add_ps(VA13,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SA23.f=SA23.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VA23=_mm_sub_ps(VA23,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VA23=_mm256_sub_ps(VA23,Vtmp1);)
|
||||
|
||||
//###########################################################
|
||||
// Update matrix U
|
||||
//###########################################################
|
||||
|
||||
#ifdef COMPUTE_U_AS_MATRIX
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SU11.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VU11);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VU11);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SU12.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VU12);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VU12);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU11.f=Sc.f*SU11.f;) ENABLE_SSE_IMPLEMENTATION(VU11=_mm_mul_ps(Vc,VU11);) ENABLE_AVX_IMPLEMENTATION(VU11=_mm256_mul_ps(Vc,VU11);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU12.f=Sc.f*SU12.f;) ENABLE_SSE_IMPLEMENTATION(VU12=_mm_mul_ps(Vc,VU12);) ENABLE_AVX_IMPLEMENTATION(VU12=_mm256_mul_ps(Vc,VU12);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU11.f=SU11.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VU11=_mm_add_ps(VU11,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VU11=_mm256_add_ps(VU11,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU12.f=SU12.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VU12=_mm_sub_ps(VU12,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VU12=_mm256_sub_ps(VU12,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SU21.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VU21);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VU21);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SU22.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VU22);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VU22);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU21.f=Sc.f*SU21.f;) ENABLE_SSE_IMPLEMENTATION(VU21=_mm_mul_ps(Vc,VU21);) ENABLE_AVX_IMPLEMENTATION(VU21=_mm256_mul_ps(Vc,VU21);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU22.f=Sc.f*SU22.f;) ENABLE_SSE_IMPLEMENTATION(VU22=_mm_mul_ps(Vc,VU22);) ENABLE_AVX_IMPLEMENTATION(VU22=_mm256_mul_ps(Vc,VU22);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU21.f=SU21.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VU21=_mm_add_ps(VU21,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VU21=_mm256_add_ps(VU21,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU22.f=SU22.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VU22=_mm_sub_ps(VU22,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VU22=_mm256_sub_ps(VU22,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SU31.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VU31);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VU31);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SU32.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VU32);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VU32);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU31.f=Sc.f*SU31.f;) ENABLE_SSE_IMPLEMENTATION(VU31=_mm_mul_ps(Vc,VU31);) ENABLE_AVX_IMPLEMENTATION(VU31=_mm256_mul_ps(Vc,VU31);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU32.f=Sc.f*SU32.f;) ENABLE_SSE_IMPLEMENTATION(VU32=_mm_mul_ps(Vc,VU32);) ENABLE_AVX_IMPLEMENTATION(VU32=_mm256_mul_ps(Vc,VU32);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU31.f=SU31.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VU31=_mm_add_ps(VU31,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VU31=_mm256_add_ps(VU31,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SU32.f=SU32.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VU32=_mm_sub_ps(VU32,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VU32=_mm256_sub_ps(VU32,Vtmp1);)
|
||||
#endif
|
||||
@ -1,118 +0,0 @@
|
||||
//#####################################################################
|
||||
// Copyright (c) 2010-2011, Eftychios Sifakis.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
|
||||
// other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//#####################################################################
|
||||
|
||||
//###########################################################
|
||||
// Compute the Givens angle (and half-angle)
|
||||
//###########################################################
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=SS21.f*Sone_half.f;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(VS21,Vone_half);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(VS21,Vone_half);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp5.f=SS11.f-SS22.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_sub_ps(VS11,VS22);) ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_sub_ps(VS11,VS22);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.ui=(Stmp2.f>=Stiny_number.f)?0xffffffff:0;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_cmpge_ps(Vtmp2,Vtiny_number);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmp_ps(Vtmp2,Vtiny_number, _CMP_GE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmpge_ps(Vtmp2,Vtiny_number);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Stmp1.ui&Ssh.ui;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_and_ps(Vtmp1,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_and_ps(Vtmp1,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Stmp1.ui&Stmp5.ui;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_and_ps(Vtmp1,Vtmp5);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_blendv_ps(Vone,Vtmp5,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=~Stmp1.ui&Sone.ui;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_andnot_ps(Vtmp1,Vone);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Sch.ui|Stmp2.ui;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_or_ps(Vch,Vtmp2);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ssh.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vsh,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vsh,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Sch.f*Sch.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vch,Vch);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vch,Vch);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_add_ps(Vtmp1,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_add_ps(Vtmp1,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=rsqrt(Stmp3.f);) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_rsqrt_ps(Vtmp3);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_rsqrt_ps(Vtmp3);)
|
||||
|
||||
#ifdef USE_ACCURATE_RSQRT_IN_JACOBI_CONJUGATION
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Stmp4.f*Sone_half.f;) ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vtmp4,Vone_half);) ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vtmp4,Vone_half);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp4.f*Ss.f;) ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vtmp4,Vs);) ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vtmp4,Vs);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp4.f*Sc.f;) ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vtmp4,Vc);) ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vtmp4,Vc);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp3.f*Sc.f;) ENABLE_SSE_IMPLEMENTATION(Vc=_mm_mul_ps(Vtmp3,Vc);) ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_mul_ps(Vtmp3,Vc);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp4.f+Ss.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_add_ps(Vtmp4,Vs);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_add_ps(Vtmp4,Vs);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp4.f-Sc.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_sub_ps(Vtmp4,Vc);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_sub_ps(Vtmp4,Vc);)
|
||||
#endif
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=Stmp4.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(Vtmp4,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(Vtmp4,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.f=Stmp4.f*Sch.f;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_mul_ps(Vtmp4,Vch);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_mul_ps(Vtmp4,Vch);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Sfour_gamma_squared.f*Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vfour_gamma_squared,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vfour_gamma_squared,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.ui=(Stmp2.f<=Stmp1.f)?0xffffffff:0;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_cmple_ps(Vtmp2,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmp_ps(Vtmp2,Vtmp1, _CMP_LE_OS);) //ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_cmple_ps(Vtmp2,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=Ssine_pi_over_eight.ui&Stmp1.ui;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_and_ps(Vsine_pi_over_eight,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_blendv_ps(Vsh,Vsine_pi_over_eight,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=~Stmp1.ui&Ssh.ui;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_andnot_ps(Vtmp1,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.ui=Ssh.ui|Stmp2.ui;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_or_ps(Vsh,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.ui=Scosine_pi_over_eight.ui&Stmp1.ui;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_and_ps(Vcosine_pi_over_eight,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vch=_mm256_blendv_ps(Vch,Vcosine_pi_over_eight,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=~Stmp1.ui&Sch.ui;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_andnot_ps(Vtmp1,Vch);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sch.ui=Sch.ui|Stmp2.ui;) ENABLE_SSE_IMPLEMENTATION(Vch=_mm_or_ps(Vch,Vtmp2);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ssh.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vsh,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vsh,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Sch.f*Sch.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vch,Vch);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vch,Vch);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sc.f=Stmp2.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(Vc=_mm_sub_ps(Vtmp2,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(Vc=_mm256_sub_ps(Vtmp2,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Sch.f*Ssh.f;) ENABLE_SSE_IMPLEMENTATION(Vs=_mm_mul_ps(Vch,Vsh);) ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_mul_ps(Vch,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ss.f=Ss.f+Ss.f;) ENABLE_SSE_IMPLEMENTATION(Vs=_mm_add_ps(Vs,Vs);) ENABLE_AVX_IMPLEMENTATION(Vs=_mm256_add_ps(Vs,Vs);)
|
||||
|
||||
//###########################################################
|
||||
// Perform the actual Givens conjugation
|
||||
//###########################################################
|
||||
|
||||
#ifndef USE_ACCURATE_RSQRT_IN_JACOBI_CONJUGATION
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Stmp1.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_add_ps(Vtmp1,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_add_ps(Vtmp1,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS33.f=SS33.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(VS33=_mm_mul_ps(VS33,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(VS33=_mm256_mul_ps(VS33,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS31.f=SS31.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(VS31=_mm_mul_ps(VS31,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(VS31=_mm256_mul_ps(VS31,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS32.f=SS32.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(VS32=_mm_mul_ps(VS32,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(VS32=_mm256_mul_ps(VS32,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS33.f=SS33.f*Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(VS33=_mm_mul_ps(VS33,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(VS33=_mm256_mul_ps(VS33,Vtmp3);)
|
||||
#endif
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ss.f*SS31.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vs,VS31);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vs,VS31);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*SS32.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,VS32);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,VS32);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS31.f=Sc.f*SS31.f;) ENABLE_SSE_IMPLEMENTATION(VS31=_mm_mul_ps(Vc,VS31);) ENABLE_AVX_IMPLEMENTATION(VS31=_mm256_mul_ps(Vc,VS31);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS32.f=Sc.f*SS32.f;) ENABLE_SSE_IMPLEMENTATION(VS32=_mm_mul_ps(Vc,VS32);) ENABLE_AVX_IMPLEMENTATION(VS32=_mm256_mul_ps(Vc,VS32);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS31.f=Stmp2.f+SS31.f;) ENABLE_SSE_IMPLEMENTATION(VS31=_mm_add_ps(Vtmp2,VS31);) ENABLE_AVX_IMPLEMENTATION(VS31=_mm256_add_ps(Vtmp2,VS31);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS32.f=SS32.f-Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VS32=_mm_sub_ps(VS32,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VS32=_mm256_sub_ps(VS32,Vtmp1);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ss.f*Ss.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vs,Vs);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vs,Vs);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=SS22.f*Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(VS22,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(VS22,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=SS11.f*Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(VS11,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(VS11,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Sc.f*Sc.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vc,Vc);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vc,Vc);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS11.f=SS11.f*Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(VS11=_mm_mul_ps(VS11,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(VS11=_mm256_mul_ps(VS11,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS22.f=SS22.f*Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(VS22=_mm_mul_ps(VS22,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(VS22=_mm256_mul_ps(VS22,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS11.f=SS11.f+Stmp1.f;) ENABLE_SSE_IMPLEMENTATION(VS11=_mm_add_ps(VS11,Vtmp1);) ENABLE_AVX_IMPLEMENTATION(VS11=_mm256_add_ps(VS11,Vtmp1);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS22.f=SS22.f+Stmp3.f;) ENABLE_SSE_IMPLEMENTATION(VS22=_mm_add_ps(VS22,Vtmp3);) ENABLE_AVX_IMPLEMENTATION(VS22=_mm256_add_ps(VS22,Vtmp3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Stmp4.f-Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_sub_ps(Vtmp4,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_sub_ps(Vtmp4,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=SS21.f+SS21.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_add_ps(VS21,VS21);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_add_ps(VS21,VS21);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS21.f=SS21.f*Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(VS21=_mm_mul_ps(VS21,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(VS21=_mm256_mul_ps(VS21,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp4.f=Sc.f*Ss.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp4=_mm_mul_ps(Vc,Vs);) ENABLE_AVX_IMPLEMENTATION(Vtmp4=_mm256_mul_ps(Vc,Vs);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Stmp2.f*Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vtmp2,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vtmp2,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp5.f=Stmp5.f*Stmp4.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp5=_mm_mul_ps(Vtmp5,Vtmp4);) ENABLE_AVX_IMPLEMENTATION(Vtmp5=_mm256_mul_ps(Vtmp5,Vtmp4);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS11.f=SS11.f+Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VS11=_mm_add_ps(VS11,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VS11=_mm256_add_ps(VS11,Vtmp2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS21.f=SS21.f-Stmp5.f;) ENABLE_SSE_IMPLEMENTATION(VS21=_mm_sub_ps(VS21,Vtmp5);) ENABLE_AVX_IMPLEMENTATION(VS21=_mm256_sub_ps(VS21,Vtmp5);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SS22.f=SS22.f-Stmp2.f;) ENABLE_SSE_IMPLEMENTATION(VS22=_mm_sub_ps(VS22,Vtmp2);) ENABLE_AVX_IMPLEMENTATION(VS22=_mm256_sub_ps(VS22,Vtmp2);)
|
||||
|
||||
//###########################################################
|
||||
// Compute the cumulative rotation, in quaternion form
|
||||
//###########################################################
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp1.f=Ssh.f*Sqvvx.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp1=_mm_mul_ps(Vsh,Vqvvx);) ENABLE_AVX_IMPLEMENTATION(Vtmp1=_mm256_mul_ps(Vsh,Vqvvx);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp2.f=Ssh.f*Sqvvy.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp2=_mm_mul_ps(Vsh,Vqvvy);) ENABLE_AVX_IMPLEMENTATION(Vtmp2=_mm256_mul_ps(Vsh,Vqvvy);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stmp3.f=Ssh.f*Sqvvz.f;) ENABLE_SSE_IMPLEMENTATION(Vtmp3=_mm_mul_ps(Vsh,Vqvvz);) ENABLE_AVX_IMPLEMENTATION(Vtmp3=_mm256_mul_ps(Vsh,Vqvvz);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssh.f=Ssh.f*Sqvs.f;) ENABLE_SSE_IMPLEMENTATION(Vsh=_mm_mul_ps(Vsh,Vqvs);) ENABLE_AVX_IMPLEMENTATION(Vsh=_mm256_mul_ps(Vsh,Vqvs);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sqvs.f=Sch.f*Sqvs.f;) ENABLE_SSE_IMPLEMENTATION(Vqvs=_mm_mul_ps(Vch,Vqvs);) ENABLE_AVX_IMPLEMENTATION(Vqvs=_mm256_mul_ps(Vch,Vqvs);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sqvvx.f=Sch.f*Sqvvx.f;) ENABLE_SSE_IMPLEMENTATION(Vqvvx=_mm_mul_ps(Vch,Vqvvx);) ENABLE_AVX_IMPLEMENTATION(Vqvvx=_mm256_mul_ps(Vch,Vqvvx);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sqvvy.f=Sch.f*Sqvvy.f;) ENABLE_SSE_IMPLEMENTATION(Vqvvy=_mm_mul_ps(Vch,Vqvvy);) ENABLE_AVX_IMPLEMENTATION(Vqvvy=_mm256_mul_ps(Vch,Vqvvy);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sqvvz.f=Sch.f*Sqvvz.f;) ENABLE_SSE_IMPLEMENTATION(Vqvvz=_mm_mul_ps(Vch,Vqvvz);) ENABLE_AVX_IMPLEMENTATION(Vqvvz=_mm256_mul_ps(Vch,Vqvvz);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SQVVZ.f=SQVVZ.f+Ssh.f;) ENABLE_SSE_IMPLEMENTATION(VQVVZ=_mm_add_ps(VQVVZ,Vsh);) ENABLE_AVX_IMPLEMENTATION(VQVVZ=_mm256_add_ps(VQVVZ,Vsh);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sqvs.f=Sqvs.f-STMP3.f;) ENABLE_SSE_IMPLEMENTATION(Vqvs=_mm_sub_ps(Vqvs,VTMP3);) ENABLE_AVX_IMPLEMENTATION(Vqvs=_mm256_sub_ps(Vqvs,VTMP3);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SQVVX.f=SQVVX.f+STMP2.f;) ENABLE_SSE_IMPLEMENTATION(VQVVX=_mm_add_ps(VQVVX,VTMP2);) ENABLE_AVX_IMPLEMENTATION(VQVVX=_mm256_add_ps(VQVVX,VTMP2);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(SQVVY.f=SQVVY.f-STMP1.f;) ENABLE_SSE_IMPLEMENTATION(VQVVY=_mm_sub_ps(VQVVY,VTMP1);) ENABLE_AVX_IMPLEMENTATION(VQVVY=_mm256_sub_ps(VQVVY,VTMP1);)
|
||||
@ -1,137 +0,0 @@
|
||||
//#####################################################################
|
||||
// Copyright (c) 2010-2011, Eftychios Sifakis.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
|
||||
// other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//#####################################################################
|
||||
|
||||
//###########################################################
|
||||
// Local variable declarations
|
||||
//###########################################################
|
||||
|
||||
#ifdef PRINT_DEBUGGING_OUTPUT
|
||||
|
||||
#ifdef USE_SSE_IMPLEMENTATION
|
||||
float buf[4];
|
||||
float A11,A21,A31,A12,A22,A32,A13,A23,A33;
|
||||
float S11,S21,S31,S22,S32,S33;
|
||||
#ifdef COMPUTE_V_AS_QUATERNION
|
||||
float QVS,QVVX,QVVY,QVVZ;
|
||||
#endif
|
||||
#ifdef COMPUTE_V_AS_MATRIX
|
||||
float V11,V21,V31,V12,V22,V32,V13,V23,V33;
|
||||
#endif
|
||||
#ifdef COMPUTE_U_AS_QUATERNION
|
||||
float QUS,QUVX,QUVY,QUVZ;
|
||||
#endif
|
||||
#ifdef COMPUTE_U_AS_MATRIX
|
||||
float U11,U21,U31,U12,U22,U32,U13,U23,U33;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef USE_AVX_IMPLEMENTATION
|
||||
float buf[8];
|
||||
float A11,A21,A31,A12,A22,A32,A13,A23,A33;
|
||||
float S11,S21,S31,S22,S32,S33;
|
||||
#ifdef COMPUTE_V_AS_QUATERNION
|
||||
float QVS,QVVX,QVVY,QVVZ;
|
||||
#endif
|
||||
#ifdef COMPUTE_V_AS_MATRIX
|
||||
float V11,V21,V31,V12,V22,V32,V13,V23,V33;
|
||||
#endif
|
||||
#ifdef COMPUTE_U_AS_QUATERNION
|
||||
float QUS,QUVX,QUVY,QUVZ;
|
||||
#endif
|
||||
#ifdef COMPUTE_U_AS_MATRIX
|
||||
float U11,U21,U31,U12,U22,U32,U13,U23,U33;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
const float Four_Gamma_Squared=sqrt(8.)+3.;
|
||||
const float Sine_Pi_Over_Eight=.5*sqrt(2.-sqrt(2.));
|
||||
const float Cosine_Pi_Over_Eight=.5*sqrt(2.+sqrt(2.));
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sfour_gamma_squared;) ENABLE_SSE_IMPLEMENTATION(__m128 Vfour_gamma_squared;) ENABLE_AVX_IMPLEMENTATION(__m256 Vfour_gamma_squared;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ssine_pi_over_eight;) ENABLE_SSE_IMPLEMENTATION(__m128 Vsine_pi_over_eight;) ENABLE_AVX_IMPLEMENTATION(__m256 Vsine_pi_over_eight;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Scosine_pi_over_eight;) ENABLE_SSE_IMPLEMENTATION(__m128 Vcosine_pi_over_eight;) ENABLE_AVX_IMPLEMENTATION(__m256 Vcosine_pi_over_eight;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sone_half;) ENABLE_SSE_IMPLEMENTATION(__m128 Vone_half;) ENABLE_AVX_IMPLEMENTATION(__m256 Vone_half;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sone;) ENABLE_SSE_IMPLEMENTATION(__m128 Vone;) ENABLE_AVX_IMPLEMENTATION(__m256 Vone;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stiny_number;) ENABLE_SSE_IMPLEMENTATION(__m128 Vtiny_number;) ENABLE_AVX_IMPLEMENTATION(__m256 Vtiny_number;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ssmall_number;) ENABLE_SSE_IMPLEMENTATION(__m128 Vsmall_number;) ENABLE_AVX_IMPLEMENTATION(__m256 Vsmall_number;)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sfour_gamma_squared.f=Four_Gamma_Squared;) ENABLE_SSE_IMPLEMENTATION(Vfour_gamma_squared=_mm_set1_ps(Four_Gamma_Squared);) ENABLE_AVX_IMPLEMENTATION(Vfour_gamma_squared=_mm256_set1_ps(Four_Gamma_Squared);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssine_pi_over_eight.f=Sine_Pi_Over_Eight;) ENABLE_SSE_IMPLEMENTATION(Vsine_pi_over_eight=_mm_set1_ps(Sine_Pi_Over_Eight);) ENABLE_AVX_IMPLEMENTATION(Vsine_pi_over_eight=_mm256_set1_ps(Sine_Pi_Over_Eight);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Scosine_pi_over_eight.f=Cosine_Pi_Over_Eight;) ENABLE_SSE_IMPLEMENTATION(Vcosine_pi_over_eight=_mm_set1_ps(Cosine_Pi_Over_Eight);) ENABLE_AVX_IMPLEMENTATION(Vcosine_pi_over_eight=_mm256_set1_ps(Cosine_Pi_Over_Eight);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sone_half.f=.5;) ENABLE_SSE_IMPLEMENTATION(Vone_half=_mm_set1_ps(.5);) ENABLE_AVX_IMPLEMENTATION(Vone_half=_mm256_set1_ps(.5);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Sone.f=1.;) ENABLE_SSE_IMPLEMENTATION(Vone=_mm_set1_ps(1.);) ENABLE_AVX_IMPLEMENTATION(Vone=_mm256_set1_ps(1.);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Stiny_number.f=1.e-20;) ENABLE_SSE_IMPLEMENTATION(Vtiny_number=_mm_set1_ps(1.e-20);) ENABLE_AVX_IMPLEMENTATION(Vtiny_number=_mm256_set1_ps(1.e-20);)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(Ssmall_number.f=1.e-12;) ENABLE_SSE_IMPLEMENTATION(Vsmall_number=_mm_set1_ps(1.e-12);) ENABLE_AVX_IMPLEMENTATION(Vsmall_number=_mm256_set1_ps(1.e-12);)
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa11;) ENABLE_SSE_IMPLEMENTATION(__m128 Va11;) ENABLE_AVX_IMPLEMENTATION(__m256 Va11;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa21;) ENABLE_SSE_IMPLEMENTATION(__m128 Va21;) ENABLE_AVX_IMPLEMENTATION(__m256 Va21;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa31;) ENABLE_SSE_IMPLEMENTATION(__m128 Va31;) ENABLE_AVX_IMPLEMENTATION(__m256 Va31;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa12;) ENABLE_SSE_IMPLEMENTATION(__m128 Va12;) ENABLE_AVX_IMPLEMENTATION(__m256 Va12;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa22;) ENABLE_SSE_IMPLEMENTATION(__m128 Va22;) ENABLE_AVX_IMPLEMENTATION(__m256 Va22;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa32;) ENABLE_SSE_IMPLEMENTATION(__m128 Va32;) ENABLE_AVX_IMPLEMENTATION(__m256 Va32;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa13;) ENABLE_SSE_IMPLEMENTATION(__m128 Va13;) ENABLE_AVX_IMPLEMENTATION(__m256 Va13;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa23;) ENABLE_SSE_IMPLEMENTATION(__m128 Va23;) ENABLE_AVX_IMPLEMENTATION(__m256 Va23;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sa33;) ENABLE_SSE_IMPLEMENTATION(__m128 Va33;) ENABLE_AVX_IMPLEMENTATION(__m256 Va33;)
|
||||
|
||||
#ifdef COMPUTE_V_AS_MATRIX
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv11;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv11;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv11;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv21;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv21;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv21;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv31;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv31;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv31;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv12;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv12;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv12;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv22;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv22;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv22;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv32;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv32;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv32;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv13;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv13;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv13;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv23;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv23;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv23;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sv33;) ENABLE_SSE_IMPLEMENTATION(__m128 Vv33;) ENABLE_AVX_IMPLEMENTATION(__m256 Vv33;)
|
||||
#endif
|
||||
|
||||
#ifdef COMPUTE_V_AS_QUATERNION
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvs;) ENABLE_SSE_IMPLEMENTATION(__m128 Vqvs;) ENABLE_AVX_IMPLEMENTATION(__m256 Vqvs;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvvx;) ENABLE_SSE_IMPLEMENTATION(__m128 Vqvvx;) ENABLE_AVX_IMPLEMENTATION(__m256 Vqvvx;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvvy;) ENABLE_SSE_IMPLEMENTATION(__m128 Vqvvy;) ENABLE_AVX_IMPLEMENTATION(__m256 Vqvvy;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sqvvz;) ENABLE_SSE_IMPLEMENTATION(__m128 Vqvvz;) ENABLE_AVX_IMPLEMENTATION(__m256 Vqvvz;)
|
||||
#endif
|
||||
|
||||
#ifdef COMPUTE_U_AS_MATRIX
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su11;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu11;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu11;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su21;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu21;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu21;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su31;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu31;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu31;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su12;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu12;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu12;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su22;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu22;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu22;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su32;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu32;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu32;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su13;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu13;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu13;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su23;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu23;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu23;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Su33;) ENABLE_SSE_IMPLEMENTATION(__m128 Vu33;) ENABLE_AVX_IMPLEMENTATION(__m256 Vu33;)
|
||||
#endif
|
||||
|
||||
#ifdef COMPUTE_U_AS_QUATERNION
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squs;) ENABLE_SSE_IMPLEMENTATION(__m128 Vqus;) ENABLE_AVX_IMPLEMENTATION(__m256 Vqus;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squvx;) ENABLE_SSE_IMPLEMENTATION(__m128 Vquvx;) ENABLE_AVX_IMPLEMENTATION(__m256 Vquvx;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squvy;) ENABLE_SSE_IMPLEMENTATION(__m128 Vquvy;) ENABLE_AVX_IMPLEMENTATION(__m256 Vquvy;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Squvz;) ENABLE_SSE_IMPLEMENTATION(__m128 Vquvz;) ENABLE_AVX_IMPLEMENTATION(__m256 Vquvz;)
|
||||
#endif
|
||||
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sc;) ENABLE_SSE_IMPLEMENTATION(__m128 Vc;) ENABLE_AVX_IMPLEMENTATION(__m256 Vc;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ss;) ENABLE_SSE_IMPLEMENTATION(__m128 Vs;) ENABLE_AVX_IMPLEMENTATION(__m256 Vs;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Sch;) ENABLE_SSE_IMPLEMENTATION(__m128 Vch;) ENABLE_AVX_IMPLEMENTATION(__m256 Vch;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Ssh;) ENABLE_SSE_IMPLEMENTATION(__m128 Vsh;) ENABLE_AVX_IMPLEMENTATION(__m256 Vsh;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp1;) ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp1;) ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp1;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp2;) ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp2;) ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp2;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp3;) ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp3;) ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp3;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp4;) ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp4;) ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp4;)
|
||||
ENABLE_SCALAR_IMPLEMENTATION(union {float f;unsigned int ui;} Stmp5;) ENABLE_SSE_IMPLEMENTATION(__m128 Vtmp5;) ENABLE_AVX_IMPLEMENTATION(__m256 Vtmp5;)
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,78 +0,0 @@
|
||||
//#####################################################################
|
||||
// Copyright (c) 2010-2011, Eftychios Sifakis.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
// * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||
// * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or
|
||||
// other materials provided with the distribution.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
|
||||
// BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
//#####################################################################
|
||||
|
||||
#ifdef PRINT_DEBUGGING_OUTPUT
|
||||
#include <iomanip>
|
||||
#include <iostream>
|
||||
#endif
|
||||
|
||||
// Prevent warnings
|
||||
#ifdef ENABLE_SCALAR_IMPLEMENTATION
|
||||
# undef ENABLE_SCALAR_IMPLEMENTATION
|
||||
#endif
|
||||
#ifdef ENABLE_SSE_IMPLEMENTATION
|
||||
# undef ENABLE_SSE_IMPLEMENTATION
|
||||
#endif
|
||||
#ifdef ENABLE_AVX_IMPLEMENTATION
|
||||
# undef ENABLE_AVX_IMPLEMENTATION
|
||||
#endif
|
||||
|
||||
#ifdef USE_SCALAR_IMPLEMENTATION
|
||||
#define ENABLE_SCALAR_IMPLEMENTATION(X) X
|
||||
#else
|
||||
#define ENABLE_SCALAR_IMPLEMENTATION(X)
|
||||
#endif
|
||||
|
||||
#ifdef USE_SSE_IMPLEMENTATION
|
||||
#define ENABLE_SSE_IMPLEMENTATION(X) X
|
||||
#else
|
||||
#define ENABLE_SSE_IMPLEMENTATION(X)
|
||||
#endif
|
||||
|
||||
#ifdef USE_AVX_IMPLEMENTATION
|
||||
#include <immintrin.h>
|
||||
#define ENABLE_AVX_IMPLEMENTATION(X) X
|
||||
#else
|
||||
// Stefan: removed include. Why does it import MMX instructions, shouldn't this be under the #ifdef USE_SSE_IMPLEMENTATION above?
|
||||
//#include <xmmintrin.h>
|
||||
#define ENABLE_AVX_IMPLEMENTATION(X)
|
||||
#endif
|
||||
|
||||
#ifdef USE_SCALAR_IMPLEMENTATION
|
||||
// Alec: Why is this using sse intrinsics if it's supposed to be the scalar
|
||||
// implementation?
|
||||
#ifdef __SSE__
|
||||
#include <mmintrin.h>
|
||||
// Changed to inline
|
||||
inline float rsqrt(const float f)
|
||||
{
|
||||
float buf[4];
|
||||
buf[0]=f;
|
||||
__m128 v=_mm_loadu_ps(buf);
|
||||
v=_mm_rsqrt_ss(v);
|
||||
_mm_storeu_ps(buf,v);
|
||||
return buf[0];
|
||||
}
|
||||
#else
|
||||
#include <cmath>
|
||||
inline float rsqrt(const float f)
|
||||
{
|
||||
return 1./sqrtf(f);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,23 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_SOLVER_STATUS_H
|
||||
#define IGL_SOLVER_STATUS_H
|
||||
namespace igl
|
||||
{
|
||||
enum SolverStatus
|
||||
{
|
||||
// Good
|
||||
SOLVER_STATUS_CONVERGED = 0,
|
||||
// OK
|
||||
SOLVER_STATUS_MAX_ITER = 1,
|
||||
// Bad
|
||||
SOLVER_STATUS_ERROR = 2,
|
||||
NUM_SOLVER_STATUSES = 3,
|
||||
};
|
||||
};
|
||||
#endif
|
||||
@ -1,66 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_SORTABLE_ROW_H
|
||||
#define IGL_SORTABLE_ROW_H
|
||||
|
||||
// Simple class to contain a rowvector which allows rowwise sorting and
|
||||
// reordering
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Templates:
|
||||
// T should be a matrix that implements .size(), and operator(int i)
|
||||
template <typename T>
|
||||
class SortableRow
|
||||
{
|
||||
public:
|
||||
T data;
|
||||
public:
|
||||
SortableRow():data(){};
|
||||
SortableRow(const T & data):data(data){};
|
||||
bool operator<(const SortableRow & that) const
|
||||
{
|
||||
// Lexicographical
|
||||
int minc = (this->data.size() < that.data.size()?
|
||||
this->data.size() : that.data.size());
|
||||
// loop over columns
|
||||
for(int i = 0;i<minc;i++)
|
||||
{
|
||||
if(this->data(i) == that.data(i))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return this->data(i) < that.data(i);
|
||||
}
|
||||
// All characters the same, comes done to length
|
||||
return this->data.size()<that.data.size();
|
||||
};
|
||||
bool operator==(const SortableRow & that) const
|
||||
{
|
||||
if(this->data.size() != that.data.size())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for(int i = 0;i<this->data.size();i++)
|
||||
{
|
||||
if(this->data(i) != that.data(i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
bool operator!=(const SortableRow & that) const
|
||||
{
|
||||
return !(*this == that);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
179
src/external/libigl-2.3.0/include/igl/Timer.h
vendored
179
src/external/libigl-2.3.0/include/igl/Timer.h
vendored
@ -1,179 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
// High Resolution Timer.
|
||||
//
|
||||
// Resolution on Mac (clock tick)
|
||||
// Resolution on Linux (1 us not tested)
|
||||
// Resolution on Windows (clock tick not tested)
|
||||
|
||||
#ifndef IGL_TIMER_H
|
||||
#define IGL_TIMER_H
|
||||
|
||||
#ifdef WIN32 // Windows system specific
|
||||
#include <windows.h>
|
||||
#elif __APPLE__ // Unix based system specific
|
||||
#include <mach/mach_time.h> // for mach_absolute_time
|
||||
#else
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#include <cstddef>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
class Timer
|
||||
{
|
||||
public:
|
||||
// default constructor
|
||||
Timer():
|
||||
stopped(0),
|
||||
#ifdef WIN32
|
||||
frequency(),
|
||||
startCount(),
|
||||
endCount()
|
||||
#elif __APPLE__
|
||||
startCount(0),
|
||||
endCount(0)
|
||||
#else
|
||||
startCount(),
|
||||
endCount()
|
||||
#endif
|
||||
{
|
||||
#ifdef WIN32
|
||||
QueryPerformanceFrequency(&frequency);
|
||||
startCount.QuadPart = 0;
|
||||
endCount.QuadPart = 0;
|
||||
#elif __APPLE__
|
||||
startCount = 0;
|
||||
endCount = 0;
|
||||
#else
|
||||
startCount.tv_sec = startCount.tv_usec = 0;
|
||||
endCount.tv_sec = endCount.tv_usec = 0;
|
||||
#endif
|
||||
|
||||
stopped = 0;
|
||||
}
|
||||
// default destructor
|
||||
~Timer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#ifdef __APPLE__
|
||||
//Raw mach_absolute_times going in, difference in seconds out
|
||||
double subtractTimes( uint64_t endTime, uint64_t startTime )
|
||||
{
|
||||
uint64_t difference = endTime - startTime;
|
||||
static double conversion = 0.0;
|
||||
|
||||
if( conversion == 0.0 )
|
||||
{
|
||||
mach_timebase_info_data_t info;
|
||||
kern_return_t err = mach_timebase_info( &info );
|
||||
|
||||
//Convert the timebase into seconds
|
||||
if( err == 0 )
|
||||
conversion = 1e-9 * (double) info.numer / (double) info.denom;
|
||||
}
|
||||
|
||||
return conversion * (double) difference;
|
||||
}
|
||||
#endif
|
||||
|
||||
// start timer
|
||||
void start()
|
||||
{
|
||||
stopped = 0; // reset stop flag
|
||||
#ifdef WIN32
|
||||
QueryPerformanceCounter(&startCount);
|
||||
#elif __APPLE__
|
||||
startCount = mach_absolute_time();
|
||||
#else
|
||||
gettimeofday(&startCount, NULL);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// stop the timer
|
||||
void stop()
|
||||
{
|
||||
stopped = 1; // set timer stopped flag
|
||||
|
||||
#ifdef WIN32
|
||||
QueryPerformanceCounter(&endCount);
|
||||
#elif __APPLE__
|
||||
endCount = mach_absolute_time();
|
||||
#else
|
||||
gettimeofday(&endCount, NULL);
|
||||
#endif
|
||||
|
||||
}
|
||||
// get elapsed time in second
|
||||
double getElapsedTime()
|
||||
{
|
||||
return this->getElapsedTimeInSec();
|
||||
}
|
||||
// get elapsed time in second (same as getElapsedTime)
|
||||
double getElapsedTimeInSec()
|
||||
{
|
||||
return this->getElapsedTimeInMicroSec() * 0.000001;
|
||||
}
|
||||
|
||||
// get elapsed time in milli-second
|
||||
double getElapsedTimeInMilliSec()
|
||||
{
|
||||
return this->getElapsedTimeInMicroSec() * 0.001;
|
||||
}
|
||||
// get elapsed time in micro-second
|
||||
double getElapsedTimeInMicroSec()
|
||||
{
|
||||
double startTimeInMicroSec = 0;
|
||||
double endTimeInMicroSec = 0;
|
||||
|
||||
#ifdef WIN32
|
||||
if(!stopped)
|
||||
QueryPerformanceCounter(&endCount);
|
||||
|
||||
startTimeInMicroSec =
|
||||
startCount.QuadPart * (1000000.0 / frequency.QuadPart);
|
||||
endTimeInMicroSec = endCount.QuadPart * (1000000.0 / frequency.QuadPart);
|
||||
#elif __APPLE__
|
||||
if (!stopped)
|
||||
endCount = mach_absolute_time();
|
||||
|
||||
return subtractTimes(endCount,startCount)/1e-6;
|
||||
#else
|
||||
if(!stopped)
|
||||
gettimeofday(&endCount, NULL);
|
||||
|
||||
startTimeInMicroSec =
|
||||
(startCount.tv_sec * 1000000.0) + startCount.tv_usec;
|
||||
endTimeInMicroSec = (endCount.tv_sec * 1000000.0) + endCount.tv_usec;
|
||||
#endif
|
||||
|
||||
return endTimeInMicroSec - startTimeInMicroSec;
|
||||
}
|
||||
|
||||
private:
|
||||
// stop flag
|
||||
int stopped;
|
||||
#ifdef WIN32
|
||||
// ticks per second
|
||||
LARGE_INTEGER frequency;
|
||||
LARGE_INTEGER startCount;
|
||||
LARGE_INTEGER endCount;
|
||||
#elif __APPLE__
|
||||
uint64_t startCount;
|
||||
uint64_t endCount;
|
||||
#else
|
||||
timeval startCount;
|
||||
timeval endCount;
|
||||
#endif
|
||||
};
|
||||
}
|
||||
#endif // TIMER_H_DEF
|
||||
|
||||
69
src/external/libigl-2.3.0/include/igl/Viewport.h
vendored
69
src/external/libigl-2.3.0/include/igl/Viewport.h
vendored
@ -1,69 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_VIEWPORT_H
|
||||
#define IGL_VIEWPORT_H
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Simple Viewport class for an opengl context. Handles reshaping and mouse.
|
||||
struct Viewport
|
||||
{
|
||||
int x,y,width,height;
|
||||
// Constructors
|
||||
Viewport(
|
||||
const int x=0,
|
||||
const int y=0,
|
||||
const int width=0,
|
||||
const int height=0):
|
||||
x(x),
|
||||
y(y),
|
||||
width(width),
|
||||
height(height)
|
||||
{
|
||||
};
|
||||
virtual ~Viewport(){}
|
||||
void reshape(
|
||||
const int x,
|
||||
const int y,
|
||||
const int width,
|
||||
const int height)
|
||||
{
|
||||
this->x = x;
|
||||
this->y = y;
|
||||
this->width = width;
|
||||
this->height = height;
|
||||
};
|
||||
// Given mouse_x,mouse_y on the entire window return mouse_x, mouse_y in
|
||||
// this viewport.
|
||||
//
|
||||
// Inputs:
|
||||
// my mouse y-coordinate
|
||||
// wh window height
|
||||
// Returns y-coordinate in viewport
|
||||
int mouse_y(const int my,const int wh)
|
||||
{
|
||||
return my - (wh - height - y);
|
||||
}
|
||||
// Inputs:
|
||||
// mx mouse x-coordinate
|
||||
// Returns x-coordinate in viewport
|
||||
int mouse_x(const int mx)
|
||||
{
|
||||
return mx - x;
|
||||
}
|
||||
// Returns whether point (mx,my) is in extend of Viewport
|
||||
bool inside(const int mx, const int my) const
|
||||
{
|
||||
return
|
||||
mx >= x && my >= y &&
|
||||
mx < x+width && my < y+height;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,389 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// # MUTUAL DEPENDENCY ISSUE FOR HEADER ONLY VERSION
|
||||
// MUST INCLUDE winding_number.h first before guard:
|
||||
#include "winding_number.h"
|
||||
|
||||
#ifndef IGL_WINDINGNUMBERAABB_H
|
||||
#define IGL_WINDINGNUMBERAABB_H
|
||||
#include "WindingNumberTree.h"
|
||||
|
||||
namespace igl
|
||||
{
|
||||
template <
|
||||
typename Point,
|
||||
typename DerivedV,
|
||||
typename DerivedF >
|
||||
class WindingNumberAABB : public WindingNumberTree<Point,DerivedV,DerivedF>
|
||||
{
|
||||
protected:
|
||||
Point min_corner;
|
||||
Point max_corner;
|
||||
typename DerivedV::Scalar total_positive_area;
|
||||
public:
|
||||
enum SplitMethod
|
||||
{
|
||||
CENTER_ON_LONGEST_AXIS = 0,
|
||||
MEDIAN_ON_LONGEST_AXIS = 1,
|
||||
NUM_SPLIT_METHODS = 2
|
||||
} split_method;
|
||||
public:
|
||||
inline WindingNumberAABB():
|
||||
total_positive_area(std::numeric_limits<typename DerivedV::Scalar>::infinity()),
|
||||
split_method(MEDIAN_ON_LONGEST_AXIS)
|
||||
{}
|
||||
inline WindingNumberAABB(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F);
|
||||
inline WindingNumberAABB(
|
||||
const WindingNumberTree<Point,DerivedV,DerivedF> & parent,
|
||||
const Eigen::MatrixBase<DerivedF> & F);
|
||||
// Initialize some things
|
||||
inline void set_mesh(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F);
|
||||
inline void init();
|
||||
inline bool inside(const Point & p) const;
|
||||
inline virtual void grow();
|
||||
// Compute min and max corners
|
||||
inline void compute_min_max_corners();
|
||||
inline typename DerivedV::Scalar max_abs_winding_number(const Point & p) const;
|
||||
inline typename DerivedV::Scalar max_simple_abs_winding_number(const Point & p) const;
|
||||
};
|
||||
}
|
||||
|
||||
// Implementation
|
||||
|
||||
#include "winding_number.h"
|
||||
|
||||
#include "barycenter.h"
|
||||
#include "median.h"
|
||||
#include "doublearea.h"
|
||||
#include "per_face_normals.h"
|
||||
|
||||
#include <limits>
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
// Minimum number of faces in a hierarchy element (this is probably dependent
|
||||
// on speed of machine and compiler optimization)
|
||||
#ifndef WindingNumberAABB_MIN_F
|
||||
# define WindingNumberAABB_MIN_F 100
|
||||
#endif
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberAABB<Point,DerivedV,DerivedF>::set_mesh(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F)
|
||||
{
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::set_mesh(V,F);
|
||||
init();
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberAABB<Point,DerivedV,DerivedF>::init()
|
||||
{
|
||||
using namespace Eigen;
|
||||
assert(max_corner.size() == 3);
|
||||
assert(min_corner.size() == 3);
|
||||
compute_min_max_corners();
|
||||
Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,1> dblA;
|
||||
doublearea(this->getV(),this->getF(),dblA);
|
||||
total_positive_area = dblA.sum()/2.0;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline igl::WindingNumberAABB<Point,DerivedV,DerivedF>::WindingNumberAABB(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F):
|
||||
WindingNumberTree<Point,DerivedV,DerivedF>(V,F),
|
||||
min_corner(),
|
||||
max_corner(),
|
||||
total_positive_area(
|
||||
std::numeric_limits<typename DerivedV::Scalar>::infinity()),
|
||||
split_method(MEDIAN_ON_LONGEST_AXIS)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline igl::WindingNumberAABB<Point,DerivedV,DerivedF>::WindingNumberAABB(
|
||||
const WindingNumberTree<Point,DerivedV,DerivedF> & parent,
|
||||
const Eigen::MatrixBase<DerivedF> & F):
|
||||
WindingNumberTree<Point,DerivedV,DerivedF>(parent,F),
|
||||
min_corner(),
|
||||
max_corner(),
|
||||
total_positive_area(
|
||||
std::numeric_limits<typename DerivedV::Scalar>::infinity()),
|
||||
split_method(MEDIAN_ON_LONGEST_AXIS)
|
||||
{
|
||||
init();
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberAABB<Point,DerivedV,DerivedF>::grow()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// Clear anything that already exists
|
||||
this->delete_children();
|
||||
|
||||
//cout<<"cap.rows(): "<<this->getcap().rows()<<endl;
|
||||
//cout<<"F.rows(): "<<this->getF().rows()<<endl;
|
||||
|
||||
// Base cases
|
||||
if(
|
||||
this->getF().rows() <= (WindingNumberAABB_MIN_F>0?WindingNumberAABB_MIN_F:0) ||
|
||||
(this->getcap().rows() - 2) >= this->getF().rows())
|
||||
{
|
||||
// Don't grow
|
||||
return;
|
||||
}
|
||||
|
||||
// Compute longest direction
|
||||
int max_d = -1;
|
||||
typename DerivedV::Scalar max_len =
|
||||
-numeric_limits<typename DerivedV::Scalar>::infinity();
|
||||
for(int d = 0;d<min_corner.size();d++)
|
||||
{
|
||||
if( (max_corner[d] - min_corner[d]) > max_len )
|
||||
{
|
||||
max_len = (max_corner[d] - min_corner[d]);
|
||||
max_d = d;
|
||||
}
|
||||
}
|
||||
// Compute facet barycenters
|
||||
Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,Eigen::Dynamic> BC;
|
||||
barycenter(this->getV(),this->getF(),BC);
|
||||
|
||||
|
||||
// Blerg, why is selecting rows so difficult
|
||||
|
||||
typename DerivedV::Scalar split_value;
|
||||
// Split in longest direction
|
||||
switch(split_method)
|
||||
{
|
||||
case MEDIAN_ON_LONGEST_AXIS:
|
||||
// Determine median
|
||||
median(BC.col(max_d),split_value);
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
case CENTER_ON_LONGEST_AXIS:
|
||||
split_value = 0.5*(max_corner[max_d] + min_corner[max_d]);
|
||||
break;
|
||||
}
|
||||
//cout<<"c: "<<0.5*(max_corner[max_d] + min_corner[max_d])<<" "<<
|
||||
// "m: "<<split_value<<endl;;
|
||||
|
||||
vector<int> id( this->getF().rows());
|
||||
for(int i = 0;i<this->getF().rows();i++)
|
||||
{
|
||||
if(BC(i,max_d) <= split_value)
|
||||
{
|
||||
id[i] = 0; //left
|
||||
}else
|
||||
{
|
||||
id[i] = 1; //right
|
||||
}
|
||||
}
|
||||
|
||||
const int lefts = (int) count(id.begin(),id.end(),0);
|
||||
const int rights = (int) count(id.begin(),id.end(),1);
|
||||
if(lefts == 0 || rights == 0)
|
||||
{
|
||||
// badly balanced base case (could try to recut)
|
||||
return;
|
||||
}
|
||||
assert(lefts+rights == this->getF().rows());
|
||||
DerivedF leftF(lefts, this->getF().cols());
|
||||
DerivedF rightF(rights,this->getF().cols());
|
||||
int left_i = 0;
|
||||
int right_i = 0;
|
||||
for(int i = 0;i<this->getF().rows();i++)
|
||||
{
|
||||
if(id[i] == 0)
|
||||
{
|
||||
leftF.row(left_i++) = this->getF().row(i);
|
||||
}else if(id[i] == 1)
|
||||
{
|
||||
rightF.row(right_i++) = this->getF().row(i);
|
||||
}else
|
||||
{
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
assert(right_i == rightF.rows());
|
||||
assert(left_i == leftF.rows());
|
||||
// Finally actually grow children and Recursively grow
|
||||
WindingNumberAABB<Point,DerivedV,DerivedF> * leftWindingNumberAABB =
|
||||
new WindingNumberAABB<Point,DerivedV,DerivedF>(*this,leftF);
|
||||
leftWindingNumberAABB->grow();
|
||||
this->children.push_back(leftWindingNumberAABB);
|
||||
WindingNumberAABB<Point,DerivedV,DerivedF> * rightWindingNumberAABB =
|
||||
new WindingNumberAABB<Point,DerivedV,DerivedF>(*this,rightF);
|
||||
rightWindingNumberAABB->grow();
|
||||
this->children.push_back(rightWindingNumberAABB);
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline bool igl::WindingNumberAABB<Point,DerivedV,DerivedF>::inside(const Point & p) const
|
||||
{
|
||||
assert(p.size() == max_corner.size());
|
||||
assert(p.size() == min_corner.size());
|
||||
for(int i = 0;i<p.size();i++)
|
||||
{
|
||||
//// Perfect matching is **not** robust
|
||||
//if( p(i) < min_corner(i) || p(i) >= max_corner(i))
|
||||
// **MUST** be conservative
|
||||
if( p(i) < min_corner(i) || p(i) > max_corner(i))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberAABB<Point,DerivedV,DerivedF>::compute_min_max_corners()
|
||||
{
|
||||
using namespace std;
|
||||
// initialize corners
|
||||
for(int d = 0;d<min_corner.size();d++)
|
||||
{
|
||||
min_corner[d] = numeric_limits<typename Point::Scalar>::infinity();
|
||||
max_corner[d] = -numeric_limits<typename Point::Scalar>::infinity();
|
||||
}
|
||||
|
||||
this->center = Point(0,0,0);
|
||||
// Loop over facets
|
||||
for(int i = 0;i<this->getF().rows();i++)
|
||||
{
|
||||
for(int j = 0;j<this->getF().cols();j++)
|
||||
{
|
||||
for(int d = 0;d<min_corner.size();d++)
|
||||
{
|
||||
min_corner[d] =
|
||||
this->getV()(this->getF()(i,j),d) < min_corner[d] ?
|
||||
this->getV()(this->getF()(i,j),d) : min_corner[d];
|
||||
max_corner[d] =
|
||||
this->getV()(this->getF()(i,j),d) > max_corner[d] ?
|
||||
this->getV()(this->getF()(i,j),d) : max_corner[d];
|
||||
}
|
||||
// This is biased toward vertices incident on more than one face, but
|
||||
// perhaps that's good
|
||||
this->center += this->getV().row(this->getF()(i,j));
|
||||
}
|
||||
}
|
||||
// Average
|
||||
this->center.array() /= this->getF().size();
|
||||
|
||||
//cout<<"min_corner: "<<this->min_corner.transpose()<<endl;
|
||||
//cout<<"Center: "<<this->center.transpose()<<endl;
|
||||
//cout<<"max_corner: "<<this->max_corner.transpose()<<endl;
|
||||
//cout<<"Diag center: "<<((this->max_corner + this->min_corner)*0.5).transpose()<<endl;
|
||||
//cout<<endl;
|
||||
|
||||
this->radius = (max_corner-min_corner).norm()/2.0;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberAABB<Point,DerivedV,DerivedF>::max_abs_winding_number(const Point & p) const
|
||||
{
|
||||
using namespace std;
|
||||
// Only valid if not inside
|
||||
if(inside(p))
|
||||
{
|
||||
return numeric_limits<typename DerivedV::Scalar>::infinity();
|
||||
}
|
||||
// Q: we know the total positive area so what's the most this could project
|
||||
// to? Remember it could be layered in the same direction.
|
||||
return numeric_limits<typename DerivedV::Scalar>::infinity();
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberAABB<Point,DerivedV,DerivedF>::max_simple_abs_winding_number(
|
||||
const Point & p) const
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// Only valid if not inside
|
||||
if(inside(p))
|
||||
{
|
||||
return numeric_limits<typename DerivedV::Scalar>::infinity();
|
||||
}
|
||||
// Max simple is the same as sum of positive winding number contributions of
|
||||
// bounding box
|
||||
|
||||
// begin precomputation
|
||||
//MatrixXd BV((int)pow(2,3),3);
|
||||
typedef
|
||||
Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,Eigen::Dynamic>
|
||||
MatrixXS;
|
||||
typedef
|
||||
Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,Eigen::Dynamic>
|
||||
MatrixXF;
|
||||
MatrixXS BV((int)(1<<3),3);
|
||||
BV <<
|
||||
min_corner[0],min_corner[1],min_corner[2],
|
||||
min_corner[0],min_corner[1],max_corner[2],
|
||||
min_corner[0],max_corner[1],min_corner[2],
|
||||
min_corner[0],max_corner[1],max_corner[2],
|
||||
max_corner[0],min_corner[1],min_corner[2],
|
||||
max_corner[0],min_corner[1],max_corner[2],
|
||||
max_corner[0],max_corner[1],min_corner[2],
|
||||
max_corner[0],max_corner[1],max_corner[2];
|
||||
MatrixXF BF(2*2*3,3);
|
||||
BF <<
|
||||
0,6,4,
|
||||
0,2,6,
|
||||
0,3,2,
|
||||
0,1,3,
|
||||
2,7,6,
|
||||
2,3,7,
|
||||
4,6,7,
|
||||
4,7,5,
|
||||
0,4,5,
|
||||
0,5,1,
|
||||
1,5,7,
|
||||
1,7,3;
|
||||
MatrixXS BFN;
|
||||
per_face_normals(BV,BF,BFN);
|
||||
// end of precomputation
|
||||
|
||||
// Only keep those with positive dot products
|
||||
MatrixXF PBF(BF.rows(),BF.cols());
|
||||
int pbfi = 0;
|
||||
Point p2c = 0.5*(min_corner+max_corner)-p;
|
||||
for(int i = 0;i<BFN.rows();i++)
|
||||
{
|
||||
if(p2c.dot(BFN.row(i)) > 0)
|
||||
{
|
||||
PBF.row(pbfi++) = BF.row(i);
|
||||
}
|
||||
}
|
||||
PBF.conservativeResize(pbfi,PBF.cols());
|
||||
return igl::winding_number(BV,PBF,p);
|
||||
}
|
||||
|
||||
// This is a bullshit template because AABB annoyingly needs templates for bad
|
||||
// combinations of 3D V with DIM=2 AABB
|
||||
//
|
||||
// _Define_ as a no-op rather than monkeying around with the proper code above
|
||||
namespace igl
|
||||
{
|
||||
template <> inline igl::WindingNumberAABB<Eigen::Matrix<double, 1, 3, 1, 1, 3>,Eigen::Matrix<double, -1, 2, 0, -1, 2>,Eigen::Matrix<int, -1, 2, 0, -1, 2>>::WindingNumberAABB(const Eigen::MatrixBase<Eigen::Matrix<double, -1, 2, 0, -1, 2>> & V, const Eigen::MatrixBase<Eigen::Matrix<int, -1, 2, 0, -1, 2>> & F){};
|
||||
template <> inline void igl::WindingNumberAABB<Eigen::Matrix<double, 1, 3, 1, 1, 3>,Eigen::Matrix<double, -1, 2, 0, -1, 2>,Eigen::Matrix<int, -1, 2, 0, -1, 2>>::grow(){};
|
||||
template <> inline void igl::WindingNumberAABB<Eigen::Matrix<double, 1, 3, 1, 1, 3>,Eigen::Matrix<double, -1, 2, 0, -1, 2>,Eigen::Matrix<int, -1, 2, 0, -1, 2>>::init(){};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,23 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_WINDINGNUMBERMETHOD_H
|
||||
#define IGL_WINDINGNUMBERMETHOD_H
|
||||
namespace igl
|
||||
{
|
||||
// EXACT_WINDING_NUMBER_METHOD exact hierarchical evaluation
|
||||
// APPROX_SIMPLE_WINDING_NUMBER_METHOD poor approximation
|
||||
// APPROX_CACHE_WINDING_NUMBER_METHOD another poor approximation
|
||||
enum WindingNumberMethod
|
||||
{
|
||||
EXACT_WINDING_NUMBER_METHOD = 0,
|
||||
APPROX_SIMPLE_WINDING_NUMBER_METHOD = 1,
|
||||
APPROX_CACHE_WINDING_NUMBER_METHOD = 2,
|
||||
NUM_WINDING_NUMBER_METHODS = 3
|
||||
};
|
||||
}
|
||||
#endif
|
||||
@ -1,501 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_WINDINGNUMBERTREE_H
|
||||
#define IGL_WINDINGNUMBERTREE_H
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <Eigen/Dense>
|
||||
#include "WindingNumberMethod.h"
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Space partitioning tree for computing winding number hierarchically.
|
||||
//
|
||||
// Templates:
|
||||
// Point type for points in space, e.g. Eigen::Vector3d
|
||||
template <
|
||||
typename Point,
|
||||
typename DerivedV,
|
||||
typename DerivedF >
|
||||
class WindingNumberTree
|
||||
{
|
||||
public:
|
||||
// Method to use (see enum above)
|
||||
//static double min_max_w;
|
||||
static std::map<
|
||||
std::pair<const WindingNumberTree*,const WindingNumberTree*>,
|
||||
typename DerivedV::Scalar>
|
||||
cached;
|
||||
// This is only need to fill in references, it should never actually be touched
|
||||
// and shouldn't cause race conditions. (This is a hack, but I think it's "safe")
|
||||
static DerivedV dummyV;
|
||||
protected:
|
||||
WindingNumberMethod method;
|
||||
const WindingNumberTree * parent;
|
||||
std::list<WindingNumberTree * > children;
|
||||
typedef
|
||||
Eigen::Matrix<typename DerivedV::Scalar,Eigen::Dynamic,Eigen::Dynamic>
|
||||
MatrixXS;
|
||||
typedef
|
||||
Eigen::Matrix<typename DerivedF::Scalar,Eigen::Dynamic,Eigen::Dynamic>
|
||||
MatrixXF;
|
||||
//// List of boundary edges (recall edges are vertices in 2d)
|
||||
//const Eigen::MatrixXi boundary;
|
||||
// Base mesh vertices
|
||||
DerivedV & V;
|
||||
// Base mesh vertices with duplicates removed
|
||||
MatrixXS SV;
|
||||
// Facets in this bounding volume
|
||||
MatrixXF F;
|
||||
// Tessellated boundary curve
|
||||
MatrixXF cap;
|
||||
// Upper Bound on radius of enclosing ball
|
||||
typename DerivedV::Scalar radius;
|
||||
// (Approximate) center (of mass)
|
||||
Point center;
|
||||
public:
|
||||
inline WindingNumberTree();
|
||||
// For root
|
||||
inline WindingNumberTree(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F);
|
||||
// For chilluns
|
||||
inline WindingNumberTree(
|
||||
const WindingNumberTree<Point,DerivedV,DerivedF> & parent,
|
||||
const Eigen::MatrixBase<DerivedF> & F);
|
||||
inline virtual ~WindingNumberTree();
|
||||
inline void delete_children();
|
||||
inline virtual void set_mesh(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F);
|
||||
// Set method
|
||||
inline void set_method( const WindingNumberMethod & m);
|
||||
public:
|
||||
inline const DerivedV & getV() const;
|
||||
inline const MatrixXF & getF() const;
|
||||
inline const MatrixXF & getcap() const;
|
||||
// Grow the Tree recursively
|
||||
inline virtual void grow();
|
||||
// Determine whether a given point is inside the bounding
|
||||
//
|
||||
// Inputs:
|
||||
// p query point
|
||||
// Returns true if the point p is inside this bounding volume
|
||||
inline virtual bool inside(const Point & p) const;
|
||||
// Compute the (partial) winding number of a given point p
|
||||
// According to method
|
||||
//
|
||||
// Inputs:
|
||||
// p query point
|
||||
// Returns winding number
|
||||
inline typename DerivedV::Scalar winding_number(const Point & p) const;
|
||||
// Same as above, but always computes winding number using exact method
|
||||
// (sum over every facet)
|
||||
inline typename DerivedV::Scalar winding_number_all(const Point & p) const;
|
||||
// Same as above, but always computes using sum over tessllated boundary
|
||||
inline typename DerivedV::Scalar winding_number_boundary(const Point & p) const;
|
||||
//// Same as winding_number above, but if max_simple_abs_winding_number is
|
||||
//// less than some threshold min_max_w just return 0 (colloquially the "fast
|
||||
//// multipole method)
|
||||
////
|
||||
////
|
||||
//// Inputs:
|
||||
//// p query point
|
||||
//// min_max_w minimum max simple w to be processed
|
||||
//// Returns approximate winding number
|
||||
//double winding_number_approx_simple(
|
||||
// const Point & p,
|
||||
// const double min_max_w);
|
||||
// Print contents of Tree
|
||||
//
|
||||
// Optional input:
|
||||
// tab tab to show depth
|
||||
inline void print(const char * tab="");
|
||||
// Determine max absolute winding number
|
||||
//
|
||||
// Inputs:
|
||||
// p query point
|
||||
// Returns max winding number of
|
||||
inline virtual typename DerivedV::Scalar max_abs_winding_number(const Point & p) const;
|
||||
// Same as above, but stronger assumptions on (V,F). Assumes (V,F) is a
|
||||
// simple polyhedron
|
||||
inline virtual typename DerivedV::Scalar max_simple_abs_winding_number(const Point & p) const;
|
||||
// Compute or read cached winding number for point p with respect to mesh
|
||||
// in bounding box, recursing according to approximation criteria
|
||||
//
|
||||
// Inputs:
|
||||
// p query point
|
||||
// that WindingNumberTree containing mesh w.r.t. which we're computing w.n.
|
||||
// Returns cached winding number
|
||||
inline virtual typename DerivedV::Scalar cached_winding_number(const WindingNumberTree & that, const Point & p) const;
|
||||
};
|
||||
}
|
||||
|
||||
// Implementation
|
||||
|
||||
#include "WindingNumberTree.h"
|
||||
#include "winding_number.h"
|
||||
#include "triangle_fan.h"
|
||||
#include "exterior_edges.h"
|
||||
|
||||
#include <igl/PI.h>
|
||||
#include <igl/remove_duplicate_vertices.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
|
||||
//template <typename Point, typename DerivedV, typename DerivedF>
|
||||
//WindingNumberMethod WindingNumberTree<Point,DerivedV,DerivedF>::method = EXACT_WINDING_NUMBER_METHOD;
|
||||
//template <typename Point, typename DerivedV, typename DerivedF>
|
||||
//double WindingNumberTree<Point,DerivedV,DerivedF>::min_max_w = 0;
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
std::map< std::pair<const igl::WindingNumberTree<Point,DerivedV,DerivedF>*,const igl::WindingNumberTree<Point,DerivedV,DerivedF>*>, typename DerivedV::Scalar>
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::cached;
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline igl::WindingNumberTree<Point,DerivedV,DerivedF>::WindingNumberTree():
|
||||
method(EXACT_WINDING_NUMBER_METHOD),
|
||||
parent(NULL),
|
||||
V(dummyV),
|
||||
SV(),
|
||||
F(),
|
||||
cap(),
|
||||
radius(std::numeric_limits<typename DerivedV::Scalar>::infinity()),
|
||||
center(0,0,0)
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline igl::WindingNumberTree<Point,DerivedV,DerivedF>::WindingNumberTree(
|
||||
const Eigen::MatrixBase<DerivedV> & _V,
|
||||
const Eigen::MatrixBase<DerivedF> & _F):
|
||||
method(EXACT_WINDING_NUMBER_METHOD),
|
||||
parent(NULL),
|
||||
V(dummyV),
|
||||
SV(),
|
||||
F(),
|
||||
cap(),
|
||||
radius(std::numeric_limits<typename DerivedV::Scalar>::infinity()),
|
||||
center(0,0,0)
|
||||
{
|
||||
set_mesh(_V,_F);
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberTree<Point,DerivedV,DerivedF>::set_mesh(
|
||||
const Eigen::MatrixBase<DerivedV> & _V,
|
||||
const Eigen::MatrixBase<DerivedF> & _F)
|
||||
{
|
||||
using namespace std;
|
||||
// Remove any exactly duplicate vertices
|
||||
// Q: Can this ever increase the complexity of the boundary?
|
||||
// Q: Would we gain even more by remove almost exactly duplicate vertices?
|
||||
MatrixXF SF,SVI,SVJ;
|
||||
igl::remove_duplicate_vertices(_V,_F,0.0,SV,SVI,SVJ,F);
|
||||
triangle_fan(igl::exterior_edges(F),cap);
|
||||
V = SV;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline igl::WindingNumberTree<Point,DerivedV,DerivedF>::WindingNumberTree(
|
||||
const igl::WindingNumberTree<Point,DerivedV,DerivedF> & parent,
|
||||
const Eigen::MatrixBase<DerivedF> & _F):
|
||||
method(parent.method),
|
||||
parent(&parent),
|
||||
V(parent.V),
|
||||
SV(),
|
||||
F(_F),
|
||||
cap(triangle_fan(igl::exterior_edges(_F)))
|
||||
{
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline igl::WindingNumberTree<Point,DerivedV,DerivedF>::~WindingNumberTree()
|
||||
{
|
||||
delete_children();
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberTree<Point,DerivedV,DerivedF>::delete_children()
|
||||
{
|
||||
using namespace std;
|
||||
// Delete children
|
||||
typename list<WindingNumberTree<Point,DerivedV,DerivedF>* >::iterator cit = children.begin();
|
||||
while(cit != children.end())
|
||||
{
|
||||
// clear the memory of this item
|
||||
delete (* cit);
|
||||
// erase from list, returns next element in iterator
|
||||
cit = children.erase(cit);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberTree<Point,DerivedV,DerivedF>::set_method(const WindingNumberMethod & m)
|
||||
{
|
||||
this->method = m;
|
||||
for(auto child : children)
|
||||
{
|
||||
child->set_method(m);
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline const DerivedV & igl::WindingNumberTree<Point,DerivedV,DerivedF>::getV() const
|
||||
{
|
||||
return V;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline const typename igl::WindingNumberTree<Point,DerivedV,DerivedF>::MatrixXF&
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::getF() const
|
||||
{
|
||||
return F;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline const typename igl::WindingNumberTree<Point,DerivedV,DerivedF>::MatrixXF&
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::getcap() const
|
||||
{
|
||||
return cap;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberTree<Point,DerivedV,DerivedF>::grow()
|
||||
{
|
||||
// Don't grow
|
||||
return;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline bool igl::WindingNumberTree<Point,DerivedV,DerivedF>::inside(const Point & /*p*/) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::winding_number(const Point & p) const
|
||||
{
|
||||
using namespace std;
|
||||
//cout<<"+"<<boundary.rows();
|
||||
// If inside then we need to be careful
|
||||
if(inside(p))
|
||||
{
|
||||
// If not a leaf then recurse
|
||||
if(children.size()>0)
|
||||
{
|
||||
// Recurse on each child and accumulate
|
||||
typename DerivedV::Scalar sum = 0;
|
||||
for(
|
||||
typename list<WindingNumberTree<Point,DerivedV,DerivedF>* >::const_iterator cit = children.begin();
|
||||
cit != children.end();
|
||||
cit++)
|
||||
{
|
||||
switch(method)
|
||||
{
|
||||
case EXACT_WINDING_NUMBER_METHOD:
|
||||
sum += (*cit)->winding_number(p);
|
||||
break;
|
||||
case APPROX_SIMPLE_WINDING_NUMBER_METHOD:
|
||||
case APPROX_CACHE_WINDING_NUMBER_METHOD:
|
||||
//if((*cit)->max_simple_abs_winding_number(p) > min_max_w)
|
||||
//{
|
||||
sum += (*cit)->winding_number(p);
|
||||
//}
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}else
|
||||
{
|
||||
return winding_number_all(p);
|
||||
}
|
||||
}else{
|
||||
// Otherwise we can just consider boundary
|
||||
// Q: If we using the "multipole" method should we also subdivide the
|
||||
// boundary case?
|
||||
if((cap.rows() - 2) < F.rows())
|
||||
{
|
||||
switch(method)
|
||||
{
|
||||
case EXACT_WINDING_NUMBER_METHOD:
|
||||
return winding_number_boundary(p);
|
||||
case APPROX_SIMPLE_WINDING_NUMBER_METHOD:
|
||||
{
|
||||
typename DerivedV::Scalar dist = (p-center).norm();
|
||||
// Radius is already an overestimate of inside
|
||||
if(dist>1.0*radius)
|
||||
{
|
||||
return 0;
|
||||
}else
|
||||
{
|
||||
return winding_number_boundary(p);
|
||||
}
|
||||
}
|
||||
case APPROX_CACHE_WINDING_NUMBER_METHOD:
|
||||
{
|
||||
return parent->cached_winding_number(*this,p);
|
||||
}
|
||||
default: assert(false);break;
|
||||
}
|
||||
}else
|
||||
{
|
||||
// doesn't pay off to use boundary
|
||||
return winding_number_all(p);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::winding_number_all(const Point & p) const
|
||||
{
|
||||
return igl::winding_number(V,F,p);
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::winding_number_boundary(const Point & p) const
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
return igl::winding_number(V,cap,p);
|
||||
}
|
||||
|
||||
//template <typename Point, typename DerivedV, typename DerivedF>
|
||||
//inline double igl::WindingNumberTree<Point,DerivedV,DerivedF>::winding_number_approx_simple(
|
||||
// const Point & p,
|
||||
// const double min_max_w)
|
||||
//{
|
||||
// using namespace std;
|
||||
// if(max_simple_abs_winding_number(p) > min_max_w)
|
||||
// {
|
||||
// return winding_number(p);
|
||||
// }else
|
||||
// {
|
||||
// cout<<"Skipped! "<<max_simple_abs_winding_number(p)<<"<"<<min_max_w<<endl;
|
||||
// return 0;
|
||||
// }
|
||||
//}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline void igl::WindingNumberTree<Point,DerivedV,DerivedF>::print(const char * tab)
|
||||
{
|
||||
using namespace std;
|
||||
// Print all facets
|
||||
cout<<tab<<"["<<endl<<F<<endl<<"]";
|
||||
// Print children
|
||||
for(
|
||||
typename list<WindingNumberTree<Point,DerivedV,DerivedF>* >::iterator cit = children.begin();
|
||||
cit != children.end();
|
||||
cit++)
|
||||
{
|
||||
cout<<","<<endl;
|
||||
(*cit)->print((string(tab)+"").c_str());
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::max_abs_winding_number(const Point & /*p*/) const
|
||||
{
|
||||
return std::numeric_limits<typename DerivedV::Scalar>::infinity();
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::max_simple_abs_winding_number(
|
||||
const Point & /*p*/) const
|
||||
{
|
||||
using namespace std;
|
||||
return numeric_limits<typename DerivedV::Scalar>::infinity();
|
||||
}
|
||||
|
||||
template <typename Point, typename DerivedV, typename DerivedF>
|
||||
inline typename DerivedV::Scalar
|
||||
igl::WindingNumberTree<Point,DerivedV,DerivedF>::cached_winding_number(
|
||||
const igl::WindingNumberTree<Point,DerivedV,DerivedF> & that,
|
||||
const Point & p) const
|
||||
{
|
||||
using namespace std;
|
||||
// Simple metric for `is_far`
|
||||
//
|
||||
// this that
|
||||
// --------
|
||||
// ----- / | \ .
|
||||
// / r \ / R \ .
|
||||
// | p ! | | ! |
|
||||
// \_____/ \ /
|
||||
// \________/
|
||||
//
|
||||
//
|
||||
// a = angle formed by trapazoid formed by raising sides with lengths r and R
|
||||
// at respective centers.
|
||||
//
|
||||
// a = atan2(R-r,d), where d is the distance between centers
|
||||
|
||||
// That should be bigger (what about parent? what about sister?)
|
||||
bool is_far = this->radius<that.radius;
|
||||
if(is_far)
|
||||
{
|
||||
typename DerivedV::Scalar a = atan2(
|
||||
that.radius - this->radius,
|
||||
(that.center - this->center).norm());
|
||||
assert(a>0);
|
||||
is_far = (a<PI/8.0);
|
||||
}
|
||||
|
||||
if(is_far)
|
||||
{
|
||||
// Not implemented yet
|
||||
pair<const WindingNumberTree*,const WindingNumberTree*> this_that(this,&that);
|
||||
// Need to compute it for first time?
|
||||
if(cached.count(this_that)==0)
|
||||
{
|
||||
cached[this_that] =
|
||||
that.winding_number_boundary(this->center);
|
||||
}
|
||||
return cached[this_that];
|
||||
}else if(children.size() == 0)
|
||||
{
|
||||
// not far and hierarchy ended too soon: can't use cache
|
||||
return that.winding_number_boundary(p);
|
||||
}else
|
||||
{
|
||||
for(
|
||||
typename list<WindingNumberTree<Point,DerivedV,DerivedF>* >::const_iterator cit = children.begin();
|
||||
cit != children.end();
|
||||
cit++)
|
||||
{
|
||||
if((*cit)->inside(p))
|
||||
{
|
||||
return (*cit)->cached_winding_number(that,p);
|
||||
}
|
||||
}
|
||||
// Not inside any children? This can totally happen because bounding boxes
|
||||
// are set to bound contained facets. So sibilings may overlap and their
|
||||
// union may not contain their parent (though, their union is certainly a
|
||||
// subset of their parent).
|
||||
assert(false);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Explicit instantiation of static variable
|
||||
template <
|
||||
typename Point,
|
||||
typename DerivedV,
|
||||
typename DerivedF >
|
||||
DerivedV igl::WindingNumberTree<Point,DerivedV,DerivedF>::dummyV;
|
||||
|
||||
#endif
|
||||
21
src/external/libigl-2.3.0/include/igl/ZERO.h
vendored
21
src/external/libigl-2.3.0/include/igl/ZERO.h
vendored
@ -1,21 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ZERO_H
|
||||
#define IGL_ZERO_H
|
||||
namespace igl
|
||||
{
|
||||
// Often one needs a reference to a dummy variable containing zero as its
|
||||
// value, for example when using AntTweakBar's
|
||||
// TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ZERO);
|
||||
const char CHAR_ZERO = 0;
|
||||
const int INT_ZERO = 0;
|
||||
const unsigned int UNSIGNED_INT_ZERO = 0;
|
||||
const double DOUBLE_ZERO = 0;
|
||||
const float FLOAT_ZERO = 0;
|
||||
}
|
||||
#endif
|
||||
@ -1,52 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2018 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "accumarray.h"
|
||||
#include <cassert>
|
||||
|
||||
template <
|
||||
typename DerivedS,
|
||||
typename DerivedV,
|
||||
typename DerivedA
|
||||
>
|
||||
void igl::accumarray(
|
||||
const Eigen::MatrixBase<DerivedS> & S,
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
Eigen::PlainObjectBase<DerivedA> & A)
|
||||
{
|
||||
assert(V.size() == S.size() && "S and V should be same size");
|
||||
if(S.size() == 0) { A.resize(0,1); return; }
|
||||
A.setZero(S.maxCoeff()+1,1);
|
||||
for(int s = 0;s<S.size();s++)
|
||||
{
|
||||
A(S(s)) += V(s);
|
||||
}
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedS,
|
||||
typename DerivedA
|
||||
>
|
||||
void igl::accumarray(
|
||||
const Eigen::MatrixBase<DerivedS> & S,
|
||||
const typename DerivedA::Scalar V,
|
||||
Eigen::PlainObjectBase<DerivedA> & A)
|
||||
{
|
||||
if(S.size() == 0) { A.resize(0,1); return; }
|
||||
A.setZero(S.maxCoeff()+1,1);
|
||||
for(int s = 0;s<S.size();s++)
|
||||
{
|
||||
A(S(s)) += V;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::accumarray<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1>::Scalar, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::accumarray<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
#endif
|
||||
@ -1,50 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2018 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef ACCUMARRY_H
|
||||
#define ACCUMARRY_H
|
||||
#include "igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
namespace igl
|
||||
{
|
||||
// ACCUMARRY Like Matlab's accumarray. Accumulate values in V using subscripts
|
||||
// in S.
|
||||
//
|
||||
// Inputs:
|
||||
// S #S list of subscripts
|
||||
// V #V list of values
|
||||
// Outputs:
|
||||
// A max(subs)+1 list of accumulated values
|
||||
template <
|
||||
typename DerivedS,
|
||||
typename DerivedV,
|
||||
typename DerivedA
|
||||
>
|
||||
void accumarray(
|
||||
const Eigen::MatrixBase<DerivedS> & S,
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
Eigen::PlainObjectBase<DerivedA> & A);
|
||||
// Inputs:
|
||||
// S #S list of subscripts
|
||||
// V single value used for all
|
||||
// Outputs:
|
||||
// A max(subs)+1 list of accumulated values
|
||||
template <
|
||||
typename DerivedS,
|
||||
typename DerivedA
|
||||
>
|
||||
void accumarray(
|
||||
const Eigen::MatrixBase<DerivedS> & S,
|
||||
const typename DerivedA::Scalar V,
|
||||
Eigen::PlainObjectBase<DerivedA> & A);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "accumarray.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
370
src/external/libigl-2.3.0/include/igl/active_set.cpp
vendored
370
src/external/libigl-2.3.0/include/igl/active_set.cpp
vendored
@ -1,370 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "active_set.h"
|
||||
#include "min_quad_with_fixed.h"
|
||||
#include "slice.h"
|
||||
#include "slice_into.h"
|
||||
#include "cat.h"
|
||||
//#include "matlab_format.h"
|
||||
|
||||
#include <iostream>
|
||||
#include <limits>
|
||||
#include <algorithm>
|
||||
|
||||
template <
|
||||
typename AT,
|
||||
typename DerivedB,
|
||||
typename Derivedknown,
|
||||
typename DerivedY,
|
||||
typename AeqT,
|
||||
typename DerivedBeq,
|
||||
typename AieqT,
|
||||
typename DerivedBieq,
|
||||
typename Derivedlx,
|
||||
typename Derivedux,
|
||||
typename DerivedZ
|
||||
>
|
||||
IGL_INLINE igl::SolverStatus igl::active_set(
|
||||
const Eigen::SparseMatrix<AT>& A,
|
||||
const Eigen::PlainObjectBase<DerivedB> & B,
|
||||
const Eigen::PlainObjectBase<Derivedknown> & known,
|
||||
const Eigen::PlainObjectBase<DerivedY> & Y,
|
||||
const Eigen::SparseMatrix<AeqT>& Aeq,
|
||||
const Eigen::PlainObjectBase<DerivedBeq> & Beq,
|
||||
const Eigen::SparseMatrix<AieqT>& Aieq,
|
||||
const Eigen::PlainObjectBase<DerivedBieq> & Bieq,
|
||||
const Eigen::PlainObjectBase<Derivedlx> & p_lx,
|
||||
const Eigen::PlainObjectBase<Derivedux> & p_ux,
|
||||
const igl::active_set_params & params,
|
||||
Eigen::PlainObjectBase<DerivedZ> & Z
|
||||
)
|
||||
{
|
||||
//#define ACTIVE_SET_CPP_DEBUG
|
||||
#if defined(ACTIVE_SET_CPP_DEBUG) && !defined(_MSC_VER)
|
||||
# warning "ACTIVE_SET_CPP_DEBUG"
|
||||
#endif
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
SolverStatus ret = SOLVER_STATUS_ERROR;
|
||||
const int n = A.rows();
|
||||
assert(n == A.cols() && "A must be square");
|
||||
// Discard const qualifiers
|
||||
//if(B.size() == 0)
|
||||
//{
|
||||
// B = DerivedB::Zero(n,1);
|
||||
//}
|
||||
assert(n == B.rows() && "B.rows() must match A.rows()");
|
||||
assert(B.cols() == 1 && "B must be a column vector");
|
||||
assert(Y.cols() == 1 && "Y must be a column vector");
|
||||
assert((Aeq.size() == 0 && Beq.size() == 0) || Aeq.cols() == n);
|
||||
assert((Aeq.size() == 0 && Beq.size() == 0) || Aeq.rows() == Beq.rows());
|
||||
assert((Aeq.size() == 0 && Beq.size() == 0) || Beq.cols() == 1);
|
||||
assert((Aieq.size() == 0 && Bieq.size() == 0) || Aieq.cols() == n);
|
||||
assert((Aieq.size() == 0 && Bieq.size() == 0) || Aieq.rows() == Bieq.rows());
|
||||
assert((Aieq.size() == 0 && Bieq.size() == 0) || Bieq.cols() == 1);
|
||||
Eigen::Matrix<typename Derivedlx::Scalar,Eigen::Dynamic,1> lx;
|
||||
Eigen::Matrix<typename Derivedux::Scalar,Eigen::Dynamic,1> ux;
|
||||
if(p_lx.size() == 0)
|
||||
{
|
||||
lx = Derivedlx::Constant(
|
||||
n,1,-numeric_limits<typename Derivedlx::Scalar>::max());
|
||||
}else
|
||||
{
|
||||
lx = p_lx;
|
||||
}
|
||||
if(p_ux.size() == 0)
|
||||
{
|
||||
ux = Derivedux::Constant(
|
||||
n,1,numeric_limits<typename Derivedux::Scalar>::max());
|
||||
}else
|
||||
{
|
||||
ux = p_ux;
|
||||
}
|
||||
assert(lx.rows() == n && "lx must have n rows");
|
||||
assert(ux.rows() == n && "ux must have n rows");
|
||||
assert(ux.cols() == 1 && "lx must be a column vector");
|
||||
assert(lx.cols() == 1 && "ux must be a column vector");
|
||||
assert((ux.array()-lx.array()).minCoeff() > 0 && "ux(i) must be > lx(i)");
|
||||
if(Z.size() != 0)
|
||||
{
|
||||
// Initial guess should have correct size
|
||||
assert(Z.rows() == n && "Z must have n rows");
|
||||
assert(Z.cols() == 1 && "Z must be a column vector");
|
||||
}
|
||||
assert(known.cols() == 1 && "known must be a column vector");
|
||||
// Number of knowns
|
||||
const int nk = known.size();
|
||||
|
||||
// Initialize active sets
|
||||
typedef int BOOL;
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
Matrix<BOOL,Dynamic,1> as_lx = Matrix<BOOL,Dynamic,1>::Constant(n,1,FALSE);
|
||||
Matrix<BOOL,Dynamic,1> as_ux = Matrix<BOOL,Dynamic,1>::Constant(n,1,FALSE);
|
||||
Matrix<BOOL,Dynamic,1> as_ieq = Matrix<BOOL,Dynamic,1>::Constant(Aieq.rows(),1,FALSE);
|
||||
|
||||
// Keep track of previous Z for comparison
|
||||
DerivedZ old_Z;
|
||||
old_Z = DerivedZ::Constant(
|
||||
n,1,numeric_limits<typename DerivedZ::Scalar>::max());
|
||||
|
||||
int iter = 0;
|
||||
while(true)
|
||||
{
|
||||
#ifdef ACTIVE_SET_CPP_DEBUG
|
||||
cout<<"Iteration: "<<iter<<":"<<endl;
|
||||
cout<<" pre"<<endl;
|
||||
#endif
|
||||
// FIND BREACHES OF CONSTRAINTS
|
||||
int new_as_lx = 0;
|
||||
int new_as_ux = 0;
|
||||
int new_as_ieq = 0;
|
||||
if(Z.size() > 0)
|
||||
{
|
||||
for(int z = 0;z < n;z++)
|
||||
{
|
||||
if(Z(z) < lx(z))
|
||||
{
|
||||
new_as_lx += (as_lx(z)?0:1);
|
||||
//new_as_lx++;
|
||||
as_lx(z) = TRUE;
|
||||
}
|
||||
if(Z(z) > ux(z))
|
||||
{
|
||||
new_as_ux += (as_ux(z)?0:1);
|
||||
//new_as_ux++;
|
||||
as_ux(z) = TRUE;
|
||||
}
|
||||
}
|
||||
if(Aieq.rows() > 0)
|
||||
{
|
||||
DerivedZ AieqZ;
|
||||
AieqZ = Aieq*Z;
|
||||
for(int a = 0;a<Aieq.rows();a++)
|
||||
{
|
||||
if(AieqZ(a) > Bieq(a))
|
||||
{
|
||||
new_as_ieq += (as_ieq(a)?0:1);
|
||||
as_ieq(a) = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef ACTIVE_SET_CPP_DEBUG
|
||||
cout<<" new_as_lx: "<<new_as_lx<<endl;
|
||||
cout<<" new_as_ux: "<<new_as_ux<<endl;
|
||||
#endif
|
||||
const double diff = (Z-old_Z).squaredNorm();
|
||||
#ifdef ACTIVE_SET_CPP_DEBUG
|
||||
cout<<"diff: "<<diff<<endl;
|
||||
#endif
|
||||
if(diff < params.solution_diff_threshold)
|
||||
{
|
||||
ret = SOLVER_STATUS_CONVERGED;
|
||||
break;
|
||||
}
|
||||
old_Z = Z;
|
||||
}
|
||||
|
||||
const int as_lx_count = std::count(as_lx.data(),as_lx.data()+n,TRUE);
|
||||
const int as_ux_count = std::count(as_ux.data(),as_ux.data()+n,TRUE);
|
||||
const int as_ieq_count =
|
||||
std::count(as_ieq.data(),as_ieq.data()+as_ieq.size(),TRUE);
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
int count = 0;
|
||||
for(int a = 0;a<as_ieq.size();a++)
|
||||
{
|
||||
if(as_ieq(a))
|
||||
{
|
||||
assert(as_ieq(a) == TRUE);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
assert(as_ieq_count == count);
|
||||
}
|
||||
#endif
|
||||
|
||||
// PREPARE FIXED VALUES
|
||||
Derivedknown known_i;
|
||||
known_i.resize(nk + as_lx_count + as_ux_count,1);
|
||||
DerivedY Y_i;
|
||||
Y_i.resize(nk + as_lx_count + as_ux_count,1);
|
||||
{
|
||||
known_i.block(0,0,known.rows(),known.cols()) = known;
|
||||
Y_i.block(0,0,Y.rows(),Y.cols()) = Y;
|
||||
int k = nk;
|
||||
// Then all lx
|
||||
for(int z = 0;z < n;z++)
|
||||
{
|
||||
if(as_lx(z))
|
||||
{
|
||||
known_i(k) = z;
|
||||
Y_i(k) = lx(z);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
// Finally all ux
|
||||
for(int z = 0;z < n;z++)
|
||||
{
|
||||
if(as_ux(z))
|
||||
{
|
||||
known_i(k) = z;
|
||||
Y_i(k) = ux(z);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
assert(k==Y_i.size());
|
||||
assert(k==known_i.size());
|
||||
}
|
||||
//cout<<matlab_format((known_i.array()+1).eval(),"known_i")<<endl;
|
||||
// PREPARE EQUALITY CONSTRAINTS
|
||||
Eigen::Matrix<typename DerivedY::Scalar, Eigen::Dynamic, 1> as_ieq_list(as_ieq_count,1);
|
||||
// Gather active constraints and resp. rhss
|
||||
DerivedBeq Beq_i;
|
||||
Beq_i.resize(Beq.rows()+as_ieq_count,1);
|
||||
Beq_i.head(Beq.rows()) = Beq;
|
||||
{
|
||||
int k =0;
|
||||
for(int a=0;a<as_ieq.size();a++)
|
||||
{
|
||||
if(as_ieq(a))
|
||||
{
|
||||
assert(k<as_ieq_list.size());
|
||||
as_ieq_list(k)=a;
|
||||
Beq_i(Beq.rows()+k,0) = Bieq(k,0);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
assert(k == as_ieq_count);
|
||||
}
|
||||
// extract active constraint rows
|
||||
SparseMatrix<AeqT> Aeq_i,Aieq_i;
|
||||
slice(Aieq,as_ieq_list,1,Aieq_i);
|
||||
// Append to equality constraints
|
||||
cat(1,Aeq,Aieq_i,Aeq_i);
|
||||
|
||||
|
||||
min_quad_with_fixed_data<AT> data;
|
||||
#ifndef NDEBUG
|
||||
{
|
||||
// NO DUPES!
|
||||
Matrix<BOOL,Dynamic,1> fixed = Matrix<BOOL,Dynamic,1>::Constant(n,1,FALSE);
|
||||
for(int k = 0;k<known_i.size();k++)
|
||||
{
|
||||
assert(!fixed[known_i(k)]);
|
||||
fixed[known_i(k)] = TRUE;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
DerivedZ sol;
|
||||
if(known_i.size() == A.rows())
|
||||
{
|
||||
// Everything's fixed?
|
||||
#ifdef ACTIVE_SET_CPP_DEBUG
|
||||
cout<<" everything's fixed."<<endl;
|
||||
#endif
|
||||
Z.resize(A.rows(),Y_i.cols());
|
||||
slice_into(Y_i,known_i,1,Z);
|
||||
sol.resize(0,Y_i.cols());
|
||||
assert(Aeq_i.rows() == 0 && "All fixed but linearly constrained");
|
||||
}else
|
||||
{
|
||||
#ifdef ACTIVE_SET_CPP_DEBUG
|
||||
cout<<" min_quad_with_fixed_precompute"<<endl;
|
||||
#endif
|
||||
if(!min_quad_with_fixed_precompute(A,known_i,Aeq_i,params.Auu_pd,data))
|
||||
{
|
||||
cerr<<"Error: min_quad_with_fixed precomputation failed."<<endl;
|
||||
if(iter > 0 && Aeq_i.rows() > Aeq.rows())
|
||||
{
|
||||
cerr<<" *Are you sure rows of [Aeq;Aieq] are linearly independent?*"<<
|
||||
endl;
|
||||
}
|
||||
ret = SOLVER_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
#ifdef ACTIVE_SET_CPP_DEBUG
|
||||
cout<<" min_quad_with_fixed_solve"<<endl;
|
||||
#endif
|
||||
if(!min_quad_with_fixed_solve(data,B,Y_i,Beq_i,Z,sol))
|
||||
{
|
||||
cerr<<"Error: min_quad_with_fixed solve failed."<<endl;
|
||||
ret = SOLVER_STATUS_ERROR;
|
||||
break;
|
||||
}
|
||||
//cout<<matlab_format((Aeq*Z-Beq).eval(),"cr")<<endl;
|
||||
//cout<<matlab_format(Z,"Z")<<endl;
|
||||
#ifdef ACTIVE_SET_CPP_DEBUG
|
||||
cout<<" post"<<endl;
|
||||
#endif
|
||||
// Computing Lagrange multipliers needs to be adjusted slightly if A is not symmetric
|
||||
assert(data.Auu_sym);
|
||||
}
|
||||
|
||||
// Compute Lagrange multiplier values for known_i
|
||||
SparseMatrix<AT> Ak;
|
||||
// Slow
|
||||
slice(A,known_i,1,Ak);
|
||||
DerivedB Bk;
|
||||
slice(B,known_i,Bk);
|
||||
MatrixXd Lambda_known_i = -(0.5*Ak*Z + 0.5*Bk);
|
||||
// reverse the lambda values for lx
|
||||
Lambda_known_i.block(nk,0,as_lx_count,1) =
|
||||
(-1*Lambda_known_i.block(nk,0,as_lx_count,1)).eval();
|
||||
|
||||
// Extract Lagrange multipliers for Aieq_i (always at back of sol)
|
||||
VectorXd Lambda_Aieq_i(Aieq_i.rows(),1);
|
||||
for(int l = 0;l<Aieq_i.rows();l++)
|
||||
{
|
||||
Lambda_Aieq_i(Aieq_i.rows()-1-l) = sol(sol.rows()-1-l);
|
||||
}
|
||||
|
||||
// Remove from active set
|
||||
for(int l = 0;l<as_lx_count;l++)
|
||||
{
|
||||
if(Lambda_known_i(nk + l) < params.inactive_threshold)
|
||||
{
|
||||
as_lx(known_i(nk + l)) = FALSE;
|
||||
}
|
||||
}
|
||||
for(int u = 0;u<as_ux_count;u++)
|
||||
{
|
||||
if(Lambda_known_i(nk + as_lx_count + u) <
|
||||
params.inactive_threshold)
|
||||
{
|
||||
as_ux(known_i(nk + as_lx_count + u)) = FALSE;
|
||||
}
|
||||
}
|
||||
for(int a = 0;a<as_ieq_count;a++)
|
||||
{
|
||||
if(Lambda_Aieq_i(a) < params.inactive_threshold)
|
||||
{
|
||||
as_ieq(int(as_ieq_list(a))) = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
iter++;
|
||||
//cout<<iter<<endl;
|
||||
if(params.max_iter>0 && iter>=params.max_iter)
|
||||
{
|
||||
ret = SOLVER_STATUS_MAX_ITER;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template igl::SolverStatus igl::active_set<double, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, double, Eigen::Matrix<double, -1, 1, 0, -1, 1>, double, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::SparseMatrix<double, 0, int> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, igl::active_set_params const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template igl::SolverStatus igl::active_set<double, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, double, Eigen::Matrix<double, -1, 1, 0, -1, 1>, double, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::SparseMatrix<double, 0, int> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, igl::active_set_params const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
111
src/external/libigl-2.3.0/include/igl/active_set.h
vendored
111
src/external/libigl-2.3.0/include/igl/active_set.h
vendored
@ -1,111 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ACTIVE_SET_H
|
||||
#define IGL_ACTIVE_SET_H
|
||||
|
||||
#include "igl_inline.h"
|
||||
#include "SolverStatus.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
struct active_set_params;
|
||||
// Known Bugs: rows of [Aeq;Aieq] **must** be linearly independent. Should be
|
||||
// using QR decomposition otherwise:
|
||||
// https://v8doc.sas.com/sashtml/ormp/chap5/sect32.htm
|
||||
//
|
||||
// ACTIVE_SET Minimize quadratic energy
|
||||
//
|
||||
// 0.5*Z'*A*Z + Z'*B + C with constraints
|
||||
//
|
||||
// that Z(known) = Y, optionally also subject to the constraints Aeq*Z = Beq,
|
||||
// and further optionally subject to the linear inequality constraints that
|
||||
// Aieq*Z <= Bieq and constant inequality constraints lx <= x <= ux
|
||||
//
|
||||
// Inputs:
|
||||
// A n by n matrix of quadratic coefficients
|
||||
// B n by 1 column of linear coefficients
|
||||
// known list of indices to known rows in Z
|
||||
// Y list of fixed values corresponding to known rows in Z
|
||||
// Aeq meq by n list of linear equality constraint coefficients
|
||||
// Beq meq by 1 list of linear equality constraint constant values
|
||||
// Aieq mieq by n list of linear inequality constraint coefficients
|
||||
// Bieq mieq by 1 list of linear inequality constraint constant values
|
||||
// lx n by 1 list of lower bounds [] implies -Inf
|
||||
// ux n by 1 list of upper bounds [] implies Inf
|
||||
// params struct of additional parameters (see below)
|
||||
// Z if not empty, is taken to be an n by 1 list of initial guess values
|
||||
// (see output)
|
||||
// Outputs:
|
||||
// Z n by 1 list of solution values
|
||||
// Returns true on success, false on error
|
||||
//
|
||||
// Benchmark: For a harmonic solve on a mesh with 325K facets, matlab 2.2
|
||||
// secs, igl/min_quad_with_fixed.h 7.1 secs
|
||||
//
|
||||
template <
|
||||
typename AT,
|
||||
typename DerivedB,
|
||||
typename Derivedknown,
|
||||
typename DerivedY,
|
||||
typename AeqT,
|
||||
typename DerivedBeq,
|
||||
typename AieqT,
|
||||
typename DerivedBieq,
|
||||
typename Derivedlx,
|
||||
typename Derivedux,
|
||||
typename DerivedZ
|
||||
>
|
||||
IGL_INLINE igl::SolverStatus active_set(
|
||||
const Eigen::SparseMatrix<AT>& A,
|
||||
const Eigen::PlainObjectBase<DerivedB> & B,
|
||||
const Eigen::PlainObjectBase<Derivedknown> & known,
|
||||
const Eigen::PlainObjectBase<DerivedY> & Y,
|
||||
const Eigen::SparseMatrix<AeqT>& Aeq,
|
||||
const Eigen::PlainObjectBase<DerivedBeq> & Beq,
|
||||
const Eigen::SparseMatrix<AieqT>& Aieq,
|
||||
const Eigen::PlainObjectBase<DerivedBieq> & Bieq,
|
||||
const Eigen::PlainObjectBase<Derivedlx> & lx,
|
||||
const Eigen::PlainObjectBase<Derivedux> & ux,
|
||||
const igl::active_set_params & params,
|
||||
Eigen::PlainObjectBase<DerivedZ> & Z
|
||||
);
|
||||
};
|
||||
|
||||
#include "EPS.h"
|
||||
struct igl::active_set_params
|
||||
{
|
||||
// Input parameters for active_set:
|
||||
// Auu_pd whether Auu is positive definite {false}
|
||||
// max_iter Maximum number of iterations (0 = Infinity, {100})
|
||||
// inactive_threshold Threshold on Lagrange multiplier values to determine
|
||||
// whether to keep constraints active {EPS}
|
||||
// constraint_threshold Threshold on whether constraints are violated (0
|
||||
// is perfect) {EPS}
|
||||
// solution_diff_threshold Threshold on the squared norm of the difference
|
||||
// between two consecutive solutions {EPS}
|
||||
bool Auu_pd;
|
||||
int max_iter;
|
||||
double inactive_threshold;
|
||||
double constraint_threshold;
|
||||
double solution_diff_threshold;
|
||||
active_set_params():
|
||||
Auu_pd(false),
|
||||
max_iter(100),
|
||||
inactive_threshold(igl::DOUBLE_EPS),
|
||||
constraint_threshold(igl::DOUBLE_EPS),
|
||||
solution_diff_threshold(igl::DOUBLE_EPS)
|
||||
{};
|
||||
};
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "active_set.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,180 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "adjacency_list.h"
|
||||
|
||||
#include "verbose.h"
|
||||
#include <algorithm>
|
||||
|
||||
template <typename Index, typename IndexVector>
|
||||
IGL_INLINE void igl::adjacency_list(
|
||||
const Eigen::MatrixBase<Index> & F,
|
||||
std::vector<std::vector<IndexVector> >& A,
|
||||
bool sorted)
|
||||
{
|
||||
A.clear();
|
||||
A.resize(F.maxCoeff()+1);
|
||||
|
||||
// Loop over faces
|
||||
for(int i = 0;i<F.rows();i++)
|
||||
{
|
||||
// Loop over this face
|
||||
for(int j = 0;j<F.cols();j++)
|
||||
{
|
||||
// Get indices of edge: s --> d
|
||||
int s = F(i,j);
|
||||
int d = F(i,(j+1)%F.cols());
|
||||
A.at(s).push_back(d);
|
||||
A.at(d).push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicates
|
||||
for(int i=0; i<(int)A.size();++i)
|
||||
{
|
||||
std::sort(A[i].begin(), A[i].end());
|
||||
A[i].erase(std::unique(A[i].begin(), A[i].end()), A[i].end());
|
||||
}
|
||||
|
||||
// If needed, sort every VV
|
||||
if (sorted)
|
||||
{
|
||||
// Loop over faces
|
||||
|
||||
// for every vertex v store a set of ordered edges not incident to v that belongs to triangle incident on v.
|
||||
std::vector<std::vector<std::vector<int> > > SR;
|
||||
SR.resize(A.size());
|
||||
|
||||
for(int i = 0;i<F.rows();i++)
|
||||
{
|
||||
// Loop over this face
|
||||
for(int j = 0;j<F.cols();j++)
|
||||
{
|
||||
// Get indices of edge: s --> d
|
||||
int s = F(i,j);
|
||||
int d = F(i,(j+1)%F.cols());
|
||||
// Get index of opposing vertex v
|
||||
int v = F(i,(j+2)%F.cols());
|
||||
|
||||
std::vector<int> e(2);
|
||||
e[0] = d;
|
||||
e[1] = v;
|
||||
SR[s].push_back(e);
|
||||
}
|
||||
}
|
||||
|
||||
for(int v=0; v<(int)SR.size();++v)
|
||||
{
|
||||
std::vector<IndexVector>& vv = A.at(v);
|
||||
std::vector<std::vector<int> >& sr = SR[v];
|
||||
|
||||
std::vector<std::vector<int> > pn = sr;
|
||||
|
||||
// Compute previous/next for every element in sr
|
||||
for(int i=0;i<(int)sr.size();++i)
|
||||
{
|
||||
int a = sr[i][0];
|
||||
int b = sr[i][1];
|
||||
|
||||
// search for previous
|
||||
int p = -1;
|
||||
for(int j=0;j<(int)sr.size();++j)
|
||||
if(sr[j][1] == a)
|
||||
p = j;
|
||||
pn[i][0] = p;
|
||||
|
||||
// search for next
|
||||
int n = -1;
|
||||
for(int j=0;j<(int)sr.size();++j)
|
||||
if(sr[j][0] == b)
|
||||
n = j;
|
||||
pn[i][1] = n;
|
||||
|
||||
}
|
||||
|
||||
// assume manifoldness (look for beginning of a single chain)
|
||||
int c = 0;
|
||||
for(int j=0; j<=(int)sr.size();++j)
|
||||
if (pn[c][0] != -1)
|
||||
c = pn[c][0];
|
||||
|
||||
if (pn[c][0] == -1) // border case
|
||||
{
|
||||
// finally produce the new vv relation
|
||||
for(int j=0; j<(int)sr.size();++j)
|
||||
{
|
||||
vv[j] = sr[c][0];
|
||||
if (pn[c][1] != -1)
|
||||
c = pn[c][1];
|
||||
}
|
||||
vv.back() = sr[c][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
// finally produce the new vv relation
|
||||
for(int j=0; j<(int)sr.size();++j)
|
||||
{
|
||||
vv[j] = sr[c][0];
|
||||
|
||||
c = pn[c][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Index>
|
||||
IGL_INLINE void igl::adjacency_list(
|
||||
const std::vector<std::vector<Index> > & F,
|
||||
std::vector<std::vector<Index> >& A)
|
||||
{
|
||||
A.clear();
|
||||
|
||||
// Find maxCoeff
|
||||
Index maxCoeff = 0;
|
||||
for(const auto &vec : F)
|
||||
{
|
||||
for(int coeff : vec)
|
||||
{
|
||||
maxCoeff = std::max(coeff, maxCoeff);
|
||||
}
|
||||
}
|
||||
A.resize(maxCoeff + 1);
|
||||
|
||||
// Loop over faces
|
||||
for(int i = 0;i<F.size();i++)
|
||||
{
|
||||
// Loop over this face
|
||||
for(int j = 0;j<F[i].size();j++)
|
||||
{
|
||||
// Get indices of edge: s --> d
|
||||
int s = F[i][j];
|
||||
int d = F[i][(j+1)%F[i].size()];
|
||||
A.at(s).push_back(d);
|
||||
A.at(d).push_back(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove duplicates
|
||||
for(int i=0; i<(int)A.size();++i)
|
||||
{
|
||||
std::sort(A[i].begin(), A[i].end());
|
||||
A[i].erase(std::unique(A[i].begin(), A[i].end()), A[i].end());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::adjacency_list<Eigen::Matrix<int, -1, 2, 0, -1, 2>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, bool);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::adjacency_list<Eigen::Matrix<int, -1, -1, 0, -1, -1>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, bool);
|
||||
template void igl::adjacency_list<Eigen::Matrix<int, -1, 3, 0, -1, 3>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&, bool);
|
||||
template void igl::adjacency_list<class Eigen::Matrix<int, -1, -1, 0, -1, -1>, unsigned int>(class Eigen::MatrixBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1> > const &, class std::vector<class std::vector<unsigned int, class std::allocator<unsigned int> >, class std::allocator<class std::vector<unsigned int, class std::allocator<unsigned int> > > > &, bool);
|
||||
template void igl::adjacency_list<int>(std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > > const&, std::vector<std::vector<int, std::allocator<int> >, std::allocator<std::vector<int, std::allocator<int> > > >&);
|
||||
#endif
|
||||
@ -1,51 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ADJACENCY_LIST_H
|
||||
#define IGL_ADJACENCY_LIST_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
#include <vector>
|
||||
namespace igl
|
||||
{
|
||||
// Constructs the graph adjacency list of a given mesh (V,F)
|
||||
// Templates:
|
||||
// T should be a eigen sparse matrix primitive type like int or double
|
||||
// Inputs:
|
||||
// F #F by dim list of mesh faces (must be triangles)
|
||||
// sorted flag that indicates if the list should be sorted counter-clockwise
|
||||
// Outputs:
|
||||
// A vector<vector<T> > containing at row i the adjacent vertices of vertex i
|
||||
//
|
||||
// Example:
|
||||
// // Mesh in (V,F)
|
||||
// vector<vector<double> > A;
|
||||
// adjacency_list(F,A);
|
||||
//
|
||||
// See also: edges, cotmatrix, diag
|
||||
template <typename Index, typename IndexVector>
|
||||
IGL_INLINE void adjacency_list(
|
||||
const Eigen::MatrixBase<Index> & F,
|
||||
std::vector<std::vector<IndexVector> >& A,
|
||||
bool sorted = false);
|
||||
|
||||
// Variant that accepts polygonal faces.
|
||||
// Each element of F is a set of indices of a polygonal face.
|
||||
template <typename Index>
|
||||
IGL_INLINE void adjacency_list(
|
||||
const std::vector<std::vector<Index> > & F,
|
||||
std::vector<std::vector<Index> >& A);
|
||||
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "adjacency_list.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,125 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "adjacency_matrix.h"
|
||||
|
||||
#include "verbose.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
template <typename DerivedF, typename T>
|
||||
IGL_INLINE void igl::adjacency_matrix(
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
Eigen::SparseMatrix<T>& A)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
typedef typename DerivedF::Scalar Index;
|
||||
|
||||
typedef Triplet<T> IJV;
|
||||
vector<IJV > ijv;
|
||||
ijv.reserve(F.size()*2);
|
||||
// Loop over **simplex** (i.e., **not quad**)
|
||||
for(int i = 0;i<F.rows();i++)
|
||||
{
|
||||
// Loop over this **simplex**
|
||||
for(int j = 0;j<F.cols();j++)
|
||||
for(int k = j+1;k<F.cols();k++)
|
||||
{
|
||||
// Get indices of edge: s --> d
|
||||
Index s = F(i,j);
|
||||
Index d = F(i,k);
|
||||
ijv.push_back(IJV(s,d,1));
|
||||
ijv.push_back(IJV(d,s,1));
|
||||
}
|
||||
}
|
||||
|
||||
const Index n = F.maxCoeff()+1;
|
||||
A.resize(n,n);
|
||||
switch(F.cols())
|
||||
{
|
||||
case 3:
|
||||
A.reserve(6*(F.maxCoeff()+1));
|
||||
break;
|
||||
case 4:
|
||||
A.reserve(26*(F.maxCoeff()+1));
|
||||
break;
|
||||
}
|
||||
A.setFromTriplets(ijv.begin(),ijv.end());
|
||||
|
||||
// Force all non-zeros to be one
|
||||
|
||||
// Iterate over outside
|
||||
for(int k=0; k<A.outerSize(); ++k)
|
||||
{
|
||||
// Iterate over inside
|
||||
for(typename Eigen::SparseMatrix<T>::InnerIterator it (A,k); it; ++it)
|
||||
{
|
||||
assert(it.value() != 0);
|
||||
A.coeffRef(it.row(),it.col()) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <typename DerivedI, typename DerivedC, typename T>
|
||||
IGL_INLINE void igl::adjacency_matrix(
|
||||
const Eigen::MatrixBase<DerivedI> & I,
|
||||
const Eigen::MatrixBase<DerivedC> & C,
|
||||
Eigen::SparseMatrix<T>& A)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
typedef Triplet<T> IJV;
|
||||
vector<IJV > ijv;
|
||||
ijv.reserve(C(C.size()-1)*2);
|
||||
typedef typename DerivedI::Scalar Index;
|
||||
const Index n = I.maxCoeff()+1;
|
||||
{
|
||||
// loop over polygons
|
||||
for(Index p = 0;p<C.size()-1;p++)
|
||||
{
|
||||
// number of edges
|
||||
const Index np = C(p+1)-C(p);
|
||||
// loop over edges
|
||||
for(Index c = 0;c<np;c++)
|
||||
{
|
||||
const Index i = I(C(p)+c);
|
||||
const Index j = I(C(p)+((c+1)%np));
|
||||
ijv.emplace_back(i,j,1);
|
||||
ijv.emplace_back(j,i,1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
A.resize(n,n);
|
||||
A.reserve(6*n);
|
||||
A.setFromTriplets(ijv.begin(),ijv.end());
|
||||
|
||||
// Force all non-zeros to be one
|
||||
|
||||
// Iterate over outside
|
||||
for(int k=0; k<A.outerSize(); ++k)
|
||||
{
|
||||
// Iterate over inside
|
||||
for(typename Eigen::SparseMatrix<T>::InnerIterator it (A,k); it; ++it)
|
||||
{
|
||||
assert(it.value() != 0);
|
||||
A.coeffRef(it.row(),it.col()) = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::adjacency_matrix<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<int, 0, int>& );
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::adjacency_matrix<Eigen::Matrix<int, -1, -1, 0, -1, -1>, bool>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<bool, 0, int>&);
|
||||
template void igl::adjacency_matrix<Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
template void igl::adjacency_matrix<Eigen::Matrix<int, -1, -1, 0, -1, -1>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<int, 0, int>&);
|
||||
template void igl::adjacency_matrix<Eigen::Matrix<int, -1, 3, 0, -1, 3>, int>(Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::SparseMatrix<int, 0, int>&);
|
||||
#endif
|
||||
@ -1,66 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ADJACENCY_MATRIX_H
|
||||
#define IGL_ADJACENCY_MATRIX_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Constructs the graph adjacency matrix of a given mesh (V,F)
|
||||
// Templates:
|
||||
// T should be a eigen sparse matrix primitive type like int or double
|
||||
// Inputs:
|
||||
// F #F by dim list of mesh simplices
|
||||
// Outputs:
|
||||
// A max(F)+1 by max(F)+1 adjacency matrix, each row i corresponding to V(i,:)
|
||||
//
|
||||
// Example:
|
||||
// // Mesh in (V,F)
|
||||
// Eigen::SparseMatrix<double> A;
|
||||
// adjacency_matrix(F,A);
|
||||
// // sum each row
|
||||
// SparseVector<double> Asum;
|
||||
// sum(A,1,Asum);
|
||||
// // Convert row sums into diagonal of sparse matrix
|
||||
// SparseMatrix<double> Adiag;
|
||||
// diag(Asum,Adiag);
|
||||
// // Build uniform laplacian
|
||||
// SparseMatrix<double> U;
|
||||
// U = A-Adiag;
|
||||
//
|
||||
// See also: edges, cotmatrix, diag
|
||||
template <typename DerivedF, typename T>
|
||||
IGL_INLINE void adjacency_matrix(
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
Eigen::SparseMatrix<T>& A);
|
||||
// Constructs an vertex adjacency for a polygon mesh.
|
||||
//
|
||||
// Inputs:
|
||||
// I #I vectorized list of polygon corner indices into rows of some matrix V
|
||||
// C #polygons+1 list of cumulative polygon sizes so that C(i+1)-C(i) =
|
||||
// size of the ith polygon, and so I(C(i)) through I(C(i+1)-1) are the
|
||||
// indices of the ith polygon
|
||||
// Outputs:
|
||||
// A max(I)+1 by max(I)+1 adjacency matrix, each row i corresponding to V(i,:)
|
||||
//
|
||||
template <typename DerivedI, typename DerivedC, typename T>
|
||||
IGL_INLINE void adjacency_matrix(
|
||||
const Eigen::MatrixBase<DerivedI> & I,
|
||||
const Eigen::MatrixBase<DerivedC> & C,
|
||||
Eigen::SparseMatrix<T>& A);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "adjacency_matrix.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
26
src/external/libigl-2.3.0/include/igl/all.cpp
vendored
26
src/external/libigl-2.3.0/include/igl/all.cpp
vendored
@ -1,26 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "all.h"
|
||||
#include "redux.h"
|
||||
|
||||
|
||||
template <typename AType, typename DerivedB>
|
||||
IGL_INLINE void igl::all(
|
||||
const Eigen::SparseMatrix<AType> & A,
|
||||
const int dim,
|
||||
Eigen::PlainObjectBase<DerivedB>& B)
|
||||
{
|
||||
typedef typename DerivedB::Scalar Scalar;
|
||||
igl::redux(A,dim,[](Scalar a, Scalar b){ return a && b!=0;},B);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
#endif
|
||||
|
||||
|
||||
36
src/external/libigl-2.3.0/include/igl/all.h
vendored
36
src/external/libigl-2.3.0/include/igl/all.h
vendored
@ -1,36 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ALL_H
|
||||
#define IGL_ALL_H
|
||||
#include "igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Sparse>
|
||||
namespace igl
|
||||
{
|
||||
// For Dense matrices use: A.rowwise().all() or A.colwise().all()
|
||||
//
|
||||
// Inputs:
|
||||
// A m by n sparse matrix
|
||||
// dim dimension along which to check for all (1 or 2)
|
||||
// Output:
|
||||
// B n-long vector (if dim == 1)
|
||||
// or
|
||||
// B m-long vector (if dim == 2)
|
||||
//
|
||||
template <typename AType, typename DerivedB>
|
||||
IGL_INLINE void all(
|
||||
const Eigen::SparseMatrix<AType> & A,
|
||||
const int dim,
|
||||
Eigen::PlainObjectBase<DerivedB>& B);
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "all.cpp"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "all_pairs_distances.h"
|
||||
#include <Eigen/Dense>
|
||||
|
||||
template <typename Mat>
|
||||
IGL_INLINE void igl::all_pairs_distances(
|
||||
const Mat & V,
|
||||
const Mat & U,
|
||||
const bool squared,
|
||||
Mat & D)
|
||||
{
|
||||
// dimension should be the same
|
||||
assert(V.cols() == U.cols());
|
||||
// resize output
|
||||
D.resize(V.rows(),U.rows());
|
||||
for(int i = 0;i<V.rows();i++)
|
||||
{
|
||||
for(int j=0;j<U.rows();j++)
|
||||
{
|
||||
D(i,j) = (V.row(i)-U.row(j)).squaredNorm();
|
||||
if(!squared)
|
||||
{
|
||||
D(i,j) = sqrt(D(i,j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::all_pairs_distances<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, bool, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
|
||||
#endif
|
||||
@ -1,41 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ALL_PAIRS_DISTANCES_H
|
||||
#define IGL_ALL_PAIRS_DISTANCES_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// ALL_PAIRS_DISTANCES compute distances between each point i in V and point j
|
||||
// in U
|
||||
//
|
||||
// D = all_pairs_distances(V,U)
|
||||
//
|
||||
// Templates:
|
||||
// Mat matrix class like MatrixXd
|
||||
// Inputs:
|
||||
// V #V by dim list of points
|
||||
// U #U by dim list of points
|
||||
// squared whether to return squared distances
|
||||
// Outputs:
|
||||
// D #V by #U matrix of distances, where D(i,j) gives the distance or
|
||||
// squareed distance between V(i,:) and U(j,:)
|
||||
//
|
||||
template <typename Mat>
|
||||
IGL_INLINE void all_pairs_distances(
|
||||
const Mat & V,
|
||||
const Mat & U,
|
||||
const bool squared,
|
||||
Mat & D);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "all_pairs_distances.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,139 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "ambient_occlusion.h"
|
||||
#include "random_dir.h"
|
||||
#include "ray_mesh_intersect.h"
|
||||
#include "EPS.h"
|
||||
#include "Hit.h"
|
||||
#include "parallel_for.h"
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
|
||||
template <
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void igl::ambient_occlusion(
|
||||
const std::function<
|
||||
bool(
|
||||
const Eigen::Vector3f&,
|
||||
const Eigen::Vector3f&)
|
||||
> & shoot_ray,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
const Eigen::MatrixBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S)
|
||||
{
|
||||
using namespace Eigen;
|
||||
const int n = P.rows();
|
||||
// Resize output
|
||||
S.resize(n,1);
|
||||
// Embree seems to be parallel when constructing but not when tracing rays
|
||||
const MatrixXf D = random_dir_stratified(num_samples).cast<float>();
|
||||
|
||||
const auto & inner = [&P,&N,&num_samples,&D,&S,&shoot_ray](const int p)
|
||||
{
|
||||
const Vector3f origin = P.row(p).template cast<float>();
|
||||
const Vector3f normal = N.row(p).template cast<float>();
|
||||
int num_hits = 0;
|
||||
for(int s = 0;s<num_samples;s++)
|
||||
{
|
||||
Vector3f d = D.row(s);
|
||||
if(d.dot(normal) < 0)
|
||||
{
|
||||
// reverse ray
|
||||
d *= -1;
|
||||
}
|
||||
if(shoot_ray(origin,d))
|
||||
{
|
||||
num_hits++;
|
||||
}
|
||||
}
|
||||
S(p) = (double)num_hits/(double)num_samples;
|
||||
};
|
||||
parallel_for(n,inner,1000);
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
int DIM,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void igl::ambient_occlusion(
|
||||
const igl::AABB<DerivedV,DIM> & aabb,
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
const Eigen::MatrixBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S)
|
||||
{
|
||||
const auto & shoot_ray = [&aabb,&V,&F](
|
||||
const Eigen::Vector3f& _s,
|
||||
const Eigen::Vector3f& dir)->bool
|
||||
{
|
||||
Eigen::Vector3f s = _s+1e-4*dir;
|
||||
igl::Hit hit;
|
||||
return aabb.intersect_ray(
|
||||
V,
|
||||
F,
|
||||
s .cast<typename DerivedV::Scalar>().eval(),
|
||||
dir.cast<typename DerivedV::Scalar>().eval(),
|
||||
hit);
|
||||
};
|
||||
return ambient_occlusion(shoot_ray,P,N,num_samples,S);
|
||||
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void igl::ambient_occlusion(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
const Eigen::MatrixBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S)
|
||||
{
|
||||
if(F.rows() < 100)
|
||||
{
|
||||
// Super naive
|
||||
const auto & shoot_ray = [&V,&F](
|
||||
const Eigen::Vector3f& _s,
|
||||
const Eigen::Vector3f& dir)->bool
|
||||
{
|
||||
Eigen::Vector3f s = _s+1e-4*dir;
|
||||
igl::Hit hit;
|
||||
return ray_mesh_intersect(s,dir,V,F,hit);
|
||||
};
|
||||
return ambient_occlusion(shoot_ray,P,N,num_samples,S);
|
||||
}
|
||||
AABB<DerivedV,3> aabb;
|
||||
aabb.init(V,F);
|
||||
return ambient_occlusion(aabb,V,F,P,N,num_samples,S);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::ambient_occlusion<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::ambient_occlusion<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::ambient_occlusion<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(std::function<bool (Eigen::Matrix<float, 3, 1, 0, 3, 1> const&, Eigen::Matrix<float, 3, 1, 0, 3, 1> const&)> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
@ -1,80 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2015 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_AMBIENT_OCCLUSION_H
|
||||
#define IGL_AMBIENT_OCCLUSION_H
|
||||
#include "igl_inline.h"
|
||||
#include "AABB.h"
|
||||
#include <Eigen/Core>
|
||||
#include <functional>
|
||||
namespace igl
|
||||
{
|
||||
// Compute ambient occlusion per given point
|
||||
//
|
||||
// Inputs:
|
||||
// shoot_ray function handle that outputs hits of a given ray against a
|
||||
// mesh (embedded in function handles as captured variable/data)
|
||||
// P #P by 3 list of origin points
|
||||
// N #P by 3 list of origin normals
|
||||
// Outputs:
|
||||
// S #P list of ambient occlusion values between 1 (fully occluded) and
|
||||
// 0 (not occluded)
|
||||
//
|
||||
template <
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void ambient_occlusion(
|
||||
const std::function<
|
||||
bool(
|
||||
const Eigen::Vector3f&,
|
||||
const Eigen::Vector3f&)
|
||||
> & shoot_ray,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
const Eigen::MatrixBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S);
|
||||
// Inputs:
|
||||
// AABB axis-aligned bounding box hierarchy around (V,F)
|
||||
template <
|
||||
typename DerivedV,
|
||||
int DIM,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void ambient_occlusion(
|
||||
const igl::AABB<DerivedV,DIM> & aabb,
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
const Eigen::MatrixBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S);
|
||||
// Inputs:
|
||||
// V #V by 3 list of mesh vertex positions
|
||||
// F #F by 3 list of mesh face indices into V
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedP,
|
||||
typename DerivedN,
|
||||
typename DerivedS >
|
||||
IGL_INLINE void ambient_occlusion(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedP> & P,
|
||||
const Eigen::MatrixBase<DerivedN> & N,
|
||||
const int num_samples,
|
||||
Eigen::PlainObjectBase<DerivedS> & S);
|
||||
|
||||
};
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "ambient_occlusion.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,20 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "angular_distance.h"
|
||||
#include <igl/EPS.h>
|
||||
#include <igl/PI.h>
|
||||
IGL_INLINE double igl::angular_distance(
|
||||
const Eigen::Quaterniond & A,
|
||||
const Eigen::Quaterniond & B)
|
||||
{
|
||||
assert(fabs(A.norm()-1)<FLOAT_EPS && "A should be unit norm");
|
||||
assert(fabs(B.norm()-1)<FLOAT_EPS && "B should be unit norm");
|
||||
//// acos is always in [0,2*pi)
|
||||
//return acos(fabs(A.dot(B)));
|
||||
return fmod(2.*acos(A.dot(B)),2.*PI);
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ANGULAR_DISTANCE_H
|
||||
#define IGL_ANGULAR_DISTANCE_H
|
||||
#include "igl_inline.h"
|
||||
#include <Eigen/Geometry>
|
||||
namespace igl
|
||||
{
|
||||
// The "angular distance" between two unit quaternions is the angle of the
|
||||
// smallest rotation (treated as an Axis and Angle) that takes A to B.
|
||||
//
|
||||
// Inputs:
|
||||
// A unit quaternion
|
||||
// B unit quaternion
|
||||
// Returns angular distance
|
||||
IGL_INLINE double angular_distance(
|
||||
const Eigen::Quaterniond & A,
|
||||
const Eigen::Quaterniond & B);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
#include "angular_distance.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
26
src/external/libigl-2.3.0/include/igl/any.cpp
vendored
26
src/external/libigl-2.3.0/include/igl/any.cpp
vendored
@ -1,26 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "any.h"
|
||||
#include "redux.h"
|
||||
|
||||
|
||||
template <typename AType, typename DerivedB>
|
||||
IGL_INLINE void igl::any(
|
||||
const Eigen::SparseMatrix<AType> & A,
|
||||
const int dim,
|
||||
Eigen::PlainObjectBase<DerivedB>& B)
|
||||
{
|
||||
typedef typename DerivedB::Scalar Scalar;
|
||||
igl::redux(A,dim,[](Scalar a, Scalar b){ return a || b!=0;},B);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::any<bool, Eigen::Array<bool, -1, 1, 0, -1, 1> >(Eigen::SparseMatrix<bool, 0, int> const&, int, Eigen::PlainObjectBase<Eigen::Array<bool, -1, 1, 0, -1, 1> >&);
|
||||
#endif
|
||||
35
src/external/libigl-2.3.0/include/igl/any.h
vendored
35
src/external/libigl-2.3.0/include/igl/any.h
vendored
@ -1,35 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2016 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ANY_H
|
||||
#define IGL_ANY_H
|
||||
#include "igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Sparse>
|
||||
namespace igl
|
||||
{
|
||||
// For Dense matrices use: A.rowwise().any() or A.colwise().any()
|
||||
//
|
||||
// Inputs:
|
||||
// A m by n sparse matrix
|
||||
// dim dimension along which to check for any (1 or 2)
|
||||
// Output:
|
||||
// B n-long vector (if dim == 1)
|
||||
// or
|
||||
// B m-long vector (if dim == 2)
|
||||
//
|
||||
template <typename AType, typename DerivedB>
|
||||
IGL_INLINE void any(
|
||||
const Eigen::SparseMatrix<AType> & A,
|
||||
const int dim,
|
||||
Eigen::PlainObjectBase<DerivedB>& B);
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "any.cpp"
|
||||
#endif
|
||||
#endif
|
||||
|
||||
20
src/external/libigl-2.3.0/include/igl/any_of.cpp
vendored
20
src/external/libigl-2.3.0/include/igl/any_of.cpp
vendored
@ -1,20 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "any_of.h"
|
||||
#include <Eigen/Core>
|
||||
template <typename Mat>
|
||||
IGL_INLINE bool igl::any_of(const Mat & S)
|
||||
{
|
||||
return std::any_of(S.data(),S.data()+S.size(),[](bool s){return s;});
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template bool igl::any_of<Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&);
|
||||
#endif
|
||||
|
||||
26
src/external/libigl-2.3.0/include/igl/any_of.h
vendored
26
src/external/libigl-2.3.0/include/igl/any_of.h
vendored
@ -1,26 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ANY_OF_H
|
||||
#define IGL_ANY_OF_H
|
||||
#include "igl_inline.h"
|
||||
namespace igl
|
||||
{
|
||||
// Wrapper for STL `any_of` for matrix types
|
||||
//
|
||||
// Inputs:
|
||||
// S matrix
|
||||
// Returns whether any entries are true
|
||||
//
|
||||
// Seems that Eigen (now) implements this for `Eigen::Array`
|
||||
template <typename Mat>
|
||||
IGL_INLINE bool any_of(const Mat & S);
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "any_of.cpp"
|
||||
#endif
|
||||
#endif
|
||||
312
src/external/libigl-2.3.0/include/igl/arap.cpp
vendored
312
src/external/libigl-2.3.0/include/igl/arap.cpp
vendored
@ -1,312 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "arap.h"
|
||||
#include "colon.h"
|
||||
#include "cotmatrix.h"
|
||||
#include "massmatrix.h"
|
||||
#include "group_sum_matrix.h"
|
||||
#include "covariance_scatter_matrix.h"
|
||||
#include "speye.h"
|
||||
#include "mode.h"
|
||||
#include "project_isometrically_to_plane.h"
|
||||
#include "slice.h"
|
||||
#include "arap_rhs.h"
|
||||
#include "repdiag.h"
|
||||
#include "columnize.h"
|
||||
#include "fit_rotations.h"
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename Derivedb>
|
||||
IGL_INLINE bool igl::arap_precomputation(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const int dim,
|
||||
const Eigen::PlainObjectBase<Derivedb> & b,
|
||||
ARAPData & data)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
typedef typename DerivedV::Scalar Scalar;
|
||||
// number of vertices
|
||||
const int n = V.rows();
|
||||
data.n = n;
|
||||
assert((b.size() == 0 || b.maxCoeff() < n) && "b out of bounds");
|
||||
assert((b.size() == 0 || b.minCoeff() >=0) && "b out of bounds");
|
||||
// remember b
|
||||
data.b = b;
|
||||
//assert(F.cols() == 3 && "For now only triangles");
|
||||
// dimension
|
||||
//const int dim = V.cols();
|
||||
assert((dim == 3 || dim ==2) && "dim should be 2 or 3");
|
||||
data.dim = dim;
|
||||
//assert(dim == 3 && "Only 3d supported");
|
||||
// Defaults
|
||||
data.f_ext = MatrixXd::Zero(n,data.dim);
|
||||
|
||||
assert(data.dim <= V.cols() && "solve dim should be <= embedding");
|
||||
bool flat = (V.cols() - data.dim)==1;
|
||||
|
||||
DerivedV plane_V;
|
||||
DerivedF plane_F;
|
||||
typedef SparseMatrix<Scalar> SparseMatrixS;
|
||||
SparseMatrixS ref_map,ref_map_dim;
|
||||
if(flat)
|
||||
{
|
||||
project_isometrically_to_plane(V,F,plane_V,plane_F,ref_map);
|
||||
repdiag(ref_map,dim,ref_map_dim);
|
||||
}
|
||||
const PlainObjectBase<DerivedV>& ref_V = (flat?plane_V:V);
|
||||
const PlainObjectBase<DerivedF>& ref_F = (flat?plane_F:F);
|
||||
SparseMatrixS L;
|
||||
cotmatrix(V,F,L);
|
||||
|
||||
ARAPEnergyType eff_energy = data.energy;
|
||||
if(eff_energy == ARAP_ENERGY_TYPE_DEFAULT)
|
||||
{
|
||||
switch(F.cols())
|
||||
{
|
||||
case 3:
|
||||
if(data.dim == 3)
|
||||
{
|
||||
eff_energy = ARAP_ENERGY_TYPE_SPOKES_AND_RIMS;
|
||||
}else
|
||||
{
|
||||
eff_energy = ARAP_ENERGY_TYPE_ELEMENTS;
|
||||
}
|
||||
break;
|
||||
case 4:
|
||||
eff_energy = ARAP_ENERGY_TYPE_ELEMENTS;
|
||||
break;
|
||||
default:
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Get covariance scatter matrix, when applied collects the covariance
|
||||
// matrices used to fit rotations to during optimization
|
||||
covariance_scatter_matrix(ref_V,ref_F,eff_energy,data.CSM);
|
||||
if(flat)
|
||||
{
|
||||
data.CSM = (data.CSM * ref_map_dim.transpose()).eval();
|
||||
}
|
||||
assert(data.CSM.cols() == V.rows()*data.dim);
|
||||
|
||||
// Get group sum scatter matrix, when applied sums all entries of the same
|
||||
// group according to G
|
||||
SparseMatrix<double> G_sum;
|
||||
if(data.G.size() == 0)
|
||||
{
|
||||
if(eff_energy == ARAP_ENERGY_TYPE_ELEMENTS)
|
||||
{
|
||||
speye(F.rows(),G_sum);
|
||||
}else
|
||||
{
|
||||
speye(n,G_sum);
|
||||
}
|
||||
}else
|
||||
{
|
||||
// groups are defined per vertex, convert to per face using mode
|
||||
if(eff_energy == ARAP_ENERGY_TYPE_ELEMENTS)
|
||||
{
|
||||
Eigen::Matrix<int,Eigen::Dynamic,1> GG;
|
||||
MatrixXi GF(F.rows(),F.cols());
|
||||
for(int j = 0;j<F.cols();j++)
|
||||
{
|
||||
Matrix<int,Eigen::Dynamic,1> GFj;
|
||||
slice(data.G,F.col(j),GFj);
|
||||
GF.col(j) = GFj;
|
||||
}
|
||||
mode<int>(GF,2,GG);
|
||||
data.G=GG;
|
||||
}
|
||||
//printf("group_sum_matrix()\n");
|
||||
group_sum_matrix(data.G,G_sum);
|
||||
}
|
||||
SparseMatrix<double> G_sum_dim;
|
||||
repdiag(G_sum,data.dim,G_sum_dim);
|
||||
assert(G_sum_dim.cols() == data.CSM.rows());
|
||||
data.CSM = (G_sum_dim * data.CSM).eval();
|
||||
|
||||
|
||||
arap_rhs(ref_V,ref_F,data.dim,eff_energy,data.K);
|
||||
if(flat)
|
||||
{
|
||||
data.K = (ref_map_dim * data.K).eval();
|
||||
}
|
||||
assert(data.K.rows() == data.n*data.dim);
|
||||
|
||||
SparseMatrix<double> Q = (-L).eval();
|
||||
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
const double h = data.h;
|
||||
assert(h != 0);
|
||||
SparseMatrix<double> M;
|
||||
massmatrix(V,F,MASSMATRIX_TYPE_DEFAULT,data.M);
|
||||
const double dw = (1./data.ym)*(h*h);
|
||||
SparseMatrix<double> DQ = dw * 1./(h*h)*data.M;
|
||||
Q += DQ;
|
||||
// Dummy external forces
|
||||
data.f_ext = MatrixXd::Zero(n,data.dim);
|
||||
data.vel = MatrixXd::Zero(n,data.dim);
|
||||
}
|
||||
|
||||
return min_quad_with_fixed_precompute(
|
||||
Q,b,SparseMatrix<double>(),true,data.solver_data);
|
||||
}
|
||||
|
||||
template <
|
||||
typename Derivedbc,
|
||||
typename DerivedU>
|
||||
IGL_INLINE bool igl::arap_solve(
|
||||
const Eigen::PlainObjectBase<Derivedbc> & bc,
|
||||
ARAPData & data,
|
||||
Eigen::PlainObjectBase<DerivedU> & U)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
assert(data.b.size() == bc.rows());
|
||||
if(bc.size() > 0)
|
||||
{
|
||||
assert(bc.cols() == data.dim && "bc.cols() match data.dim");
|
||||
}
|
||||
const int n = data.n;
|
||||
int iter = 0;
|
||||
if(U.size() == 0)
|
||||
{
|
||||
// terrible initial guess.. should at least copy input mesh
|
||||
#ifndef NDEBUG
|
||||
cerr<<"arap_solve: Using terrible initial guess for U. Try U = V."<<endl;
|
||||
#endif
|
||||
U = MatrixXd::Zero(data.n,data.dim);
|
||||
}else
|
||||
{
|
||||
assert(U.cols() == data.dim && "U.cols() match data.dim");
|
||||
}
|
||||
// changes each arap iteration
|
||||
MatrixXd U_prev = U;
|
||||
// doesn't change for fixed with_dynamics timestep
|
||||
MatrixXd U0;
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
U0 = U_prev;
|
||||
}
|
||||
while(iter < data.max_iter)
|
||||
{
|
||||
U_prev = U;
|
||||
// enforce boundary conditions exactly
|
||||
for(int bi = 0;bi<bc.rows();bi++)
|
||||
{
|
||||
U.row(data.b(bi)) = bc.row(bi);
|
||||
}
|
||||
|
||||
const auto & Udim = U.replicate(data.dim,1);
|
||||
assert(U.cols() == data.dim);
|
||||
// As if U.col(2) was 0
|
||||
MatrixXd S = data.CSM * Udim;
|
||||
// THIS NORMALIZATION IS IMPORTANT TO GET SINGLE PRECISION SVD CODE TO WORK
|
||||
// CORRECTLY.
|
||||
S /= S.array().abs().maxCoeff();
|
||||
|
||||
const int Rdim = data.dim;
|
||||
MatrixXd R(Rdim,data.CSM.rows());
|
||||
if(R.rows() == 2)
|
||||
{
|
||||
fit_rotations_planar(S,R);
|
||||
}else
|
||||
{
|
||||
fit_rotations(S,true,R);
|
||||
//#ifdef __SSE__ // fit_rotations_SSE will convert to float if necessary
|
||||
// fit_rotations_SSE(S,R);
|
||||
//#else
|
||||
// fit_rotations(S,true,R);
|
||||
//#endif
|
||||
}
|
||||
//for(int k = 0;k<(data.CSM.rows()/dim);k++)
|
||||
//{
|
||||
// R.block(0,dim*k,dim,dim) = MatrixXd::Identity(dim,dim);
|
||||
//}
|
||||
|
||||
|
||||
// Number of rotations: #vertices or #elements
|
||||
int num_rots = data.K.cols()/Rdim/Rdim;
|
||||
// distribute group rotations to vertices in each group
|
||||
MatrixXd eff_R;
|
||||
if(data.G.size() == 0)
|
||||
{
|
||||
// copy...
|
||||
eff_R = R;
|
||||
}else
|
||||
{
|
||||
eff_R.resize(Rdim,num_rots*Rdim);
|
||||
for(int r = 0;r<num_rots;r++)
|
||||
{
|
||||
eff_R.block(0,Rdim*r,Rdim,Rdim) =
|
||||
R.block(0,Rdim*data.G(r),Rdim,Rdim);
|
||||
}
|
||||
}
|
||||
|
||||
MatrixXd Dl;
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
assert(data.M.rows() == n &&
|
||||
"No mass matrix. Call arap_precomputation if changing with_dynamics");
|
||||
const double h = data.h;
|
||||
assert(h != 0);
|
||||
//Dl = 1./(h*h*h)*M*(-2.*V0 + Vm1) - fext;
|
||||
// data.vel = (V0-Vm1)/h
|
||||
// h*data.vel = (V0-Vm1)
|
||||
// -h*data.vel = -V0+Vm1)
|
||||
// -V0-h*data.vel = -2V0+Vm1
|
||||
const double dw = (1./data.ym)*(h*h);
|
||||
Dl = dw * (1./(h*h)*data.M*(-U0 - h*data.vel) - data.f_ext);
|
||||
}
|
||||
|
||||
VectorXd Rcol;
|
||||
columnize(eff_R,num_rots,2,Rcol);
|
||||
VectorXd Bcol = -data.K * Rcol;
|
||||
assert(Bcol.size() == data.n*data.dim);
|
||||
for(int c = 0;c<data.dim;c++)
|
||||
{
|
||||
VectorXd Uc,Bc,bcc,Beq;
|
||||
Bc = Bcol.block(c*n,0,n,1);
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
Bc += Dl.col(c);
|
||||
}
|
||||
if(bc.size()>0)
|
||||
{
|
||||
bcc = bc.col(c);
|
||||
}
|
||||
min_quad_with_fixed_solve(
|
||||
data.solver_data,
|
||||
Bc,bcc,Beq,
|
||||
Uc);
|
||||
U.col(c) = Uc;
|
||||
}
|
||||
|
||||
iter++;
|
||||
}
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
// Keep track of velocity for next time
|
||||
data.vel = (U-U0)/data.h;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
template bool igl::arap_solve<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, igl::ARAPData&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template bool igl::arap_precomputation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, igl::ARAPData&);
|
||||
#endif
|
||||
104
src/external/libigl-2.3.0/include/igl/arap.h
vendored
104
src/external/libigl-2.3.0/include/igl/arap.h
vendored
@ -1,104 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ARAP_H
|
||||
#define IGL_ARAP_H
|
||||
#include "igl_inline.h"
|
||||
#include "min_quad_with_fixed.h"
|
||||
#include "ARAPEnergyType.h"
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
struct ARAPData
|
||||
{
|
||||
// n #V
|
||||
// G #V list of group indices (1 to k) for each vertex, such that vertex i
|
||||
// is assigned to group G(i)
|
||||
// energy type of energy to use
|
||||
// with_dynamics whether using dynamics (need to call arap_precomputation
|
||||
// after changing)
|
||||
// f_ext #V by dim list of external forces
|
||||
// vel #V by dim list of velocities
|
||||
// h dynamics time step
|
||||
// ym ~Young's modulus smaller is softer, larger is more rigid/stiff
|
||||
// max_iter maximum inner iterations
|
||||
// K rhs pre-multiplier
|
||||
// M mass matrix
|
||||
// solver_data quadratic solver data
|
||||
// b list of boundary indices into V
|
||||
// dim dimension being used for solving
|
||||
int n;
|
||||
Eigen::VectorXi G;
|
||||
ARAPEnergyType energy;
|
||||
bool with_dynamics;
|
||||
Eigen::MatrixXd f_ext,vel;
|
||||
double h;
|
||||
double ym;
|
||||
int max_iter;
|
||||
Eigen::SparseMatrix<double> K,M;
|
||||
Eigen::SparseMatrix<double> CSM;
|
||||
min_quad_with_fixed_data<double> solver_data;
|
||||
Eigen::VectorXi b;
|
||||
int dim;
|
||||
ARAPData():
|
||||
n(0),
|
||||
G(),
|
||||
energy(ARAP_ENERGY_TYPE_DEFAULT),
|
||||
with_dynamics(false),
|
||||
f_ext(),
|
||||
h(1),
|
||||
ym(1),
|
||||
max_iter(10),
|
||||
K(),
|
||||
CSM(),
|
||||
solver_data(),
|
||||
b(),
|
||||
dim(-1) // force this to be set by _precomputation
|
||||
{
|
||||
};
|
||||
};
|
||||
|
||||
// Compute necessary information to start using an ARAP deformation
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of mesh positions
|
||||
// F #F by simplex-size list of triangle|tet indices into V
|
||||
// dim dimension being used at solve time. For deformation usually dim =
|
||||
// V.cols(), for surface parameterization V.cols() = 3 and dim = 2
|
||||
// b #b list of "boundary" fixed vertex indices into V
|
||||
// Outputs:
|
||||
// data struct containing necessary precomputation
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename Derivedb>
|
||||
IGL_INLINE bool arap_precomputation(
|
||||
const Eigen::PlainObjectBase<DerivedV> & V,
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const int dim,
|
||||
const Eigen::PlainObjectBase<Derivedb> & b,
|
||||
ARAPData & data);
|
||||
// Inputs:
|
||||
// bc #b by dim list of boundary conditions
|
||||
// data struct containing necessary precomputation and parameters
|
||||
// U #V by dim initial guess
|
||||
template <
|
||||
typename Derivedbc,
|
||||
typename DerivedU>
|
||||
IGL_INLINE bool arap_solve(
|
||||
const Eigen::PlainObjectBase<Derivedbc> & bc,
|
||||
ARAPData & data,
|
||||
Eigen::PlainObjectBase<DerivedU> & U);
|
||||
};
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
#include "arap.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
884
src/external/libigl-2.3.0/include/igl/arap_dof.cpp
vendored
884
src/external/libigl-2.3.0/include/igl/arap_dof.cpp
vendored
@ -1,884 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "arap_dof.h"
|
||||
|
||||
#include "cotmatrix.h"
|
||||
#include "massmatrix.h"
|
||||
#include "speye.h"
|
||||
#include "repdiag.h"
|
||||
#include "repmat.h"
|
||||
#include "slice.h"
|
||||
#include "colon.h"
|
||||
#include "is_sparse.h"
|
||||
#include "mode.h"
|
||||
#include "is_symmetric.h"
|
||||
#include "group_sum_matrix.h"
|
||||
#include "arap_rhs.h"
|
||||
#include "covariance_scatter_matrix.h"
|
||||
#include "fit_rotations.h"
|
||||
|
||||
#include "verbose.h"
|
||||
#include "print_ijv.h"
|
||||
|
||||
#include "get_seconds_hires.h"
|
||||
//#include "MKLEigenInterface.h"
|
||||
#include "kkt_inverse.h"
|
||||
#include "get_seconds.h"
|
||||
#include "columnize.h"
|
||||
|
||||
// defined if no early exit is supported, i.e., always take a fixed number of iterations
|
||||
#define IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
|
||||
|
||||
// A careful derivation of this implementation is given in the corresponding
|
||||
// matlab function arap_dof.m
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
IGL_INLINE bool igl::arap_dof_precomputation(
|
||||
const Eigen::MatrixXd & V,
|
||||
const Eigen::MatrixXi & F,
|
||||
const LbsMatrixType & M,
|
||||
const Eigen::Matrix<int,Eigen::Dynamic,1> & G,
|
||||
ArapDOFData<LbsMatrixType, SSCALAR> & data)
|
||||
{
|
||||
using namespace Eigen;
|
||||
typedef Matrix<SSCALAR, Dynamic, Dynamic> MatrixXS;
|
||||
// number of mesh (domain) vertices
|
||||
int n = V.rows();
|
||||
// cache problem size
|
||||
data.n = n;
|
||||
// dimension of mesh
|
||||
data.dim = V.cols();
|
||||
assert(data.dim == M.rows()/n);
|
||||
assert(data.dim*n == M.rows());
|
||||
if(data.dim == 3)
|
||||
{
|
||||
// Check if z-coordinate is all zeros
|
||||
if(V.col(2).minCoeff() == 0 && V.col(2).maxCoeff() == 0)
|
||||
{
|
||||
data.effective_dim = 2;
|
||||
}
|
||||
}else
|
||||
{
|
||||
data.effective_dim = data.dim;
|
||||
}
|
||||
// Number of handles
|
||||
data.m = M.cols()/data.dim/(data.dim+1);
|
||||
assert(data.m*data.dim*(data.dim+1) == M.cols());
|
||||
//assert(m == C.rows());
|
||||
|
||||
//printf("n=%d; dim=%d; m=%d;\n",n,data.dim,data.m);
|
||||
|
||||
// Build cotangent laplacian
|
||||
SparseMatrix<double> Lcot;
|
||||
//printf("cotmatrix()\n");
|
||||
cotmatrix(V,F,Lcot);
|
||||
// Discrete laplacian (should be minus matlab version)
|
||||
SparseMatrix<double> Lapl = -2.0*Lcot;
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"LaplIJV=["<<endl;print_ijv(Lapl,1);cout<<endl<<"];"<<
|
||||
endl<<"Lapl=sparse(LaplIJV(:,1),LaplIJV(:,2),LaplIJV(:,3),"<<
|
||||
Lapl.rows()<<","<<Lapl.cols()<<");"<<endl;
|
||||
#endif
|
||||
|
||||
// Get group sum scatter matrix, when applied sums all entries of the same
|
||||
// group according to G
|
||||
SparseMatrix<double> G_sum;
|
||||
if(G.size() == 0)
|
||||
{
|
||||
speye(n,G_sum);
|
||||
}else
|
||||
{
|
||||
// groups are defined per vertex, convert to per face using mode
|
||||
Eigen::Matrix<int,Eigen::Dynamic,1> GG;
|
||||
if(data.energy == ARAP_ENERGY_TYPE_ELEMENTS)
|
||||
{
|
||||
MatrixXi GF(F.rows(),F.cols());
|
||||
for(int j = 0;j<F.cols();j++)
|
||||
{
|
||||
Matrix<int,Eigen::Dynamic,1> GFj;
|
||||
slice(G,F.col(j),GFj);
|
||||
GF.col(j) = GFj;
|
||||
}
|
||||
mode<int>(GF,2,GG);
|
||||
}else
|
||||
{
|
||||
GG=G;
|
||||
}
|
||||
//printf("group_sum_matrix()\n");
|
||||
group_sum_matrix(GG,G_sum);
|
||||
}
|
||||
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"G_sumIJV=["<<endl;print_ijv(G_sum,1);cout<<endl<<"];"<<
|
||||
endl<<"G_sum=sparse(G_sumIJV(:,1),G_sumIJV(:,2),G_sumIJV(:,3),"<<
|
||||
G_sum.rows()<<","<<G_sum.cols()<<");"<<endl;
|
||||
#endif
|
||||
|
||||
// Get covariance scatter matrix, when applied collects the covariance matrices
|
||||
// used to fit rotations to during optimization
|
||||
SparseMatrix<double> CSM;
|
||||
//printf("covariance_scatter_matrix()\n");
|
||||
covariance_scatter_matrix(V,F,data.energy,CSM);
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"CSMIJV=["<<endl;print_ijv(CSM,1);cout<<endl<<"];"<<
|
||||
endl<<"CSM=sparse(CSMIJV(:,1),CSMIJV(:,2),CSMIJV(:,3),"<<
|
||||
CSM.rows()<<","<<CSM.cols()<<");"<<endl;
|
||||
#endif
|
||||
|
||||
|
||||
// Build the covariance matrix "constructor". This is a set of *scatter*
|
||||
// matrices that when multiplied on the right by column of the transformation
|
||||
// matrix entries (the degrees of freedom) L, we get a stack of dim by 1
|
||||
// covariance matrix column, with a column in the stack for each rotation
|
||||
// *group*. The output is a list of matrices because we construct each column
|
||||
// in the stack of covariance matrices with an independent matrix-vector
|
||||
// multiplication.
|
||||
//
|
||||
// We want to build S which is a stack of dim by dim covariance matrices.
|
||||
// Thus S is dim*g by dim, where dim is the number of dimensions and g is the
|
||||
// number of groups. We can precompute dim matrices CSM_M such that column i
|
||||
// in S is computed as S(:,i) = CSM_M{i} * L, where L is a column of the
|
||||
// skinning transformation matrix values. To be clear, the covariance matrix
|
||||
// for group k is then given as the dim by dim matrix pulled from the stack:
|
||||
// S((k-1)*dim + 1:dim,:)
|
||||
|
||||
// Apply group sum to each dimension's block of covariance scatter matrix
|
||||
SparseMatrix<double> G_sum_dim;
|
||||
repdiag(G_sum,data.dim,G_sum_dim);
|
||||
CSM = (G_sum_dim * CSM).eval();
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"CSMIJV=["<<endl;print_ijv(CSM,1);cout<<endl<<"];"<<
|
||||
endl<<"CSM=sparse(CSMIJV(:,1),CSMIJV(:,2),CSMIJV(:,3),"<<
|
||||
CSM.rows()<<","<<CSM.cols()<<");"<<endl;
|
||||
#endif
|
||||
|
||||
//printf("CSM_M()\n");
|
||||
// Precompute CSM times M for each dimension
|
||||
data.CSM_M.resize(data.dim);
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"data.CSM_M = cell("<<data.dim<<",1);"<<endl;
|
||||
#endif
|
||||
// span of integers from 0 to n-1
|
||||
Eigen::Matrix<int,Eigen::Dynamic,1> span_n(n);
|
||||
for(int i = 0;i<n;i++)
|
||||
{
|
||||
span_n(i) = i;
|
||||
}
|
||||
|
||||
// span of integers from 0 to M.cols()-1
|
||||
Eigen::Matrix<int,Eigen::Dynamic,1> span_mlbs_cols(M.cols());
|
||||
for(int i = 0;i<M.cols();i++)
|
||||
{
|
||||
span_mlbs_cols(i) = i;
|
||||
}
|
||||
|
||||
// number of groups
|
||||
int k = CSM.rows()/data.dim;
|
||||
for(int i = 0;i<data.dim;i++)
|
||||
{
|
||||
//printf("CSM_M(): Mi\n");
|
||||
LbsMatrixType M_i;
|
||||
//printf("CSM_M(): slice\n");
|
||||
slice(M,(span_n.array()+i*n).matrix().eval(),span_mlbs_cols,M_i);
|
||||
LbsMatrixType M_i_dim;
|
||||
data.CSM_M[i].resize(k*data.dim,data.m*data.dim*(data.dim+1));
|
||||
assert(data.CSM_M[i].cols() == M.cols());
|
||||
for(int j = 0;j<data.dim;j++)
|
||||
{
|
||||
SparseMatrix<double> CSMj;
|
||||
//printf("CSM_M(): slice\n");
|
||||
slice(
|
||||
CSM,
|
||||
colon<int>(j*k,(j+1)*k-1),
|
||||
colon<int>(j*n,(j+1)*n-1),
|
||||
CSMj);
|
||||
assert(CSMj.rows() == k);
|
||||
assert(CSMj.cols() == n);
|
||||
LbsMatrixType CSMjM_i = CSMj * M_i;
|
||||
if(is_sparse(CSMjM_i))
|
||||
{
|
||||
// Convert to full
|
||||
//printf("CSM_M(): full\n");
|
||||
MatrixXd CSMjM_ifull(CSMjM_i);
|
||||
// printf("CSM_M[%d]: %d %d\n",i,data.CSM_M[i].rows(),data.CSM_M[i].cols());
|
||||
// printf("CSM_M[%d].block(%d*%d=%d,0,%d,%d): %d %d\n",i,j,k,CSMjM_i.rows(),CSMjM_i.cols(),
|
||||
// data.CSM_M[i].block(j*k,0,CSMjM_i.rows(),CSMjM_i.cols()).rows(),
|
||||
// data.CSM_M[i].block(j*k,0,CSMjM_i.rows(),CSMjM_i.cols()).cols());
|
||||
// printf("CSM_MjMi: %d %d\n",i,CSMjM_i.rows(),CSMjM_i.cols());
|
||||
// printf("CSM_MjM_ifull: %d %d\n",i,CSMjM_ifull.rows(),CSMjM_ifull.cols());
|
||||
data.CSM_M[i].block(j*k,0,CSMjM_i.rows(),CSMjM_i.cols()) = CSMjM_ifull;
|
||||
}else
|
||||
{
|
||||
data.CSM_M[i].block(j*k,0,CSMjM_i.rows(),CSMjM_i.cols()) = CSMjM_i;
|
||||
}
|
||||
}
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"CSM_Mi=["<<endl<<data.CSM_M[i]<<endl<<"];"<<endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
// precompute arap_rhs matrix
|
||||
//printf("arap_rhs()\n");
|
||||
SparseMatrix<double> K;
|
||||
arap_rhs(V,F,V.cols(),data.energy,K);
|
||||
//#ifdef EXTREME_VERBOSE
|
||||
// cout<<"KIJV=["<<endl;print_ijv(K,1);cout<<endl<<"];"<<
|
||||
// endl<<"K=sparse(KIJV(:,1),KIJV(:,2),KIJV(:,3),"<<
|
||||
// K.rows()<<","<<K.cols()<<");"<<endl;
|
||||
//#endif
|
||||
// Precompute left muliplication by M and right multiplication by G_sum
|
||||
SparseMatrix<double> G_sumT = G_sum.transpose();
|
||||
SparseMatrix<double> G_sumT_dim_dim;
|
||||
repdiag(G_sumT,data.dim*data.dim,G_sumT_dim_dim);
|
||||
LbsMatrixType MT = M.transpose();
|
||||
// If this is a bottle neck then consider reordering matrix multiplication
|
||||
data.M_KG = -4.0 * (MT * (K * G_sumT_dim_dim));
|
||||
//#ifdef EXTREME_VERBOSE
|
||||
// cout<<"data.M_KGIJV=["<<endl;print_ijv(data.M_KG,1);cout<<endl<<"];"<<
|
||||
// endl<<"data.M_KG=sparse(data.M_KGIJV(:,1),data.M_KGIJV(:,2),data.M_KGIJV(:,3),"<<
|
||||
// data.M_KG.rows()<<","<<data.M_KG.cols()<<");"<<endl;
|
||||
//#endif
|
||||
|
||||
// Precompute system matrix
|
||||
//printf("A()\n");
|
||||
SparseMatrix<double> A;
|
||||
repdiag(Lapl,data.dim,A);
|
||||
data.Q = MT * (A * M);
|
||||
//#ifdef EXTREME_VERBOSE
|
||||
// cout<<"QIJV=["<<endl;print_ijv(data.Q,1);cout<<endl<<"];"<<
|
||||
// endl<<"Q=sparse(QIJV(:,1),QIJV(:,2),QIJV(:,3),"<<
|
||||
// data.Q.rows()<<","<<data.Q.cols()<<");"<<endl;
|
||||
//#endif
|
||||
|
||||
// Always do dynamics precomputation so we can hot-switch
|
||||
//if(data.with_dynamics)
|
||||
//{
|
||||
// Build cotangent laplacian
|
||||
SparseMatrix<double> Mass;
|
||||
//printf("massmatrix()\n");
|
||||
massmatrix(V,F,(F.cols()>3?MASSMATRIX_TYPE_BARYCENTRIC:MASSMATRIX_TYPE_VORONOI),Mass);
|
||||
//cout<<"MIJV=["<<endl;print_ijv(Mass,1);cout<<endl<<"];"<<
|
||||
// endl<<"M=sparse(MIJV(:,1),MIJV(:,2),MIJV(:,3),"<<
|
||||
// Mass.rows()<<","<<Mass.cols()<<");"<<endl;
|
||||
//speye(data.n,Mass);
|
||||
SparseMatrix<double> Mass_rep;
|
||||
repdiag(Mass,data.dim,Mass_rep);
|
||||
|
||||
// Multiply either side by weights matrix (should be dense)
|
||||
data.Mass_tilde = MT * Mass_rep * M;
|
||||
MatrixXd ones(data.dim*data.n,data.dim);
|
||||
for(int i = 0;i<data.n;i++)
|
||||
{
|
||||
for(int d = 0;d<data.dim;d++)
|
||||
{
|
||||
ones(i+d*data.n,d) = 1;
|
||||
}
|
||||
}
|
||||
data.fgrav = MT * (Mass_rep * ones);
|
||||
data.fext = MatrixXS::Zero(MT.rows(),1);
|
||||
//data.fgrav = MT * (ones);
|
||||
//}
|
||||
|
||||
|
||||
// This may/should be superfluous
|
||||
//printf("is_symmetric()\n");
|
||||
if(!is_symmetric(data.Q))
|
||||
{
|
||||
//printf("Fixing symmetry...\n");
|
||||
// "Fix" symmetry
|
||||
LbsMatrixType QT = data.Q.transpose();
|
||||
LbsMatrixType Q_copy = data.Q;
|
||||
data.Q = 0.5*(Q_copy+QT);
|
||||
// Check that ^^^ this really worked. It doesn't always
|
||||
//assert(is_symmetric(*Q));
|
||||
}
|
||||
|
||||
//printf("arap_dof_precomputation() succeeded... so far...\n");
|
||||
verbose("Number of handles: %i\n", data.m);
|
||||
return true;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// STATIC FUNCTIONS (These should be removed or properly defined)
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
namespace igl
|
||||
{
|
||||
// returns maximal difference of 'blok' from scalar times 3x3 identity:
|
||||
template <typename SSCALAR>
|
||||
inline static SSCALAR maxBlokErr(const Eigen::Matrix3f &blok)
|
||||
{
|
||||
SSCALAR mD;
|
||||
SSCALAR value = blok(0,0);
|
||||
SSCALAR diff1 = fabs(blok(1,1) - value);
|
||||
SSCALAR diff2 = fabs(blok(2,2) - value);
|
||||
if (diff1 > diff2) mD = diff1;
|
||||
else mD = diff2;
|
||||
|
||||
for (int v=0; v<3; v++)
|
||||
{
|
||||
for (int w=0; w<3; w++)
|
||||
{
|
||||
if (v == w)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (mD < fabs(blok(v, w)))
|
||||
{
|
||||
mD = fabs(blok(v, w));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return mD;
|
||||
}
|
||||
|
||||
// converts CSM_M_SSCALAR[0], CSM_M_SSCALAR[1], CSM_M_SSCALAR[2] into one
|
||||
// "condensed" matrix CSM while checking we're not losing any information by
|
||||
// this process; specifically, returns maximal difference from scaled 3x3
|
||||
// identity blocks, which should be pretty small number
|
||||
template <typename MatrixXS>
|
||||
static typename MatrixXS::Scalar condense_CSM(
|
||||
const std::vector<MatrixXS> &CSM_M_SSCALAR,
|
||||
int numBones,
|
||||
int dim,
|
||||
MatrixXS &CSM)
|
||||
{
|
||||
const int numRows = CSM_M_SSCALAR[0].rows();
|
||||
assert(CSM_M_SSCALAR[0].cols() == dim*(dim+1)*numBones);
|
||||
assert(CSM_M_SSCALAR[1].cols() == dim*(dim+1)*numBones);
|
||||
assert(CSM_M_SSCALAR[2].cols() == dim*(dim+1)*numBones);
|
||||
assert(CSM_M_SSCALAR[1].rows() == numRows);
|
||||
assert(CSM_M_SSCALAR[2].rows() == numRows);
|
||||
|
||||
const int numCols = (dim + 1)*numBones;
|
||||
CSM.resize(numRows, numCols);
|
||||
|
||||
typedef typename MatrixXS::Scalar SSCALAR;
|
||||
SSCALAR maxDiff = 0.0f;
|
||||
|
||||
for (int r=0; r<numRows; r++)
|
||||
{
|
||||
for (int coord=0; coord<dim+1; coord++)
|
||||
{
|
||||
for (int b=0; b<numBones; b++)
|
||||
{
|
||||
// this is just a test if we really have a multiple of 3x3 identity
|
||||
Eigen::Matrix3f blok;
|
||||
for (int v=0; v<3; v++)
|
||||
{
|
||||
for (int w=0; w<3; w++)
|
||||
{
|
||||
blok(v,w) = CSM_M_SSCALAR[v](r, coord*(numBones*dim) + b + w*numBones);
|
||||
}
|
||||
}
|
||||
|
||||
//SSCALAR value[3];
|
||||
//for (int v=0; v<3; v++)
|
||||
// CSM_M_SSCALAR[v](r, coord*(numBones*dim) + b + v*numBones);
|
||||
|
||||
SSCALAR mD = maxBlokErr<SSCALAR>(blok);
|
||||
if (mD > maxDiff) maxDiff = mD;
|
||||
|
||||
// use the first value:
|
||||
CSM(r, coord*numBones + b) = blok(0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maxDiff;
|
||||
}
|
||||
|
||||
// splits x_0, ... , x_dim coordinates in column vector 'L' into a numBones*(dimp1) x dim matrix 'Lsep';
|
||||
// assumes 'Lsep' has already been preallocated
|
||||
//
|
||||
// is this the same as uncolumnize? no.
|
||||
template <typename MatL, typename MatLsep>
|
||||
static void splitColumns(
|
||||
const MatL &L,
|
||||
int numBones,
|
||||
int dim,
|
||||
int dimp1,
|
||||
MatLsep &Lsep)
|
||||
{
|
||||
assert(L.cols() == 1);
|
||||
assert(L.rows() == dim*(dimp1)*numBones);
|
||||
|
||||
assert(Lsep.rows() == (dimp1)*numBones && Lsep.cols() == dim);
|
||||
|
||||
for (int b=0; b<numBones; b++)
|
||||
{
|
||||
for (int coord=0; coord<dimp1; coord++)
|
||||
{
|
||||
for (int c=0; c<dim; c++)
|
||||
{
|
||||
Lsep(coord*numBones + b, c) = L(coord*numBones*dim + c*numBones + b, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// the inverse of splitColumns, i.e., takes numBones*(dimp1) x dim matrix 'Lsep' and merges the dimensions
|
||||
// into columns vector 'L' (which is assumed to be already allocated):
|
||||
//
|
||||
// is this the same as columnize? no.
|
||||
template <typename MatrixXS>
|
||||
static void mergeColumns(const MatrixXS &Lsep, int numBones, int dim, int dimp1, MatrixXS &L)
|
||||
{
|
||||
assert(L.cols() == 1);
|
||||
assert(L.rows() == dim*(dimp1)*numBones);
|
||||
|
||||
assert(Lsep.rows() == (dimp1)*numBones && Lsep.cols() == dim);
|
||||
|
||||
for (int b=0; b<numBones; b++)
|
||||
{
|
||||
for (int coord=0; coord<dimp1; coord++)
|
||||
{
|
||||
for (int c=0; c<dim; c++)
|
||||
{
|
||||
L(coord*numBones*dim + c*numBones + b, 0) = Lsep(coord*numBones + b, c);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// converts "Solve1" the "rotations" part of FullSolve matrix (the first part)
|
||||
// into one "condensed" matrix CSolve1 while checking we're not losing any
|
||||
// information by this process; specifically, returns maximal difference from
|
||||
// scaled 3x3 identity blocks, which should be pretty small number
|
||||
template <typename MatrixXS>
|
||||
static typename MatrixXS::Scalar condense_Solve1(MatrixXS &Solve1, int numBones, int numGroups, int dim, MatrixXS &CSolve1)
|
||||
{
|
||||
assert(Solve1.rows() == dim*(dim + 1)*numBones);
|
||||
assert(Solve1.cols() == dim*dim*numGroups);
|
||||
|
||||
typedef typename MatrixXS::Scalar SSCALAR;
|
||||
SSCALAR maxDiff = 0.0f;
|
||||
|
||||
CSolve1.resize((dim + 1)*numBones, dim*numGroups);
|
||||
for (int rowCoord=0; rowCoord<dim+1; rowCoord++)
|
||||
{
|
||||
for (int b=0; b<numBones; b++)
|
||||
{
|
||||
for (int colCoord=0; colCoord<dim; colCoord++)
|
||||
{
|
||||
for (int g=0; g<numGroups; g++)
|
||||
{
|
||||
Eigen::Matrix3f blok;
|
||||
for (int r=0; r<3; r++)
|
||||
{
|
||||
for (int c=0; c<3; c++)
|
||||
{
|
||||
blok(r, c) = Solve1(rowCoord*numBones*dim + r*numBones + b, colCoord*numGroups*dim + c*numGroups + g);
|
||||
}
|
||||
}
|
||||
|
||||
SSCALAR mD = maxBlokErr<SSCALAR>(blok);
|
||||
if (mD > maxDiff) maxDiff = mD;
|
||||
|
||||
CSolve1(rowCoord*numBones + b, colCoord*numGroups + g) = blok(0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return maxDiff;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
IGL_INLINE bool igl::arap_dof_recomputation(
|
||||
const Eigen::Matrix<int,Eigen::Dynamic,1> & fixed_dim,
|
||||
const Eigen::SparseMatrix<double> & A_eq,
|
||||
ArapDOFData<LbsMatrixType, SSCALAR> & data)
|
||||
{
|
||||
using namespace Eigen;
|
||||
typedef Matrix<SSCALAR, Dynamic, Dynamic> MatrixXS;
|
||||
|
||||
LbsMatrixType * Q;
|
||||
LbsMatrixType Qdyn;
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
// multiply by 1/timestep and to quadratic coefficients matrix
|
||||
// Might be missing a 0.5 here
|
||||
LbsMatrixType Q_copy = data.Q;
|
||||
Qdyn = Q_copy + (1.0/(data.h*data.h))*data.Mass_tilde;
|
||||
Q = &Qdyn;
|
||||
|
||||
// This may/should be superfluous
|
||||
//printf("is_symmetric()\n");
|
||||
if(!is_symmetric(*Q))
|
||||
{
|
||||
//printf("Fixing symmetry...\n");
|
||||
// "Fix" symmetry
|
||||
LbsMatrixType QT = (*Q).transpose();
|
||||
LbsMatrixType Q_copy = *Q;
|
||||
*Q = 0.5*(Q_copy+QT);
|
||||
// Check that ^^^ this really worked. It doesn't always
|
||||
//assert(is_symmetric(*Q));
|
||||
}
|
||||
}else
|
||||
{
|
||||
Q = &data.Q;
|
||||
}
|
||||
|
||||
assert((int)data.CSM_M.size() == data.dim);
|
||||
assert(A_eq.cols() == data.m*data.dim*(data.dim+1));
|
||||
data.fixed_dim = fixed_dim;
|
||||
|
||||
if(fixed_dim.size() > 0)
|
||||
{
|
||||
assert(fixed_dim.maxCoeff() < data.m*data.dim*(data.dim+1));
|
||||
assert(fixed_dim.minCoeff() >= 0);
|
||||
}
|
||||
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"data.fixed_dim=["<<endl<<data.fixed_dim<<endl<<"]+1;"<<endl;
|
||||
#endif
|
||||
|
||||
// Compute dense solve matrix (alternative of matrix factorization)
|
||||
//printf("kkt_inverse()\n");
|
||||
MatrixXd Qfull(*Q);
|
||||
MatrixXd A_eqfull(A_eq);
|
||||
MatrixXd M_Solve;
|
||||
|
||||
double timer0_start = get_seconds_hires();
|
||||
bool use_lu = data.effective_dim != 2;
|
||||
//use_lu = false;
|
||||
//printf("use_lu: %s\n",(use_lu?"TRUE":"FALSE"));
|
||||
kkt_inverse(Qfull, A_eqfull, use_lu,M_Solve);
|
||||
double timer0_end = get_seconds_hires();
|
||||
verbose("Bob timing: %.20f\n", (timer0_end - timer0_start)*1000.0);
|
||||
|
||||
// Precompute full solve matrix:
|
||||
const int fsRows = data.m * data.dim * (data.dim + 1); // 12 * number_of_bones
|
||||
const int fsCols1 = data.M_KG.cols(); // 9 * number_of_posConstraints
|
||||
const int fsCols2 = A_eq.rows(); // number_of_posConstraints
|
||||
data.M_FullSolve.resize(fsRows, fsCols1 + fsCols2);
|
||||
// note the magical multiplicative constant "-0.5", I've no idea why it has
|
||||
// to be there :)
|
||||
data.M_FullSolve <<
|
||||
(-0.5 * M_Solve.block(0, 0, fsRows, fsRows) * data.M_KG).template cast<SSCALAR>(),
|
||||
M_Solve.block(0, fsRows, fsRows, fsCols2).template cast<SSCALAR>();
|
||||
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
printf(
|
||||
"---------------------------------------------------------------------\n"
|
||||
"\n\n\nWITH DYNAMICS recomputation\n\n\n"
|
||||
"---------------------------------------------------------------------\n"
|
||||
);
|
||||
// Also need to save Π1 before it gets multiplied by Ktilde (aka M_KG)
|
||||
data.Pi_1 = M_Solve.block(0, 0, fsRows, fsRows).template cast<SSCALAR>();
|
||||
}
|
||||
|
||||
// Precompute condensed matrices,
|
||||
// first CSM:
|
||||
std::vector<MatrixXS> CSM_M_SSCALAR;
|
||||
CSM_M_SSCALAR.resize(data.dim);
|
||||
for (int i=0; i<data.dim; i++) CSM_M_SSCALAR[i] = data.CSM_M[i].template cast<SSCALAR>();
|
||||
SSCALAR maxErr1 = condense_CSM(CSM_M_SSCALAR, data.m, data.dim, data.CSM);
|
||||
verbose("condense_CSM maxErr = %.15f (this should be close to zero)\n", maxErr1);
|
||||
assert(fabs(maxErr1) < 1e-5);
|
||||
|
||||
// and then solveBlock1:
|
||||
// number of groups
|
||||
const int k = data.CSM_M[0].rows()/data.dim;
|
||||
MatrixXS SolveBlock1 = data.M_FullSolve.block(0, 0, data.M_FullSolve.rows(), data.dim * data.dim * k);
|
||||
SSCALAR maxErr2 = condense_Solve1(SolveBlock1, data.m, k, data.dim, data.CSolveBlock1);
|
||||
verbose("condense_Solve1 maxErr = %.15f (this should be close to zero)\n", maxErr2);
|
||||
assert(fabs(maxErr2) < 1e-5);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
IGL_INLINE bool igl::arap_dof_update(
|
||||
const ArapDOFData<LbsMatrixType, SSCALAR> & data,
|
||||
const Eigen::Matrix<double,Eigen::Dynamic,1> & B_eq,
|
||||
const Eigen::MatrixXd & L0,
|
||||
const int max_iters,
|
||||
const double
|
||||
#ifdef IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
|
||||
tol,
|
||||
#else
|
||||
/*tol*/,
|
||||
#endif
|
||||
Eigen::MatrixXd & L
|
||||
)
|
||||
{
|
||||
using namespace Eigen;
|
||||
typedef Matrix<SSCALAR, Dynamic, Dynamic> MatrixXS;
|
||||
#ifdef ARAP_GLOBAL_TIMING
|
||||
double timer_start = get_seconds_hires();
|
||||
#endif
|
||||
|
||||
// number of dimensions
|
||||
assert((int)data.CSM_M.size() == data.dim);
|
||||
assert((int)L0.size() == (data.m)*data.dim*(data.dim+1));
|
||||
assert(max_iters >= 0);
|
||||
assert(tol >= 0);
|
||||
|
||||
// timing variables
|
||||
double
|
||||
sec_start,
|
||||
sec_covGather,
|
||||
sec_fitRotations,
|
||||
//sec_rhs,
|
||||
sec_prepMult,
|
||||
sec_solve, sec_end;
|
||||
|
||||
assert(L0.cols() == 1);
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"dim="<<data.dim<<";"<<endl;
|
||||
cout<<"m="<<data.m<<";"<<endl;
|
||||
#endif
|
||||
|
||||
// number of groups
|
||||
const int k = data.CSM_M[0].rows()/data.dim;
|
||||
for(int i = 0;i<data.dim;i++)
|
||||
{
|
||||
assert(data.CSM_M[i].rows()/data.dim == k);
|
||||
}
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"k="<<k<<";"<<endl;
|
||||
#endif
|
||||
|
||||
// resize output and initialize with initial guess
|
||||
L = L0;
|
||||
#ifndef IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
|
||||
// Keep track of last solution
|
||||
MatrixXS L_prev;
|
||||
#endif
|
||||
// We will be iterating on L_SSCALAR, only at the end we convert back to double
|
||||
MatrixXS L_SSCALAR = L.cast<SSCALAR>();
|
||||
|
||||
int iters = 0;
|
||||
#ifndef IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
|
||||
double max_diff = tol+1;
|
||||
#endif
|
||||
|
||||
MatrixXS S(k*data.dim,data.dim);
|
||||
MatrixXS R(data.dim,data.dim*k);
|
||||
Eigen::Matrix<SSCALAR,Eigen::Dynamic,1> Rcol(data.dim * data.dim * k);
|
||||
Matrix<SSCALAR,Dynamic,1> B_eq_SSCALAR = B_eq.cast<SSCALAR>();
|
||||
Matrix<SSCALAR,Dynamic,1> B_eq_fix_SSCALAR;
|
||||
Matrix<SSCALAR,Dynamic,1> L0SSCALAR = L0.cast<SSCALAR>();
|
||||
slice(L0SSCALAR, data.fixed_dim, B_eq_fix_SSCALAR);
|
||||
//MatrixXS rhsFull(Rcol.rows() + B_eq.rows() + B_eq_fix_SSCALAR.rows(), 1);
|
||||
|
||||
MatrixXS Lsep(data.m*(data.dim + 1), 3);
|
||||
const MatrixXS L_part2 =
|
||||
data.M_FullSolve.block(0, Rcol.rows(), data.M_FullSolve.rows(), B_eq_SSCALAR.rows()) * B_eq_SSCALAR;
|
||||
const MatrixXS L_part3 =
|
||||
data.M_FullSolve.block(0, Rcol.rows() + B_eq_SSCALAR.rows(), data.M_FullSolve.rows(), B_eq_fix_SSCALAR.rows()) * B_eq_fix_SSCALAR;
|
||||
MatrixXS L_part2and3 = L_part2 + L_part3;
|
||||
|
||||
// preallocate workspace variables:
|
||||
MatrixXS Rxyz(k*data.dim, data.dim);
|
||||
MatrixXS L_part1xyz((data.dim + 1) * data.m, data.dim);
|
||||
MatrixXS L_part1(data.dim * (data.dim + 1) * data.m, 1);
|
||||
|
||||
#ifdef ARAP_GLOBAL_TIMING
|
||||
double timer_prepFinished = get_seconds_hires();
|
||||
#endif
|
||||
|
||||
#ifdef IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
|
||||
while(iters < max_iters)
|
||||
#else
|
||||
while(iters < max_iters && max_diff > tol)
|
||||
#endif
|
||||
{
|
||||
if(data.print_timings)
|
||||
{
|
||||
sec_start = get_seconds_hires();
|
||||
}
|
||||
|
||||
#ifndef IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
|
||||
L_prev = L_SSCALAR;
|
||||
#endif
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// Local step: Fix positions, fit rotations
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Gather covariance matrices
|
||||
|
||||
splitColumns(L_SSCALAR, data.m, data.dim, data.dim + 1, Lsep);
|
||||
|
||||
S = data.CSM * Lsep;
|
||||
// interestingly, this doesn't seem to be so slow, but
|
||||
//MKL is still 2x faster (probably due to AVX)
|
||||
//#ifdef IGL_ARAP_DOF_DOUBLE_PRECISION_SOLVE
|
||||
// MKL_matMatMult_double(S, data.CSM, Lsep);
|
||||
//#else
|
||||
// MKL_matMatMult_single(S, data.CSM, Lsep);
|
||||
//#endif
|
||||
|
||||
if(data.print_timings)
|
||||
{
|
||||
sec_covGather = get_seconds_hires();
|
||||
}
|
||||
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"S=["<<endl<<S<<endl<<"];"<<endl;
|
||||
#endif
|
||||
// Fit rotations to covariance matrices
|
||||
if(data.effective_dim == 2)
|
||||
{
|
||||
fit_rotations_planar(S,R);
|
||||
}else
|
||||
{
|
||||
#ifdef __SSE__ // fit_rotations_SSE will convert to float if necessary
|
||||
fit_rotations_SSE(S,R);
|
||||
#else
|
||||
fit_rotations(S,false,R);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"R=["<<endl<<R<<endl<<"];"<<endl;
|
||||
#endif
|
||||
|
||||
if(data.print_timings)
|
||||
{
|
||||
sec_fitRotations = get_seconds_hires();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// "Global" step: fix rotations per mesh vertex, solve for
|
||||
// linear transformations at handles
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// all this shuffling is retarded and not completely negligible time-wise;
|
||||
// TODO: change fit_rotations_XXX so it returns R in the format ready for
|
||||
// CSolveBlock1 multiplication
|
||||
columnize(R, k, 2, Rcol);
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"Rcol=["<<endl<<Rcol<<endl<<"];"<<endl;
|
||||
#endif
|
||||
splitColumns(Rcol, k, data.dim, data.dim, Rxyz);
|
||||
|
||||
if(data.print_timings)
|
||||
{
|
||||
sec_prepMult = get_seconds_hires();
|
||||
}
|
||||
|
||||
L_part1xyz = data.CSolveBlock1 * Rxyz;
|
||||
//#ifdef IGL_ARAP_DOF_DOUBLE_PRECISION_SOLVE
|
||||
// MKL_matMatMult_double(L_part1xyz, data.CSolveBlock1, Rxyz);
|
||||
//#else
|
||||
// MKL_matMatMult_single(L_part1xyz, data.CSolveBlock1, Rxyz);
|
||||
//#endif
|
||||
mergeColumns(L_part1xyz, data.m, data.dim, data.dim + 1, L_part1);
|
||||
|
||||
if(data.with_dynamics)
|
||||
{
|
||||
// Consider reordering or precomputing matrix multiplications
|
||||
MatrixXS L_part1_dyn(data.dim * (data.dim + 1) * data.m, 1);
|
||||
// Eigen can't parse this:
|
||||
//L_part1_dyn =
|
||||
// -(2.0/(data.h*data.h)) * data.Pi_1 * data.Mass_tilde * data.L0 +
|
||||
// (1.0/(data.h*data.h)) * data.Pi_1 * data.Mass_tilde * data.Lm1;
|
||||
// -1.0 because we've moved these linear terms to the right hand side
|
||||
//MatrixXS temp = -1.0 *
|
||||
// ((-2.0/(data.h*data.h)) * data.L0.array() +
|
||||
// (1.0/(data.h*data.h)) * data.Lm1.array()).matrix();
|
||||
//MatrixXS temp = -1.0 *
|
||||
// ( (-1.0/(data.h*data.h)) * data.L0.array() +
|
||||
// (1.0/(data.h*data.h)) * data.Lm1.array()
|
||||
// (-1.0/(data.h*data.h)) * data.L0.array() +
|
||||
// ).matrix();
|
||||
//Lvel0 = (1.0/(data.h)) * data.Lm1.array() - data.L0.array();
|
||||
MatrixXS temp = -1.0 *
|
||||
( (-1.0/(data.h*data.h)) * data.L0.array() +
|
||||
(1.0/(data.h)) * data.Lvel0.array()
|
||||
).matrix();
|
||||
MatrixXd temp_d = temp.template cast<double>();
|
||||
|
||||
MatrixXd temp_g = data.fgrav*(data.grav_mag*data.grav_dir);
|
||||
|
||||
assert(data.fext.rows() == temp_g.rows());
|
||||
assert(data.fext.cols() == temp_g.cols());
|
||||
MatrixXd temp2 = data.Mass_tilde * temp_d + temp_g + data.fext.template cast<double>();
|
||||
MatrixXS temp2_f = temp2.template cast<SSCALAR>();
|
||||
L_part1_dyn = data.Pi_1 * temp2_f;
|
||||
L_part1.array() = L_part1.array() + L_part1_dyn.array();
|
||||
}
|
||||
|
||||
//L_SSCALAR = L_part1 + L_part2and3;
|
||||
assert(L_SSCALAR.rows() == L_part1.rows() && L_SSCALAR.rows() == L_part2and3.rows());
|
||||
for (int i=0; i<L_SSCALAR.rows(); i++)
|
||||
{
|
||||
L_SSCALAR(i, 0) = L_part1(i, 0) + L_part2and3(i, 0);
|
||||
}
|
||||
|
||||
#ifdef EXTREME_VERBOSE
|
||||
cout<<"L=["<<endl<<L<<endl<<"];"<<endl;
|
||||
#endif
|
||||
|
||||
if(data.print_timings)
|
||||
{
|
||||
sec_solve = get_seconds_hires();
|
||||
}
|
||||
|
||||
#ifndef IGL_ARAP_DOF_FIXED_ITERATIONS_COUNT
|
||||
// Compute maximum absolute difference with last iteration's solution
|
||||
max_diff = (L_SSCALAR-L_prev).eval().array().abs().matrix().maxCoeff();
|
||||
#endif
|
||||
iters++;
|
||||
|
||||
if(data.print_timings)
|
||||
{
|
||||
sec_end = get_seconds_hires();
|
||||
#ifndef WIN32
|
||||
// trick to get sec_* variables to compile without warning on mac
|
||||
if(false)
|
||||
#endif
|
||||
printf(
|
||||
"\ntotal iteration time = %f "
|
||||
"[local: covGather = %f, "
|
||||
"fitRotations = %f, "
|
||||
"global: prep = %f, "
|
||||
"solve = %f, "
|
||||
"error = %f [ms]]\n",
|
||||
(sec_end - sec_start)*1000.0,
|
||||
(sec_covGather - sec_start)*1000.0,
|
||||
(sec_fitRotations - sec_covGather)*1000.0,
|
||||
(sec_prepMult - sec_fitRotations)*1000.0,
|
||||
(sec_solve - sec_prepMult)*1000.0,
|
||||
(sec_end - sec_solve)*1000.0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
L = L_SSCALAR.template cast<double>();
|
||||
assert(L.cols() == 1);
|
||||
|
||||
#ifdef ARAP_GLOBAL_TIMING
|
||||
double timer_finito = get_seconds_hires();
|
||||
printf(
|
||||
"ARAP preparation = %f, "
|
||||
"all %i iterations = %f [ms]\n",
|
||||
(timer_prepFinished - timer_start)*1000.0,
|
||||
max_iters,
|
||||
(timer_finito - timer_prepFinished)*1000.0);
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template bool igl::arap_dof_update<Eigen::Matrix<double, -1, -1, 0, -1, -1>, double>(ArapDOFData<Eigen::Matrix<double, -1, -1, 0, -1, -1>, double> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, int, double, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
|
||||
template bool igl::arap_dof_recomputation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int> const&, ArapDOFData<Eigen::Matrix<double, -1, -1, 0, -1, -1>, double>&);
|
||||
template bool igl::arap_dof_precomputation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, double>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, ArapDOFData<Eigen::Matrix<double, -1, -1, 0, -1, -1>, double>&);
|
||||
template bool igl::arap_dof_update<Eigen::Matrix<double, -1, -1, 0, -1, -1>, float>(igl::ArapDOFData<Eigen::Matrix<double, -1, -1, 0, -1, -1>, float> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, int, double, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
|
||||
template bool igl::arap_dof_recomputation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, float>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int> const&, igl::ArapDOFData<Eigen::Matrix<double, -1, -1, 0, -1, -1>, float>&);
|
||||
template bool igl::arap_dof_precomputation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, float>(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, igl::ArapDOFData<Eigen::Matrix<double, -1, -1, 0, -1, -1>, float>&);
|
||||
#endif
|
||||
244
src/external/libigl-2.3.0/include/igl/arap_dof.h
vendored
244
src/external/libigl-2.3.0/include/igl/arap_dof.h
vendored
@ -1,244 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ARAP_ENERGY_TYPE_DOF_H
|
||||
#define IGL_ARAP_ENERGY_TYPE_DOF_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
#include "ARAPEnergyType.h"
|
||||
#include <vector>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Caller example:
|
||||
//
|
||||
// Once:
|
||||
// arap_dof_precomputation(...)
|
||||
//
|
||||
// Each frame:
|
||||
// while(not satisfied)
|
||||
// arap_dof_update(...)
|
||||
// end
|
||||
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
struct ArapDOFData;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Arap DOF precomputation consists of two parts the computation. The first is
|
||||
// that which depends solely on the mesh (V,F), the linear blend skinning
|
||||
// weights (M) and the groups G. Then there's the part that depends on the
|
||||
// previous precomputation and the list of free and fixed vertices.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// The code and variables differ from the description in Section 3 of "Fast
|
||||
// Automatic Skinning Transformations" by [Jacobson et al. 2012]
|
||||
//
|
||||
// Here is a useful conversion table:
|
||||
//
|
||||
// [article] [code]
|
||||
// S = \tilde{K} T S = CSM * Lsep
|
||||
// S --> R S --> R --shuffled--> Rxyz
|
||||
// Gamma_solve RT = Pi_1 \tilde{K} RT L_part1xyz = CSolveBlock1 * Rxyz
|
||||
// Pi_1 \tilde{K} CSolveBlock1
|
||||
// Peq = [T_full; P_pos]
|
||||
// T_full B_eq_fix <--- L0
|
||||
// P_pos B_eq
|
||||
// Pi_2 * P_eq = Lpart2and3 = Lpart2 + Lpart3
|
||||
// Pi_2_left T_full + Lpart3 = M_fullsolve(right) * B_eq_fix
|
||||
// Pi_2_right P_pos Lpart2 = M_fullsolve(left) * B_eq
|
||||
// T = [Pi_1 Pi_2] [\tilde{K}TRT P_eq] L = Lpart1 + Lpart2and3
|
||||
//
|
||||
|
||||
// Precomputes the system we are going to optimize. This consists of building
|
||||
// constructor matrices (to compute covariance matrices from transformations
|
||||
// and to build the poisson solve right hand side from rotation matrix entries)
|
||||
// and also prefactoring the poisson system.
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by dim list of vertex positions
|
||||
// F #F by {3|4} list of face indices
|
||||
// M #V * dim by #handles * dim * (dim+1) matrix such that
|
||||
// new_V(:) = LBS(V,W,A) = reshape(M * A,size(V)), where A is a column
|
||||
// vectors formed by the entries in each handle's dim by dim+1
|
||||
// transformation matrix. Specifcally, A =
|
||||
// reshape(permute(Astack,[3 1 2]),n*dim*(dim+1),1)
|
||||
// or A = [Lxx;Lyx;Lxy;Lyy;tx;ty], and likewise for other dim
|
||||
// if Astack(:,:,i) is the dim by (dim+1) transformation at handle i
|
||||
// handles are ordered according to P then BE (point handles before bone
|
||||
// handles)
|
||||
// G #V list of group indices (1 to k) for each vertex, such that vertex i
|
||||
// is assigned to group G(i)
|
||||
// Outputs:
|
||||
// data structure containing all necessary precomputation for calling
|
||||
// arap_dof_update
|
||||
// Returns true on success, false on error
|
||||
//
|
||||
// See also: lbs_matrix_column
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
IGL_INLINE bool arap_dof_precomputation(
|
||||
const Eigen::MatrixXd & V,
|
||||
const Eigen::MatrixXi & F,
|
||||
const LbsMatrixType & M,
|
||||
const Eigen::Matrix<int,Eigen::Dynamic,1> & G,
|
||||
ArapDOFData<LbsMatrixType, SSCALAR> & data);
|
||||
|
||||
// Should always be called after arap_dof_precomputation, but may be called in
|
||||
// between successive calls to arap_dof_update, recomputes precomputation
|
||||
// given that there are only changes in free and fixed
|
||||
//
|
||||
// Inputs:
|
||||
// fixed_dim list of transformation element indices for fixed (or partailly
|
||||
// fixed) handles: not necessarily the complement of 'free'
|
||||
// NOTE: the constraints for fixed transformations still need to be
|
||||
// present in A_eq
|
||||
// A_eq dim*#constraint_points by m*dim*(dim+1) matrix of linear equality
|
||||
// constraint coefficients. Each row corresponds to a linear constraint,
|
||||
// so that A_eq * L = Beq says that the linear transformation entries in
|
||||
// the column L should produce the user supplied positional constraints
|
||||
// for each handle in Beq. The row A_eq(i*dim+d) corresponds to the
|
||||
// constrain on coordinate d of position i
|
||||
// Outputs:
|
||||
// data structure containing all necessary precomputation for calling
|
||||
// arap_dof_update
|
||||
// Returns true on success, false on error
|
||||
//
|
||||
// See also: lbs_matrix_column
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
IGL_INLINE bool arap_dof_recomputation(
|
||||
const Eigen::Matrix<int,Eigen::Dynamic,1> & fixed_dim,
|
||||
const Eigen::SparseMatrix<double> & A_eq,
|
||||
ArapDOFData<LbsMatrixType, SSCALAR> & data);
|
||||
|
||||
// Optimizes the transformations attached to each weight function based on
|
||||
// precomputed system.
|
||||
//
|
||||
// Inputs:
|
||||
// data precomputation data struct output from arap_dof_precomputation
|
||||
// Beq dim*#constraint_points constraint values.
|
||||
// L0 #handles * dim * dim+1 list of initial guess transformation entries,
|
||||
// also holds fixed transformation entries for fixed handles
|
||||
// max_iters maximum number of iterations
|
||||
// tol stopping criteria parameter. If variables (linear transformation
|
||||
// matrix entries) change by less than 'tol' the optimization terminates,
|
||||
// 0.75 (weak tolerance)
|
||||
// 0.0 (extreme tolerance)
|
||||
// Outputs:
|
||||
// L #handles * dim * dim+1 list of final optimized transformation entries,
|
||||
// allowed to be the same as L
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
IGL_INLINE bool arap_dof_update(
|
||||
const ArapDOFData<LbsMatrixType,SSCALAR> & data,
|
||||
const Eigen::Matrix<double,Eigen::Dynamic,1> & B_eq,
|
||||
const Eigen::MatrixXd & L0,
|
||||
const int max_iters,
|
||||
const double tol,
|
||||
Eigen::MatrixXd & L
|
||||
);
|
||||
|
||||
// Structure that contains fields for all precomputed data or data that needs
|
||||
// to be remembered at update
|
||||
template <typename LbsMatrixType, typename SSCALAR>
|
||||
struct ArapDOFData
|
||||
{
|
||||
typedef Eigen::Matrix<SSCALAR, Eigen::Dynamic, Eigen::Dynamic> MatrixXS;
|
||||
// Type of arap energy we're solving
|
||||
igl::ARAPEnergyType energy;
|
||||
//// LU decomposition precomptation data; note: not used by araf_dop_update
|
||||
//// any more, replaced by M_FullSolve
|
||||
//igl::min_quad_with_fixed_data<double> lu_data;
|
||||
// List of indices of fixed transformation entries
|
||||
Eigen::Matrix<int,Eigen::Dynamic,1> fixed_dim;
|
||||
// List of precomputed covariance scatter matrices multiplied by lbs
|
||||
// matrices
|
||||
//std::vector<Eigen::SparseMatrix<double> > CSM_M;
|
||||
std::vector<Eigen::MatrixXd> CSM_M;
|
||||
LbsMatrixType M_KG;
|
||||
// Number of mesh vertices
|
||||
int n;
|
||||
// Number of weight functions
|
||||
int m;
|
||||
// Number of dimensions
|
||||
int dim;
|
||||
// Effective dimensions
|
||||
int effective_dim;
|
||||
// List of indices into C of positional constraints
|
||||
Eigen::Matrix<int,Eigen::Dynamic,1> interpolated;
|
||||
std::vector<bool> free_mask;
|
||||
// Full quadratic coefficients matrix before lagrangian (should be dense)
|
||||
LbsMatrixType Q;
|
||||
|
||||
|
||||
//// Solve matrix for the global step
|
||||
//Eigen::MatrixXd M_Solve; // TODO: remove from here
|
||||
|
||||
// Full solve matrix that contains also conversion from rotations to the right hand side,
|
||||
// i.e., solves Poisson transformations just from rotations and positional constraints
|
||||
MatrixXS M_FullSolve;
|
||||
|
||||
// Precomputed condensed matrices (3x3 commutators folded to 1x1):
|
||||
MatrixXS CSM;
|
||||
MatrixXS CSolveBlock1;
|
||||
|
||||
// Print timings at each update
|
||||
bool print_timings;
|
||||
|
||||
// Dynamics
|
||||
bool with_dynamics;
|
||||
// I'm hiding the extra dynamics stuff in this struct, which sort of defeats
|
||||
// the purpose of this function-based coding style...
|
||||
|
||||
// Time step
|
||||
double h;
|
||||
|
||||
// L0 #handles * dim * dim+1 list of transformation entries from
|
||||
// previous solve
|
||||
MatrixXS L0;
|
||||
//// Lm1 #handles * dim * dim+1 list of transformation entries from
|
||||
//// previous-previous solve
|
||||
//MatrixXS Lm1;
|
||||
// "Velocity"
|
||||
MatrixXS Lvel0;
|
||||
|
||||
// #V by dim matrix of external forces
|
||||
// fext
|
||||
MatrixXS fext;
|
||||
|
||||
// Mass_tilde: MT * Mass * M
|
||||
LbsMatrixType Mass_tilde;
|
||||
|
||||
// Force due to gravity (premultiplier)
|
||||
Eigen::MatrixXd fgrav;
|
||||
// Direction of gravity
|
||||
Eigen::Vector3d grav_dir;
|
||||
// Magnitude of gravity
|
||||
double grav_mag;
|
||||
|
||||
// Π1 from the paper
|
||||
MatrixXS Pi_1;
|
||||
|
||||
// Default values
|
||||
ArapDOFData():
|
||||
energy(igl::ARAP_ENERGY_TYPE_SPOKES),
|
||||
with_dynamics(false),
|
||||
h(1),
|
||||
grav_dir(0,-1,0),
|
||||
grav_mag(0)
|
||||
{
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "arap_dof.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,259 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "arap_linear_block.h"
|
||||
#include "verbose.h"
|
||||
#include "cotmatrix_entries.h"
|
||||
#include <Eigen/Dense>
|
||||
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void igl::arap_linear_block(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
const igl::ARAPEnergyType energy,
|
||||
MatK & Kd)
|
||||
{
|
||||
switch(energy)
|
||||
{
|
||||
case ARAP_ENERGY_TYPE_SPOKES:
|
||||
return igl::arap_linear_block_spokes(V,F,d,Kd);
|
||||
break;
|
||||
case ARAP_ENERGY_TYPE_SPOKES_AND_RIMS:
|
||||
return igl::arap_linear_block_spokes_and_rims(V,F,d,Kd);
|
||||
break;
|
||||
case ARAP_ENERGY_TYPE_ELEMENTS:
|
||||
return igl::arap_linear_block_elements(V,F,d,Kd);
|
||||
break;
|
||||
default:
|
||||
verbose("Unsupported energy type: %d\n",energy);
|
||||
assert(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void igl::arap_linear_block_spokes(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
MatK & Kd)
|
||||
{
|
||||
typedef typename MatK::Scalar Scalar;
|
||||
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// simplex size (3: triangles, 4: tetrahedra)
|
||||
int simplex_size = F.cols();
|
||||
// Number of elements
|
||||
int m = F.rows();
|
||||
// Temporary output
|
||||
Matrix<int,Dynamic,2> edges;
|
||||
Kd.resize(V.rows(), V.rows());
|
||||
vector<Triplet<Scalar> > Kd_IJV;
|
||||
if(simplex_size == 3)
|
||||
{
|
||||
// triangles
|
||||
Kd.reserve(7*V.rows());
|
||||
Kd_IJV.reserve(7*V.rows());
|
||||
edges.resize(3,2);
|
||||
edges <<
|
||||
1,2,
|
||||
2,0,
|
||||
0,1;
|
||||
}else if(simplex_size == 4)
|
||||
{
|
||||
// tets
|
||||
Kd.reserve(17*V.rows());
|
||||
Kd_IJV.reserve(17*V.rows());
|
||||
edges.resize(6,2);
|
||||
edges <<
|
||||
1,2,
|
||||
2,0,
|
||||
0,1,
|
||||
3,0,
|
||||
3,1,
|
||||
3,2;
|
||||
}
|
||||
// gather cotangent weights
|
||||
Matrix<Scalar,Dynamic,Dynamic> C;
|
||||
cotmatrix_entries(V,F,C);
|
||||
// should have weights for each edge
|
||||
assert(C.cols() == edges.rows());
|
||||
// loop over elements
|
||||
for(int i = 0;i<m;i++)
|
||||
{
|
||||
// loop over edges of element
|
||||
for(int e = 0;e<edges.rows();e++)
|
||||
{
|
||||
int source = F(i,edges(e,0));
|
||||
int dest = F(i,edges(e,1));
|
||||
double v = 0.5*C(i,e)*(V(source,d)-V(dest,d));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(source,dest,v));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(dest,source,-v));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(source,source,v));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(dest,dest,-v));
|
||||
}
|
||||
}
|
||||
Kd.setFromTriplets(Kd_IJV.begin(),Kd_IJV.end());
|
||||
Kd.makeCompressed();
|
||||
}
|
||||
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void igl::arap_linear_block_spokes_and_rims(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
MatK & Kd)
|
||||
{
|
||||
typedef typename MatK::Scalar Scalar;
|
||||
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// simplex size (3: triangles, 4: tetrahedra)
|
||||
int simplex_size = F.cols();
|
||||
// Number of elements
|
||||
int m = F.rows();
|
||||
// Temporary output
|
||||
Kd.resize(V.rows(), V.rows());
|
||||
vector<Triplet<Scalar> > Kd_IJV;
|
||||
Matrix<int,Dynamic,2> edges;
|
||||
if(simplex_size == 3)
|
||||
{
|
||||
// triangles
|
||||
Kd.reserve(7*V.rows());
|
||||
Kd_IJV.reserve(7*V.rows());
|
||||
edges.resize(3,2);
|
||||
edges <<
|
||||
1,2,
|
||||
2,0,
|
||||
0,1;
|
||||
}else if(simplex_size == 4)
|
||||
{
|
||||
// tets
|
||||
Kd.reserve(17*V.rows());
|
||||
Kd_IJV.reserve(17*V.rows());
|
||||
edges.resize(6,2);
|
||||
edges <<
|
||||
1,2,
|
||||
2,0,
|
||||
0,1,
|
||||
3,0,
|
||||
3,1,
|
||||
3,2;
|
||||
// Not implemented yet for tets
|
||||
assert(false);
|
||||
}
|
||||
// gather cotangent weights
|
||||
Matrix<Scalar,Dynamic,Dynamic> C;
|
||||
cotmatrix_entries(V,F,C);
|
||||
// should have weights for each edge
|
||||
assert(C.cols() == edges.rows());
|
||||
// loop over elements
|
||||
for(int i = 0;i<m;i++)
|
||||
{
|
||||
// loop over edges of element
|
||||
for(int e = 0;e<edges.rows();e++)
|
||||
{
|
||||
int source = F(i,edges(e,0));
|
||||
int dest = F(i,edges(e,1));
|
||||
double v = C(i,e)*(V(source,d)-V(dest,d))/3.0;
|
||||
// loop over edges again
|
||||
for(int f = 0;f<edges.rows();f++)
|
||||
{
|
||||
int Rs = F(i,edges(f,0));
|
||||
int Rd = F(i,edges(f,1));
|
||||
if(Rs == source && Rd == dest)
|
||||
{
|
||||
Kd_IJV.push_back(Triplet<Scalar>(Rs,Rd,v));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(Rd,Rs,-v));
|
||||
}else if(Rd == source)
|
||||
{
|
||||
Kd_IJV.push_back(Triplet<Scalar>(Rd,Rs,v));
|
||||
}else if(Rs == dest)
|
||||
{
|
||||
Kd_IJV.push_back(Triplet<Scalar>(Rs,Rd,-v));
|
||||
}
|
||||
}
|
||||
Kd_IJV.push_back(Triplet<Scalar>(source,source,v));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(dest,dest,-v));
|
||||
}
|
||||
}
|
||||
Kd.setFromTriplets(Kd_IJV.begin(),Kd_IJV.end());
|
||||
Kd.makeCompressed();
|
||||
}
|
||||
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void igl::arap_linear_block_elements(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
MatK & Kd)
|
||||
{
|
||||
typedef typename MatK::Scalar Scalar;
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// simplex size (3: triangles, 4: tetrahedra)
|
||||
int simplex_size = F.cols();
|
||||
// Number of elements
|
||||
int m = F.rows();
|
||||
// Temporary output
|
||||
Kd.resize(V.rows(), F.rows());
|
||||
vector<Triplet<Scalar> > Kd_IJV;
|
||||
Matrix<int,Dynamic,2> edges;
|
||||
if(simplex_size == 3)
|
||||
{
|
||||
// triangles
|
||||
Kd.reserve(7*V.rows());
|
||||
Kd_IJV.reserve(7*V.rows());
|
||||
edges.resize(3,2);
|
||||
edges <<
|
||||
1,2,
|
||||
2,0,
|
||||
0,1;
|
||||
}else if(simplex_size == 4)
|
||||
{
|
||||
// tets
|
||||
Kd.reserve(17*V.rows());
|
||||
Kd_IJV.reserve(17*V.rows());
|
||||
edges.resize(6,2);
|
||||
edges <<
|
||||
1,2,
|
||||
2,0,
|
||||
0,1,
|
||||
3,0,
|
||||
3,1,
|
||||
3,2;
|
||||
}
|
||||
// gather cotangent weights
|
||||
Matrix<Scalar,Dynamic,Dynamic> C;
|
||||
cotmatrix_entries(V,F,C);
|
||||
// should have weights for each edge
|
||||
assert(C.cols() == edges.rows());
|
||||
// loop over elements
|
||||
for(int i = 0;i<m;i++)
|
||||
{
|
||||
// loop over edges of element
|
||||
for(int e = 0;e<edges.rows();e++)
|
||||
{
|
||||
int source = F(i,edges(e,0));
|
||||
int dest = F(i,edges(e,1));
|
||||
double v = C(i,e)*(V(source,d)-V(dest,d));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(source,i,v));
|
||||
Kd_IJV.push_back(Triplet<Scalar>(dest,i,-v));
|
||||
}
|
||||
}
|
||||
Kd.setFromTriplets(Kd_IJV.begin(),Kd_IJV.end());
|
||||
Kd.makeCompressed();
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::arap_linear_block<Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >, Eigen::SparseMatrix<double, 0, int> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, int, igl::ARAPEnergyType, Eigen::SparseMatrix<double, 0, int>&);
|
||||
template void igl::arap_linear_block<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::SparseMatrix<double, 0, int> >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, int, igl::ARAPEnergyType, Eigen::SparseMatrix<double, 0, int>&);
|
||||
#endif
|
||||
@ -1,78 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ARAP_LINEAR_BLOCK_H
|
||||
#define IGL_ARAP_LINEAR_BLOCK_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <Eigen/Sparse>
|
||||
#include <igl/ARAPEnergyType.h>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// ARAP_LINEAR_BLOCK constructs a block of the matrix which constructs the
|
||||
// linear terms of a given arap energy. When treating rotations as knowns
|
||||
// (arranged in a column) then this constructs Kd of K such that the linear
|
||||
// portion of the energy is as a column:
|
||||
// K * R = [Kx Z ... Ky Z ...
|
||||
// Z Kx ... Z Ky ...
|
||||
// ... ]
|
||||
// These blocks are also used to build the "covariance scatter matrices".
|
||||
// Here we want to build a scatter matrix that multiplies against positions
|
||||
// (treated as known) producing covariance matrices to fit each rotation.
|
||||
// Notice that in the case of the RHS of the poisson solve the rotations are
|
||||
// known and the positions unknown, and vice versa for rotation fitting.
|
||||
// These linear block just relate the rotations to the positions, linearly in
|
||||
// each.
|
||||
//
|
||||
// Templates:
|
||||
// MatV vertex position matrix, e.g. Eigen::MatrixXd
|
||||
// MatF face index matrix, e.g. Eigen::MatrixXd
|
||||
// Scalar e.g. double
|
||||
// Inputs:
|
||||
// V #V by dim list of initial domain positions
|
||||
// F #F by #simplex size list of triangle indices into V
|
||||
// d coordinate of linear constructor to build
|
||||
// energy ARAPEnergyType enum value defining which energy is being used.
|
||||
// See ARAPEnergyType.h for valid options and explanations.
|
||||
// Outputs:
|
||||
// Kd #V by #V/#F block of the linear constructor matrix corresponding to
|
||||
// coordinate d
|
||||
//
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void arap_linear_block(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
const igl::ARAPEnergyType energy,
|
||||
MatK & Kd);
|
||||
// Helper functions for each energy type
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void arap_linear_block_spokes(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
MatK & Kd);
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void arap_linear_block_spokes_and_rims(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
MatK & Kd);
|
||||
template <typename MatV, typename MatF, typename MatK>
|
||||
IGL_INLINE void arap_linear_block_elements(
|
||||
const MatV & V,
|
||||
const MatF & F,
|
||||
const int d,
|
||||
MatK & Kd);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "arap_linear_block.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,95 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "arap_rhs.h"
|
||||
#include "arap_linear_block.h"
|
||||
#include "verbose.h"
|
||||
#include "repdiag.h"
|
||||
#include "cat.h"
|
||||
#include <iostream>
|
||||
|
||||
template<typename DerivedV, typename DerivedF, typename DerivedK>
|
||||
IGL_INLINE void igl::arap_rhs(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const int dim,
|
||||
const igl::ARAPEnergyType energy,
|
||||
Eigen::SparseCompressedBase<DerivedK>& K)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// Number of dimensions
|
||||
int Vdim = V.cols();
|
||||
//// Number of mesh vertices
|
||||
//int n = V.rows();
|
||||
//// Number of mesh elements
|
||||
//int m = F.rows();
|
||||
//// number of rotations
|
||||
//int nr;
|
||||
switch(energy)
|
||||
{
|
||||
case ARAP_ENERGY_TYPE_SPOKES:
|
||||
//nr = n;
|
||||
break;
|
||||
case ARAP_ENERGY_TYPE_SPOKES_AND_RIMS:
|
||||
//nr = n;
|
||||
break;
|
||||
case ARAP_ENERGY_TYPE_ELEMENTS:
|
||||
//nr = m;
|
||||
break;
|
||||
default:
|
||||
fprintf(
|
||||
stderr,
|
||||
"arap_rhs.h: Error: Unsupported arap energy %d\n",
|
||||
energy);
|
||||
return;
|
||||
}
|
||||
|
||||
DerivedK KX,KY,KZ;
|
||||
arap_linear_block(V,F,0,energy,KX);
|
||||
arap_linear_block(V,F,1,energy,KY);
|
||||
if(Vdim == 2)
|
||||
{
|
||||
K = cat(2,repdiag(KX,dim),repdiag(KY,dim));
|
||||
}else if(Vdim == 3)
|
||||
{
|
||||
arap_linear_block(V,F,2,energy,KZ);
|
||||
if(dim == 3)
|
||||
{
|
||||
K = cat(2,cat(2,repdiag(KX,dim),repdiag(KY,dim)),repdiag(KZ,dim));
|
||||
}else if(dim ==2)
|
||||
{
|
||||
DerivedK ZZ(KX.rows()*2,KX.cols());
|
||||
K = cat(2,cat(2,
|
||||
cat(2,repdiag(KX,dim),ZZ),
|
||||
cat(2,repdiag(KY,dim),ZZ)),
|
||||
cat(2,repdiag(KZ,dim),ZZ));
|
||||
}else
|
||||
{
|
||||
assert(false);
|
||||
fprintf(
|
||||
stderr,
|
||||
"arap_rhs.h: Error: Unsupported dimension %d\n",
|
||||
dim);
|
||||
}
|
||||
}else
|
||||
{
|
||||
assert(false);
|
||||
fprintf(
|
||||
stderr,
|
||||
"arap_rhs.h: Error: Unsupported dimension %d\n",
|
||||
Vdim);
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
template void igl::arap_rhs(const Eigen::MatrixBase<Eigen::MatrixXd> & V, const Eigen::MatrixBase<Eigen::MatrixXi> & F,const int dim, const igl::ARAPEnergyType energy,Eigen::SparseCompressedBase<Eigen::SparseMatrix<double>>& K);
|
||||
#endif
|
||||
43
src/external/libigl-2.3.0/include/igl/arap_rhs.h
vendored
43
src/external/libigl-2.3.0/include/igl/arap_rhs.h
vendored
@ -1,43 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_ARAP_RHS_H
|
||||
#define IGL_ARAP_RHS_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
#include <igl/ARAPEnergyType.h>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// ARAP_RHS build right-hand side constructor of global poisson solve for
|
||||
// various Arap energies
|
||||
// Inputs:
|
||||
// V #V by Vdim list of initial domain positions
|
||||
// F #F by 3 list of triangle indices into V
|
||||
// dim dimension being used at solve time. For deformation usually dim =
|
||||
// V.cols(), for surface parameterization V.cols() = 3 and dim = 2
|
||||
// energy igl::ARAPEnergyType enum value defining which energy is being
|
||||
// used. See igl::ARAPEnergyType.h for valid options and explanations.
|
||||
// Outputs:
|
||||
// K #V*dim by #(F|V)*dim*dim matrix such that:
|
||||
// b = K * reshape(permute(R,[3 1 2]),size(V|F,1)*size(V,2)*size(V,2),1);
|
||||
//
|
||||
// See also: arap_linear_block
|
||||
template<typename DerivedV, typename DerivedF, typename DerivedK>
|
||||
IGL_INLINE void arap_rhs(
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const int dim,
|
||||
const igl::ARAPEnergyType energy,
|
||||
Eigen::SparseCompressedBase<DerivedK>& K);
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
#include "arap_rhs.cpp"
|
||||
#endif
|
||||
#endif
|
||||
@ -1,68 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2020 Oded Stein <oded.stein@columbia.edu>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "average_from_edges_onto_vertices.h"
|
||||
|
||||
template<typename DerivedF,typename DerivedE,typename DerivedoE,
|
||||
typename DeriveduE,typename DeriveduV>
|
||||
IGL_INLINE void
|
||||
igl::average_from_edges_onto_vertices(
|
||||
const Eigen::MatrixBase<DerivedF> &F,
|
||||
const Eigen::MatrixBase<DerivedE> &E,
|
||||
const Eigen::MatrixBase<DerivedoE> &oE,
|
||||
const Eigen::MatrixBase<DeriveduE> &uE,
|
||||
Eigen::PlainObjectBase<DeriveduV> &uV)
|
||||
{
|
||||
using Scalar = typename DeriveduE::Scalar;
|
||||
using VecX = Eigen::Matrix<Scalar, Eigen::Dynamic, 1>;
|
||||
using Int = typename DerivedF::Scalar;
|
||||
|
||||
assert(E.rows()==F.rows() && "E does not match dimensions of F.");
|
||||
assert(oE.rows()==F.rows() && "oE does not match dimensions of F.");
|
||||
assert(E.cols()==3 && F.cols()==3 && oE.cols()==3 &&
|
||||
"This method is for triangle meshes.");
|
||||
|
||||
const Int n = F.maxCoeff()+1;
|
||||
|
||||
VecX edgesPerVertex(n);
|
||||
edgesPerVertex.setZero();
|
||||
uV.resize(n,1);
|
||||
uV.setZero();
|
||||
|
||||
for(Eigen::Index i=0; i<F.rows(); ++i) {
|
||||
for(int j=0; j<3; ++j) {
|
||||
if(oE(i,j)<0) {
|
||||
continue;
|
||||
}
|
||||
const Int e = E(i,j);
|
||||
const Int vi=F(i,(j+1)%3), vj=F(i,(j+2)%3);
|
||||
|
||||
//Count vertex valence
|
||||
++edgesPerVertex(vi);
|
||||
++edgesPerVertex(vj);
|
||||
|
||||
//Average uE value onto vertices
|
||||
uV(vi) += uE(e);
|
||||
uV(vj) += uE(e);
|
||||
}
|
||||
}
|
||||
|
||||
//Divide by valence
|
||||
for(Int i=0; i<n; ++i) {
|
||||
const Scalar valence = edgesPerVertex(i);
|
||||
if(valence>0) {
|
||||
uV(i) /= valence;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::average_from_edges_onto_vertices<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::PartialReduxExpr<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::internal::member_norm<double>, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::PartialReduxExpr<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::internal::member_norm<double>, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::average_from_edges_onto_vertices<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::average_from_edges_onto_vertices<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
#endif
|
||||
@ -1,39 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2020 Oded Stein <oded.stein@columbia.edu>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_AVERAGE_FROM_EDGES_ONTO_VERTICES_H
|
||||
#define IGL_AVERAGE_FROM_EDGES_ONTO_VERTICES_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
namespace igl
|
||||
{
|
||||
// Move a scalar field defined on edges to vertices by averaging
|
||||
//
|
||||
// Input:
|
||||
// F: triangle mesh connectivity
|
||||
// E, oE: mapping from halfedges to edges and orientation as generated by
|
||||
// orient_halfedges
|
||||
// uE: scalar field defined on edges, one per edge
|
||||
//
|
||||
// Output:
|
||||
// uV: scalar field defined on vertices
|
||||
template<typename DerivedF,typename DerivedE,typename DerivedoE,
|
||||
typename DeriveduE,typename DeriveduV>
|
||||
IGL_INLINE void average_from_edges_onto_vertices(
|
||||
const Eigen::MatrixBase<DerivedF> &F,
|
||||
const Eigen::MatrixBase<DerivedE> &E,
|
||||
const Eigen::MatrixBase<DerivedoE> &oE,
|
||||
const Eigen::MatrixBase<DeriveduE> &uE,
|
||||
Eigen::PlainObjectBase<DeriveduV> &uV);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "average_from_edges_onto_vertices.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@ -1,27 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "average_onto_faces.h"
|
||||
|
||||
template <typename DerivedF, typename DerivedS, typename DerivedSF>
|
||||
IGL_INLINE void igl::average_onto_faces(
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedS> & S,
|
||||
Eigen::PlainObjectBase<DerivedSF> & SF)
|
||||
{
|
||||
SF.setConstant(F.rows(),S.cols(),0);
|
||||
for (int i = 0; i <F.rows(); ++i)
|
||||
for (int j = 0; j<F.cols(); ++j)
|
||||
SF.row(i) += S.row(F(i,j));
|
||||
SF.array() /= F.cols();
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::average_onto_faces<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
#endif
|
||||
@ -1,34 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public License
|
||||
// v. 2.0. If a copy of the MPL was not distributed with this file, You can
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#ifndef IGL_AVERAGE_ONTO_FACES_H
|
||||
#define IGL_AVERAGE_ONTO_FACES_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
namespace igl
|
||||
{
|
||||
// average_onto_vertices
|
||||
// Move a scalar field defined on faces to vertices by averaging
|
||||
//
|
||||
// Input:
|
||||
// F #F by ss list of simples/faces
|
||||
// S #V by dim list of per-vertex values
|
||||
// Output:
|
||||
// SF #F by dim list of per-face values
|
||||
template <typename DerivedF, typename DerivedS, typename DerivedSF>
|
||||
IGL_INLINE void average_onto_faces(
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedS> & S,
|
||||
Eigen::PlainObjectBase<DerivedSF> & SF);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "average_onto_faces.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user