Эх сурвалжийг харах

Misc compilation fixes for Eigen 3.3 compatibility.

Jérémie Dumas 6 жил өмнө
parent
commit
607148cf72

+ 2 - 2
.appveyor.yml

@@ -25,9 +25,9 @@ build_script:
   - set PATH=C:\Python%PYTHON%-x64;C:\Python%PYTHON%-x64\Scripts;%PATH%
   - mkdir build
   - cd build
-  - cmake -DCMAKE_BUILD_TYPE=%CONFIG% -DLIBIGL_WITH_CGAL=ON -DLIBIGL_WITH_COMISO=OFF -G "Visual Studio 15 2017 Win64" ../
+  - cmake -DCMAKE_BUILD_TYPE=%CONFIG% -DLIBIGL_WITH_CGAL=ON -DLIBIGL_WITH_COMISO=OFF -DEMBREE_ISA_AVX=OFF -DEMBREE_ISA_AVX2=OFF -DEMBREE_ISA_AVX512SKX=OFF -G "Visual Studio 15 2017 Win64" ../
   - set MSBuildLogger="C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll"
-  - set MSBuildOptions=/v:m /m:4 /p:BuildInParallel=true /p:Configuration=%CONFIG% /logger:%MSBuildLogger%
+  - set MSBuildOptions=/v:m /m /p:BuildInParallel=true /p:Configuration=%CONFIG% /logger:%MSBuildLogger%
   - msbuild %MSBuildOptions% libigl.sln
 
 test_script:

+ 22 - 1
.travis.yml

@@ -44,6 +44,27 @@ matrix:
         - libpython3-dev
     env:
     - MATRIX_EVAL="export CC=gcc-7 && CXX=g++-7 && CONFIG=Debug && PYTHON=python3"
+  - os: linux
+    compiler: gcc-7
+    addons:
+      apt:
+        sources:
+        - ubuntu-toolchain-r-test
+        packages:
+        - gcc-7
+        - g++-7
+        - libmpfr-dev
+        - libboost-filesystem-dev
+        - libboost-system-dev
+        - libboost-thread-dev
+        - libblas-dev
+        - liblapack-dev
+        - xorg-dev
+        - libglu1-mesa-dev
+        - python3-setuptools
+        - libpython3-dev
+    env:
+    - MATRIX_EVAL="export CC=gcc-7 && CXX=g++-7 && CONFIG=Debug && PYTHON=python3 CMAKE_EXTRA='-DLIBIGL_EIGEN_VERSION=3.3.7 -DLIBIGL_EIGEN_MD5=f2a417d083fe8ca4b8ed2bc613d20f07'"
   - os: osx
     compiler: clang
     env:
@@ -60,7 +81,7 @@ script:
 # Tutorials and tests
 - mkdir build
 - pushd build
-- cmake -DCMAKE_BUILD_TYPE=$CONFIG -DLIBIGL_CHECK_UNDEFINED=ON -DLIBIGL_WITH_CGAL=ON -DEMBREE_ISA_AVX=OFF -DEMBREE_ISA_AVX2=OFF -DEMBREE_ISA_AVX512SKX=OFF ../
+- cmake ${CMAKE_EXTRA} -DCMAKE_BUILD_TYPE=$CONFIG -DLIBIGL_CHECK_UNDEFINED=ON -DLIBIGL_WITH_CGAL=ON -DEMBREE_ISA_AVX=OFF -DEMBREE_ISA_AVX2=OFF -DEMBREE_ISA_AVX512SKX=OFF ../
 - make -j 2
 - ctest --verbose
 - popd

+ 7 - 3
cmake/LibiglDownloadExternal.cmake

@@ -48,10 +48,14 @@ function(igl_download_cork)
 endfunction()
 
 ## Eigen
+# 3.2.10 8ad10ac703a78143a4062c9bda9d8fd3
+# 3.3.7  f2a417d083fe8ca4b8ed2bc613d20f07
+option(LIBIGL_EIGEN_VERSION "Default version of Eigen used by libigl." 3.2.10)
+option(LIBIGL_EIGEN_MD5     "md5sum of the tar.gz archive corresponding to this version." 8ad10ac703a78143a4062c9bda9d8fd3)
 function(igl_download_eigen)
 	igl_download_project(eigen
-		URL           http://bitbucket.org/eigen/eigen/get/3.2.10.tar.gz
-		URL_MD5       8ad10ac703a78143a4062c9bda9d8fd3
+		URL           http://bitbucket.org/eigen/eigen/get/${LIBIGL_EIGEN_VERSION}.tar.gz
+		URL_MD5       ${LIBIGL_EIGEN_MD5}
 	)
 endfunction()
 
