Browse Source

Merge branch 'master' of https://github.com/libigl/libigl

Former-commit-id: 1b92eb0ae8969af1116d607c4dc623a1d7c77e67
Olga Diamanti 10 years ago
parent
commit
ccdc2fb8af

+ 3 - 0
.gitignore

@@ -1,6 +1,9 @@
 # use glob syntax.
 syntax: glob
 scripts/change_name.sh
+*.so
+*.so.[0123456789]
+*.so.[0123456789].[0123456789]
 *.o
 *.a
 *.dylib

+ 116 - 50
README.md

@@ -4,28 +4,78 @@ libigl - A simple c++ geometry processing library
 <http://igl.ethz.ch/projects/libigl/>
 <https://github.com/alecjacobson/libigl/>
 
-Copyright 2013 - Alec Jacobson, Daniele Panozzo, Olga Diamanti, Kenshi
-Takayama, Leo Sacht, Wenzel Jacob
+Copyright 2014 - Alec Jacobson, Daniele Panozzo, Olga Diamanti, Kenshi
+Takayama, Leo Sacht, Wenzel Jacob, etc.
 
 This is first and foremost a *header* library. Each header file should contain
 a single function.  The function may have multiple prototypes. All functions
 should use the igl namespace and should adhere to the conventions and styles
 listed below.
 
