Browse Source

reorganize tutorial cmake, bug fix in static ver. of npoly demo

Former-commit-id: eb7d645d5e65ac05d814e2d8a5828404908ede84
Alec Jacobson 10 years ago
parent
commit
38328367b6

+ 1 - 360
include/igl/conjugate_frame_fields.cpp

@@ -5,80 +5,15 @@
 // 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 <igl/conjugate_frame_fields.h>
-#include <igl/edge_topology.h>
-#include <igl/local_basis.h>
-#include <igl/nchoosek.h>
-#include <igl/sparse.h>
 #include <igl/speye.h>
 #include <igl/slice.h>
 #include <igl/polyroots.h>
-#include <igl/colon.h>
-#include <igl/false_barycentric_subdivision.h>
-#include <igl/principal_curvature.h>
 #include <Eigen/Sparse>
 
 #include <iostream>
 
 namespace igl {
-
-  template <typename DerivedV, typename DerivedF>
-  class ConjugateFFSolverData
-  {
-    public:
-      const Eigen::PlainObjectBase<DerivedV> &V; int numV;
-      const Eigen::PlainObjectBase<DerivedF> &F; int numF;
-
-      Eigen::MatrixXi EV; int numE;
-      Eigen::MatrixXi F2E;
-      Eigen::MatrixXi E2F;
-      Eigen::VectorXd K;
-
-      Eigen::VectorXi isBorderEdge;
-      int numInteriorEdges;
-      Eigen::Matrix<int,Eigen::Dynamic,2> E2F_int;
-      Eigen::VectorXi indInteriorToFull;
-      Eigen::VectorXi indFullToInterior;
-
-      Eigen::PlainObjectBase<DerivedV> B1, B2, FN;
-
-
-      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic,1> kmin, kmax;
-      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic,2> dmin, dmax;
-      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic,3> dmin3, dmax3;
-
-      Eigen::VectorXd nonPlanarityMeasure;
-      Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > planarityWeight;
-
-      //conjugacy matrix
-      std::vector<Eigen::Matrix<typename DerivedV::Scalar, 4,4> > H;
-
-      //conjugacy matrix eigenvectors and (scaled) eigenvalues
-      std::vector<Eigen::Matrix<typename DerivedV::Scalar, 4,4> > UH;
-      std::vector<Eigen::Matrix<typename DerivedV::Scalar, 4,1> > s;
-
-      //laplacians
-      Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar>> DDA, DDB;
-
-  private:
-    IGL_INLINE void computeCurvatureAndPrincipals();
-    IGL_INLINE void precomputeConjugacyStuff();
-    IGL_INLINE void computeLaplacians();
-    IGL_INLINE void computek();
-    IGL_INLINE void computeCoefficientLaplacian(int n, Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > &D);
-
-    IGL_INLINE void precomputeInteriorEdges();
-
-public:
-    IGL_INLINE ConjugateFFSolverData(const Eigen::PlainObjectBase<DerivedV> &_V,
-                                   const Eigen::PlainObjectBase<DerivedF> &_F);
-    IGL_INLINE void evaluateConjugacy(const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvU,
-                                      const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvV,
-                                      Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> &conjValues) const ;
-
-  };
-
   template <typename DerivedV, typename DerivedF, typename DerivedO>
   class ConjugateFFSolver
   {
@@ -129,301 +64,6 @@ public:
 }
 
 //Implementation
-/***************************** Data ***********************************/
-
-template <typename DerivedV, typename DerivedF>
-IGL_INLINE igl::ConjugateFFSolverData<DerivedV, DerivedF>::
-ConjugateFFSolverData(const Eigen::PlainObjectBase<DerivedV> &_V,
-                  const Eigen::PlainObjectBase<DerivedF> &_F):
-V(_V),
-numV(_V.rows()),
-F(_F),
-numF(_F.rows())
-{
-  igl::edge_topology(V,F,EV,F2E,E2F);
-  numE = EV.rows();
-
-  precomputeInteriorEdges();
-
-  igl::local_basis(V,F,B1,B2,FN);
-
-  computek();
-
-  computeLaplacians();
-
-  computeCurvatureAndPrincipals();
-  precomputeConjugacyStuff();
-
-};
-
-
-template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::computeCurvatureAndPrincipals()
-{
-  Eigen::MatrixXd VCBary;
-  Eigen::MatrixXi FCBary;
-
-  VCBary.setZero(numV+numF,3);
-  FCBary.setZero(3*numF,3);
-  igl::false_barycentric_subdivision(V, F, VCBary, FCBary);
-
-  Eigen::MatrixXd dmax3_,dmin3_;
-  igl::principal_curvature(VCBary, FCBary, dmax3_, dmin3_, kmax, kmin, 5,true);
-
-  dmax3 = dmax3_.bottomRows(numF);
-  dmin3 = dmin3_.bottomRows(numF);
-
-  kmax = kmax.bottomRows(numF);
-  kmin = kmin.bottomRows(numF);
-
-  //  kmax = dmax3.rowwise().norm();
-  //  kmin = dmin3.rowwise().norm();
-
-  dmin3.rowwise().normalize();
-  dmax3.rowwise().normalize();
-  dmax.setZero(numF,2);
-  dmin.setZero(numF,2);
-  for (int i= 0; i <numF; ++i)
-  {
-    if(kmin[i] != kmin[i] || kmax[i] != kmax[i] || (dmin3.row(i).array() != dmin3.row(i).array()).any() || (dmax3.row(i).array() != dmax3.row(i).array()).any())
-    {
-      kmin[i] = 0;
-      kmax[i] = 0;
-      dmin3.row(i) = B1.row(i);
-      dmax3.row(i) = B2.row(i);
-    }
-    else
-    {
-      dmax3.row(i) = (dmax3.row(i) - (dmax3.row(i).dot(FN.row(i)))*FN.row(i)).normalized();
-      dmin3.row(i) = dmin3.row(i) - (dmin3.row(i).dot(FN.row(i)))*FN.row(i);
-      dmin3.row(i) = (dmin3.row(i) - (dmin3.row(i).dot(dmax3.row(i)))*dmax3.row(i)).normalized();
-      if ((dmin3.row(i).cross(dmax3.row(i))).dot(FN.row(i))<0)
-        dmin3.row(i) = -dmin3.row(i);
-    }
-    dmax.row(i) << dmax3.row(i).dot(B1.row(i)), dmax3.row(i).dot(B2.row(i));
-    dmax.row(i).normalize();
-    dmin.row(i) << dmin3.row(i).dot(B1.row(i)), dmin3.row(i).dot(B2.row(i));
-    dmin.row(i).normalize();
-
-  }
-
-  nonPlanarityMeasure = kmax.cwiseAbs().array()*kmin.cwiseAbs().array();
-  typename DerivedV::Scalar minP = nonPlanarityMeasure.minCoeff();
-  typename DerivedV::Scalar maxP = nonPlanarityMeasure.maxCoeff();
-  nonPlanarityMeasure = (nonPlanarityMeasure.array()-minP)/(maxP-minP);
-  Eigen::VectorXi I = igl::colon<typename DerivedF::Scalar>(0, numF-1);
-  igl::sparse(I, I, nonPlanarityMeasure, numF, numF, planarityWeight);
-
-}
-
-template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::precomputeConjugacyStuff()
-{
-  H.resize(numF);
-  UH.resize(numF);
-  s.resize(numF);
-
-  for (int i = 0; i<numF; ++i)
-  {
-    //compute conjugacy matrix
-    typename DerivedV::Scalar e1x = dmin(i,0), e1y = dmin(i,1), e2x = dmax(i,0), e2y = dmax(i,1), k1 = kmin[i], k2 = kmax[i];
-
-    H[i]<<
-    0,          0, k1*e1x*e1x, k1*e1x*e1y,
-    0,          0, k1*e1x*e1y, k1*e1y*e1y,
-    k2*e2x*e2x, k2*e2x*e2y,          0,          0,
-    k2*e2x*e2y, k2*e2y*e2y,          0,          0;
-    Eigen::Matrix<typename DerivedV::Scalar, 4, 4> Ht = H[i].transpose();
-    H[i] = .5*(H[i]+Ht);
-
-    Eigen::EigenSolver<Eigen::Matrix<typename DerivedV::Scalar, 4, 4> > es(H[i]);
-    s[i] = es.eigenvalues().real();//ok to do this because H symmetric
-    //scale
-    s[i] = s[i]/(s[i].cwiseAbs().minCoeff());
-    UH[i] = es.eigenvectors().real();
-
-
-  }
-}
-
-
-template <typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::computeLaplacians()
-{
-  computeCoefficientLaplacian(2, DDA);
-
-  computeCoefficientLaplacian(4, DDB);
-}
-
-template<typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
-precomputeInteriorEdges()
-{
-  // Flag border edges
-  numInteriorEdges = 0;
-  isBorderEdge.setZero(numE,1);
-  indFullToInterior = -1.*Eigen::VectorXi::Ones(numE,1);
-
-  for(unsigned i=0; i<numE; ++i)
-  {
-    if ((E2F(i,0) == -1) || ((E2F(i,1) == -1)))
-      isBorderEdge[i] = 1;
-    else
-    {
-      indFullToInterior[i] = numInteriorEdges;
-      numInteriorEdges++;
-    }
-  }
-
-  E2F_int.resize(numInteriorEdges, 2);
-  indInteriorToFull.setZero(numInteriorEdges,1);
-  int ii = 0;
-  for (int k=0; k<numE; ++k)
-  {
-    if (isBorderEdge[k])
-      continue;
-    E2F_int.row(ii) = E2F.row(k);
-    indInteriorToFull[ii] = k;
-    ii++;
-  }
-
-}
-
-
-
-template<typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
-computeCoefficientLaplacian(int n, Eigen::SparseMatrix<std::complex<typename DerivedV::Scalar> > &D)
-{
-  std::vector<Eigen::Triplet<std::complex<typename DerivedV::Scalar> >> tripletList;
-
-  // For every non-border edge
-  for (unsigned eid=0; eid<numE; ++eid)
-  {
-    if (!isBorderEdge[eid])
-    {
-      int fid0 = E2F(eid,0);
-      int fid1 = E2F(eid,1);
-
-      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid0,
-                                                                                     fid0,
-                                                                                     std::complex<typename DerivedV::Scalar>(1.)));
-      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid1,
-                                                                                     fid1,
-                                                                                     std::complex<typename DerivedV::Scalar>(1.)));
-      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid0,
-                                                                                     fid1,
-                                                                                     -1.*std::polar(1.,-1.*n*K[eid])));
-      tripletList.push_back(Eigen::Triplet<std::complex<typename DerivedV::Scalar> >(fid1,
-                                                                                     fid0,
-                                                                                     -1.*std::polar(1.,1.*n*K[eid])));
-
-    }
-  }
-  D.resize(numF,numF);
-  D.setFromTriplets(tripletList.begin(), tripletList.end());
-
-
-}
-
-template<typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
-computek()
-{
-  K.setZero(numE);
-  // For every non-border edge
-  for (unsigned eid=0; eid<numE; ++eid)
-  {
-    if (!isBorderEdge[eid])
-    {
-      int fid0 = E2F(eid,0);
-      int fid1 = E2F(eid,1);
-
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> N0 = FN.row(fid0);
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> N1 = FN.row(fid1);
-
-      // find common edge on triangle 0 and 1
-      int fid0_vc = -1;
-      int fid1_vc = -1;
-      for (unsigned i=0;i<3;++i)
-      {
-        if (F2E(fid0,i) == eid)
-          fid0_vc = i;
-        if (F2E(fid1,i) == eid)
-          fid1_vc = i;
-      }
-      assert(fid0_vc != -1);
-      assert(fid1_vc != -1);
-
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> common_edge = V.row(F(fid0,(fid0_vc+1)%3)) - V.row(F(fid0,fid0_vc));
-      common_edge.normalize();
-
-      // Map the two triangles in a new space where the common edge is the x axis and the N0 the z axis
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> P;
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> o = V.row(F(fid0,fid0_vc));
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> tmp = -N0.cross(common_edge);
-      P << common_edge, tmp, N0;
-      //      P.transposeInPlace();
-
-
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> V0;
-      V0.row(0) = V.row(F(fid0,0)) -o;
-      V0.row(1) = V.row(F(fid0,1)) -o;
-      V0.row(2) = V.row(F(fid0,2)) -o;
-
-      V0 = (P*V0.transpose()).transpose();
-
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> V1;
-      V1.row(0) = V.row(F(fid1,0)) -o;
-      V1.row(1) = V.row(F(fid1,1)) -o;
-      V1.row(2) = V.row(F(fid1,2)) -o;
-      V1 = (P*V1.transpose()).transpose();
-
-      // compute rotation R such that R * N1 = N0
-      // i.e. map both triangles to the same plane
-      double alpha = -atan2(V1((fid1_vc+2)%3,2),V1((fid1_vc+2)%3,1));
-
-      Eigen::Matrix<typename DerivedV::Scalar, 3, 3> R;
-      R << 1,          0,            0,
-      0, cos(alpha), -sin(alpha) ,
-      0, sin(alpha),  cos(alpha);
-      V1 = (R*V1.transpose()).transpose();
-
-      // measure the angle between the reference frames
-      // k_ij is the angle between the triangle on the left and the one on the right
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> ref0 = V0.row(1) - V0.row(0);
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 3> ref1 = V1.row(1) - V1.row(0);
-
-      ref0.normalize();
-      ref1.normalize();
-
-      double ktemp = atan2(ref1(1),ref1(0)) - atan2(ref0(1),ref0(0));
-
-      // just to be sure, rotate ref0 using angle ktemp...
-      Eigen::Matrix<typename DerivedV::Scalar, 2, 2> R2;
-      R2 << cos(ktemp), -sin(ktemp), sin(ktemp), cos(ktemp);
-
-      Eigen::Matrix<typename DerivedV::Scalar, 1, 2> tmp1 = R2*(ref0.head(2)).transpose();
-
-      K[eid] = ktemp;
-    }
-  }
-
-}
-
-template<typename DerivedV, typename DerivedF>
-IGL_INLINE void igl::ConjugateFFSolverData<DerivedV, DerivedF>::
-evaluateConjugacy(const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvU,
-                   const Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 2> &pvV,
-                  Eigen::Matrix<typename DerivedV::Scalar, Eigen::Dynamic, 1> &conjValues) const 
-{
-  conjValues.resize(numF,1);
-  for (int j =0; j<numF; ++j)
-  {
-    Eigen::Matrix<typename DerivedV::Scalar, 4, 1> x; x<<pvU.row(j).transpose(), pvV.row(j).transpose();
-    conjValues[j] = x.transpose()*H[j]*x;
-  }
-}
 /***************************** Solver ***********************************/
 template <typename DerivedV, typename DerivedF, typename DerivedO>
 IGL_INLINE igl::ConjugateFFSolver<DerivedV, DerivedF, DerivedO>::
