diff --git a/.appveyor.yml b/.appveyor.yml index 295558993..1d8b5925d 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -1,22 +1,28 @@ version: 1.0.{build} -os: Visual Studio 2015 +os: Visual Studio 2017 test: off clone_folder: C:\projects\libigl branches: only: - master - alecjacobson + - cmake + - cgal install: - git submodule update --init --recursive - cinstall: python build_script: - echo Running cmake... - - cd c:\projects\libigl\tutorial + - cd c:\projects\libigl + - cd external - mkdir build - cd build - - cmake -D "LIBIGL_USE_STATIC_LIBRARY=ON" -G "Visual Studio 14 2015 Win64" ../ -# - cmake -G "Visual Studio 14 2015 Win64" ../ + - cmake -G "Visual Studio 15 2017 Win64" -T "host=x64" .. + - msbuild %MSBuildOptions% libigl_external.sln + - cd ../../tutorial + - mkdir build + - cd build + - cmake -D "LIBIGL_USE_STATIC_LIBRARY=ON" -D "LIBIGL_WITH_ANTTWEAKBAR=OFF" -D "BOOST_ROOT=../external/boost/" -G "Visual Studio 15 2017 Win64" ../ - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" -# - set MSBuildOptions=/v:m /p:Configuration=Release /logger:%MSBuildLogger% - set MSBuildOptions=/v:m /p:Configuration=Debug /logger:%MSBuildLogger% - msbuild %MSBuildOptions% libigl_tutorials.sln diff --git a/.gitignore b/.gitignore index f0fb7da9c..3fa0d594f 100644 --- a/.gitignore +++ b/.gitignore @@ -98,3 +98,5 @@ python/builddebug tutorial/.idea python/buildstatic tutorial/cmake-build-debug +.vscode/ +.idea/ diff --git a/.gitmodules b/.gitmodules index 0cc6c1948..334261809 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +1,3 @@ -[submodule "external/nanogui"] - path = external/nanogui -url=https://github.com/libigl/nanogui.git - fetchRecursiveSubmodules = true - ignore = dirty [submodule "external/embree"] path = external/embree url = https://github.com/embree/embree.git @@ -24,3 +19,15 @@ url=https://github.com/libigl/nanogui.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 diff --git a/.travis.yml b/.travis.yml index aae8fddab..4be93d046 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,26 @@ language: cpp sudo: false +dist: precise matrix: include: - os: linux compiler: gcc-4.8.1 script: - git submodule update --init --recursive - - mkdir external/nanogui/ext/glfw/include/GL - - wget --no-check-certificate -P external/nanogui/ext/glfw/include/GL http://www.opengl.org/registry/api/GL/glcorearb.h + - mkdir external/glfw/include/GL + - wget --no-check-certificate -P external/glfw/include/GL http://www.opengl.org/registry/api/GL/glcorearb.h - cd python - mkdir build - cd build - cmake -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 -DLIBIGL_WITH_EMBREE=OFF -DLIBIGL_USE_STATIC_LIBRARY=ON ../ - make -j 2 - cd ../tutorial - - python 101_FileIO.py || { cd ../; mkdir build2; cd build2; cmake -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 -DLIBIGL_WITH_EMBREE=OFF -DLIBIGL_USE_STATIC_LIBRARY=ON - DCHECK_UNDEFINED=ON; make -j 2; } + - python3 101_FileIO.py || { cd ../; mkdir build2; cd build2; cmake -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 -DLIBIGL_WITH_EMBREE=OFF -DLIBIGL_USE_STATIC_LIBRARY=ON - DCHECK_UNDEFINED=ON ../; make -j 2; } - cd ../../ - cd tutorial - mkdir build - cd build - - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 ../ + - cmake -DLIBIGL_USE_STATIC_LIBRARY=ON -DCMAKE_CXX_COMPILER=g++-4.8 -DCMAKE_C_COMPILER=gcc-4.8 -DLIBIGL_WITH_EMBREE=OFF ../ - make -j 2 addons: apt: diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 000000000..cbfe9b7b0 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,17 @@ +Before opening an issue on creating a pull request, please check the following: + +## Compilation Issues + +- If you are on Windows, did you select the **x64** version of the Visual Studio compiler? + +- If you have a **CMake issue**, make sure you follow the same approach as the [libigl-example-project](https://github.com/libigl/libigl-example-project) to build libigl with your project, and make sure that you can compile the example project. + +- If you have an issue with a **submodule**, check if your submodules are up to date. If you have a doubt about a submodule, delete its folder and run `git submodule update --init --recursive` in the libigl directory. + +- If you have an issue with a missing **template issue**, check if your code compile with the *header-only* option of libigl activated. Turn **`OFF`** the CMake option `LIBIGL_USE_STATIC_LIBRARY`: either modify your `CMakeCache.txt` via CMake GUI or ccmake, or delete your `CMakeCache.txt` and re-run `cmake -DLIBIGL_USE_STATIC_LIBRARY=OFF ..` in your build folder. + +- Make sure your read the [**FAQ**](https://github.com/libigl/libigl/wiki/FAQ) before asking a new question, and search [**existing issues**](https://github.com/libigl/libigl/issues?q=is%3Aissue+is%3Aclosed) for a problem similar to yours. + +- Make sure you read the informations contained in the libigl [homepage](https://github.com/libigl/libigl) as well as the [tutorials](http://libigl.github.io/libigl/tutorial/tutorial.html). + +- If none of these solve your problem, then please report your issue in the bug tracker! diff --git a/LICENSE b/LICENSE deleted file mode 100644 index de7f67652..000000000 --- a/LICENSE +++ /dev/null @@ -1,7 +0,0 @@ -Libigl is primarily licensed under MPL2 - - http://www.mozilla.org/MPL/2.0/ - - http://www.mozilla.org/MPL/2.0/FAQ.html - -Some files contain third-party code under other licenses: - - - tga.h/tga.cpp GNU GPL diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 000000000..4a5ab52de --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,40 @@ +Libigl is primarily licensed under MPL2 + - http://www.mozilla.org/MPL/2.0/ + - http://www.mozilla.org/MPL/2.0/FAQ.html + +All `.h` and `.cpp` _files_ directly in `include/igl` (but not necessarily in +sub-directories) are subject only to the terms of the MPL2; they should not +include any code that is covered by other/less-permissive licenses. + +The `.h` and `.cpp` _files_ in sub-directories of `include/igl` allow libigl to +integrate with external third-party libraries (e.g., those in `external/`) and +are subject to the MPL2, _**and**_ also the terms of licenses of the +corresponding external library. The licenses used by these libraries fall under +three categories: + +- common "free, non-copyleft licenses" (such as zlib, BSD, MIT, and public + domain) + - `include/igl/anttweakbar` + - `include/igl/embree` + - `include/igl/opengl` + - `include/igl/opengl/glfw` + - `include/igl/opengl2` + - `include/igl/png` + - `include/igl/viewer` + - `include/igl/xml` +- common "copyleft" licences (such as GPL, LGPL, and AGPL) + - `include/igl/copyleft` + - `include/igl/copyleft/cgal` + - `include/igl/copyleft/comiso` + - `include/igl/copyleft/cork` + - `include/igl/copyleft/tetgen` +- other "uncommon" licenses or commercial software + - `include/igl/lim` + - `include/igl/matlab` + - `include/igl/mosek` + - `include/igl/triangle` + +The Libigl code that interfaces with "copyleft" libraries is in +`include/igl/copyleft`. Only include these headers if you are accept the +licensing terms of the corresponding external library. For example, using +`include/igl/copyleft/tetgen` requires that you accept the terms of the AGPLv3. diff --git a/README.md b/README.md index c321259e3..ac01461e9 100644 --- a/README.md +++ b/README.md @@ -193,7 +193,7 @@ BibTeX entry: title = {{libigl}: A simple {C++} geometry processing library}, author = {Alec Jacobson and Daniele Panozzo and others}, note = {http://libigl.github.io/libigl/}, - year = {2016}, + year = {2017}, } ``` @@ -262,8 +262,6 @@ 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, Amir Vaxman, Nico Pietroni, Stefan Brugger, Kenshi Takayama, Wenzel Jakob, Nikolas De -Giorgis, Luigi Rocca, Leonardo Sacht, Kevin Walliman, Olga Sorkine-Hornung, and others. +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. diff --git a/RELEASE_HISTORY.md b/RELEASE_HISTORY.md index f1ea72fbf..b58648b50 100644 --- a/RELEASE_HISTORY.md +++ b/RELEASE_HISTORY.md @@ -37,7 +37,7 @@ Version | Short description 0.3.1 | Linearly dependent constraints in min_quad_with_fixed, SparseQR buggy 0.3.0 | Better active set method support 0.2.3 | More explicits, active set method, opengl/anttweakbar guards -0.2.2 | More explicit instanciations, faster sorts and uniques +0.2.2 | More explicit instantiations, faster sorts and uniques 0.2.1 | Bug fixes in barycenter and doublearea found by Martin Bisson 0.2.0 | XML serializer more stable and fixed bug in remove_duplicate_vertices 0.1.8 | Embree and xml (windows only) extras diff --git a/coding-guidelines.html b/coding-guidelines.html index 5352d4c52..6f7ec37c6 100644 --- a/coding-guidelines.html +++ b/coding-guidelines.html @@ -1,14 +1,11 @@ - +
A .dmat file contains a dense matrix in column major order. It can contain ASCII or binary data. Note that it is uncompressed so binary only reduces the -file size by 50%. But writing and reading binary is usualy faster. In MATLAB, +file size by 50%. But writing and reading binary is usually faster. In MATLAB, binary is almost 100x faster.
[#cols] [#rows]
-Then coefficents are written in column-major order in Little-endian 8-byte +Then coefficients are written in column-major order in Little-endian 8-byte double precision IEEE floating point format.
Note: Line endings must be '\n' aka char(10) aka line feeds.
A .tgf file contains a graph of describing a set of control handles/structures: -point controls, bones of a skelton and cages made of "cage edges". +point controls, bones of a skeleton and cages made of "cage edges".
The first part of the file consists of lines regarding each vertex of the graph. Each line reads:
diff --git a/file-formats/xml.html b/file-formats/xml.html
index e9652fa6c..b670af495 100644
--- a/file-formats/xml.html
+++ b/file-formats/xml.html
@@ -31,7 +31,7 @@ STL containers: std::array, std::vector, std::pair
Eigen types: Eigen::Matrix, Eigen::SparseMatrix
User defined types: XMLSerializable*.
-There can also be a hierachical structure like vector<int>, this will result in the following serialization:
+There can also be a hierarchical structure like vector<int>, this will result in the following serialization:
<group>
<vector size="3">
diff --git a/include/igl/AABB.cpp b/include/igl/AABB.cpp
index d71a53304..aa9e9231b 100644
--- a/include/igl/AABB.cpp
+++ b/include/igl/AABB.cpp
@@ -15,6 +15,7 @@
#include "sort.h"
#include "volume.h"
#include "ray_box_intersect.h"
+#include "parallel_for.h"
#include "ray_mesh_intersect.h"
#include
#include
@@ -27,7 +28,7 @@ template
template
IGL_INLINE void igl::AABB::init(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const Eigen::MatrixBase & bb_mins,
const Eigen::MatrixBase & bb_maxs,
const Eigen::MatrixBase & elements,
@@ -106,7 +107,7 @@ template <
typename DerivedI>
IGL_INLINE void igl::AABB::init(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const Eigen::MatrixBase & SI,
const Eigen::MatrixBase & I)
{
@@ -204,15 +205,15 @@ template
template
IGL_INLINE std::vector igl::AABB::find(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const Eigen::MatrixBase & q,
const bool first) const
{
using namespace std;
using namespace Eigen;
- assert(q.size() == DIM &&
+ assert(q.size() == DIM &&
"Query dimension should match aabb dimension");
- assert(Ele.cols() == V.cols()+1 &&
+ assert(Ele.cols() == V.cols()+1 &&
"AABB::find only makes sense for (d+1)-simplices");
const Scalar epsilon = igl::EPS();
// Check if outside bounding box
@@ -250,7 +251,7 @@ IGL_INLINE std::vector igl::AABB::find(
const Vector2S V2 = V.row(Ele(m_primitive,1));
const Vector2S V3 = V.row(Ele(m_primitive,2));
// Hack for now to keep templates simple. If becomes bottleneck
- // consider using std::enable_if_t
+ // consider using std::enable_if_t
const Vector2S q2 = q.head(2);
a1 = doublearea_single(V1,V2,q2);
a2 = doublearea_single(V2,V3,q2);
@@ -266,9 +267,9 @@ IGL_INLINE std::vector igl::AABB::find(
a3 /= sum;
a4 /= sum;
if(
- a1>=-epsilon &&
- a2>=-epsilon &&
- a3>=-epsilon &&
+ a1>=-epsilon &&
+ a2>=-epsilon &&
+ a3>=-epsilon &&
a4>=-epsilon)
{
return std::vector(1,m_primitive);
@@ -345,10 +346,10 @@ IGL_INLINE void igl::AABB::serialize(
template
template
-IGL_INLINE typename igl::AABB::Scalar
+IGL_INLINE typename igl::AABB::Scalar
igl::AABB::squared_distance(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & p,
int & i,
Eigen::PlainObjectBase & c) const
@@ -359,10 +360,10 @@ igl::AABB::squared_distance(
template
template
-IGL_INLINE typename igl::AABB::Scalar
+IGL_INLINE typename igl::AABB::Scalar
igl::AABB::squared_distance(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & p,
Scalar low_sqr_d,
Scalar up_sqr_d,
@@ -393,7 +394,7 @@ igl::AABB::squared_distance(
{
int i_left;
RowVectorDIMS c_left = c;
- Scalar sqr_d_left =
+ Scalar sqr_d_left =
m_left->squared_distance(V,Ele,p,low_sqr_d,sqr_d,i_left,c_left);
this->set_min(p,sqr_d_left,i_left,c_left,sqr_d,i,c);
looked_left = true;
@@ -401,8 +402,8 @@ igl::AABB::squared_distance(
const auto & look_right = [&]()
{
int i_right;
- Eigen::PlainObjectBase c_right = c;
- Scalar sqr_d_right =
+ RowVectorDIMS c_right = c;
+ Scalar sqr_d_right =
m_right->squared_distance(V,Ele,p,low_sqr_d,sqr_d,i_right,c_right);
this->set_min(p,sqr_d_right,i_right,c_right,sqr_d,i,c);
looked_right = true;
@@ -418,9 +419,9 @@ igl::AABB::squared_distance(
look_right();
}
// if haven't looked left and could be less than current min, then look
- Scalar left_up_sqr_d =
+ Scalar left_up_sqr_d =
m_left->m_box.squaredExteriorDistance(p.transpose());
- Scalar right_up_sqr_d =
+ Scalar right_up_sqr_d =
m_right->m_box.squaredExteriorDistance(p.transpose());
if(left_up_sqr_d < right_up_sqr_d)
{
@@ -449,10 +450,10 @@ igl::AABB::squared_distance(
template
template
-IGL_INLINE typename igl::AABB::Scalar
+IGL_INLINE typename igl::AABB::Scalar
igl::AABB::squared_distance(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & p,
Scalar up_sqr_d,
int & i,
@@ -464,13 +465,13 @@ igl::AABB::squared_distance(
template
template <
typename DerivedEle,
- typename DerivedP,
- typename DerivedsqrD,
- typename DerivedI,
+ typename DerivedP,
+ typename DerivedsqrD,
+ typename DerivedI,
typename DerivedC>
IGL_INLINE void igl::AABB::squared_distance(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const Eigen::MatrixBase & P,
Eigen::PlainObjectBase & sqrD,
Eigen::PlainObjectBase & I,
@@ -482,35 +483,37 @@ IGL_INLINE void igl::AABB::squared_distance(
C.resizeLike(P);
// O( #P * log #Ele ), where log #Ele is really the depth of this AABB
// hierarchy
- for(int p = 0;p
-template <
+template <
typename DerivedEle,
typename Derivedother_V,
typename Derivedother_Ele,
- typename DerivedsqrD,
- typename DerivedI,
+ typename DerivedsqrD,
+ typename DerivedI,
typename DerivedC>
IGL_INLINE void igl::AABB::squared_distance(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const AABB & other,
const Eigen::MatrixBase & other_V,
- const Eigen::MatrixBase & other_Ele,
+ const Eigen::MatrixBase & other_Ele,
Eigen::PlainObjectBase & sqrD,
Eigen::PlainObjectBase & I,
Eigen::PlainObjectBase & C) const
{
- assert(other_Ele.cols() == 1 &&
+ assert(other_Ele.cols() == 1 &&
"Only implemented for other as list of points");
assert(other_V.cols() == V.cols() && "other must match this dimension");
sqrD.setConstant(other_Ele.rows(),1,std::numeric_limits::infinity());
@@ -528,20 +531,20 @@ IGL_INLINE void igl::AABB::squared_distance(
}
template
-template <
+template <
typename DerivedEle,
typename Derivedother_V,
typename Derivedother_Ele,
- typename DerivedsqrD,
- typename DerivedI,
+ typename DerivedsqrD,
+ typename DerivedI,
typename DerivedC>
-IGL_INLINE typename igl::AABB::Scalar
+IGL_INLINE typename igl::AABB::Scalar
igl::AABB::squared_distance_helper(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const AABB * other,
const Eigen::MatrixBase & other_V,
- const Eigen::MatrixBase & other_Ele,
+ const Eigen::MatrixBase & other_Ele,
const Scalar /*up_sqr_d*/,
Eigen::PlainObjectBase & sqrD,
Eigen::PlainObjectBase & I,
@@ -584,7 +587,7 @@ IGL_INLINE typename igl::AABB::Scalar
return sqr_d;
}
- //// Exact minimum squared distance between arbitary primitives inside this and
+ //// Exact minimum squared distance between arbitrary primitives inside this and
//// othre's bounding boxes
//const auto & min_squared_distance = [&](
// const AABB * A,
@@ -731,9 +734,9 @@ IGL_INLINE typename igl::AABB::Scalar
//assert(mc == mm);
// Only look left/right in this_list if can possible decrease somebody's
// distance in this_tree.
- const Scalar min_this_other = min_squared_distance(this_tree,other_tree);
+ const Scalar min_this_other = min_squared_distance(this_tree,other_tree);
if(
- min_this_other < sqr_d &&
+ min_this_other < sqr_d &&
min_this_other < other_tree->m_low_sqr_d)
{
//cout<<"before: "<
template
IGL_INLINE void igl::AABB::leaf_squared_distance(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & p,
const Scalar low_sqr_d,
Scalar & sqr_d,
@@ -789,7 +792,7 @@ template
template
IGL_INLINE void igl::AABB::leaf_squared_distance(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & p,
Scalar & sqr_d,
int & i,
@@ -801,7 +804,7 @@ IGL_INLINE void igl::AABB::leaf_squared_distance(
template
IGL_INLINE void igl::AABB::set_min(
- const RowVectorDIMS &
+ const RowVectorDIMS &
#ifndef NDEBUG
p
#endif
@@ -831,10 +834,10 @@ IGL_INLINE void igl::AABB::set_min(
template
template
-IGL_INLINE bool
+IGL_INLINE bool
igl::AABB::intersect_ray(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & origin,
const RowVectorDIMS & dir,
std::vector & hits) const
@@ -874,10 +877,10 @@ igl::AABB::intersect_ray(
template
template
-IGL_INLINE bool
+IGL_INLINE bool
igl::AABB::intersect_ray(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & origin,
const RowVectorDIMS & dir,
igl::Hit & hit) const
@@ -932,10 +935,10 @@ igl::AABB::intersect_ray(
template
template
-IGL_INLINE bool
+IGL_INLINE bool
igl::AABB::intersect_ray(
const Eigen::MatrixBase & V,
- const Eigen::MatrixBase & Ele,
+ const Eigen::MatrixBase & Ele,
const RowVectorDIMS & origin,
const RowVectorDIMS & dir,
const Scalar _min_t,
@@ -1001,7 +1004,7 @@ igl::AABB::intersect_ray(
// This is a bullshit template because AABB annoyingly needs templates for bad
// combinations of 3D V with DIM=2 AABB
-//
+//
// _Define_ as a no-op rather than monkeying around with the proper code above
//
// Meanwhile, GCC seems to have a bug. Let's see if GCC likes using explicit
@@ -1022,6 +1025,10 @@ namespace igl
#ifdef IGL_STATIC_LIBRARY
// Explicit template instantiation
// generated by autoexplicit.sh
+template double igl::AABB, 3>::squared_distance >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix const&, double, double, int&, Eigen::PlainObjectBase >&) const;
+// generated by autoexplicit.sh
+template void igl::AABB, 3>::init >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&);
+// generated by autoexplicit.sh
// generated by autoexplicit.sh
template float igl::AABB, 3>::squared_distance >(Eigen::MatrixBase > const&, Eigen::MatrixBase > const&, Eigen::Matrix const&, float, float, int&, Eigen::PlainObjectBase >&) const;
// generated by autoexplicit.sh
diff --git a/include/igl/AtA_cached.cpp b/include/igl/AtA_cached.cpp
new file mode 100644
index 000000000..af7d0ad86
--- /dev/null
+++ b/include/igl/AtA_cached.cpp
@@ -0,0 +1,130 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2017 Daniele Panozzo
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "AtA_cached.h"
+
+#include
+#include
+#include
+
+template
+IGL_INLINE void igl::AtA_cached_precompute(
+ const Eigen::SparseMatrix& A,
+ igl::AtA_cached_data& data,
+ Eigen::SparseMatrix& AtA)
+{
+ // 1 Compute At (this could be avoided, but performance-wise it will not make a difference)
+ std::vector > Col_RowPtr;
+ std::vector > Col_IndexPtr;
+
+ Col_RowPtr.resize(A.cols());
+ Col_IndexPtr.resize(A.cols());
+
+ for (unsigned k=0; k= 0);
+ assert(row < A.rows());
+ assert(row >= 0);
+ assert(value_index >= 0);
+ assert(value_index < A.nonZeros());
+
+ Col_RowPtr[col].push_back(row);
+ Col_IndexPtr[col].push_back(value_index);
+ }
+ }
+
+ Eigen::SparseMatrix At = A.transpose();
+ At.makeCompressed();
+ AtA = At * A;
+ AtA.makeCompressed();
+
+ assert(AtA.isCompressed());
+
+ // If weights are not provided, use 1
+ if (data.W.size() == 0)
+ data.W = Eigen::VectorXd::Ones(A.rows());
+ assert(data.W.size() == A.rows());
+
+ data.I_outer.reserve(AtA.outerSize());
+ data.I_row.reserve(2*AtA.nonZeros());
+ data.I_col.reserve(2*AtA.nonZeros());
+ data.I_w.reserve(2*AtA.nonZeros());
+
+ // 2 Construct the rules
+ for (unsigned k=0; k= 0);
+ assert(row < AtA.rows());
+ assert(row >= 0);
+ assert(value_index >= 0);
+ assert(value_index < AtA.nonZeros());
+
+ data.I_outer.push_back(data.I_row.size());
+
+ // Find correspondences
+ unsigned i=0;
+ unsigned j=0;
+ while (i Col_RowPtr[col][j])
+ ++j;
+ else
+ ++i;
+
+ }
+ }
+ }
+ data.I_outer.push_back(data.I_row.size()); // makes it more efficient to iterate later on
+
+ igl::AtA_cached(A,data,AtA);
+}
+
+template
+IGL_INLINE void igl::AtA_cached(
+ const Eigen::SparseMatrix& A,
+ const igl::AtA_cached_data& data,
+ Eigen::SparseMatrix& AtA)
+{
+ for (unsigned i=0; i(Eigen::SparseMatrix const&, igl::AtA_cached_data const&, Eigen::SparseMatrix&);
+template void igl::AtA_cached_precompute(Eigen::SparseMatrix const&, igl::AtA_cached_data&, Eigen::SparseMatrix&);
+#endif
diff --git a/include/igl/AtA_cached.h b/include/igl/AtA_cached.h
new file mode 100644
index 000000000..776825411
--- /dev/null
+++ b/include/igl/AtA_cached.h
@@ -0,0 +1,70 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+//
+// Copyright (C) 2017 Daniele Panozzo
+//
+// This Source Code Form is subject to the terms of the Mozilla Public License
+// v. 2.0. If a copy of the MPL was not distributed with this file, You can
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_ATA_CACHED_H
+#define IGL_ATA_CACHED_H
+#include "igl_inline.h"
+#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
+#include
+#include
+namespace igl
+{
+ struct AtA_cached_data
+ {
+ // Weights
+ Eigen::VectorXd W;
+
+ // Flatten composition rules
+ std::vector I_row;
+ std::vector I_col;
+ std::vector I_w;
+
+ // For each entry of AtA, points to the beginning
+ // of the composition rules
+ std::vector I_outer;
+ };
+
+ // Computes At * W * A, where A is sparse and W is diagonal. Divides the
+ // construction in two phases, one
+ // for fixing the sparsity pattern, and one to populate it with values. Compared to
+ // evaluating it directly, this version is slower for the first time (since it requires a
+ // precomputation), but faster to the subsequent evaluations.
+ //
+ // Input:
+ // A m x n sparse matrix
+ // data stores the precomputed sparsity pattern, data.W contains the optional diagonal weights (stored as a dense vector). If W is not provided, it is replaced by the identity.
+ // Outputs:
+ // AtA m by m matrix computed as AtA * W * A
+ //
+ // Example:
+ // AtA_data = igl::AtA_cached_data();
+ // AtA_data.W = W;
+ // if (s.AtA.rows() == 0)
+ // igl::AtA_cached_precompute(s.A,s.AtA_data,s.AtA);
+ // else
+ // igl::AtA_cached(s.A,s.AtA_data,s.AtA);
+ template
+ IGL_INLINE void AtA_cached_precompute(
+ const Eigen::SparseMatrix& A,
+ AtA_cached_data& data,
+ Eigen::SparseMatrix& AtA
+ );
+
+ template
+ IGL_INLINE void AtA_cached(
+ const Eigen::SparseMatrix& A,
+ const AtA_cached_data& data,
+ Eigen::SparseMatrix& AtA
+ );
+
+}
+
+#ifndef IGL_STATIC_LIBRARY
+# include "AtA_cached.cpp"
+#endif
+
+#endif
diff --git a/include/igl/Camera.h b/include/igl/Camera.h
index 231bd8b56..1c8975dc0 100644
--- a/include/igl/Camera.h
+++ b/include/igl/Camera.h
@@ -23,7 +23,7 @@ namespace igl
// A simple camera class. The camera stores projection parameters (field of
// view angle, aspect ratio, near and far clips) as well as a rigid
- // tranformation *of the camera as if it were also a scene object*. Thus, the
+ // transformation *of the camera as if it were also a scene object*. Thus, the
// **inverse** of this rigid transformation is the modelview transformation.
class Camera
{
diff --git a/include/igl/ConjugateFFSolverData.h b/include/igl/ConjugateFFSolverData.h
deleted file mode 100644
index d32f49a44..000000000
--- a/include/igl/ConjugateFFSolverData.h
+++ /dev/null
@@ -1,375 +0,0 @@
-// This file is part of libigl, a simple c++ geometry processing library.
-//
-// Copyright (C) 2013 Olga Diamanti, 2015 Alec Jacobson
-//
-// 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_CONJUGATE_FF_SOLVER_DATA_H
-#define IGL_CONJUGATE_FF_SOLVER_DATA_H
-#include "igl_inline.h"
-#include
-#include
-#include
-using namespace std;
-namespace igl
-{
- // Data class for the Conjugate Frame Field Solver
- template
- class ConjugateFFSolverData
- {
- public:
- const Eigen::PlainObjectBase &V; int numV;
- const Eigen::PlainObjectBase &F; int numF;
-
- Eigen::MatrixXi EV; int numE;
- Eigen::MatrixXi F2E;
- Eigen::MatrixXi E2F;
- Eigen::VectorXd K;
-
- Eigen::VectorXi isBorderEdge;
- int numInteriorEdges;
- Eigen::Matrix E2F_int;
- Eigen::VectorXi indInteriorToFull;
- Eigen::VectorXi indFullToInterior;
-
- DerivedV B1, B2, FN;
-
-
- Eigen::Matrix kmin, kmax;
- Eigen::Matrix dmin, dmax;
- Eigen::Matrix dmin3, dmax3;
-
- Eigen::VectorXd nonPlanarityMeasure;
- Eigen::SparseMatrix > planarityWeight;
-
- //conjugacy matrix
- std::vector > H;
-
- //conjugacy matrix eigenvectors and (scaled) eigenvalues
- std::vector > UH;
- std::vector > s;
-
- //laplacians
- Eigen::SparseMatrix> DDA, DDB;
-
- private:
- IGL_INLINE void computeCurvatureAndPrincipals();
- IGL_INLINE void precomputeConjugacyStuff();
- IGL_INLINE void computeLaplacians();
- IGL_INLINE void computek();
- IGL_INLINE void computeCoefficientLaplacian(int n, Eigen::SparseMatrix > &D);
-
- IGL_INLINE void precomputeInteriorEdges();
-
-public:
- IGL_INLINE ConjugateFFSolverData(const Eigen::PlainObjectBase &_V,
- const Eigen::PlainObjectBase &_F);
- IGL_INLINE void evaluateConjugacy(const Eigen::Matrix &pvU,
- const Eigen::Matrix &pvV,
- Eigen::Matrix &conjValues) const ;
- };
-}
-
-#include
-#include
-#include
-#include
-#include
-#include
-
-template
-IGL_INLINE igl::ConjugateFFSolverData::
-ConjugateFFSolverData(const Eigen::PlainObjectBase &_V,
- const Eigen::PlainObjectBase &_F):
-V(_V),
-numV(_V.rows()),
-F(_F),
-numF(_F.rows())
-{
- igl::edge_topology(V,F,EV,F2E,E2F);
- numE = EV.rows();
-
- precomputeInteriorEdges();
-
- igl::local_basis(V,F,B1,B2,FN);
-
- computek();
-
- computeLaplacians();
-
- computeCurvatureAndPrincipals();
- precomputeConjugacyStuff();
-
-};
-
-
-template
-IGL_INLINE void igl::ConjugateFFSolverData::computeCurvatureAndPrincipals()
-{
- Eigen::MatrixXd VCBary;
- Eigen::MatrixXi FCBary;
-
- VCBary.setZero(numV+numF,3);
- FCBary.setZero(3*numF,3);
- igl::false_barycentric_subdivision(V, F, VCBary, FCBary);
-
- Eigen::MatrixXd dmax3_,dmin3_;
- igl::principal_curvature(VCBary, FCBary, dmax3_, dmin3_, kmax, kmin, 5,true);
-
- dmax3 = dmax3_.bottomRows(numF);
- dmin3 = dmin3_.bottomRows(numF);
-
- kmax = kmax.bottomRows(numF);
- kmin = kmin.bottomRows(numF);
-
- // kmax = dmax3.rowwise().norm();
- // kmin = dmin3.rowwise().norm();
-
- dmin3.rowwise().normalize();
- dmax3.rowwise().normalize();
- dmax.setZero(numF,2);
- dmin.setZero(numF,2);
- for (int i= 0; i (0, numF-1);
- igl::sparse(I, I, nonPlanarityMeasure, numF, numF, planarityWeight);
-
-}
-
-template
-IGL_INLINE void igl::ConjugateFFSolverData::precomputeConjugacyStuff()
-{
- H.resize(numF);
- UH.resize(numF);
- s.resize(numF);
-
- for (int i = 0; i