-> **New:** As of 1 July 2014, we have release our libigl beta version 1.0. There are a
-> number of changes we collected for this release to minimize confusion and
-> changes to how you use libigl. See [Version 1.0 Changes][version1.0changes].
+> **New:** As of 1 July 2014, we have released libigl as beta version 1.0.
+> There are a number of changes we collected for this release to minimize
+> confusion and changes to how you use libigl. See [Version 1.0
+> Changes][version1.0changes].
+
+## Installation ##
+Libigl is a *header* library. You do **not** need to build anything to install.
+Simple add `igl/` to your include path and include relevant headers. Here's a
+small "Hello, World" program:
+
+```cpp
+#include <igl/cotmatrix.h>
+#include <Eigen/Dense>
+#include <Eigen/SparseMatrix>
+#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 on `gcc` with Eigen installed via
+macports for example you could compile this with:
+
+```bash
+gcc -I/opt/local/include/eigen3 -I./igl/ 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
+```
+
+## Tutorial ##
+
+As of version 1.0, libigl includes an introductory tutorial that covers its basic
+functionalities. See [tutorial/tutorial.md](./tutorial/tutorial.md) to get started.
 
 ## Dependencies ##
 - Eigen3  Last tested with Eigen Version 3.2
 
 ### Optional ###
-- OpenGL < 3.2 (`IGL_NO_OPENGL`)
-- OpenGL >= 4 (`IGL_OPENGL_4`)
-- AntTweakBar  (`IGL_NO_ANTTWEAKBAR`) Last tested 1.16 (see
--   libigl/external/AntTweakBar)
+- OpenGL (disable with `IGL_NO_OPENGL`)
+    * OpenGL >= 4 (enable with `IGL_OPENGL_4`)
+- AntTweakBar  (disable with `IGL_NO_ANTTWEAKBAR`) Last tested 1.16 (see
+  `libigl/external/AntTweakBar`)
 - GLEW  Windows and Linux
-- OpenMP  
+- OpenMP
 - libpng  libiglpng extra only
 - Mosek  libiglmosek extra only
 - Matlab  libiglmatlab extra only
@@ -45,7 +95,7 @@ listed below.
 - LIM  liblim extra only
 
 ## Header only ##
-libigl is designed to work "out-of-the-box" as a headers only library. To
+Libigl is designed to work "out-of-the-box" as a headers only library. To
 include libigl in your project. You need only include the libigl/include/
 directory in your include path. To
 compile a hello-word example.cpp:
@@ -76,18 +126,15 @@ Then run this example with:
 
     ./example examples/shared/TinyTorus.obj
 
-## Tutorial ##
-
-As of version 1.0, libigl includes an introductory tutorial that covers its basic
-functionalities. See [tutorial/tutorial.md](./tutorial/tutorial.md) to get started.
-
 ## Compilation as a static library ##
-libigl is developed most often on Mac OS X, though has current users in Linux and Windows.
+Libigl is developed most often on Mac OS X, though has current users in Linux
+and Windows.
 
 ### Linux/Mac OS X/Cygwin ###
 
-libigl may also be compiled to a static library. This is advantageous when
-building a project with libigl, since when used as an header-only library can slow down compile times.
+Libigl may also be compiled to a static library. This is advantageous when
+building a project with libigl, since when used as an header-only library can
+slow down compile times.
 
 To build the entire libigl library producing lib/libigl.a, issue:
 
@@ -277,36 +324,36 @@ current users should read and adapt their code accordingly.
 The following table lists functions which have changed name as of version
 1.0.0:
 
- Old | --> | New
- ----|-|----
- `igl::add_barycenter`| |`igl::false_barycentric_subdivision`
- `igl::areamatrix`| |`igl::vector_area_matrix`
- `igl::barycentric2global`| |`igl::barycentric_to_global`
- `igl::boundary_faces`| |`igl::boundary_facets`
- `igl::boundary_vertices_sorted`| |`igl::boundary_loop`
- `igl::cotangent`| |`igl::cotmatrix_entries`
- `igl::edgetopology`| |`igl::edge_topology`
- `igl::gradMat`| |`igl::grad`
- `igl::is_manifold`| |`igl::is_edge_manifold`
- `igl::mexStream`| |`igl::MexStream`
- `igl::moveFV`| |`igl::average_onto_vertices`
- `igl::moveVF`| |`igl::average_onto_faces`
- `igl::plot_vector`| |`igl::print_vector`
- `igl::pos`| |`igl::HalfEdgeIterator`
- `igl::plane_project`| |`igl::project_isometrically_to_plane`
- `igl::project_points_mesh`| |`igl::line_mesh_intersection`
- `igl::read`| |`igl::read_triangle_mesh`
- `igl::removeDuplicates.cpp`| |`igl::remove_duplicates`
- `igl::removeUnreferenced`| |`igl::remove_unreferenced`
- `igl::tt`| |`igl::triangle_triangle_adjacency`
- `igl::vf`| |`igl::vertex_triangle_adjacency`
- `igl::write`| |`igl::write_triangle_mesh`
- `igl::manifold_patches`| |`igl::orientable_patches`
- `igl::selfintersect`| |`igl::remesh_self_intersections`
- `igl::project_mesh`| |`igl::line_mesh_intersection`
- `igl::triangulate`| |`igl::polygon_mesh_to_triangle_mesh`
- `igl::is_manifold`| |`igl::is_edge_manifold`
- `igl::triangle_wrapper`| |`igl::triangulate`
+Old                              | New
+-------------------------------- | -------------------------------------
+`igl::add_barycenter`            | `igl::false_barycentric_subdivision`
+`igl::areamatrix`                | `igl::vector_area_matrix`
+`igl::barycentric2global`        | `igl::barycentric_to_global`
+`igl::boundary_faces`            | `igl::boundary_facets`
+`igl::boundary_vertices_sorted`  | `igl::boundary_loop`
+`igl::cotangent`                 | `igl::cotmatrix_entries`
+`igl::edgetopology`              | `igl::edge_topology`
+`igl::gradMat`                   | `igl::grad`
+`igl::is_manifold`               | `igl::is_edge_manifold`
+`igl::mexStream`                 | `igl::MexStream`
+`igl::moveFV`                    | `igl::average_onto_vertices`
+`igl::moveVF`                    | `igl::average_onto_faces`
+`igl::plot_vector`               | `igl::print_vector`
+`igl::pos`                       | `igl::HalfEdgeIterator`
+`igl::plane_project`             | `igl::project_isometrically_to_plane`
+`igl::project_points_mesh`       | `igl::line_mesh_intersection`
+`igl::read`                      | `igl::read_triangle_mesh`
+`igl::removeDuplicates.cpp`      | `igl::remove_duplicates`
+`igl::removeUnreferenced`        | `igl::remove_unreferenced`
+`igl::tt`                        | `igl::triangle_triangle_adjacency`
+`igl::vf`                        | `igl::vertex_triangle_adjacency`
+`igl::write`                     | `igl::write_triangle_mesh`
+`igl::manifold_patches`          | `igl::orientable_patches`
+`igl::selfintersect`             | `igl::remesh_self_intersections`
+`igl::project_mesh`              | `igl::line_mesh_intersection`
+`igl::triangulate`               | `igl::polygon_mesh_to_triangle_mesh`
+`igl::is_manifold`               | `igl::is_edge_manifold`
+`igl::triangle_wrapper`          | `igl::triangulate`
 
 ### Miscellaneous ###
  - To match interfaces provided by (all) other quadratic optimization
@@ -337,9 +384,28 @@ The following table lists functions which have changed name as of version
    these lines with mesh _B_, has been removed.
 
 ## Contact ##
-libigl is a group endeavor led by Alec Jacobson and Daniele Panozzo. Please
+Libigl is a group endeavor led by Alec Jacobson and Daniele Panozzo. Please
 contact [alecjacobson@gmail.com](mailto:alecjacobson@gmail.com) if you have
 questions or comments. We are happy to get feedback! Enjoy!
 
+If you're using libigl in your projects, quickly [drop us a
+note](mailto:alecjacobson@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).
+
+## Academic citation ##
+If you use libigl in your research 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://igl.ethz.ch/projects/libigl/},
+  year = {2013},
+}
+```