@@ -794,4 +434,5 @@ IGL_INLINE void igl::conjugate_frame_fields(const igl::ConjugateFFSolverData<Der
 
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
+template void igl::conjugate_frame_fields<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::Matrix<double, -1, -1, 0, -1, -1> >(igl::ConjugateFFSolverData<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, int, Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar const&, Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar const&, bool, Eigen::Matrix<double, -1, -1, 0, -1, -1>::Scalar*);
 #endif

+ 1 - 1
include/igl/conjugate_frame_fields.h

@@ -9,7 +9,7 @@
 #ifndef IGL_CONJUGATE_FRAME_FIELDS
 #define IGL_CONJUGATE_FRAME_FIELDS
 #include "igl_inline.h"
-
+#include "ConjugateFFSolverData.h"
 #include <Eigen/Core>
 #include <vector>
 

+ 1 - 0
include/igl/false_barycentric_subdivision.cpp

@@ -55,4 +55,5 @@ IGL_INLINE void igl::false_barycentric_subdivision(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 template void igl::false_barycentric_subdivision<Eigen::Matrix<double, -1, 3, 0, -1, 3>, Eigen::Matrix<int, -1, 3, 0, -1, 3> >(Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, 3, 0, -1, 3> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, 3, 0, -1, 3> >&);
+template void igl::false_barycentric_subdivision<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> > const&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::PlainObjectBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&, Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >&);
 #endif

+ 1 - 0
include/igl/polyroots.cpp

@@ -34,4 +34,5 @@ IGL_INLINE void igl::polyRoots(Eigen::Matrix<S, Eigen::Dynamic,1> &polyCoeff, //
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template specialization
 template void igl::polyRoots<std::complex<double>, double>(Eigen::Matrix<std::complex<double>, -1, 1, 0, -1, 1>&, Eigen::Matrix<std::complex<double>, -1, 1, 0, -1, 1>&);
+template void igl::polyRoots<double, double>(Eigen::Matrix<double, -1, 1, 0, -1, 1>&, Eigen::Matrix<std::complex<double>, -1, 1, 0, -1, 1>&);
 #endif

+ 1 - 0
include/igl/sparse.cpp

@@ -110,4 +110,5 @@ template Eigen::SparseMatrix<Eigen::Matrix<double, -1, 1, 0, -1, 1>::Scalar, 0,
 template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, unsigned long, unsigned long, Eigen::SparseMatrix<double, 0, int>&);
 template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> >, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<double>, Eigen::Matrix<double, -1, 1, 0, -1, 1> > const&, Eigen::SparseMatrix<double, 0, int>&);
 template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, double>(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::Matrix<double, -1, 1, 0, -1, 1>, std::complex<double> >(Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<int, -1, 1, 0, -1, 1> const&, Eigen::Matrix<double, -1, 1, 0, -1, 1> const&, unsigned long, unsigned long, Eigen::SparseMatrix<std::complex<double>, 0, int>&);
 #endif

+ 1 - 0
include/igl/speye.cpp

@@ -31,4 +31,5 @@ IGL_INLINE void igl::speye(const int n, Eigen::SparseMatrix<T> & I)
 // Explicit template specialization
 // generated by autoexplicit.sh
 template void igl::speye<double>(int, Eigen::SparseMatrix<double, 0, int>&);
+template void igl::speye<std::complex<double> >(int, int, Eigen::SparseMatrix<std::complex<double>, 0, int>&);
 #endif

+ 5 - 8
tutorial/403_BoundedBiharmonicWeights/CMakeLists.txt

@@ -3,18 +3,16 @@ project(403_BoundedBiharmonicWeights)
 
 include("../CMakeLists.shared")
 
-#find_package(EMBREE REQUIRED)
-#include_directories(${EMBREE_INCLUDE_DIRS})
-
-if(NOT MOSEK_FOUND)
+find_package(MOSEK QUIET)
+if(MOSEK_FOUND)
+  include_directories( ${MOSEK_INCLUDE_DIR} )
+else(MOSEK_FOUND)
   add_definitions(-DIGL_NO_MOSEK)
   if(LIBIGL_USE_STATIC_LIBRARY)
     set(LIBIGLMOSEK_LIBRARY "")
   endif(LIBIGL_USE_STATIC_LIBRARY)
   set(MOSEK_LIBRARIES "")
-else(NOT MOSEK_FOUND)
-  include_directories( ${MOSEK_INCLUDE_DIR} )
-endif(NOT MOSEK_FOUND)
+endif(MOSEK_FOUND)
 
 set(SOURCES
 ${PROJECT_SOURCE_DIR}/main.cpp
@@ -22,4 +20,3 @@ ${PROJECT_SOURCE_DIR}/main.cpp
 
 add_executable(${PROJECT_NAME}_bin ${SOURCES} ${SHARED_SOURCES})
 target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES} ${MOSEK_LIBRARIES})
