Explorar el Código

compiles with skinning app

Former-commit-id: 18c9719d8e76b3076a0f547bac5b237736f19cbb
jalec hace 13 años
padre
commit
3888611403

+ 1 - 1
examples/glslversion/Makefile

@@ -12,7 +12,7 @@ igl_lib=../../
 
 CFLAGS=-g
 inc=-I$(igl_lib)/include
-lib=-framework OpenGL -framework GLUT -L$(igl_lib)/lib -ligl
+lib=$(OPENGL_LIB) $(GLUT_LIB) -L$(igl_lib)/lib -ligl
 
 example: example.o
 	g++ $(CFLAGS) -o example example.o $(lib)

+ 5 - 1
examples/glslversion/example.cpp

@@ -1,4 +1,8 @@
-#include <GLUT/glut.h>
+#ifdef __APPLE__
+#  include <GLUT/glut.h>
+#else
+#  include <GL/glut.h>
+#endif
 #include <cstdio>
 
 int main(int argc,char * argv[])

+ 2 - 2
examples/glut_speed_test/Makefile

@@ -12,10 +12,10 @@ igl_lib=../../
 
 CFLAGS=-g -Wall 
 inc=-I$(igl_lib)/include
-lib=-L$(igl_lib)/lib -ligl
+lib=$(OPENGL_LIB) $(GLUT_LIB) -L$(igl_lib)/lib -ligl
 
 example: example.o
-	g++ $(CFLAGS) -o example example.o -framework OpenGL -framework GLUT $(lib)
+	g++ $(CFLAGS) -o example example.o $(lib)
 
 example.o: example.cpp
 	g++ $(CFLAGS) $(deps) -c example.cpp -o example.o $(inc)

+ 1 - 0
examples/harwell_boeing/example.cpp

@@ -1,5 +1,6 @@
 #define IGL_HEADER_ONLY
 #include <igl/harwell_boeing.h>
+#include <iostream>
 
 template <typename T>
 void print(T & v)

+ 2 - 0
examples/marching_cubes/example.cpp

@@ -1,4 +1,6 @@
 #include <igl/marching_cubes.h>
+#include <iostream>
+#include <cstdio>
 
 #include "igl/MCTables.hh"
 

+ 1 - 0
examples/meshio/example.cpp

@@ -1,4 +1,5 @@
 #include <igl/readOBJ.h>
+#include <iostream>
 
 #include <cstdio>
 #include <vector>

+ 1 - 0
examples/sort/example.cpp

@@ -5,6 +5,7 @@ using namespace std;
 #include <igl/sort.h>
 using namespace igl;
 
+#include <cstdio>
 
 template <typename T>
 void matlab_print(const string name, const T & X)

+ 2 - 2
examples/trackball/Makefile

@@ -13,10 +13,10 @@ igl_lib=../../
 CFLAGS=-g -Wall 
 #deps=-MMD -MF depends.txt
 inc=-I$(igl_lib)/include
-lib=-L$(igl_lib)/lib -ligl
+lib=$(OPENGL_LIB) $(GLUT_LIB) -L$(igl_lib)/lib -ligl
 
 example: example.o
-	g++ $(CFLAGS) -o example example.o -framework OpenGL -framework GLUT $(lib)
+	g++ $(CFLAGS) -o example example.o $(lib)
 
 example.o: example.cpp
 	g++ $(CFLAGS) $(deps) -c example.cpp -o example.o $(inc)

+ 2 - 2
include/igl/canonical_quaternions.cpp

@@ -2,11 +2,11 @@
 
 template <> IGL_INLINE const float igl::CANONICAL_VIEW_QUAT<float>(int i, int j)
 {
-  return igl::CANONICAL_VIEW_QUAT_F[i][j];
+  return (float)igl::CANONICAL_VIEW_QUAT_F[i][j];
 }
 template <> IGL_INLINE const double igl::CANONICAL_VIEW_QUAT<double>(int i, int j)
 {
-  return igl::CANONICAL_VIEW_QUAT_D[i][j];
+  return (double)igl::CANONICAL_VIEW_QUAT_D[i][j];
 }
 
 #ifndef IGL_HEADER_ONLY

+ 1 - 1
include/igl/cotangent.cpp