+ 1 - 1
build/Makefile

@@ -101,7 +101,7 @@ obj:
 	mkdir -p obj
 
 ../lib/libigl.a: obj $(OBJ_FILES)
-	mkdir -p lib
+	mkdir -p ../lib
 	rm -f $@
 	ar cqs $@ $(OBJ_FILES)
 

+ 5 - 0
include/igl/cotmatrix.h

@@ -38,6 +38,11 @@ namespace igl
   //
   // See also: adjacency_matrix
   //
+  // Note: This Laplacian uses the convention that diagonal entries are
+  // **minus** the sum of off-diagonal entries. The diagonal entries are
+  // therefore in general negative and the matrix is **negative** semi-definite
+  // (immediately, -L is **positive** semi-definite)
+  //
   // Known bugs: off by 1e-16 on regular grid. I think its a problem of
   // arithmetic order in cotmatrix_entries.h: C(i,e) = (arithmetic)/dblA/4
   template <typename DerivedV, typename DerivedF, typename Scalar>

+ 2 - 3
include/igl/draw_beach_ball.cpp

@@ -28,9 +28,6 @@
 ////////////////////////////////////////////////////////////////////////////
 // Begin Copied Straight from AntTweakBar
 ////////////////////////////////////////////////////////////////////////////
-static const float  FLOAT_EPS     = 1.0e-7f;
-static const float  FLOAT_EPS_SQ  = 1.0e-14f;
-static const float  FLOAT_PI      = 3.14159265358979323846f;
 enum EArrowParts     { ARROW_CONE, ARROW_CONE_CAP, ARROW_CYL, ARROW_CYL_CAP };
 
 template <typename T> SAFE_INLINE const T& TClamp(const T& X, const T& Limit1, const T& Limit2)
@@ -133,6 +130,7 @@ static void CreateSphere()
                     norm = sqrtf(x*x+y*y+z*z);
                     x /= norm; y /= norm; z /= norm;
                     s_SphTri.push_back(x); s_SphTri.push_back(y); s_SphTri.push_back(z);
+static const float  FLOAT_EPS     = 1.0e-7f;
                     if( u[l]+v[l]>FLOAT_EPS )
                         col = ColorBlend(COL_A[i], ColorBlend(COL_B[i], COL_C[i], v[l]/(u[l]+v[l])), u[l]+v[l]);
                     else