@@ -113,7 +117,7 @@ endfunction()
 function(igl_download_tetgen)
 	igl_download_project(tetgen
 		GIT_REPOSITORY https://github.com/jdumas/tetgen.git
-		GIT_TAG        63b4bdc5b947f9db75f01e0da36af54074ace5c9
+		GIT_TAG        c63e7a6434652b8a2065c835bd9d6d298db1a0bc
 	)
 endfunction()
 

+ 5 - 4
include/igl/heat_geodesics.cpp

@@ -63,7 +63,7 @@ IGL_INLINE bool igl::heat_geodesics_precompute(
   // number of gradient components
   data.ng = data.Grad.rows() / F.rows();
   assert(data.ng == 3 || data.ng == 2);
-  data.Div = -0.25*data.Grad.transpose()*dblA.replicate(data.ng,1).asDiagonal();
+  data.Div = -0.25*data.Grad.transpose()*dblA.colwise().replicate(data.ng).asDiagonal();
 
   Eigen::SparseMatrix<Scalar> Q = M - t*L;
   Eigen::MatrixXi O;
@@ -85,8 +85,9 @@ IGL_INLINE bool igl::heat_geodesics_precompute(
       }
     }
     const Eigen::SparseMatrix<double> Aeq = M.diagonal().transpose().sparseView();
+    L *= -0.5;
     if(!igl::min_quad_with_fixed_precompute(
-      (-L*0.5).eval(),Eigen::VectorXi(),Aeq,true,data.Poisson))
+      L,Eigen::VectorXi(),Aeq,true,data.Poisson))
     {
       return false;
     }
@@ -117,7 +118,7 @@ IGL_INLINE void igl::heat_geodesics_solve(
     // Average Dirichelt and Neumann solutions
     DerivedD uD;
     igl::min_quad_with_fixed_solve(
-      data.Dirichlet,u0,DerivedD::Zero(data.b.size()),DerivedD(),uD);
+      data.Dirichlet,u0,DerivedD::Zero(data.b.size()).eval(),DerivedD(),uD);
     u += uD;
     u *= 0.5;
   }
@@ -141,7 +142,7 @@ IGL_INLINE void igl::heat_geodesics_solve(
   }
   const DerivedD div_X = -data.Div*grad_u;
   const DerivedD Beq = (DerivedD(1,1)<<0).finished();
-  igl::min_quad_with_fixed_solve(data.Poisson,-2.0*div_X,DerivedD(),Beq,D);
+  igl::min_quad_with_fixed_solve(data.Poisson,(-2.0*div_X).eval(),DerivedD(),Beq,D);
   DerivedD Dgamma;
   igl::slice(D,gamma,Dgamma);
   D.array() -= Dgamma.mean();

+ 3 - 0
include/igl/matlab_format.cpp