-#target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES} ${MOSEK_LIBRARIES} ${EMBREE_LIBRARIES})

+ 1 - 1
tutorial/507_PolyVectorField/CMakeLists.txt

@@ -8,4 +8,4 @@ ${PROJECT_SOURCE_DIR}/main.cpp
 )
 
 add_executable(${PROJECT_NAME}_bin ${SOURCES} ${SHARED_SOURCES})
-target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES} ${LIBCOMISO_LIBRARY})
+target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES})

+ 1 - 1
tutorial/508_ConjugateField/CMakeLists.txt

@@ -8,4 +8,4 @@ ${PROJECT_SOURCE_DIR}/main.cpp
 )
 
 add_executable(${PROJECT_NAME}_bin ${SOURCES} ${SHARED_SOURCES})
-target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES} ${LIBCOMISO_LIBRARY})
+target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES})

+ 1 - 0
tutorial/508_ConjugateField/main.cpp

@@ -1,6 +1,7 @@
 #include <igl/avg_edge_length.h>
 #include <igl/barycenter.h>
 #include <igl/conjugate_frame_fields.h>
+#include <igl/ConjugateFFSolverData.h>
 #include <igl/dot_row.h>
 #include <igl/jet.h>
 #include <igl/local_basis.h>

+ 0 - 1
tutorial/601_Serialization/CMakeLists.txt