@@ -169,6 +167,7 @@ static void CreateArrow()
     float x0, x1, y0, y1, z0, z1, a0, a1, nx, nn;
     for(i=0; i<SUBDIV; ++i)
     {
+static const float  FLOAT_PI      = 3.14159265358979323846f;
         a0 = 2.0f*FLOAT_PI*(float(i))/SUBDIV;
         a1 = 2.0f*FLOAT_PI*(float(i+1))/SUBDIV;
         x0 = ARROW_BGN;

+ 5 - 0
include/igl/matlab/MatlabWorkspace.h

@@ -188,6 +188,11 @@ inline bool igl::MatlabWorkspace::write(const std::string & path) const
 {
   using namespace std;
   MATFile * mat_file = matOpen(path.c_str(), "w");
+  if(mat_file == NULL)
+  {
+    fprintf(stderr,"Error opening file %s\n",path.c_str());
+    return false;
+  }
   assert(names.size() == data.size());
   // loop over names and data
   for(int i = 0;i < (int)names.size(); i++)

+ 4 - 3
include/igl/min_quad_with_fixed.h

@@ -21,9 +21,10 @@ namespace igl
 {
   template <typename T>
   struct min_quad_with_fixed_data;
-  // Known Bugs: rows of Aeq **must** be linearly independent. Should be using
-  // QR decomposition otherwise:
-  //   http://www.okstate.edu/sas/v8/sashtml/ormp/chap5/sect32.htm
+  // Known Bugs: rows of Aeq **should probably** be linearly independent.
+  // During precomputation, the rows of a Aeq are checked via QR. But in case
+  // they're not then resulting probably will no longer be sparse: it will be
+  // slow.
   //
   // MIN_QUAD_WITH_FIXED Minimize quadratic energy 
   //

+ 2 - 4
include/igl/png/render_to_png_async.cpp

@@ -5,7 +5,6 @@
 // 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_NO_BOOST
 #include "render_to_png_async.h"
 #include <YImage.hpp>
 
@@ -43,7 +42,7 @@ static IGL_INLINE bool render_to_png_async_helper(
   return img->save(png_file.c_str(),fast);
 }
 
-IGL_INLINE boost::thread igl::render_to_png_async(
+IGL_INLINE std::thread igl::render_to_png_async(
   const std::string png_file,
   const int width,
   const int height,
@@ -62,6 +61,5 @@ IGL_INLINE boost::thread igl::render_to_png_async(
     GL_UNSIGNED_BYTE,
     img->data());
   // Part that should be asynchronous  
-  return boost::thread(render_to_png_async_helper,img,png_file,alpha,fast);
+  return std::thread(render_to_png_async_helper,img,png_file,alpha,fast);
 }
-#endif

+ 3 - 5
include/igl/png/render_to_png_async.h

@@ -5,11 +5,11 @@
 // 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_NO_BOOST
 #ifndef IGL_RENDER_TO_PNG_ASYNC_H
 #define IGL_RENDER_TO_PNG_ASYNC_H
 #include <igl/igl_inline.h>
-#include <boost/thread/thread.hpp>
+#include <thread>
+//#include <boost/thread/thread.hpp>
 
 #include <string>
 namespace igl
@@ -27,7 +27,7 @@ namespace igl
   // Returns true only if no errors occured
   //
   // See also: igl/render_to_tga which is faster but writes .tga files
-  IGL_INLINE boost::thread render_to_png_async(
+  IGL_INLINE std::thread render_to_png_async(
     const std::string png_file,
     const int width,
     const int height,
@@ -40,5 +40,3 @@ namespace igl
 #endif
 
 #endif
-
-#endif

+ 2 - 0
include/igl/svd3x3/svd3x3_avx.cpp

@@ -99,8 +99,10 @@ IGL_INLINE void igl::svd3x3_avx(
 }
 #pragma runtime_checks( "u", restore )
 
+#ifdef IGL_STATIC_LIBRARY
 // forced instantiation
 template void igl::svd3x3_avx(const Eigen::Matrix<float, 3*8, 3>& A, Eigen::Matrix<float, 3*8, 3> &U, Eigen::Matrix<float, 3*8, 1> &S, Eigen::Matrix<float, 3*8, 3>&V);
 // doesn't even make sense with double because the wunder-SVD code is only single precision anyway...
 template void igl::svd3x3_avx<float>(Eigen::Matrix<float, 24, 3, 0, 24, 3> const&, Eigen::Matrix<float, 24, 3, 0, 24, 3>&, Eigen::Matrix<float, 24, 1, 0, 24, 1>&, Eigen::Matrix<float, 24, 3, 0, 24, 3>&);
 #endif
+#endif

+ 18 - 9
include/igl/viewer/Viewer.cpp

@@ -76,6 +76,13 @@ static double highdpi = 1;
 static double scroll_x = 0;
 static double scroll_y = 0;
 
+namespace {
+void TW_CALL copy_str(std::string& dst, const std::string& src)
+{
+  dst = src;
+}
+}
+
 static void glfw_mouse_press(GLFWwindow* window, int button, int action, int modifier)
 {
   bool tw_used = TwEventMouseButtonGLFW(button, action);
@@ -904,17 +911,17 @@ namespace igl
       return EXIT_FAILURE;
     }
 
-	glfwMakeContextCurrent(window);
+  glfwMakeContextCurrent(window);
 
 #ifndef __APPLE__
-	glewExperimental = true;
-	GLenum err = glewInit();
-	if (GLEW_OK != err)
-	{
-		/* Problem: glewInit failed, something is seriously wrong. */
-		fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
-	}
-	fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
+  glewExperimental = true;
+  GLenum err = glewInit();
+  if (GLEW_OK != err)
+  {
+    /* Problem: glewInit failed, something is seriously wrong. */
+    fprintf(stderr, "Error: %s\n", glewGetErrorString(err));
+  }
+  fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION));
 #endif
 
     #ifdef DEBUG
@@ -931,6 +938,8 @@ namespace igl
 
     // Initialize AntTweakBar
     TwInit(TW_OPENGL_CORE, NULL);
+    TwCopyStdStringToClientFunc(static_cast<TwCopyStdStringToClient>(::copy_str));
+
 
     // Initialize IGL viewer
     init();

+ 3 - 5
include/igl/viewer/ViewerPlugin.h

@@ -8,7 +8,7 @@
 
 #ifndef IGL_VIEWER_PLUGIN_H
 #define IGL_VIEWER_PLUGIN_H
-
+#include <string>
 #include <igl/igl_inline.h>
 
 #ifdef ENABLE_XML_SERIALIZATION
@@ -39,9 +39,9 @@ public:
   #ifdef ENABLE_XML_SERIALIZATION
   : XMLSerialization("dummy")
   #endif
-  {plugin_name = "dummy";};
+  {plugin_name = "dummy";}
 
-  ~ViewerPlugin(){};
+  virtual ~ViewerPlugin(){}
 
   // This function is called when the viewer is initialized (no mesh will be loaded at this stage)
   IGL_INLINE virtual void init(igl::Viewer *_viewer)
@@ -132,8 +132,6 @@ public:
 protected:
   // Pointer to the main Preview3D class
   Viewer *viewer;
-public:
-    EIGEN_MAKE_ALIGNED_OPERATOR_NEW
 };
 
 }

+ 1 - 1
include/igl/xml/XMLSerializer.h.REMOVED.git-id

@@ -1 +1 @@
-8732db96cb04680209315d0fd383a4e392159b2e
+ab26d135c79d225b587e9dd8a7cb86a677edcb82

+ 1 - 1
tutorial/607_Picking/main.cpp

@@ -27,7 +27,7 @@ bool mouse_down(igl::Viewer& viewer, int button, int modifier)
   // Cast a ray in the view direction starting from the mouse position
   double x = viewer.current_mouse_x;
   double y = viewer.core.viewport(3) - viewer.current_mouse_y;
-  bool hit = unproject_onto_mesh(Vector2f(x,y),
+  bool hit = igl::unproject_onto_mesh(Vector2f(x,y),
                                 F,
                                 viewer.core.view * viewer.core.model,
                                 viewer.core.proj,

+ 1 - 1
tutorial/tutorial.html.REMOVED.git-id

@@ -1 +1 @@
-7c2e6ed8a0789197fdaae35c8a1cbd5f502f3c53
+141eb93f575045ab7a950e5674b54ec2fa87b197

+ 1 - 1
tutorial/tutorial.md.REMOVED.git-id

@@ -1 +1 @@
-a8e5c24e1a1aaa51c9fbc704d55d0b81f350a52a
+d0833fffecc624061e2d057e37e4e3e99cc11351