@@ -106,7 +106,7 @@ IGL_INLINE void igl::cotangent(const MatV & V, const MatF & F, MatC & C)
 
       // Kj =  det(JTj)/6 * Ej'Ej 
       Mat4x4 Kj = EjTEj*volume;
-      diag_all_pos &= Kj(0,0)>0 & Kj(1,1)>0 & Kj(2,2)>0 & Kj(3,3)>0;
+      diag_all_pos &= ((Kj(0,0)>0) & (Kj(1,1)>0)) & ((Kj(2,2)>0) & (Kj(3,3)>0));
       C(j,0) = Kj(1,2);
       C(j,1) = Kj(2,0);
       C(j,2) = Kj(0,1);

+ 2 - 0
include/igl/project_to_line.cpp

@@ -17,9 +17,11 @@ IGL_INLINE void igl::project_to_line(
   // http://mathworld.wolfram.com/Point-LineDistance3-Dimensional.html
 
   // number of dimensions
+#ifndef NDEBUG
   int dim = P.cols();
   assert(dim == S.size());
   assert(dim == D.size());
+#endif
   // number of points
   int np  = P.rows();
   // vector from source to destination

+ 10 - 34
include/igl/readMESH.cpp

@@ -106,12 +106,8 @@ IGL_INLINE bool igl::readMESH(
 
   //fgets(line,LINE_MAX,mesh_file);
 
-#ifdef __APPLE__
-  size_t number_of_vertices;
-#else
   int number_of_vertices;
-#endif
-  if(1 != fscanf(mesh_file," %ld",&number_of_vertices) || number_of_vertices > 1000000000)
+  if(1 != fscanf(mesh_file," %d",&number_of_vertices) || number_of_vertices > 1000000000)
   {
     fprintf(stderr,"Error: expecting number of vertices less than 10^9...\n");
     fclose(mesh_file);
@@ -119,15 +115,11 @@ IGL_INLINE bool igl::readMESH(
   }
   // allocate space for vertices
   V.resize(number_of_vertices,vector<Scalar>(3,0));
-#ifdef __APPLE__
-  size_t extra;
-#else
   int extra;
-#endif
-  for(size_t i = 0;i<number_of_vertices;i++)
+  for(int i = 0;i<number_of_vertices;i++)
   {
     double x,y,z;
-    if(4 != fscanf(mesh_file," %lg %lg %lg %ld",&x,&y,&z,&extra))
+    if(4 != fscanf(mesh_file," %lg %lg %lg %d",&x,&y,&z,&extra))
     {
       fprintf(stderr,"Error: expecting vertex position...\n");
       fclose(mesh_file);
@@ -154,12 +146,8 @@ IGL_INLINE bool igl::readMESH(
     fclose(mesh_file);
     return false;
   }
-#ifdef __APPLE__
-  size_t number_of_triangles;
-#else
   int number_of_triangles;
-#endif
-  if(1 != fscanf(mesh_file," %ld",&number_of_triangles))
+  if(1 != fscanf(mesh_file," %d",&number_of_triangles))
   {
     fprintf(stderr,"Error: expecting number of triangles...\n");
     fclose(mesh_file);
@@ -168,19 +156,15 @@ IGL_INLINE bool igl::readMESH(
   // allocate space for triangles
   F.resize(number_of_triangles,vector<Index>(3));
   // triangle indices
-#ifdef __APPLE__
-  size_t tri[3];
-#else
   int tri[3];
-#endif
-  for(size_t i = 0;i<number_of_triangles;i++)
+  for(int i = 0;i<number_of_triangles;i++)
   {
-    if(4 != fscanf(mesh_file," %ld %ld %ld %ld",&tri[0],&tri[1],&tri[2],&extra))
+    if(4 != fscanf(mesh_file," %d %d %d %d",&tri[0],&tri[1],&tri[2],&extra))
     {
       printf("Error: expecting triangle indices...\n");
       return false;
     }
-    for(size_t j = 0;j<3;j++)
+    for(int j = 0;j<3;j++)
     {
       F[i][j] = tri[j]-1;
     }
@@ -202,12 +186,8 @@ IGL_INLINE bool igl::readMESH(
     fclose(mesh_file);
     return false;
   }
-#ifdef __APPLE__
-  size_t number_of_tetrahedra;
-#else
   int number_of_tetrahedra;
-#endif
-  if(1 != fscanf(mesh_file," %ld",&number_of_tetrahedra))
+  if(1 != fscanf(mesh_file," %d",&number_of_tetrahedra))
   {
     fprintf(stderr,"Error: expecting number of tetrahedra...\n");
     fclose(mesh_file);
@@ -216,14 +196,10 @@ IGL_INLINE bool igl::readMESH(
   // allocate space for tetrahedra
   T.resize(number_of_tetrahedra,vector<Index>(4));
   // tet indices
-#ifdef __APPLE__  
-  size_t a,b,c,d;
-#else
   int a,b,c,d;
-#endif 
-  for(size_t i = 0;i<number_of_tetrahedra;i++)
+  for(int i = 0;i<number_of_tetrahedra;i++)
   {
-    if(5 != fscanf(mesh_file," %ld %ld %ld %ld %ld",&a,&b,&c,&d,&extra))
+    if(5 != fscanf(mesh_file," %d %d %d %d %d",&a,&b,&c,&d,&extra))
     {
       fprintf(stderr,"Error: expecting tetrahedra indices...\n");
       fclose(mesh_file);

+ 7 - 1
include/igl/rotate_by_quat.cpp

@@ -17,8 +17,14 @@ IGL_INLINE void igl::rotate_by_quat(
 
   // normalize input 
   Q_type normalized_q[4];
-  bool normalized = igl::normalize_quat<Q_type>(q,normalized_q);
+
+#ifndef NDEBUG
+  bool normalized = 
+#endif
+  igl::normalize_quat<Q_type>(q,normalized_q);
+#ifndef NDEBUG
   assert(normalized);
+#endif
 
   // Conjugate of q
   Q_type q_conj[4];

+ 2 - 0
include/igl/slice.cpp

@@ -75,8 +75,10 @@ IGL_INLINE void igl::slice(
   const Eigen::Matrix<int,Eigen::Dynamic,1> & C,
   Eigen::PlainObjectBase<DerivedX> & Y)
 {
+#ifndef NDEBUG
   int xm = X.rows();
   int xn = X.cols();
+#endif
   int ym = R.size();
   int yn = C.size();
 

+ 1 - 0
include/igl/tt.cpp

@@ -95,4 +95,5 @@ IGL_INLINE void igl::tt(const Eigen::PlainObjectBase<DerivedV>& V,
 // Explicit template specialization
 // generated by autoexplicit.sh
 template void igl::tt<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::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> >&);
+template void igl::tt<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::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

+ 34 - 15
include/igl/upsample.cpp

@@ -1,15 +1,24 @@
 #include "upsample.h"
 
 #include "tt.h"
-#include <Eigen/Dense>
 
-// Bug in unsupported/Eigen/SparseExtra needs iostream first
-#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
-#include <iostream>
-#include <unsupported/Eigen/SparseExtra>
+//// Bug in unsupported/Eigen/SparseExtra needs iostream first
+//#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
+//#include <iostream>
+//#include <unsupported/Eigen/SparseExtra>
+
+#include <Eigen/Dense>
 
-template <typename MatV, typename MatF>
-IGL_INLINE void igl::upsample( const MatV & V, const MatF & F, MatV & NV, MatF & NF)
+template <
+  typename DerivedV, 
+  typename DerivedF,
+  typename DerivedNV,
+  typename DerivedNF>
+IGL_INLINE void igl::upsample(
+  const Eigen::PlainObjectBase<DerivedV>& V,
+  const Eigen::PlainObjectBase<DerivedF>& F,
+  Eigen::PlainObjectBase<DerivedNV>& NV,
+  Eigen::PlainObjectBase<DerivedNF>& NF)
 {
   // Use "in place" wrapper instead
   assert(&V != &NV);
@@ -18,13 +27,17 @@ IGL_INLINE void igl::upsample( const MatV & V, const MatF & F, MatV & NV, MatF &
   using namespace std;
   using namespace Eigen;
 
-  MatF FF, FFi;
-  tt<double>(V,F,FF,FFi);
+  ////typedef Eigen::PlainObjectBase<DerivedF> MatF;
+  ////typedef Eigen::PlainObjectBase<DerivedNF> MatNF;
+  ////typedef Eigen::PlainObjectBase<DerivedNV> MatNV;
+  ////MatF FF, FFi;
+  Eigen::MatrixXi FF,FFi;
+  tt(V,F,FF,FFi);
 
   // TODO: Cache optimization missing from here, it is a mess
   
   // Compute the number and positions of the vertices to insert (on edges)
-  MatF NI = MatF::Constant(FF.rows(),FF.cols(),-1);
+  Eigen::MatrixXi NI = Eigen::MatrixXi::Constant(FF.rows(),FF.cols(),-1);
   int counter = 0;
   
   for(int i=0;i<FF.rows();++i)
@@ -49,8 +62,8 @@ IGL_INLINE void igl::upsample( const MatV & V, const MatF & F, MatV & NV, MatF &
   //SUBD.reserve(15 * (V.rows()+n_even));
   
   // Preallocate NV and NF
-  NV = MatV(V.rows()+n_even,V.cols());
-  NF = MatF(F.rows()*4,3);
+  NV.resize(V.rows()+n_even,V.cols());
+  NF.resize(F.rows()*4,3);
   
   // Fill the odd vertices position
   NV.block(0,0,V.rows(),V.cols()) = V;
@@ -84,9 +97,15 @@ IGL_INLINE void igl::upsample( const MatV & V, const MatF & F, MatV & NV, MatF &
   
 }
 
-template <typename MatV, typename MatF>
-IGL_INLINE void igl::upsample( MatV & V,MatF & F)
+template <
+  typename DerivedV, 
+  typename DerivedF>
+IGL_INLINE void igl::upsample(
+  Eigen::PlainObjectBase<DerivedV>& V,
+  Eigen::PlainObjectBase<DerivedF>& F)
 {
+  typedef Eigen::PlainObjectBase<DerivedF> MatF;
+  typedef Eigen::PlainObjectBase<DerivedV> MatV;
   const MatV V_copy = V;
   const MatF F_copy = F;
   return upsample(V_copy,F_copy,V,F);
@@ -94,5 +113,5 @@ IGL_INLINE void igl::upsample( MatV & V,MatF & F)
 
 #ifndef IGL_HEADER_ONLY
 // Explicit template specialization
-//template void igl::upsample<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::Matrix<double, -1, -1, 0, -1, -1>&, Eigen::Matrix<int, -1, -1, 0, -1, -1>&);
+template void igl::upsample<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 21 - 4
include/igl/upsample.h

@@ -1,6 +1,11 @@
 #ifndef IGL_UPSAMPLE_H
 #define IGL_UPSAMPLE_H
 #include "igl_inline.h"
+
+#include <Eigen/Core>
+
+// History:
+//  changed templates from generic matrices to PlainObjectBase Alec May 7, 2011
 namespace igl
 {
   // Subdivide a mesh without moving vertices: loop subdivision but odd
@@ -18,11 +23,23 @@ namespace igl
   //
   // NOTE: V should not be the same as NV,
   // NOTE: F should not be the same as NF, use other proto
-  template <typename MatV, typename MatF>
-  IGL_INLINE void upsample( const MatV & V, const MatF & F, MatV & NV, MatF & NF);
+  template <
+    typename DerivedV, 
+    typename DerivedF,
+    typename DerivedNV,
+    typename DerivedNF>
+  IGL_INLINE void upsample(
+    const Eigen::PlainObjectBase<DerivedV>& V,
+    const Eigen::PlainObjectBase<DerivedF>& F,
+    Eigen::PlainObjectBase<DerivedNV>& NV,
+    Eigen::PlainObjectBase<DerivedNF>& NF);
   // Virtually in place wrapper
-  template <typename MatV, typename MatF>
-  IGL_INLINE void upsample( MatV & V,MatF & F);
+  template <
+    typename DerivedV, 
+    typename DerivedF>
+  IGL_INLINE void upsample(
+    Eigen::PlainObjectBase<DerivedV>& V,
+    Eigen::PlainObjectBase<DerivedF>& F);
 }
 
 #ifdef IGL_HEADER_ONLY