@@ -4,7 +4,6 @@ project(601_Serialization)
 include("../CMakeLists.shared")
 
 find_package(TINYXML2 REQUIRED)
-
 include_directories( ${TINYXML2_INCLUDE_DIR})
 
 set(SOURCES

+ 1 - 1
tutorial/701_Statistics/CMakeLists.txt

@@ -8,4 +8,4 @@ ${PROJECT_SOURCE_DIR}/main.cpp
 )
 
 add_executable(${PROJECT_NAME}_bin ${SOURCES} ${SHARED_SOURCES})
-target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES} ${CGAL_LIBRARIES})
+target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES})

+ 18 - 20
tutorial/CMakeLists.txt

@@ -4,18 +4,15 @@ project(libigl_tutorials)
 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ../)
 SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
 
-## Check for CoMiSo, if not available skip the examples that depends on it
+find_package(CORK QUIET)
+find_package(CGAL QUIET)
+find_package(EMBREE QUIET)
 find_package(LIBCOMISO QUIET)
-
-## Check for MATLAB, if not available skip the examples that depends on it
 find_package(MATLAB QUIET)
-
-## Check for EMBREE, if not available skip the examples that depends on it
-find_package(EMBREE QUIET)
-find_package(CGAL QUIET)
-
-## Check for mosek
 find_package(MOSEK QUIET)
