Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f6b4064274 | ||
|
|
16b8ab326c | ||
|
|
c27e57e85e | ||
|
|
67e99976f1 | ||
|
|
241187bbe3 | ||
|
|
36eb913385 | ||
|
|
de74c292ee | ||
|
|
da7a3eb70b | ||
|
|
33cea64ae8 | ||
|
|
bbfc88926e | ||
|
|
19bfe1a203 | ||
|
|
7e0e6a87e0 | ||
|
|
ab6bfb7e9f | ||
|
|
b407970ecd | ||
|
|
e33f534ffd | ||
|
|
10e04cbef5 | ||
|
|
aea868bd1f | ||
|
|
8d89982555 | ||
|
|
450935874f | ||
|
|
fbcb933c5b | ||
|
|
e38ee99766 | ||
|
|
b15bafaed2 | ||
|
|
bc657bc94b | ||
|
|
7677e66587 | ||
|
|
be2e69a35c | ||
|
|
05666a7e72 | ||
|
|
a7cf3ddc1f | ||
|
|
749b9c1c27 | ||
|
|
cefb0fa35f | ||
|
|
4959bc5f22 | ||
|
|
6ad790f846 | ||
|
|
832fdc2abb | ||
|
|
01a18ac2ed | ||
|
|
ccfe8b6843 | ||
|
|
86a4a8cb31 | ||
|
|
e2d80105ed | ||
|
|
21b9ce5eff | ||
|
|
43e043e0b6 | ||
|
|
72bad999b0 | ||
|
|
c9d0b35b6a | ||
|
|
60c375f84e | ||
|
|
2e04483a46 | ||
|
|
a1fc8f0cb4 | ||
|
|
1ab05f99e9 | ||
|
|
1d02b140d2 | ||
|
|
3b84f100b5 | ||
|
|
2842637d4c | ||
|
|
9230cc8b83 | ||
|
|
9478106d6a | ||
|
|
289148c069 | ||
|
|
deac455ab9 | ||
|
|
c1d4e3a728 | ||
|
|
42cbff3c64 | ||
|
|
16ce83c381 | ||
|
|
e3cfbc1541 | ||
|
|
daf7d0707c | ||
|
|
146a37b892 | ||
|
|
5a51832959 | ||
|
|
4c611d88f9 | ||
|
|
bb2d2188ef | ||
|
|
5e2d8ddebe | ||
|
|
8641870916 | ||
|
|
412f8c5def | ||
|
|
3c79ad18e7 | ||
|
|
07d68473d9 | ||
|
|
8b794aa9a6 | ||
|
|
c7c06e3735 | ||
|
|
f530a2a645 | ||
|
|
c85ee4ef79 | ||
|
|
9621a87edd | ||
|
|
eafa7266d4 | ||
|
|
a5590c6389 | ||
|
|
7a1e0435a8 | ||
|
|
c65e487996 | ||
|
|
843438eab9 | ||
|
|
4052eef33c | ||
|
|
c6a0e1cda5 | ||
|
|
cde3014e2c | ||
|
|
b2938a41d9 | ||
|
|
96bdfb64ba | ||
|
|
77eb3f88fd | ||
|
|
01729b533d | ||
|
|
52d6df75c8 | ||
|
|
4575cbd670 | ||
|
|
8b8a3f7def | ||
|
|
6992440c83 | ||
|
|
a022f3fcb8 | ||
|
|
7404dc98fa | ||
|
|
5065640657 | ||
|
|
63b5effada | ||
|
|
ae5af1be35 | ||
|
|
3a72136c4d | ||
|
|
b1058a4eb7 | ||
|
|
48ac6aa0b5 | ||
|
|
6b1870aea4 | ||
|
|
e7d4ec2599 | ||
|
|
f102334b7a | ||
|
|
0294540603 | ||
|
|
ad43734d8d | ||
|
|
b62b908d1d | ||
|
|
0920459a45 | ||
|
|
7895811be4 | ||
|
|
1deb471727 | ||
|
|
67257e8ed0 | ||
|
|
a87d62a78f | ||
|
|
a5cd601cb5 | ||
|
|
607148cf72 | ||
|
|
b9d547b2bd | ||
|
|
e8d0ffa43f | ||
|
|
44fc595bcb | ||
|
|
28d72d3b81 | ||
|
|
5ceedbff82 | ||
|
|
917158c851 | ||
|
|
652b4db6d3 | ||
|
|
2eef4a9b30 | ||
|
|
429745301a | ||
|
|
217b838df2 | ||
|
|
f186bed09c | ||
|
|
9f663dfdce | ||
|
|
72b6464f7e | ||
|
|
0751e904b0 | ||
|
|
f140e63649 | ||
|
|
418d48ead3 | ||
|
|
cec2f07c0b | ||
|
|
48c7fa98c1 | ||
|
|
70be34da08 | ||
|
|
b5875d5ea1 | ||
|
|
85b93826a2 | ||
|
|
0b1f0b2009 | ||
|
|
bce6685db0 | ||
|
|
8df183bc46 | ||
|
|
d5778fea4b | ||
|
|
d621a19859 | ||
|
|
e8d993dd73 | ||
|
|
7c66185d74 | ||
|
|
3934ce09d8 | ||
|
|
e699d257fe | ||
|
|
626aeba4bd | ||
|
|
987321eb1b | ||
|
|
86f5f170b3 | ||
|
|
8eac86c163 | ||
|
|
3c9cf28948 | ||
|
|
22b271aefc | ||
|
|
0295a6523f | ||
|
|
20d69977b1 | ||
|
|
2a2e5b74d5 | ||
|
|
b47c6b5472 | ||
|
|
485662856a | ||
|
|
a6e97d4df6 | ||
|
|
1a67e24a41 | ||
|
|
ac0f60903e | ||
|
|
1d12983ce2 | ||
|
|
724eda9174 | ||
|
|
e8305e944d | ||
|
|
90cad1cfda | ||
|
|
608fc010a5 | ||
|
|
b87a8b2743 | ||
|
|
bde427319f | ||
|
|
b2e4c75f9a | ||
|
|
15c84780f4 | ||
|
|
0caefd9dc8 | ||
|
|
b7d36697df | ||
|
|
fe382012fd | ||
|
|
6571c463e3 | ||
|
|
8a3c960eb9 | ||
|
|
0b6f488f28 | ||
|
|
e686604f4f | ||
|
|
32910f260e | ||
|
|
a5a501f3a7 | ||
|
|
173e77d755 | ||
|
|
7a56aaf0cc | ||
|
|
b1c29bcef5 | ||
|
|
d0ccc52e51 | ||
|
|
db6c89aa0a | ||
|
|
46c76ee772 | ||
|
|
fb63fbcdc7 | ||
|
|
9e5a72582e | ||
|
|
fc63f61f97 | ||
|
|
853240d83c | ||
|
|
c4a31599a5 | ||
|
|
47143c1f30 | ||
|
|
7d2a958ab3 | ||
|
|
b0c518a05f | ||
|
|
1225b8d5a9 | ||
|
|
230df4d30b | ||
|
|
f4eff4ea57 | ||
|
|
116d2bc1de | ||
|
|
de180a073f | ||
|
|
4190af313e | ||
|
|
70ec447489 | ||
|
|
1dce7f09b6 | ||
|
|
a3f240620a | ||
|
|
985ad5d623 | ||
|
|
6952f3f158 | ||
|
|
866a073a84 | ||
|
|
0eb685643b | ||
|
|
d696b54ba9 | ||
|
|
a5da5ca3dc | ||
|
|
b7db5a8ee0 | ||
|
|
1917b63220 | ||
|
|
9b9da70b8e | ||
|
|
d568485242 | ||
|
|
a1395f916a | ||
|
|
928045da6f | ||
|
|
8bebcf827e | ||
|
|
470f03dc41 | ||
|
|
ac8b269300 | ||
|
|
3dd8e3e0e6 | ||
|
|
67edc94c8a | ||
|
|
b580234968 | ||
|
|
80b95c0aad | ||
|
|
b7124f179f | ||
|
|
33510d9f1b | ||
|
|
1ca0e9bb3d | ||
|
|
fc7ecbb046 | ||
|
|
7cd05d594c | ||
|
|
475ddcd2e8 | ||
|
|
78a33cf870 | ||
|
|
7f7551af16 | ||
|
|
1c3c7c7b6f | ||
|
|
8338d9e6ee | ||
|
|
6f41773f47 | ||
|
|
64803e08c5 | ||
|
|
80a8e2df21 | ||
|
|
83553eb3bb | ||
|
|
c6e6f809da | ||
|
|
788f0bc2f2 | ||
|
|
1c6e530501 | ||
|
|
ce2eaf8fc9 | ||
|
|
3593e5ca8b | ||
|
|
894a51f132 | ||
|
|
ab730005e9 | ||
|
|
e032f31a92 | ||
|
|
7e976f3666 | ||
|
|
5864468596 | ||
|
|
44f93fa0d9 | ||
|
|
3c9ca8a0c1 | ||
|
|
b5a0619ae2 | ||
|
|
e5c78841a8 | ||
|
|
b94304fd75 | ||
|
|
49535abdad | ||
|
|
2c31834bab | ||
|
|
a103eb67fe | ||
|
|
840e762291 | ||
|
|
552da1fae0 | ||
|
|
9036259dc3 | ||
|
|
fbd4eb8457 | ||
|
|
918061f1dc | ||
|
|
3edbcc8662 | ||
|
|
ebdc43fd30 | ||
|
|
8692a04310 | ||
|
|
345f82245d | ||
|
|
688b137e8d | ||
|
|
f11eb36f47 | ||
|
|
f6af195656 | ||
|
|
c60f5f1297 | ||
|
|
ae257dd8a1 | ||
|
|
ab00135605 | ||
|
|
5fe542d003 | ||
|
|
5bee6c7f48 | ||
|
|
4180f4b778 | ||
|
|
4f6d98e504 | ||
|
|
beb304e729 | ||
|
|
07c44a392d | ||
|
|
c1de27fbf0 | ||
|
|
0e04d631b1 | ||
|
|
b97523348c | ||
|
|
7b7086162f | ||
|
|
d7cd36b42e | ||
|
|
9b5e48cfe6 | ||
|
|
fb55f764d7 | ||
|
|
a826bc5f33 | ||
|
|
4ff99273aa | ||
|
|
0c563d4bf6 | ||
|
|
75d60e40a8 | ||
|
|
cf3b31ce47 | ||
|
|
0f40780d5d | ||
|
|
67ad5eb9e5 | ||
|
|
f838c51c03 | ||
|
|
87a59c5fcd | ||
|
|
bb187b5b84 | ||
|
|
a6b6fe2a90 | ||
|
|
8d5533a308 | ||
|
|
6b13d5a70b | ||
|
|
8b34137a90 | ||
|
|
0e6a09026f | ||
|
|
b3681c14bd | ||
|
|
6f08784072 | ||
|
|
ffdcbb5114 | ||
|
|
4f5ba3ccdb | ||
|
|
49a74590d4 | ||
|
|
65c2cd3af4 | ||
|
|
fd27d213d8 | ||
|
|
e452f5c8c3 | ||
|
|
bd524580e6 | ||
|
|
f12cecd9d6 | ||
|
|
758a353e99 | ||
|
|
bd3a7c6b9c | ||
|
|
be75695e02 | ||
|
|
c29460666a | ||
|
|
e930df68d1 | ||
|
|
7c214ce04a | ||
|
|
aa0faffe9f | ||
|
|
53c46c8041 | ||
|
|
5251bce154 | ||
|
|
ca3868ca65 | ||
|
|
0eb3fa2acb | ||
|
|
ee3d3a373d | ||
|
|
2e91bb3a00 | ||
|
|
7401f5b650 | ||
|
|
56e0642fbb | ||
|
|
aa40b908c9 | ||
|
|
167599e4d2 | ||
|
|
7f6f93c424 | ||
|
|
79a1d67a7f | ||
|
|
3e203ac69e | ||
|
|
6bead806ee | ||
|
|
ac7fb9913a | ||
|
|
71508b1b30 | ||
|
|
ef73edafd1 | ||
|
|
d49c892643 | ||
|
|
eb3953d901 | ||
|
|
b367156df7 | ||
|
|
b02f622c39 | ||
|
|
0eb5ddfa40 | ||
|
|
e6116bf9dd | ||
|
|
ed363da1f6 | ||
|
|
15bd0e0996 | ||
|
|
8235ccb3d0 | ||
|
|
61639328f9 | ||
|
|
8ca734ee17 | ||
|
|
1bfaa60e32 | ||
|
|
67c8d6a141 | ||
|
|
971d190108 | ||
|
|
b2e8d0b3d3 | ||
|
|
ae3df06258 | ||
|
|
75577c62d7 | ||
|
|
8895c712b6 | ||
|
|
7f852d8aee | ||
|
|
d3dd83f11b | ||
|
|
5977205363 | ||
|
|
954cd99196 | ||
|
|
883d0a5028 | ||
|
|
036fc21668 | ||
|
|
8035584024 | ||
|
|
72f08a45b8 | ||
|
|
a1e026fbe6 | ||
|
|
b672900456 | ||
|
|
e9fc2a82eb | ||
|
|
0c831a3fe9 | ||
|
|
956c94dfad | ||
|
|
8825f6f94a | ||
|
|
e4d513a0b7 | ||
|
|
5066b5d253 | ||
|
|
99bc7bddb6 | ||
|
|
14da3a4a9a | ||
|
|
ee2599de1a | ||
|
|
ba47646bc5 | ||
|
|
8ce9abcfc6 | ||
|
|
0bfa95b9d9 | ||
|
|
10200efa2b | ||
|
|
af18599ef7 | ||
|
|
c722b46cbd | ||
|
|
2921ffaff6 | ||
|
|
76370d4525 | ||
|
|
0787113a1b | ||
|
|
3f7895d172 | ||
|
|
ef78023af4 | ||
|
|
242a4485af | ||
|
|
4ffc570482 | ||
|
|
4d66545557 | ||
|
|
628375d4d2 | ||
|
|
340521757c | ||
|
|
76b8ca17d8 | ||
|
|
1ef33b03a2 | ||
|
|
0d1d133330 | ||
|
|
1fe4eb190f | ||
|
|
65aa93e9ef | ||
|
|
7cb42ce972 | ||
|
|
c0c396c237 | ||
|
|
7dc2b11c2a | ||
|
|
3f442b54f3 | ||
|
|
96c8ea4931 | ||
|
|
928cbe67bb | ||
|
|
9a149ece72 | ||
|
|
76ae819489 | ||
|
|
66ec792368 | ||
|
|
2726464472 | ||
|
|
31d419e2c0 | ||
|
|
9e10c1b534 | ||
|
|
4e739bc528 | ||
|
|
d3510ceeba | ||
|
|
41b4a5e62e | ||
|
|
2de5e29fc9 | ||
|
|
93cba2e044 | ||
|
|
a38371d231 | ||
|
|
5e20808faa | ||
|
|
714658b8d7 | ||
|
|
414740aa38 | ||
|
|
0cdc451a80 | ||
|
|
56eee0e3a4 | ||
|
|
5b534bff4c | ||
|
|
12b904a5b8 | ||
|
|
bcddf01d77 | ||
|
|
b0eb3db0aa | ||
|
|
409aee509d | ||
|
|
0c2b5cec70 | ||
|
|
075e95bfd2 | ||
|
|
3e35dc3a76 | ||
|
|
7b6ebdc3ea | ||
|
|
c192e28084 | ||
|
|
59251ca327 | ||
|
|
2a47253152 | ||
|
|
ef42f203ad | ||
|
|
e0849c88da | ||
|
|
c415f21858 | ||
|
|
4125afe80f | ||
|
|
f16ee6d7c5 | ||
|
|
8847026227 | ||
|
|
a6423836aa | ||
|
|
03653319d1 | ||
|
|
f12ffbd24e | ||
|
|
28801efb8b | ||
|
|
4db3a4c521 | ||
|
|
85ffda7ef4 | ||
|
|
2e66247d99 | ||
|
|
5f428b210e | ||
|
|
7aed747cd7 | ||
|
|
3ef2e16408 | ||
|
|
45acb3a583 | ||
|
|
42883bb57a | ||
|
|
c7c906c204 | ||
|
|
dd44506bcc | ||
|
|
4f83e01386 | ||
|
|
e2a7dc74dd | ||
|
|
8c5e9bd9bd | ||
|
|
855f60f9f6 | ||
|
|
bb730dec7d | ||
|
|
cec9df42aa | ||
|
|
2b666475ec | ||
|
|
fd8ee231b1 | ||
|
|
66696c2222 | ||
|
|
c47b26d73a | ||
|
|
db2419a6e3 | ||
|
|
2ceac853c3 | ||
|
|
f6c1f0bea1 | ||
|
|
1a42b39c93 | ||
|
|
a54d558f82 | ||
|
|
ef81faeac2 | ||
|
|
7117af68b5 | ||
|
|
5b13a5c490 | ||
|
|
c314bf9182 | ||
|
|
58f16f00e7 | ||
|
|
621f31e10e | ||
|
|
209b81e56c | ||
|
|
92f2e20fa5 | ||
|
|
9cdf351f6b | ||
|
|
7fba338427 | ||
|
|
eb6ffec8d5 | ||
|
|
edf08926c5 | ||
|
|
b3fce1689c | ||
|
|
de3749fc55 | ||
|
|
a9c3b6d50a | ||
|
|
18a1eaf38c | ||
|
|
075f884f5f | ||
|
|
28f59dfe2f | ||
|
|
2256dd7264 | ||
|
|
eaa2d52f4e | ||
|
|
418d98b02e | ||
|
|
e8ca66fb7c | ||
|
|
90ed035285 | ||
|
|
7f305a8532 | ||
|
|
87d401b82b | ||
|
|
dc1d3bb46c | ||
|
|
da3bd928dd | ||
|
|
86128972f6 | ||
|
|
dfbc3ee1c1 | ||
|
|
576529d8d9 | ||
|
|
792c814200 | ||
|
|
4a3ce8d896 | ||
|
|
dde2f93dd7 | ||
|
|
83db1d2f19 | ||
|
|
94dac679eb | ||
|
|
e2e4926241 | ||
|
|
8571d5f3a2 | ||
|
|
7c249cb5e2 |
+25
-27
@@ -1,41 +1,39 @@
|
||||
version: 1.0.{build}
|
||||
os: Visual Studio 2017
|
||||
test: off
|
||||
platform: x64
|
||||
clone_folder: C:\projects\libigl
|
||||
shallow_clone: true
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- alecjacobson
|
||||
- cmake
|
||||
- cgal
|
||||
- dev
|
||||
environment:
|
||||
BOOST_ROOT: C:/Libraries/boost_1_65_1
|
||||
matrix:
|
||||
- CONFIG: Debug
|
||||
BOOST_ROOT: C:/Libraries/boost_1_65_1
|
||||
PYTHON: 37
|
||||
- CONFIG: Release
|
||||
BOOST_ROOT: C:/Libraries/boost_1_65_1
|
||||
PYTHON: 37
|
||||
install:
|
||||
- git submodule update --init --recursive
|
||||
- cinstall: python
|
||||
build:
|
||||
parallel: true
|
||||
build_script:
|
||||
- cd c:\projects\libigl
|
||||
# External libraries (boost)
|
||||
# - cd external
|
||||
# - mkdir build
|
||||
# - cd build
|
||||
# - cmake -G "Visual Studio 15 2017 Win64" -T "host=x64" ..
|
||||
# - msbuild %MSBuildOptions% libigl_external.sln
|
||||
# - cd ../..
|
||||
# Python bindings
|
||||
# - cd python
|
||||
# - mkdir build
|
||||
# - cd build
|
||||
# - cmake -DLIBIGL_WITH_EMBREE=OFF -DLIBIGL_USE_STATIC_LIBRARY=ON ../
|
||||
# - msbuild %MSBuildOptions% pyigl.sln
|
||||
# - cd ../tutorial
|
||||
# - ${PYTHON} 101_FileIO.py
|
||||
# - cd ../../
|
||||
# Tutorials
|
||||
- cd tutorial
|
||||
# Tutorials and tests
|
||||
- set PATH=C:\Python%PYTHON%-x64;C:\Python%PYTHON%-x64\Scripts;%PATH%
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DLIBIGL_USE_STATIC_LIBRARY=ON -G "Visual Studio 15 2017 Win64" ../
|
||||
- cmake -DCMAKE_BUILD_TYPE=%CONFIG%
|
||||
-DLIBIGL_WITH_CGAL=ON
|
||||
-DLIBIGL_WITH_COMISO=OFF
|
||||
-G "Visual Studio 15 2017 Win64"
|
||||
../
|
||||
- set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
|
||||
- set MSBuildOptions=/v:m /p:Configuration=Debug /logger:%MSBuildLogger%
|
||||
- msbuild %MSBuildOptions% libigl_tutorials.sln
|
||||
- set MSBuildOptions=/v:m /m /p:BuildInParallel=true /p:Configuration=%CONFIG% /logger:%MSBuildLogger%
|
||||
- msbuild %MSBuildOptions% libigl.sln
|
||||
|
||||
test_script:
|
||||
- set CTEST_OUTPUT_ON_FAILURE=1
|
||||
- ctest -C %CONFIG% --verbose --output-on-failure -j 2
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#### Describe your issue
|
||||
|
||||
...
|
||||
|
||||
#### Check all that apply (change to `[x]`)
|
||||
- [ ] Windows
|
||||
- [ ] Mac OS X
|
||||
- [ ] Linux
|
||||
- [ ] I have tried the `dev` branch and the problem persists
|
||||
|
||||
See https://libigl.github.io/CONTRIBUTING/#bugreport for more tips.
|
||||
@@ -0,0 +1,8 @@
|
||||
[Describe your changes and what you've already done to test it.]
|
||||
|
||||
#### 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.
|
||||
- [ ] Adds corresponding python binding.
|
||||
- [ ] This is a minor change.
|
||||
+76
-87
@@ -1,110 +1,99 @@
|
||||
# use glob syntax.
|
||||
syntax: glob
|
||||
scripts/change_name.sh
|
||||
*.a
|
||||
*.dylib
|
||||
*.egg-info/
|
||||
*.exe
|
||||
*.ilk
|
||||
*.log
|
||||
*.o
|
||||
*.opensdf
|
||||
*.orig
|
||||
*.pdb
|
||||
*.psess
|
||||
*.pyc
|
||||
*.sdf
|
||||
*.so
|
||||
*.so.[0123456789]
|
||||
*.so.[0123456789].[0123456789]
|
||||
*.o
|
||||
*.a
|
||||
*.dylib
|
||||
*~
|
||||
*CMakeFiles*
|
||||
example
|
||||
examples/bbw/bbw_demo_selfcontained/*
|
||||
examples/bbw/bbw_demo_selfcontained.zip
|
||||
examples/quicklook-mesh/Mesh.qlgenerator/*
|
||||
examples/*/*.mexmaci64
|
||||
examples/*/*.rbr
|
||||
example_static
|
||||
example_header_only
|
||||
example1
|
||||
external/yimg/.git*
|
||||
external/tinyxml2/CMakeFiles*
|
||||
external/tinyxml2/CMakeCache.txt
|
||||
external/tinyxml2/cmake_install.cmake
|
||||
external/tinyxml2/Makefile
|
||||
external/embree/build/*
|
||||
external/embree/bin/*
|
||||
external/embree/bin
|
||||
external/embree/doc/html/*
|
||||
external/embree/doc/latex/*
|
||||
external/gmp
|
||||
external/mpfr
|
||||
external/boost
|
||||
external/.cache
|
||||
external/build
|
||||
.DS_Store
|
||||
libigl.zip
|
||||
*tags
|
||||
*.exe
|
||||
*.pdb
|
||||
*.sdf
|
||||
*.suo
|
||||
*.ilk
|
||||
*.log
|
||||
*.swo
|
||||
*.swp
|
||||
*.tlog
|
||||
Debug/
|
||||
Release/
|
||||
*.orig
|
||||
*.user
|
||||
*.vsp
|
||||
*.opensdf
|
||||
*.psess
|
||||
*.swp
|
||||
*.swo
|
||||
documentation/*.aux
|
||||
documentation/*.out
|
||||
documentation/*.log
|
||||
*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
|
||||
external/medit/rebar.rbr
|
||||
examples/bbw/bbw_demo_selfcontained.zip
|
||||
examples/bbw/bbw_demo_selfcontained/*
|
||||
examples/bbw/examples/*-volume.dmat
|
||||
examples/bbw/examples/*-volume.mesh
|
||||
examples/upright/upright
|
||||
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
|
||||
README.html
|
||||
tutorial/readme.html
|
||||
tutorial/*/build/*
|
||||
tutorial/*/Makefile
|
||||
external/glew/build
|
||||
external/glfw/build
|
||||
*buildXcode*
|
||||
tutorial/build*
|
||||
tutorial/*/*.mexmaci64
|
||||
external/libpng/build
|
||||
external/tinyxml2/build
|
||||
optional/build
|
||||
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
|
||||
python/py_igl/todo
|
||||
python/build
|
||||
python/.idea
|
||||
untitled
|
||||
Untitled.ipynb
|
||||
python/.ipynb_checkpoints
|
||||
python/py_igl/todo
|
||||
python/__pycache__
|
||||
iglhelpers.pyc
|
||||
python/build2
|
||||
tests/build
|
||||
tests/bin
|
||||
python/build3
|
||||
*.pyc
|
||||
python/build4
|
||||
python/scripts/generated
|
||||
python/builddebug
|
||||
tutorial/.idea
|
||||
python/buildstatic
|
||||
tutorial/build
|
||||
tutorial/cmake-build-debug
|
||||
.vscode/
|
||||
.idea/
|
||||
site/
|
||||
*.egg-info/
|
||||
.vs/
|
||||
tutorial/data
|
||||
tutorial/readme.html
|
||||
untitled
|
||||
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
[submodule "external/embree"]
|
||||
path = external/embree
|
||||
url = https://github.com/embree/embree.git
|
||||
[submodule "external/cgal"]
|
||||
path = external/cgal
|
||||
url = https://github.com/CGAL/cgal.git
|
||||
[submodule "external/tetgen"]
|
||||
path = external/tetgen
|
||||
url = https://github.com/libigl/tetgen.git
|
||||
[submodule "external/triangle"]
|
||||
path = external/triangle
|
||||
url = https://github.com/libigl/triangle.git
|
||||
[submodule "external/tinyxml2"]
|
||||
path = external/tinyxml2
|
||||
url = https://github.com/leethomason/tinyxml2.git
|
||||
[submodule "external/CoMISo"]
|
||||
path = external/CoMISo
|
||||
url = https://github.com/libigl/CoMISo.git
|
||||
[submodule "external/cork"]
|
||||
path = external/cork
|
||||
url = https://github.com/libigl/cork.git
|
||||
[submodule "external/imgui"]
|
||||
path = external/imgui/imgui
|
||||
url = https://github.com/ocornut/imgui.git
|
||||
[submodule "external/glfw"]
|
||||
path = external/glfw
|
||||
url = https://github.com/glfw/glfw.git
|
||||
[submodule "external/eigen"]
|
||||
path = external/eigen
|
||||
url = https://github.com/eigenteam/eigen-git-mirror.git
|
||||
[submodule "external/pybind11"]
|
||||
path = external/pybind11
|
||||
url = https://github.com/pybind/pybind11
|
||||
+52
-47
@@ -2,72 +2,77 @@ dist: trusty
|
||||
sudo: true
|
||||
language: cpp
|
||||
cache: ccache
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- g++-7
|
||||
- gcc-7
|
||||
- libblas-dev
|
||||
- libboost-filesystem-dev
|
||||
- libboost-system-dev
|
||||
- libboost-thread-dev
|
||||
- libglu1-mesa-dev
|
||||
- liblapack-dev
|
||||
- libmpfr-dev
|
||||
- libpython3-dev
|
||||
- python3-setuptools
|
||||
- xorg-dev
|
||||
homebrew:
|
||||
packages:
|
||||
- ccache
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
compiler: gcc # 4.8.4 by default on Trusty
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libmpfr-dev
|
||||
- libboost-filesystem-dev
|
||||
- libboost-system-dev
|
||||
- libboost-thread-dev
|
||||
- libblas-dev
|
||||
- liblapack-dev
|
||||
- xorg-dev
|
||||
- libglu1-mesa-dev
|
||||
- python3-setuptools
|
||||
- libpython3-dev
|
||||
env:
|
||||
- MATRIX_EVAL="export CONFIG=Debug && CHECK_UNDEFINED=ON && PYTHON=python3"
|
||||
- MATRIX_EVAL="export CONFIG=Release PYTHON=python3"
|
||||
- os: linux
|
||||
compiler: gcc-7
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- gcc-7
|
||||
- g++-7
|
||||
- libmpfr-dev
|
||||
- libboost-filesystem-dev
|
||||
- libboost-system-dev
|
||||
- libboost-thread-dev
|
||||
- libblas-dev
|
||||
- liblapack-dev
|
||||
- xorg-dev
|
||||
- libglu1-mesa-dev
|
||||
- python3-setuptools
|
||||
- libpython3-dev
|
||||
env:
|
||||
- MATRIX_EVAL="export CC=gcc-7 && CXX=g++-7 && CONFIG=Debug && CHECK_UNDEFINED=ON && PYTHON=python3"
|
||||
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3"
|
||||
- os: linux # same config like above but with -DLIBIGL_USE_STATIC_LIBRARY=OFF to test static and header-only builds
|
||||
compiler: gcc-7
|
||||
env:
|
||||
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3 CMAKE_EXTRA='-DLIBIGL_USE_STATIC_LIBRARY=OFF'"
|
||||
- os: linux
|
||||
compiler: gcc-7
|
||||
env:
|
||||
- MATRIX_EVAL="export CC=gcc-7 CXX=g++-7 CONFIG=Release PYTHON=python3 CMAKE_EXTRA='-DLIBIGL_EIGEN_VERSION=3.3.7'"
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env:
|
||||
- MATRIX_EVAL="export CONFIG=Debug && CHECK_UNDEFINED=ON && PYTHON=python3"
|
||||
- MATRIX_EVAL="export CONFIG=Debug PYTHON=python3 LIBIGL_NUM_THREADS=1"
|
||||
- os: osx # same config like above but with -DLIBIGL_USE_STATIC_LIBRARY=OFF to test static and header-only builds
|
||||
compiler: clang
|
||||
env:
|
||||
- MATRIX_EVAL="export CONFIG=Debug PYTHON=python3 LIBIGL_NUM_THREADS=1 CMAKE_EXTRA='-DLIBIGL_USE_STATIC_LIBRARY=OFF'"
|
||||
- os: osx
|
||||
compiler: clang
|
||||
env:
|
||||
- MATRIX_EVAL="export CONFIG=Debug PYTHON=python3 LIBIGL_NUM_THREADS=1 CMAKE_EXTRA='-DLIBIGL_EIGEN_VERSION=3.3.7'""
|
||||
|
||||
install:
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install ccache; fi
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then export PATH="/usr/local/opt/ccache/libexec:$PATH"; fi
|
||||
- eval "${MATRIX_EVAL}"
|
||||
- ccache --max-size=5.0G
|
||||
- ccache -V && ccache --show-stats && ccache --zero-stats
|
||||
|
||||
script:
|
||||
# Python bindings
|
||||
- cd python
|
||||
- ${PYTHON} setup.py develop --user -- -DCMAKE_BUILD_TYPE=${CONFIG} -DLIBIGL_WITH_EMBREE=OFF -DLIBIGL_USE_STATIC_LIBRARY=ON -DCHECK_UNDEFINED=${CHECK_UNDEFINED}
|
||||
- cd tutorial
|
||||
- ${PYTHON} 101_FileIO.py
|
||||
- cd ../../
|
||||
- rm -rf python/build
|
||||
# Tutorials
|
||||
- cd tutorial
|
||||
# Tutorials and tests
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake -DCMAKE_BUILD_TYPE=$CONFIG -DLIBIGL_USE_STATIC_LIBRARY=ON ../
|
||||
- pushd build
|
||||
- cmake ${CMAKE_EXTRA}
|
||||
-DCMAKE_BUILD_TYPE=$CONFIG
|
||||
-DLIBIGL_CHECK_UNDEFINED=ON
|
||||
-DLIBIGL_WITH_CGAL=ON
|
||||
../
|
||||
- make -j 2
|
||||
- ctest --verbose
|
||||
- popd
|
||||
- pushd python/tutorial
|
||||
- ${PYTHON} 101_FileIO.py
|
||||
- popd
|
||||
- rm -rf build
|
||||
- ccache --show-stats
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
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, tutorials and python bindings
|
||||
option(LIBIGL_BUILD_TESTS "Build libigl unit test" ${LIBIGL_TOPLEVEL_PROJECT})
|
||||
option(LIBIGL_BUILD_TUTORIALS "Build libigl tutorial" ${LIBIGL_TOPLEVEL_PROJECT})
|
||||
option(LIBIGL_BUILD_PYTHON "Build libigl python bindings" ${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" ${LIBIGL_BUILD_PYTHON})
|
||||
### End
|
||||
|
||||
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_WITH_PYTHON)
|
||||
add_subdirectory(python)
|
||||
endif()
|
||||
@@ -1,268 +1,8 @@
|
||||
# libigl - A simple C++ geometry processing library
|
||||
[](https://travis-ci.org/libigl/libigl)
|
||||
[](https://ci.appveyor.com/project/danielepanozzo/libigl-6hjk1/branch/master)
|
||||

|
||||

|
||||
|
||||
<https://github.com/libigl/libigl/>
|
||||
Documentation, tutorial, and instructions at <https://libigl.github.io>.
|
||||
|
||||
> Get started with:
|
||||
>
|
||||
```bash
|
||||
git clone --recursive https://github.com/libigl/libigl.git
|
||||
```
|
||||
|
||||
libigl is a simple C++ geometry processing library. We have a wide
|
||||
functionality including construction of sparse discrete differential geometry
|
||||
operators and finite-elements matrices such as the cotangent Laplacian and
|
||||
diagonalized mass matrix, simple facet and edge-based topology data structures,
|
||||
mesh-viewing utilities for OpenGL and GLSL, and many core functions for matrix
|
||||
manipulation which make [Eigen](http://eigen.tuxfamily.org) feel a lot more
|
||||
like MATLAB.
|
||||
|
||||
It is **a header-only library**. You do not need to compile anything to use,
|
||||
just include igl headers (e.g. `#include <igl/cotmatrix.h>`) and run. Each
|
||||
header file contains a single function (e.g. `igl/cotmatrix.h` contains
|
||||
`igl::cotmatrix()`). Most are tailored to operate on a generic triangle mesh
|
||||
stored in an n-by-3 matrix of vertex positions `V` and an m-by-3 matrix of
|
||||
triangle indices `F`.
|
||||
|
||||
_Optionally_ the library may also be [pre-compiled](http://libigl.github.io/libigl/static-library/) into a statically
|
||||
linked library, for faster compile times with your projects. This only effects
|
||||
compile time (run-time performance and behavior is identical). If in doubt, use
|
||||
the header-only default mode: (i.e. just include the headers you want to use).
|
||||
|
||||
We use the [Eigen](http://eigen.tuxfamily.org) library heavily in our code. Our
|
||||
group prototypes a lot in MATLAB, and we have a useful [MATLAB to libigl+Eigen
|
||||
conversion table](matlab-to-eigen.html).
|
||||
|
||||
We regularly test compiling our library on Mac OS X with clang, Linux with gcc
|
||||
and Windows with Visual Studio 2015 Community Edition.
|
||||
|
||||
## Tutorial
|
||||
|
||||
As of version 1.0, libigl includes an introductory
|
||||
[tutorial](http://libigl.github.io/libigl/tutorial) that covers many functionalities.
|
||||
|
||||
## libigl Example Project
|
||||
|
||||
We provide a [blank project example](https://github.com/libigl/libigl-example-project) showing how to use libigl and cmake. Feel free and encouraged to copy or fork this project as a way of starting a new personal project using libigl.
|
||||
|
||||
## Coding Guidelines and Tips
|
||||
|
||||
libigl follows strict coding guidelines, please take a look [here](http://libigl.github.io/libigl/style-guidelines) before submitting your pull requests. We also have a set of [general coding tips](http://libigl.github.io/libigl/coding-guidelines) on how to code a geometry processing research project.
|
||||
|
||||
## Installation
|
||||
|
||||
Libigl is a **header-only** library. You do **not** need to build anything to
|
||||
install. Simply add `libigl/include` to your include path and include relevant
|
||||
headers. Here is a small "Hello, World" program:
|
||||
|
||||
```cpp
|
||||
#include <igl/cotmatrix.h>
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
#include <iostream>
|
||||
int main()
|
||||
{
|
||||
Eigen::MatrixXd V(4,2);
|
||||
V<<0,0,
|
||||
1,0,
|
||||
1,1,
|
||||
0,1;
|
||||
Eigen::MatrixXi F(2,3);
|
||||
F<<0,1,2,
|
||||
0,2,3;
|
||||
Eigen::SparseMatrix<double> L;
|
||||
igl::cotmatrix(V,F,L);
|
||||
std::cout<<"Hello, mesh: "<<std::endl<<L*V<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
If you save this in `hello.cpp`, then you could compile this with (assuming
|
||||
Eigen is installed in `/usr/local/include/eigen3`):
|
||||
|
||||
```bash
|
||||
g++ -std=c++11 -I/usr/local/include/eigen3 -I./libigl/include/ hello.cpp -o hello
|
||||
```
|
||||
|
||||
Running `./hello` would then produce
|
||||
|
||||
```
|
||||
Hello, mesh:
|
||||
0.5 0.5
|
||||
-0.5 0.5
|
||||
-0.5 -0.5
|
||||
0.5 -0.5
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
Dependencies are on a per-include basis and the majority of the functions in
|
||||
libigl depends only on the [Eigen](http://eigen.tuxfamily.org) library.
|
||||
|
||||
For more information see our [tutorial](http://libigl.github.io/libigl/tutorial).
|
||||
|
||||
### Optional Dependencies
|
||||
|
||||
Libigl compartmentalizes its **optional** dependences via its directory
|
||||
organization in the `include/` folder. All header files located _directly_ in
|
||||
the `include/igl/` folder have only stl and Eigen as dependencies. For example,
|
||||
all of the headers that depend on CGAL are located in `include/igl/copyleft/cgal`.
|
||||
For a full list of _optional_ dependencies check `optional/CMakeLists.txt`.
|
||||
|
||||
### GCC and the Optional CGAL Dependency
|
||||
The `include/igl/copyleft/cgal/*.h` headers depend on CGAL. It has come to
|
||||
our attention that CGAL does not work properly with GCC 4.8. To the best of
|
||||
our knowledge, GCC 4.7 and clang will work correctly.
|
||||
|
||||
### OpenMP and Windows
|
||||
Some of our functions will take advantage of OpenMP if available. However, it
|
||||
has come to our attention that Visual Studio + Eigen + OpenMP does not work
|
||||
properly. Since we use OpenMP only to improve performance, we recommend
|
||||
avoiding OpenMP on Windows or proceeding with caution.
|
||||
|
||||
## Download
|
||||
You can keep up to date by cloning a read-only copy of our GitHub
|
||||
[repository](https://github.com/libigl).
|
||||
|
||||
## Known Issues
|
||||
We rely heavily on Eigen. Nearly all inputs and outputs are Eigen matrices of
|
||||
some kind. However, we currently _only_ officially support Eigen's default
|
||||
column-major ordering. That means, we **do not** expect our code to work for
|
||||
matrices using the `Eigen::RowMajor` flag. If you can, change definitions like:
|
||||
|
||||
```cpp
|
||||
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor> A;
|
||||
```
|
||||
|
||||
to
|
||||
|
||||
```cpp
|
||||
Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::ColMajor> A;
|
||||
// or simply
|
||||
Eigen::Matrix<double, Eigen::Dynamic, 3> A;
|
||||
```
|
||||
|
||||
We hope to fix this, or at least identify which functions are safe (many of
|
||||
them probably work just fine). This requires setting up unit testing, which is
|
||||
a major _todo_ for our development.
|
||||
|
||||
## Git Submodules
|
||||
Libigl uses git submodules for its _optional_ dependencies,
|
||||
in particular, those needed by the OpenGL viewer to run the examples in the
|
||||
[tutorial](http://libigl.github.io/libigl/tutorial). Git submodules allow use to treat clones of
|
||||
other libraries as sub-directories within ours while separating our commits.
|
||||
Read the [documentation](http://git-scm.com/docs/git-submodule) for a detailed
|
||||
explanation, but essentially our libigl repo stores a hash for each of its
|
||||
subrepos containing which version to update to. When a change is introduced in
|
||||
a dependencies repo we can incorporate that change by pulling in our sub-repo
|
||||
and updating (i.e. committing) that change to the hash.
|
||||
|
||||
When pulling new changes to libigl it's also a good idea to update changes to
|
||||
subrepos:
|
||||
|
||||
```bash
|
||||
git pull
|
||||
git submodule update --recursive
|
||||
```
|
||||
|
||||
## Unit Testing
|
||||
|
||||
Libigl maintains [separate
|
||||
repository](https://github.com/libigl/libigl-unit-tests) for unit testing.
|
||||
|
||||
## How to Contribute
|
||||
|
||||
If you are interested in joining development, please fork the repository and
|
||||
submit a [pull request](https://help.github.com/articles/using-pull-requests/)
|
||||
with your changes. libigl follows strict coding guidelines, please take a look at our [style guidelines](http://libigl.github.io/libigl/style-guidelines) before submitting your pull requests.
|
||||
|
||||
## License
|
||||
libigl is primarily [MPL2](http://www.mozilla.org/MPL/2.0/) licensed
|
||||
([FAQ](http://www.mozilla.org/MPL/2.0/FAQ.html)). Some files contain
|
||||
third-party code under other licenses. We're currently in the processes of
|
||||
identifying these and marking appropriately.
|
||||
|
||||
## Attribution
|
||||
If you use libigl in your academic projects, please cite the papers we
|
||||
implement as appropriate. To cite the library in general, you could use this
|
||||
BibTeX entry:
|
||||
|
||||
```bibtex
|
||||
@misc{libigl,
|
||||
title = {{libigl}: A simple {C++} geometry processing library},
|
||||
author = {Alec Jacobson and Daniele Panozzo and others},
|
||||
note = {http://libigl.github.io/libigl/},
|
||||
year = {2017},
|
||||
}
|
||||
```
|
||||
|
||||
## Projects/Universities using libigl
|
||||
Libigl is used by many research groups around the world. In 2015, it won the
|
||||
Eurographics/ACM Symposium on Geometry Processing software award. Here are a
|
||||
few labs/companies/institutions using libigl:
|
||||
|
||||
- [Activision](http://www.activision.com)
|
||||
- [Adobe Research](http://www.adobe.com/technology/)
|
||||
- [Electronic Arts, Inc](http://www.ea.com)
|
||||
- [Epic Games](https://epicgames.com)
|
||||
- [Google Research](https://research.google.com)
|
||||
- [Industrial Light and Magic](http://ilm.com)
|
||||
- [Mesh consultants](http://meshconsultants.ca/), Canada
|
||||
- [Microsoft Research](https://www.microsoft.com/en-us/research/)
|
||||
- [Pixar](http://graphics.pixar.com/research/)
|
||||
- [Spine by Esoteric Software](http://esotericsoftware.com/) is an animation tool dedicated to 2D characters.
|
||||
- [vvvv toolkit](http://vvvv.org) a multipurpose tookit
|
||||
- Columbia University, [Columbia Computer Graphics Group](http://www.cs.columbia.edu/cg/), USA
|
||||
- [Cornell University](http://www.graphics.cornell.edu/), USA
|
||||
- [Czech Technical University in Prague](http://dcgi.felk.cvut.cz/), Czech
|
||||
- EPF Lausanne, [Computer Graphics and Geometry Laboratory](http://lgg.epfl.ch/people.php), Switzerland
|
||||
- ETH Zurich, [Interactive Geometry Lab](http://igl.ethz.ch/) and [Advanced Technologies Lab](http://ait.inf.ethz.ch/), Swizterland
|
||||
- George Mason University, [CraGL](http://cs.gmu.edu/~ygingold/), USA
|
||||
- [Hong Kong University of Science and Technology](http://www.ust.hk/), Hong Kong
|
||||
- [Inria, Université Grenoble Alpes](https://www.inria.fr/centre/grenoble/), France
|
||||
- [Jiangnan university](http://english.jiangnan.edu.cn), China
|
||||
- [National Institute of Informatics](http://www.nii.ac.jp/en/), Japan
|
||||
- New York University, [Media Research Lab](http://mrl.nyu.edu/), USA
|
||||
- NYUPoly, [Game Innovation Lab](http://game.engineering.nyu.edu/), USA
|
||||
- [TU Berlin](https://www.cg.tu-berlin.de), Germany
|
||||
- [TU Delft](http://www.tudelft.nl/en/), Netherlands
|
||||
- [TU Wien](https://www.tuwien.ac.at/en/tuwien_home/), Austria
|
||||
- [Telecom ParisTech](http://www.telecom-paristech.fr/en/formation-et-innovation-dans-le-numerique.html), Paris, France
|
||||
- [UBISOFT](https://www.ubisoft.com/en-us/), USA
|
||||
- [Utrecht University](http://www.staff.science.uu.nl/~vaxma001/), The Netherlands
|
||||
- [Universidade Federal de Santa Catarina](http://mtm.ufsc.br/~leo/), Brazil
|
||||
- [University College London](http://vecg.cs.ucl.ac.uk/), England
|
||||
- [University of California Berkeley](http://vis.berkeley.edu/), USA
|
||||
- [University of Cambridge](http://www.cam.ac.uk/), England
|
||||
- [University of Pennsylvania](http://cg.cis.upenn.edu/), USA
|
||||
- [University of Texas at Austin](http://www.cs.utexas.edu/users/evouga/), USA
|
||||
- [University of Toronto](http://dgp.toronto.edu), Canada
|
||||
- [University of Victoria](https://www.csc.uvic.ca/Research/graphics/), Canada
|
||||
- [University of Wisconsin-Eau Claire](http://www.uwec.edu/computer-science/), USA
|
||||
- [Università della Svizzera Italiana](http://www.usi.ch/en), Switzerland
|
||||
- [Université Toulouse III Paul Sabatier](http://www.univ-tlse3.fr/), France
|
||||
- [Zhejiang University](http://www.math.zju.edu.cn/cagd/), China
|
||||
|
||||
|
||||
## Contact
|
||||
|
||||
Libigl is a group endeavor led by [Alec
|
||||
Jacobson](http://www.cs.toronto.edu/~jacobson/) and [Daniele
|
||||
Panozzo](http://cs.nyu.edu/~panozzo/). Please [contact
|
||||
us](mailto:alecjacobson@gmail.com,daniele.panozzo@gmail.com) if you have
|
||||
questions or comments. For troubleshooting, please post an
|
||||
[issue](https://github.com/libigl/libigl/issues) on github.
|
||||
|
||||
If you're using libigl in your projects, quickly [drop us a
|
||||
note](mailto:alecjacobson@gmail.com,daniele.panozzo@gmail.com). Tell us who you
|
||||
are and what you're using it for. This helps us apply for funding and justify
|
||||
spending time maintaining this.
|
||||
|
||||
If you find bugs or have problems please use our [github issue tracking
|
||||
page](https://github.com/libigl/libigl/issues).
|
||||
|
||||
## Copyright
|
||||
2017 Alec Jacobson, Daniele Panozzo, Christian Schüller, Olga Diamanti, Qingnan Zhou, Sebastian Koch, Jeremie Dumas, Amir Vaxman, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De Giorgis, Luigi Rocca, Leonardo Sacht, Kevin Walliman, Olga Sorkine-Hornung, and others.
|
||||
|
||||
Please see individual files for appropriate copyright notices.
|
||||
:exclamation: **On October 15, 2018, a new, cleaned-up history was pushed onto the main libigl repository. To learn more about the consequences of this, and troubleshooting, please read [this page](https://libigl.github.io/rewritten-history/).**
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
# This file should contain the current version number of libigl
|
||||
# World.Major.Minor
|
||||
# Anyone may increment Minor to indicate a small change.
|
||||
# Major indicates a large change or large number of changes (upload to website)
|
||||
# World indicates a substantial change or release
|
||||
1.2.1
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,190 @@
|
||||
################################################################################
|
||||
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 1f9618cf9b7bd77370d817976470d59091928606
|
||||
)
|
||||
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.2.10 CACHE STRING "Default version of Eigen used by libigl.")
|
||||
function(igl_download_eigen)
|
||||
igl_download_project(eigen
|
||||
GIT_REPOSITORY https://github.com/eigenteam/eigen-git-mirror.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.5.2
|
||||
${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 3.3
|
||||
${LIBIGL_BRANCH_OPTIONS}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## ImGui
|
||||
function(igl_download_imgui)
|
||||
igl_download_project(imgui
|
||||
GIT_REPOSITORY https://github.com/ocornut/imgui.git
|
||||
GIT_TAG v1.69
|
||||
${LIBIGL_BRANCH_OPTIONS}
|
||||
)
|
||||
igl_download_project(libigl-imgui
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-imgui.git
|
||||
GIT_TAG 07ecd3858acc71e70f0f9b2dea20a139bdddf8ae
|
||||
)
|
||||
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 d284c4a843efac043c310f5fa640b17cf7d96170
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Catch2
|
||||
function(igl_download_catch2)
|
||||
igl_download_project(catch2
|
||||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
|
||||
GIT_TAG 03d122a35c3f5c398c43095a87bc82ed44642516
|
||||
)
|
||||
endfunction()
|
||||
|
||||
## Predicates
|
||||
function(igl_download_predicates)
|
||||
igl_download_project(predicates
|
||||
GIT_REPOSITORY https://github.com/libigl/libigl-predicates.git
|
||||
GIT_TAG 4c57c1d3f31646b010d1d58bfbe201e75c2b2ad8
|
||||
)
|
||||
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 adc66cabf712a0bd68ac182b4e7f8b5ba009c3dd
|
||||
)
|
||||
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 5c6a1ea809c043d71e5595775709c15325a7158c
|
||||
)
|
||||
endfunction()
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
if(MSVC)
|
||||
if("${MSVC_RUNTIME}" STREQUAL "")
|
||||
set(MSVC_RUNTIME "static")
|
||||
endif()
|
||||
if(${MSVC_RUNTIME} STREQUAL "static")
|
||||
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()
|
||||
endif()
|
||||
@@ -0,0 +1,31 @@
|
||||
@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)
|
||||
|
||||
@@ -11,48 +11,37 @@ if(APPLE)
|
||||
message(STATUS "Found libtool - ${CMAKE_LIBTOOL}")
|
||||
get_property(languages GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
foreach(lang ${languages})
|
||||
# Added -c
|
||||
# Added -c
|
||||
set(CMAKE_${lang}_CREATE_STATIC_LIBRARY
|
||||
"${CMAKE_LIBTOOL} -c -static -o <TARGET> <LINK_FLAGS> <OBJECTS> ")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
### Find packages to populate default options ###
|
||||
#
|
||||
# COMPONENTS should match subsequent calls
|
||||
find_package(Matlab COMPONENTS MEX_COMPILER MX_LIBRARY ENG_LIBRARY) # --> Matlab_FOUND
|
||||
find_package(MOSEK) # --> MOSEK_FOUND
|
||||
find_package(OpenGL) # --> OPENGL_FOUND
|
||||
|
||||
### Available options ###
|
||||
option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" ON)
|
||||
option(LIBIGL_WITH_ANTTWEAKBAR "Use AntTweakBar" OFF)
|
||||
option(LIBIGL_WITH_CGAL "Use CGAL" ON)
|
||||
option(LIBIGL_WITH_COMISO "Use CoMiso" ON)
|
||||
option(LIBIGL_WITH_CORK "Use Cork" OFF)
|
||||
option(LIBIGL_WITH_EMBREE "Use Embree" OFF)
|
||||
option(LIBIGL_WITH_LIM "Use LIM" ON)
|
||||
option(LIBIGL_WITH_MATLAB "Use Matlab" "${Matlab_FOUND}")
|
||||
option(LIBIGL_WITH_MOSEK "Use MOSEK" "${MOSEK_FOUND}")
|
||||
option(LIBIGL_WITH_OPENGL "Use OpenGL" "${OPENGL_FOUND}")
|
||||
option(LIBIGL_WITH_OPENGL_GLFW "Use GLFW" "${OPENGL_FOUND}")
|
||||
option(LIBIGL_WITH_OPENGL_GLFW_IMGUI "Use ImGui" OFF)
|
||||
option(LIBIGL_WITH_PNG "Use PNG" ON)
|
||||
option(LIBIGL_WITH_TETGEN "Use Tetgen" ON)
|
||||
option(LIBIGL_WITH_TRIANGLE "Use Triangle" ON)
|
||||
option(LIBIGL_WITH_VIEWER "Use OpenGL viewer" "${OPENGL_FOUND}")
|
||||
option(LIBIGL_WITH_XML "Use XML" ON)
|
||||
option(LIBIGL_WITH_PYTHON "Use Python" OFF)
|
||||
|
||||
if(LIBIGL_WITH_VIEWER AND (NOT LIBIGL_WITH_OPENGL_GLFW OR NOT LIBIGL_WITH_OPENGL) )
|
||||
message(FATAL_ERROR "LIBIGL_WITH_VIEWER=ON requires LIBIGL_WITH_OPENGL_GLFW=ON and LIBIGL_WITH_OPENGL=ON")
|
||||
endif()
|
||||
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_WITH_PYTHON "Use Python" OFF)
|
||||
option(LIBIGL_WITHOUT_COPYLEFT "Disable Copyleft libraries" OFF)
|
||||
option(LIBIGL_EXPORT_TARGETS "Export libigl CMake targets" OFF)
|
||||
|
||||
################################################################################
|
||||
|
||||
### Configuration
|
||||
set(LIBIGL_ROOT "${CMAKE_CURRENT_LIST_DIR}/../..")
|
||||
set(LIBIGL_ROOT "${CMAKE_CURRENT_LIST_DIR}/..")
|
||||
set(LIBIGL_SOURCE_DIR "${LIBIGL_ROOT}/include")
|
||||
set(LIBIGL_EXTERNAL "${LIBIGL_ROOT}/external")
|
||||
|
||||
@@ -63,12 +52,21 @@ else()
|
||||
set(IGL_SCOPE INTERFACE)
|
||||
endif()
|
||||
|
||||
# Download and update 3rdparty libraries
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
include(LibiglDownloadExternal)
|
||||
|
||||
################################################################################
|
||||
### IGL Common
|
||||
################################################################################
|
||||
|
||||
add_library(igl_common INTERFACE)
|
||||
target_include_directories(igl_common SYSTEM INTERFACE ${LIBIGL_SOURCE_DIR})
|
||||
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()
|
||||
@@ -81,19 +79,32 @@ target_compile_features(igl_common INTERFACE ${CXX11_FEATURES})
|
||||
if(MSVC)
|
||||
# Enable parallel compilation for Visual Studio
|
||||
target_compile_options(igl_common INTERFACE /MP /bigobj)
|
||||
target_compile_definitions(igl_common INTERFACE -DNOMINMAX)
|
||||
endif()
|
||||
|
||||
### Set compiler flags for building the tests on Windows with Visual Studio
|
||||
include(LibiglWindows)
|
||||
|
||||
if(BUILD_SHARED_LIBS)
|
||||
# Generate position independent code
|
||||
set_target_properties(igl_common PROPERTIES INTERFACE_POSITION_INDEPENDENT_CODE ON)
|
||||
endif()
|
||||
|
||||
if(UNIX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
endif()
|
||||
|
||||
# Eigen
|
||||
if(TARGET Eigen3::Eigen)
|
||||
# If an imported target already exists, use it
|
||||
target_link_libraries(igl_common INTERFACE Eigen3::Eigen)
|
||||
else()
|
||||
target_include_directories(igl_common SYSTEM INTERFACE ${LIBIGL_EXTERNAL}/eigen)
|
||||
igl_download_eigen()
|
||||
target_include_directories(igl_common SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${LIBIGL_EXTERNAL}/eigen>
|
||||
$<INSTALL_INTERFACE:include>
|
||||
)
|
||||
endif()
|
||||
|
||||
# C++11 Thread library
|
||||
@@ -102,20 +113,6 @@ target_link_libraries(igl_common INTERFACE ${CMAKE_THREAD_LIBS_INIT})
|
||||
|
||||
################################################################################
|
||||
|
||||
include(DownloadProject)
|
||||
|
||||
# Shortcut function
|
||||
function(igl_download_project name)
|
||||
download_project(
|
||||
PROJ ${name}
|
||||
SOURCE_DIR ${LIBIGL_EXTERNAL}/${name}
|
||||
DOWNLOAD_DIR ${LIBIGL_EXTERNAL}/.cache/${name}
|
||||
${ARGN}
|
||||
)
|
||||
endfunction()
|
||||
|
||||
################################################################################
|
||||
|
||||
## CGAL dependencies on Windows: GMP & MPFR
|
||||
function(igl_download_cgal_deps)
|
||||
if(WIN32)
|
||||
@@ -143,8 +140,12 @@ function(compile_igl_module module_dir)
|
||||
endif()
|
||||
if(LIBIGL_USE_STATIC_LIBRARY)
|
||||
file(GLOB SOURCES_IGL_${module_name}
|
||||
"${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.cpp"
|
||||
"${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.cpp")
|
||||
"${LIBIGL_SOURCE_DIR}/igl/${module_dir}/*.cpp")
|
||||
if(NOT LIBIGL_WITHOUT_COPYLEFT)
|
||||
file(GLOB COPYLEFT_SOURCES_IGL_${module_name}
|
||||
"${LIBIGL_SOURCE_DIR}/igl/copyleft/${module_dir}/*.cpp")
|
||||
list(APPEND SOURCES_IGL_${module_name} ${COPYLEFT_SOURCES_IGL_${module_name}})
|
||||
endif()
|
||||
add_library(${module_libname} STATIC ${SOURCES_IGL_${module_name}} ${ARGN})
|
||||
if(MSVC)
|
||||
target_compile_options(${module_libname} PRIVATE /w) # disable all warnings (not ideal but...)
|
||||
@@ -163,6 +164,8 @@ function(compile_igl_module module_dir)
|
||||
# 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()
|
||||
|
||||
################################################################################
|
||||
@@ -177,15 +180,9 @@ endif()
|
||||
compile_igl_module("core" ${SOURCES_IGL})
|
||||
|
||||
################################################################################
|
||||
## Compile the AntTweakBar part ###
|
||||
if(LIBIGL_WITH_ANTTWEAKBAR)
|
||||
set(ANTTWEAKBAR_DIR "${LIBIGL_EXTERNAL}/AntTweakBar")
|
||||
if(NOT TARGET AntTweakBar)
|
||||
add_subdirectory("${ANTTWEAKBAR_DIR}" AntTweakBar)
|
||||
endif()
|
||||
compile_igl_module("anttweakbar")
|
||||
target_link_libraries(igl_anttweakbar ${IGL_SCOPE} AntTweakBar)
|
||||
target_include_directories(igl_anttweakbar ${IGL_SCOPE} "${ANTTWEAKBAR_DIR}/include")
|
||||
### Download the python part ###
|
||||
if(LIBIGL_WITH_PYTHON)
|
||||
igl_download_pybind11()
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
@@ -196,11 +193,16 @@ if(LIBIGL_WITH_CGAL)
|
||||
# `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()
|
||||
if(EXISTS ${LIBIGL_EXTERNAL}/boost)
|
||||
set(BOOST_ROOT "${LIBIGL_EXTERNAL}/boost")
|
||||
endif()
|
||||
set(CGAL_Boost_USE_STATIC_LIBS ON CACHE BOOL "" FORCE)
|
||||
if(LIBIGL_WITH_PYTHON)
|
||||
option(CGAL_Boost_USE_STATIC_LIBS "Use static Boost libs with CGAL" OFF)
|
||||
else()
|
||||
option(CGAL_Boost_USE_STATIC_LIBS "Use static Boost libs with CGAL" ON)
|
||||
endif()
|
||||
find_package(CGAL CONFIG COMPONENTS Core PATHS ${CGAL_DIR} NO_DEFAULT_PATH)
|
||||
endif()
|
||||
|
||||
@@ -242,6 +244,7 @@ endfunction()
|
||||
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)
|
||||
@@ -254,6 +257,7 @@ if(LIBIGL_WITH_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")
|
||||
@@ -267,56 +271,33 @@ endif()
|
||||
if(LIBIGL_WITH_EMBREE)
|
||||
set(EMBREE_DIR "${LIBIGL_EXTERNAL}/embree")
|
||||
|
||||
set(EMBREE_TESTING_INTENSITY 0 CACHE STRING "" FORCE)
|
||||
set(EMBREE_ISPC_SUPPORT OFF CACHE BOOL " " FORCE)
|
||||
set(EMBREE_TASKING_SYSTEM "INTERNAL" CACHE BOOL " " FORCE)
|
||||
set(EMBREE_TUTORIALS OFF CACHE BOOL " " FORCE)
|
||||
set(EMBREE_MAX_ISA NONE CACHE STRINGS " " FORCE)
|
||||
set(BUILD_TESTING OFF CACHE BOOL " " FORCE)
|
||||
|
||||
# set(ENABLE_INSTALLER OFF CACHE BOOL " " FORCE)
|
||||
set(EMBREE_MAX_ISA "SSE2" CACHE STRING " " FORCE)
|
||||
set(EMBREE_STATIC_LIB ON CACHE BOOL " " FORCE)
|
||||
if(MSVC)
|
||||
# set(EMBREE_STATIC_RUNTIME OFF CACHE BOOL " " FORCE)
|
||||
set(EMBREE_STATIC_LIB OFF CACHE BOOL " " FORCE)
|
||||
else()
|
||||
set(EMBREE_STATIC_LIB ON CACHE BOOL " " FORCE)
|
||||
set(EMBREE_STATIC_RUNTIME ON CACHE BOOL " " FORCE)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET embree)
|
||||
# TODO: Should probably save/restore the CMAKE_CXX_FLAGS_*, since embree seems to be
|
||||
# overriding them on Windows. But well... it works for now.
|
||||
igl_download_embree()
|
||||
add_subdirectory("${EMBREE_DIR}" "embree")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_custom_target(Copy-Embree-DLL ALL # Adds a post-build event
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different # which executes "cmake - E
|
||||
$<TARGET_FILE:embree> # <--this is in-file
|
||||
"${CMAKE_BINARY_DIR}" # <--this is out-file path
|
||||
DEPENDS embree) # Execute after embree target has been built
|
||||
endif()
|
||||
|
||||
compile_igl_module("embree")
|
||||
target_link_libraries(igl_embree ${IGL_SCOPE} embree)
|
||||
target_include_directories(igl_embree ${IGL_SCOPE} ${EMBREE_DIR}/include)
|
||||
if(NOT MSVC)
|
||||
target_compile_definitions(igl_embree ${IGL_SCOPE} -DENABLE_STATIC_LIB)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
################################################################################
|
||||
### Compile the lim part ###
|
||||
if(LIBIGL_WITH_LIM)
|
||||
set(LIM_DIR "${LIBIGL_EXTERNAL}/lim")
|
||||
if(NOT TARGET lim)
|
||||
add_subdirectory("${LIM_DIR}" "lim")
|
||||
endif()
|
||||
compile_igl_module("lim")
|
||||
target_link_libraries(igl_lim ${IGL_SCOPE} lim)
|
||||
target_include_directories(igl_lim ${IGL_SCOPE} ${LIM_DIR})
|
||||
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)
|
||||
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})
|
||||
@@ -336,13 +317,23 @@ endif()
|
||||
### Compile the opengl part ###
|
||||
if(LIBIGL_WITH_OPENGL)
|
||||
# OpenGL module
|
||||
find_package(OpenGL REQUIRED)
|
||||
compile_igl_module("opengl")
|
||||
target_link_libraries(igl_opengl ${IGL_SCOPE} ${OPENGL_gl_LIBRARY})
|
||||
target_include_directories(igl_opengl SYSTEM ${IGL_SCOPE} ${OPENGL_INCLUDE_DIR})
|
||||
|
||||
# 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)
|
||||
@@ -359,6 +350,7 @@ if(LIBIGL_WITH_OPENGL_GLFW)
|
||||
set(GLFW_BUILD_TESTS OFF CACHE BOOL " " FORCE)
|
||||
set(GLFW_BUILD_DOCS OFF CACHE BOOL " " FORCE)
|
||||
set(GLFW_INSTALL OFF CACHE BOOL " " FORCE)
|
||||
igl_download_glfw()
|
||||
add_subdirectory(${LIBIGL_EXTERNAL}/glfw glfw)
|
||||
endif()
|
||||
target_link_libraries(igl_opengl_glfw ${IGL_SCOPE} igl_opengl glfw)
|
||||
@@ -372,7 +364,8 @@ if(LIBIGL_WITH_OPENGL_GLFW_IMGUI)
|
||||
# ImGui module
|
||||
compile_igl_module("opengl/glfw/imgui")
|
||||
if(NOT TARGET imgui)
|
||||
add_subdirectory(${LIBIGL_EXTERNAL}/imgui imgui)
|
||||
igl_download_imgui()
|
||||
add_subdirectory(${LIBIGL_EXTERNAL}/libigl-imgui imgui)
|
||||
endif()
|
||||
target_link_libraries(igl_opengl_glfw_imgui ${IGL_SCOPE} igl_opengl_glfw imgui)
|
||||
endif()
|
||||
@@ -384,9 +377,9 @@ 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)
|
||||
set(STB_IMAGE_DIR "${LIBIGL_EXTERNAL}/stb_image")
|
||||
if(NOT TARGET stb_image)
|
||||
add_subdirectory("${STB_IMAGE_DIR}" "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)
|
||||
@@ -398,6 +391,7 @@ endif()
|
||||
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")
|
||||
@@ -410,6 +404,7 @@ endif()
|
||||
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")
|
||||
@@ -417,12 +412,28 @@ if(LIBIGL_WITH_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"
|
||||
@@ -432,3 +443,87 @@ if(LIBIGL_WITH_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
|
||||
)
|
||||
|
||||
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)
|
||||
|
||||
# Install and export core library
|
||||
install(
|
||||
TARGETS
|
||||
igl
|
||||
igl_common
|
||||
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
|
||||
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)
|
||||
|
||||
@@ -1072,4 +1072,12 @@ template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::init<Eigen
|
||||
template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::init<Eigen::Matrix<int, -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&);
|
||||
template double igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<int, -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::Matrix<double, 1, 3, 1, 1, 3> const&, double, int&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&) const;
|
||||
template bool igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::intersect_ray<Eigen::Matrix<int, -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::Matrix<double, 1, 3, 1, 1, 3> const&, Eigen::Matrix<double, 1, 3, 1, 1, 3> const&, igl::Hit&) const;
|
||||
template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 2, 3, 0, 2, 3>, Eigen::Matrix<double, 2, 1, 0, 2, 1>, Eigen::Matrix<int, 2, 1, 0, 2, 1>, Eigen::Matrix<double, 2, 3, 0, 2, 3> >(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, 2, 3, 0, 2, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 1, 0, 2, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, 2, 1, 0, 2, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 3, 0, 2, 3> >&) const;
|
||||
template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<int, -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::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
|
||||
template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 2>::squared_distance<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<int, -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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
|
||||
template void igl::AABB<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 3>::squared_distance<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<int, -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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) const;
|
||||
#ifdef WIN32
|
||||
template void igl::AABB<class Eigen::Matrix<double,-1,-1,0,-1,-1>,2>::squared_distance<class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,1,0,-1,1>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<double,-1,3,0,-1,3> >(class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > &)const;
|
||||
template void igl::AABB<class Eigen::Matrix<double,-1,-1,0,-1,-1>,3>::squared_distance<class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,-1,0,-1,-1>,class Eigen::Matrix<double,-1,1,0,-1,1>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<double,-1,3,0,-1,3> >(class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::MatrixBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > &)const;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// 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,
|
||||
LOG_ARAP,
|
||||
SYMMETRIC_DIRICHLET,
|
||||
CONFORMAL,
|
||||
EXP_CONFORMAL,
|
||||
EXP_SYMMETRIC_DIRICHLET
|
||||
};
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1 +0,0 @@
|
||||
e8898a8aa8e920ab7c2cd0bfaac5acc2e4991daf
|
||||
@@ -164,7 +164,6 @@ inline igl::WindingNumberTree<Point,DerivedV,DerivedF>::WindingNumberTree():
|
||||
V(dummyV),
|
||||
SV(),
|
||||
F(),
|
||||
//boundary(igl::boundary_facets<Eigen::MatrixXi,Eigen::MatrixXi>(F))
|
||||
cap(),
|
||||
radius(std::numeric_limits<typename DerivedV::Scalar>::infinity()),
|
||||
center(0,0,0)
|
||||
@@ -180,7 +179,6 @@ inline igl::WindingNumberTree<Point,DerivedV,DerivedF>::WindingNumberTree(
|
||||
V(dummyV),
|
||||
SV(),
|
||||
F(),
|
||||
//boundary(igl::boundary_facets<Eigen::MatrixXi,Eigen::MatrixXi>(F))
|
||||
cap(),
|
||||
radius(std::numeric_limits<typename DerivedV::Scalar>::infinity()),
|
||||
center(0,0,0)
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
// 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
|
||||
@@ -0,0 +1,50 @@
|
||||
// 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
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
template <typename Index, typename IndexVector>
|
||||
IGL_INLINE void igl::adjacency_list(
|
||||
const Eigen::PlainObjectBase<Index> & F,
|
||||
const Eigen::MatrixBase<Index> & F,
|
||||
std::vector<std::vector<IndexVector> >& A,
|
||||
bool sorted)
|
||||
{
|
||||
@@ -132,8 +132,18 @@ IGL_INLINE void igl::adjacency_list(
|
||||
const std::vector<std::vector<Index> > & F,
|
||||
std::vector<std::vector<Index> >& A)
|
||||
{
|
||||
A.clear();
|
||||
A.resize(F.maxCoeff()+1);
|
||||
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++)
|
||||
@@ -142,8 +152,8 @@ IGL_INLINE void igl::adjacency_list(
|
||||
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());
|
||||
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);
|
||||
}
|
||||
@@ -161,8 +171,10 @@ IGL_INLINE void igl::adjacency_list(
|
||||
#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::PlainObjectBase<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);
|
||||
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::PlainObjectBase<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::PlainObjectBase<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<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
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace igl
|
||||
// See also: edges, cotmatrix, diag
|
||||
template <typename Index, typename IndexVector>
|
||||
IGL_INLINE void adjacency_list(
|
||||
const Eigen::PlainObjectBase<Index> & F,
|
||||
const Eigen::MatrixBase<Index> & F,
|
||||
std::vector<std::vector<IndexVector> >& A,
|
||||
bool sorted = false);
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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
|
||||
//
|
||||
// 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"
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
template <typename DerivedF, typename T>
|
||||
IGL_INLINE void igl::adjacency_matrix(
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
Eigen::SparseMatrix<T>& A)
|
||||
{
|
||||
using namespace std;
|
||||
@@ -71,4 +71,5 @@ IGL_INLINE void igl::adjacency_matrix(
|
||||
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,934 +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 "ReAntTweakBar.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
|
||||
// GLOBAL WRAPPERS
|
||||
namespace
|
||||
{
|
||||
std::map<
|
||||
TwType,std::pair<const char *,std::vector<TwEnumVal> >
|
||||
> ReTw_custom_types;
|
||||
}
|
||||
|
||||
IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnum(
|
||||
const char *name,
|
||||
const TwEnumVal *enumValues,
|
||||
unsigned int nbValues)
|
||||
{
|
||||
using namespace std;
|
||||
// copy enum valus into vector
|
||||
std::vector<TwEnumVal> enum_vals;
|
||||
enum_vals.resize(nbValues);
|
||||
for(unsigned int j = 0; j<nbValues;j++)
|
||||
{
|
||||
enum_vals[j] = enumValues[j];
|
||||
}
|
||||
TwType type = TwDefineEnum(name,enumValues,nbValues);
|
||||
|
||||
ReTw_custom_types[type] =
|
||||
std::pair<const char *,std::vector<TwEnumVal> >(name,enum_vals);
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
IGL_INLINE TwType igl::anttweakbar::ReTwDefineEnumFromString(
|
||||
const char * _Name,
|
||||
const char * _EnumString)
|
||||
{
|
||||
// Taken directly from TwMgr.cpp, just replace TwDefineEnum with
|
||||
// ReTwDefineEnum
|
||||
using namespace std;
|
||||
{
|
||||
if (_EnumString == NULL)
|
||||
return ReTwDefineEnum(_Name, NULL, 0);
|
||||
|
||||
// split enumString
|
||||
stringstream EnumStream(_EnumString);
|
||||
string Label;
|
||||
vector<string> Labels;
|
||||
while( getline(EnumStream, Label, ',') ) {
|
||||
// trim Label
|
||||
size_t Start = Label.find_first_not_of(" \n\r\t");
|
||||
size_t End = Label.find_last_not_of(" \n\r\t");
|
||||
if( Start==string::npos || End==string::npos )
|
||||
Label = "";
|
||||
else
|
||||
Label = Label.substr(Start, (End-Start)+1);
|
||||
// store Label
|
||||
Labels.push_back(Label);
|
||||
}
|
||||
// create TwEnumVal array
|
||||
vector<TwEnumVal> Vals(Labels.size());
|
||||
for( int i=0; i<(int)Labels.size(); i++ )
|
||||
{
|
||||
Vals[i].Value = i;
|
||||
// Wrong:
|
||||
//Vals[i].Label = Labels[i].c_str();
|
||||
// Allocate char on heap
|
||||
// http://stackoverflow.com/a/10050258/148668
|
||||
char * c_label = new char[Labels[i].length()+1];
|
||||
std::strcpy(c_label, Labels[i].c_str());
|
||||
Vals[i].Label = c_label;
|
||||
}
|
||||
|
||||
const TwType type =
|
||||
ReTwDefineEnum(_Name, Vals.empty() ?
|
||||
NULL :
|
||||
&(Vals[0]), (unsigned int)Vals.size());
|
||||
return type;
|
||||
}
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
struct ReTwTypeString
|
||||
{
|
||||
TwType type;
|
||||
const char * type_str;
|
||||
};
|
||||
|
||||
#define RETW_NUM_DEFAULT_TYPE_STRINGS 23
|
||||
ReTwTypeString ReTwDefaultTypeStrings[RETW_NUM_DEFAULT_TYPE_STRINGS] =
|
||||
{
|
||||
{TW_TYPE_UNDEF,"TW_TYPE_UNDEF"},
|
||||
{TW_TYPE_BOOLCPP,"TW_TYPE_BOOLCPP"},
|
||||
{TW_TYPE_BOOL8,"TW_TYPE_BOOL8"},
|
||||
{TW_TYPE_BOOL16,"TW_TYPE_BOOL16"},
|
||||
{TW_TYPE_BOOL32,"TW_TYPE_BOOL32"},
|
||||
{TW_TYPE_CHAR,"TW_TYPE_CHAR"},
|
||||
{TW_TYPE_INT8,"TW_TYPE_INT8"},
|
||||
{TW_TYPE_UINT8,"TW_TYPE_UINT8"},
|
||||
{TW_TYPE_INT16,"TW_TYPE_INT16"},
|
||||
{TW_TYPE_UINT16,"TW_TYPE_UINT16"},
|
||||
{TW_TYPE_INT32,"TW_TYPE_INT32"},
|
||||
{TW_TYPE_UINT32,"TW_TYPE_UINT32"},
|
||||
{TW_TYPE_FLOAT,"TW_TYPE_FLOAT"},
|
||||
{TW_TYPE_DOUBLE,"TW_TYPE_DOUBLE"},
|
||||
{TW_TYPE_COLOR32,"TW_TYPE_COLOR32"},
|
||||
{TW_TYPE_COLOR3F,"TW_TYPE_COLOR3F"},
|
||||
{TW_TYPE_COLOR4F,"TW_TYPE_COLOR4F"},
|
||||
{TW_TYPE_CDSTRING,"TW_TYPE_CDSTRING"},
|
||||
{TW_TYPE_STDSTRING,"TW_TYPE_STDSTRING"},
|
||||
{TW_TYPE_QUAT4F,"TW_TYPE_QUAT4F"},
|
||||
{TW_TYPE_QUAT4D,"TW_TYPE_QUAT4D"},
|
||||
{TW_TYPE_DIR3F,"TW_TYPE_DIR3F"},
|
||||
{TW_TYPE_DIR3D,"TW_TYPE_DIR3D"}
|
||||
};
|
||||
}
|
||||
|
||||
IGL_INLINE igl::anttweakbar::ReTwBar::ReTwBar():
|
||||
bar(NULL),
|
||||
name(),
|
||||
rw_items(),cb_items()
|
||||
{
|
||||
}
|
||||
|
||||
IGL_INLINE igl::anttweakbar::ReTwBar::ReTwBar(
|
||||
const igl::anttweakbar::ReTwBar & that):
|
||||
bar(that.bar),
|
||||
name(that.name),
|
||||
rw_items(that.rw_items),
|
||||
cb_items(that.cb_items)
|
||||
{
|
||||
}
|
||||
|
||||
IGL_INLINE igl::anttweakbar::ReTwBar &
|
||||
igl::anttweakbar::ReTwBar::operator=(const igl::anttweakbar::ReTwBar & that)
|
||||
{
|
||||
// check for self assignment
|
||||
if(this != &that)
|
||||
{
|
||||
bar = that.bar;
|
||||
rw_items = that.rw_items;
|
||||
cb_items = that.cb_items;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
// BAR WRAPPERS
|
||||
IGL_INLINE void igl::anttweakbar::ReTwBar::TwNewBar(const char * _name)
|
||||
{
|
||||
this->bar = ::TwNewBar(_name);
|
||||
// Alec: This causes trouble (not sure why) in multiple applications
|
||||
// (medit, puppet) Probably there is some sort of memory corrpution.
|
||||
// this->name = _name;
|
||||
// Suspiciously this also fails:
|
||||
//this->name = "foobar";
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRW(
|
||||
const char *name,
|
||||
TwType type,
|
||||
void *var,
|
||||
const char *def,
|
||||
const bool record)
|
||||
{
|
||||
int ret = ::TwAddVarRW(this->bar,name,type,var,def);
|
||||
if(ret && record)
|
||||
{
|
||||
rw_items.push_back(ReTwRWItem(name,type,var));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarCB(
|
||||
const char *name,
|
||||
TwType type,
|
||||
TwSetVarCallback setCallback,
|
||||
TwGetVarCallback getCallback,
|
||||
void *clientData,
|
||||
const char *def,
|
||||
const bool record)
|
||||
{
|
||||
int ret =
|
||||
::TwAddVarCB(this->bar,name,type,setCallback,getCallback,clientData,def);
|
||||
if(ret && record)
|
||||
{
|
||||
cb_items.push_back(ReTwCBItem(name,type,setCallback,getCallback,clientData));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddVarRO(
|
||||
const char *name,
|
||||
TwType type,
|
||||
void *var,
|
||||
const char *def)
|
||||
{
|
||||
int ret = ::TwAddVarRO(this->bar,name,type,var,def);
|
||||
// Read only variables are not recorded
|
||||
//if(ret)
|
||||
//{
|
||||
// rw_items.push_back(ReTwRWItem(name,type,var));
|
||||
//}
|
||||
return ret;
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwAddButton(
|
||||
const char *name,
|
||||
TwButtonCallback buttonCallback,
|
||||
void *clientData,
|
||||
const char *def)
|
||||
{
|
||||
int ret =
|
||||
::TwAddButton(this->bar,name,buttonCallback,clientData,def);
|
||||
// buttons are not recorded
|
||||
//if(ret)
|
||||
//{
|
||||
// cb_items.push_back(ReTwCBItem(name,type,setCallback,getCallback,clientData));
|
||||
//}
|
||||
return ret;
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwSetParam(
|
||||
const char *varName,
|
||||
const char *paramName,
|
||||
TwParamValueType paramValueType,
|
||||
unsigned int inValueCount,
|
||||
const void *inValues)
|
||||
{
|
||||
// For now just pass these along
|
||||
return
|
||||
::TwSetParam(
|
||||
this->bar,
|
||||
varName,
|
||||
paramName,
|
||||
paramValueType,
|
||||
inValueCount,
|
||||
inValues);
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwGetParam(
|
||||
const char *varName,
|
||||
const char *paramName,
|
||||
TwParamValueType paramValueType,
|
||||
unsigned int outValueMaxCount,
|
||||
void *outValues)
|
||||
{
|
||||
return
|
||||
::TwGetParam(
|
||||
this->bar,
|
||||
varName,
|
||||
paramName,
|
||||
paramValueType,
|
||||
outValueMaxCount,
|
||||
outValues);
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwRefreshBar()
|
||||
{
|
||||
return ::TwRefreshBar(this->bar);
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::ReTwBar::TwTerminate()
|
||||
{
|
||||
//std::cout<<"TwTerminate"<<std::endl;
|
||||
int r = ::TwTerminate();
|
||||
//std::cout<<" "<<r<<std::endl;
|
||||
return r;
|
||||
}
|
||||
|
||||
IGL_INLINE bool igl::anttweakbar::ReTwBar::save(const char *file_name)
|
||||
{
|
||||
FILE * fp;
|
||||
if(file_name == NULL)
|
||||
{
|
||||
fp = stdout;
|
||||
}else
|
||||
{
|
||||
fp = fopen(file_name,"w");
|
||||
}
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
printf("ERROR: not able to open %s for writing...\n",file_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Print all RW variables
|
||||
for(
|
||||
std::vector<ReTwRWItem>::iterator it = rw_items.begin();
|
||||
it != rw_items.end();
|
||||
it++)
|
||||
{
|
||||
std::string s = (*it).name;
|
||||
const char * name = s.c_str();
|
||||
TwType type = (*it).type;
|
||||
void * var = (*it).var;
|
||||
fprintf(fp,"%s: %s\n",
|
||||
name,
|
||||
get_value_as_string(var,type).c_str());
|
||||
}
|
||||
|
||||
char var[REANTTWEAKBAR_MAX_CB_VAR_SIZE];
|
||||
// Print all CB variables
|
||||
for(
|
||||
std::vector<ReTwCBItem>::iterator it = cb_items.begin();
|
||||
it != cb_items.end();
|
||||
it++)
|
||||
{
|
||||
const char * name = it->name.c_str();
|
||||
TwType type = it->type;
|
||||
//TwSetVarCallback setCallback = it->setCallback;
|
||||
TwGetVarCallback getCallback = it->getCallback;
|
||||
void * clientData = it->clientData;
|
||||
// I'm not sure how to do what I want to do. getCallback needs to be sure
|
||||
// that it can write to var. So var needs to point to a valid and big
|
||||
// enough chunk of memory
|
||||
getCallback(var,clientData);
|
||||
fprintf(fp,"%s: %s\n",
|
||||
name,
|
||||
get_value_as_string(var,type).c_str());
|
||||
}
|
||||
|
||||
fprintf(fp,"\n");
|
||||
|
||||
if(file_name != NULL)
|
||||
{
|
||||
fclose(fp);
|
||||
}
|
||||
// everything succeeded
|
||||
return true;
|
||||
}
|
||||
|
||||
IGL_INLINE std::string igl::anttweakbar::ReTwBar::get_value_as_string(
|
||||
void * var,
|
||||
TwType type)
|
||||
{
|
||||
std::stringstream sstr;
|
||||
switch(type)
|
||||
{
|
||||
case TW_TYPE_BOOLCPP:
|
||||
{
|
||||
sstr << "TW_TYPE_BOOLCPP" << " ";
|
||||
sstr << *(static_cast<bool*>(var));
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_QUAT4D:
|
||||
{
|
||||
sstr << "TW_TYPE_QUAT4D" << " ";
|
||||
// Q: Why does casting to double* work? shouldn't I have to cast to
|
||||
// double**?
|
||||
double * q = static_cast<double*>(var);
|
||||
sstr << std::setprecision(15) << q[0] << " " << q[1] << " " << q[2] << " " << q[3];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_QUAT4F:
|
||||
{
|
||||
sstr << "TW_TYPE_QUAT4F" << " ";
|
||||
// Q: Why does casting to float* work? shouldn't I have to cast to
|
||||
// float**?
|
||||
float * q = static_cast<float*>(var);
|
||||
sstr << q[0] << " " << q[1] << " " << q[2] << " " << q[3];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_COLOR4F:
|
||||
{
|
||||
sstr << "TW_TYPE_COLOR4F" << " ";
|
||||
float * c = static_cast<float*>(var);
|
||||
sstr << c[0] << " " << c[1] << " " << c[2] << " " << c[3];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_COLOR3F:
|
||||
{
|
||||
sstr << "TW_TYPE_COLOR3F" << " ";
|
||||
float * c = static_cast<float*>(var);
|
||||
sstr << c[0] << " " << c[1] << " " << c[2];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_DIR3D:
|
||||
{
|
||||
sstr << "TW_TYPE_DIR3D" << " ";
|
||||
double * d = static_cast<double*>(var);
|
||||
sstr << std::setprecision(15) << d[0] << " " << d[1] << " " << d[2];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_DIR3F:
|
||||
{
|
||||
sstr << "TW_TYPE_DIR3F" << " ";
|
||||
float * d = static_cast<float*>(var);
|
||||
sstr << d[0] << " " << d[1] << " " << d[2];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_BOOL32:
|
||||
{
|
||||
sstr << "TW_TYPE_BOOL32" << " ";
|
||||
sstr << *(static_cast<int*>(var));
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_UINT8:
|
||||
{
|
||||
sstr << "TW_TYPE_UINT8" << " ";
|
||||
// Cast to int so that it's human readable
|
||||
sstr << (int)*(static_cast<unsigned char*>(var));
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_INT32:
|
||||
{
|
||||
sstr << "TW_TYPE_INT32" << " ";
|
||||
sstr << *(static_cast<int*>(var));
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_UINT32:
|
||||
{
|
||||
sstr << "TW_TYPE_UINT32" << " ";
|
||||
sstr << *(static_cast<unsigned int*>(var));
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_FLOAT:
|
||||
{
|
||||
sstr << "TW_TYPE_FLOAT" << " ";
|
||||
sstr << *(static_cast<float*>(var));
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_DOUBLE:
|
||||
{
|
||||
sstr << "TW_TYPE_DOUBLE" << " ";
|
||||
sstr << std::setprecision(15) << *(static_cast<double*>(var));
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_STDSTRING:
|
||||
{
|
||||
sstr << "TW_TYPE_STDSTRING" << " ";
|
||||
std::string *destPtr = static_cast<std::string *>(var);
|
||||
sstr << destPtr->c_str();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
using namespace std;
|
||||
std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::const_iterator iter =
|
||||
ReTw_custom_types.find(type);
|
||||
if(iter != ReTw_custom_types.end())
|
||||
{
|
||||
sstr << (*iter).second.first << " ";
|
||||
int enum_val = *(static_cast<int*>(var));
|
||||
// try find display name for enum value
|
||||
std::vector<TwEnumVal>::const_iterator eit = (*iter).second.second.begin();
|
||||
bool found = false;
|
||||
for(;eit<(*iter).second.second.end();eit++)
|
||||
{
|
||||
if(enum_val == eit->Value)
|
||||
{
|
||||
sstr << eit->Label;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
sstr << "ERROR_ENUM_VALUE_NOT_DEFINED";
|
||||
}
|
||||
}else
|
||||
{
|
||||
sstr << "ERROR_TYPE_NOT_SUPPORTED";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sstr.str();
|
||||
}
|
||||
|
||||
IGL_INLINE bool igl::anttweakbar::ReTwBar::load(const char *file_name)
|
||||
{
|
||||
FILE * fp;
|
||||
fp = fopen(file_name,"r");
|
||||
|
||||
if(fp == NULL)
|
||||
{
|
||||
printf("ERROR: not able to open %s for reading...\n",file_name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// go through file line by line
|
||||
char line[REANTTWEAKBAR_MAX_LINE];
|
||||
bool still_comments;
|
||||
char name[REANTTWEAKBAR_MAX_WORD];
|
||||
char type_str[REANTTWEAKBAR_MAX_WORD];
|
||||
char value_str[REANTTWEAKBAR_MAX_WORD];
|
||||
|
||||
|
||||
// line number
|
||||
int j = 0;
|
||||
bool finished = false;
|
||||
while(true)
|
||||
{
|
||||
// Eat comments
|
||||
still_comments = true;
|
||||
while(still_comments)
|
||||
{
|
||||
if(fgets(line,REANTTWEAKBAR_MAX_LINE,fp) == NULL)
|
||||
{
|
||||
finished = true;
|
||||
break;
|
||||
}
|
||||
// Blank lines and lines that begin with # are comments
|
||||
still_comments = (line[0] == '#' || line[0] == '\n');
|
||||
j++;
|
||||
}
|
||||
if(finished)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
sscanf(line,"%[^:]: %s %[^\n]",name,type_str,value_str);
|
||||
//printf("%s: %s %s\n",name, type_str,value_str);
|
||||
|
||||
TwType type;
|
||||
if(!type_from_string(type_str,type))
|
||||
{
|
||||
printf("ERROR: %s type not found... Skipping...\n",type_str);
|
||||
continue;
|
||||
}
|
||||
set_value_from_string(name,type,value_str);
|
||||
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
||||
// everything succeeded
|
||||
return true;
|
||||
}
|
||||
|
||||
IGL_INLINE bool igl::anttweakbar::ReTwBar::type_from_string(
|
||||
const char *type_str, TwType & type)
|
||||
{
|
||||
// first check default types
|
||||
for(int j = 0; j < RETW_NUM_DEFAULT_TYPE_STRINGS; j++)
|
||||
{
|
||||
if(strcmp(type_str,ReTwDefaultTypeStrings[j].type_str) == 0)
|
||||
{
|
||||
type = ReTwDefaultTypeStrings[j].type;
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// then check custom types
|
||||
std::map<
|
||||
TwType,std::pair<const char *,std::vector<TwEnumVal> >
|
||||
>::const_iterator iter =
|
||||
ReTw_custom_types.begin();
|
||||
for(;iter != ReTw_custom_types.end(); iter++)
|
||||
{
|
||||
if(strcmp((*iter).second.first,type_str)==0)
|
||||
{
|
||||
type = (*iter).first;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool igl::anttweakbar::ReTwBar::set_value_from_string(
|
||||
const char * name,
|
||||
TwType type,
|
||||
const char * value_str)
|
||||
{
|
||||
void * value = NULL;
|
||||
// possible value slots
|
||||
int i;
|
||||
float v;
|
||||
double dv;
|
||||
float f[4];
|
||||
double d[4];
|
||||
bool b;
|
||||
unsigned int u;
|
||||
unsigned char uc;
|
||||
std::string s;
|
||||
|
||||
// First try to get value from default types
|
||||
switch(type)
|
||||
{
|
||||
case TW_TYPE_BOOLCPP:
|
||||
{
|
||||
int ib;
|
||||
if(sscanf(value_str," %d",&ib) == 1)
|
||||
{
|
||||
b = ib!=0;
|
||||
value = &b;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_QUAT4D:
|
||||
//case TW_TYPE_COLOR4D:
|
||||
{
|
||||
if(sscanf(value_str," %lf %lf %lf %lf",&d[0],&d[1],&d[2],&d[3]) == 4)
|
||||
{
|
||||
value = &d;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_QUAT4F:
|
||||
case TW_TYPE_COLOR4F:
|
||||
{
|
||||
if(sscanf(value_str," %f %f %f %f",&f[0],&f[1],&f[2],&f[3]) == 4)
|
||||
{
|
||||
value = &f;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
//case TW_TYPE_COLOR3D:
|
||||
case TW_TYPE_DIR3D:
|
||||
{
|
||||
if(sscanf(value_str," %lf %lf %lf",&d[0],&d[1],&d[2]) == 3)
|
||||
{
|
||||
value = &d;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_COLOR3F:
|
||||
case TW_TYPE_DIR3F:
|
||||
{
|
||||
if(sscanf(value_str," %f %f %f",&f[0],&f[1],&f[2]) == 3)
|
||||
{
|
||||
value = &f;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_UINT8:
|
||||
{
|
||||
if(sscanf(value_str," %d",&i) == 1)
|
||||
{
|
||||
// Cast to unsigned char
|
||||
uc = (unsigned char) i;
|
||||
value = &uc;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_BOOL32:
|
||||
case TW_TYPE_INT32:
|
||||
{
|
||||
if(sscanf(value_str," %d",&i) == 1)
|
||||
{
|
||||
value = &i;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_UINT32:
|
||||
{
|
||||
if(sscanf(value_str," %u",&u) == 1)
|
||||
{
|
||||
value = &u;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_FLOAT:
|
||||
{
|
||||
if(sscanf(value_str," %f",&v) == 1)
|
||||
{
|
||||
value = &v;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_DOUBLE:
|
||||
{
|
||||
if(sscanf(value_str," %lf",&dv) == 1)
|
||||
{
|
||||
value = &dv;
|
||||
}else
|
||||
{
|
||||
printf("ERROR: Bad value format...\n");
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_STDSTRING:
|
||||
{
|
||||
s = value_str;
|
||||
value = &s;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Try to find type in custom enum types
|
||||
std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::const_iterator iter =
|
||||
ReTw_custom_types.find(type);
|
||||
if(iter != ReTw_custom_types.end())
|
||||
{
|
||||
std::vector<TwEnumVal>::const_iterator eit = (*iter).second.second.begin();
|
||||
bool found = false;
|
||||
for(;eit<(*iter).second.second.end();eit++)
|
||||
{
|
||||
if(strcmp(value_str,eit->Label) == 0)
|
||||
{
|
||||
i = eit->Value;
|
||||
value = &i;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
printf("ERROR_ENUM_VALUE_NOT_DEFINED");
|
||||
}
|
||||
}else
|
||||
{
|
||||
printf("ERROR_TYPE_NOT_SUPPORTED\n");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Find variable based on name
|
||||
// First look in RW items
|
||||
bool item_found = false;
|
||||
for(
|
||||
std::vector<ReTwRWItem>::iterator it = rw_items.begin();
|
||||
it != rw_items.end();
|
||||
it++)
|
||||
{
|
||||
if(it->name == name)
|
||||
{
|
||||
void * var = it->var;
|
||||
switch(type)
|
||||
{
|
||||
case TW_TYPE_BOOLCPP:
|
||||
{
|
||||
bool * bvar = static_cast<bool*>(var);
|
||||
bool * bvalue = static_cast<bool*>(value);
|
||||
*bvar = *bvalue;
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_QUAT4D:
|
||||
//case TW_TYPE_COLOR4D:
|
||||
{
|
||||
double * dvar = static_cast<double*>(var);
|
||||
double * dvalue = static_cast<double*>(value);
|
||||
dvar[0] = dvalue[0];
|
||||
dvar[1] = dvalue[1];
|
||||
dvar[2] = dvalue[2];
|
||||
dvar[3] = dvalue[3];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_QUAT4F:
|
||||
case TW_TYPE_COLOR4F:
|
||||
{
|
||||
float * fvar = static_cast<float*>(var);
|
||||
float * fvalue = static_cast<float*>(value);
|
||||
fvar[0] = fvalue[0];
|
||||
fvar[1] = fvalue[1];
|
||||
fvar[2] = fvalue[2];
|
||||
fvar[3] = fvalue[3];
|
||||
break;
|
||||
}
|
||||
//case TW_TYPE_COLOR3D:
|
||||
case TW_TYPE_DIR3D:
|
||||
{
|
||||
double * dvar = static_cast<double*>(var);
|
||||
double * dvalue = static_cast<double*>(value);
|
||||
dvar[0] = dvalue[0];
|
||||
dvar[1] = dvalue[1];
|
||||
dvar[2] = dvalue[2];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_COLOR3F:
|
||||
case TW_TYPE_DIR3F:
|
||||
{
|
||||
float * fvar = static_cast<float*>(var);
|
||||
float * fvalue = static_cast<float*>(value);
|
||||
fvar[0] = fvalue[0];
|
||||
fvar[1] = fvalue[1];
|
||||
fvar[2] = fvalue[2];
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_UINT8:
|
||||
{
|
||||
unsigned char * ucvar = static_cast<unsigned char*>(var);
|
||||
unsigned char * ucvalue = static_cast<unsigned char*>(value);
|
||||
*ucvar = *ucvalue;
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_BOOL32:
|
||||
case TW_TYPE_INT32:
|
||||
{
|
||||
int * ivar = static_cast<int*>(var);
|
||||
int * ivalue = static_cast<int*>(value);
|
||||
*ivar = *ivalue;
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_UINT32:
|
||||
{
|
||||
unsigned int * uvar = static_cast<unsigned int*>(var);
|
||||
unsigned int * uvalue = static_cast<unsigned int*>(value);
|
||||
*uvar = *uvalue;
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_FLOAT:
|
||||
{
|
||||
float * fvar = static_cast<float*>(var);
|
||||
float * fvalue = static_cast<float*>(value);
|
||||
*fvar = *fvalue;
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_DOUBLE:
|
||||
{
|
||||
double * dvar = static_cast<double*>(var);
|
||||
double * fvalue = static_cast<double*>(value);
|
||||
*dvar = *fvalue;
|
||||
break;
|
||||
}
|
||||
case TW_TYPE_STDSTRING:
|
||||
{
|
||||
std::string * svar = static_cast<std::string*>(var);
|
||||
std::string * svalue = static_cast<std::string*>(value);
|
||||
*svar = *svalue;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// Try to find type in custom enum types
|
||||
std::map<TwType,std::pair<const char *,std::vector<TwEnumVal> > >::iterator iter =
|
||||
ReTw_custom_types.find(type);
|
||||
if(iter != ReTw_custom_types.end())
|
||||
{
|
||||
int * ivar = static_cast<int*>(var);
|
||||
std::vector<TwEnumVal>::iterator eit = (*iter).second.second.begin();
|
||||
bool found = false;
|
||||
for(;eit<(*iter).second.second.end();eit++)
|
||||
{
|
||||
if(strcmp(value_str,eit->Label) == 0)
|
||||
{
|
||||
*ivar = eit->Value;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
printf("ERROR_ENUM_VALUE_NOT_DEFINED");
|
||||
}
|
||||
}else
|
||||
{
|
||||
printf("ERROR_TYPE_NOT_SUPPORTED\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
item_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Try looking in CB items
|
||||
if(!item_found)
|
||||
{
|
||||
for(
|
||||
std::vector<ReTwCBItem>::iterator it = cb_items.begin();
|
||||
it != cb_items.end();
|
||||
it++)
|
||||
{
|
||||
if(it->name==name)
|
||||
{
|
||||
it->setCallback(value,it->clientData);
|
||||
item_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!item_found)
|
||||
{
|
||||
printf("ERROR: item '%s' not found\n",name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
IGL_INLINE const std::vector<igl::anttweakbar::ReTwRWItem> &
|
||||
igl::anttweakbar::ReTwBar::get_rw_items()
|
||||
{
|
||||
return rw_items;
|
||||
}
|
||||
|
||||
IGL_INLINE const std::vector<igl::anttweakbar::ReTwCBItem> &
|
||||
igl::anttweakbar::ReTwBar::get_cb_items()
|
||||
{
|
||||
return cb_items;
|
||||
}
|
||||
@@ -1,286 +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_ANTTWEAKBAR_REANTTWEAKBAR_H
|
||||
#define IGL_ANTTWEAKBAR_REANTTWEAKBAR_H
|
||||
#include "../igl_inline.h"
|
||||
// ReAntTweakBar is a minimal wrapper for the AntTweakBar library that allows
|
||||
// "bars" to be saved and load from disk. Changing your existing app that uses
|
||||
// AntTweakBar to use ReAntTweakBar is trivial.
|
||||
//
|
||||
// Many (but not all) variable types are supported. I'll try to keep track them
|
||||
// here:
|
||||
// TW_TYPE_BOOLCPP
|
||||
// TW_TYPE_QUAT4F
|
||||
// TW_TYPE_QUAT4D
|
||||
// TW_TYPE_COLOR4F
|
||||
// TW_TYPE_COLOR4D
|
||||
// TW_TYPE_COLOR3F
|
||||
// TW_TYPE_DIR3F
|
||||
// TW_TYPE_DIR3D
|
||||
// TW_TYPE_BOOL32
|
||||
// TW_TYPE_INT32
|
||||
// TW_TYPE_UINT32
|
||||
// TW_TYPE_FLOAT
|
||||
// TW_TYPE_DOUBLE
|
||||
// TW_TYPE_UINT8
|
||||
// and
|
||||
// custom TwTypes made with TwDefineEnum
|
||||
//
|
||||
// I'm working on adding the rest on an as-needed basis. Adding a new type only
|
||||
// requires changes in a few places...
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
// This allows the user to have a non-global, static installation of
|
||||
// AntTweakBar
|
||||
#include <AntTweakBar.h>
|
||||
// Instead of including AntTweakBar.h, just define the necessary types
|
||||
// Types used:
|
||||
// - TwType
|
||||
// - TwEnumVal
|
||||
// - TwSetVarCallback
|
||||
// - TwGetVarCallback
|
||||
// - TwBar
|
||||
// - TwButtonCallback
|
||||
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
#define REANTTWEAKBAR_MAX_CB_VAR_SIZE 1000
|
||||
// Max line size for reading files
|
||||
#define REANTTWEAKBAR_MAX_LINE 1000
|
||||
#define REANTTWEAKBAR_MAX_WORD 100
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace anttweakbar
|
||||
{
|
||||
TwType ReTwDefineEnum(
|
||||
const char *name,
|
||||
const TwEnumVal *enumValues,
|
||||
unsigned int nbValues);
|
||||
TwType ReTwDefineEnumFromString(const char * name,const char * enumString);
|
||||
|
||||
struct ReTwRWItem
|
||||
{
|
||||
//const char * name;
|
||||
std::string name;
|
||||
TwType type;
|
||||
void * var;
|
||||
// Default constructor
|
||||
IGL_INLINE ReTwRWItem(
|
||||
const std::string _name,
|
||||
TwType _type,
|
||||
void *_var):
|
||||
name(_name),
|
||||
type(_type),
|
||||
var(_var)
|
||||
{
|
||||
}
|
||||
// Shallow copy constructor
|
||||
// I solemnly swear it's OK to copy var this way
|
||||
// Q: Is it really?
|
||||
IGL_INLINE ReTwRWItem(const ReTwRWItem & that):
|
||||
name(that.name),
|
||||
type(that.type),
|
||||
var(that.var)
|
||||
{
|
||||
}
|
||||
// Shallow assignment
|
||||
// I solemnly swear it's OK to copy var this way
|
||||
IGL_INLINE ReTwRWItem & operator=(const ReTwRWItem & that)
|
||||
{
|
||||
if(this != &that)
|
||||
{
|
||||
this->name = that.name;
|
||||
this->type = that.type;
|
||||
this->var = that.var;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
struct ReTwCBItem
|
||||
{
|
||||
//const char * name;
|
||||
std::string name;
|
||||
TwType type;
|
||||
TwSetVarCallback setCallback;
|
||||
TwGetVarCallback getCallback;
|
||||
void * clientData;
|
||||
// Default constructor
|
||||
IGL_INLINE ReTwCBItem(
|
||||
const std::string _name,
|
||||
TwType _type,
|
||||
TwSetVarCallback _setCallback,
|
||||
TwGetVarCallback _getCallback,
|
||||
void * _clientData):
|
||||
name(_name),
|
||||
type(_type),
|
||||
setCallback(_setCallback),
|
||||
getCallback(_getCallback),
|
||||
clientData(_clientData)
|
||||
{
|
||||
}
|
||||
// Shallow copy
|
||||
// I solemnly swear it's OK to copy clientData this way
|
||||
IGL_INLINE ReTwCBItem(const ReTwCBItem & that):
|
||||
name(that.name),
|
||||
type(that.type),
|
||||
setCallback(that.setCallback),
|
||||
getCallback(that.getCallback),
|
||||
clientData(that.clientData)
|
||||
{
|
||||
}
|
||||
// Shallow assignment
|
||||
// I solemnly swear it's OK to copy clientData this way
|
||||
IGL_INLINE ReTwCBItem & operator=(const ReTwCBItem & that)
|
||||
{
|
||||
if(this != &that)
|
||||
{
|
||||
name = that.name;
|
||||
type = that.type;
|
||||
setCallback = that.setCallback;
|
||||
getCallback = that.getCallback;
|
||||
clientData = that.clientData;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class ReTwBar
|
||||
{
|
||||
// VARIABLES
|
||||
// Should be private, but seeing as I'm not going to implement all of the
|
||||
// AntTweakBar public functions right away, I'll expose this so that at
|
||||
// anytime AntTweakBar functions can be called directly on the bar
|
||||
public:
|
||||
TwBar * bar;
|
||||
std::string name;
|
||||
protected:
|
||||
std::vector<ReTwRWItem> rw_items;
|
||||
std::vector<ReTwCBItem> cb_items;
|
||||
public:
|
||||
// Default constructor with explicit initialization
|
||||
IGL_INLINE ReTwBar();
|
||||
private:
|
||||
// Copy constructor does shallow copy
|
||||
IGL_INLINE ReTwBar(const ReTwBar & that);
|
||||
// Assignment operator does shallow assignment
|
||||
IGL_INLINE ReTwBar &operator=(const ReTwBar & that);
|
||||
|
||||
// WRAPPERS FOR ANTTWEAKBAR FUNCTIONS
|
||||
public:
|
||||
IGL_INLINE void TwNewBar(const char *_name);
|
||||
IGL_INLINE int TwAddVarRW(
|
||||
const char *name,
|
||||
TwType type,
|
||||
void *var,
|
||||
const char *def,
|
||||
const bool record=true);
|
||||
IGL_INLINE int TwAddVarCB(
|
||||
const char *name,
|
||||
TwType type,
|
||||
TwSetVarCallback setCallback,
|
||||
TwGetVarCallback getCallback,
|
||||
void *clientData,
|
||||
const char *def,
|
||||
const bool record=true);
|
||||
// Wrappers for convenience (not recorded, just passed on)
|
||||
IGL_INLINE int TwAddVarRO(const char *name, TwType type, void *var, const char *def);
|
||||
IGL_INLINE int TwAddButton(
|
||||
const char *name,
|
||||
TwButtonCallback buttonCallback,
|
||||
void *clientData,
|
||||
const char *def);
|
||||
IGL_INLINE int TwSetParam(
|
||||
const char *varName,
|
||||
const char *paramName,
|
||||
TwParamValueType paramValueType,
|
||||
unsigned int inValueCount,
|
||||
const void *inValues);
|
||||
IGL_INLINE int TwGetParam(
|
||||
const char *varName,
|
||||
const char *paramName,
|
||||
TwParamValueType paramValueType,
|
||||
unsigned int outValueMaxCount,
|
||||
void *outValues);
|
||||
IGL_INLINE int TwRefreshBar();
|
||||
IGL_INLINE int TwTerminate();
|
||||
|
||||
|
||||
// IO FUNCTIONS
|
||||
public:
|
||||
// Save current items to file
|
||||
// Input:
|
||||
// file_name name of file to save data to, can be null which means print
|
||||
// to stdout
|
||||
// Return:
|
||||
// true only if there were no (fatal) errors
|
||||
IGL_INLINE bool save(const char *file_name);
|
||||
std::string get_value_as_string(
|
||||
void * var,
|
||||
TwType type);
|
||||
// Load into current items from file
|
||||
// Input:
|
||||
// file_name name of input file to load
|
||||
// Return:
|
||||
// true only if there were no (fatal) errors
|
||||
IGL_INLINE bool load(const char *file_name);
|
||||
// Get TwType from string
|
||||
// Input
|
||||
// type_str string of type
|
||||
// Output
|
||||
// type TwType converted from string
|
||||
// Returns
|
||||
// true only if string matched a valid type
|
||||
IGL_INLINE bool type_from_string(const char *type_str, TwType & type);
|
||||
// I realize that I mix std::string and const char * all over the place.
|
||||
// What can you do...
|
||||
IGL_INLINE bool set_value_from_string(
|
||||
const char * name,
|
||||
TwType type,
|
||||
const char * value_str);
|
||||
IGL_INLINE const std::vector<ReTwRWItem> & get_rw_items();
|
||||
IGL_INLINE const std::vector<ReTwCBItem> & get_cb_items();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// List of TwBar functions
|
||||
//TW_API TwBar * TW_CALL TwNewBar(const char *barName);
|
||||
//TW_API int TW_CALL TwDeleteBar(TwBar *bar);
|
||||
//TW_API int TW_CALL TwDeleteAllBars();
|
||||
//TW_API int TW_CALL TwSetTopBar(const TwBar *bar);
|
||||
//TW_API TwBar * TW_CALL TwGetTopBar();
|
||||
//TW_API int TW_CALL TwSetBottomBar(const TwBar *bar);
|
||||
//TW_API TwBar * TW_CALL TwGetBottomBar();
|
||||
//TW_API const char * TW_CALL TwGetBarName(TwBar *bar);
|
||||
//TW_API int TW_CALL TwGetBarCount();
|
||||
//TW_API TwBar * TW_CALL TwGetBarByIndex(int barIndex);
|
||||
//TW_API TwBar * TW_CALL TwGetBarByName(const char *barName);
|
||||
//TW_API int TW_CALL TwRefreshBar(TwBar *bar);
|
||||
//TW_API int TW_CALL TwTerminate();
|
||||
//
|
||||
//TW_API int TW_CALL TwAddVarRW(TwBar *bar, const char *name, TwType type, void *var, const char *def);
|
||||
//TW_API int TW_CALL TwAddVarRO(TwBar *bar, const char *name, TwType type, const void *var, const char *def);
|
||||
//TW_API int TW_CALL TwAddVarCB(TwBar *bar, const char *name, TwType type, TwSetVarCallback setCallback, TwGetVarCallback getCallback, void *clientData, const char *def);
|
||||
//TW_API int TW_CALL TwAddButton(TwBar *bar, const char *name, TwButtonCallback callback, void *clientData, const char *def);
|
||||
//TW_API int TW_CALL TwAddSeparator(TwBar *bar, const char *name, const char *def);
|
||||
//TW_API int TW_CALL TwRemoveVar(TwBar *bar, const char *name);
|
||||
//TW_API int TW_CALL TwRemoveAllVars(TwBar *bar);
|
||||
|
||||
// Until AntTweakBar dependency folder exists, this is header-only
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "ReAntTweakBar.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,81 +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 "cocoa_key_to_anttweakbar_key.h"
|
||||
|
||||
#include <AntTweakBar.h>
|
||||
|
||||
IGL_INLINE int igl::anttweakbar::cocoa_key_to_anttweakbar_key(int key)
|
||||
{
|
||||
// I've left commented the AntTweakBar key codes that correspond to keys I
|
||||
// don't have on my keyboard. Please fill this in if you have those keys
|
||||
switch(key)
|
||||
{
|
||||
case 127:
|
||||
return TW_KEY_BACKSPACE;
|
||||
case 9:
|
||||
return TW_KEY_TAB;
|
||||
//TW_KEY_CLEAR = 0x0c,
|
||||
case 3://ENTER
|
||||
case 13:
|
||||
return TW_KEY_RETURN;
|
||||
case 27:
|
||||
return TW_KEY_ESCAPE;
|
||||
case 32:
|
||||
return TW_KEY_SPACE;
|
||||
// IN A GLUT APP 40 is (
|
||||
//case 40:
|
||||
case 63272:
|
||||
return TW_KEY_DELETE;
|
||||
case 63232:
|
||||
return TW_KEY_UP;
|
||||
case 63233:
|
||||
return TW_KEY_DOWN;
|
||||
case 63235:
|
||||
return TW_KEY_RIGHT;
|
||||
case 63234:
|
||||
return TW_KEY_LEFT;
|
||||
//TW_KEY_INSERT,
|
||||
//TW_KEY_HOME,
|
||||
//TW_KEY_END,
|
||||
//TW_KEY_PAGE_UP,
|
||||
//TW_KEY_PAGE_DOWN,
|
||||
case 63236:
|
||||
return TW_KEY_F1;
|
||||
case 63237:
|
||||
return TW_KEY_F2;
|
||||
case 63238:
|
||||
return TW_KEY_F3;
|
||||
case 63239:
|
||||
return TW_KEY_F4;
|
||||
case 63240:
|
||||
return TW_KEY_F5;
|
||||
case 63241:
|
||||
return TW_KEY_F6;
|
||||
case 63242:
|
||||
return TW_KEY_F7;
|
||||
case 63243:
|
||||
return TW_KEY_F8;
|
||||
case 63244:
|
||||
return TW_KEY_F9;
|
||||
case 63245:
|
||||
return TW_KEY_F10;
|
||||
case 63246:
|
||||
return TW_KEY_F11;
|
||||
case 63247:
|
||||
return TW_KEY_F12;
|
||||
case 63248:
|
||||
return TW_KEY_F13;
|
||||
case 63249:
|
||||
return TW_KEY_F14;
|
||||
case 63250:
|
||||
return TW_KEY_F15;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
@@ -1,31 +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_ANTTWEAKBAR_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
|
||||
#define IGL_ANTTWEAKBAR_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H
|
||||
#include "../igl_inline.h"
|
||||
|
||||
|
||||
namespace igl
|
||||
{
|
||||
namespace anttweakbar
|
||||
{
|
||||
// Convert an unsigned char (like that from Cocoa apps) to AntTweakBar key
|
||||
// code.
|
||||
// See also: TranslateKey() in TwMgr.cpp in AntTweakBar source
|
||||
// Inputs:
|
||||
// key unsigned char key from keyboard
|
||||
// Returns int of new key code
|
||||
IGL_INLINE int cocoa_key_to_anttweakbar_key(int key);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "cocoa_key_to_anttweakbar_key.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,11 +1,12 @@
|
||||
// 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
|
||||
//
|
||||
// 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 "avg_edge_length.h"
|
||||
#include "edges.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
@@ -14,20 +15,19 @@ IGL_INLINE double igl::avg_edge_length(
|
||||
const Eigen::MatrixBase<DerivedV>& V,
|
||||
const Eigen::MatrixBase<DerivedF>& F)
|
||||
{
|
||||
double avg = 0;
|
||||
long int count = 0;
|
||||
typedef typename DerivedF::Scalar Index;
|
||||
Eigen::Matrix<Index, Eigen::Dynamic, 2> E;
|
||||
|
||||
// Augh. Technically this is double counting interior edges...
|
||||
for (unsigned i=0;i<F.rows();++i)
|
||||
igl::edges(F, E);
|
||||
|
||||
double avg = 0;
|
||||
|
||||
for (unsigned i=0;i<E.rows();++i)
|
||||
{
|
||||
for (unsigned j=0;j<F.cols();++j)
|
||||
{
|
||||
++count;
|
||||
avg += (V.row(F(i,j)) - V.row(F(i,(j+1)%F.cols()))).norm();
|
||||
}
|
||||
avg += (V.row(E(i,0)) - V.row(E(i,1))).norm();
|
||||
}
|
||||
|
||||
return avg / (double) count;
|
||||
return avg / (double) E.rows();
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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
|
||||
//
|
||||
// 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_AVERAGEEDGELENGTH_H
|
||||
#define IGL_AVERAGEEDGELENGTH_H
|
||||
@@ -13,7 +13,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace igl
|
||||
namespace igl
|
||||
{
|
||||
// Compute the average edge length for the given triangle mesh
|
||||
// Templates:
|
||||
|
||||
@@ -54,4 +54,6 @@ template void igl::barycenter<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::M
|
||||
template void igl::barycenter<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::barycenter<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::barycenter<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 2, 0, -1, 2> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> >&);
|
||||
template void igl::barycenter<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 2, 3, 0, 2, 3>, Eigen::Matrix<double, 2, 3, 0, 2, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, 2, 3, 0, 2, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 3, 0, 2, 3> >&);
|
||||
template void igl::barycenter<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, 2, 3, 0, 2, 3>, Eigen::Matrix<double, 2, 3, 0, 2, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, 2, 3, 0, 2, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 2, 3, 0, 2, 3> >&);
|
||||
#endif
|
||||
|
||||
@@ -118,7 +118,12 @@ IGL_INLINE bool igl::bbw(
|
||||
}
|
||||
W.col(i) = Wi;
|
||||
};
|
||||
#ifdef WIN32
|
||||
for (int i = 0; i < m; ++i)
|
||||
optimize_weight(i);
|
||||
#else
|
||||
parallel_for(m,optimize_weight,2);
|
||||
#endif
|
||||
if(error)
|
||||
{
|
||||
return false;
|
||||
|
||||
+118
-37
@@ -7,19 +7,127 @@
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "boundary_facets.h"
|
||||
#include "face_occurrences.h"
|
||||
|
||||
// IGL includes
|
||||
#include "list_to_matrix.h"
|
||||
#include "matrix_to_list.h"
|
||||
#include "sort.h"
|
||||
#include "unique_rows.h"
|
||||
#include "accumarray.h"
|
||||
#include "slice_mask.h"
|
||||
|
||||
#include <Eigen/Core>
|
||||
|
||||
// STL includes
|
||||
#include <map>
|
||||
#include <iostream>
|
||||
|
||||
template <
|
||||
typename DerivedT,
|
||||
typename DerivedF,
|
||||
typename DerivedJ,
|
||||
typename DerivedK>
|
||||
IGL_INLINE void igl::boundary_facets(
|
||||
const Eigen::MatrixBase<DerivedT>& T,
|
||||
Eigen::PlainObjectBase<DerivedF>& F,
|
||||
Eigen::PlainObjectBase<DerivedJ>& J,
|
||||
Eigen::PlainObjectBase<DerivedK>& K)
|
||||
{
|
||||
const int simplex_size = T.cols();
|
||||
// Handle boring base case
|
||||
if(T.rows() == 0)
|
||||
{
|
||||
F.resize(0,simplex_size-1);
|
||||
J.resize(0,1);
|
||||
K.resize(0,1);
|
||||
return;
|
||||
}
|
||||
// Get a list of all facets
|
||||
DerivedF allF(T.rows()*simplex_size,simplex_size-1);
|
||||
// Gather faces (e.g., loop over tets)
|
||||
for(int i = 0; i< (int)T.rows();i++)
|
||||
{
|
||||
switch(simplex_size)
|
||||
{
|
||||
case 4:
|
||||
// get face in correct order
|
||||
allF(i*simplex_size+0,0) = T(i,1);
|
||||
allF(i*simplex_size+0,1) = T(i,3);
|
||||
allF(i*simplex_size+0,2) = T(i,2);
|
||||
// get face in correct order
|
||||
allF(i*simplex_size+1,0) = T(i,0);
|
||||
allF(i*simplex_size+1,1) = T(i,2);
|
||||
allF(i*simplex_size+1,2) = T(i,3);
|
||||
// get face in correct order
|
||||
allF(i*simplex_size+2,0) = T(i,0);
|
||||
allF(i*simplex_size+2,1) = T(i,3);
|
||||
allF(i*simplex_size+2,2) = T(i,1);
|
||||
// get face in correct order
|
||||
allF(i*simplex_size+3,0) = T(i,0);
|
||||
allF(i*simplex_size+3,1) = T(i,1);
|
||||
allF(i*simplex_size+3,2) = T(i,2);
|
||||
break;
|
||||
case 3:
|
||||
allF(i*simplex_size+0,0) = T(i,1);
|
||||
allF(i*simplex_size+0,1) = T(i,2);
|
||||
allF(i*simplex_size+1,0) = T(i,2);
|
||||
allF(i*simplex_size+1,1) = T(i,0);
|
||||
allF(i*simplex_size+2,0) = T(i,0);
|
||||
allF(i*simplex_size+2,1) = T(i,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
DerivedF sortedF;
|
||||
igl::sort(allF,2,true,sortedF);
|
||||
Eigen::VectorXi m,n;
|
||||
{
|
||||
DerivedF _1;
|
||||
igl::unique_rows(sortedF,_1,m,n);
|
||||
}
|
||||
Eigen::VectorXi C;
|
||||
igl::accumarray(n,1,C);
|
||||
const int ones = (C.array()==1).count();
|
||||
// Resize output to fit number of non-twos
|
||||
F.resize(ones, allF.cols());
|
||||
J.resize(F.rows(),1);
|
||||
K.resize(F.rows(),1);
|
||||
int k = 0;
|
||||
for(int c = 0;c< (int)C.size();c++)
|
||||
{
|
||||
if(C(c) == 1)
|
||||
{
|
||||
const int i = m(c);
|
||||
assert(k<(int)F.rows());
|
||||
F.row(k) = allF.row(i);
|
||||
J(k) = i/simplex_size;
|
||||
K(k) = i%simplex_size;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
assert(k==(int)F.rows());
|
||||
}
|
||||
|
||||
template <typename DerivedT, typename DerivedF>
|
||||
IGL_INLINE void igl::boundary_facets(
|
||||
const Eigen::MatrixBase<DerivedT>& T,
|
||||
Eigen::PlainObjectBase<DerivedF>& F)
|
||||
{
|
||||
Eigen::VectorXi J,K;
|
||||
return boundary_facets(T,F,J,K);
|
||||
}
|
||||
|
||||
template <typename DerivedT, typename Ret>
|
||||
Ret igl::boundary_facets(
|
||||
const Eigen::MatrixBase<DerivedT>& T)
|
||||
{
|
||||
Ret F;
|
||||
igl::boundary_facets(T,F);
|
||||
return F;
|
||||
}
|
||||
|
||||
template <typename IntegerT, typename IntegerF>
|
||||
IGL_INLINE void igl::boundary_facets(
|
||||
const std::vector<std::vector<IntegerT> > & T,
|
||||
std::vector<std::vector<IntegerF> > & F)
|
||||
{
|
||||
// Kept for legacy reasons. Could probably just delete.
|
||||
using namespace std;
|
||||
|
||||
if(T.size() == 0)
|
||||
@@ -98,44 +206,17 @@ IGL_INLINE void igl::boundary_facets(
|
||||
|
||||
}
|
||||
|
||||
#include "list_to_matrix.h"
|
||||
#include "matrix_to_list.h"
|
||||
|
||||
template <typename DerivedT, typename DerivedF>
|
||||
IGL_INLINE void igl::boundary_facets(
|
||||
const Eigen::PlainObjectBase<DerivedT>& T,
|
||||
Eigen::PlainObjectBase<DerivedF>& F)
|
||||
{
|
||||
assert(T.cols() == 0 || T.cols() == 4 || T.cols() == 3);
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
// Cop out: use vector of vectors version
|
||||
vector<vector<typename DerivedT::Scalar> > vT;
|
||||
matrix_to_list(T,vT);
|
||||
vector<vector<typename DerivedF::Scalar> > vF;
|
||||
boundary_facets(vT,vF);
|
||||
list_to_matrix(vF,F);
|
||||
}
|
||||
|
||||
template <typename DerivedT, typename Ret>
|
||||
Ret igl::boundary_facets(
|
||||
const Eigen::PlainObjectBase<DerivedT>& T)
|
||||
{
|
||||
Ret F;
|
||||
igl::boundary_facets(T,F);
|
||||
return F;
|
||||
}
|
||||
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >&);
|
||||
template void igl::boundary_facets<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::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned int, -1, 3, 1, -1, 3> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::boundary_facets<int, 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> > > >&);
|
||||
//template Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > igl::boundary_facets(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
|
||||
template Eigen::Matrix<int, -1, -1, 0, -1, -1> igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
|
||||
template void igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
//template Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > igl::boundary_facets(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&);
|
||||
template Eigen::Matrix<int, -1, -1, 0, -1, -1> igl::boundary_facets<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&);
|
||||
template void igl::boundary_facets<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
#endif
|
||||
|
||||
@@ -18,31 +18,36 @@ namespace igl
|
||||
// BOUNDARY_FACETS Determine boundary faces (edges) of tetrahedra (triangles)
|
||||
// stored in T (analogous to qptoolbox's `outline` and `boundary_faces`).
|
||||
//
|
||||
// Templates:
|
||||
// IntegerT integer-value: e.g. int
|
||||
// IntegerF integer-value: e.g. int
|
||||
// Input:
|
||||
// T tetrahedron (triangle) index list, m by 4 (3), where m is the number of tetrahedra
|
||||
// Output:
|
||||
// F list of boundary faces, n by 3 (2), where n is the number of boundary faces
|
||||
// J list of indices into T, n by 1
|
||||
// K list of indices revealing across from which vertex is this facet
|
||||
//
|
||||
//
|
||||
template <typename IntegerT, typename IntegerF>
|
||||
template <
|
||||
typename DerivedT,
|
||||
typename DerivedF,
|
||||
typename DerivedJ,
|
||||
typename DerivedK>
|
||||
IGL_INLINE void boundary_facets(
|
||||
const std::vector<std::vector<IntegerT> > & T,
|
||||
std::vector<std::vector<IntegerF> > & F);
|
||||
|
||||
// Templates:
|
||||
// DerivedT integer-value: i.e. from MatrixXi
|
||||
// DerivedF integer-value: i.e. from MatrixXi
|
||||
const Eigen::MatrixBase<DerivedT>& T,
|
||||
Eigen::PlainObjectBase<DerivedF>& F,
|
||||
Eigen::PlainObjectBase<DerivedJ>& J,
|
||||
Eigen::PlainObjectBase<DerivedK>& K);
|
||||
template <typename DerivedT, typename DerivedF>
|
||||
IGL_INLINE void boundary_facets(
|
||||
const Eigen::PlainObjectBase<DerivedT>& T,
|
||||
const Eigen::MatrixBase<DerivedT>& T,
|
||||
Eigen::PlainObjectBase<DerivedF>& F);
|
||||
// Same as above but returns F
|
||||
template <typename DerivedT, typename Ret>
|
||||
Ret boundary_facets(
|
||||
const Eigen::PlainObjectBase<DerivedT>& T);
|
||||
const Eigen::MatrixBase<DerivedT>& T);
|
||||
template <typename IntegerT, typename IntegerF>
|
||||
IGL_INLINE void boundary_facets(
|
||||
const std::vector<std::vector<IntegerT> > & T,
|
||||
std::vector<std::vector<IntegerF> > & F);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
template <typename DerivedF, typename Index>
|
||||
IGL_INLINE void igl::boundary_loop(
|
||||
const Eigen::PlainObjectBase<DerivedF> & F,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
std::vector<std::vector<Index> >& L)
|
||||
{
|
||||
using namespace std;
|
||||
@@ -91,7 +91,7 @@ IGL_INLINE void igl::boundary_loop(
|
||||
|
||||
template <typename DerivedF, typename Index>
|
||||
IGL_INLINE void igl::boundary_loop(
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::MatrixBase<DerivedF>& F,
|
||||
std::vector<Index>& L)
|
||||
{
|
||||
using namespace Eigen;
|
||||
@@ -130,7 +130,7 @@ IGL_INLINE void igl::boundary_loop(
|
||||
|
||||
template <typename DerivedF, typename DerivedL>
|
||||
IGL_INLINE void igl::boundary_loop(
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::MatrixBase<DerivedF>& F,
|
||||
Eigen::PlainObjectBase<DerivedL>& L)
|
||||
{
|
||||
using namespace Eigen;
|
||||
@@ -149,5 +149,6 @@ IGL_INLINE void igl::boundary_loop(
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::boundary_loop<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::boundary_loop<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::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::boundary_loop<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> > > >&);
|
||||
#endif
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace igl
|
||||
//
|
||||
template <typename DerivedF, typename Index>
|
||||
IGL_INLINE void boundary_loop(
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::MatrixBase<DerivedF>& F,
|
||||
std::vector<std::vector<Index> >& L);
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace igl
|
||||
//
|
||||
template <typename DerivedF, typename Index>
|
||||
IGL_INLINE void boundary_loop(
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::MatrixBase<DerivedF>& F,
|
||||
std::vector<Index>& L);
|
||||
|
||||
// Compute ordered boundary loops for a manifold mesh and return the
|
||||
@@ -56,7 +56,7 @@ namespace igl
|
||||
//
|
||||
template <typename DerivedF, typename DerivedL>
|
||||
IGL_INLINE void boundary_loop(
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::MatrixBase<DerivedF>& F,
|
||||
Eigen::PlainObjectBase<DerivedL>& L);
|
||||
}
|
||||
|
||||
|
||||
+80
-11
@@ -1,9 +1,9 @@
|
||||
// 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
|
||||
//
|
||||
// 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 "cat.h"
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
#include <unsupported/Eigen/SparseExtra>
|
||||
|
||||
|
||||
// Sparse matrices need to be handled carefully. Because C++ does not
|
||||
// Sparse matrices need to be handled carefully. Because C++ does not
|
||||
// Template:
|
||||
// Scalar sparse matrix scalar type, e.g. double
|
||||
template <typename Scalar>
|
||||
IGL_INLINE void igl::cat(
|
||||
const int dim,
|
||||
const Eigen::SparseMatrix<Scalar> & A,
|
||||
const Eigen::SparseMatrix<Scalar> & B,
|
||||
const int dim,
|
||||
const Eigen::SparseMatrix<Scalar> & A,
|
||||
const Eigen::SparseMatrix<Scalar> & B,
|
||||
Eigen::SparseMatrix<Scalar> & C)
|
||||
{
|
||||
|
||||
@@ -108,13 +108,13 @@ IGL_INLINE void igl::cat(
|
||||
|
||||
}
|
||||
|
||||
C = SparseMatrix<Scalar>(
|
||||
C = SparseMatrix<Scalar>(
|
||||
dim == 1 ? A.rows()+B.rows() : A.rows(),
|
||||
dim == 1 ? A.cols() : A.cols()+B.cols());
|
||||
C.reserve(A.nonZeros() + B.nonZeros());
|
||||
C.setFromTriplets(CIJV.begin(),CIJV.end());
|
||||
#else
|
||||
C = SparseMatrix<Scalar>(
|
||||
C = SparseMatrix<Scalar>(
|
||||
dim == 1 ? A.rows()+B.rows() : A.rows(),
|
||||
dim == 1 ? A.cols() : A.cols()+B.cols());
|
||||
Eigen::VectorXi per_col = Eigen::VectorXi::Zero(C.cols());
|
||||
@@ -189,7 +189,7 @@ IGL_INLINE void igl::cat(
|
||||
template <typename Derived, class MatC>
|
||||
IGL_INLINE void igl::cat(
|
||||
const int dim,
|
||||
const Eigen::MatrixBase<Derived> & A,
|
||||
const Eigen::MatrixBase<Derived> & A,
|
||||
const Eigen::MatrixBase<Derived> & B,
|
||||
MatC & C)
|
||||
{
|
||||
@@ -251,6 +251,65 @@ IGL_INLINE void igl::cat(const std::vector<std::vector< Mat > > & A, Mat & C)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, typename DerivedC>
|
||||
IGL_INLINE void igl::cat(const int dim, const std::vector<T> & A, Eigen::PlainObjectBase<DerivedC> & C)
|
||||
{
|
||||
assert(dim == 1 || dim == 2);
|
||||
using namespace Eigen;
|
||||
|
||||
const int num_mat = A.size();
|
||||
if(num_mat == 0)
|
||||
{
|
||||
C.resize(0,0);
|
||||
return;
|
||||
}
|
||||
|
||||
if(dim == 1)
|
||||
{
|
||||
const int A_cols = A[0].cols();
|
||||
|
||||
int tot_rows = 0;
|
||||
for(const auto & m : A)
|
||||
{
|
||||
tot_rows += m.rows();
|
||||
}
|
||||
|
||||
C.resize(tot_rows, A_cols);
|
||||
|
||||
int cur_row = 0;
|
||||
for(int i = 0; i < num_mat; i++)
|
||||
{
|
||||
assert(A_cols == A[i].cols());
|
||||
C.block(cur_row,0,A[i].rows(),A_cols) = A[i];
|
||||
cur_row += A[i].rows();
|
||||
}
|
||||
}
|
||||
else if(dim == 2)
|
||||
{
|
||||
const int A_rows = A[0].rows();
|
||||
|
||||
int tot_cols = 0;
|
||||
for(const auto & m : A)
|
||||
{
|
||||
tot_cols += m.cols();
|
||||
}
|
||||
|
||||
C.resize(A_rows,tot_cols);
|
||||
|
||||
int cur_col = 0;
|
||||
for(int i = 0; i < num_mat; i++)
|
||||
{
|
||||
assert(A_rows == A[i].rows());
|
||||
C.block(0,cur_col,A_rows,A[i].cols()) = A[i];
|
||||
cur_col += A[i].cols();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"cat.h: Error: Unsupported dimension %d\n",dim);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
@@ -264,4 +323,14 @@ template Eigen::Matrix<int, -1, 1, 0, -1, 1> igl::cat<Eigen::Matrix<int, -1, 1,
|
||||
template Eigen::Matrix<double, -1, 1, 0, -1, 1> igl::cat<Eigen::Matrix<double, -1, 1, 0, -1, 1> >(int, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&);
|
||||
template void igl::cat<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(int, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
|
||||
template void igl::cat<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::Matrix<int, -1, -1, 0, -1, -1>&);
|
||||
template void igl::cat<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::Matrix<int, -1, 1, 0, -1, 1>&);
|
||||
template void igl::cat<Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<int, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<int, -1, -1, 0, -1, -1> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<int, 1, 4, 1, 1, 4>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<int, 1, 4, 1, 1, 4>, std::allocator<Eigen::Matrix<int, 1, 4, 1, 1, 4> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<int, 1, 15, 1, 1, 15>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<int, 1, 15, 1, 1, 15>, std::allocator<Eigen::Matrix<int, 1, 15, 1, 1, 15> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<int, 1, 2, 1, 1, 2>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<int, 1, 2, 1, 1, 2>, std::allocator<Eigen::Matrix<int, 1, 2, 1, 1, 2> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<int, 1, 27, 1, 1, 27>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<int, 1, 27, 1, 1, 27>, std::allocator<Eigen::Matrix<int, 1, 27, 1, 1, 27> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<int, 1, 3, 1, 1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<int, 1, 3, 1, 1, 3>, std::allocator<Eigen::Matrix<int, 1, 3, 1, 1, 3> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<int, 3, 1, 0, 3, 1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<int, 3, 1, 0, 3, 1>, std::allocator<Eigen::Matrix<int, 3, 1, 0, 3, 1> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<double, 1, 3, 1, 1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<double, 1, 3, 1, 1, 3>, std::allocator<Eigen::Matrix<double, 1, 3, 1, 1, 3> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cat<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(int, std::vector<Eigen::Matrix<double, 3, 1, 0, 3, 1>, std::allocator<Eigen::Matrix<double, 3, 1, 0, 3, 1> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
|
||||
@@ -62,6 +62,16 @@ namespace igl
|
||||
// C
|
||||
template <class Mat>
|
||||
IGL_INLINE void cat(const std::vector<std::vector< Mat > > & A, Mat & C);
|
||||
|
||||
// Concatenate a std::vector of matrices along the specified dimension
|
||||
//
|
||||
// Inputs:
|
||||
// dim dimension along which to concatenate, 1 or 2
|
||||
// A std::vector of eigen matrices. Must have identical # cols if dim == 1 or rows if dim == 2
|
||||
// Outputs:
|
||||
// C output matrix
|
||||
template <typename T, typename DerivedC>
|
||||
IGL_INLINE void cat(const int dim, const std::vector<T> & A, Eigen::PlainObjectBase<DerivedC> & C);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
|
||||
@@ -64,4 +64,5 @@ IGL_INLINE void igl::centroid(
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::centroid<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<float, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> >&);
|
||||
template void igl::centroid<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
|
||||
template void igl::centroid<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 1, 3, 1, 1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 3, 1, 1, 3> >&);
|
||||
#endif
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
// obtain one at http://mozilla.org/MPL/2.0/.
|
||||
#include "circulation.h"
|
||||
#include "list_to_matrix.h"
|
||||
#include <cassert>
|
||||
|
||||
IGL_INLINE std::vector<int> igl::circulation(
|
||||
const int e,
|
||||
const bool ccw,
|
||||
const Eigen::MatrixXi & F,
|
||||
const Eigen::MatrixXi & E,
|
||||
const Eigen::VectorXi & EMAP,
|
||||
const Eigen::MatrixXi & EF,
|
||||
const Eigen::MatrixXi & EI)
|
||||
@@ -20,7 +19,8 @@ IGL_INLINE std::vector<int> igl::circulation(
|
||||
// prepare output
|
||||
std::vector<int> N;
|
||||
N.reserve(6);
|
||||
const int m = F.rows();
|
||||
const int m = EMAP.size()/3;
|
||||
assert(m*3 == EMAP.size());
|
||||
const auto & step = [&](
|
||||
const int e,
|
||||
const int ff,
|
||||
@@ -59,13 +59,11 @@ IGL_INLINE std::vector<int> igl::circulation(
|
||||
IGL_INLINE void igl::circulation(
|
||||
const int e,
|
||||
const bool ccw,
|
||||
const Eigen::MatrixXi & F,
|
||||
const Eigen::MatrixXi & E,
|
||||
const Eigen::VectorXi & EMAP,
|
||||
const Eigen::MatrixXi & EF,
|
||||
const Eigen::MatrixXi & EI,
|
||||
Eigen::VectorXi & vN)
|
||||
{
|
||||
std::vector<int> N = circulation(e,ccw,F,E,EMAP,EF,EI);
|
||||
std::vector<int> N = circulation(e,ccw,EMAP,EF,EI);
|
||||
igl::list_to_matrix(N,vN);
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ namespace igl
|
||||
// e index into E of edge to circulate
|
||||
// ccw whether to _continue_ in ccw direction of edge (circulate around
|
||||
// E(e,1))
|
||||
// F #F by 3 list of face indices
|
||||
// E #E by 2 list of edge indices
|
||||
// EMAP #F*3 list of indices into E, mapping each directed edge to unique
|
||||
// unique edge in E
|
||||
// EF #E by 2 list of edge flaps, EF(e,0)=f means e=(i-->j) is the edge of
|
||||
@@ -30,11 +28,10 @@ namespace igl
|
||||
// EI #E by 2 list of edge flap corners (see above).
|
||||
// Returns list of faces touched by circulation (in cyclically order).
|
||||
//
|
||||
// See also: edge_flaps
|
||||
IGL_INLINE std::vector<int> circulation(
|
||||
const int e,
|
||||
const bool ccw,
|
||||
const Eigen::MatrixXi & F,
|
||||
const Eigen::MatrixXi & E,
|
||||
const Eigen::VectorXi & EMAP,
|
||||
const Eigen::MatrixXi & EF,
|
||||
const Eigen::MatrixXi & EI);
|
||||
@@ -42,8 +39,6 @@ namespace igl
|
||||
IGL_INLINE void circulation(
|
||||
const int e,
|
||||
const bool ccw,
|
||||
const Eigen::MatrixXi & F,
|
||||
const Eigen::MatrixXi & E,
|
||||
const Eigen::VectorXi & EMAP,
|
||||
const Eigen::MatrixXi & EF,
|
||||
const Eigen::MatrixXi & EI,
|
||||
|
||||
@@ -40,7 +40,7 @@ IGL_INLINE bool igl::collapse_edge(
|
||||
}
|
||||
|
||||
// Important to grab neighbors of d before monkeying with edges
|
||||
const std::vector<int> nV2Fd = circulation(e,!eflip,F,E,EMAP,EF,EI);
|
||||
const std::vector<int> nV2Fd = circulation(e,!eflip,EMAP,EF,EI);
|
||||
|
||||
// The following implementation strongly relies on s<d
|
||||
assert(s<d && "s should be less than d");
|
||||
@@ -339,8 +339,8 @@ IGL_INLINE bool igl::collapse_edge(
|
||||
Q.erase(Q.begin());
|
||||
e = p.second;
|
||||
Qit[e] = Q.end();
|
||||
std::vector<int> N = circulation(e, true,F,E,EMAP,EF,EI);
|
||||
std::vector<int> Nd = circulation(e,false,F,E,EMAP,EF,EI);
|
||||
std::vector<int> N = circulation(e, true,EMAP,EF,EI);
|
||||
std::vector<int> Nd = circulation(e,false,EMAP,EF,EI);
|
||||
N.insert(N.begin(),Nd.begin(),Nd.end());
|
||||
bool collapsed = true;
|
||||
if(pre_collapse(V,F,E,EMAP,EF,EI,Q,Qit,C,e))
|
||||
|
||||
@@ -37,9 +37,9 @@ namespace igl
|
||||
// e=(j->i)
|
||||
// EI #E by 2 list of edge flap corners (see above).
|
||||
// e1 index into E of edge collpased on left
|
||||
// e2 index into E of edge collpased on left
|
||||
// f1 index into E of edge collpased on left
|
||||
// f2 index into E of edge collpased on left
|
||||
// e2 index into E of edge collpased on right
|
||||
// f1 index into F of face collpased on left
|
||||
// f2 index into F of face collpased on right
|
||||
// Returns true if edge was collapsed
|
||||
#define IGL_COLLAPSE_EDGE_NULL 0
|
||||
IGL_INLINE bool collapse_edge(
|
||||
|
||||
@@ -59,8 +59,10 @@ template void igl::colon<int, double, double, double>(int, double, double, Eigen
|
||||
template void igl::colon<double, double, double>(double, double, Eigen::Matrix<double, -1, 1, 0, -1, 1>&);
|
||||
template void igl::colon<double, double, double, double>(double, double, double, Eigen::Matrix<double, -1, 1, 0, -1, 1>&);
|
||||
template void igl::colon<int, int, long>(int, int, Eigen::Matrix<long, -1, 1, 0, -1, 1>&);
|
||||
template void igl::colon<int, long, double>(int, long, Eigen::Matrix<double, -1, 1, 0, -1, 1>&);
|
||||
#ifdef WIN32
|
||||
template void igl::colon<int, long long,long>(int, long long, class Eigen::Matrix<long,-1,1,0,-1,1> &);
|
||||
template void igl::colon<int, __int64, __int64>(int, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1> &);
|
||||
template void igl::colon<int,__int64,double>(int,__int64,class Eigen::Matrix<double,-1,1,0,-1,1> &);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -86,35 +86,42 @@ namespace igl {
|
||||
|
||||
std::deque<int> d;
|
||||
|
||||
d.push_back(0);
|
||||
mark(0) = true;
|
||||
|
||||
while (!d.empty())
|
||||
while (!mark.all()) // Stop until all vertices are marked
|
||||
{
|
||||
int f0 = d.at(0);
|
||||
d.pop_front();
|
||||
for (int k=0; k<3; k++)
|
||||
int unmarked = 0;
|
||||
while (mark(unmarked))
|
||||
unmarked++;
|
||||
|
||||
d.push_back(unmarked);
|
||||
mark(unmarked) = true;
|
||||
|
||||
while (!d.empty())
|
||||
{
|
||||
int f1 = TT(f0,k);
|
||||
if (f1==-1) continue;
|
||||
if (mark(f1)) continue;
|
||||
int f0 = d.at(0);
|
||||
d.pop_front();
|
||||
for (int k=0; k<3; k++)
|
||||
{
|
||||
int f1 = TT(f0,k);
|
||||
if (f1==-1) continue;
|
||||
if (mark(f1)) continue;
|
||||
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0 = PD1out.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1out.row(f1);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0 = N.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1 = N.row(f1);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0 = PD1out.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1out.row(f1);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0 = N.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1 = N.row(f1);
|
||||
|
||||
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0Rot = igl::rotation_matrix_from_directions(n0, n1)*dir0;
|
||||
dir0Rot.normalize();
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> targD = K_PI_new(dir1,dir0Rot,n1);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0Rot = igl::rotation_matrix_from_directions(n0, n1)*dir0;
|
||||
dir0Rot.normalize();
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> targD = K_PI_new(dir1,dir0Rot,n1);
|
||||
|
||||
PD1out.row(f1) = targD;
|
||||
PD2out.row(f1) = n1.cross(targD).normalized();
|
||||
PD1out.row(f1) = targD;
|
||||
PD2out.row(f1) = n1.cross(targD).normalized();
|
||||
|
||||
mark(f1) = true;
|
||||
d.push_back(f1);
|
||||
mark(f1) = true;
|
||||
d.push_back(f1);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -69,10 +69,6 @@ IGL_INLINE void igl::comb_frame_field(const Eigen::PlainObjectBase<DerivedV> &V,
|
||||
PD2_combed.row(i) = DIRs.row(M);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// PD1_combed = BIS1_combed;
|
||||
// PD2_combed = BIS2_combed;
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
|
||||
@@ -90,6 +90,7 @@ IGL_INLINE void igl::combine(
|
||||
// Explicit template instantiation
|
||||
template void igl::combine<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<int, -1, -1, 0, -1, -1>, Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1>, Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >(std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const&, std::vector<Eigen::Matrix<int, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<int, -1, -1, 0, -1, -1> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::combine<Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3>, Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(std::vector<Eigen::Matrix<double, -1, 3, 1, -1, 3>, std::allocator<Eigen::Matrix<double, -1, 3, 1, -1, 3> > > const&, std::vector<Eigen::Matrix<int, -1, 3, 1, -1, 3>, std::allocator<Eigen::Matrix<int, -1, 3, 1, -1, 3> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
template void igl::combine<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<int, -1, -1, 0, -1, -1> >(std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const&, std::vector<Eigen::Matrix<int, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<int, -1, -1, 0, -1, -1> > > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
#ifdef WIN32
|
||||
template void igl::combine<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<int,-1,-1,0,-1,-1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> >(class std::vector<Eigen::Matrix<double,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<double,-1,-1,0,-1,-1> > > const &,class std::vector<Eigen::Matrix<int,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<int,-1,-1,0,-1,-1> > > const &,Eigen::PlainObjectBase<Eigen::Matrix<double,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &);
|
||||
template void igl::combine<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<int,-1,-1,0,-1,-1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1>,Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> >(class std::vector<Eigen::Matrix<double,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<double,-1,-1,0,-1,-1> > > const &,class std::vector<Eigen::Matrix<int,-1,-1,0,-1,-1>,class std::allocator<Eigen::Matrix<int,-1,-1,0,-1,-1> > > const &,Eigen::PlainObjectBase<Eigen::Matrix<double,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<int,-1,-1,0,-1,-1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &,Eigen::PlainObjectBase<Eigen::Matrix<unsigned __int64,-1,1,0,-1,1> > &);
|
||||
|
||||
@@ -82,4 +82,5 @@ IGL_INLINE void igl::compute_frame_field_bisectors(
|
||||
// Explicit template instantiation
|
||||
template void igl::compute_frame_field_bisectors<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::compute_frame_field_bisectors<Eigen::Matrix<double, -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&, 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> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::compute_frame_field_bisectors<Eigen::Matrix<double, -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&, 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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
|
||||
@@ -24,20 +24,48 @@ IGL_INLINE void igl::copyleft::cgal::convex_hull(
|
||||
Eigen::PlainObjectBase<DerivedG> & G)
|
||||
{
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
|
||||
typedef K::Point_3 Point_3;
|
||||
//typedef CGAL::Delaunay_triangulation_3<K> Delaunay;
|
||||
//typedef Delaunay::Vertex_handle Vertex_handle;
|
||||
//typedef CGAL::Surface_mesh<Point_3> Surface_mesh;
|
||||
typedef CGAL::Polyhedron_3<K> Polyhedron_3;
|
||||
std::vector<Point_3> points(V.rows());
|
||||
for(int i = 0;i<V.rows();i++)
|
||||
switch(V.cols())
|
||||
{
|
||||
points[i] = Point_3(V(i,0),V(i,1),V(i,2));
|
||||
case 3:
|
||||
{
|
||||
typedef K::Point_3 Point_3;
|
||||
//typedef CGAL::Delaunay_triangulation_3<K> Delaunay;
|
||||
//typedef Delaunay::Vertex_handle Vertex_handle;
|
||||
//typedef CGAL::Surface_mesh<Point_3> Surface_mesh;
|
||||
typedef CGAL::Polyhedron_3<K> Polyhedron_3;
|
||||
std::vector<Point_3> points(V.rows());
|
||||
for(int i = 0;i<V.rows();i++)
|
||||
{
|
||||
points[i] = Point_3(V(i,0),V(i,1),V(i,2));
|
||||
}
|
||||
Polyhedron_3 poly;
|
||||
CGAL::convex_hull_3(points.begin(),points.end(),poly);
|
||||
assert(poly.is_pure_triangle() && "Assuming CGAL outputs a triangle mesh");
|
||||
polyhedron_to_mesh(poly,W,G);
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
typedef K::Point_2 Point_2;
|
||||
std::vector<Point_2> points(V.rows());
|
||||
std::vector<Point_2> result;
|
||||
for(int i = 0;i<V.rows();i++)
|
||||
{
|
||||
points[i] = Point_2(V(i,0),V(i,1));
|
||||
}
|
||||
CGAL::convex_hull_2(points.begin(),points.end(),std::back_inserter(result));
|
||||
W.resize(result.size(),2);
|
||||
G.resize(result.size(),2);
|
||||
for(int i = 0;i<result.size();i++)
|
||||
{
|
||||
W(i,0) = result[i].x();
|
||||
W(i,1) = result[i].y();
|
||||
G(i,0) = i;
|
||||
G(i,1) = (i+1)%result.size();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
Polyhedron_3 poly;
|
||||
CGAL::convex_hull_3(points.begin(),points.end(),poly);
|
||||
assert(poly.is_pure_triangle() && "Assuming CGAL outputs a triangle mesh");
|
||||
polyhedron_to_mesh(poly,W,G);
|
||||
}
|
||||
|
||||
template <
|
||||
@@ -69,4 +97,6 @@ IGL_INLINE void igl::copyleft::cgal::convex_hull(
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::copyleft::cgal::convex_hull<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::cgal::convex_hull<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::cgal::convex_hull<Eigen::Matrix<double, -1, 2, 0, -1, 2>, Eigen::Matrix<double, -1, 2, 0, -1, 2>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 2, 0, -1, 2> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
|
||||
@@ -16,7 +16,7 @@ template<
|
||||
typename DerivedV,
|
||||
typename DerivedF>
|
||||
IGL_INLINE void igl::copyleft::cgal::delaunay_triangulation(
|
||||
const Eigen::PlainObjectBase<DerivedV>& V,
|
||||
const Eigen::MatrixBase<DerivedV>& V,
|
||||
Eigen::PlainObjectBase<DerivedF>& F)
|
||||
{
|
||||
typedef typename DerivedV::Scalar Scalar;
|
||||
@@ -60,3 +60,8 @@ IGL_INLINE void igl::copyleft::cgal::delaunay_triangulation(
|
||||
// };
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::copyleft::cgal::delaunay_triangulation<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace igl
|
||||
typename DerivedF
|
||||
>
|
||||
IGL_INLINE void delaunay_triangulation(
|
||||
const Eigen::PlainObjectBase<DerivedV>& V,
|
||||
const Eigen::MatrixBase<DerivedV>& V,
|
||||
Eigen::PlainObjectBase<DerivedF>& F);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2015 Qingnan Zhou <qnzhou@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
|
||||
//
|
||||
// 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 "extract_cells.h"
|
||||
@@ -56,7 +56,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
igl::copyleft::cgal::extract_cells(V,F,P,E,uE,uE2E,EMAP,per_patch_cells);
|
||||
// Distribute per-patch cell information to each face
|
||||
cells.resize(num_faces, 2);
|
||||
for (size_t i=0; i<num_faces; i++)
|
||||
for (size_t i=0; i<num_faces; i++)
|
||||
{
|
||||
cells.row(i) = per_patch_cells.row(P[i]);
|
||||
}
|
||||
@@ -81,7 +81,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
const Eigen::PlainObjectBase<DeriveduE>& uE,
|
||||
const std::vector<std::vector<uE2EType> >& uE2E,
|
||||
const Eigen::PlainObjectBase<DerivedEMAP>& EMAP,
|
||||
Eigen::PlainObjectBase<DerivedC>& cells)
|
||||
Eigen::PlainObjectBase<DerivedC>& cells)
|
||||
{
|
||||
// Trivial base case
|
||||
if(P.size() == 0)
|
||||
@@ -143,7 +143,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
// components[c] --> list of face indices into F of faces in component c
|
||||
std::vector<std::vector<size_t> > components(num_components);
|
||||
// Loop over all faces
|
||||
for (size_t i=0; i<num_faces; i++)
|
||||
for (size_t i=0; i<num_faces; i++)
|
||||
{
|
||||
components[C[i]].push_back(i);
|
||||
}
|
||||
@@ -155,11 +155,11 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
std::vector<
|
||||
CGAL::AABB_tree<
|
||||
CGAL::AABB_traits<
|
||||
Kernel,
|
||||
Kernel,
|
||||
CGAL::AABB_triangle_primitive<
|
||||
Kernel, std::vector<
|
||||
Kernel::Triangle_3 >::iterator > > > > trees(num_components);
|
||||
std::vector< std::vector<Kernel::Triangle_3 > >
|
||||
std::vector< std::vector<Kernel::Triangle_3 > >
|
||||
triangle_lists(num_components);
|
||||
std::vector<std::vector<bool> > in_Is(num_components);
|
||||
|
||||
@@ -185,7 +185,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
// Inputs:
|
||||
// fid index into F
|
||||
// Returns row-vector of barycenter coordinates
|
||||
const auto get_triangle_center = [&V,&F](const size_t fid)
|
||||
const auto get_triangle_center = [&V,&F](const size_t fid)
|
||||
{
|
||||
return ((V.row(F(fid,0))+V.row(F(fid,1))+V.row(F(fid,2)))/3.0).eval();
|
||||
};
|
||||
@@ -193,7 +193,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
std::vector<std::vector<size_t> > ambient_cells(num_raw_cells);
|
||||
std::vector<std::vector<size_t> > ambient_comps(num_components);
|
||||
// Only bother if there's more than one component
|
||||
if(num_components > 1)
|
||||
if(num_components > 1)
|
||||
{
|
||||
// construct bounding boxes for each component
|
||||
DerivedV bbox_min(num_components, 3);
|
||||
@@ -207,7 +207,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
// component of this face
|
||||
const auto comp_id = C[i];
|
||||
const auto& f = F.row(i);
|
||||
for (size_t j=0; j<3; j++)
|
||||
for (size_t j=0; j<3; j++)
|
||||
{
|
||||
for(size_t d=0;d<3;d++)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
bbox_max(cj,1) < bbox_min(ci,1) ||
|
||||
bbox_max(cj,2) < bbox_min(ci,2));
|
||||
};
|
||||
|
||||
|
||||
// Loop over components. This section is O(m²)
|
||||
for (size_t i=0; i<num_components; i++)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
std::vector<size_t> candidate_comps;
|
||||
candidate_comps.reserve(num_components);
|
||||
// Loop over components
|
||||
for (size_t j=0; j<num_components; j++)
|
||||
for (size_t j=0; j<num_components; j++)
|
||||
{
|
||||
if (i == j) continue;
|
||||
if (bbox_intersects(i,j)) candidate_comps.push_back(j);
|
||||
@@ -248,7 +248,7 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
submesh_aabb_tree(V,F,Is[i],trees[i],triangle_lists[i],in_Is[i]);
|
||||
|
||||
// Get query points on each candidate component: barycenter of
|
||||
// outer-facet
|
||||
// outer-facet
|
||||
DerivedV queries(num_candidate_comps, 3);
|
||||
for (size_t j=0; j<num_candidate_comps; j++)
|
||||
{
|
||||
@@ -266,17 +266,17 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells(
|
||||
Eigen::VectorXi closest_facets, closest_facet_orientations;
|
||||
closest_facet(
|
||||
V,
|
||||
F,
|
||||
I,
|
||||
F,
|
||||
I,
|
||||
queries,
|
||||
uE2E,
|
||||
EMAP,
|
||||
uE2E,
|
||||
EMAP,
|
||||
VF,
|
||||
VFi,
|
||||
tree,
|
||||
triangles,
|
||||
in_I,
|
||||
closest_facets,
|
||||
closest_facets,
|
||||
closest_facet_orientations);
|
||||
// Loop over all candidates
|
||||
for (size_t j=0; j<num_candidate_comps; j++)
|
||||
@@ -402,13 +402,13 @@ IGL_INLINE size_t igl::copyleft::cgal::extract_cells_single_component(
|
||||
};
|
||||
// Determine if a face (containing undirected edge {s,d} is consistently
|
||||
// oriented with directed edge {s,d} (or otherwise it is with {d,s})
|
||||
//
|
||||
//
|
||||
// Inputs:
|
||||
// fid face index into F
|
||||
// s source index of edge
|
||||
// d destination index of edge
|
||||
// Returns true if face F(fid,:) is consistent with {s,d}
|
||||
const auto is_consistent =
|
||||
const auto is_consistent =
|
||||
[&F](const size_t fid, const size_t s, const size_t d) -> bool
|
||||
{
|
||||
if ((size_t)F(fid, 0) == s && (size_t)F(fid, 1) == d) return false;
|
||||
@@ -543,5 +543,6 @@ template unsigned long igl::copyleft::cgal::extract_cells<Eigen::Matrix<CGAL::La
|
||||
template unsigned __int64 igl::copyleft::cgal::extract_cells<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, unsigned __int64, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class std::vector<class std::vector<unsigned __int64, class std::allocator<unsigned __int64>>, class std::allocator<class std::vector<unsigned __int64, class std::allocator<unsigned __int64>>>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &);
|
||||
template unsigned __int64 igl::copyleft::cgal::extract_cells<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, unsigned __int64, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class std::vector<class std::vector<unsigned __int64, class std::allocator<unsigned __int64>>, class std::allocator<class std::vector<unsigned __int64, class std::allocator<unsigned __int64>>>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &);
|
||||
template unsigned __int64 igl::copyleft::cgal::extract_cells<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, 3, 1, -1, 3>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, unsigned __int64, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 3, 1, -1, 3>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class std::vector<class std::vector<unsigned __int64, class std::allocator<unsigned __int64>>, class std::allocator<class std::vector<unsigned __int64, class std::allocator<unsigned __int64>>>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &);
|
||||
template unsigned __int64 igl::copyleft::cgal::extract_cells<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1> >(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > &);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -41,4 +41,4 @@ IGL_INLINE void igl::copyleft::cgal::hausdorff(
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::copyleft::cgal::hausdorff<Eigen::Matrix<double, -1, -1, 0, -1, -1>, CGAL::Simple_cartesian<double>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, CGAL::AABB_tree<CGAL::AABB_traits<CGAL::Simple_cartesian<double>, CGAL::AABB_triangle_primitive<CGAL::Simple_cartesian<double>, std::vector<CGAL::Triangle_3<CGAL::Simple_cartesian<double> >, std::allocator<CGAL::Triangle_3<CGAL::Simple_cartesian<double> > > >::iterator, CGAL::Boolean_tag<false> >, CGAL::Default> > const&, std::vector<CGAL::Triangle_3<CGAL::Simple_cartesian<double> >, std::allocator<CGAL::Triangle_3<CGAL::Simple_cartesian<double> > > > const&, double&, double&);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2016 Qingan Zhou <qnzhou@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
|
||||
//
|
||||
// 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 "incircle.h"
|
||||
@@ -12,10 +12,10 @@
|
||||
|
||||
template<typename Scalar>
|
||||
IGL_INLINE short igl::copyleft::cgal::incircle(
|
||||
const Scalar pa[2],
|
||||
const Scalar pb[2],
|
||||
const Scalar pc[2],
|
||||
const Scalar pd[2])
|
||||
const Scalar *pa,
|
||||
const Scalar *pb,
|
||||
const Scalar *pc,
|
||||
const Scalar *pd)
|
||||
{
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck;
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick;
|
||||
@@ -37,3 +37,12 @@ IGL_INLINE short igl::copyleft::cgal::incircle(
|
||||
throw "Invalid incircle result";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template short igl::copyleft::cgal::incircle<double>(double const*, double const*, double const*, double const*);
|
||||
#ifdef WIN32
|
||||
template short igl::copyleft::cgal::incircle<double>(double const * const,double const * const,double const * const,double const * const);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2016 Qingan Zhou <qnzhou@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
|
||||
//
|
||||
// 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_COPYLEFT_CGAL_INCIRCLE_H
|
||||
@@ -25,10 +25,10 @@ namespace igl
|
||||
// -1 if pd is outside of the oriented circle formed by pa,pb,pc.
|
||||
template <typename Scalar>
|
||||
IGL_INLINE short incircle(
|
||||
const Scalar pa[2],
|
||||
const Scalar pb[2],
|
||||
const Scalar pc[2],
|
||||
const Scalar pd[2]);
|
||||
const Scalar *pa,
|
||||
const Scalar *pb,
|
||||
const Scalar *pc,
|
||||
const Scalar *pd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,14 @@
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
#include <CGAL/Polyhedron_incremental_builder_3.h>
|
||||
|
||||
|
||||
template <typename Polyhedron>
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename Polyhedron>
|
||||
IGL_INLINE bool igl::copyleft::cgal::mesh_to_polyhedron(
|
||||
const Eigen::MatrixXd & V,
|
||||
const Eigen::MatrixXi & F,
|
||||
Polyhedron & poly)
|
||||
const Eigen::MatrixBase<DerivedV>& V,
|
||||
const Eigen::MatrixBase<DerivedF>& F,
|
||||
Polyhedron& poly)
|
||||
{
|
||||
typedef typename Polyhedron::HalfedgeDS HalfedgeDS;
|
||||
// Postcondition: hds is a valid polyhedral surface.
|
||||
@@ -50,5 +52,6 @@ IGL_INLINE bool igl::copyleft::cgal::mesh_to_polyhedron(
|
||||
// Explicit template instantiation
|
||||
#include <CGAL/Simple_cartesian.h>
|
||||
#include <CGAL/Polyhedron_items_with_id_3.h>
|
||||
template bool igl::copyleft::cgal::mesh_to_polyhedron<CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(Eigen::Matrix<double, -1, -1, 0, -1, -1> const&, Eigen::Matrix<int, -1, -1, 0, -1, -1> const&, CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> >&);
|
||||
#include <CGAL/Polyhedron_3.h>
|
||||
template bool igl::copyleft::cgal::mesh_to_polyhedron<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> > >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, CGAL::Polyhedron_3<CGAL::Simple_cartesian<double>, CGAL::Polyhedron_items_with_id_3, CGAL::HalfedgeDS_default, std::allocator<int> >&);
|
||||
#endif
|
||||
|
||||
@@ -27,10 +27,13 @@ namespace igl
|
||||
// poly cgal polyhedron
|
||||
// Returns true only if (V,F) can be converted to a valid polyhedron (i.e. if
|
||||
// (V,F) is vertex and edge manifold).
|
||||
template <typename Polyhedron>
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename Polyhedron>
|
||||
IGL_INLINE bool mesh_to_polyhedron(
|
||||
const Eigen::MatrixXd & V,
|
||||
const Eigen::MatrixXi & F,
|
||||
const Eigen::MatrixBase<DerivedV> & V,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
Polyhedron & poly);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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
|
||||
//
|
||||
// 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 "order_facets_around_edges.h"
|
||||
#include "order_facets_around_edge.h"
|
||||
@@ -160,7 +160,7 @@ template<
|
||||
typename uE2EType,
|
||||
typename uE2oEType,
|
||||
typename uE2CType >
|
||||
IGL_INLINE
|
||||
IGL_INLINE
|
||||
typename std::enable_if<std::is_same<typename DerivedV::Scalar,
|
||||
typename CGAL::Exact_predicates_exact_constructions_kernel::FT>::value, void>::type
|
||||
igl::copyleft::cgal::order_facets_around_edges(
|
||||
@@ -329,4 +329,9 @@ template void igl::copyleft::cgal::order_facets_around_edges<Eigen::Matrix<CGAL:
|
||||
template void igl::copyleft::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
|
||||
template void igl::copyleft::cgal::order_facets_around_edges<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(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<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
|
||||
template void igl::copyleft::cgal::order_facets_around_edges<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 2, 0, -1, 2>, long, long, bool>(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 2, 0, -1, 2> > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > > const&, std::vector<std::vector<long, std::allocator<long> >, std::allocator<std::vector<long, std::allocator<long> > > >&, std::vector<std::vector<bool, std::allocator<bool> >, std::allocator<std::vector<bool, std::allocator<bool> > > >&);
|
||||
#ifdef WIN32
|
||||
template void igl::copyleft::cgal::order_facets_around_edges<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,2,0,-1,2>,__int64,__int64,bool>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,2,0,-1,2> > const &,class std::vector<class std::vector<__int64,class std::allocator<__int64> >,class std::allocator<class std::vector<__int64,class std::allocator<__int64> > > > const &,class std::vector<class std::vector<__int64,class std::allocator<__int64> >,class std::allocator<class std::vector<__int64,class std::allocator<__int64> > > > &,class std::vector<class std::vector<bool,class std::allocator<bool> >,class std::allocator<class std::vector<bool,class std::allocator<bool> > > > &);
|
||||
template void igl::copyleft::cgal::order_facets_around_edges<class Eigen::Matrix<double,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,2,0,-1,2>,__int64,__int64,bool>(class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,2,0,-1,2> > const &,class std::vector<class std::vector<__int64,class std::allocator<__int64> >,class std::allocator<class std::vector<__int64,class std::allocator<__int64> > > > const &,class std::vector<class std::vector<__int64,class std::allocator<__int64> >,class std::allocator<class std::vector<__int64,class std::allocator<__int64> > > > &,class std::vector<class std::vector<bool,class std::allocator<bool> >,class std::allocator<class std::vector<bool,class std::allocator<bool> > > > &);
|
||||
template void igl::copyleft::cgal::order_facets_around_edges<class Eigen::Matrix<double,-1,3,0,-1,3>,class Eigen::Matrix<int,-1,3,0,-1,3>,class Eigen::Matrix<int,-1,2,0,-1,2>,__int64,__int64,bool>(class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,2,0,-1,2> > const &,class std::vector<class std::vector<__int64,class std::allocator<__int64> >,class std::allocator<class std::vector<__int64,class std::allocator<__int64> > > > const &,class std::vector<class std::vector<__int64,class std::allocator<__int64> >,class std::allocator<class std::vector<__int64,class std::allocator<__int64> > > > &,class std::vector<class std::vector<bool,class std::allocator<bool> >,class std::allocator<class std::vector<bool,class std::allocator<bool> > > > &);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2016 Qingan Zhou <qnzhou@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
|
||||
//
|
||||
// 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 "orient2D.h"
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
template<typename Scalar>
|
||||
IGL_INLINE short igl::copyleft::cgal::orient2D(
|
||||
const Scalar pa[2],
|
||||
const Scalar pb[2],
|
||||
const Scalar pc[2])
|
||||
const Scalar *pa,
|
||||
const Scalar *pb,
|
||||
const Scalar *pc)
|
||||
{
|
||||
typedef CGAL::Exact_predicates_exact_constructions_kernel Epeck;
|
||||
typedef CGAL::Exact_predicates_inexact_constructions_kernel Epick;
|
||||
@@ -24,7 +24,8 @@ IGL_INLINE short igl::copyleft::cgal::orient2D(
|
||||
switch(CGAL::orientation(
|
||||
typename Kernel::Point_2(pa[0], pa[1]),
|
||||
typename Kernel::Point_2(pb[0], pb[1]),
|
||||
typename Kernel::Point_2(pc[0], pc[1]))) {
|
||||
typename Kernel::Point_2(pc[0], pc[1])))
|
||||
{
|
||||
case CGAL::LEFT_TURN:
|
||||
return 1;
|
||||
case CGAL::RIGHT_TURN:
|
||||
@@ -35,3 +36,12 @@ IGL_INLINE short igl::copyleft::cgal::orient2D(
|
||||
throw "Invalid orientation";
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template short igl::copyleft::cgal::orient2D<double>(double const*, double const*, double const*);
|
||||
#ifdef WIN32
|
||||
template short igl::copyleft::cgal::orient2D<double>(double const * const, double const * const, double const * const);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2016 Qingan Zhou <qnzhou@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
|
||||
//
|
||||
// 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_COPYLEFT_CGAL_ORIENT_2D_H
|
||||
@@ -25,9 +25,9 @@ namespace igl
|
||||
// -1 if pa,pb,pc are clockwise oriented.
|
||||
template <typename Scalar>
|
||||
IGL_INLINE short orient2D(
|
||||
const Scalar pa[2],
|
||||
const Scalar pb[2],
|
||||
const Scalar pc[2]);
|
||||
const Scalar *pa,
|
||||
const Scalar *pb,
|
||||
const Scalar *pc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -224,9 +224,11 @@ template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<class CGAL::La
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, __int64 &, __int64 &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, 3, 1, -1, 3>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 3, 1, -1, 3>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, __int64 &, __int64 &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, 3, 0, -1, 3>, class Eigen::Matrix<int, -1, 3, 0, -1, 3>, class Eigen::Matrix<long, -1, 1, 0, -1, 1>, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, 3, 0, -1, 3>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 3, 0, -1, 3>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<long, -1, 1, 0, -1, 1>> const &, __int64 &, __int64 &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,__int64,class Eigen::Matrix<__int64,-1,1,0,-1,1> >(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > const &,__int64 &,__int64 &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<double, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<double, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, __int64 &, __int64 &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<double, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<double, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, __int64 &, __int64 &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<double, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, -1, 1, -1, -1>, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<double, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 1, -1, -1>> const &, __int64 &, __int64 &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<double, -1, 3, 0, -1, 3>, class Eigen::Matrix<int, -1, 3, 0, -1, 3>, class Eigen::Matrix<long, -1, 1, 0, -1, 1>, __int64, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>>(class Eigen::PlainObjectBase<class Eigen::Matrix<double, -1, 3, 0, -1, 3>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 3, 0, -1, 3>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<long, -1, 1, 0, -1, 1>> const &, __int64 &, __int64 &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::outer_edge<class Eigen::Matrix<double,-1,3,0,-1,3>,class Eigen::Matrix<int,-1,3,0,-1,3>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,__int64,class Eigen::Matrix<__int64,-1,1,0,-1,1> >(class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > const &,__int64 &,__int64 &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
//
|
||||
// Copyright (C) 2015 Qingnan Zhou <qnzhou@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
|
||||
//
|
||||
// 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 "outer_facet.h"
|
||||
@@ -39,7 +39,7 @@ IGL_INLINE void igl::copyleft::cgal::outer_facet(
|
||||
// implemnetation of outer_edge()). The first adjacent facet is facing
|
||||
// outside (i.e. flipped=false) if it has positive X normal component.
|
||||
// If it has zero normal component, it is facing outside if it contains
|
||||
// directed edge (s, d).
|
||||
// directed edge (s, d).
|
||||
|
||||
//typedef typename DerivedV::Scalar Scalar;
|
||||
typedef typename DerivedV::Index Index;
|
||||
@@ -118,7 +118,7 @@ IGL_INLINE void igl::copyleft::cgal::outer_facet(
|
||||
Scalar max_nx = 0;
|
||||
size_t outer_fid = INVALID;
|
||||
const size_t num_incident_faces = incident_faces.size();
|
||||
for (size_t i=0; i<num_incident_faces; i++)
|
||||
for (size_t i=0; i<num_incident_faces; i++)
|
||||
{
|
||||
const auto& fid = incident_faces(i);
|
||||
const Scalar nx = N(fid, 0);
|
||||
@@ -176,5 +176,8 @@ template void igl::copyleft::cgal::outer_facet<Eigen::Matrix<double, -1, -1, 0,
|
||||
template void igl::copyleft::cgal::outer_facet<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, unsigned __int64>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, unsigned __int64 &, bool &);
|
||||
template void igl::copyleft::cgal::outer_facet<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, unsigned __int64>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, unsigned __int64 &, bool &);
|
||||
template void igl::copyleft::cgal::outer_facet<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>, class Eigen::Matrix<int, -1, 3, 1, -1, 3>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>, unsigned __int64>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 1, -1, -1>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 3, 1, -1, 3>> const &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> const &, unsigned __int64 &, bool &);
|
||||
template void igl::copyleft::cgal::outer_facet<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,int>(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > const &,int &,bool &);
|
||||
template void igl::copyleft::cgal::outer_facet<class Eigen::Matrix<double,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,1,0,-1,1>,unsigned __int64>(class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,1,0,-1,1> > const &,unsigned __int64 &,bool &);
|
||||
template void igl::copyleft::cgal::outer_facet<class Eigen::Matrix<double,-1,3,0,-1,3>,class Eigen::Matrix<int,-1,3,0,-1,3>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,int>(class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > const &,int &,bool &);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -532,4 +532,8 @@ template void igl::copyleft::cgal::outer_hull_legacy< Eigen::Matrix<double, -1,
|
||||
template void igl::copyleft::cgal::outer_hull_legacy< 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::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&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::cgal::outer_hull_legacy<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::outer_hull_legacy<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
#ifdef WIN32
|
||||
template void igl::copyleft::cgal::outer_hull_legacy<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<int,-1,1,0,-1,1> >(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,1,0,-1,1> > &);
|
||||
template void igl::copyleft::cgal::outer_hull_legacy<class Eigen::Matrix<double,-1,3,0,-1,3>,class Eigen::Matrix<int,-1,3,0,-1,3>,class Eigen::Matrix<int,-1,3,0,-1,3>,class Eigen::Matrix<__int64,-1,1,0,-1,1>,class Eigen::Matrix<int,-1,1,0,-1,1> >(class Eigen::PlainObjectBase<class Eigen::Matrix<double,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,3,0,-1,3> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,3,0,-1,3> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<__int64,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,1,0,-1,1> > &);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
// 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
|
||||
//
|
||||
// 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 "peel_outer_hull_layers.h"
|
||||
#include "outer_hull.h"
|
||||
@@ -121,4 +121,7 @@ IGL_INLINE size_t igl::copyleft::cgal::peel_outer_hull_layers(
|
||||
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
|
||||
template unsigned long igl::copyleft::cgal::peel_outer_hull_layers<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template size_t igl::copyleft::cgal::peel_outer_hull_layers<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
#ifdef WIN32
|
||||
template unsigned __int64 igl::copyleft::cgal::peel_outer_hull_layers<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,-1,0,-1,-1>,class Eigen::Matrix<int,-1,1,0,-1,1>,class Eigen::Matrix<int,-1,1,0,-1,1> >(class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,-1,0,-1,-1> > const &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,1,0,-1,1> > &,class Eigen::PlainObjectBase<class Eigen::Matrix<int,-1,1,0,-1,1> > &);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -524,6 +524,8 @@ template void igl::copyleft::cgal::remesh_intersections<Eigen::Matrix<CGAL::Lazy
|
||||
template void igl::copyleft::cgal::remesh_intersections<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, 8, 3, 0, 8, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epick, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, 8, 3, 0, 8, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > > const&, std::map<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, std::vector<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object> > >, std::less<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index const, std::vector<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object> > > > > > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::remesh_intersections<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, 8, 3, 0, 8, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epeck, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, 8, 3, 0, 8, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<CGAL::Triangle_3<CGAL::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > > const&, std::map<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, std::vector<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object> > >, std::less<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index const, std::vector<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object> > > > > > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::remesh_intersections<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, CGAL::Epeck, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3>, 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::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, std::vector<CGAL::Triangle_3<CGAL::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > > const&, std::map<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, std::vector<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object> > >, std::less<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index const, std::vector<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, -1, 0, -1, -1>::Index, CGAL::Object> > > > > > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::remesh_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epeck, 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::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epeck>, std::allocator<CGAL::Triangle_3<CGAL::Epeck> > > const&, std::map<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, std::vector<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object> > >, std::less<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index>, std::allocator<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index const, std::vector<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object> > > > > > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::remesh_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, CGAL::Epick, 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::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, std::vector<CGAL::Triangle_3<CGAL::Epick>, std::allocator<CGAL::Triangle_3<CGAL::Epick> > > const&, std::map<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, std::vector<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object> > >, std::less<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index>, std::allocator<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index const, std::vector<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object>, std::allocator<std::pair<Eigen::Matrix<int, -1, 3, 0, -1, 3>::Index, CGAL::Object> > > > > > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
#ifdef WIN32
|
||||
template void igl::copyleft::cgal::remesh_intersections<class Eigen::Matrix<double, -1, 3, 0, -1, 3>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class CGAL::Epeck, class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<double, -1, 3, 0, -1, 3>> const &, class Eigen::MatrixBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class std::vector<class CGAL::Triangle_3<class CGAL::Epeck>, class std::allocator<class CGAL::Triangle_3<class CGAL::Epeck>>> const &, class std::map<__int64, class std::vector<struct std::pair<__int64, class CGAL::Object>, class std::allocator<struct std::pair<__int64, class CGAL::Object>>>, struct std::less<__int64>, class std::allocator<struct std::pair<__int64 const, class std::vector<struct std::pair<__int64, class CGAL::Object>, class std::allocator<struct std::pair<__int64, class CGAL::Object>>>>>> const &, bool, class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::remesh_intersections<class Eigen::Matrix<double, -1, 3, 0, -1, 3>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class CGAL::Epick, class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<double, -1, 3, 0, -1, 3>> const &, class Eigen::MatrixBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, class std::vector<class CGAL::Triangle_3<class CGAL::Epick>, class std::allocator<class CGAL::Triangle_3<class CGAL::Epick>>> const &, class std::map<__int64, class std::vector<struct std::pair<__int64, class CGAL::Object>, class std::allocator<struct std::pair<__int64, class CGAL::Object>>>, struct std::less<__int64>, class std::allocator<struct std::pair<__int64 const, class std::vector<struct std::pair<__int64, class CGAL::Object>, class std::allocator<struct std::pair<__int64, class CGAL::Object>>>>>> const &, bool, class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> &);
|
||||
|
||||
@@ -101,6 +101,7 @@ template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<CGAL:
|
||||
template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<long, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<long, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<CGAL::Lazy_exact_nt<CGAL::Gmpq>, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::copyleft::cgal::remesh_self_intersections<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, 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::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, igl::copyleft::cgal::RemeshSelfIntersectionsParam const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
#ifdef WIN32
|
||||
template void igl::copyleft::cgal::remesh_self_intersections<class Eigen::Matrix<double, -1, 3, 0, -1, 3>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<double, -1, 3, 0, -1, 3>> const &, class Eigen::MatrixBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, struct igl::copyleft::cgal::RemeshSelfIntersectionsParam const &, class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::copyleft::cgal::remesh_self_intersections<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, 3, 0, -1, 3>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<int, -1, -1, 0, -1, -1>, class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<int, -1, 1, 0, -1, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, 3, 0, -1, 3>> const &, class Eigen::MatrixBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> const &, struct igl::copyleft::cgal::RemeshSelfIntersectionsParam const &, class Eigen::PlainObjectBase<class Eigen::Matrix<class CGAL::Lazy_exact_nt<class CGAL::Gmpq>, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, -1, 0, -1, -1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<__int64, -1, 1, 0, -1, 1>> &, class Eigen::PlainObjectBase<class Eigen::Matrix<int, -1, 1, 0, -1, 1>> &);
|
||||
|
||||
@@ -62,6 +62,15 @@ IGL_INLINE void igl::copyleft::cgal::wire_mesh(
|
||||
v = v-c*(PV.rows());
|
||||
p = v;
|
||||
};
|
||||
|
||||
// Count each vertex's indicident edges.
|
||||
std::vector<int> nedges(WV.rows(), 0);
|
||||
for(int e = 0;e<WE.rows();e++)
|
||||
{
|
||||
++nedges[WE(e, 0)];
|
||||
++nedges[WE(e, 1)];
|
||||
}
|
||||
|
||||
// loop over all edges
|
||||
for(int e = 0;e<WE.rows();e++)
|
||||
{
|
||||
@@ -88,7 +97,8 @@ IGL_INLINE void igl::copyleft::cgal::wire_mesh(
|
||||
// Start with factor of thickness;
|
||||
// Max out amount at 1/3 of edge length so that there's always some
|
||||
// amount of edge
|
||||
Scalar dist = std::min(1.*th,len/3.0);
|
||||
// Zero out if vertex is incident on only one edge
|
||||
Scalar dist = std::min(1.*th,len/3.0) * (nedges[WE(e,c)] > 1);
|
||||
// Move to endpoint, offset by amount
|
||||
V.row(index(e,c,p)) =
|
||||
qp+WV.row(WE(e,c)) + dist*dir*uv;
|
||||
|
||||
+341
-332
File diff suppressed because it is too large
Load Diff
@@ -17,35 +17,37 @@ namespace igl
|
||||
{
|
||||
namespace comiso
|
||||
{
|
||||
// Global seamless parametrization aligned with a given per-face jacobian (PD1,PD2).
|
||||
// Global seamless parametrization aligned with a given per-face Jacobian (PD1, PD2).
|
||||
// The algorithm is based on
|
||||
// "Mixed-Integer Quadrangulation" by D. Bommes, H. Zimmer, L. Kobbelt
|
||||
// ACM SIGGRAPH 2009, Article No. 77 (http://dl.acm.org/citation.cfm?id=1531383)
|
||||
// We thank Nico Pietroni for providing a reference implementation of MIQ
|
||||
// on which our code is based.
|
||||
|
||||
// Inputs:
|
||||
// V #V by 3 list of mesh vertex 3D positions
|
||||
// F #F by 3 list of faces indices in V
|
||||
// PD1 #V by 3 first line of the Jacobian per triangle
|
||||
// PD2 #V by 3 second line of the Jacobian per triangle
|
||||
// (optional, if empty it will be a vector in the tangent plane orthogonal to PD1)
|
||||
// scale global scaling for the gradient (controls the quads resolution)
|
||||
// stiffness weight for the stiffness iterations
|
||||
// direct_round greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
|
||||
// iter stiffness iterations (0 = no stiffness)
|
||||
// local_iter number of local iterations for the integer rounding
|
||||
// do_round enables the integer rounding (disabling it could be useful for debugging)
|
||||
// round_vertices id of additional vertices that should be snapped to integer coordinates
|
||||
// hard_features #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
|
||||
// Limitations:
|
||||
// - Due to the way of handling of hardFeatures the algorithm may fail in difficult cases.
|
||||
// - Meshes with boundaries are not hendled properly i.e., jagged edges along the boundary are possible
|
||||
|
||||
// Input:
|
||||
// V #V by 3 list of mesh vertex 3D positions
|
||||
// F #F by 3 list of faces indices in V
|
||||
// PD1 #V by 3 first line of the Jacobian per triangle
|
||||
// PD2 #V by 3 second line of the Jacobian per triangle
|
||||
// (optional, if empty it will be a vector in the tangent plane orthogonal to PD1)
|
||||
// gradientSize global scaling for the gradient (controls the quads resolution)
|
||||
// stiffness weight for the stiffness iterations (Reserved but not used!)
|
||||
// directRound greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
|
||||
// iter stiffness iterations (0 = no stiffness)
|
||||
// localIter number of local iterations for the integer rounding
|
||||
// doRound enables the integer rounding (disabling it could be useful for debugging)
|
||||
// singularityRound set true/false to decide if the singularities' coordinates should be rounded to the nearest integers
|
||||
// roundVertices id of additional vertices that should be snapped to integer coordinates
|
||||
// hardFeatures #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
|
||||
//
|
||||
// Output:
|
||||
// UV #UV by 2 list of vertices in 2D
|
||||
// FUV #FUV by 3 list of face indices in UV
|
||||
// UV #UV by 2 list of vertices in 2D
|
||||
// FUV #FUV by 3 list of face indices in UV
|
||||
//
|
||||
// TODO: rename the parameters name in the cpp consistently
|
||||
// improve the handling of hard_features, right now it might fail in difficult cases
|
||||
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedU>
|
||||
IGL_INLINE void miq(
|
||||
const Eigen::PlainObjectBase<DerivedV> &V,
|
||||
@@ -54,41 +56,64 @@ namespace igl
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD2,
|
||||
Eigen::PlainObjectBase<DerivedU> &UV,
|
||||
Eigen::PlainObjectBase<DerivedF> &FUV,
|
||||
double scale = 30.0,
|
||||
double gradientSize = 30.0,
|
||||
double stiffness = 5.0,
|
||||
bool direct_round = false,
|
||||
int iter = 5,
|
||||
int local_iter = 5,
|
||||
bool DoRound = true,bool SingularityRound=true,
|
||||
std::vector<int> round_vertices = std::vector<int>(),
|
||||
std::vector<std::vector<int> > hard_features = std::vector<std::vector<int> >());
|
||||
bool directRound = false,
|
||||
unsigned int iter = 5,
|
||||
unsigned int localIter = 5,
|
||||
bool doRound = true,
|
||||
bool singularityRound = true,
|
||||
const std::vector<int> &roundVertices = std::vector<int>(),
|
||||
const std::vector<std::vector<int>> &hardFeatures = std::vector<std::vector<int> >());
|
||||
|
||||
// Helper function that allows to directly provided pre-combed bisectors for an already cut mesh
|
||||
// Additional input:
|
||||
// PD1_combed, PD2_combed : #F by 3 combed jacobian
|
||||
// BIS1_combed, BIS2_combed: #F by 3 pre combed bi-sectors
|
||||
// MMatch: #F by 3 list of per-corner integer PI/2 rotations
|
||||
// Singular: #V list of flag that denotes if a vertex is singular or not
|
||||
// SingularDegree: #V list of flag that denotes the degree of the singularity
|
||||
// Seams: #F by 3 list of per-corner flag that denotes seams
|
||||
|
||||
// Input:
|
||||
// V #V by 3 list of mesh vertex 3D positions
|
||||
// F #F by 3 list of faces indices in V
|
||||
|
||||
// Additional Input:
|
||||
// PD1_combed #F by 3 first combed Jacobian
|
||||
// PD2_combed #F by 3 second combed Jacobian
|
||||
// mismatch #F by 3 list of per-corner integer PI/2 rotations
|
||||
// singular #V list of flag that denotes if a vertex is singular or not
|
||||
// seams #F by 3 list of per-corner flag that denotes seams
|
||||
|
||||
// Input:
|
||||
// gradientSize global scaling for the gradient (controls the quads resolution)
|
||||
// stiffness weight for the stiffness iterations (Reserved but not used!)
|
||||
// directRound greedily round all integer variables at once (greatly improves optimization speed but lowers quality)
|
||||
// iter stiffness iterations (0 = no stiffness)
|
||||
// localIter number of local iterations for the integer rounding
|
||||
// doRound enables the integer rounding (disabling it could be useful for debugging)
|
||||
// singularityRound set true/false to decide if the singularities' coordinates should be rounded to the nearest integers
|
||||
// roundVertices id of additional vertices that should be snapped to integer coordinates
|
||||
// hardFeatures #H by 2 list of pairs of vertices that belongs to edges that should be snapped to integer coordinates
|
||||
|
||||
// Output:
|
||||
// UV #UV by 2 list of vertices in 2D
|
||||
// FUV #FUV by 3 list of face indices in UV
|
||||
//
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedU>
|
||||
IGL_INLINE void miq(const Eigen::PlainObjectBase<DerivedV> &V,
|
||||
IGL_INLINE void miq(
|
||||
const Eigen::PlainObjectBase<DerivedV> &V,
|
||||
const Eigen::PlainObjectBase<DerivedF> &F,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD1_combed,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD2_combed,
|
||||
const Eigen::Matrix<int, Eigen::Dynamic, 3> &MMatch,
|
||||
const Eigen::Matrix<int, Eigen::Dynamic, 1> &Singular,
|
||||
const Eigen::Matrix<int, Eigen::Dynamic, 3> &Seams,
|
||||
const Eigen::Matrix<int, Eigen::Dynamic, 3> &mismatch,
|
||||
const Eigen::Matrix<int, Eigen::Dynamic, 1> &singular,
|
||||
const Eigen::Matrix<int, Eigen::Dynamic, 3> &seams,
|
||||
Eigen::PlainObjectBase<DerivedU> &UV,
|
||||
Eigen::PlainObjectBase<DerivedF> &FUV,
|
||||
double GradientSize = 30.0,
|
||||
double Stiffness = 5.0,
|
||||
bool DirectRound = false,
|
||||
int iter = 5,
|
||||
int localIter = 5, bool DoRound = true,bool SingularityRound=true,
|
||||
std::vector<int> roundVertices = std::vector<int>(),
|
||||
std::vector<std::vector<int> > hardFeatures = std::vector<std::vector<int> >());
|
||||
double gradientSize = 30.0,
|
||||
double stiffness = 5.0,
|
||||
bool directRound = false,
|
||||
unsigned int iter = 5,
|
||||
unsigned int localIter = 5,
|
||||
bool doRound = true,
|
||||
bool singularityRound = true,
|
||||
const std::vector<int> &roundVertices = std::vector<int>(),
|
||||
const std::vector<std::vector<int>> &hardFeatures = std::vector<std::vector<int> >());
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
#include <igl/edge_topology.h>
|
||||
#include <igl/per_face_normals.h>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
#include "../../PI.h"
|
||||
|
||||
#include <Eigen/Geometry>
|
||||
#include <Eigen/Sparse>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
#include <gmm/gmm.h>
|
||||
#include <CoMISo/Solver/ConstrainedSolver.hh>
|
||||
@@ -40,19 +41,19 @@ public:
|
||||
|
||||
// Generate the N-rosy field
|
||||
// N degree of the rosy field
|
||||
// roundseparately: round the integer variables one at a time, slower but higher quality
|
||||
IGL_INLINE void solve(const int N = 4);
|
||||
// round separately: round the integer variables one at a time, slower but higher quality
|
||||
IGL_INLINE void solve(int N = 4);
|
||||
|
||||
// Set a hard constraint on fid
|
||||
// fid: face id
|
||||
// v: direction to fix (in 3d)
|
||||
IGL_INLINE void setConstraintHard(const int fid, const Eigen::Vector3d& v);
|
||||
IGL_INLINE void setConstraintHard(int fid, const Eigen::Vector3d& v);
|
||||
|
||||
// Set a soft constraint on fid
|
||||
// fid: face id
|
||||
// w: weight of the soft constraint, clipped between 0 and 1
|
||||
// v: direction to fix (in 3d)
|
||||
IGL_INLINE void setConstraintSoft(const int fid, const double w, const Eigen::Vector3d& v);
|
||||
IGL_INLINE void setConstraintSoft(int fid, double w, const Eigen::Vector3d& v);
|
||||
|
||||
// Set the ratio between smoothness and soft constraints (0 -> smoothness only, 1 -> soft constr only)
|
||||
IGL_INLINE void setSoftAlpha(double alpha);
|
||||
@@ -63,9 +64,6 @@ public:
|
||||
// Return the current field
|
||||
IGL_INLINE Eigen::MatrixXd getFieldPerFace();
|
||||
|
||||
// Return the current field (in Ahish's ffield format)
|
||||
IGL_INLINE Eigen::MatrixXd getFFieldPerFace();
|
||||
|
||||
// Compute singularity indexes
|
||||
IGL_INLINE void findCones(int N);
|
||||
|
||||
@@ -73,7 +71,6 @@ public:
|
||||
IGL_INLINE Eigen::VectorXd getSingularityIndexPerVertex();
|
||||
|
||||
private:
|
||||
|
||||
// Compute angle differences between reference frames
|
||||
IGL_INLINE void computek();
|
||||
|
||||
@@ -81,20 +78,11 @@ private:
|
||||
IGL_INLINE void reduceSpace();
|
||||
|
||||
// Prepare the system matrix
|
||||
IGL_INLINE void prepareSystemMatrix(const int N);
|
||||
|
||||
// Solve without roundings
|
||||
IGL_INLINE void solveNoRoundings();
|
||||
IGL_INLINE void prepareSystemMatrix(int N);
|
||||
|
||||
// Solve with roundings using CoMIso
|
||||
IGL_INLINE void solveRoundings();
|
||||
|
||||
// Round all p to 0 and fix
|
||||
IGL_INLINE void roundAndFixToZero();
|
||||
|
||||
// Round all p and fix
|
||||
IGL_INLINE void roundAndFix();
|
||||
|
||||
// Convert a vector in 3d to an angle wrt the local reference system
|
||||
IGL_INLINE double convert3DtoLocal(unsigned fid, const Eigen::Vector3d& v);
|
||||
|
||||
@@ -114,7 +102,7 @@ private:
|
||||
// Soft constraints
|
||||
Eigen::VectorXd soft;
|
||||
Eigen::VectorXd wSoft;
|
||||
double softAlpha;
|
||||
double softAlpha;
|
||||
|
||||
// Face Topology
|
||||
Eigen::MatrixXi TT, TTi;
|
||||
@@ -158,16 +146,12 @@ private:
|
||||
|
||||
igl::copyleft::comiso::NRosyField::NRosyField(const Eigen::MatrixXd& _V, const Eigen::MatrixXi& _F)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
V = _V;
|
||||
F = _F;
|
||||
|
||||
assert(V.rows() > 0);
|
||||
assert(F.rows() > 0);
|
||||
|
||||
|
||||
// Generate topological relations
|
||||
igl::triangle_triangle_adjacency(F,TT,TTi);
|
||||
igl::edge_topology(V,F, EV, FE, EF);
|
||||
@@ -184,30 +168,29 @@ igl::copyleft::comiso::NRosyField::NRosyField(const Eigen::MatrixXd& _V, const E
|
||||
for(unsigned fid=0; fid<F.rows(); ++fid)
|
||||
{
|
||||
// First edge
|
||||
Vector3d e1 = V.row(F(fid,1)) - V.row(F(fid,0));
|
||||
Eigen::Vector3d e1 = V.row(F(fid,1)) - V.row(F(fid,0));
|
||||
e1.normalize();
|
||||
Vector3d e2 = N.row(fid);
|
||||
Eigen::Vector3d e2 = N.row(fid);
|
||||
e2 = e2.cross(e1);
|
||||
e2.normalize();
|
||||
|
||||
MatrixXd TP(2,3);
|
||||
Eigen::MatrixXd TP(2,3);
|
||||
TP << e1.transpose(), e2.transpose();
|
||||
TPs.push_back(TP);
|
||||
}
|
||||
|
||||
// Alloc internal variables
|
||||
angles = VectorXd::Zero(F.rows());
|
||||
p = VectorXi::Zero(EV.rows());
|
||||
angles = Eigen::VectorXd::Zero(F.rows());
|
||||
p = Eigen::VectorXi::Zero(EV.rows());
|
||||
pFixed.resize(EV.rows());
|
||||
k = VectorXd::Zero(EV.rows());
|
||||
singularityIndex = VectorXd::Zero(V.rows());
|
||||
k = Eigen::VectorXd::Zero(EV.rows());
|
||||
singularityIndex = Eigen::VectorXd::Zero(V.rows());
|
||||
|
||||
// Reset the constraints
|
||||
resetConstraints();
|
||||
|
||||
// Compute k, differences between reference frames
|
||||
computek();
|
||||
|
||||
softAlpha = 0.5;
|
||||
}
|
||||
|
||||
@@ -220,9 +203,6 @@ void igl::copyleft::comiso::NRosyField::setSoftAlpha(double alpha)
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
double Nd = N;
|
||||
|
||||
// Minimize the MIQ energy
|
||||
@@ -239,9 +219,9 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
// pij [ 4pi/N -4pi/N 2*(2pi/N)^2 4pi/N ]
|
||||
|
||||
// Count and tag the variables
|
||||
tag_t = VectorXi::Constant(F.rows(),-1);
|
||||
vector<int> id_t;
|
||||
int count = 0;
|
||||
tag_t = Eigen::VectorXi::Constant(F.rows(),-1);
|
||||
std::vector<int> id_t;
|
||||
size_t count = 0;
|
||||
for(unsigned i=0; i<F.rows(); ++i)
|
||||
if (!isHard[i])
|
||||
{
|
||||
@@ -249,10 +229,10 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
id_t.push_back(i);
|
||||
}
|
||||
|
||||
unsigned count_t = id_t.size();
|
||||
size_t count_t = id_t.size();
|
||||
|
||||
tag_p = VectorXi::Constant(EF.rows(),-1);
|
||||
vector<int> id_p;
|
||||
tag_p = Eigen::VectorXi::Constant(EF.rows(),-1);
|
||||
std::vector<int> id_p;
|
||||
for(unsigned i=0; i<EF.rows(); ++i)
|
||||
{
|
||||
if (!pFixed[i])
|
||||
@@ -273,20 +253,20 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
}
|
||||
}
|
||||
|
||||
unsigned count_p = count - count_t;
|
||||
size_t count_p = count - count_t;
|
||||
// System sizes: A (count_t + count_p) x (count_t + count_p)
|
||||
// b (count_t + count_p)
|
||||
|
||||
b = VectorXd::Zero(count_t + count_p);
|
||||
b.resize(count_t + count_p);
|
||||
b.setZero();
|
||||
|
||||
std::vector<Eigen::Triplet<double> > T;
|
||||
T.reserve(3 * 4 * count_p);
|
||||
|
||||
for(unsigned r=0; r<id_p.size(); ++r)
|
||||
for(auto eid : id_p)
|
||||
{
|
||||
int eid = id_p[r];
|
||||
int i = EF(eid,0);
|
||||
int j = EF(eid,1);
|
||||
int i = EF(eid, 0);
|
||||
int j = EF(eid, 1);
|
||||
bool isFixed_i = isHard[i];
|
||||
bool isFixed_j = isHard[j];
|
||||
bool isFixed_p = pFixed[eid];
|
||||
@@ -295,9 +275,15 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
if (!isFixed_i)
|
||||
{
|
||||
row = tag_t[i];
|
||||
if (isFixed_i) b(row) += -2 * hard[i]; else T.push_back(Eigen::Triplet<double>(row,tag_t[i] , 2 ));
|
||||
if (isFixed_j) b(row) += 2 * hard[j]; else T.push_back(Eigen::Triplet<double>(row,tag_t[j] ,-2 ));
|
||||
if (isFixed_p) b(row) += -((4 * igl::PI)/Nd) * p[eid] ; else T.push_back(Eigen::Triplet<double>(row,tag_p[eid],((4 * igl::PI)/Nd)));
|
||||
T.emplace_back(row, tag_t[i], 2);
|
||||
if (isFixed_j)
|
||||
b(row) += 2 * hard[j];
|
||||
else
|
||||
T.emplace_back(row, tag_t[j], -2);
|
||||
if (isFixed_p)
|
||||
b(row) += -((4. * igl::PI) / Nd) * p[eid];
|
||||
else
|
||||
T.emplace_back(row, tag_p[eid], ((4. * igl::PI) / Nd));
|
||||
b(row) += -2 * k[eid];
|
||||
assert(hard[i] == hard[i]);
|
||||
assert(hard[j] == hard[j]);
|
||||
@@ -309,9 +295,15 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
if (!isFixed_j)
|
||||
{
|
||||
row = tag_t[j];
|
||||
if (isFixed_i) b(row) += 2 * hard[i]; else T.push_back(Eigen::Triplet<double>(row,tag_t[i] , -2 ));
|
||||
if (isFixed_j) b(row) += -2 * hard[j]; else T.push_back(Eigen::Triplet<double>(row,tag_t[j] , 2 ));
|
||||
if (isFixed_p) b(row) += ((4 * igl::PI)/Nd) * p[eid] ; else T.push_back(Eigen::Triplet<double>(row,tag_p[eid],-((4 * igl::PI)/Nd)));
|
||||
T.emplace_back(row, tag_t[j], 2);
|
||||
if (isFixed_i)
|
||||
b(row) += 2 * hard[i];
|
||||
else
|
||||
T.emplace_back(row, tag_t[i], -2);
|
||||
if (isFixed_p)
|
||||
b(row) += ((4. * igl::PI) / Nd) * p[eid];
|
||||
else
|
||||
T.emplace_back(row, tag_p[eid], -((4. * igl::PI) / Nd));
|
||||
b(row) += 2 * k[eid];
|
||||
assert(k[eid] == k[eid]);
|
||||
assert(b(row) == b(row));
|
||||
@@ -320,17 +312,22 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
if (!isFixed_p)
|
||||
{
|
||||
row = tag_p[eid];
|
||||
if (isFixed_i) b(row) += -(4 * igl::PI)/Nd * hard[i]; else T.push_back(Eigen::Triplet<double>(row,tag_t[i] , (4 * igl::PI)/Nd ));
|
||||
if (isFixed_j) b(row) += (4 * igl::PI)/Nd * hard[j]; else T.push_back(Eigen::Triplet<double>(row,tag_t[j] , -(4 * igl::PI)/Nd ));
|
||||
if (isFixed_p) b(row) += -(2 * pow(((2*igl::PI)/Nd),2)) * p[eid] ; else T.push_back(Eigen::Triplet<double>(row,tag_p[eid], (2 * pow(((2*igl::PI)/Nd),2))));
|
||||
T.emplace_back(row, tag_p[eid], (2. * pow(((2. * igl::PI) / Nd), 2)));
|
||||
if (isFixed_i)
|
||||
b(row) += -(4. * igl::PI) / Nd * hard[i];
|
||||
else
|
||||
T.emplace_back(row, tag_t[i], (4. * igl::PI) / Nd);
|
||||
if (isFixed_j)
|
||||
b(row) += (4. * igl::PI) / Nd * hard[j];
|
||||
else
|
||||
T.emplace_back(row,tag_t[j], -(4. * igl::PI) / Nd);
|
||||
b(row) += - (4 * igl::PI)/Nd * k[eid];
|
||||
assert(k[eid] == k[eid]);
|
||||
assert(b(row) == b(row));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
A = SparseMatrix<double>(count_t + count_p, count_t + count_p);
|
||||
A.resize(count_t + count_p, count_t + count_p);
|
||||
A.setFromTriplets(T.begin(), T.end());
|
||||
|
||||
// Soft constraints
|
||||
@@ -342,10 +339,7 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
|
||||
if (addSoft)
|
||||
{
|
||||
cerr << " Adding soft here: " << endl;
|
||||
cerr << " softAplha: " << softAlpha << endl;
|
||||
VectorXd bSoft = VectorXd::Zero(count_t + count_p);
|
||||
|
||||
Eigen::VectorXd bSoft = Eigen::VectorXd::Zero(count_t + count_p);
|
||||
std::vector<Eigen::Triplet<double> > TSoft;
|
||||
TSoft.reserve(2 * count_p);
|
||||
|
||||
@@ -354,98 +348,36 @@ void igl::copyleft::comiso::NRosyField::prepareSystemMatrix(const int N)
|
||||
int varid = tag_t[i];
|
||||
if (varid != -1) // if it is a variable in the system
|
||||
{
|
||||
TSoft.push_back(Eigen::Triplet<double>(varid,varid,wSoft[i]));
|
||||
TSoft.emplace_back(varid, varid, wSoft[i]);
|
||||
bSoft[varid] += wSoft[i] * soft[i];
|
||||
}
|
||||
}
|
||||
SparseMatrix<double> ASoft(count_t + count_p, count_t + count_p);
|
||||
Eigen::SparseMatrix<double> ASoft(count_t + count_p, count_t + count_p);
|
||||
ASoft.setFromTriplets(TSoft.begin(), TSoft.end());
|
||||
|
||||
// ofstream s("/Users/daniele/As.txt");
|
||||
// for(unsigned i=0; i<TSoft.size(); ++i)
|
||||
// s << TSoft[i].row() << " " << TSoft[i].col() << " " << TSoft[i].value() << endl;
|
||||
// s.close();
|
||||
|
||||
// ofstream s2("/Users/daniele/bs.txt");
|
||||
// for(unsigned i=0; i<bSoft.rows(); ++i)
|
||||
// s2 << bSoft(i) << endl;
|
||||
// s2.close();
|
||||
|
||||
// Stupid Eigen bug
|
||||
SparseMatrix<double> Atmp (count_t + count_p, count_t + count_p);
|
||||
SparseMatrix<double> Atmp2(count_t + count_p, count_t + count_p);
|
||||
SparseMatrix<double> Atmp3(count_t + count_p, count_t + count_p);
|
||||
|
||||
// Merge the two part of the energy
|
||||
Atmp = (1.0 - softAlpha)*A;
|
||||
Atmp2 = softAlpha * ASoft;
|
||||
Atmp3 = Atmp+Atmp2;
|
||||
|
||||
A = Atmp3;
|
||||
b = b*(1.0 - softAlpha) + bSoft * softAlpha;
|
||||
A = (1.0 - softAlpha) * A + softAlpha * ASoft;
|
||||
b = b * (1.0 - softAlpha) + bSoft * softAlpha;
|
||||
}
|
||||
|
||||
// ofstream s("/Users/daniele/A.txt");
|
||||
// for (int k=0; k<A.outerSize(); ++k)
|
||||
// for (SparseMatrix<double>::InnerIterator it(A,k); it; ++it)
|
||||
// {
|
||||
// s << it.row() << " " << it.col() << " " << it.value() << endl;
|
||||
// }
|
||||
// s.close();
|
||||
//
|
||||
// ofstream s2("/Users/daniele/b.txt");
|
||||
// for(unsigned i=0; i<b.rows(); ++i)
|
||||
// s2 << b(i) << endl;
|
||||
// s2.close();
|
||||
}
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::solveNoRoundings()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
// Solve the linear system
|
||||
SimplicialLDLT<SparseMatrix<double> > solver;
|
||||
solver.compute(A);
|
||||
VectorXd x = solver.solve(b);
|
||||
|
||||
// Copy the result back
|
||||
for(unsigned i=0; i<F.rows(); ++i)
|
||||
if (tag_t[i] != -1)
|
||||
angles[i] = x(tag_t[i]);
|
||||
else
|
||||
angles[i] = hard[i];
|
||||
|
||||
for(unsigned i=0; i<EF.rows(); ++i)
|
||||
if(tag_p[i] != -1)
|
||||
p[i] = roundl(x[tag_p[i]]);
|
||||
}
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::solveRoundings()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
unsigned n = A.rows();
|
||||
|
||||
gmm::col_matrix< gmm::wsvector< double > > gmm_A;
|
||||
std::vector<double> gmm_b;
|
||||
gmm::col_matrix< gmm::wsvector< double > > gmm_A(n, n);
|
||||
std::vector<double> gmm_b(n);
|
||||
std::vector<int> ids_to_round;
|
||||
std::vector<double> x;
|
||||
|
||||
gmm_A.resize(n,n);
|
||||
gmm_b.resize(n);
|
||||
x.resize(n);
|
||||
std::vector<double> x(n);
|
||||
|
||||
// Copy A
|
||||
for (int k=0; k<A.outerSize(); ++k)
|
||||
for (SparseMatrix<double>::InnerIterator it(A,k); it; ++it)
|
||||
for (Eigen::SparseMatrix<double>::InnerIterator it(A, k); it; ++it)
|
||||
{
|
||||
gmm_A(it.row(),it.col()) += it.value();
|
||||
}
|
||||
|
||||
// Copy b
|
||||
for(unsigned i=0; i<n;++i)
|
||||
for(unsigned int i = 0; i < n;++i)
|
||||
gmm_b[i] = b[i];
|
||||
|
||||
// Set variables to round
|
||||
@@ -458,7 +390,6 @@ void igl::copyleft::comiso::NRosyField::solveRoundings()
|
||||
gmm::row_matrix< gmm::wsvector< double > > gmm_C(0, n);
|
||||
|
||||
COMISO::ConstrainedSolver cs;
|
||||
//print_miso_settings(cs.misolver());
|
||||
cs.solve(gmm_C, gmm_A, x, gmm_b, ids_to_round, 0.0, false, true);
|
||||
|
||||
// Copy the result back
|
||||
@@ -470,26 +401,10 @@ void igl::copyleft::comiso::NRosyField::solveRoundings()
|
||||
|
||||
for(unsigned i=0; i<EF.rows(); ++i)
|
||||
if(tag_p[i] != -1)
|
||||
p[i] = roundl(x[tag_p[i]]);
|
||||
|
||||
p[i] = (int)std::round(x[tag_p[i]]);
|
||||
}
|
||||
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::roundAndFix()
|
||||
{
|
||||
for(unsigned i=0; i<p.rows(); ++i)
|
||||
pFixed[i] = true;
|
||||
}
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::roundAndFixToZero()
|
||||
{
|
||||
for(unsigned i=0; i<p.rows(); ++i)
|
||||
{
|
||||
pFixed[i] = true;
|
||||
p[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::solve(const int N)
|
||||
{
|
||||
// Reduce the search space by fixing matchings
|
||||
@@ -501,19 +416,6 @@ void igl::copyleft::comiso::NRosyField::solve(const int N)
|
||||
// Solve with integer roundings
|
||||
solveRoundings();
|
||||
|
||||
// This is a very greedy solving strategy
|
||||
// // Solve with no roundings
|
||||
// solveNoRoundings();
|
||||
//
|
||||
// // Round all p and fix them
|
||||
// roundAndFix();
|
||||
//
|
||||
// // Build the system
|
||||
// prepareSystemMatrix(N);
|
||||
//
|
||||
// // Solve with no roundings (they are all fixed)
|
||||
// solveNoRoundings();
|
||||
|
||||
// Find the cones
|
||||
findCones(N);
|
||||
}
|
||||
@@ -532,65 +434,34 @@ void igl::copyleft::comiso::NRosyField::setConstraintSoft(const int fid, const d
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::resetConstraints()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
isHard.resize(F.rows());
|
||||
for(unsigned i=0; i<F.rows(); ++i)
|
||||
for(unsigned i = 0; i < F.rows(); ++i)
|
||||
isHard[i] = false;
|
||||
hard = VectorXd::Zero(F.rows());
|
||||
|
||||
wSoft = VectorXd::Zero(F.rows());
|
||||
soft = VectorXd::Zero(F.rows());
|
||||
hard = Eigen::VectorXd::Zero(F.rows());
|
||||
wSoft = Eigen::VectorXd::Zero(F.rows());
|
||||
soft = Eigen::VectorXd::Zero(F.rows());
|
||||
}
|
||||
|
||||
Eigen::MatrixXd igl::copyleft::comiso::NRosyField::getFieldPerFace()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
MatrixXd result(F.rows(),3);
|
||||
for(unsigned i=0; i<F.rows(); ++i)
|
||||
Eigen::MatrixXd result(F.rows(),3);
|
||||
for(unsigned int i = 0; i < F.rows(); ++i)
|
||||
result.row(i) = convertLocalto3D(i, angles(i));
|
||||
return result;
|
||||
}
|
||||
|
||||
Eigen::MatrixXd igl::copyleft::comiso::NRosyField::getFFieldPerFace()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
MatrixXd result(F.rows(),6);
|
||||
for(unsigned i=0; i<F.rows(); ++i)
|
||||
{
|
||||
Vector3d v1 = convertLocalto3D(i, angles(i));
|
||||
Vector3d n = N.row(i);
|
||||
Vector3d v2 = n.cross(v1);
|
||||
v1.normalize();
|
||||
v2.normalize();
|
||||
|
||||
result.block(i,0,1,3) = v1.transpose();
|
||||
result.block(i,3,1,3) = v2.transpose();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::computek()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
// For every non-border edge
|
||||
for (unsigned eid=0; eid<EF.rows(); ++eid)
|
||||
for (unsigned eid = 0; eid < EF.rows(); ++eid)
|
||||
{
|
||||
if (!isBorderEdge[eid])
|
||||
{
|
||||
int fid0 = EF(eid,0);
|
||||
int fid1 = EF(eid,1);
|
||||
|
||||
Vector3d N0 = N.row(fid0);
|
||||
Vector3d N1 = N.row(fid1);
|
||||
Eigen::Vector3d N0 = N.row(fid0);
|
||||
Eigen::Vector3d N1 = N.row(fid1);
|
||||
|
||||
// find common edge on triangle 0 and 1
|
||||
int fid0_vc = -1;
|
||||
@@ -605,18 +476,18 @@ void igl::copyleft::comiso::NRosyField::computek()
|
||||
assert(fid0_vc != -1);
|
||||
assert(fid1_vc != -1);
|
||||
|
||||
Vector3d common_edge = V.row(F(fid0,(fid0_vc+1)%3)) - V.row(F(fid0,fid0_vc));
|
||||
Eigen::Vector3d common_edge = V.row(F(fid0,(fid0_vc+1)%3)) - V.row(F(fid0,fid0_vc));
|
||||
common_edge.normalize();
|
||||
|
||||
// Map the two triangles in a new space where the common edge is the x axis and the N0 the z axis
|
||||
MatrixXd P(3,3);
|
||||
VectorXd o = V.row(F(fid0,fid0_vc));
|
||||
VectorXd tmp = -N0.cross(common_edge);
|
||||
Eigen::MatrixXd P(3,3);
|
||||
Eigen::VectorXd o = V.row(F(fid0,fid0_vc));
|
||||
Eigen::VectorXd tmp = -N0.cross(common_edge);
|
||||
P << common_edge, tmp, N0;
|
||||
P.transposeInPlace();
|
||||
|
||||
|
||||
MatrixXd V0(3,3);
|
||||
Eigen::MatrixXd V0(3,3);
|
||||
V0.row(0) = V.row(F(fid0,0)).transpose() -o;
|
||||
V0.row(1) = V.row(F(fid0,1)).transpose() -o;
|
||||
V0.row(2) = V.row(F(fid0,2)).transpose() -o;
|
||||
@@ -627,7 +498,7 @@ void igl::copyleft::comiso::NRosyField::computek()
|
||||
assert(V0(1,2) < 10e-10);
|
||||
assert(V0(2,2) < 10e-10);
|
||||
|
||||
MatrixXd V1(3,3);
|
||||
Eigen::MatrixXd V1(3,3);
|
||||
V1.row(0) = V.row(F(fid1,0)).transpose() -o;
|
||||
V1.row(1) = V.row(F(fid1,1)).transpose() -o;
|
||||
V1.row(2) = V.row(F(fid1,2)).transpose() -o;
|
||||
@@ -638,12 +509,12 @@ void igl::copyleft::comiso::NRosyField::computek()
|
||||
|
||||
// compute rotation R such that R * N1 = N0
|
||||
// i.e. map both triangles to the same plane
|
||||
double alpha = -atan2(V1((fid1_vc+2)%3,2),V1((fid1_vc+2)%3,1));
|
||||
double alpha = -std::atan2(V1((fid1_vc + 2) % 3, 2), V1((fid1_vc + 2) % 3, 1));
|
||||
|
||||
MatrixXd R(3,3);
|
||||
Eigen::MatrixXd R(3,3);
|
||||
R << 1, 0, 0,
|
||||
0, cos(alpha), -sin(alpha) ,
|
||||
0, sin(alpha), cos(alpha);
|
||||
0, std::cos(alpha), -std::sin(alpha) ,
|
||||
0, std::sin(alpha), std::cos(alpha);
|
||||
V1 = (R*V1.transpose()).transpose();
|
||||
|
||||
assert(V1(0,2) < 10e-10);
|
||||
@@ -652,17 +523,17 @@ void igl::copyleft::comiso::NRosyField::computek()
|
||||
|
||||
// measure the angle between the reference frames
|
||||
// k_ij is the angle between the triangle on the left and the one on the right
|
||||
VectorXd ref0 = V0.row(1) - V0.row(0);
|
||||
VectorXd ref1 = V1.row(1) - V1.row(0);
|
||||
Eigen::VectorXd ref0 = V0.row(1) - V0.row(0);
|
||||
Eigen::VectorXd ref1 = V1.row(1) - V1.row(0);
|
||||
|
||||
ref0.normalize();
|
||||
ref1.normalize();
|
||||
|
||||
double ktemp = atan2(ref1(1),ref1(0)) - atan2(ref0(1),ref0(0));
|
||||
double ktemp = std::atan2(ref1(1), ref1(0)) - std::atan2(ref0(1), ref0(0));
|
||||
|
||||
// just to be sure, rotate ref0 using angle ktemp...
|
||||
MatrixXd R2(2,2);
|
||||
R2 << cos(ktemp), -sin(ktemp), sin(ktemp), cos(ktemp);
|
||||
Eigen::MatrixXd R2(2,2);
|
||||
R2 << std::cos(ktemp), -std::sin(ktemp), std::sin(ktemp), std::cos(ktemp);
|
||||
|
||||
tmp = R2*ref0.head<2>();
|
||||
|
||||
@@ -677,30 +548,15 @@ void igl::copyleft::comiso::NRosyField::computek()
|
||||
|
||||
void igl::copyleft::comiso::NRosyField::reduceSpace()
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
// All variables are free in the beginning
|
||||
for(unsigned i=0; i<EV.rows(); ++i)
|
||||
for(unsigned int i = 0; i < EV.rows(); ++i)
|
||||
pFixed[i] = false;
|
||||
|
||||
vector<VectorXd> debug;
|
||||
std::vector<bool> visited(EV.rows(), false);
|
||||
std::vector<bool> starting(EV.rows(), false);
|
||||
|
||||
// debug
|
||||
// MatrixXd B(F.rows(),3);
|
||||
// for(unsigned i=0; i<F.rows(); ++i)
|
||||
// B.row(i) = 1./3. * (V.row(F(i,0)) + V.row(F(i,1)) + V.row(F(i,2)));
|
||||
|
||||
vector<bool> visited(EV.rows());
|
||||
for(unsigned i=0; i<EV.rows(); ++i)
|
||||
visited[i] = false;
|
||||
|
||||
vector<bool> starting(EV.rows());
|
||||
for(unsigned i=0; i<EV.rows(); ++i)
|
||||
starting[i] = false;
|
||||
|
||||
queue<int> q;
|
||||
for(unsigned i=0; i<F.rows(); ++i)
|
||||
std::queue<int> q;
|
||||
for(unsigned int i = 0; i < F.rows(); ++i)
|
||||
if (isHard[i] || wSoft[i] != 0)
|
||||
{
|
||||
q.push(i);
|
||||
@@ -730,7 +586,6 @@ void igl::copyleft::comiso::NRosyField::reduceSpace()
|
||||
p[eid] = 0;
|
||||
visited[fid] = true;
|
||||
q.push(fid);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -740,15 +595,14 @@ void igl::copyleft::comiso::NRosyField::reduceSpace()
|
||||
p[eid] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Force matchings between fixed faces
|
||||
for(unsigned i=0; i<F.rows();++i)
|
||||
for(unsigned int i = 0; i < F.rows();++i)
|
||||
{
|
||||
if (isHard[i])
|
||||
{
|
||||
for(unsigned int j=0; j<3; ++j)
|
||||
for(unsigned int j = 0; j < 3; ++j)
|
||||
{
|
||||
int fid = TT(i,j);
|
||||
if ((fid!=-1) && (isHard[fid]))
|
||||
@@ -759,37 +613,25 @@ void igl::copyleft::comiso::NRosyField::reduceSpace()
|
||||
int fid1 = EF(eid,1);
|
||||
|
||||
pFixed[eid] = true;
|
||||
p[eid] = roundl(2.0/igl::PI*(hard(fid1) - hard(fid0) - k(eid)));
|
||||
p[eid] = (int)std::round(2.0 / igl::PI * (hard(fid1) - hard(fid0) - k(eid)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// std::ofstream s("/Users/daniele/debug.txt");
|
||||
// for(unsigned i=0; i<debug.size(); i += 2)
|
||||
// s << debug[i].transpose() << " " << debug[i+1].transpose() << endl;
|
||||
// s.close();
|
||||
|
||||
}
|
||||
|
||||
double igl::copyleft::comiso::NRosyField::convert3DtoLocal(unsigned fid, const Eigen::Vector3d& v)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
// Project onto the tangent plane
|
||||
Vector2d vp = TPs[fid] * v;
|
||||
Eigen::Vector2d vp = TPs[fid] * v;
|
||||
|
||||
// Convert to angle
|
||||
return atan2(vp(1),vp(0));
|
||||
return std::atan2(vp(1), vp(0));
|
||||
}
|
||||
|
||||
Eigen::Vector3d igl::copyleft::comiso::NRosyField::convertLocalto3D(unsigned fid, double a)
|
||||
{
|
||||
using namespace std;
|
||||
using namespace Eigen;
|
||||
|
||||
Vector2d vp(cos(a),sin(a));
|
||||
Eigen::Vector2d vp(std::cos(a), std::sin(a));
|
||||
return vp.transpose() * TPs[fid];
|
||||
}
|
||||
|
||||
@@ -797,15 +639,18 @@ Eigen::VectorXd igl::copyleft::comiso::NRosyField::angleDefect()
|
||||
{
|
||||
Eigen::VectorXd A = Eigen::VectorXd::Constant(V.rows(),-2*igl::PI);
|
||||
|
||||
for (unsigned i=0; i < F.rows(); ++i)
|
||||
for (unsigned int i = 0; i < F.rows(); ++i)
|
||||
{
|
||||
for (int j = 0; j < 3; ++j)
|
||||
{
|
||||
Eigen::VectorXd a = V.row(F(i,(j+1)%3)) - V.row(F(i,j));
|
||||
Eigen::VectorXd b = V.row(F(i,(j+2)%3)) - V.row(F(i,j));
|
||||
double t = a.transpose()*b;
|
||||
t /= (a.norm() * b.norm());
|
||||
A(F(i,j)) += acos(t);
|
||||
double t = a.transpose() * b;
|
||||
if(a.norm() > 0. && b.norm() > 0.)
|
||||
t /= (a.norm() * b.norm());
|
||||
else
|
||||
throw std::runtime_error("igl::copyleft::comiso::NRosyField::angleDefect: Division by zero!");
|
||||
A(F(i, j)) += std::acos(std::max(std::min(t, 1.), -1.));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -816,57 +661,46 @@ void igl::copyleft::comiso::NRosyField::findCones(int N)
|
||||
{
|
||||
// Compute I0, see http://www.graphics.rwth-aachen.de/media/papers/bommes_zimmer_2009_siggraph_011.pdf for details
|
||||
|
||||
Eigen::VectorXd I0 = Eigen::VectorXd::Zero(V.rows());
|
||||
singularityIndex = Eigen::VectorXd::Zero(V.rows());
|
||||
|
||||
// first the k
|
||||
for (unsigned i=0; i < EV.rows(); ++i)
|
||||
for (unsigned i = 0; i < EV.rows(); ++i)
|
||||
{
|
||||
if (!isBorderEdge[i])
|
||||
{
|
||||
I0(EV(i,0)) -= k(i);
|
||||
I0(EV(i,1)) += k(i);
|
||||
singularityIndex(EV(i, 0)) -= k(i);
|
||||
singularityIndex(EV(i, 1)) += k(i);
|
||||
}
|
||||
}
|
||||
|
||||
// then the A
|
||||
Eigen::VectorXd A = angleDefect();
|
||||
|
||||
I0 = I0 + A;
|
||||
|
||||
singularityIndex += A;
|
||||
// normalize
|
||||
I0 = I0 / (2*igl::PI);
|
||||
singularityIndex /= (2 * igl::PI);
|
||||
|
||||
// round to integer (remove numerical noise)
|
||||
for (unsigned i=0; i < I0.size(); ++i)
|
||||
I0(i) = round(I0(i));
|
||||
for (unsigned i = 0; i < singularityIndex.size(); ++i)
|
||||
singularityIndex(i) = round(singularityIndex(i));
|
||||
|
||||
// compute I
|
||||
Eigen::VectorXd I = I0;
|
||||
|
||||
for (unsigned i=0; i < EV.rows(); ++i)
|
||||
for (unsigned i = 0; i < EV.rows(); ++i)
|
||||
{
|
||||
if (!isBorderEdge[i])
|
||||
{
|
||||
I(EV(i,0)) -= double(p(i))/double(N);
|
||||
I(EV(i,1)) += double(p(i))/double(N);
|
||||
singularityIndex(EV(i, 0)) -= double(p(i)) / double(N);
|
||||
singularityIndex(EV(i, 1)) += double(p(i)) / double(N);
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the vertices on the edges
|
||||
for (unsigned i=0; i < EV.rows(); ++i)
|
||||
for (unsigned i = 0; i < EV.rows(); ++i)
|
||||
{
|
||||
if (isBorderEdge[i])
|
||||
{
|
||||
I0(EV(i,0)) = 0;
|
||||
I0(EV(i,1)) = 0;
|
||||
I(EV(i,0)) = 0;
|
||||
I(EV(i,1)) = 0;
|
||||
A(EV(i,0)) = 0;
|
||||
A(EV(i,1)) = 0;
|
||||
singularityIndex(EV(i,0)) = 0;
|
||||
singularityIndex(EV(i,1)) = 0;
|
||||
}
|
||||
}
|
||||
|
||||
singularityIndex = I;
|
||||
}
|
||||
|
||||
Eigen::VectorXd igl::copyleft::comiso::NRosyField::getSingularityIndexPerVertex()
|
||||
@@ -889,15 +723,15 @@ IGL_INLINE void igl::copyleft::comiso::nrosy(
|
||||
)
|
||||
{
|
||||
// Init solver
|
||||
igl::copyleft::comiso::NRosyField solver(V,F);
|
||||
igl::copyleft::comiso::NRosyField solver(V, F);
|
||||
|
||||
// Add hard constraints
|
||||
for (unsigned i=0; i<b.size();++i)
|
||||
solver.setConstraintHard(b(i),bc.row(i));
|
||||
for (unsigned i = 0; i < b.size(); ++i)
|
||||
solver.setConstraintHard(b(i), bc.row(i));
|
||||
|
||||
// Add soft constraints
|
||||
for (unsigned i=0; i<b_soft.size();++i)
|
||||
solver.setConstraintSoft(b_soft(i),w_soft(i),bc_soft.row(i));
|
||||
for (unsigned i = 0; i < b_soft.size(); ++i)
|
||||
solver.setConstraintSoft(b_soft(i), w_soft(i), bc_soft.row(i));
|
||||
|
||||
// Set the soft constraints global weight
|
||||
solver.setSoftAlpha(soft);
|
||||
@@ -924,11 +758,11 @@ IGL_INLINE void igl::copyleft::comiso::nrosy(
|
||||
)
|
||||
{
|
||||
// Init solver
|
||||
igl::copyleft::comiso::NRosyField solver(V,F);
|
||||
igl::copyleft::comiso::NRosyField solver(V, F);
|
||||
|
||||
// Add hard constraints
|
||||
for (unsigned i=0; i<b.size();++i)
|
||||
solver.setConstraintHard(b(i),bc.row(i));
|
||||
for (unsigned i= 0; i < b.size(); ++i)
|
||||
solver.setConstraintHard(b(i), bc.row(i));
|
||||
|
||||
// Interpolate
|
||||
solver.solve(N);
|
||||
|
||||
@@ -8,12 +8,9 @@
|
||||
#ifndef IGL_COMISO_NROSY_H
|
||||
#define IGL_COMISO_NROSY_H
|
||||
|
||||
#include <iostream>
|
||||
#include <Eigen/Core>
|
||||
#include <Eigen/Sparse>
|
||||
#include <vector>
|
||||
#include "../../igl_inline.h"
|
||||
#include "../../PI.h"
|
||||
|
||||
namespace igl
|
||||
{
|
||||
@@ -46,8 +43,8 @@ namespace igl
|
||||
const Eigen::VectorXi& b_soft,
|
||||
const Eigen::VectorXd& w_soft,
|
||||
const Eigen::MatrixXd& bc_soft,
|
||||
const int N,
|
||||
const double soft,
|
||||
int N,
|
||||
double soft,
|
||||
Eigen::MatrixXd& R,
|
||||
Eigen::VectorXd& S
|
||||
);
|
||||
@@ -57,7 +54,7 @@ namespace igl
|
||||
const Eigen::MatrixXi& F,
|
||||
const Eigen::VectorXi& b,
|
||||
const Eigen::MatrixXd& bc,
|
||||
const int N,
|
||||
int N,
|
||||
Eigen::MatrixXd& R,
|
||||
Eigen::VectorXd& S
|
||||
);
|
||||
|
||||
@@ -33,44 +33,45 @@ extern const int edgeTable[256];
|
||||
extern const int triTable[256][2][17];
|
||||
extern const int polyTable[8][16];
|
||||
|
||||
struct EdgeKey
|
||||
{
|
||||
EdgeKey(unsigned i0, unsigned i1) : i0_(i0), i1_(i1) {}
|
||||
|
||||
bool operator==(const EdgeKey& _rhs) const
|
||||
{
|
||||
return i0_ == _rhs.i0_ && i1_ == _rhs.i1_;
|
||||
}
|
||||
|
||||
unsigned i0_, i1_;
|
||||
};
|
||||
|
||||
struct EdgeHash
|
||||
{
|
||||
std::size_t operator()(const EdgeKey& key) const {
|
||||
std::size_t seed = 0;
|
||||
seed ^= key.i0_ + 0x9e3779b9 + (seed<<6) + (seed>>2); // Copied from boost::hash_combine
|
||||
seed ^= key.i1_ + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||
return std::hash<std::size_t>()(seed);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template <typename Derivedvalues, typename Derivedpoints,typename Derivedvertices, typename DerivedF>
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedIndices, typename DerivedFaces>
|
||||
class MarchingCubes
|
||||
{
|
||||
struct EdgeKey
|
||||
{
|
||||
EdgeKey(unsigned i0, unsigned i1) : i0_(i0), i1_(i1) {}
|
||||
|
||||
bool operator==(const EdgeKey& _rhs) const
|
||||
{
|
||||
return i0_ == _rhs.i0_ && i1_ == _rhs.i1_;
|
||||
}
|
||||
|
||||
unsigned i0_, i1_;
|
||||
};
|
||||
|
||||
struct EdgeHash
|
||||
{
|
||||
std::size_t operator()(const EdgeKey& key) const {
|
||||
std::size_t seed = 0;
|
||||
seed ^= key.i0_ + 0x9e3779b9 + (seed<<6) + (seed>>2); // Copied from boost::hash_combine
|
||||
seed ^= key.i1_ + 0x9e3779b9 + (seed<<6) + (seed>>2);
|
||||
return std::hash<std::size_t>()(seed);
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unordered_map<EdgeKey, unsigned, EdgeHash> MyMap;
|
||||
typedef typename MyMap::const_iterator MyMapIterator;
|
||||
|
||||
public:
|
||||
MarchingCubes(
|
||||
const Eigen::PlainObjectBase<Derivedvalues> &values,
|
||||
const Eigen::PlainObjectBase<Derivedpoints> &points,
|
||||
// Dense index grid version
|
||||
MarchingCubes(const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
Eigen::PlainObjectBase<Derivedvertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedF> &faces)
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
assert(values.cols() == 1);
|
||||
assert(points.cols() == 3);
|
||||
@@ -83,7 +84,6 @@ public:
|
||||
vertices.resize(10000,3);
|
||||
int num_vertices = 0;
|
||||
|
||||
|
||||
unsigned n_cubes = (x_res-1) * (y_res-1) * (z_res-1);
|
||||
assert(unsigned(points.rows()) == x_res * y_res * z_res);
|
||||
|
||||
@@ -99,15 +99,9 @@ public:
|
||||
|
||||
for (unsigned cube_it =0 ; cube_it < n_cubes; ++cube_it)
|
||||
{
|
||||
|
||||
unsigned corner[8];
|
||||
typename DerivedF::Scalar samples[12];
|
||||
unsigned char cubetype(0);
|
||||
unsigned int i;
|
||||
|
||||
|
||||
// get point indices of corner vertices
|
||||
for (i=0; i<8; ++i)
|
||||
for (int i=0; i<8; ++i)
|
||||
{
|
||||
// get cube coordinates
|
||||
unsigned int _idx = cube_it;
|
||||
@@ -115,144 +109,441 @@ public:
|
||||
unsigned int x = _idx % X; _idx /= X;
|
||||
unsigned int y = _idx % Y; _idx /= Y;
|
||||
unsigned int z = _idx;
|
||||
|
||||
// transform to point coordinates
|
||||
_idx = x + y*x_res + z*x_res*y_res;
|
||||
|
||||
// add offset
|
||||
corner[i] = _idx + offsets_[i];
|
||||
}
|
||||
add_cube(values,points,isovalue,corner,vertices,num_vertices,faces,num_faces,edge2vertex);
|
||||
}
|
||||
vertices.conservativeResize(num_vertices, Eigen::NoChange);
|
||||
faces.conservativeResize(num_faces, Eigen::NoChange);
|
||||
}
|
||||
|
||||
// Sparse index grid version
|
||||
MarchingCubes(const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const Eigen::MatrixBase<DerivedIndices> &cubes,
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
assert(values.cols() == 1);
|
||||
assert(points.cols() == 3);
|
||||
assert(cubes.cols() == 8);
|
||||
|
||||
if(cubes.rows() == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
faces.resize(10000,3);
|
||||
int num_faces = 0;
|
||||
|
||||
vertices.resize(10000,3);
|
||||
int num_vertices = 0;
|
||||
|
||||
|
||||
// determine cube type
|
||||
for (i=0; i<8; ++i)
|
||||
if (values(corner[i]) > 0.0)
|
||||
cubetype |= (1<<i);
|
||||
unsigned n_cubes = cubes.rows();
|
||||
|
||||
for (unsigned cube_it =0 ; cube_it < n_cubes; ++cube_it)
|
||||
{
|
||||
typedef Eigen::Matrix<typename DerivedIndices::Scalar, 1, 8> CubeIndexVector;
|
||||
|
||||
// trivial reject ?
|
||||
if (cubetype == 0 || cubetype == 255)
|
||||
continue;
|
||||
CubeIndexVector corner = cubes.row(cube_it);
|
||||
add_cube(values,points,isovalue,corner.data(),vertices,num_vertices,faces,num_faces,edge2vertex);
|
||||
}
|
||||
vertices.conservativeResize(num_vertices, Eigen::NoChange);
|
||||
faces.conservativeResize(num_faces, Eigen::NoChange);
|
||||
}
|
||||
|
||||
// Dense index grid function version
|
||||
template <typename DerivedValue, typename DerivedPoint>
|
||||
MarchingCubes(
|
||||
const std::function< DerivedValue(const DerivedPoint & ) > & value_fun,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
assert(points.cols() == 3);
|
||||
|
||||
// compute samples on cube's edges
|
||||
if (edgeTable[cubetype]&1)
|
||||
samples[0] = add_vertex(values, points, corner[0], corner[1], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&2)
|
||||
samples[1] = add_vertex(values, points, corner[1], corner[2], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&4)
|
||||
samples[2] = add_vertex(values, points, corner[3], corner[2], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&8)
|
||||
samples[3] = add_vertex(values, points, corner[0], corner[3], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&16)
|
||||
samples[4] = add_vertex(values, points, corner[4], corner[5], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&32)
|
||||
samples[5] = add_vertex(values, points, corner[5], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&64)
|
||||
samples[6] = add_vertex(values, points, corner[7], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&128)
|
||||
samples[7] = add_vertex(values, points, corner[4], corner[7], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&256)
|
||||
samples[8] = add_vertex(values, points, corner[0], corner[4], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&512)
|
||||
samples[9] = add_vertex(values, points, corner[1], corner[5], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&1024)
|
||||
samples[10] = add_vertex(values, points, corner[2], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&2048)
|
||||
samples[11] = add_vertex(values, points, corner[3], corner[7], vertices, num_vertices, edge2vertex);
|
||||
if(x_res <2 || y_res<2 ||z_res<2)
|
||||
return;
|
||||
faces.resize(10000,3);
|
||||
int num_faces = 0;
|
||||
|
||||
vertices.resize(10000,3);
|
||||
int num_vertices = 0;
|
||||
|
||||
unsigned n_cubes = (x_res-1) * (y_res-1) * (z_res-1);
|
||||
assert(unsigned(points.rows()) == x_res * y_res * z_res);
|
||||
|
||||
// connect samples by triangles
|
||||
for (i=0; triTable[cubetype][0][i] != -1; i+=3 )
|
||||
unsigned int offsets_[8];
|
||||
offsets_[0] = 0;
|
||||
offsets_[1] = 1;
|
||||
offsets_[2] = 1 + x_res;
|
||||
offsets_[3] = x_res;
|
||||
offsets_[4] = x_res*y_res;
|
||||
offsets_[5] = 1 + x_res*y_res;
|
||||
offsets_[6] = 1 + x_res + x_res*y_res;
|
||||
offsets_[7] = x_res + x_res*y_res;
|
||||
|
||||
for (unsigned cube_it =0 ; cube_it < n_cubes; ++cube_it)
|
||||
{
|
||||
unsigned corner[8];
|
||||
// get point indices of corner vertices
|
||||
for (int i=0; i<8; ++i)
|
||||
{
|
||||
num_faces++;
|
||||
if (num_faces > faces.rows())
|
||||
faces.conservativeResize(faces.rows()+10000, Eigen::NoChange);
|
||||
// get cube coordinates
|
||||
unsigned int _idx = cube_it;
|
||||
unsigned int X(x_res-1), Y(y_res-1);
|
||||
unsigned int x = _idx % X; _idx /= X;
|
||||
unsigned int y = _idx % Y; _idx /= Y;
|
||||
unsigned int z = _idx;
|
||||
// transform to point coordinates
|
||||
_idx = x + y*x_res + z*x_res*y_res;
|
||||
// add offset
|
||||
corner[i] = _idx + offsets_[i];
|
||||
}
|
||||
add_cube(value_fun,points,isovalue,corner,vertices,num_vertices,faces,num_faces,edge2vertex);
|
||||
}
|
||||
vertices.conservativeResize(num_vertices, Eigen::NoChange);
|
||||
faces.conservativeResize(num_faces, Eigen::NoChange);
|
||||
}
|
||||
|
||||
faces.row(num_faces-1) <<
|
||||
template <typename CubeIndexType>
|
||||
static void add_cube(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const double isovalue,
|
||||
const CubeIndexType corner[],
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
int &num_vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces,
|
||||
int & num_faces,
|
||||
MyMap &edge2vertex)
|
||||
{
|
||||
typedef typename DerivedFaces::Scalar SampleScalar;
|
||||
SampleScalar samples[12];
|
||||
unsigned char cubetype(0);
|
||||
|
||||
// determine cube type
|
||||
for (int i=0; i<8; ++i)
|
||||
{
|
||||
if (values(corner[i]) > isovalue)
|
||||
{
|
||||
cubetype |= (1<<i);
|
||||
}
|
||||
}
|
||||
|
||||
// trivial reject ?
|
||||
if (cubetype == 0 || cubetype == 255)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// compute samples on cube's edges
|
||||
if (edgeTable[cubetype]&1)
|
||||
samples[0] = add_vertex(values, points, isovalue, corner[0], corner[1], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&2)
|
||||
samples[1] = add_vertex(values, points, isovalue, corner[1], corner[2], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&4)
|
||||
samples[2] = add_vertex(values, points, isovalue, corner[3], corner[2], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&8)
|
||||
samples[3] = add_vertex(values, points, isovalue, corner[0], corner[3], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&16)
|
||||
samples[4] = add_vertex(values, points, isovalue, corner[4], corner[5], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&32)
|
||||
samples[5] = add_vertex(values, points, isovalue, corner[5], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&64)
|
||||
samples[6] = add_vertex(values, points, isovalue, corner[7], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&128)
|
||||
samples[7] = add_vertex(values, points, isovalue, corner[4], corner[7], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&256)
|
||||
samples[8] = add_vertex(values, points, isovalue, corner[0], corner[4], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&512)
|
||||
samples[9] = add_vertex(values, points, isovalue, corner[1], corner[5], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&1024)
|
||||
samples[10] = add_vertex(values, points, isovalue, corner[2], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&2048)
|
||||
samples[11] = add_vertex(values, points, isovalue, corner[3], corner[7], vertices, num_vertices, edge2vertex);
|
||||
|
||||
// connect samples by triangles
|
||||
for (int i=0; triTable[cubetype][0][i] != -1; i+=3 )
|
||||
{
|
||||
num_faces++;
|
||||
if (num_faces > faces.rows())
|
||||
{
|
||||
faces.conservativeResize(faces.rows()+10000, Eigen::NoChange);
|
||||
}
|
||||
faces.row(num_faces-1) <<
|
||||
samples[triTable[cubetype][0][i ]],
|
||||
samples[triTable[cubetype][0][i+1]],
|
||||
samples[triTable[cubetype][0][i+2]];
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vertices.conservativeResize(num_vertices, Eigen::NoChange);
|
||||
faces.conservativeResize(num_faces, Eigen::NoChange);
|
||||
|
||||
};
|
||||
|
||||
static typename DerivedF::Scalar add_vertex(const Eigen::PlainObjectBase<Derivedvalues> &values,
|
||||
const Eigen::PlainObjectBase<Derivedpoints> &points,
|
||||
unsigned int i0,
|
||||
unsigned int i1,
|
||||
Eigen::PlainObjectBase<Derivedvertices> &vertices,
|
||||
int &num_vertices,
|
||||
MyMap &edge2vertex)
|
||||
template <typename DerivedValue, typename DerivedPoint, typename CubeIndexType>
|
||||
static void add_cube(
|
||||
const std::function< DerivedValue(const DerivedPoint & ) > & value_fun,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const double isovalue,
|
||||
const CubeIndexType corner[],
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
int &num_vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces,
|
||||
int & num_faces,
|
||||
MyMap &edge2vertex)
|
||||
{
|
||||
typedef typename DerivedFaces::Scalar SampleScalar;
|
||||
SampleScalar samples[12];
|
||||
unsigned char cubetype(0);
|
||||
|
||||
// determine cube type
|
||||
for (int i=0; i<8; ++i)
|
||||
{
|
||||
if (value_fun(points.row(corner[i])) > isovalue)
|
||||
{
|
||||
cubetype |= (1<<i);
|
||||
}
|
||||
}
|
||||
|
||||
// trivial reject ?
|
||||
if (cubetype == 0 || cubetype == 255)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// compute samples on cube's edges
|
||||
if (edgeTable[cubetype]&1)
|
||||
samples[0] = add_vertex(value_fun, points, isovalue, corner[0], corner[1], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&2)
|
||||
samples[1] = add_vertex(value_fun, points, isovalue, corner[1], corner[2], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&4)
|
||||
samples[2] = add_vertex(value_fun, points, isovalue, corner[3], corner[2], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&8)
|
||||
samples[3] = add_vertex(value_fun, points, isovalue, corner[0], corner[3], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&16)
|
||||
samples[4] = add_vertex(value_fun, points, isovalue, corner[4], corner[5], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&32)
|
||||
samples[5] = add_vertex(value_fun, points, isovalue, corner[5], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&64)
|
||||
samples[6] = add_vertex(value_fun, points, isovalue, corner[7], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&128)
|
||||
samples[7] = add_vertex(value_fun, points, isovalue, corner[4], corner[7], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&256)
|
||||
samples[8] = add_vertex(value_fun, points, isovalue, corner[0], corner[4], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&512)
|
||||
samples[9] = add_vertex(value_fun, points, isovalue, corner[1], corner[5], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&1024)
|
||||
samples[10] = add_vertex(value_fun, points, isovalue, corner[2], corner[6], vertices, num_vertices, edge2vertex);
|
||||
if (edgeTable[cubetype]&2048)
|
||||
samples[11] = add_vertex(value_fun, points, isovalue, corner[3], corner[7], vertices, num_vertices, edge2vertex);
|
||||
|
||||
// connect samples by triangles
|
||||
for (int i=0; triTable[cubetype][0][i] != -1; i+=3 )
|
||||
{
|
||||
num_faces++;
|
||||
if (num_faces > faces.rows())
|
||||
{
|
||||
faces.conservativeResize(faces.rows()+10000, Eigen::NoChange);
|
||||
}
|
||||
faces.row(num_faces-1) <<
|
||||
samples[triTable[cubetype][0][i ]],
|
||||
samples[triTable[cubetype][0][i+1]],
|
||||
samples[triTable[cubetype][0][i+2]];
|
||||
}
|
||||
};
|
||||
|
||||
static typename DerivedFaces::Scalar add_vertex(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const double isovalue,
|
||||
unsigned int i0,
|
||||
unsigned int i1,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
int &num_vertices,
|
||||
MyMap &edge2vertex)
|
||||
{
|
||||
// find vertex if it has been computed already
|
||||
MyMapIterator it = edge2vertex.find(EdgeKey(i0, i1));
|
||||
if (it != edge2vertex.end())
|
||||
{
|
||||
return it->second;
|
||||
;
|
||||
}
|
||||
|
||||
// generate new vertex
|
||||
const Eigen::Matrix<typename Derivedpoints::Scalar, 1, 3> & p0 = points.row(i0);
|
||||
const Eigen::Matrix<typename Derivedpoints::Scalar, 1, 3> & p1 = points.row(i1);
|
||||
|
||||
typename Derivedvalues::Scalar s0 = fabs(values(i0));
|
||||
typename Derivedvalues::Scalar s1 = fabs(values(i1));
|
||||
typename Derivedvalues::Scalar t = s0 / (s0+s1);
|
||||
|
||||
|
||||
const Eigen::Matrix<typename DerivedPoints::Scalar, 1, 3> & p0 = points.row(i0);
|
||||
const Eigen::Matrix<typename DerivedPoints::Scalar, 1, 3> & p1 = points.row(i1);
|
||||
typename DerivedValues::Scalar s0 = fabs(values(i0)-isovalue);
|
||||
typename DerivedValues::Scalar s1 = fabs(values(i1)-isovalue);
|
||||
typename DerivedValues::Scalar t = s0 / (s0+s1);
|
||||
num_vertices++;
|
||||
if (num_vertices > vertices.rows())
|
||||
{
|
||||
vertices.conservativeResize(vertices.rows()+10000, Eigen::NoChange);
|
||||
|
||||
}
|
||||
//
|
||||
// Linear interpolation based on linearly interpolating values
|
||||
vertices.row(num_vertices-1) = ((1.0f-t)*p0 + t*p1).template cast<typename Derivedvertices::Scalar>();
|
||||
vertices.row(num_vertices-1) = ((1.0f-t)*p0 + t*p1).template cast<typename DerivedVertices::Scalar>();
|
||||
edge2vertex[EdgeKey(i0, i1)] = num_vertices-1;
|
||||
return num_vertices-1;
|
||||
}
|
||||
|
||||
template <typename DerivedValue, typename DerivedPoint>
|
||||
static typename DerivedFaces::Scalar add_vertex(
|
||||
const std::function< DerivedValue(const DerivedPoint & ) > & value_fun,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const double isovalue,
|
||||
unsigned int i0,
|
||||
unsigned int i1,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
int &num_vertices,
|
||||
MyMap &edge2vertex)
|
||||
{
|
||||
// find vertex if it has been computed already
|
||||
MyMapIterator it = edge2vertex.find(EdgeKey(i0, i1));
|
||||
if (it != edge2vertex.end())
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
num_vertices++;
|
||||
if (num_vertices > vertices.rows())
|
||||
{
|
||||
vertices.conservativeResize(vertices.rows()+10000, Eigen::NoChange);
|
||||
}
|
||||
|
||||
// generate new vertex
|
||||
typedef Eigen::Matrix<typename DerivedPoints::Scalar, 1, 3> RowVector3S;
|
||||
const RowVector3S & p0 = points.row(i0);
|
||||
const RowVector3S & p1 = points.row(i1);
|
||||
// Linear interpolation based on linearly interpolating values
|
||||
//typename DerivedValues::Scalar s0 = fabs(value_fun(points.row(i0))-isovalue);
|
||||
//typename DerivedValues::Scalar s1 = fabs(value_fun(points.row(i1))-isovalue);
|
||||
//typename DerivedValues::Scalar t = s0 / (s0+s1);
|
||||
const DerivedValue v1 = value_fun(p1);
|
||||
double t0 = (v1>isovalue)?0:1;
|
||||
double t1 = (v1>isovalue)?1:0;
|
||||
double t;
|
||||
for(int j = 0;j<10;j++)
|
||||
{
|
||||
t = 0.5*(t0+t1);
|
||||
const double val = value_fun( ((1.0f-t)*p0 + t*p1) );
|
||||
if( val > isovalue )
|
||||
{
|
||||
t1 = t;
|
||||
}else
|
||||
{
|
||||
t0 = t;
|
||||
}
|
||||
}
|
||||
vertices.row(num_vertices-1) = ((1.0f-t)*p0 + t*p1).template cast<typename DerivedVertices::Scalar>();
|
||||
|
||||
edge2vertex[EdgeKey(i0, i1)] = num_vertices-1;
|
||||
|
||||
return num_vertices-1;
|
||||
}
|
||||
;
|
||||
|
||||
// maps an edge to the sample vertex generated on it
|
||||
MyMap edge2vertex;
|
||||
};
|
||||
|
||||
|
||||
template <typename Derivedvalues, typename Derivedpoints, typename Derivedvertices, typename DerivedF>
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedFaces>
|
||||
IGL_INLINE void igl::copyleft::marching_cubes(
|
||||
const Eigen::PlainObjectBase<Derivedvalues> &values,
|
||||
const Eigen::PlainObjectBase<Derivedpoints> &points,
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
Eigen::PlainObjectBase<Derivedvertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedF> &faces)
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
MarchingCubes<Derivedvalues, Derivedpoints, Derivedvertices, DerivedF> mc(values,
|
||||
points,
|
||||
x_res,
|
||||
y_res,
|
||||
z_res,
|
||||
vertices,
|
||||
faces);
|
||||
typedef Eigen::MatrixXi Shim; /* DerivedIndices shim type is unused in this instantiation*/
|
||||
MarchingCubes<DerivedValues, DerivedPoints, DerivedVertices, Shim, DerivedFaces>
|
||||
mc(values, points, x_res, y_res, z_res, isovalue, vertices, faces);
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedValue,
|
||||
typename DerivedPoint,
|
||||
typename DerivedPoints,
|
||||
typename DerivedVertices,
|
||||
typename DerivedFaces>
|
||||
IGL_INLINE void igl::copyleft::marching_cubes(
|
||||
const std::function< DerivedValue(const DerivedPoint & ) > & value_fun,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
MarchingCubes<
|
||||
Eigen::Matrix<DerivedValue,Eigen::Dynamic,1>, /* unnecessary */
|
||||
DerivedPoints, DerivedVertices,
|
||||
Eigen::Matrix<int,Eigen::Dynamic,1>, /* unnecessary */
|
||||
DerivedFaces> mc(value_fun, points, x_res, y_res, z_res, isovalue, vertices, faces);
|
||||
}
|
||||
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedFaces>
|
||||
IGL_INLINE void igl::copyleft::marching_cubes(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
typedef Eigen::MatrixXi Shim; /* DerivedIndices shim type is unused in this instantiation*/
|
||||
MarchingCubes<DerivedValues, DerivedPoints, DerivedVertices, Shim, DerivedFaces>
|
||||
mc(values, points, x_res, y_res, z_res, 0.0 /*isovalue*/, vertices, faces);
|
||||
}
|
||||
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedIndices, typename DerivedFaces>
|
||||
IGL_INLINE void igl::copyleft::marching_cubes(
|
||||
const Eigen::MatrixBase<DerivedValues>& values,
|
||||
const Eigen::MatrixBase<DerivedPoints>& points,
|
||||
const Eigen::MatrixBase<DerivedIndices>& indices,
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices>& vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
MarchingCubes<DerivedValues, DerivedPoints, DerivedVertices, DerivedIndices, DerivedFaces> mc(values, points, indices, isovalue, vertices, faces);
|
||||
}
|
||||
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedIndices, typename DerivedFaces>
|
||||
IGL_INLINE void igl::copyleft::marching_cubes(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const Eigen::MatrixBase<DerivedIndices> & indices,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces)
|
||||
{
|
||||
MarchingCubes<DerivedValues, DerivedPoints, DerivedVertices, DerivedIndices, DerivedFaces> mc(values, points, indices, 0.0 /*isovalue*/, vertices, faces);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes< 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<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<float, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<float, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<float, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<float, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 3, 1, -1, 3> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 1, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes<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<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<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<int, -1, -1, 0, -1, -1>, 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 Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, 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, 3, 0, -1, 3> >&, const Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, 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 Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, 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, 3, 0, -1, 3> >&, const Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<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<int, -1, 8, 0, -1, 8>, 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 Eigen::MatrixBase<Eigen::Matrix<int, -1, 8, 0, -1, 8> >&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<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<int, -1, -1, 0, -1, -1>,Eigen::Matrix<int, -1, 3, 0, -1, 3> >(const Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&,const Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&,const Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&,Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&,Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes<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<int, -1, 8, 0, -1, 8>,Eigen::Matrix<int, -1, 3, 0, -1, 3> >(const Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&,const Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&,const Eigen::MatrixBase<Eigen::Matrix<int, -1, 8, 0, -1, 8> >&,Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&,Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes<Eigen::Matrix<double, -1, 1, 0, -1, 1>,Eigen::Matrix<double, -1, 3, 0, -1, 3>,Eigen::Matrix<double, -1, 3, 0, -1, 3>,Eigen::Matrix<int, -1, 8, 0, -1, 8>,Eigen::Matrix<int, -1, 3, 0, -1, 3> >(const Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&,const Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&,const Eigen::MatrixBase<Eigen::Matrix<int, -1, 8, 0, -1, 8> >&,Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&,Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::copyleft::marching_cubes<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<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::copyleft::marching_cubes<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<int, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, unsigned int, unsigned int, unsigned int, double, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
|
||||
@@ -14,10 +14,10 @@ namespace igl
|
||||
{
|
||||
namespace copyleft
|
||||
{
|
||||
// marching_cubes( values, points, x_res, y_res, z_res, vertices, faces )
|
||||
// marching_cubes( values, points, x_res, y_res, z_res, isovalue, vertices, faces )
|
||||
//
|
||||
// performs marching cubes reconstruction on the grid defined by values, and
|
||||
// points, and generates vertices and faces
|
||||
// performs marching cubes reconstruction on a grid defined by values, and
|
||||
// points, and generates a mesh defined by vertices and faces
|
||||
//
|
||||
// Input:
|
||||
// values #number_of_grid_points x 1 array -- the scalar values of an
|
||||
@@ -34,24 +34,90 @@ namespace igl
|
||||
// xres resolutions of the grid in x dimension
|
||||
// yres resolutions of the grid in y dimension
|
||||
// zres resolutions of the grid in z dimension
|
||||
// isovalue the isovalue of the surface to reconstruct
|
||||
// Output:
|
||||
// vertices #V by 3 list of mesh vertex positions
|
||||
// faces #F by 3 list of mesh triangle indices
|
||||
//
|
||||
template <
|
||||
typename Derivedvalues,
|
||||
typename Derivedpoints,
|
||||
typename Derivedvertices,
|
||||
typename DerivedF>
|
||||
IGL_INLINE void marching_cubes(
|
||||
const Eigen::PlainObjectBase<Derivedvalues> &values,
|
||||
const Eigen::PlainObjectBase<Derivedpoints> &points,
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedFaces>
|
||||
IGL_INLINE void marching_cubes(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
Eigen::PlainObjectBase<Derivedvertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedF> &faces);
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces);
|
||||
template <
|
||||
typename DerivedValue,
|
||||
typename DerivedPoint,
|
||||
typename DerivedPoints,
|
||||
typename DerivedVertices,
|
||||
typename DerivedFaces>
|
||||
IGL_INLINE void marching_cubes(
|
||||
const std::function< DerivedValue(const DerivedPoint & ) > & value_fun,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces);
|
||||
|
||||
// Overload of the above function where the isovalue defaults to 0.0
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedFaces>
|
||||
IGL_INLINE void marching_cubes(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const unsigned x_res,
|
||||
const unsigned y_res,
|
||||
const unsigned z_res,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces);
|
||||
|
||||
|
||||
|
||||
// marching_cubes( values, points, indices, vertices, faces )
|
||||
//
|
||||
// Perform marching cubes reconstruction on the sparse grid cells defined by (indices, points).
|
||||
// The indices parameter is an nx8 dense array of index values into the points and values arrays.
|
||||
// Each row of indices represents a cube for which to generate vertices and faces over.
|
||||
//
|
||||
// Input:
|
||||
// values #number_of_grid_points x 1 array -- the scalar values of an
|
||||
// implicit function defined on the grid points (<0 in the inside of the
|
||||
// surface, 0 on the border, >0 outside)
|
||||
// points #number_of_grid_points x 3 array -- 3-D positions of the grid
|
||||
// points, ordered in x,y,z order:
|
||||
// indices #cubes x 8 array -- one row for each cube where each value is
|
||||
// the index of a vertex in points and a scalar in values.
|
||||
// i.e. points[indices[i, j]] = the position of the j'th vertex of the i'th cube
|
||||
// Output:
|
||||
// vertices #V by 3 list of mesh vertex positions
|
||||
// faces #F by 3 list of mesh triangle indices
|
||||
// Note: The winding direction of the cube indices will affect the output winding of the faces
|
||||
//
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedIndices, typename DerivedFaces>
|
||||
IGL_INLINE void marching_cubes(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const Eigen::MatrixBase<DerivedIndices> &indices,
|
||||
const double isovalue,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces);
|
||||
|
||||
// Overload of the above function where the isovalue defaults to 0.0
|
||||
template <typename DerivedValues, typename DerivedPoints, typename DerivedVertices, typename DerivedIndices, typename DerivedFaces>
|
||||
IGL_INLINE void marching_cubes(
|
||||
const Eigen::MatrixBase<DerivedValues> &values,
|
||||
const Eigen::MatrixBase<DerivedPoints> &points,
|
||||
const Eigen::MatrixBase<DerivedIndices> &indices,
|
||||
Eigen::PlainObjectBase<DerivedVertices> &vertices,
|
||||
Eigen::PlainObjectBase<DerivedFaces> &faces);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
|
||||
@@ -72,6 +72,7 @@ IGL_INLINE bool igl::opengl::render_to_tga(
|
||||
if(NULL==imgFile)
|
||||
{
|
||||
printf("IOError: %s could not be opened...\n",tga_file.c_str());
|
||||
free(genericImage);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -373,6 +373,7 @@ igl::opengl::gliReadTGA(FILE *fp, char *name, int /*hflip*/, int vflip)
|
||||
sprintf(error, "TGA: error reading colormap (ftell == %ld)\n",
|
||||
ftell (fp));
|
||||
if (_verbose) printf("%s\n", error);
|
||||
free(cmap);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,8 @@ IGL_INLINE void igl::copyleft::progressive_hulls_cost_and_placement(
|
||||
|
||||
assert(V.cols() == 3 && "V.cols() should be 3");
|
||||
// Gather list of unique face neighbors
|
||||
vector<int> Nall = circulation(e, true,F,E,EMAP,EF,EI);
|
||||
vector<int> Nother= circulation(e,false,F,E,EMAP,EF,EI);
|
||||
vector<int> Nall = circulation(e, true,EMAP,EF,EI);
|
||||
vector<int> Nother= circulation(e,false,EMAP,EF,EI);
|
||||
Nall.insert(Nall.end(),Nother.begin(),Nother.end());
|
||||
vector<int> N;
|
||||
igl::unique(Nall,N);
|
||||
|
||||
@@ -13,6 +13,94 @@
|
||||
// STL includes
|
||||
#include <cassert>
|
||||
|
||||
|
||||
IGL_INLINE bool igl::copyleft::tetgen::mesh_to_tetgenio(
|
||||
const std::vector<std::vector<REAL > > & V,
|
||||
const std::vector<std::vector<int> > & F,
|
||||
const std::vector<std::vector<REAL> > & H,
|
||||
const std::vector<std::vector<REAL> > & R,
|
||||
tetgenio & in)
|
||||
{
|
||||
using namespace std;
|
||||
in.firstnumber = 0;
|
||||
in.numberofpoints = V.size();
|
||||
in.pointlist = new REAL[in.numberofpoints * 3];
|
||||
//loop over points
|
||||
for(size_t i = 0; i < (size_t)V.size(); i++)
|
||||
{
|
||||
assert(V[i].size() == 3);
|
||||
in.pointlist[i*3+0] = V[i][0];
|
||||
in.pointlist[i*3+1] = V[i][1];
|
||||
in.pointlist[i*3+2] = V[i][2];
|
||||
}
|
||||
in.numberoffacets = F.size();
|
||||
in.facetlist = new tetgenio::facet[in.numberoffacets];
|
||||
in.facetmarkerlist = new int[in.numberoffacets];
|
||||
|
||||
// loop over face
|
||||
for(size_t i = 0;i < (size_t)F.size(); i++)
|
||||
{
|
||||
in.facetmarkerlist[i] = i;
|
||||
tetgenio::facet * f = &in.facetlist[i];
|
||||
f->numberofpolygons = 1;
|
||||
f->polygonlist = new tetgenio::polygon[f->numberofpolygons];
|
||||
f->numberofholes = 0;
|
||||
f->holelist = NULL;
|
||||
tetgenio::polygon * p = &f->polygonlist[0];
|
||||
p->numberofvertices = F[i].size();
|
||||
p->vertexlist = new int[p->numberofvertices];
|
||||
// loop around face
|
||||
for(int j = 0;j < (int)F[i].size(); j++)
|
||||
{
|
||||
p->vertexlist[j] = F[i][j];
|
||||
}
|
||||
}
|
||||
|
||||
in.numberofholes = H.size();
|
||||
in.holelist = new double[3 * in.numberofholes];
|
||||
// loop over holes
|
||||
for(size_t holeID = 0, nHoles = H.size(); holeID < nHoles; holeID++)
|
||||
{
|
||||
in.holelist[holeID * 3 + 0] = H[holeID][0];
|
||||
in.holelist[holeID * 3 + 1] = H[holeID][1];
|
||||
in.holelist[holeID * 3 + 2] = H[holeID][2];
|
||||
}
|
||||
|
||||
in.numberofregions = R.size();
|
||||
in.regionlist = new REAL[ 5 * in.numberofregions];
|
||||
// loop over regions
|
||||
for(size_t regionID = 0, nRegions = R.size(); regionID < nRegions; regionID++)
|
||||
{
|
||||
in.regionlist[regionID * 5 + 0] = R[regionID][0];
|
||||
in.regionlist[regionID * 5 + 1] = R[regionID][1];
|
||||
in.regionlist[regionID * 5 + 2] = R[regionID][2];
|
||||
in.regionlist[regionID * 5 + 3] = R[regionID][3];
|
||||
in.regionlist[regionID * 5 + 4] = R[regionID][4];
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedH, typename DerivedR>
|
||||
IGL_INLINE bool igl::copyleft::tetgen::mesh_to_tetgenio(
|
||||
const Eigen::PlainObjectBase<DerivedV>& V,
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::PlainObjectBase<DerivedH>& H,
|
||||
const Eigen::PlainObjectBase<DerivedR>& R,
|
||||
tetgenio & in)
|
||||
{
|
||||
using namespace std;
|
||||
vector<vector<REAL> > vV, vH, vR;
|
||||
vector<vector<int> > vF;
|
||||
matrix_to_list(V,vV);
|
||||
matrix_to_list(F,vF);
|
||||
matrix_to_list(H, vH);
|
||||
matrix_to_list(R, vR);
|
||||
return mesh_to_tetgenio(vV,vF,vH,vR,in);
|
||||
}
|
||||
|
||||
|
||||
IGL_INLINE bool igl::copyleft::tetgen::mesh_to_tetgenio(
|
||||
const std::vector<std::vector<REAL > > & V,
|
||||
const std::vector<std::vector<int> > & F,
|
||||
|
||||
@@ -43,6 +43,38 @@ namespace igl
|
||||
const Eigen::PlainObjectBase<DerivedV>& V,
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
tetgenio & in);
|
||||
|
||||
|
||||
// Load a vertex list and face list into a tetgenio object
|
||||
// Inputs:
|
||||
// V #V by 3 vertex position list
|
||||
// F #F list of polygon face indices into V (0-indexed)
|
||||
// H #H list of seed point inside each hole
|
||||
// R #R list of seed point inside each region
|
||||
// Outputs:
|
||||
// in tetgenio input object
|
||||
// Returns true on success, false on error
|
||||
IGL_INLINE bool mesh_to_tetgenio(
|
||||
const std::vector<std::vector<REAL> > & V,
|
||||
const std::vector<std::vector<int> > & F,
|
||||
const std::vector<std::vector<REAL > > & H,
|
||||
const std::vector<std::vector<REAL > > & R,
|
||||
tetgenio & in);
|
||||
|
||||
|
||||
// Wrapper with Eigen types
|
||||
// Templates:
|
||||
// DerivedV real-value: i.e. from MatrixXd
|
||||
// DerivedF integer-value: i.e. from MatrixXi
|
||||
// DerivedH real-value
|
||||
// DerivedR real-value
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedH, typename DerivedR>
|
||||
IGL_INLINE bool mesh_to_tetgenio(
|
||||
const Eigen::PlainObjectBase<DerivedV>& V,
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::PlainObjectBase<DerivedH>& H,
|
||||
const Eigen::PlainObjectBase<DerivedR>& R,
|
||||
tetgenio& in);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,120 @@
|
||||
// STL includes
|
||||
#include <iostream>
|
||||
|
||||
IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
|
||||
const tetgenio & out,
|
||||
std::vector<std::vector<REAL > > & V,
|
||||
std::vector<std::vector<int> > & T,
|
||||
std::vector<std::vector<int > > & F,
|
||||
std::vector<std::vector<REAL > >& R,
|
||||
std::vector<std::vector<int > >& N,
|
||||
std::vector<std::vector<int > >& PT,
|
||||
std::vector<std::vector<int > >& FT,
|
||||
size_t & nR )
|
||||
{
|
||||
using namespace std;
|
||||
// process points
|
||||
if(out.pointlist == NULL)
|
||||
{
|
||||
cerr<<"^tetgenio_to_tetmesh Error: point list is NULL\n"<<endl;
|
||||
return false;
|
||||
}
|
||||
V.resize(out.numberofpoints,vector<REAL>(3));
|
||||
// loop over points
|
||||
for(int i = 0;i < out.numberofpoints; i++)
|
||||
{
|
||||
V[i][0] = out.pointlist[i*3+0];
|
||||
V[i][1] = out.pointlist[i*3+1];
|
||||
V[i][2] = out.pointlist[i*3+2];
|
||||
}
|
||||
|
||||
// process tets
|
||||
if(out.tetrahedronlist == NULL)
|
||||
{
|
||||
cerr<<"^tetgenio_to_tetmesh Error: tet list is NULL\n"<<endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// When would this not be 4?
|
||||
assert(out.numberofcorners == 4);
|
||||
T.resize(out.numberoftetrahedra,vector<int>(out.numberofcorners));
|
||||
int min_index = 1e7;
|
||||
int max_index = -1e7;
|
||||
// loop over tetrahedra
|
||||
for(int i = 0; i < out.numberoftetrahedra; i++)
|
||||
{
|
||||
for(int j = 0; j<out.numberofcorners; j++)
|
||||
{
|
||||
int index = out.tetrahedronlist[i * out.numberofcorners + j];
|
||||
T[i][j] = index;
|
||||
min_index = (min_index > index ? index : min_index);
|
||||
max_index = (max_index < index ? index : max_index);
|
||||
}
|
||||
}
|
||||
|
||||
assert(min_index >= 0);
|
||||
assert(max_index >= 0);
|
||||
assert(max_index < (int)V.size());
|
||||
|
||||
cout<<out.numberoftrifaces<<endl;
|
||||
|
||||
// When would this not be 4?
|
||||
F.clear();
|
||||
// loop over tetrahedra
|
||||
for(int i = 0; i < out.numberoftrifaces; i++)
|
||||
{
|
||||
if(out.trifacemarkerlist[i]>=0)
|
||||
{
|
||||
vector<int> face(3);
|
||||
for(int j = 0; j<3; j++)
|
||||
{
|
||||
face[j] = out.trifacelist[i * 3 + j];
|
||||
}
|
||||
F.push_back(face);
|
||||
}
|
||||
}
|
||||
|
||||
R.resize(out.numberoftetrahedra, vector<REAL>(1));
|
||||
unordered_map<REAL, REAL> hashUniqueRegions;
|
||||
for(size_t i = 0; i < out.numberoftetrahedra; i++)
|
||||
{
|
||||
R[i][0] = out.tetrahedronattributelist[i];
|
||||
hashUniqueRegions[R[i][0]] = i;
|
||||
}
|
||||
// extract region marks
|
||||
nR = hashUniqueRegions.size();
|
||||
|
||||
// extract neighbor list
|
||||
N.resize(out.numberoftetrahedra, vector<int>(4));
|
||||
for (size_t i = 0; i < out.numberoftetrahedra; i++)
|
||||
{
|
||||
for (size_t j = 0; j < 4; j++)
|
||||
N[i][j] = out.neighborlist[i * 4 + j];
|
||||
}
|
||||
|
||||
// extract point 2 tetrahedron list
|
||||
PT.resize(out.numberofpoints, vector<int>(1));
|
||||
for (size_t i = 0; i < out.numberofpoints; i++)
|
||||
{
|
||||
PT[i][0] = out.point2tetlist[i];
|
||||
}
|
||||
|
||||
//extract face to tetrahedron list
|
||||
FT.resize(out.numberoftrifaces, vector<int>(2));
|
||||
int triface;
|
||||
|
||||
for (size_t i = 0; i < out.numberoftrifaces; i++)
|
||||
{
|
||||
for (size_t j = 0; j < 2; j++)
|
||||
{
|
||||
FT[i][j] = out.face2tetlist[0];
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
|
||||
const tetgenio & out,
|
||||
std::vector<std::vector<REAL > > & V,
|
||||
@@ -63,8 +177,6 @@ IGL_INLINE bool igl::copyleft::tetgen::tetgenio_to_tetmesh(
|
||||
assert(max_index >= 0);
|
||||
assert(max_index < (int)V.size());
|
||||
|
||||
cout<<out.numberoftrifaces<<endl;
|
||||
|
||||
// When would this not be 4?
|
||||
F.clear();
|
||||
// loop over tetrahedra
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#endif
|
||||
#include "tetgen.h" // Defined tetgenio, REAL
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <Eigen/Core>
|
||||
namespace igl
|
||||
{
|
||||
@@ -54,7 +55,32 @@ namespace igl
|
||||
const tetgenio & out,
|
||||
Eigen::PlainObjectBase<DerivedV>& V,
|
||||
Eigen::PlainObjectBase<DerivedT>& T);
|
||||
}
|
||||
|
||||
// Extract a tetrahedral mesh from a tetgenio object
|
||||
// Inputs:
|
||||
// out tetgenio output object
|
||||
// Outputs:
|
||||
// V #V by 3 vertex position list
|
||||
// T #T by 4 list of tetrahedra indices into V
|
||||
// F #F by 3 list of marked facets
|
||||
// R #T list of region IDs for tetrahedra
|
||||
// N #T by 2 list of neighbors for each tetrahedron
|
||||
// PT #V list of incident tetrahedron for each vertex
|
||||
// FT #F by 2 list of tetrahedra sharing each face
|
||||
// nR number of regions in output mesh
|
||||
// Returns true on success, false on error
|
||||
IGL_INLINE bool tetgenio_to_tetmesh(
|
||||
const tetgenio & out,
|
||||
std::vector<std::vector<REAL > > & V,
|
||||
std::vector<std::vector<int> > & T,
|
||||
std::vector<std::vector<int> > & F,
|
||||
std::vector<std::vector<REAL> > & R,// region marks for tetrahedrons
|
||||
std::vector<std::vector<int > > &N, // neighborlist per tet
|
||||
std::vector<std::vector<int > > &PT, // Point to tet list per point
|
||||
std::vector<std::vector<int > > &FT, // face to tet list
|
||||
size_t & nR); // number of regions
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,131 @@
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
|
||||
|
||||
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
|
||||
const std::vector<std::vector<REAL > > & V,
|
||||
const std::vector<std::vector<int> > & F,
|
||||
const std::vector<std::vector<REAL > > & H,
|
||||
const std::vector<std::vector<REAL > > & R,
|
||||
const std::string switches,
|
||||
std::vector<std::vector<REAL > > & TV,
|
||||
std::vector<std::vector<int > > & TT,
|
||||
std::vector<std::vector<int > > & TF,
|
||||
std::vector<std::vector<REAL > > &TR,
|
||||
std::vector<std::vector<int > > & TN,
|
||||
std::vector<std::vector<int > > & PT,
|
||||
std::vector<std::vector<int > > & FT,
|
||||
size_t & numRegions)
|
||||
{
|
||||
using namespace std;
|
||||
tetgenio in,out;
|
||||
bool success;
|
||||
success = mesh_to_tetgenio(V, F, H, R, in);
|
||||
if(!success)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
try
|
||||
{
|
||||
char * cswitches = new char[switches.size() + 1];
|
||||
strcpy(cswitches, switches.c_str());
|
||||
|
||||
::tetrahedralize(cswitches, &in, &out);
|
||||
delete[] cswitches;
|
||||
}catch(int e)
|
||||
{
|
||||
cerr <<"^"<<__FUNCTION__<<": TETGEN CRASHED...KABOOM!!"<<endl;
|
||||
return 1;
|
||||
}
|
||||
if(out.numberoftetrahedra == 0)
|
||||
{
|
||||
cerr<<"^"<<__FUNCTION__<<": Tetgen failed to create tets"<<endl;
|
||||
return 2;
|
||||
}
|
||||
success = tetgenio_to_tetmesh(out, TV, TT, TF, TR, TN, PT, FT, numRegions
|
||||
);
|
||||
if(!success)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedH,
|
||||
typename DerivedR,
|
||||
typename DerivedTV,
|
||||
typename DerivedTT,
|
||||
typename DerivedTF,
|
||||
typename DerivedTR>
|
||||
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
|
||||
const Eigen::PlainObjectBase<DerivedV>& V,
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::PlainObjectBase<DerivedH>& H,
|
||||
const Eigen::PlainObjectBase<DerivedR>& R,
|
||||
const std::string switches,
|
||||
Eigen::PlainObjectBase<DerivedTV>& TV,
|
||||
Eigen::PlainObjectBase<DerivedTT>& TT,
|
||||
Eigen::PlainObjectBase<DerivedTF>& TF,
|
||||
Eigen::PlainObjectBase<DerivedTR>& TR,
|
||||
Eigen::PlainObjectBase<DerivedTT>& TN,
|
||||
Eigen::PlainObjectBase<DerivedTT>& PT,
|
||||
Eigen::PlainObjectBase<DerivedTT>& FT,
|
||||
size_t & numRegions)
|
||||
{
|
||||
using namespace std;
|
||||
vector<vector<REAL> > vV, vH, vR, vTV, vTR;
|
||||
vector<vector<int> > vF,vTT,vTF, vTN, vPT, vFT;
|
||||
matrix_to_list(V,vV);
|
||||
matrix_to_list(F,vF);
|
||||
matrix_to_list(H, vH);
|
||||
matrix_to_list(R, vR);
|
||||
|
||||
int e = tetrahedralize(vV,vF,vH,vR,switches,vTV,vTT,vTF,vTR,vTN,vPT,vFT, numRegions);
|
||||
|
||||
if(e == 0)
|
||||
{
|
||||
bool TV_rect = list_to_matrix(vTV,TV);
|
||||
if(!TV_rect)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
bool TT_rect = list_to_matrix(vTT,TT);
|
||||
if(!TT_rect)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
bool TF_rect = list_to_matrix(vTF,TF);
|
||||
if(!TF_rect)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
bool TR_rect = list_to_matrix(vTR, TR);
|
||||
if(!TR_rect)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
bool TN_rect = list_to_matrix(vTN, TN);
|
||||
if(!TN_rect)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
bool PT_rect = list_to_matrix(vPT, PT);
|
||||
if(!PT_rect)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
bool FT_rect = list_to_matrix(vFT, FT);
|
||||
if(!FT_rect)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
|
||||
const std::vector<std::vector<REAL > > & V,
|
||||
const std::vector<std::vector<int> > & F,
|
||||
@@ -55,7 +180,7 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
//boundary_facets(TT,TF);
|
||||
boundary_facets(TT,TF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -208,7 +333,7 @@ IGL_INLINE int igl::copyleft::tetgen::tetrahedralize(
|
||||
for (int i = 0; i < out.numberofpoints; ++i) {
|
||||
TM[i] = out.pointmarkerlist[i];
|
||||
}
|
||||
//boundary_facets(TT,TF);
|
||||
boundary_facets(TT,TF);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,83 @@ namespace igl
|
||||
Eigen::PlainObjectBase<DerivedTT>& TT,
|
||||
Eigen::PlainObjectBase<DerivedTF>& TF,
|
||||
Eigen::PlainObjectBase<DerivedTM>& TM);
|
||||
}
|
||||
|
||||
|
||||
// Mesh the interior of a surface mesh (V,F) using tetgen
|
||||
//
|
||||
// Inputs:
|
||||
// V #V by 3 vertex position list
|
||||
// F #F list of polygon face indices into V (0-indexed)
|
||||
// H #H by 3 list of seed points inside holes
|
||||
// R #R by 5 list of region attributes
|
||||
|
||||
// switches string of tetgen options (See tetgen documentation) e.g.
|
||||
// "pq1.414a0.01" tries to mesh the interior of a given surface with
|
||||
// quality and area constraints
|
||||
// "" will mesh the convex hull constrained to pass through V (ignores F)
|
||||
// Outputs:
|
||||
// TV #V by 3 vertex position list
|
||||
// TT #T by 4 list of tet face indices
|
||||
// TF #F by 3 list of triangle face indices
|
||||
// TR #T list of region ID for each tetrahedron
|
||||
// TN #T by 4 list of indices neighbors for each tetrahedron
|
||||
// PT #V list of incident tetrahedron for a vertex
|
||||
// FT #F by 2 list of tetrahedrons sharing a triface
|
||||
// numRegions Number of regions in output mesh
|
||||
|
||||
// Returns status:
|
||||
// 0 success
|
||||
// 1 tetgen threw exception
|
||||
// 2 tetgen did not crash but could not create any tets (probably there are
|
||||
// holes, duplicate faces etc.)
|
||||
// -1 other error
|
||||
IGL_INLINE int tetrahedralize(
|
||||
const std::vector<std::vector<REAL> > &V,
|
||||
const std::vector<std::vector<int> > &F,
|
||||
const std::vector<std::vector<REAL> > &H,
|
||||
const std::vector<std::vector<REAL> > &R,
|
||||
|
||||
const std::string switches,
|
||||
|
||||
std::vector<std::vector<REAL > > & TV,
|
||||
std::vector<std::vector<int > > & TT,
|
||||
std::vector<std::vector<int > > & TF,
|
||||
std::vector<std::vector<REAL > > &TR,
|
||||
std::vector<std::vector<int > > &TN,
|
||||
std::vector<std::vector<int > > &PT,
|
||||
std::vector<std::vector<int > > &FT,
|
||||
size_t & numRegions);
|
||||
|
||||
|
||||
// Wrapper with Eigen types
|
||||
// Templates:
|
||||
// DerivedV real-value: i.e. from MatrixXd
|
||||
// DerivedF integer-value: i.e. from MatrixXi
|
||||
template <
|
||||
typename DerivedV,
|
||||
typename DerivedF,
|
||||
typename DerivedH,
|
||||
typename DerivedR,
|
||||
typename DerivedTV,
|
||||
typename DerivedTT,
|
||||
typename DerivedTF,
|
||||
typename DerivedTR>
|
||||
IGL_INLINE int tetrahedralize(
|
||||
const Eigen::PlainObjectBase<DerivedV>& V,
|
||||
const Eigen::PlainObjectBase<DerivedF>& F,
|
||||
const Eigen::PlainObjectBase<DerivedH>& H,
|
||||
const Eigen::PlainObjectBase<DerivedR>& R,
|
||||
const std::string switches,
|
||||
Eigen::PlainObjectBase<DerivedTV>& TV,
|
||||
Eigen::PlainObjectBase<DerivedTT>& TT,
|
||||
Eigen::PlainObjectBase<DerivedTF>& TF,
|
||||
Eigen::PlainObjectBase<DerivedTR>& TR,
|
||||
Eigen::PlainObjectBase<DerivedTT>& TN,
|
||||
Eigen::PlainObjectBase<DerivedTT>& PT,
|
||||
Eigen::PlainObjectBase<DerivedTT>& FT,
|
||||
size_t & numRegions);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace igl
|
||||
// Scalar scalar type for eigen sparse matrix (e.g. double)
|
||||
// Inputs:
|
||||
// V #V by dim list of mesh vertex positions
|
||||
// F #F by simplex_size list of mesh faces (must be triangles)
|
||||
// F #F by simplex_size list of mesh elements (triangles or tetrahedra)
|
||||
// Outputs:
|
||||
// L #V by #V cotangent matrix, each row i corresponding to V(i,:)
|
||||
//
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// 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
|
||||
@@ -50,6 +51,7 @@ IGL_INLINE void igl::cotmatrix_entries(
|
||||
C.resize(m,3);
|
||||
for(int i = 0;i<m;i++)
|
||||
{
|
||||
// Alec: I'm doubtful that using l2 here is actually improving numerics.
|
||||
C(i,0) = (l2(i,1) + l2(i,2) - l2(i,0))/dblA(i)/4.0;
|
||||
C(i,1) = (l2(i,2) + l2(i,0) - l2(i,1))/dblA(i)/4.0;
|
||||
C(i,2) = (l2(i,0) + l2(i,1) - l2(i,2))/dblA(i)/4.0;
|
||||
@@ -97,14 +99,49 @@ IGL_INLINE void igl::cotmatrix_entries(
|
||||
}
|
||||
}
|
||||
|
||||
template <typename Derivedl, typename DerivedC>
|
||||
IGL_INLINE void igl::cotmatrix_entries(
|
||||
const Eigen::MatrixBase<Derivedl>& l,
|
||||
Eigen::PlainObjectBase<DerivedC>& C)
|
||||
{
|
||||
using namespace Eigen;
|
||||
const int m = l.rows();
|
||||
assert(l.cols() == 3 && "Only triangles accepted");
|
||||
//Compute squared Edge lengths
|
||||
Matrix<typename DerivedC::Scalar,Dynamic,3> l2;
|
||||
l2 = l.array().square();
|
||||
// Alec: It's a little annoying that there's duplicate code here. The
|
||||
// "extrinic" version above is first computing squared edge lengths, taking
|
||||
// the square root and calling this. We can't have a cotmatrix_entries(l,l2,C)
|
||||
// overload because it will confuse Eigen with the cotmatrix_entries(V,F,C)
|
||||
// overload. In the end, I'd like to be convinced that using l2 directly above
|
||||
// is actually better numerically (or significantly faster) than just calling
|
||||
// edge_lengths and this cotmatrix_entries(l,C);
|
||||
//
|
||||
// double area
|
||||
Matrix<typename DerivedC::Scalar,Dynamic,1> dblA;
|
||||
doublearea(l,0.,dblA);
|
||||
// cotangents and diagonal entries for element matrices
|
||||
// correctly divided by 4 (alec 2010)
|
||||
C.resize(m,3);
|
||||
for(int i = 0;i<m;i++)
|
||||
{
|
||||
// Alec: I'm doubtful that using l2 here is actually improving numerics.
|
||||
C(i,0) = (l2(i,1) + l2(i,2) - l2(i,0))/dblA(i)/4.0;
|
||||
C(i,1) = (l2(i,2) + l2(i,0) - l2(i,1))/dblA(i)/4.0;
|
||||
C(i,2) = (l2(i,0) + l2(i,1) - l2(i,2))/dblA(i)/4.0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cotmatrix_entries<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cotmatrix_entries<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cotmatrix_entries<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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cotmatrix_entries<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cotmatrix_entries<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::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cotmatrix_entries<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 4, 0, -1, 4>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 4, 0, -1, 4> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cotmatrix_entries<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
#endif
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Alec Jacobson <alecjacobson@gmail.com>
|
||||
// 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
|
||||
@@ -28,6 +29,17 @@ namespace igl
|
||||
const Eigen::MatrixBase<DerivedV>& V,
|
||||
const Eigen::MatrixBase<DerivedF>& F,
|
||||
Eigen::PlainObjectBase<DerivedC>& C);
|
||||
// Intrinsic version.
|
||||
//
|
||||
// Inputs:
|
||||
// l #F by 3 list of triangle edge lengths (see edge_lengths)
|
||||
// Outputs:
|
||||
// C #F by 3 list of 1/2*cotangents corresponding angles
|
||||
// for triangles, columns correspond to edges [1,2],[2,0],[0,1]
|
||||
template <typename Derivedl, typename DerivedC>
|
||||
IGL_INLINE void cotmatrix_entries(
|
||||
const Eigen::MatrixBase<Derivedl>& l,
|
||||
Eigen::PlainObjectBase<DerivedC>& C);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
// 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 "cotmatrix_intrinsic.h"
|
||||
#include "cotmatrix_entries.h"
|
||||
#include <iostream>
|
||||
|
||||
template <typename Derivedl, typename DerivedF, typename Scalar>
|
||||
IGL_INLINE void igl::cotmatrix_intrinsic(
|
||||
const Eigen::MatrixBase<Derivedl> & l,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
Eigen::SparseMatrix<Scalar>& L)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
// Cribbed from cotmatrix
|
||||
|
||||
const int nverts = F.maxCoeff()+1;
|
||||
L.resize(nverts,nverts);
|
||||
Matrix<int,Dynamic,2> edges;
|
||||
int simplex_size = F.cols();
|
||||
// 3 for triangles, 4 for tets
|
||||
assert(simplex_size == 3);
|
||||
// This is important! it could decrease the comptuation time by a factor of 2
|
||||
// Laplacian for a closed 2d manifold mesh will have on average 7 entries per
|
||||
// row
|
||||
L.reserve(10*nverts);
|
||||
edges.resize(3,2);
|
||||
edges <<
|
||||
1,2,
|
||||
2,0,
|
||||
0,1;
|
||||
// Gather cotangents
|
||||
Matrix<Scalar,Dynamic,Dynamic> C;
|
||||
cotmatrix_entries(l,C);
|
||||
|
||||
vector<Triplet<Scalar> > IJV;
|
||||
IJV.reserve(F.rows()*edges.rows()*4);
|
||||
// Loop over triangles
|
||||
for(int i = 0; i < F.rows(); 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));
|
||||
IJV.push_back(Triplet<Scalar>(source,dest,C(i,e)));
|
||||
IJV.push_back(Triplet<Scalar>(dest,source,C(i,e)));
|
||||
IJV.push_back(Triplet<Scalar>(source,source,-C(i,e)));
|
||||
IJV.push_back(Triplet<Scalar>(dest,dest,-C(i,e)));
|
||||
}
|
||||
}
|
||||
L.setFromTriplets(IJV.begin(),IJV.end());
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::cotmatrix_intrinsic<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
template void igl::cotmatrix_intrinsic<Eigen::Matrix<double, -1, -1, 1, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 1, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
template void igl::cotmatrix_intrinsic<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 4, 0, -1, 4>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 4, 0, -1, 4> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
template void igl::cotmatrix_intrinsic<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
template void igl::cotmatrix_intrinsic<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, double>(Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int>&);
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
// 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 IGL_COTMATRIX_INTRINSIC_H
|
||||
#define IGL_COTMATRIX_INTRINSIC_H
|
||||
#include "igl_inline.h"
|
||||
|
||||
#include <Eigen/Dense>
|
||||
#include <Eigen/Sparse>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Constructs the cotangent stiffness matrix (discrete laplacian) for a given
|
||||
// mesh with faces F and edge lengths l.
|
||||
//
|
||||
// Inputs:
|
||||
// l #F by 3 list of (half-)edge lengths
|
||||
// F #F by 3 list of face indices into some (not necessarily
|
||||
// determined/embedable) list of vertex positions V. It is assumed #V ==
|
||||
// F.maxCoeff()+1
|
||||
// Outputs:
|
||||
// L #V by #V sparse Laplacian matrix
|
||||
//
|
||||
// See also: cotmatrix, intrinsic_delaunay_cotmatrix
|
||||
template <typename Derivedl, typename DerivedF, typename Scalar>
|
||||
IGL_INLINE void cotmatrix_intrinsic(
|
||||
const Eigen::MatrixBase<Derivedl> & l,
|
||||
const Eigen::MatrixBase<DerivedF> & F,
|
||||
Eigen::SparseMatrix<Scalar>& L);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "cotmatrix_intrinsic.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,132 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>, Olga Diamanti <olga.diam@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 "cross_field_mismatch.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <igl/comb_cross_field.h>
|
||||
#include <igl/per_face_normals.h>
|
||||
#include <igl/is_border_vertex.h>
|
||||
#include <igl/vertex_triangle_adjacency.h>
|
||||
#include <igl/triangle_triangle_adjacency.h>
|
||||
#include <igl/rotation_matrix_from_directions.h>
|
||||
#include <igl/PI.h>
|
||||
|
||||
namespace igl {
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedM>
|
||||
class MismatchCalculator
|
||||
{
|
||||
public:
|
||||
|
||||
const Eigen::PlainObjectBase<DerivedV> &V;
|
||||
const Eigen::PlainObjectBase<DerivedF> &F;
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD1;
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD2;
|
||||
|
||||
DerivedV N;
|
||||
|
||||
private:
|
||||
// internal
|
||||
std::vector<bool> V_border; // bool
|
||||
std::vector<std::vector<int> > VF;
|
||||
std::vector<std::vector<int> > VFi;
|
||||
|
||||
DerivedF TT;
|
||||
DerivedF TTi;
|
||||
|
||||
|
||||
private:
|
||||
///compute the mismatch between 2 faces
|
||||
inline int mismatchByCross(const int f0,
|
||||
const int f1)
|
||||
{
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0 = PD1.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1.row(f1);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0 = N.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1 = N.row(f1);
|
||||
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1Rot = igl::rotation_matrix_from_directions(n1,n0)*dir1;
|
||||
dir1Rot.normalize();
|
||||
|
||||
double angle_diff = atan2(dir1Rot.dot(PD2.row(f0)),dir1Rot.dot(PD1.row(f0)));
|
||||
|
||||
double step=igl::PI/2.0;
|
||||
int i=(int)std::floor((angle_diff/step)+0.5);
|
||||
int k=0;
|
||||
if (i>=0)
|
||||
k=i%4;
|
||||
else
|
||||
k=(-(3*i))%4;
|
||||
return k;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
inline MismatchCalculator(const Eigen::PlainObjectBase<DerivedV> &_V,
|
||||
const Eigen::PlainObjectBase<DerivedF> &_F,
|
||||
const Eigen::PlainObjectBase<DerivedV> &_PD1,
|
||||
const Eigen::PlainObjectBase<DerivedV> &_PD2):
|
||||
V(_V),
|
||||
F(_F),
|
||||
PD1(_PD1),
|
||||
PD2(_PD2)
|
||||
{
|
||||
igl::per_face_normals(V,F,N);
|
||||
V_border = igl::is_border_vertex(V,F);
|
||||
igl::vertex_triangle_adjacency(V,F,VF,VFi);
|
||||
igl::triangle_triangle_adjacency(F,TT,TTi);
|
||||
}
|
||||
|
||||
inline void calculateMismatch(Eigen::PlainObjectBase<DerivedM> &Handle_MMatch)
|
||||
{
|
||||
Handle_MMatch.setConstant(F.rows(),3,-1);
|
||||
for (size_t i=0;i<F.rows();i++)
|
||||
{
|
||||
for (int j=0;j<3;j++)
|
||||
{
|
||||
if (((int)i)==TT(i,j) || TT(i,j) == -1)
|
||||
Handle_MMatch(i,j)=0;
|
||||
else
|
||||
Handle_MMatch(i,j) = mismatchByCross(i, TT(i, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedM>
|
||||
IGL_INLINE void igl::cross_field_mismatch(const Eigen::PlainObjectBase<DerivedV> &V,
|
||||
const Eigen::PlainObjectBase<DerivedF> &F,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD1,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD2,
|
||||
const bool isCombed,
|
||||
Eigen::PlainObjectBase<DerivedM> &mismatch)
|
||||
{
|
||||
DerivedV PD1_combed;
|
||||
DerivedV PD2_combed;
|
||||
|
||||
if (!isCombed)
|
||||
igl::comb_cross_field(V,F,PD1,PD2,PD1_combed,PD2_combed);
|
||||
else
|
||||
{
|
||||
PD1_combed = PD1;
|
||||
PD2_combed = PD2;
|
||||
}
|
||||
igl::MismatchCalculator<DerivedV, DerivedF, DerivedM> sf(V, F, PD1_combed, PD2_combed);
|
||||
sf.calculateMismatch(mismatch);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::cross_field_mismatch<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const &, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const &, const bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > &);
|
||||
template void igl::cross_field_mismatch<Eigen::Matrix<double, -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 &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, const bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > &);
|
||||
template void igl::cross_field_mismatch<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const &, const bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > &);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,43 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>, Olga Diamanti <olga.diam@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_CROSS_FIELD_MISMATCH_H
|
||||
#define IGL_CROSS_FIELD_MISMATCH_H
|
||||
#include "igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
namespace igl
|
||||
{
|
||||
// Calculates the mismatch (integer), at each face edge, of a cross field defined on the mesh faces.
|
||||
// The integer mismatch is a multiple of pi/2 that transforms the cross on one side of the edge to
|
||||
// the cross on the other side. It represents the deviation from a Lie connection across the edge.
|
||||
|
||||
// Inputs:
|
||||
// V #V by 3 eigen Matrix of mesh vertex 3D positions
|
||||
// F #F by 3 eigen Matrix of face (quad) indices
|
||||
// PD1 #F by 3 eigen Matrix of the first per face cross field vector
|
||||
// PD2 #F by 3 eigen Matrix of the second per face cross field vector
|
||||
// isCombed boolean, specifying whether the field is combed (i.e. matching has been precomputed.
|
||||
// If not, the field is combed first.
|
||||
// Output:
|
||||
// mismatch #F by 3 eigen Matrix containing the integer mismatch of the cross field
|
||||
// across all face edges
|
||||
//
|
||||
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedM>
|
||||
IGL_INLINE void cross_field_mismatch(const Eigen::PlainObjectBase<DerivedV> &V,
|
||||
const Eigen::PlainObjectBase<DerivedF> &F,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD1,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD2,
|
||||
const bool isCombed,
|
||||
Eigen::PlainObjectBase<DerivedM> &mismatch);
|
||||
}
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
#include "cross_field_mismatch.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,142 +0,0 @@
|
||||
// This file is part of libigl, a simple c++ geometry processing library.
|
||||
//
|
||||
// Copyright (C) 2014 Daniele Panozzo <daniele.panozzo@gmail.com>, Olga Diamanti <olga.diam@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 "cross_field_missmatch.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <vector>
|
||||
#include <deque>
|
||||
#include <igl/comb_cross_field.h>
|
||||
#include <igl/per_face_normals.h>
|
||||
#include <igl/is_border_vertex.h>
|
||||
#include <igl/vertex_triangle_adjacency.h>
|
||||
#include <igl/triangle_triangle_adjacency.h>
|
||||
#include <igl/rotation_matrix_from_directions.h>
|
||||
#include <igl/PI.h>
|
||||
|
||||
namespace igl {
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedM>
|
||||
class MissMatchCalculator
|
||||
{
|
||||
public:
|
||||
|
||||
const Eigen::PlainObjectBase<DerivedV> &V;
|
||||
const Eigen::PlainObjectBase<DerivedF> &F;
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD1;
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD2;
|
||||
|
||||
DerivedV N;
|
||||
|
||||
private:
|
||||
// internal
|
||||
std::vector<bool> V_border; // bool
|
||||
std::vector<std::vector<int> > VF;
|
||||
std::vector<std::vector<int> > VFi;
|
||||
|
||||
DerivedF TT;
|
||||
DerivedF TTi;
|
||||
|
||||
|
||||
private:
|
||||
///compute the mismatch between 2 faces
|
||||
inline int MissMatchByCross(const int f0,
|
||||
const int f1)
|
||||
{
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir0 = PD1.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1 = PD1.row(f1);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n0 = N.row(f0);
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> n1 = N.row(f1);
|
||||
|
||||
Eigen::Matrix<typename DerivedV::Scalar, 3, 1> dir1Rot = igl::rotation_matrix_from_directions(n1,n0)*dir1;
|
||||
dir1Rot.normalize();
|
||||
|
||||
// TODO: this should be equivalent to the other code below, to check!
|
||||
// Compute the angle between the two vectors
|
||||
// double a0 = atan2(dir0.dot(B2.row(f0)),dir0.dot(B1.row(f0)));
|
||||
// double a1 = atan2(dir1Rot.dot(B2.row(f0)),dir1Rot.dot(B1.row(f0)));
|
||||
//
|
||||
// double angle_diff = a1-a0; //VectToAngle(f0,dir1Rot);
|
||||
|
||||
double angle_diff = atan2(dir1Rot.dot(PD2.row(f0)),dir1Rot.dot(PD1.row(f0)));
|
||||
|
||||
// std::cerr << "Dani: " << dir0(0) << " " << dir0(1) << " " << dir0(2) << " " << dir1Rot(0) << " " << dir1Rot(1) << " " << dir1Rot(2) << " " << angle_diff << std::endl;
|
||||
|
||||
double step=igl::PI/2.0;
|
||||
int i=(int)std::floor((angle_diff/step)+0.5);
|
||||
int k=0;
|
||||
if (i>=0)
|
||||
k=i%4;
|
||||
else
|
||||
k=(-(3*i))%4;
|
||||
return k;
|
||||
}
|
||||
|
||||
|
||||
public:
|
||||
inline MissMatchCalculator(const Eigen::PlainObjectBase<DerivedV> &_V,
|
||||
const Eigen::PlainObjectBase<DerivedF> &_F,
|
||||
const Eigen::PlainObjectBase<DerivedV> &_PD1,
|
||||
const Eigen::PlainObjectBase<DerivedV> &_PD2
|
||||
):
|
||||
V(_V),
|
||||
F(_F),
|
||||
PD1(_PD1),
|
||||
PD2(_PD2)
|
||||
{
|
||||
igl::per_face_normals(V,F,N);
|
||||
V_border = igl::is_border_vertex(V,F);
|
||||
igl::vertex_triangle_adjacency(V,F,VF,VFi);
|
||||
igl::triangle_triangle_adjacency(F,TT,TTi);
|
||||
}
|
||||
|
||||
inline void calculateMissmatch(Eigen::PlainObjectBase<DerivedM> &Handle_MMatch)
|
||||
{
|
||||
Handle_MMatch.setConstant(F.rows(),3,-1);
|
||||
for (size_t i=0;i<F.rows();i++)
|
||||
{
|
||||
for (int j=0;j<3;j++)
|
||||
{
|
||||
if (((int)i)==TT(i,j) || TT(i,j) == -1)
|
||||
Handle_MMatch(i,j)=0;
|
||||
else
|
||||
Handle_MMatch(i,j) = MissMatchByCross(i,TT(i,j));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
template <typename DerivedV, typename DerivedF, typename DerivedM>
|
||||
IGL_INLINE void igl::cross_field_missmatch(const Eigen::PlainObjectBase<DerivedV> &V,
|
||||
const Eigen::PlainObjectBase<DerivedF> &F,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD1,
|
||||
const Eigen::PlainObjectBase<DerivedV> &PD2,
|
||||
const bool isCombed,
|
||||
Eigen::PlainObjectBase<DerivedM> &missmatch)
|
||||
{
|
||||
DerivedV PD1_combed;
|
||||
DerivedV PD2_combed;
|
||||
|
||||
if (!isCombed)
|
||||
igl::comb_cross_field(V,F,PD1,PD2,PD1_combed,PD2_combed);
|
||||
else
|
||||
{
|
||||
PD1_combed = PD1;
|
||||
PD2_combed = PD2;
|
||||
}
|
||||
igl::MissMatchCalculator<DerivedV, DerivedF, DerivedM> sf(V, F, PD1_combed, PD2_combed);
|
||||
sf.calculateMissmatch(missmatch);
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::cross_field_missmatch<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
template void igl::cross_field_missmatch<Eigen::Matrix<double, -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&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cross_field_missmatch<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(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::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,76 @@
|
||||
// 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 "cumprod.h"
|
||||
#include <numeric>
|
||||
#include <iostream>
|
||||
|
||||
template <typename DerivedX, typename DerivedY>
|
||||
IGL_INLINE void igl::cumprod(
|
||||
const Eigen::MatrixBase<DerivedX > & X,
|
||||
const int dim,
|
||||
Eigen::PlainObjectBase<DerivedY > & Y)
|
||||
{
|
||||
using namespace Eigen;
|
||||
using namespace std;
|
||||
Y.resizeLike(X);
|
||||
// get number of columns (or rows)
|
||||
int num_outer = (dim == 1 ? X.cols() : X.rows() );
|
||||
// get number of rows (or columns)
|
||||
int num_inner = (dim == 1 ? X.rows() : X.cols() );
|
||||
// This has been optimized so that dim = 1 or 2 is roughly the same cost.
|
||||
// (Optimizations assume ColMajor order)
|
||||
if(dim == 1)
|
||||
{
|
||||
#pragma omp parallel for
|
||||
for(int o = 0;o<num_outer;o++)
|
||||
{
|
||||
typename DerivedX::Scalar prod = 1;
|
||||
for(int i = 0;i<num_inner;i++)
|
||||
{
|
||||
prod *= X(i,o);
|
||||
Y(i,o) = prod;
|
||||
}
|
||||
}
|
||||
}else
|
||||
{
|
||||
for(int i = 0;i<num_inner;i++)
|
||||
{
|
||||
// Notice that it is *not* OK to put this above the inner loop
|
||||
// Though here it doesn't seem to pay off...
|
||||
//#pragma omp parallel for
|
||||
for(int o = 0;o<num_outer;o++)
|
||||
{
|
||||
if(i == 0)
|
||||
{
|
||||
Y(o,i) = X(o,i);
|
||||
}else
|
||||
{
|
||||
Y(o,i) = Y(o,i-1) * X(o,i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cumprod<Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cumprod<Eigen::Matrix<double, 1, 4, 1, 1, 4>, Eigen::Matrix<double, 1, 4, 1, 1, 4> >(Eigen::MatrixBase<Eigen::Matrix<double, 1, 4, 1, 1, 4> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 4, 1, 1, 4> >&);
|
||||
template void igl::cumprod<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&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cumprod<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&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::cumprod<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
|
||||
template void igl::cumprod<Eigen::Matrix<unsigned long, 2, 1, 0, 2, 1>, Eigen::Matrix<unsigned long, 2, 1, 0, 2, 1> >(Eigen::MatrixBase<Eigen::Matrix<unsigned long, 2, 1, 0, 2, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<unsigned long, 2, 1, 0, 2, 1> >&);
|
||||
template void igl::cumprod<Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1>, Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >(Eigen::MatrixBase<Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<unsigned long, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::cumprod<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&, int, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
|
||||
#ifdef WIN32
|
||||
template void igl::cumprod<class Eigen::Matrix<unsigned __int64, -1, 1, 0, -1, 1>, class Eigen::Matrix<unsigned __int64, -1, 1, 0, -1, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<unsigned __int64, -1, 1, 0, -1, 1>> const &, int, class Eigen::PlainObjectBase<class Eigen::Matrix<unsigned __int64, -1, 1, 0, -1, 1>> &);
|
||||
template void igl::cumprod<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>, class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>>(class Eigen::MatrixBase<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>> const &, int, class Eigen::PlainObjectBase<class Eigen::Matrix<unsigned __int64, 2, 1, 0, 2, 1>> &);
|
||||
#endif
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
// 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 IGL_CUMPROD_H
|
||||
#define IGL_CUMPROD_H
|
||||
|
||||
#include "igl_inline.h"
|
||||
#include <Eigen/Core>
|
||||
|
||||
namespace igl
|
||||
{
|
||||
// Computes a cumulative product of the columns of X, like matlab's `cumprod`.
|
||||
//
|
||||
// Templates:
|
||||
// DerivedX Type of matrix X
|
||||
// DerivedY Type of matrix Y
|
||||
// Inputs:
|
||||
// X m by n Matrix to be cumulatively multiplied.
|
||||
// dim dimension to take cumulative product (1 or 2)
|
||||
// Output:
|
||||
// Y m by n Matrix containing cumulative product.
|
||||
//
|
||||
template <typename DerivedX, typename DerivedY>
|
||||
IGL_INLINE void cumprod(
|
||||
const Eigen::MatrixBase<DerivedX > & X,
|
||||
const int dim,
|
||||
Eigen::PlainObjectBase<DerivedY > & Y);
|
||||
//template <typename DerivedX, typename DerivedY>
|
||||
//IGL_INLINE void cumprod(
|
||||
// const Eigen::MatrixBase<DerivedX > & X,
|
||||
// Eigen::PlainObjectBase<DerivedY > & Y);
|
||||
}
|
||||
|
||||
#ifndef IGL_STATIC_LIBRARY
|
||||
# include "cumprod.cpp"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -59,6 +59,10 @@ IGL_INLINE void igl::cumsum(
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cumsum<Eigen::Matrix<double, 4, 1, 0, 4, 1>, Eigen::Matrix<double, 4, 1, 0, 4, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, 4, 1, 0, 4, 1> >&);
|
||||
// generated by autoexplicit.sh
|
||||
template void igl::cumsum<Eigen::Matrix<double, 1, 4, 1, 1, 4>, Eigen::Matrix<double, 1, 4, 1, 1, 4> >(Eigen::MatrixBase<Eigen::Matrix<double, 1, 4, 1, 1, 4> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, 1, 4, 1, 1, 4> >&);
|
||||
template void igl::cumsum<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&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
|
||||
template void igl::cumsum<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&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
|
||||
template void igl::cumsum<Eigen::Matrix<double, 3, 1, 0, 3, 1>, Eigen::Matrix<double, 3, 1, 0, 3, 1> >(Eigen::MatrixBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> > const&, int, Eigen::PlainObjectBase<Eigen::Matrix<double, 3, 1, 0, 3, 1> >&);
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
namespace igl
|
||||
{
|
||||
// Given a mesh (V,F) and the integer mismatch of a cross field per edge
|
||||
// (MMatch), finds the cut_graph connecting the singularities (seams) and the
|
||||
// (mismatch), finds the cut_graph connecting the singularities (seams) and the
|
||||
// degree of the singularities singularity_index
|
||||
//
|
||||
// Input:
|
||||
// V #V by 3 list of mesh vertex positions
|
||||
// F #F by 3 list of faces
|
||||
// MMatch #F by 3 list of per corner integer mismatch
|
||||
// mismatch #F by 3 list of per corner integer mismatch
|
||||
// Outputs:
|
||||
// seams #F by 3 list of per corner booleans that denotes if an edge is a
|
||||
// seam or not
|
||||
|
||||
@@ -0,0 +1,342 @@
|
||||
#include "cut_to_disk.h"
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <deque>
|
||||
#include <algorithm>
|
||||
|
||||
namespace igl {
|
||||
template <typename DerivedF, typename Index>
|
||||
void cut_to_disk(
|
||||
const Eigen::MatrixBase<DerivedF> &F,
|
||||
std::vector<std::vector<Index> > &cuts)
|
||||
{
|
||||
cuts.clear();
|
||||
|
||||
Index nfaces = F.rows();
|
||||
|
||||
if (nfaces == 0)
|
||||
return;
|
||||
|
||||
std::map<std::pair<Index, Index>, std::vector<Index> > edges;
|
||||
// build edges
|
||||
|
||||
for (Index i = 0; i < nfaces; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
Index v0 = F(i, j);
|
||||
Index v1 = F(i, (j + 1) % 3);
|
||||
std::pair<Index, Index> e;
|
||||
e.first = std::min(v0, v1);
|
||||
e.second = std::max(v0, v1);
|
||||
edges[e].push_back(i);
|
||||
}
|
||||
}
|
||||
|
||||
int nedges = edges.size();
|
||||
Eigen::Matrix<Index, -1, -1> edgeVerts(nedges,2);
|
||||
Eigen::Matrix<Index, -1, -1> edgeFaces(nedges,2);
|
||||
Eigen::Matrix<Index, -1, -1> faceEdges(nfaces, 3);
|
||||
std::set<Index> boundaryEdges;
|
||||
std::map<std::pair<Index, Index>, Index> edgeidx;
|
||||
Index idx = 0;
|
||||
for (auto it : edges)
|
||||
{
|
||||
edgeidx[it.first] = idx;
|
||||
edgeVerts(idx, 0) = it.first.first;
|
||||
edgeVerts(idx, 1) = it.first.second;
|
||||
edgeFaces(idx, 0) = it.second[0];
|
||||
if (it.second.size() > 1)
|
||||
{
|
||||
edgeFaces(idx, 1) = it.second[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
edgeFaces(idx, 1) = -1;
|
||||
boundaryEdges.insert(idx);
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
for (Index i = 0; i < nfaces; i++)
|
||||
{
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
Index v0 = F(i, j);
|
||||
Index v1 = F(i, (j + 1) % 3);
|
||||
std::pair<Index, Index> e;
|
||||
e.first = std::min(v0, v1);
|
||||
e.second = std::max(v0, v1);
|
||||
faceEdges(i, j) = edgeidx[e];
|
||||
}
|
||||
}
|
||||
|
||||
bool *deleted = new bool[nfaces];
|
||||
for (Index i = 0; i < nfaces; i++)
|
||||
deleted[i] = false;
|
||||
|
||||
std::set<Index> deletededges;
|
||||
|
||||
// loop over faces
|
||||
for (Index face = 0; face < nfaces; face++)
|
||||
{
|
||||
// stop at first undeleted face
|
||||
if (deleted[face])
|
||||
continue;
|
||||
deleted[face] = true;
|
||||
std::deque<Index> processEdges;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Index e = faceEdges(face, i);
|
||||
if (boundaryEdges.count(e))
|
||||
continue;
|
||||
int ndeleted = 0;
|
||||
if (deleted[edgeFaces(e, 0)])
|
||||
ndeleted++;
|
||||
if (deleted[edgeFaces(e, 1)])
|
||||
ndeleted++;
|
||||
if (ndeleted == 1)
|
||||
processEdges.push_back(e);
|
||||
}
|
||||
// delete all faces adjacent to edges with exactly one adjacent face
|
||||
while (!processEdges.empty())
|
||||
{
|
||||
Index nexte = processEdges.front();
|
||||
processEdges.pop_front();
|
||||
Index todelete = nfaces;
|
||||
if (!deleted[edgeFaces(nexte, 0)])
|
||||
todelete = edgeFaces(nexte, 0);
|
||||
if (!deleted[edgeFaces(nexte, 1)])
|
||||
todelete = edgeFaces(nexte, 1);
|
||||
if (todelete != nfaces)
|
||||
{
|
||||
deletededges.insert(nexte);
|
||||
deleted[todelete] = true;
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
Index e = faceEdges(todelete, i);
|
||||
if (boundaryEdges.count(e))
|
||||
continue;
|
||||
int ndeleted = 0;
|
||||
if (deleted[edgeFaces(e, 0)])
|
||||
ndeleted++;
|
||||
if (deleted[edgeFaces(e, 1)])
|
||||
ndeleted++;
|
||||
if (ndeleted == 1)
|
||||
processEdges.push_back(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
delete[] deleted;
|
||||
|
||||
// accumulated non-deleted edges
|
||||
std::vector<Index> leftedges;
|
||||
for (Index i = 0; i < nedges; i++)
|
||||
{
|
||||
if (!deletededges.count(i))
|
||||
leftedges.push_back(i);
|
||||
}
|
||||
|
||||
deletededges.clear();
|
||||
// prune spines
|
||||
std::map<Index, std::vector<Index> > spinevertedges;
|
||||
for (Index i : leftedges)
|
||||
{
|
||||
spinevertedges[edgeVerts(i, 0)].push_back(i);
|
||||
spinevertedges[edgeVerts(i, 1)].push_back(i);
|
||||
}
|
||||
|
||||
std::deque<Index> vertsProcess;
|
||||
std::map<Index, int> spinevertnbs;
|
||||
for (auto it : spinevertedges)
|
||||
{
|
||||
spinevertnbs[it.first] = it.second.size();
|
||||
if (it.second.size() == 1)
|
||||
vertsProcess.push_back(it.first);
|
||||
}
|
||||
while (!vertsProcess.empty())
|
||||
{
|
||||
Index vert = vertsProcess.front();
|
||||
vertsProcess.pop_front();
|
||||
for (Index e : spinevertedges[vert])
|
||||
{
|
||||
if (!deletededges.count(e))
|
||||
{
|
||||
deletededges.insert(e);
|
||||
for (int j = 0; j < 2; j++)
|
||||
{
|
||||
spinevertnbs[edgeVerts(e, j)]--;
|
||||
if (spinevertnbs[edgeVerts(e, j)] == 1)
|
||||
{
|
||||
vertsProcess.push_back(edgeVerts(e, j));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::vector<Index> loopedges;
|
||||
for (Index i : leftedges)
|
||||
if (!deletededges.count(i))
|
||||
loopedges.push_back(i);
|
||||
|
||||
Index nloopedges = loopedges.size();
|
||||
if (nloopedges == 0)
|
||||
return;
|
||||
|
||||
std::map<Index, std::vector<Index> > loopvertedges;
|
||||
for (Index e : loopedges)
|
||||
{
|
||||
loopvertedges[edgeVerts(e, 0)].push_back(e);
|
||||
loopvertedges[edgeVerts(e, 1)].push_back(e);
|
||||
}
|
||||
|
||||
std::set<Index> usededges;
|
||||
for (Index e : loopedges)
|
||||
{
|
||||
// make a cycle or chain starting from this edge
|
||||
while (!usededges.count(e))
|
||||
{
|
||||
std::vector<Index> cycleverts;
|
||||
std::vector<Index> cycleedges;
|
||||
cycleverts.push_back(edgeVerts(e, 0));
|
||||
cycleverts.push_back(edgeVerts(e, 1));
|
||||
cycleedges.push_back(e);
|
||||
|
||||
std::map<Index, Index> cycleidx;
|
||||
cycleidx[cycleverts[0]] = 0;
|
||||
cycleidx[cycleverts[1]] = 1;
|
||||
|
||||
Index curvert = edgeVerts(e, 1);
|
||||
Index cure = e;
|
||||
bool foundcycle = false;
|
||||
while (curvert != -1 && !foundcycle)
|
||||
{
|
||||
Index nextvert = -1;
|
||||
Index nexte = -1;
|
||||
for (Index cande : loopvertedges[curvert])
|
||||
{
|
||||
if (!usededges.count(cande) && cande != cure)
|
||||
{
|
||||
int vidx = 0;
|
||||
if (curvert == edgeVerts(cande, vidx))
|
||||
vidx = 1;
|
||||
nextvert = edgeVerts(cande, vidx);
|
||||
nexte = cande;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nextvert != -1)
|
||||
{
|
||||
auto it = cycleidx.find(nextvert);
|
||||
if (it != cycleidx.end())
|
||||
{
|
||||
// we've hit outselves
|
||||
std::vector<Index> cut;
|
||||
for (Index i = it->second; i < cycleverts.size(); i++)
|
||||
{
|
||||
cut.push_back(cycleverts[i]);
|
||||
}
|
||||
cut.push_back(nextvert);
|
||||
cuts.push_back(cut);
|
||||
for (Index i = it->second; i < cycleedges.size(); i++)
|
||||
{
|
||||
usededges.insert(cycleedges[i]);
|
||||
}
|
||||
usededges.insert(nexte);
|
||||
foundcycle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cycleidx[nextvert] = cycleverts.size();
|
||||
cycleverts.push_back(nextvert);
|
||||
cycleedges.push_back(nexte);
|
||||
}
|
||||
}
|
||||
curvert = nextvert;
|
||||
cure = nexte;
|
||||
}
|
||||
if (!foundcycle)
|
||||
{
|
||||
// we've hit a dead end. reverse and try the other direction
|
||||
std::reverse(cycleverts.begin(), cycleverts.end());
|
||||
std::reverse(cycleedges.begin(), cycleedges.end());
|
||||
cycleidx.clear();
|
||||
for (Index i = 0; i < cycleverts.size(); i++)
|
||||
{
|
||||
cycleidx[cycleverts[i]] = i;
|
||||
}
|
||||
|
||||
curvert = cycleverts.back();
|
||||
cure = cycleedges.back();
|
||||
while (curvert != -1 && !foundcycle)
|
||||
{
|
||||
Index nextvert = -1;
|
||||
Index nexte = -1;
|
||||
for (Index cande : loopvertedges[curvert])
|
||||
{
|
||||
if (!usededges.count(cande) && cande != cure)
|
||||
{
|
||||
int vidx = 0;
|
||||
if (curvert == edgeVerts(cande, vidx))
|
||||
vidx = 1;
|
||||
nextvert = edgeVerts(cande, vidx);
|
||||
nexte = cande;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nextvert != -1)
|
||||
{
|
||||
auto it = cycleidx.find(nextvert);
|
||||
if (it != cycleidx.end())
|
||||
{
|
||||
// we've hit outselves
|
||||
std::vector<int> cut;
|
||||
for (Index i = it->second; i < cycleverts.size(); i++)
|
||||
{
|
||||
cut.push_back(cycleverts[i]);
|
||||
}
|
||||
cut.push_back(nextvert);
|
||||
cuts.push_back(cut);
|
||||
for (Index i = it->second; i < cycleedges.size(); i++)
|
||||
{
|
||||
usededges.insert(cycleedges[i]);
|
||||
}
|
||||
usededges.insert(nexte);
|
||||
foundcycle = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
cycleidx[nextvert] = cycleverts.size();
|
||||
cycleverts.push_back(nextvert);
|
||||
cycleedges.push_back(nexte);
|
||||
}
|
||||
}
|
||||
curvert = nextvert;
|
||||
cure = nexte;
|
||||
}
|
||||
if (!foundcycle)
|
||||
{
|
||||
// we've found a chain
|
||||
std::vector<Index> cut;
|
||||
for (Index i = 0; i < cycleverts.size(); i++)
|
||||
{
|
||||
cut.push_back(cycleverts[i]);
|
||||
}
|
||||
cuts.push_back(cut);
|
||||
for (Index i = 0; i < cycleedges.size(); i++)
|
||||
{
|
||||
usededges.insert(cycleedges[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef IGL_STATIC_LIBRARY
|
||||
// Explicit template instantiation
|
||||
template void igl::cut_to_disk<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> > > >&);
|
||||
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user