Browse Source

readme

Former-commit-id: 76076d0979080008b0f87a4e35fab843bb7c50c9
Alec Jacobson (jalec 11 years ago
parent
commit
695e3393cd
6 changed files with 203 additions and 179 deletions
  1. 0 0
      LICENSE
  2. 0 153
      README
  3. 147 0
      README.md
  4. 50 21
      examples/arap/example.cpp
  5. 4 4
      examples/quicklook-mesh/Makefile
  6. 2 1
      include/igl/cotangent.cpp

+ 0 - 0
LICENSE.TXT → LICENSE


+ 0 - 153
README

@@ -1,153 +0,0 @@
-libigl - A simple c++ geometry processing library
-
-http://igl.ethz.ch/projects/libigl/
-
-Copyright 2013 - Alec Jacobson, Daniele Panozzo, Olga Diamanti, Kenshi
-Takayama, Leo Sacht, Interactive Geometry Lab - ETH Zurich
-
-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. 
-
-= Dependencies =
-Eigen3  Last tested with Eigen Version 3.2
-
-  = Optional =
-  OpenGL (IGL_NO_OPENGL)
-  AntTweakBar  (IGL_NO_ANTTWEAKBAR) Last tested 1.16 (see
-    libigl/external/AntTweakBar)
-  GLEW  Windows only
-  OpenMP  
-  libpng  libiglpng extra only
-  Mosek  libiglmosek extra only
-  Matlab  libiglmatlab extra only
-  boost  libboost extra only
-
-  = Optional (included in external/ =
-  TetGen  libigltetgen extra only
-  Embree  libiglembree extra only
-  tinyxml2  libiglxml extra only
-
-= Header only =
-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 and define the IGL_HEADER_ONLY macro. To 
-compile a hello-word example.cpp:
-
-#include <Eigen/Dense>
-#include <igl/readOBJ.h>
-#include <iostream>
-int main(int argc, char * argv[])
-{
-  if(argc>1)
-  {
-    Eigen::MatrixXd V;
-    Eigen::MatrixXi F;
-    igl::readOBJ(argv[1],V,F);
-    std::cout<<"Hello, mesh with "<<V.rows()<<" vertices!"<<std::endl;
-  }else{
-    std::cout<<"Hello, world!"<<std::endl;
-  }
-  return 0;
-}
-
-using gcc (replacing appropriate paths):
-
-g++ -DIGL_HEADER_ONLY -I/usr/local/igl/libigl/include \
-  -I/opt/local/include/eigen3 example.cpp -o example
-
-Then run this example with:
-
-./example examples/shared/TinyTorus.obj
-
-= Compile =
-
-  = Linux/Mac OS X/Cygwin =
-  
-  libigl may also be compiled to a static library. This is advantageous when
-  building a project with libigl, since the header only directive can slow down
-  compile times.
-  
-  To build the entire libigl library producing lib/libigl.a, issue:
-  
-  make lib
-  
-  You may need to edit Makefile.conf accordingly. Best to give yourself an
-  IGL_USERNAME and add a custom install suite for yourself. Then you can enable
-  appropriate extras.
-  
-    = Extras =
-    Once you've set up an IGL_USERNAME and enabled extras within Makefile.conf.
-    You can build the extra libraries (into lib/ligiglpng.a, lib/libiglmatlab.a,
-    lib/libigltetgen.a, lib/libiglmosek.a, etc.) by issuing:
-  
-    make extras
-  
-    = Examples =
-    You can make a slew of examples by issuing:
-  
-    make examples
-  
-    = External =
-    Finally there are a number of external libraries that we include in
-    ./external/ because they are either difficult to obtain or they have been
-    patched for easier use with libigl. Please see the respective readmes in
-    those directories.
-
-  = Windows (Experimental) =
-  To build a static library (.lib) on windows, open Visual Studio 2010.
-
-  New > Project ...
-  Visual C++ > Win32
-  Win32 Console Application
-  Name: libiglVisualStudio
-  Uncheck "Create directory for solution"
-  
-  Then hit OK, and then Next
-
-  Check "Static Library"
-  Uncheck "Precompiled headers"
-
-  Add all include/igl/*.cpp to the sources directory
-  Add all include/igl/*.h to the headers directory
-
-  Open Project > libigl Properties...
-  Add the path to eigen3 to the include paths
-  Change the target name to libigl
-
-  Build and pray (this should create libigl.lib
-
-    = Source =
-    http://msdn.microsoft.com/en-us/library/ms235627(v=vs.80).aspx
-
-= Examples =
-To get started, we advise that you take a look at a few examples:
-
-  ./examples/hello-world/
-
-  ./examples/meshio/
-
-  ./examples/basic-topology/
-
-  ./examples/ReAntTweakBar/
-
-= Development =
-Further documentation for developers is listed in tutorial.html,
-style_guidelines.html
-
-= License =
-For now, all files are Copyright 2013 - Alec Jacobson, Daniele Panozzo, Olga
-Diamanti, Kenshi Takayama, Leo Sacht, Interactive Geometry Lab - ETH Zurich
-unless otherwise noted. Soon we hope to upgrade to a more liberal license.
-
-= Zipping =
-Zip this directory without .hg litter using:
-
-make clean
-zip -9 -r --exclude=@exclude.lst  libigl.zip ../libigl
-
-= Contact =
-libigl is a group endeavor led by Alec Jacobson and Daniele Panozzo. Please
-contact alecjacobson@gmail.com if you have questions or comments. We are happy
-to get feedback! Enjoy!

+ 147 - 0
README.md

@@ -0,0 +1,147 @@
+libigl - A simple c++ geometry processing library
+=================================================
+
+<http://igl.ethz.ch/projects/libigl/>
+
+Copyright 2013 - Alec Jacobson, Daniele Panozzo, Olga Diamanti, Kenshi
+Takayama, Leo Sacht
+
+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. 
+
+## Dependencies ##
+- Eigen3  Last tested with Eigen Version 3.2
+
+### Optional ###
+- OpenGL (IGL_NO_OPENGL)
+- AntTweakBar  (IGL_NO_ANTTWEAKBAR) Last tested 1.16 (see
+-   libigl/external/AntTweakBar)
+- GLEW  Windows only
+- OpenMP  
+- libpng  libiglpng extra only
+- Mosek  libiglmosek extra only
+- Matlab  libiglmatlab extra only
+- boost  libboost extra only
+
+### Optional (included in external/) ###
+- TetGen  libigltetgen extra only
+- Embree  libiglembree extra only
+- tinyxml2  libiglxml extra only
+ 
+## Header only ##
+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 and define the IGL_HEADER_ONLY macro. To 
+compile a hello-word example.cpp:
+
+    #include <Eigen/Dense>
+    #include <igl/readOBJ.h>
+    #include <iostream>
+    int main(int argc, char * argv[])
+    {
+      if(argc>1)
+      {
+        Eigen::MatrixXd V;
+        Eigen::MatrixXi F;
+        igl::readOBJ(argv[1],V,F);
+        std::cout<<"Hello, mesh with "<<V.rows()<<" vertices!"<<std::endl;
+      }else{
+        std::cout<<"Hello, world!"<<std::endl;
+      }
+      return 0;
+    }
+
+using gcc (replacing appropriate paths):
+
+    g++ -DIGL_HEADER_ONLY -I/usr/local/igl/libigl/include \
+      -I/opt/local/include/eigen3 example.cpp -o example
+
+Then run this example with:
+
+    ./example examples/shared/TinyTorus.obj
+
+## Compile ##
+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 the header only directive can slow down
+compile times.
+
+To build the entire libigl library producing lib/libigl.a, issue:
+  
+    make lib
+  
+You may need to edit Makefile.conf accordingly. Best to give yourself an
+IGL_USERNAME and add a custom install suite for yourself. Then you can enable
+appropriate extras.
+  
+#### Extras ####
+Once you've set up an IGL_USERNAME and enabled extras within Makefile.conf.
+You can build the extra libraries (into lib/ligiglpng.a, lib/libiglmatlab.a,
+lib/libigltetgen.a, lib/libiglmosek.a, etc.) by issuing:
+  
+    make extras
+  
+#### Examples ####
+You can make a slew of examples by issuing:
+  
+    make examples
+  
+#### External ####
+Finally there are a number of external libraries that we include in
+./external/ because they are either difficult to obtain or they have been
+patched for easier use with libigl. Please see the respective readmes in
+those directories.
+
+## Windows (Experimental) ##
+To build a static library (.lib) on windows, open Visual Studio 2010.
+
+- New > Project ...
+- Visual C++ > Win32
+- Win32 Console Application
+- Name: libiglVisualStudio
+- Uncheck "Create directory for solution"
+- Then hit OK, and then Next
+- Check "Static Library"
+- Uncheck "Precompiled headers"
+- Add all include/igl/*.cpp to the sources directory
+- Add all include/igl/*.h to the headers directory
+- Open Project > libigl Properties...
+- Add the path to eigen3 to the include paths
+- Change the target name to libigl
+- Build and pray (this should create libigl.lib
+
+[Source](http://msdn.microsoft.com/en-us/library/ms235627(v=vs.80).aspx)
+
+## Examples ##
+To get started, we advise that you take a look at a few examples:
+
+    ./examples/hello-world/
+
+    ./examples/meshio/
+
+    ./examples/basic-topology/
+
+    ./examples/ReAntTweakBar/
+
+## Development ##
+Further documentation for developers is listed in tutorial.html,
+style_guidelines.html
+
+## License ##
+See `LICENSE.txt`
+
+## Zipping ##
+Zip this directory without .hg litter using:
+
+    make clean
+    zip -9 -r --exclude=@exclude.lst  libigl.zip ../libigl
+
+## Contact ##
+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!

+ 50 - 21
examples/arap/example.cpp

@@ -28,6 +28,7 @@
 #include <igl/material_colors.h>
 #include <igl/barycenter.h>
 #include <igl/matlab_format.h>
+#include <igl/material_colors.h>
 #include <igl/ReAntTweakBar.h>
 #include <igl/pathinfo.h>
 #include <igl/Camera.h>
@@ -129,7 +130,7 @@ int width,height;
 // Position of light
 float light_pos[4] = {0.1,0.1,-0.9,0};
 // Vertex positions, normals, colors and centroid
-Eigen::MatrixXd V,U,N,mid;
+Eigen::MatrixXd V,U,N,C,mid;
 Eigen::VectorXi S;
 igl::ARAPData arap_data;
 Eigen::MatrixXi F;
@@ -163,6 +164,7 @@ bool init_arap()
   using namespace std;
   VectorXi b(num_in_selection(S));
   assert(S.rows() == V.rows());
+  C.resize(S.rows(),3);
   MatrixXd bc = MatrixXd::Zero(b.size(),S.maxCoeff()+1);
   // get b from S
   {
@@ -174,6 +176,19 @@ bool init_arap()
         b(bi) = v;
         bc(bi,S(v)) = 1;
         bi++;
+        if(S(v) == 0)
+        {
+          C.row(v) = RowVector3d(0.039,0.31,1);
+        }else
+        {
+          C.row(v) = RowVector3d(1,0.41,0.70);
+        }
+      }else
+      {
+        C.row(v) = RowVector3d(
+          GOLD_DIFFUSE[0],
+          GOLD_DIFFUSE[1],
+          GOLD_DIFFUSE[2]);
       }
     }
   }
@@ -208,16 +223,27 @@ bool update_arap()
         {
           case 0:
           {
-            const double r = mid(0)*0.25;
-            bc(bi,0) += r*cos(0.5*get_seconds()*2.*PI);
-            bc(bi,1) -= r+r*sin(0.5*get_seconds()*2.*PI);
+            //const double r = mid(0)*0.25;
+            //bc(bi,0) += r*cos(0.5*get_seconds()*2.*PI);
+            //bc(bi,1) -= r+r*sin(0.5*get_seconds()*2.*PI);
             break;
           }
           case 1:
           {
-            const double r = mid(1)*0.15;
-            bc(bi,1) += r+r*cos(0.15*get_seconds()*2.*PI);
-            bc(bi,2) -= r*sin(0.15*get_seconds()*2.*PI);
+            //const double r = mid(1)*0.15;
+            //bc(bi,1) += r+r*cos(0.15*get_seconds()*2.*PI);
+            //bc(bi,2) -= r*sin(0.15*get_seconds()*2.*PI);
+
+            //// Pull-up
+            //bc(bi,0) += 0.42;//mid(0)*0.5;
+            //bc(bi,1) += 0.55;//mid(0)*0.5;
+            // Bend
+            Vector3d t(-1,0,0);
+            Quaterniond q(AngleAxisd(PI/1.5,Vector3d(0,1.0,0.1).normalized()));
+            const Vector3d a = bc.row(bi);
+            bc.row(bi) = (q*(a-t) + t) + Vector3d(1.5,0.1,0.9);
+                
+
             break;
           }
           default:
@@ -304,7 +330,7 @@ void lights()
   using namespace std;
   glEnable(GL_LIGHTING);
   glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
-  glEnable(GL_LIGHT0);
+  //glEnable(GL_LIGHT0);
   glEnable(GL_LIGHT1);
   float amb[4];
   amb[0] = amb[1] = amb[2] = 0;
@@ -328,7 +354,8 @@ void lights()
   glLightfv(GL_LIGHT1,GL_POSITION,pos);
 }
 
-const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
+//const float back[4] = {30.0/255.0,30.0/255.0,50.0/255.0,0};
+const float back[4] = {255.0/255.0,255.0/255.0,255.0/255.0,0};
 void display()
 {
   using namespace Eigen;
@@ -363,17 +390,18 @@ void display()
 
   // Draw the model
   // Set material properties
-  glDisable(GL_COLOR_MATERIAL);
-  glMaterialfv(GL_FRONT, GL_AMBIENT,  GOLD_AMBIENT);
-  glMaterialfv(GL_FRONT, GL_DIFFUSE,  GOLD_DIFFUSE  );
-  glMaterialfv(GL_FRONT, GL_SPECULAR, GOLD_SPECULAR);
-  glMaterialf (GL_FRONT, GL_SHININESS, 128);
-  glMaterialfv(GL_BACK, GL_AMBIENT,  SILVER_AMBIENT);
-  glMaterialfv(GL_BACK, GL_DIFFUSE,  FAST_GREEN_DIFFUSE  );
-  glMaterialfv(GL_BACK, GL_SPECULAR, SILVER_SPECULAR);
-  glMaterialf (GL_BACK, GL_SHININESS, 128);
-
-  draw_mesh(U,F,N);
+  //glDisable(GL_COLOR_MATERIAL);
+  //glMaterialfv(GL_FRONT, GL_AMBIENT,  GOLD_AMBIENT);
+  //glMaterialfv(GL_FRONT, GL_DIFFUSE,  GOLD_DIFFUSE  );
+  //glMaterialfv(GL_FRONT, GL_SPECULAR, GOLD_SPECULAR);
+  //glMaterialf (GL_FRONT, GL_SHININESS, 128);
+  //glMaterialfv(GL_BACK, GL_AMBIENT,  SILVER_AMBIENT);
+  //glMaterialfv(GL_BACK, GL_DIFFUSE,  FAST_GREEN_DIFFUSE  );
+  //glMaterialfv(GL_BACK, GL_SPECULAR, SILVER_SPECULAR);
+  //glMaterialf (GL_BACK, GL_SHININESS, 128);
+  glEnable(GL_COLOR_MATERIAL);
+
+  draw_mesh(U,F,N,C);
   glDisable(GL_COLOR_MATERIAL);
 
   pop_object();
@@ -387,7 +415,8 @@ void display()
   const float GREY[4] = {0.5,0.5,0.6,1.0};
   const float DARK_GREY[4] = {0.2,0.2,0.3,1.0};
 
-  draw_floor(GREY,DARK_GREY);
+  //draw_floor(GREY,DARK_GREY);
+  draw_floor();
   glPopMatrix();
 
   pop_scene();

+ 4 - 4
examples/quicklook-mesh/Makefile

@@ -4,10 +4,10 @@
 # include the Foundation headers
 #CXX=llvm-g++
 #C=llvm-gcc
-#CXX=clang++
-#C=clang
-CXX=clang++-mp-3.4
-C=clang-mp-3.4
+CXX=clang++
+C=clang
+#CXX=clang++-mp-3.4
+#C=clang-mp-3.4
 CXXFLAGS += -stdlib=libc++ -std=c++11
 
 EIGEN=/opt/local/include/eigen3/

+ 2 - 1
include/igl/cotangent.cpp

@@ -22,6 +22,7 @@ IGL_INLINE void igl::cotangent(const MatV & V, const MatF & F, MatC & C)
   // Number of elements
   int m = F.rows();
 
+  // Law of cosines + law of sines
   if(simplex_size == 3)
   {
     // Triangles
@@ -39,7 +40,7 @@ IGL_INLINE void igl::cotangent(const MatV & V, const MatF & F, MatC & C)
     // semiperimeters
     Matrix<typename MatC::Scalar,Dynamic,1> s = l.rowwise().sum()*0.5;
     assert(s.rows() == m);
-    // Heron's forumal for area
+    // Heron's formula for area
     Matrix<typename MatC::Scalar,Dynamic,1> dblA(m);
     for(int i = 0;i<m;i++)
     {