+find_package(TETGEN QUIET)
+find_package(TINYXML2 QUIET)
+find_package(TRIANGLE QUIET)
 
 message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
 include("CMakeLists.shared")
@@ -53,32 +50,33 @@ add_subdirectory("406_FastAutomaticSkinningTransformations")
 add_subdirectory("501_HarmonicParam")
 add_subdirectory("502_LSCMParam")
 add_subdirectory("503_ARAPParam")
-
 if(LIBCOMISO_FOUND)
-add_subdirectory("504_NRosyDesign")
-add_subdirectory("505_MIQ")
-add_subdirectory("506_FrameField")
+  add_subdirectory("504_NRosyDesign")
+  add_subdirectory("505_MIQ")
+  add_subdirectory("506_FrameField")
+endif(LIBCOMISO_FOUND)
 add_subdirectory("507_PolyVectorField")
 add_subdirectory("508_ConjugateField")
-endif(LIBCOMISO_FOUND)
 add_subdirectory("509_Planarization")
 
 # Chapter 6
-add_subdirectory("601_Serialization")
+if(TINYXML2_FOUND)
+  add_subdirectory("601_Serialization")
+endif(TINYXML2_FOUND)
 if(MATLAB_FOUND)
-add_subdirectory("602_Matlab")
+  add_subdirectory("602_Matlab")
 endif(MATLAB_FOUND)
 add_subdirectory("604_Triangle")
 add_subdirectory("605_Tetgen")
 if(EMBREE_FOUND)