@@ -113,12 +113,15 @@ IGL_INLINE const std::string igl::matlab_format(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
+#if EIGEN_VERSION_AT_LEAST(3,3,0)
+#else
 // generated by autoexplicit.sh
 template Eigen::WithFormat<Eigen::CwiseUnaryOp<Eigen::internal::scalar_cast_op<bool, int>, Eigen::Matrix<bool, -1, 3, 0, -1, 3> const> > const igl::matlab_format<Eigen::CwiseUnaryOp<Eigen::internal::scalar_cast_op<bool, int>, Eigen::Matrix<bool, -1, 3, 0, -1, 3> const> >(Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_cast_op<bool, int>, Eigen::Matrix<bool, -1, 3, 0, -1, 3> const> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >);
 // generated by autoexplicit.sh
 template Eigen::WithFormat<Eigen::CwiseUnaryOp<Eigen::internal::scalar_add_op<int>, Eigen::ArrayWrapper<Eigen::Matrix<int, -1, -1, 0, -1, -1> const> const> > const igl::matlab_format<Eigen::CwiseUnaryOp<Eigen::internal::scalar_add_op<int>, Eigen::ArrayWrapper<Eigen::Matrix<int, -1, -1, 0, -1, -1> const> const> >(Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_add_op<int>, Eigen::ArrayWrapper<Eigen::Matrix<int, -1, -1, 0, -1, -1> const> const> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >);
 // generated by autoexplicit.sh
 template Eigen::WithFormat<Eigen::CwiseUnaryOp<Eigen::internal::scalar_add_op<int>, Eigen::ArrayWrapper<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const> > const igl::matlab_format<Eigen::CwiseUnaryOp<Eigen::internal::scalar_add_op<int>, Eigen::ArrayWrapper<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const> >(Eigen::DenseBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_add_op<int>, Eigen::ArrayWrapper<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >);
+#endif
 // generated by autoexplicit.sh
 template Eigen::WithFormat<Eigen::Matrix<float, 1, 3, 1, 1, 3> > const igl::matlab_format<Eigen::Matrix<float, 1, 3, 1, 1, 3> >(Eigen::DenseBase<Eigen::Matrix<float, 1, 3, 1, 1, 3> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >);
 // generated by autoexplicit.sh

+ 3 - 0
include/igl/min_quad_with_fixed.cpp

@@ -582,8 +582,11 @@ IGL_INLINE bool igl::min_quad_with_fixed(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
+#if EIGEN_VERSION_AT_LEAST(3,3,0)
+#else
 template bool igl::min_quad_with_fixed_solve<double, Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> const>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::min_quad_with_fixed_data<double> const&, Eigen::MatrixBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> const> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 template bool igl::min_quad_with_fixed_solve<double, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::min_quad_with_fixed_data<double> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> > > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
+#endif
 template bool igl::min_quad_with_fixed<double, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::SparseMatrix<double, 0, int> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::SparseMatrix<double, 0, int> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, bool, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&);
 template bool igl::min_quad_with_fixed_solve<double, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >(igl::min_quad_with_fixed_data<double> const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::MatrixBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 1, 0, -1, 1> >&);
 template bool igl::min_quad_with_fixed_precompute<double, Eigen::Matrix<int, -1, 1, 0, -1, 1> >(Eigen::SparseMatrix<double, 0, int> const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int> const&, bool, igl::min_quad_with_fixed_data<double>&);

+ 11 - 10
include/igl/readDMAT.cpp

@@ -1,9 +1,9 @@
 // This file is part of libigl, a simple c++ geometry processing library.
-// 
+//
 // Copyright (C) 2013 Alec Jacobson <alecjacobson@gmail.com>
-// 
-// 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 
+//
+// 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/.
 #include "readDMAT.h"
 
@@ -11,6 +11,7 @@
 #include <cstdio>
 #include <iostream>
 #include <cassert>
+#include <memory>
 
 // Static helper method reads the first to elements in the given file
 // Inputs:
@@ -18,7 +19,7 @@
 // Outputs:
 //   num_rows  number of rows
 //   num_cols number of columns
-// Returns 
+// Returns
 //   0  success
 //   1  did not find header
 //   2  bad num_cols
@@ -64,7 +65,7 @@ IGL_INLINE bool igl::readDMAT(const std::string file_name,
   if(fp == NULL)
   {
     fprintf(stderr,"IOError: readDMAT() could not open %s...\n",file_name.c_str());
-    return false; 
+    return false;
   }
   int num_rows,num_cols;
   int head_success = readDMAT_read_header(fp,num_rows,num_cols);
@@ -114,8 +115,8 @@ IGL_INLINE bool igl::readDMAT(const std::string file_name,
     assert(W.size() == 0);
     // Resize for output
     W.resize(num_rows,num_cols);
-    double * Wraw = new double[num_rows*num_cols];
-    fread(Wraw, sizeof(double), num_cols*num_rows, fp);
+    std::unique_ptr<double[]> Wraw(new double[num_rows*num_cols]);
+    fread(Wraw.get(), sizeof(double), num_cols*num_rows, fp);
     // Loop over columns slowly
     for(int j = 0;j < num_cols;j++)
     {
@@ -142,14 +143,14 @@ IGL_INLINE bool igl::readDMAT(const std::string file_name,
 
 template <typename Scalar>
 IGL_INLINE bool igl::readDMAT(
-  const std::string file_name, 
+  const std::string file_name,
   std::vector<std::vector<Scalar> > & W)
 {
   FILE * fp = fopen(file_name.c_str(),"r");
   if(fp == NULL)
   {
     fprintf(stderr,"IOError: readDMAT() could not open %s...\n",file_name.c_str());
-    return false; 
+    return false;
   }
   int num_rows,num_cols;
   bool head_success = readDMAT_read_header(fp,num_rows,num_cols);

+ 3 - 0
include/igl/slice.cpp

@@ -247,8 +247,11 @@ IGL_INLINE DerivedX igl::slice(
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
+#if EIGEN_VERSION_AT_LEAST(3,3,0)
+#else
 // generated by autoexplicit.sh
 template void igl::slice<Eigen::MatrixBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> const> >, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::MatrixBase<Eigen::CwiseUnaryOp<Eigen::internal::scalar_multiple_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> const> > const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, int, Eigen::Matrix<double, -1, -1, 0, -1, -1>&);
+#endif
 // generated by autoexplicit.sh
 template void igl::slice<Eigen::Matrix<float, -1, 3, 1, -1, 3>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<float, -1, 3, 1, -1, 3> >(Eigen::DenseBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> > const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::DenseBase<Eigen::Matrix<int, -1, 1, 0, -1, 1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<float, -1, 3, 1, -1, 3> >&);
 // generated by autoexplicit.sh

+ 1 - 1
include/igl/writePLY.cpp

@@ -70,7 +70,7 @@ IGL_INLINE bool igl::writePLY(
 
   igl::ply::PlyProperty face_props[] =
   { /* list of property information for a face */
-    {"vertex_indices", ply_type<FScalar>(), ply_type<FScalar>(), 
+    {"vertex_indices", ply_type<FScalar>(), ply_type<FScalar>(),
       offsetof(Face,verts), 1, PLY_UCHAR, PLY_UCHAR, offsetof(Face,nverts)},
   };
   const bool has_normals = N.rows() > 0;

+ 6 - 2
python/modules/py_vector.cpp

@@ -641,7 +641,11 @@ void python_export_vector(py::module &m) {
     //py::implicitly_convertible<double, Eigen::MatrixXi>();
 
     /* Bindings for MatrixXb */
+    #if EIGEN_VERSION_AT_LEAST(3,3,0)
+    // Temporarily disabled with Eigen 3.3
+    #else
     bind_eigen_2<Eigen::Matrix<bool,Eigen::Dynamic,Eigen::Dynamic> > (me, "MatrixXb");
+    #endif
 
     /* Bindings for MatrixXuc */
     bind_eigen_2<Eigen::Matrix<unsigned char,Eigen::Dynamic,Eigen::Dynamic> > (me, "MatrixXuc");
@@ -723,7 +727,7 @@ void python_export_vector(py::module &m) {
     ;
     // Bindings for Quaterniond
     py::class_<Eigen::Quaterniond > quaterniond(me, "Quaterniond");
-    
+
     quaterniond
     .def(py::init<>())
     .def(py::init<double, double, double, double>())
@@ -765,7 +769,7 @@ void python_export_vector(py::module &m) {
 //    })
     ;
 
-    
+
 
 
 

+ 0 - 1
tests/include/igl/cotmatrix.cpp

@@ -1,7 +1,6 @@
 #include <test_common.h>
 #include <igl/cotmatrix.h>
 
-
 TEST_CASE("cotmatrix: constant_in_null_space", "[igl]")
 {
   const auto test_case = [](const std::string &param)

+ 2 - 2
tests/include/igl/grad.cpp

@@ -20,8 +20,8 @@ TEST_CASE("grad: laplace_grid", "[igl]")
   igl::grad(V,F,G);
   Eigen::VectorXd dblA;
   igl::doublearea(V,F,dblA);
-  Eigen::SparseMatrix<double> GTAG = 
-    G.transpose() * (dblA.replicate(3,1).asDiagonal()) * G;
+  Eigen::SparseMatrix<double> GTAG =
+    G.transpose() * (dblA.colwise().replicate(3).asDiagonal()) * G;
   test_common::assert_near(
     Eigen::MatrixXd(L),Eigen::MatrixXd(-0.5*GTAG),igl::EPS<double>());
 }

+ 2 - 2
tests/include/igl/grad_intrinsic.cpp

@@ -22,8 +22,8 @@ TEST_CASE("grad_intrinsic: laplace_grid", "[igl]")
   igl::grad_intrinsic(l,F,G);
   Eigen::VectorXd dblA;
   igl::doublearea(l,0,dblA);
-  Eigen::SparseMatrix<double> GTAG = 
-    G.transpose() * (dblA.replicate(2,1).asDiagonal()) * G;
+  Eigen::SparseMatrix<double> GTAG =
+    G.transpose() * (dblA.colwise().replicate(2).asDiagonal()) * G;
   test_common::assert_near(
     Eigen::MatrixXd(L),Eigen::MatrixXd(-0.5*GTAG),igl::EPS<double>());
 }