diff --git a/Makefile b/Makefile index 714cff0ae..29ddcd82f 100644 --- a/Makefile +++ b/Makefile @@ -14,10 +14,11 @@ $(info Hello, $(IGL_USERNAME)!) # optimized default settings all: LFLAGS += -OPTFLAGS+=-O3 -DNDEBUG $(OPENMP) $(SSE) +OPTFLAGS+=-O3 -DNDEBUG $(OPENMP) #debug: OPTFLAGS= -g -Wall -Werror debug: OPTFLAGS= -g -Wall CFLAGS += $(OPTFLAGS) +#CFLAGS += -DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR EXTRA_DIRS= ifeq ($(IGL_WITH_TETGEN),1) diff --git a/Makefile.conf b/Makefile.conf index e8ddc5508..f81242b77 100644 --- a/Makefile.conf +++ b/Makefile.conf @@ -33,8 +33,6 @@ ifeq ($(IGL_USERNAME),ajx) # msse4.2 is necessary for me to get embree to compile correctly AFLAGS = -m64 -msse4.2 OPENMP=-fopenmp -#SSE=-mavx - SSE=-msse endif ifeq ($(IGL_USERNAME),alecjaco) @@ -45,7 +43,8 @@ ifeq ($(IGL_USERNAME),alecjaco) #IGL_WITH_MOSEK=1 OPENGL_INC=-I$(DEFAULT_PREFIX)/include OPENGL_LIB=-lGL -lGLU - #GLUT_LIB=-lglut + # Glut is needed only for examples + GLUT_LIB=-lglut ANTTWEAKBAR_LIB=-lAntTweakBar OPENMP=-fopenmp endif @@ -64,6 +63,7 @@ ifeq ($(IGL_USERNAME),jalec_linux) IGL_WITH_MATLAB=0 IGL_WITH_MOSEK=1 OPENGL_LIB=-lGL -lGLU + # Glut is needed only for examples GLUT_LIB=-lglut ANTTWEAKBAR_LIB=-lAntTweakBar IGL_WITH_PNG=1 @@ -85,6 +85,7 @@ ifeq ($(IGL_USERNAME),chrsch) IGL_WITH_MOSEK=0 #MOSEKPLATFORM=linux64x86 OPENGL_LIB=-lGL -lGLU + # Glut is needed only for examples GLUT_LIB=-lglut ANTTWEAKBAR_LIB=-lAntTweakBar OPENMP=-fopenmp @@ -97,7 +98,8 @@ ifeq ($(IGL_USERNAME),chrsch) IGL_WITH_MOSEK=0 OPENGL_INC=-I$(DEFAULT_PREFIX)/include OPENGL_LIB=-lGL -lGLU - #GLUT_LIB=-lglut + # Glut is needed only for examples + GLUT_LIB=-lglut ANTTWEAKBAR_LIB=-lAntTweakBar OPENMP=-fopenmp AFLAGS = -m64 diff --git a/RELEASE_HISTORY.txt b/RELEASE_HISTORY.txt index c523894e3..d72195be7 100644 --- a/RELEASE_HISTORY.txt +++ b/RELEASE_HISTORY.txt @@ -1,3 +1,4 @@ +0.2.3 More explicits, active set method, opengl/anttweakbar guards 0.2.2 More explicit instanciations, 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 diff --git a/VERSION.txt b/VERSION.txt index ab4a021bc..f3b378a4b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -3,4 +3,4 @@ # 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 -0.2.3 +0.2.4 diff --git a/examples/svd/example.cpp b/examples/svd/example.cpp index 7b2eddcef..f0e076dd7 100755 --- a/examples/svd/example.cpp +++ b/examples/svd/example.cpp @@ -1,96 +1,97 @@ -#include -#include -#include -#include - -/* Auxiliary routines prototypes */ -extern void print_matrix( char* desc, int m, int n, double* a, int lda ); - -/* Parameters */ - -void print3x3(const char * s, double * a) -{ - printf("%s =\n",s); - for(int i = 0;i<3;i++) - { - for(int j = 0;j<3;j++) - { - printf("%g ",a[j*3+i]); - } - printf("\n"); - } - printf("\n"); -} - -int main(int argc, char * argv[]) -{ - //// List of rest positions - //// (0,1) - //// / \ - //// / \ - //// / \ - //// / \ - //// (-1,0)-----(1,0) - //// - //double rest[3][3] = { - // {-1,0,0}, - // {1,0,0}, - // {0,1,0}}; - //// List of pose positions - //// - //// (0,1) - //// | \ - //// | \ - //// | (1,0) - //// | / - //// | / - //// (0,-1) - //double pose[3][3] = { - // {0,1,0}, - // {0,-1,0}, - // {1,0,0}}; - //// Compute covariance matrix C - //double C[3*3]; - //// Initialize to zero - //for(int i = 0;i<3*3;i++) - //{ - // C[i] = 0; - //} - - //// Loop over vertices - //for(int i = 0;i<3;i++) - //{ - // // Compute outer product rest[i] * pose[i] - // // Loop over coordinates - // for(int j = 0;j<3;j++) - // { - // // Loop over coordinates - // for(int k = 0;k<3;k++) - // { - // C[k*3+j] = rest[i][j] * pose[i][k]; - // } - // } - //} - //print3x3("C",C); - - - // - //double C[3*3] = {8,3,4,1,5,9,6,7,2}; - double C[3*3] = {5242.55,3364,-0,-8170.15,-5242.56,0,-0,-0,0}; - double u[3*3],s[3],vt[3*3]; - print3x3("C",C); - // Compute SVD of C - igl::svd3x3(C,u,s,vt); - print3x3("u",u); - print3x3("vt",vt); - - // Compute R = u*vt - double R[3*3]; - const double _3 = 3; - const double _1 = 1; - cblas_dgemm(CblasColMajor, CblasNoTrans,CblasNoTrans,3,3,3,1,u,3,vt,3,1,R,3); - print3x3("RT (transposed to be row-major)",R); - - - return 0; -} +int main(){} +//#include +//#include +//#include +//#include +// +///* Auxiliary routines prototypes */ +//extern void print_matrix( char* desc, int m, int n, double* a, int lda ); +// +///* Parameters */ +// +//void print3x3(const char * s, double * a) +//{ +// printf("%s =\n",s); +// for(int i = 0;i<3;i++) +// { +// for(int j = 0;j<3;j++) +// { +// printf("%g ",a[j*3+i]); +// } +// printf("\n"); +// } +// printf("\n"); +//} +// +//int main(int argc, char * argv[]) +//{ +// //// List of rest positions +// //// (0,1) +// //// / \ +// //// / \ +// //// / \ +// //// / \ +// //// (-1,0)-----(1,0) +// //// +// //double rest[3][3] = { +// // {-1,0,0}, +// // {1,0,0}, +// // {0,1,0}}; +// //// List of pose positions +// //// +// //// (0,1) +// //// | \ +// //// | \ +// //// | (1,0) +// //// | / +// //// | / +// //// (0,-1) +// //double pose[3][3] = { +// // {0,1,0}, +// // {0,-1,0}, +// // {1,0,0}}; +// //// Compute covariance matrix C +// //double C[3*3]; +// //// Initialize to zero +// //for(int i = 0;i<3*3;i++) +// //{ +// // C[i] = 0; +// //} +// +// //// Loop over vertices +// //for(int i = 0;i<3;i++) +// //{ +// // // Compute outer product rest[i] * pose[i] +// // // Loop over coordinates +// // for(int j = 0;j<3;j++) +// // { +// // // Loop over coordinates +// // for(int k = 0;k<3;k++) +// // { +// // C[k*3+j] = rest[i][j] * pose[i][k]; +// // } +// // } +// //} +// //print3x3("C",C); +// +// +// // +// //double C[3*3] = {8,3,4,1,5,9,6,7,2}; +// double C[3*3] = {5242.55,3364,-0,-8170.15,-5242.56,0,-0,-0,0}; +// double u[3*3],s[3],vt[3*3]; +// print3x3("C",C); +// // Compute SVD of C +// igl::svd3x3(C,u,s,vt); +// print3x3("u",u); +// print3x3("vt",vt); +// +// // Compute R = u*vt +// double R[3*3]; +// const double _3 = 3; +// const double _1 = 1; +// cblas_dgemm(CblasColMajor, CblasNoTrans,CblasNoTrans,3,3,3,1,u,3,vt,3,1,R,3); +// print3x3("RT (transposed to be row-major)",R); +// +// +// return 0; +//} diff --git a/include/igl/ONE.h b/include/igl/ONE.h index b21d38b9d..35842f927 100644 --- a/include/igl/ONE.h +++ b/include/igl/ONE.h @@ -1,6 +1,6 @@ #ifndef IGL_ONE_H #define IGL_ONE_H -// Often one needs a reference to a dummy variable containing zero as its +// Often one needs a reference to a dummy variable containing one as its // value, for example when using AntTweakBar's // TwSetParam( "3D View", "opened", TW_PARAM_INT32, 1, &INT_ONE); namespace igl diff --git a/include/igl/ReAntTweakBar.cpp b/include/igl/ReAntTweakBar.cpp index aa6bbc6a8..e4c78c8e6 100644 --- a/include/igl/ReAntTweakBar.cpp +++ b/include/igl/ReAntTweakBar.cpp @@ -1,4 +1,5 @@ #include "ReAntTweakBar.h" +#ifndef IGL_NO_ANTTWEAKBAR #include #include @@ -834,3 +835,4 @@ const std::vector & igl::ReTwBar::get_cb_items() { return cb_items; } +#endif diff --git a/include/igl/ReAntTweakBar.h b/include/igl/ReAntTweakBar.h index 85961187b..a4581d1f3 100644 --- a/include/igl/ReAntTweakBar.h +++ b/include/igl/ReAntTweakBar.h @@ -1,5 +1,6 @@ #ifndef IGL_REANTTWEAKBAR_H #define IGL_REANTTWEAKBAR_H +#ifndef IGL_NO_ANTTWEAKBAR #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 @@ -273,3 +274,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/cocoa_key_to_anttweakbar_key.cpp b/include/igl/cocoa_key_to_anttweakbar_key.cpp index fdabb9096..2fddb9e7a 100644 --- a/include/igl/cocoa_key_to_anttweakbar_key.cpp +++ b/include/igl/cocoa_key_to_anttweakbar_key.cpp @@ -1,4 +1,5 @@ #include "cocoa_key_to_anttweakbar_key.h" +#ifndef IGL_NO_ANTTWEAKBAR #include @@ -72,3 +73,4 @@ IGL_INLINE int igl::cocoa_key_to_anttweakbar_key(int key) } return key; } +#endif diff --git a/include/igl/cocoa_key_to_anttweakbar_key.h b/include/igl/cocoa_key_to_anttweakbar_key.h index f311d2285..e2634fab7 100644 --- a/include/igl/cocoa_key_to_anttweakbar_key.h +++ b/include/igl/cocoa_key_to_anttweakbar_key.h @@ -1,5 +1,6 @@ #ifndef IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H #define IGL_COCOA_KEY_TO_ANTTWEAKBAR_KEY_H +#ifndef IGL_NO_ANTTWEAKBAR #include "igl_inline.h" @@ -19,3 +20,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/create_index_vbo.cpp b/include/igl/create_index_vbo.cpp index c7db546b4..51e3776a6 100644 --- a/include/igl/create_index_vbo.cpp +++ b/include/igl/create_index_vbo.cpp @@ -1,5 +1,6 @@ #include "create_index_vbo.h" +#ifndef IGL_NO_OPENGL // http://www.songho.ca/opengl/gl_vbo.html#create IGL_INLINE void igl::create_index_vbo( const Eigen::MatrixXi & F, @@ -33,6 +34,7 @@ IGL_INLINE void igl::create_index_vbo( // bind with 0, so, switch back to normal pointer operation glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0); } +#endif #ifndef IGL_HEADER_ONLY // Explicit template specialization diff --git a/include/igl/create_index_vbo.h b/include/igl/create_index_vbo.h index 40a0d3a5a..1fea487a1 100644 --- a/include/igl/create_index_vbo.h +++ b/include/igl/create_index_vbo.h @@ -1,23 +1,12 @@ #ifndef IGL_CREATE_INDEX_VBO_H #define IGL_CREATE_INDEX_VBO_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" // NOTE: It wouldn't be so hard to template this using Eigen's templates #include -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" // Create a VBO (Vertex Buffer Object) for a list of indices: // GL_ELEMENT_ARRAY_BUFFER_ARB for the triangle indices (F) @@ -39,3 +28,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/create_mesh_vbo.cpp b/include/igl/create_mesh_vbo.cpp index 1c03cbeb9..d2d39b05e 100644 --- a/include/igl/create_mesh_vbo.cpp +++ b/include/igl/create_mesh_vbo.cpp @@ -1,4 +1,5 @@ #include "create_mesh_vbo.h" +#ifndef IGL_NO_OPENGL #include "create_vector_vbo.h" #include "create_index_vbo.h" @@ -34,3 +35,4 @@ IGL_INLINE void igl::create_mesh_vbo( #ifndef IGL_HEADER_ONLY // Explicit template specialization #endif +#endif diff --git a/include/igl/create_mesh_vbo.h b/include/igl/create_mesh_vbo.h index 710b5a40b..ee2d6afa8 100644 --- a/include/igl/create_mesh_vbo.h +++ b/include/igl/create_mesh_vbo.h @@ -1,23 +1,12 @@ #ifndef IGL_CREATE_MESH_VBO_H #define IGL_CREATE_MESH_VBO_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" // NOTE: It wouldn't be so hard to template this using Eigen's templates #include -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" // Create a VBO (Vertex Buffer Object) for a mesh. Actually two VBOs: one // GL_ARRAY_BUFFER for the vertex positions (V) and one @@ -64,3 +53,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/create_shader_program.cpp b/include/igl/create_shader_program.cpp index 7716c809a..c2bf4226c 100644 --- a/include/igl/create_shader_program.cpp +++ b/include/igl/create_shader_program.cpp @@ -1,4 +1,5 @@ #include "create_shader_program.h" +#ifndef IGL_NO_OPENGL #include "load_shader.h" #include "print_program_info_log.h" @@ -70,3 +71,4 @@ IGL_INLINE bool igl::create_shader_program( return true; } +#endif diff --git a/include/igl/create_shader_program.h b/include/igl/create_shader_program.h index 57ba38dcb..34b869764 100644 --- a/include/igl/create_shader_program.h +++ b/include/igl/create_shader_program.h @@ -1,22 +1,12 @@ #ifndef IGL_CREATE_SHADER_PROGRAM_H #define IGL_CREATE_SHADER_PROGRAM_H + +#ifndef IGL_NO_OPENGL #include "igl_inline.h" #include #include -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -48,3 +38,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/create_vector_vbo.cpp b/include/igl/create_vector_vbo.cpp index 7a8fefc11..6cb08508c 100644 --- a/include/igl/create_vector_vbo.cpp +++ b/include/igl/create_vector_vbo.cpp @@ -1,4 +1,5 @@ #include "create_vector_vbo.h" +#ifndef IGL_NO_OPENGL #include @@ -47,3 +48,5 @@ template void igl::create_vector_vbo(Eigen::Matrix // generated by autoexplicit.sh template void igl::create_vector_vbo(Eigen::Matrix const&, unsigned int&); #endif + +#endif diff --git a/include/igl/create_vector_vbo.h b/include/igl/create_vector_vbo.h index f939077d1..1b673591a 100644 --- a/include/igl/create_vector_vbo.h +++ b/include/igl/create_vector_vbo.h @@ -1,23 +1,12 @@ #ifndef IGL_CREATE_VECTOR_VBO_H #define IGL_CREATE_VECTOR_VBO_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" // NOTE: It wouldn't be so hard to template this using Eigen's templates #include -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" // Create a VBO (Vertex Buffer Object) for a list of vectors: // GL_ARRAY_BUFFER for the vectors (V) @@ -42,3 +31,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/destroy_shader_program.cpp b/include/igl/destroy_shader_program.cpp index 915dce277..b8502d5d7 100644 --- a/include/igl/destroy_shader_program.cpp +++ b/include/igl/destroy_shader_program.cpp @@ -1,4 +1,5 @@ #include "destroy_shader_program.h" +#ifndef IGL_NO_OPENGL #include #include "report_gl_error.h" @@ -36,3 +37,4 @@ IGL_INLINE bool igl::destroy_shader_program(const GLuint id) glDeleteProgram(id); return true; } +#endif diff --git a/include/igl/destroy_shader_program.h b/include/igl/destroy_shader_program.h index 481c67e99..c3b323d84 100644 --- a/include/igl/destroy_shader_program.h +++ b/include/igl/destroy_shader_program.h @@ -1,20 +1,9 @@ #ifndef IGL_DESTROY_SHADER_PROGRAM_H #define IGL_DESTROY_SHADER_PROGRAM_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -36,3 +25,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/draw_beach_ball.cpp b/include/igl/draw_beach_ball.cpp index 93e3981af..8ff6cf977 100644 --- a/include/igl/draw_beach_ball.cpp +++ b/include/igl/draw_beach_ball.cpp @@ -1,15 +1,7 @@ #include "draw_beach_ball.h" +#ifndef IGL_NO_OPENGL -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -#else -# include -#endif +#include "OpenGL_convenience.h" // I'm not sure why windows would need it this way: // http://lists.cairographics.org/archives/cairo/2008-January/012722.html @@ -285,3 +277,4 @@ IGL_INLINE void igl::draw_beach_ball() (cm ? glEnable(GL_COLOR_MATERIAL):glDisable(GL_COLOR_MATERIAL)); } +#endif diff --git a/include/igl/draw_beach_ball.h b/include/igl/draw_beach_ball.h index e32c1b22b..c11b31837 100644 --- a/include/igl/draw_beach_ball.h +++ b/include/igl/draw_beach_ball.h @@ -1,5 +1,6 @@ #ifndef IGL_DRAW_BEACH_BALL_H #define IGL_DRAW_BEACH_BALL_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" namespace igl @@ -14,3 +15,4 @@ namespace igl } #endif +#endif diff --git a/include/igl/draw_mesh.cpp b/include/igl/draw_mesh.cpp index ae3aef1f4..4e7551b4b 100644 --- a/include/igl/draw_mesh.cpp +++ b/include/igl/draw_mesh.cpp @@ -1,4 +1,5 @@ #include "draw_mesh.h" +#ifndef IGL_NO_OPENGL IGL_INLINE void igl::draw_mesh( const Eigen::MatrixXd & V, @@ -337,3 +338,4 @@ IGL_INLINE void igl::draw_mesh( glEnd(); } +#endif diff --git a/include/igl/draw_mesh.h b/include/igl/draw_mesh.h index ca8cfc178..2c468afd5 100644 --- a/include/igl/draw_mesh.h +++ b/include/igl/draw_mesh.h @@ -1,22 +1,11 @@ #ifndef IGL_DRAW_MESH_H #define IGL_DRAW_MESH_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" #include -#if __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -110,3 +99,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/draw_point.cpp b/include/igl/draw_point.cpp index 67dbe2ac4..5080c0697 100644 --- a/include/igl/draw_point.cpp +++ b/include/igl/draw_point.cpp @@ -1,20 +1,8 @@ #include "draw_point.h" +#ifndef IGL_NO_OPENGL // Implementation - -#if __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" #include #include @@ -85,3 +73,4 @@ IGL_INLINE void igl::draw_point( //if(old_depth_test) glEnable(GL_DEPTH_TEST); } +#endif diff --git a/include/igl/draw_point.h b/include/igl/draw_point.h index 8a8b1052d..068836615 100644 --- a/include/igl/draw_point.h +++ b/include/igl/draw_point.h @@ -1,5 +1,6 @@ #ifndef IGL_DRAW_POINT_H #define IGL_DRAW_POINT_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" namespace igl { @@ -28,3 +29,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/gl_type_size.cpp b/include/igl/gl_type_size.cpp index 22b10ea46..fe8b66221 100644 --- a/include/igl/gl_type_size.cpp +++ b/include/igl/gl_type_size.cpp @@ -1,4 +1,5 @@ #include "gl_type_size.h" +#ifndef IGL_NO_OPENGL #include IGL_INLINE int igl::gl_type_size(const GLenum type) @@ -21,3 +22,4 @@ IGL_INLINE int igl::gl_type_size(const GLenum type) } return -1; } +#endif diff --git a/include/igl/gl_type_size.h b/include/igl/gl_type_size.h index 7ea503638..251cb67a7 100644 --- a/include/igl/gl_type_size.h +++ b/include/igl/gl_type_size.h @@ -1,20 +1,9 @@ #ifndef IGL_GL_TYPE_SIZE_H #define IGL_GL_TYPE_SIZE_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" - -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -30,3 +19,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/load_shader.cpp b/include/igl/load_shader.cpp index 4fa060a9b..88c291bba 100644 --- a/include/igl/load_shader.cpp +++ b/include/igl/load_shader.cpp @@ -1,4 +1,5 @@ #include "load_shader.h" +#ifndef IGL_NO_OPENGL // Copyright Denis Kovacs 4/10/08 #include "print_shader_info_log.h" @@ -18,3 +19,4 @@ IGL_INLINE GLuint igl::load_shader(const char *src,const GLenum type) igl::print_shader_info_log(s); return s; } +#endif diff --git a/include/igl/load_shader.h b/include/igl/load_shader.h index d222139f8..af41bd7ab 100644 --- a/include/igl/load_shader.h +++ b/include/igl/load_shader.h @@ -1,20 +1,9 @@ #ifndef IGL_LOAD_SHADER_H #define IGL_LOAD_SHADER_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -34,3 +23,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/print_gl_get.cpp b/include/igl/print_gl_get.cpp index 7d0ab0223..b6baec73a 100644 --- a/include/igl/print_gl_get.cpp +++ b/include/igl/print_gl_get.cpp @@ -1,4 +1,5 @@ #include "print_gl_get.h" +#ifndef IGL_NO_OPENGL #include IGL_INLINE void igl::print_gl_get(GLenum pname) @@ -29,3 +30,4 @@ IGL_INLINE void igl::print_gl_get(GLenum pname) fprintf(stderr,"ERROR in print_gl_get(), gl enum not recognized.\n"); } } +#endif diff --git a/include/igl/print_gl_get.h b/include/igl/print_gl_get.h index 6a0a2f225..419c6da41 100644 --- a/include/igl/print_gl_get.h +++ b/include/igl/print_gl_get.h @@ -1,19 +1,9 @@ #ifndef IGL_PRINT_GL_GET_H #define IGL_PRINT_GL_GET_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -28,3 +18,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/print_program_info_log.cpp b/include/igl/print_program_info_log.cpp index f2040685b..589811b71 100644 --- a/include/igl/print_program_info_log.cpp +++ b/include/igl/print_program_info_log.cpp @@ -1,4 +1,5 @@ #include "print_program_info_log.h" +#ifndef IGL_NO_OPENGL #include #include @@ -19,3 +20,4 @@ IGL_INLINE void igl::print_program_info_log(const GLuint obj) free(infoLog); } } +#endif diff --git a/include/igl/print_program_info_log.h b/include/igl/print_program_info_log.h index 88247a4c1..efbc47ff3 100644 --- a/include/igl/print_program_info_log.h +++ b/include/igl/print_program_info_log.h @@ -1,20 +1,9 @@ #ifndef IGL_PRINT_PROGRAM_INFO_LOG_H #define IGL_PRINT_PROGRAM_INFO_LOG_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -28,3 +17,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/print_shader_info_log.cpp b/include/igl/print_shader_info_log.cpp index cf86eb481..3dad8b31f 100644 --- a/include/igl/print_shader_info_log.cpp +++ b/include/igl/print_shader_info_log.cpp @@ -1,4 +1,5 @@ #include "print_shader_info_log.h" +#ifndef IGL_NO_OPENGL #include #include @@ -20,3 +21,4 @@ IGL_INLINE void igl::print_shader_info_log(const GLuint obj) free(infoLog); } } +#endif diff --git a/include/igl/print_shader_info_log.h b/include/igl/print_shader_info_log.h index c22d3247d..c1483ec32 100644 --- a/include/igl/print_shader_info_log.h +++ b/include/igl/print_shader_info_log.h @@ -1,20 +1,9 @@ #ifndef IGL_PRINT_SHADER_INFO_LOG_H #define IGL_PRINT_SHADER_INFO_LOG_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -28,3 +17,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/project.cpp b/include/igl/project.cpp index 9884c7148..e9fb7219b 100644 --- a/include/igl/project.cpp +++ b/include/igl/project.cpp @@ -1,19 +1,9 @@ #include "project.h" +#ifndef IGL_NO_OPENGL #include #include "report_gl_error.h" -#ifdef __APPLE__ -# include -# include -#else -# ifdef _WIN32 -# define NOMINMAX -# include -# undef NOMINMAX -# endif -# include -# include -#endif +#include "OpenGL_convenience.h" IGL_INLINE int igl::project( const double objX, @@ -72,3 +62,4 @@ IGL_INLINE int igl::project( return gluProject(objX,objY,objZ,MV,P,VP,winX,winY,winZ); } +#endif diff --git a/include/igl/render_to_tga.cpp b/include/igl/render_to_tga.cpp index 2354afc4d..618edc649 100644 --- a/include/igl/render_to_tga.cpp +++ b/include/igl/render_to_tga.cpp @@ -1,19 +1,8 @@ #include "render_to_tga.h" +#ifndef IGL_NO_OPENGL #include "tga.h" -#if __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" #include @@ -86,3 +75,5 @@ IGL_INLINE bool igl::render_to_tga( free(genericImage); return fclose(imgFile) == 0; } + +#endif diff --git a/include/igl/repdiag.cpp b/include/igl/repdiag.cpp index dc3492e87..e75d5e023 100644 --- a/include/igl/repdiag.cpp +++ b/include/igl/repdiag.cpp @@ -1,4 +1,5 @@ #include "repdiag.h" +#ifndef IGL_NO_OPENGL // Bug in unsupported/Eigen/SparseExtra needs iostream first #include @@ -70,3 +71,4 @@ template void igl::repdiag(Eigen::SparseMatrix const&, i // generated by autoexplicit.sh template Eigen::SparseMatrix igl::repdiag >(Eigen::SparseMatrix const&, int); #endif +#endif diff --git a/include/igl/report_gl_error.cpp b/include/igl/report_gl_error.cpp index 258974bea..726a857a7 100644 --- a/include/igl/report_gl_error.cpp +++ b/include/igl/report_gl_error.cpp @@ -1,4 +1,5 @@ #include "report_gl_error.h" +#ifndef IGL_NO_OPENGL #include "verbose.h" @@ -17,3 +18,4 @@ IGL_INLINE GLenum igl::report_gl_error() { return igl::report_gl_error(std::string("")); } +#endif diff --git a/include/igl/report_gl_error.h b/include/igl/report_gl_error.h index b495ae324..d898d42d7 100644 --- a/include/igl/report_gl_error.h +++ b/include/igl/report_gl_error.h @@ -1,19 +1,9 @@ #ifndef IGL_REPORT_GL_ERROR_H #define IGL_REPORT_GL_ERROR_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" -#ifdef __APPLE__ -# include -# include -#else -# ifdef _WIN32 -# define NOMINMAX -# include -# undef NOMINMAX -# endif -# include -# include -#endif +#include "OpenGL_convenience.h" #include #include @@ -34,3 +24,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/right_axis.cpp b/include/igl/right_axis.cpp index 2ec18280c..2a7ea73a6 100644 --- a/include/igl/right_axis.cpp +++ b/include/igl/right_axis.cpp @@ -1,18 +1,7 @@ #include "right_axis.h" +#ifndef IGL_NO_OPENGL -#if __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" IGL_INLINE void igl::right_axis(double * x, double * y, double * z) { @@ -28,3 +17,4 @@ IGL_INLINE void igl::right_axis(const double * mv,double * x, double * y, double *z = -mv[2*4+0]; } +#endif diff --git a/include/igl/svd.cpp b/include/igl/svd.cpp index e5a4cd29b..992d1ef1f 100644 --- a/include/igl/svd.cpp +++ b/include/igl/svd.cpp @@ -1,40 +1,40 @@ -// This only works on MAC ... -#ifdef __APPLE__ -#include "svd.h" -#include -#include -#include - -bool igl::svd3x3(double * a, double * u, double * s, double * vt) -{ - /* Locals */ - int m = 3, n = 3, lda = 3, ldu = 3, ldvt = 3, info, lwork; - double wkopt; - double* work; - /* Local arrays */ - /* iwork dimension should be at least 8*min(m,n) */ - int iwork[8*3]; - //double s[3], u[3*3], vt[3*3]; - //double a[3*3] = {8,3,4,1,5,9,6,7,2}; - /* Query and allocate the optimal workspace */ - lwork = -1; - dgesdd_( - "Singular vectors", - &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, &wkopt, &lwork, iwork, &info); - lwork = (int)wkopt; - work = (double*)malloc( lwork*sizeof(double) ); - /* Compute SVD */ - dgesdd_( - "Singular vectors", - &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info ); - /* Check for convergence */ - if( info > 0 ) - { - printf("The algorithm computing SVD failed to converge.\n" ); - return false; - } - /* Free workspace */ - free( (void*)work ); - return true; -} -#endif +//// This only works on MAC ... +//#ifdef __APPLE__ +//#include "svd.h" +//#include +//#include +//#include +// +//bool igl::svd3x3(double * a, double * u, double * s, double * vt) +//{ +// /* Locals */ +// int m = 3, n = 3, lda = 3, ldu = 3, ldvt = 3, info, lwork; +// double wkopt; +// double* work; +// /* Local arrays */ +// /* iwork dimension should be at least 8*min(m,n) */ +// int iwork[8*3]; +// //double s[3], u[3*3], vt[3*3]; +// //double a[3*3] = {8,3,4,1,5,9,6,7,2}; +// /* Query and allocate the optimal workspace */ +// lwork = -1; +// dgesdd_( +// "Singular vectors", +// &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, &wkopt, &lwork, iwork, &info); +// lwork = (int)wkopt; +// work = (double*)malloc( lwork*sizeof(double) ); +// /* Compute SVD */ +// dgesdd_( +// "Singular vectors", +// &m, &n, a, &lda, s, u, &ldu, vt, &ldvt, work, &lwork, iwork, &info ); +// /* Check for convergence */ +// if( info > 0 ) +// { +// printf("The algorithm computing SVD failed to converge.\n" ); +// return false; +// } +// /* Free workspace */ +// free( (void*)work ); +// return true; +//} +//#endif diff --git a/include/igl/svd.h b/include/igl/svd.h index cace44731..41a2fe632 100644 --- a/include/igl/svd.h +++ b/include/igl/svd.h @@ -1,24 +1,26 @@ -#ifndef IGL_SVD_H -#define IGL_SVD_H -namespace igl -{ - // Compute 3x3 SVD using lapack's dgesdd_ function - // - // Input: - // a pointer to 3x3 matrix in COLUMN MAJOR order - // Outputs: - // u pointer to 3x3 matrix in COLUMN MAJOR order - // s pointer to 3 vector - // vt pointer to 3x3 matrix in COLUMN MAJOR order, or think of this as v in - // row-major order - // Returns true on success, false on failure - // - // Known bugs: This only compiles on Mac and depends on Lapack rather than eigen - bool svd3x3(double * a, double * u, double * s, double * vt); -}; +//THIS DEPENDS ON BLAS. WHY? WHY NOT EIGEN? -#ifdef IGL_HEADER_ONLY -#include "svd.cpp" -#endif - -#endif +//#ifndef IGL_SVD_H +//#define IGL_SVD_H +//namespace igl +//{ +// // Compute 3x3 SVD using lapack's dgesdd_ function +// // +// // Input: +// // a pointer to 3x3 matrix in COLUMN MAJOR order +// // Outputs: +// // u pointer to 3x3 matrix in COLUMN MAJOR order +// // s pointer to 3 vector +// // vt pointer to 3x3 matrix in COLUMN MAJOR order, or think of this as v in +// // row-major order +// // Returns true on success, false on failure +// // +// // Known bugs: This only compiles on Mac and depends on Lapack rather than eigen +// bool svd3x3(double * a, double * u, double * s, double * vt); +//}; +// +//#ifdef IGL_HEADER_ONLY +//#include "svd.cpp" +//#endif +// +//#endif diff --git a/include/igl/texture_from_tga.cpp b/include/igl/texture_from_tga.cpp index 5143b385f..27206558f 100644 --- a/include/igl/texture_from_tga.cpp +++ b/include/igl/texture_from_tga.cpp @@ -1,4 +1,5 @@ #include "texture_from_tga.h" +#ifndef IGL_NO_OPENGL #include "tga.h" #include "report_gl_error.h" @@ -59,3 +60,5 @@ IGL_INLINE bool igl::texture_from_tga(const std::string tga_file, GLuint & id) img->pixels); return id; } + +#endif diff --git a/include/igl/texture_from_tga.h b/include/igl/texture_from_tga.h index 21c5a6d5c..12a8a1569 100644 --- a/include/igl/texture_from_tga.h +++ b/include/igl/texture_from_tga.h @@ -1,20 +1,9 @@ #ifndef IGL_TEXTURE_FROM_TGA_H #define IGL_TEXTURE_FROM_TGA_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" #include @@ -35,3 +24,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/tga.cpp b/include/igl/tga.cpp index 8c8a01782..0ea237eb1 100644 --- a/include/igl/tga.cpp +++ b/include/igl/tga.cpp @@ -46,6 +46,7 @@ #include #include "tga.h" +#ifndef IGL_NO_OPENGL static char error[256]; @@ -548,3 +549,4 @@ void igl::writeTGA( igl::gliGenericImage* image, FILE *fp) { fwrite(image->pixels, image->height*image->width*image->components, sizeof(char),fp); } +#endif diff --git a/include/igl/tga.h b/include/igl/tga.h index e04ffa873..a66b9fbde 100644 --- a/include/igl/tga.h +++ b/include/igl/tga.h @@ -1,5 +1,6 @@ #ifndef IGL_TGA_H #define IGL_TGA_H +#ifndef IGL_NO_OPENGL // See license in tga.cpp /* tga.h - interface for TrueVision (TGA) image file loader */ @@ -10,19 +11,7 @@ #include #endif -#if __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -108,3 +97,4 @@ void writeTGA( gliGenericImage* image, FILE *fp); #endif #endif +#endif diff --git a/include/igl/uniform_type_to_string.cpp b/include/igl/uniform_type_to_string.cpp index 084605e94..61da70769 100644 --- a/include/igl/uniform_type_to_string.cpp +++ b/include/igl/uniform_type_to_string.cpp @@ -1,4 +1,5 @@ #include "uniform_type_to_string.h" +#ifndef IGL_NO_OPENGL IGL_INLINE std::string igl::uniform_type_to_string(const GLenum type) { @@ -62,3 +63,4 @@ IGL_INLINE std::string igl::uniform_type_to_string(const GLenum type) return "UNKNOWN_TYPE"; } } +#endif diff --git a/include/igl/uniform_type_to_string.h b/include/igl/uniform_type_to_string.h index 6db3d0ad3..d514d9836 100644 --- a/include/igl/uniform_type_to_string.h +++ b/include/igl/uniform_type_to_string.h @@ -1,22 +1,11 @@ #ifndef IGL_UNIFORM_TYPE_TO_STRING_H #define IGL_UNIFORM_TYPE_TO_STRING_H +#ifndef IGL_NO_OPENGL #include "igl_inline.h" #include -#ifdef __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" namespace igl { @@ -33,3 +22,4 @@ namespace igl #endif #endif +#endif diff --git a/include/igl/unproject.cpp b/include/igl/unproject.cpp index dde48c1a2..256e02301 100644 --- a/include/igl/unproject.cpp +++ b/include/igl/unproject.cpp @@ -1,17 +1,7 @@ #include "unproject.h" +#ifndef IGL_NO_OPENGL -#ifdef __APPLE__ -# include -# include -#else -# ifdef _WIN32 -# define NOMINMAX -# include -# undef NOMINMAX -# endif -# include -# include -#endif +#include "OpenGL_convenience.h" IGL_INLINE int igl::unproject( const double winX, @@ -30,3 +20,4 @@ IGL_INLINE int igl::unproject( glGetIntegerv(GL_VIEWPORT, VP); return gluUnProject(winX,winY,winZ,MV,P,VP,objX,objY,objZ); } +#endif diff --git a/include/igl/unproject_to_zero_plane.cpp b/include/igl/unproject_to_zero_plane.cpp index b8dde15b1..4f3a73cbe 100644 --- a/include/igl/unproject_to_zero_plane.cpp +++ b/include/igl/unproject_to_zero_plane.cpp @@ -1,17 +1,7 @@ #include "unproject_to_zero_plane.h" +#ifndef IGL_NO_OPENGL -#ifdef __APPLE__ -# include -# include -#else -# ifdef _WIN32 -# define NOMINMAX -# include -# undef NOMINMAX -# endif -# include -# include -#endif +#include "OpenGL_convenience.h" #include "project.h" #include "unproject.h" @@ -28,3 +18,4 @@ IGL_INLINE int igl::unproject_to_zero_plane( return igl::unproject(winX, winY, winOrigin[2], objX, objY, objZ); } +#endif diff --git a/include/igl/up_axis.cpp b/include/igl/up_axis.cpp index 00d6984e2..48e645ff8 100644 --- a/include/igl/up_axis.cpp +++ b/include/igl/up_axis.cpp @@ -1,18 +1,7 @@ #include "up_axis.h" +#ifndef IGL_NO_OPENGL -#if __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" IGL_INLINE void igl::up_axis(double * x, double * y, double * z) { @@ -28,3 +17,4 @@ IGL_INLINE void igl::up_axis(const double *mv, double * x, double * y, double * *z = -mv[2*4+1]; } +#endif diff --git a/include/igl/view_axis.cpp b/include/igl/view_axis.cpp index 89ba86930..f95e779f0 100644 --- a/include/igl/view_axis.cpp +++ b/include/igl/view_axis.cpp @@ -1,18 +1,7 @@ #include "view_axis.h" +#ifndef IGL_NO_OPENGL -#if __APPLE__ -# include -#elif defined(_WIN32) -# define NOMINMAX -# include -# undef NOMINMAX -# include -# include -#else -# define GL_GLEXT_PROTOTYPES -# include -# include -#endif +#include "OpenGL_convenience.h" IGL_INLINE void igl::view_axis(double * x, double * y, double * z) { @@ -27,3 +16,4 @@ IGL_INLINE void igl::view_axis(const double * mv, double * x, double * y, double *y = -mv[1*4+2]; *z = -mv[2*4+2]; } +#endif diff --git a/readme.txt b/readme.txt index db8381c56..f56b39205 100644 --- a/readme.txt +++ b/readme.txt @@ -14,7 +14,6 @@ listed below. Eigen3 Last tested with Eigen Version 3.1.2 AntTweakBar Last tested 1.14 (see External) OpenGL -GLUT GLEW Windows only = Optional = diff --git a/scripts/compress.sh b/scripts/compress.sh index 588b14371..ac69ff597 100755 --- a/scripts/compress.sh +++ b/scripts/compress.sh @@ -35,6 +35,8 @@ rm -f $H_OUT rm -f $CPP_OUT HEADER=" +Automatically generated by libigl/scripts/compress.sh **Do not edit** + libigl - A simple c++ geometry processing library http://igl.ethz.ch/projects/libigl/ @@ -128,6 +130,7 @@ fi echo "Compile with:" echo "" echo " g++ -o igl.o -c igl.cpp -I/opt/local/include/eigen3" +echo " rm -f libigl.a" echo " ar cqs libigl.a igl.o" echo " rm igl.o" echo "" diff --git a/style.css b/style.css index a8defa432..c778e5146 100644 --- a/style.css +++ b/style.css @@ -8,6 +8,7 @@ tr.header th background-color: #ffb; padding-left: 10px; padding-right: 20px; + text-align: left; } tr.d0 td { @@ -120,22 +121,70 @@ img.center margin-right: auto; } -.article_body +body, html { margin: 0px; padding: 0px; - text-align: center; background-color: #bbb; + font-family: "HelveticaNeueLight", "HelveticaNeue-Light", "Helvetica Neue Light", "HelveticaNeue", "Helvetica Neue", 'TeXGyreHerosRegular', "Helvetica", "Tahoma", "Geneva", "Arial", sans-serif; font-weight:300; font-stretch:normal; + height: 100%; } -.article +.article_outer { + padding: 0px; + margin:0px auto; + /* 600px = 2*300px wider that article_inner*/ + width: 1415px; +} + +.article_inner +{ + padding: 20px; + position:relative; font-size: 14pt; background-color: #fff; margin:0px auto; - padding: 20px; border-left: 1px solid #888; border-right: 1px solid #888; - width: 960px; + width: 815px; text-align: left; } + +#container +{ + position:absolute; + top:0px; + bottom: -0px; + left:0px; + right:0px; + overflow:auto; +} + +#fixed_sidebar +{ + margin: 0px; + position:absolute; + padding: 5px 10px; + top:10px; + left:0px; + right:0px; + background-color: #fff; + overflow:hidden; + width: 250px; + z-index:100; + border-right: 1px solid #888; + border-top: 1px solid #888; + border-bottom: 1px solid #888; +} +ul +{ + margin:0px; + padding: 0px 20px; + list-style-type:none; +} +li { font-size: 100% } +li li { font-size: 90% } +li li li { font-size: 80% } +li li li li { font-size: 70% } +li li li li li { font-size: 60%} diff --git a/tutorial.html b/tutorial.html index d89f152fb..525a74bba 100644 --- a/tutorial.html +++ b/tutorial.html @@ -3,24 +3,53 @@ libigl developer tutorial - -
- igl logo -