-add_subdirectory("606_AmbientOcclusion")
-add_subdirectory("607_Picking")
+  add_subdirectory("606_AmbientOcclusion")
+  add_subdirectory("607_Picking")
 endif(EMBREE_FOUND)
 if(LIM_FOUND)
-add_subdirectory("608_LIM")
+  add_subdirectory("608_LIM")
 endif(LIM_FOUND)
 if(CGAL_FOUND)
-add_subdirectory("609_Boolean")
+  add_subdirectory("609_Boolean")
 endif()
 add_subdirectory("701_Statistics")
 add_subdirectory("702_WindingNumber")

+ 100 - 86
tutorial/cmake/FindLIBIGL.cmake

@@ -47,99 +47,128 @@ if(LIBIGL_USE_STATIC_LIBRARY)
    /usr/lib
    /usr/local/lib)
   FIND_LIBRARY( LIBIGL_LIBRARY NAMES igl PATHS ${LIBIGL_LIB_DIRS})
+
+  # try to find pre-requisites
+  find_package(CORK QUIET)
+  find_package(CGAL QUIET)
+  find_package(EMBREE QUIET)
+  find_package(LIBCOMISO QUIET)
+  find_package(MATLAB QUIET)
+  find_package(MOSEK QUIET)
+  find_package(TETGEN QUIET)
+  find_package(TINYXML2 QUIET)
+  find_package(TRIANGLE QUIET)
+
+  # Main library must be found
   if(NOT LIBIGL_LIBRARY)
     set(LIBIGL_FOUND FALSE)
     message(FATAL_ERROR "could NOT find libigl")
   endif(NOT LIBIGL_LIBRARY)
   set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGL_LIBRARY})
 
