Browse Source

merge

Former-commit-id: 7d523207b8424156e285782d99564df5bfcd0ad4
Daniele Panozzo 11 years ago
parent
commit
ee5453d587

+ 1 - 1
examples/principal_curvature/curvature.REMOVED.git-id

@@ -1 +1 @@
-982fd49ae481af158720a1ec35673ee78ea80526
+3b29fb167099af338cc72c6c7ac90ac23d8e2948

+ 2 - 1
include/igl/draw_floor.h

@@ -5,7 +5,8 @@
 namespace igl
 {
   // Draw a checkerboard floor aligned with current (X,Z) plane using OpenGL
-  // calls.
+  // calls. side=50 centered at (0,0):
+  //   (-25,-25)-->(-25,25)-->(25,25)-->(25,-25)
   //
   // Use glPushMatrix(), glScaled(), glTranslated() to arrange the floor.
   // 

+ 72 - 2
include/igl/draw_mesh.cpp

@@ -42,8 +42,74 @@ IGL_INLINE void igl::draw_mesh(
     // loop over corners of triangle
     for(int j = 0;j<3;j++)
     {
-      glColor3d(C(F(i,j),0),C(F(i,j),1),C(F(i,j),2));
-      if(C.rows() == V.rows())
+      if(C.rows() == 1)
+      {
+        glColor3d(C(0,0),C(0,1),C(0,2));
+      }else if(C.rows() == V.rows())
+      {
+        glColor3d(C(F(i,j),0),C(F(i,j),1),C(F(i,j),2));
+      }else if(C.rows() == F.rows()*3)
+      {
+        glColor3d(C(i*3+j,0),C(i*3+j,1),C(i*3+j,2));
+      }else if(C.rows() == F.rows())
+      {
+        glColor3d(C(i,0),C(i,1),C(i,2));
+      }else
+      {
+        assert(C.size() == 0);
+      }
+      if(N.rows() == V.rows())
+      {
+        glNormal3d(N(F(i,j),0),N(F(i,j),1),N(F(i,j),2));
+      }else if(N.rows() == F.rows()*3)
+      {
+        glNormal3d(N(i*3+j,0),N(i*3+j,1),N(i*3+j,2));
+      }else if(N.rows() == F.rows())
+      {
+        glNormal3d(N(i,0),N(i,1),N(i,2));
+      }
+      glVertex3d(V(F(i,j),0),V(F(i,j),1),V(F(i,j),2));
+    }
+  }
+  glEnd();
+}
+
+IGL_INLINE void igl::draw_mesh(
+  const Eigen::MatrixXd & V,
+  const Eigen::MatrixXi & F,
+  const Eigen::MatrixXd & N,
+  const Eigen::MatrixXd & C,
+  const Eigen::MatrixXd & TC)
+{
+  glBegin(GL_TRIANGLES);
+  // loop over faces
+  for(int i = 0; i<F.rows();i++)
+  {
+    // loop over corners of triangle
+    for(int j = 0;j<3;j++)
+    {
+
+      if(TC.rows() == 1)
+      {
+        glTexCoord2d(TC(F(i,j),0),TC(F(i,j),1));
+      }else if(TC.rows() == V.rows())
+      {
+        glTexCoord2d(TC(F(i,j),0),TC(F(i,j),1));
+      }else if(TC.rows() == F.rows()*2)
+      {
+        glTexCoord2d(TC(i*2+j,0),TC(i*2+j,1));
+      }else if(TC.rows() == F.rows())
+      {
+        glTexCoord2d(TC(i,0),TC(i,1));
+      }else
+      {
+        assert(TC.size() == 0);
+      }
+
+      if(C.rows() == 1)
+      {
+        glColor3d(C(0,0),C(0,1),C(0,2));
+      }else if(C.rows() == V.rows())
       {
         glColor3d(C(F(i,j),0),C(F(i,j),1),C(F(i,j),2));
       }else if(C.rows() == F.rows()*3)
@@ -52,7 +118,11 @@ IGL_INLINE void igl::draw_mesh(
       }else if(C.rows() == F.rows())
       {
         glColor3d(C(i,0),C(i,1),C(i,2));
+      }else
+      {
+        assert(C.size() == 0);
       }
+
       if(N.rows() == V.rows())
       {
         glNormal3d(N(F(i,j),0),N(F(i,j),1),N(F(i,j),2));

+ 15 - 3
include/igl/draw_mesh.h

@@ -14,7 +14,7 @@ namespace igl
   // Inputs:
   //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F  #F by 3 eigne Matrix of face (triangle) indices
-  //   N  #V by 3 eigen Matrix of mesh vertex 3D normals
+  //   N  #V|#F by 3 eigen Matrix of 3D normals
   IGL_INLINE void draw_mesh(
     const Eigen::MatrixXd & V,
     const Eigen::MatrixXi & F,
@@ -26,13 +26,25 @@ namespace igl
   // Inputs:
   //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
   //   F  #F by 3 eigne Matrix of face (triangle) indices
-  //   N  #V by 3 eigen Matrix of mesh vertex 3D normals
-  //   C  #V by 3 eigen Matrix of mesh vertex RGB colors
+  //   N  #V|#F by 3 eigen Matrix of 3D normals
+  //   C  #V|#F|1 by 3 eigen Matrix of RGB colors
   IGL_INLINE void draw_mesh(
     const Eigen::MatrixXd & V,
     const Eigen::MatrixXi & F,
     const Eigen::MatrixXd & N,
     const Eigen::MatrixXd & C);
+  // Inputs:
+  //   V  #V by 3 eigen Matrix of mesh vertex 3D positions
+  //   F  #F by 3 eigne Matrix of face (triangle) indices
+  //   N  #V|#F by 3 eigen Matrix of 3D normals
+  //   C  #V|#F|1 by 3 eigen Matrix of RGB colors
+  //   TC  #V|#F|1 by 3 eigen Matrix of Texture Coordinates
+  IGL_INLINE void draw_mesh(
+    const Eigen::MatrixXd & V,
+    const Eigen::MatrixXi & F,
+    const Eigen::MatrixXd & N,
+    const Eigen::MatrixXd & C,
+    const Eigen::MatrixXd & TC);
   
   // Draw OpenGL commands needed to display a mesh with normals, per-vertex
   // colors and LBS weights

+ 8 - 6
include/igl/lens_flare.cpp

@@ -1,5 +1,6 @@
 #include "lens_flare.h"
 
+#ifndef IGL_NO_OPENGL
 #include "C_STR.h"
 #include "unproject.h"
 #include "project.h"
@@ -128,12 +129,12 @@ void igl::lens_flare_draw(
   Vector3f center = unproject(Vector3f(0.5*vp[2],0.5*vp[3],plight[2]-1e-3));
   //Vector3f center(0,0,1);
   Vector3f axis = light-center;
-  glLineWidth(4.);
-  glColor3f(1,0,0);
-  glBegin(GL_LINES);
-  glVertex3fv(center.data());
-  glVertex3fv(light.data());
-  glEnd();
+  //glLineWidth(4.);
+  //glColor3f(1,0,0);
+  //glBegin(GL_LINES);
+  //glVertex3fv(center.data());
+  //glVertex3fv(light.data());
+  //glEnd();
 
   const Vector3f SX = unproject(psx).normalized();
   const Vector3f SY = unproject(psy).normalized();
@@ -186,3 +187,4 @@ void igl::lens_flare_draw(
   glDepthFunc(odf);
   glDepthMask(odwm);
 }
+#endif

+ 2 - 0
include/igl/lens_flare.h

@@ -1,6 +1,7 @@
 #ifndef IGL_LENS_FLARE_H
 #define IGL_LENS_FLARE_H
 
+#ifndef IGL_NO_OPENGL
 #include <igl/OpenGL_convenience.h>
 #include <Eigen/Core>
 
@@ -80,3 +81,4 @@ namespace igl
 #endif
 
 #endif
+#endif

+ 5 - 1
include/igl/sort_triangles.cpp

@@ -6,7 +6,6 @@
 #include "round.h"
 #include "colon.h"
 #include "matlab_format.h"
-#include "OpenGL_convenience.h"
 
 #include <iostream>
 
@@ -81,6 +80,8 @@ IGL_INLINE void igl::sort_triangles(
   slice(F,I,1,FF);
 }
 
+#ifndef IGL_NO_OPENGL
+#include "OpenGL_convenience.h"
 template <
   typename DerivedV,
   typename DerivedF,
@@ -553,10 +554,13 @@ class Triangle
 //    return sort_triangles_robust(V,F,MV,P,FF,I);
 //  }
 //}
+#endif
 
 #ifndef IGL_HEADER_ONLY
 // Explicit template instanciation
 //template void igl::sort_triangles_robust<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
+#ifndef IGL_NO_OPENGL
 template void igl::sort_triangles<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 template void igl::sort_triangles_slow<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> >&);
 #endif
+#endif

+ 2 - 0
include/igl/sort_triangles.h

@@ -28,6 +28,7 @@ namespace igl
     const Eigen::PlainObjectBase<DerivedP> & P,
     Eigen::PlainObjectBase<DerivedFF> & FF,
     Eigen::PlainObjectBase<DerivedI> & I);
+#ifndef IGL_NO_OPENGL
   template <
     typename DerivedV,
     typename DerivedF,
@@ -72,6 +73,7 @@ namespace igl
   //  const Eigen::PlainObjectBase<DerivedF> & F,
   //  Eigen::PlainObjectBase<DerivedFF> & FF,
   //  Eigen::PlainObjectBase<DerivedI> & I);
+#endif
 }
 
 #ifdef IGL_HEADER_ONLY

+ 5 - 0
tutorial.html

@@ -297,6 +297,11 @@ g++ -g -I/opt/local/include/eigen3/ -I/usr/local/igl/libigl/ -L/usr/local/igl/li
 ./test path/to/mesh.obj
       </code></pre>
 
+      <p>The following bash one-liner will find all source files that contain the string <code>OpenGL</code> but don't contain and <code>IGL_NO_OPENGL</code> guard:
+      <pre><code>
+grep OpenGL `grep -L IGL_NO_OPENGL include/igl/*`
+      </code></pre>
+
       <h2 id="dependencies">Dependencies</h2>
       <p>
         By design the libigl library has very few external dependencies.