Using the libigl library

-

- The libigl library is a collection of useful/reusable/sharable C++ functions - with very few external dependencies. The - library may be used as a "headers only" - library or a statically linked library. -

+ + +
+
+
+ igl logo +

Using the libigl library

+

+ The libigl library is a collection of useful/reusable/sharable C++ functions + with very few external dependencies. The + library may be used as a "headers only" + library, a statically linked library, or as a compressed .h/.cpp pair. +

-

- This duality is illustrated in the example - examples/example_fun. When built this example compiles two - binaries, one using the example_fun routine of the igl - library, either as a headers-only library or linking against the igl - static library. -

+

+ This duality between statically compiled and header-only is illustrated + in the example examples/example_fun. When built, this example + compiles two binaries, one using the example_fun routine of + the igl library, either as a headers-only library or linking against the + igl static library. +

Headers (.h) only library

@@ -40,7 +69,7 @@ at compile time if need be.

-

+

One may also define IGL_HEADER_ONLY not only on a per-file basis, but a per-include basis. For example it may be useful for a project to use the static library for most functionality from IGL, but then @@ -70,7 +99,7 @@ purposes.

-

Benefits of headers-only library

+

Benefits of headers-only library

  • Easy templates: When using the libigl library as a headers-only library no special care need be taken when using templated @@ -189,7 +218,7 @@ make clean make -

    Benefits of static library

    +

    Benefits of static library

    • Faster compile time: Because the libigl library is already compiled, only the new code in ones project must be @@ -208,35 +237,107 @@ make exposing templated functions.
    +

    Compressed .h/.cpp pair

    +

    Calling the script:

    +
    scripts/compress.sh igl.h igl.cpp
    +

    will create a single header + igl.h and a single cpp file igl.cpp. + +

    Alternatively, you can also compress everything into a single header file (analagous to IGL_HEADER_ONLY):

    +
    scripts/compress.sh igl.h
    + +

    Benefits of compressed .h/.cpp pair

    +
      +
    • Easy incorporation: This can be easily incorporated + into external projects.
    • +
    +

    Drawbacks of compressed .h/.cpp pair

    +
      +
    • Hard to debug/edit: The compressed files are + automatically generated. They're huge and should not be edited. Thus + debugging and editting are near impossible.
    • +
    • Compounded dependencies: + An immediate disadvantage of this + seems to be that even to use a single function (e.g. + cotmatrix), compiling and linking against + igl.cpp will require linking to all of libigl's + dependencies (OpenGL, GLUT, + AntTweakBar, BLAS). However, because all + depencies other than Eigen should be encapsulated between + #ifndef guards (e.g. #ifndef IGL_NO_OPENGL, it + is possible to ignore certain functions that have such dependencies.
    • +
    • Long compile: Compiling igl.cpp takes a long time and isn't easily parallelized (no make -j12 equivalent).
    • +
    + +

    Here's a tiny test example using igl.h and igl.cpp. Save the following in test.cpp:

    +
    
    +#include <igl.h>
    +#include <Eigen/Core>
    +
    +int main(int argc, char * argv[])
    +{
    +  Eigen::MatrixXd V;
    +  Eigen::MatrixXi F;
    +  return (argc>=2 && igl::read(argv[1],V,F)?0:1);
    +}
    +      
    +

    Then compile igl.cpp with: +

    
    +g++ -o igl.o -c igl.cpp -I/opt/local/include/eigen3 -DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR
    +      
    +

    Notice that we're using -DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR to disable any libigl dependencies on OpenGL and AntTweakBar.

    + +

    Now compile test.cpp with: +

    
    +g++ -g -I/opt/local/include/eigen3/ -I/usr/local/igl/libigl/ -L/usr/local/igl/libigl/ -ligl -DIGL_NO_OPENGL -DIGL_NO_ANTTWEAKBAR -o test
    +      
    + +

    Try running it with:

    +
    
    +./test path/to/mesh.obj
    +      
    +

    Dependencies

    By design the libigl library has very few external dependencies.

    Mandatory dependencies

    -

    - Besides the standard C++ library, there are a few dependencies, - without which the main library will not compile or work properly. - These are: +

    Eigen3 and the Standard + Template Library (STL) are the only truly mandatory dependencies. + Without them libigl will not compile or work properly.

    +

    OpenGL is an assumed dependency, but is in fact also + optional. All OpenGL-dependent functions may be disabled by defining + the IGL_NO_OPENGL preprocessor macro.

    -
      -
    • Eigen3
    • -
    • OpenGL implement IGL_NO_OPENGL compiler option
    • -
    • GLUT implement IGL_NO_GLUT compiler option
    • -
    +

    Likewise, + AntTweakBar + is an + assumed dependency, similarly diabled by defining + the IGL_NO_ANTTWEAKBAR preprocessor macro.

    + +

    Each IGL_NO_XXX should just be replaced by a libiglXXX.a extra

    Optional dependencies

    - Certain functions and classes included the libigl library have - external dependencies by construction (e.g. the matlab_interface - routines are only useful when matlab is present anyway). These are - never compiled by default into the static igl - library and are only exposed through compiler - options. These are: + Certain extra functions and classes included the libigl + library have external dependencies by construction (e.g. the + matlab_interface routines are only useful when matlab is present + anyway). These are never compiled by default into + the static igl library, rather they are compiled as "extras" (e.g. + libiglmatlab.a contains the MATLAB-dependent functions).

    - -

    Converting matlab code to C++ using IGL and Eigen

    +

    Currently these include:

    + + + + + + + + +
    ExtraDependency
    libiglmatlab.aMATLAB
    libiglmosek.aMosek
    libigltetgen.aTetGen
    libiglxml.aTinyXml2
    libiglpng.aLibPNG
    libiglembree.aEmbree
    +

    Some of our examples (libigl/examples) also depend on GLUT.

    + +

    Converting matlab code to C++ using IGL and Eigen

    Eigen's matrix API often makes it fairly to translate to and from matlab code (Eigen provides a Our own translation table shows a list of common matlab functions and their igl-eigen equivalents.

    -

    See also: style guidlines, auto-documentation, file formats

    +

    Including OpenGL

    +

    Just include the convenience header, which takes care of system dependent paths, glew, etc.:

    +
    
    +#include "OpenGL_convenience.h"
    +      
    + +

    A standard include for the OpenGL headers should be placed in the .cpp file if possible. To ensure compilability on Mac OS X, Windows and Linux, use:

    
    @@ -268,7 +376,7 @@ make
     #endif
           

    -

    This should be encapsulated in a single utility header

    +

    Including headers to other igl functions

    Source files in the main igl directory should include other libigl headers using the name of the file in quotation marks: @@ -290,26 +398,14 @@ make #include <igl/extra/some_extra_function.h> -

    Compressing into a single .h/.cpp pair

    -

    Calling the script:

    -
    scripts/compress.sh igl.h igl.cpp
    -

    will create a single header - igl.h and a single cpp file igl.cpp. This can - be easily incorporated into external projects. The disadvantage of this - seems to be that even to use a single function (e.g. - cotmatrix), compiling and linking against - igl.cpp will require linking to all of libigl's - dependencies (OpenGL, GLUT, - AntTweakBar, BLAS).

    - -

    Alternatively, you can compress everything into a single header file (analagous to IGL_HEADER_ONLY):

    -
    scripts/compress.sh igl.h
    -

    This seems to have the seem linking dependency troubles as above.

    - -

    One option would be to be better about enclosing - things in #ifndef IGL_NO_ANTTWEAKBAR type guards.

    +
    +

    See also: style guidlines, auto-documentation, file formats

    +
+