+  # libiglbbw will work with/without mosek
   FIND_LIBRARY( LIBIGLBBW_LIBRARY NAMES iglbbw PATHS ${LIBIGL_LIB_DIRS})
   if(NOT LIBIGLBBW_LIBRARY)
     set(LIBIGL_FOUND FALSE)
     message(FATAL_ERROR "could NOT find libiglbbw")
   endif(NOT LIBIGLBBW_LIBRARY)
   set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLBBW_LIBRARY})
-  # WARNING: PLEASE FIND A BETTER WAY OF DEALING WITH MOSEK THAN COMMENTING OUT
-  # THIS ENTIRE SECTION... OR AT LEAST DEFINE IGL_NO_MOSEK...
-  FIND_LIBRARY( LIBIGLMOSEK_LIBRARY NAMES iglmosek PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLMOSEK_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libiglmosek")
-  endif(NOT LIBIGLMOSEK_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLMOSEK_LIBRARY})
-  if(MOSEK_FOUND)
-    set(LIBIGL_INCLUDE_DIRS ${LIBIGL_INCLUDE_DIRS}  ${MOSEK_INCLUDE_DIR})
-    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${MOSEK_LIBRARIES})
-  else(MOSEK_FOUND)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find mosek")
-  endif(MOSEK_FOUND)
 
-  FIND_LIBRARY( LIBIGLCGAL_LIBRARY NAMES iglcgal PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLCGAL_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libiglcgal")
-  endif(NOT LIBIGLCGAL_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLCGAL_LIBRARY})
-
-  FIND_LIBRARY( LIBIGLBOOLEAN_LIBRARY NAMES iglboolean PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLBOOLEAN_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libiglboolean ")
-  endif(NOT LIBIGLBOOLEAN_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLBOOLEAN_LIBRARY})
+  if(LIBCOMISO_FOUND)
+    FIND_LIBRARY(LIBIGLCOMISO_LIBRARY NAMES iglcomiso PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLCOMISO_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libiglcomiso")
+    endif(NOT LIBIGLCOMISO_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLCOMISO_LIBRARY})
+  endif(LIBCOMISO_FOUND)
+
+  if(CGAL_FOUND)
+    FIND_LIBRARY( LIBIGLBOOLEAN_LIBRARY NAMES iglboolean PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLBOOLEAN_LIBRARY)
+      message(FATAL_ERROR "could NOT find libiglboolean ")
+    endif(NOT LIBIGLBOOLEAN_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLBOOLEAN_LIBRARY})
+
+    FIND_LIBRARY( LIBIGLCGAL_LIBRARY NAMES iglcgal PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLCGAL_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libiglcgal")
+    endif(NOT LIBIGLCGAL_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLCGAL_LIBRARY})
+  endif(CGAL_FOUND)
+
+  if(EMBREE_FOUND)
+    FIND_LIBRARY( LIBIGLEMBREE_LIBRARY NAMES iglembree PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLEMBREE_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libiglembree")
+    endif(NOT LIBIGLEMBREE_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLEMBREE_LIBRARY})
+  endif(EMBREE_FOUND)
+
+  if(LIM_FOUND)
+    FIND_LIBRARY( LIBIGLLIM_LIBRARY NAMES igllim PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLLIM_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libigllim")
+    endif(NOT LIBIGLLIM_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLLIM_LIBRARY})
+  endif(LIM_FOUND)
 
-  FIND_LIBRARY( LIBIGLEMBREE_LIBRARY NAMES iglembree PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLEMBREE_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libiglembree")
-  endif(NOT LIBIGLEMBREE_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLEMBREE_LIBRARY})
-  find_package(Embree REQUIRED)
-
-  FIND_LIBRARY( LIBIGLLIM_LIBRARY NAMES igllim PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLLIM_LIBRARY)
-    #set(LIBIGL_FOUND FALSE)
-    message(WARNING "could NOT find libigllim")
-    set(LIBIGLLIM_LIBRARY "")
-  endif(NOT LIBIGLLIM_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLLIM_LIBRARY})
-
-  FIND_LIBRARY( LIBIGLMATLAB_LIBRARY NAMES iglmatlab PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLMATLAB_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libiglmatlab")
-  endif(NOT LIBIGLMATLAB_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLMATLAB_LIBRARY})
-  find_package(Matlab REQUIRED)
   if(MATLAB_FOUND)
-    set(LIBIGL_INCLUDE_DIRS ${LIBIGL_INCLUDE_DIRS}  ${MATLAB_INCLUDE_DIR})
-    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${MATLAB_LIBRARIES})
-  else(MATLAB_FOUND)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find matlab")
+    FIND_LIBRARY( LIBIGLMATLAB_LIBRARY NAMES iglmatlab PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLMATLAB_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libiglmatlab")
+    endif(NOT LIBIGLMATLAB_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLMATLAB_LIBRARY})
   endif(MATLAB_FOUND)
 
-  FIND_LIBRARY( LIBIGLTETGEN_LIBRARY NAMES igltetgen PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLTETGEN_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libigltetgen")
-  endif(NOT LIBIGLTETGEN_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLTETGEN_LIBRARY})
-
-  FIND_LIBRARY( LIBIGLTRIANGLE_LIBRARY NAMES igltriangle PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLTRIANGLE_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libigltriangle")
-  endif(NOT LIBIGLTRIANGLE_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLTRIANGLE_LIBRARY})
+  # mosek support should be determined before trying to find bbw
+  if(MOSEK_FOUND)
+    FIND_LIBRARY( LIBIGLMOSEK_LIBRARY NAMES iglmosek PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLMOSEK_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libiglmosek")
+    endif(NOT LIBIGLMOSEK_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLMOSEK_LIBRARY})
+  endif(MOSEK_FOUND)
 
+  if(TETGEN_FOUND)
+    FIND_LIBRARY( LIBIGLTETGEN_LIBRARY NAMES igltetgen PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLTETGEN_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libigltetgen")
+    endif(NOT LIBIGLTETGEN_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLTETGEN_LIBRARY})
+  endif(TETGEN_FOUND)
+
+  if(TINYXML2_FOUND)
+    FIND_LIBRARY( LIBIGLXML_LIBRARY NAMES iglxml PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLXML_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libiglxml")
+    endif(NOT LIBIGLXML_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLXML_LIBRARY})
+  endif(TINYXML2_FOUND)
+
+  if(TRIANGLE_FOUND)
+    FIND_LIBRARY( LIBIGLTRIANGLE_LIBRARY NAMES igltriangle PATHS ${LIBIGL_LIB_DIRS})
+    if(NOT LIBIGLTRIANGLE_LIBRARY)
+      set(LIBIGL_FOUND FALSE)
+      message(FATAL_ERROR "could NOT find libigltriangle")
+    endif(NOT LIBIGLTRIANGLE_LIBRARY)
+    set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLTRIANGLE_LIBRARY})
+  endif(TRIANGLE_FOUND)
+
+  # libiglviewer is required
   FIND_LIBRARY( LIBIGLVIEWER_LIBRARY NAMES iglviewer PATHS ${LIBIGL_LIB_DIRS})
   if(NOT LIBIGLVIEWER_LIBRARY)
     set(LIBIGL_FOUND FALSE)
-      message(FATAL_ERROR "could NOT find libiglviewer")
+    message(FATAL_ERROR "could NOT find libiglviewer")
   endif(NOT LIBIGLVIEWER_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLVIEWER_LIBRARY})
+  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES} ${LIBIGLVIEWER_LIBRARY})
 
   find_package(OpenMP)
   if (OPENMP_FOUND)
@@ -147,21 +176,6 @@ if(LIBIGL_USE_STATIC_LIBRARY)
     set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
   endif(OPENMP_FOUND)
 
-  FIND_LIBRARY( LIBIGLXML_LIBRARY NAMES iglxml PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLXML_LIBRARY)
-    set(LIBIGL_FOUND FALSE)
-    message(FATAL_ERROR "could NOT find libiglxml")
-  endif(NOT LIBIGLXML_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLXML_LIBRARY})
-
-  FIND_LIBRARY( LIBIGLCOMISO_LIBRARY NAMES iglcomiso PATHS ${LIBIGL_LIB_DIRS})
-  if(NOT LIBIGLCOMISO_LIBRARY)
-    #set(LIBIGL_FOUND FALSE)
-    set(LIBIGLCOMISO_LIBRARY "")
-    message(WARNING "could NOT find libiglcomiso")
-  endif(NOT LIBIGLCOMISO_LIBRARY)
-  set(LIBIGL_LIBRARIES ${LIBIGL_LIBRARIES}  ${LIBIGLCOMISO_LIBRARY})
-
 
 endif(LIBIGL_USE_STATIC_LIBRARY)