Ver código fonte

merge

Former-commit-id: e3c02aceb7ea0b47b4cbd8b79fd007101f118fcd
Alec Jacobson 8 anos atrás
pai
commit
0434de7e9b

+ 2 - 2
README.md

@@ -1,6 +1,6 @@
 # libigl - A simple C++ geometry processing library
 [![Build Status](https://travis-ci.org/libigl/libigl.svg?branch=master)](https://travis-ci.org/libigl/libigl)
-[![Build status](https://ci.appveyor.com/api/projects/status/mf3t9rnhco0vhly8?svg=true)](https://ci.appveyor.com/project/danielepanozzo/libigl-6hjk1)
+[![Build status](https://ci.appveyor.com/api/projects/status/mf3t9rnhco0vhly8/branch/master?svg=true)](https://ci.appveyor.com/project/danielepanozzo/libigl-6hjk1/branch/master)
 ![](libigl-teaser.png)
 
 <https://github.com/libigl/libigl/>
@@ -241,7 +241,7 @@ few labs/companies/institutions using libigl:
 
 Libigl is a group endeavor led by [Alec
 Jacobson](http://www.cs.toronto.edu/~jacobson/) and [Daniele
-Panozzo](http://www.inf.ethz.ch/personal/dpanozzo/). Please [contact
+Panozzo](http://cs.nyu.edu/~panozzo/). Please [contact
 us](mailto:alecjacobson@gmail.com,daniele.panozzo@gmail.com) if you have
 questions or comments. For troubleshooting, please post an
 [issue](https://github.com/libigl/libigl/issues) on github.

+ 4 - 12
include/igl/AABB.cpp

@@ -148,22 +148,14 @@ IGL_INLINE void igl::AABB<DerivedV,DIM>::init(
         {
           SIdI(i) = SI(I(i),max_d);
         }
-        // Since later I use <= I think I don't need to worry about odd/even
         // Pass by copy to avoid changing input
-        const auto median = [](VectorXi A)->Scalar
+        const auto median = [](VectorXi A)->int
         {
-          size_t n = A.size()/2;
+          size_t n = (A.size()-1)/2;
           nth_element(A.data(),A.data()+n,A.data()+A.size());
-          if(A.rows() % 2 == 1)
-          {
-            return A(n);
-          }else
-          {
-            nth_element(A.data(),A.data()+n-1,A.data()+A.size());
-            return 0.5*(A(n)+A(n-1));
-          }
+          return A(n);
         };
-        const Scalar med = median(SIdI);
+        const int med = median(SIdI);
         VectorXi LI((I.rows()+1)/2),RI(I.rows()/2);
         assert(LI.rows()+RI.rows() == I.rows());
         // Distribute left and right

+ 2 - 2
include/igl/embree/EmbreeIntersector.h

@@ -228,8 +228,8 @@ inline igl::embree::EmbreeIntersector::EmbreeIntersector()
   :
   //scene(NULL),
   geomID(0),
-  triangles(NULL),
   vertices(NULL),
+  triangles(NULL),
   initialized(false)
 {
 }
@@ -239,8 +239,8 @@ inline igl::embree::EmbreeIntersector::EmbreeIntersector(
   :// To make -Weffc++ happy
   //scene(NULL),
   geomID(0),
-  triangles(NULL),
   vertices(NULL),
+  triangles(NULL),
   initialized(false)
 {
   assert(false && "Embree: Copying EmbreeIntersector is not allowed");

+ 29 - 27
include/igl/flip_avoiding_line_search.cpp

@@ -63,46 +63,48 @@ namespace igl
     IGL_INLINE double get_smallest_pos_quad_zero(double a,double b, double c)
     {
       using namespace std;
-      double t1,t2;
-      if (std::abs(a)>1.0e-10)
+      double t1, t2;
+      if(std::abs(a) > 1.0e-10)
       {
-        double delta_in = pow(b,2) - 4*a*c;
-        if (delta_in < 0)
+        double delta_in = pow(b, 2) - 4 * a * c;
+        if(delta_in <= 0)
         {
           return INFINITY;
         }
-        double delta = sqrt(delta_in);
-        t1 = (-b + delta)/ (2*a);
-        t2 = (-b - delta)/ (2*a);
-      }
-      else
-      {
-        t1 = t2 = -b/c;
-      }
-      assert (std::isfinite(t1));
-      assert (std::isfinite(t2));
 
-      double tmp_n = std::min(t1,t2);
-      t1 = std::max(t1,t2); t2 = tmp_n;
-      if (t1 == t2)
-      {
-        return INFINITY; // means the orientation flips twice = doesn't flip
-      }
-      // return the smallest negative root if it exists, otherwise return infinity
-      if (t1 > 0)
-      {
-        if (t2 > 0)
+        double delta = sqrt(delta_in); // delta >= 0
+        if(b >= 0) // avoid subtracting two similar numbers
         {
-          return t2;
+          double bd = - b - delta;
+          t1 = 2 * c / bd;
+          t2 = bd / (2 * a);
         }
         else
         {
-          return t1;
+          double bd = - b + delta;
+          t1 = bd / (2 * a);
+          t2 = (2 * c) / bd;
+        }
+
+        assert (std::isfinite(t1));
+        assert (std::isfinite(t2));
+
+        if(a < 0) std::swap(t1, t2); // make t1 > t2
+        // return the smaller positive root if it exists, otherwise return infinity
+        if(t1 > 0)
+        {
+          return t2 > 0 ? t2 : t1;
+        }
+        else
+        {
+          return INFINITY;
         }
       }
       else
       {
-        return INFINITY;
+        if(b == 0) return INFINITY; // just to avoid divide-by-zero
+        t1 = -c / b;
+        return t1 > 0 ? t1 : INFINITY;
       }
     }
 

+ 1 - 1
include/igl/grad.cpp

@@ -149,7 +149,7 @@ IGL_INLINE void grad_tri(const Eigen::PlainObjectBase<DerivedV>&V,
       // get h (by the area of the triangle)
       double h = sqrt( (dblA)/sin(M_PI / 3.0)); // (h^2*sin(60))/2. = Area => h = sqrt(2*Area/sin_60)
 
-      Eigen::VectorXd v1,v2,v3;
+      Eigen::Vector3d v1,v2,v3;
       v1 << 0,0,0;
       v2 << h,0,0;
       v3 << h/2.,(sqrt(3)/2.)*h,0;

+ 3 - 1
include/igl/opengl/State.cpp

@@ -176,7 +176,9 @@ IGL_INLINE void igl::opengl::State::set_data(
         V_uv_vbo.resize(data.F.rows()*3,2);
         for (unsigned i=0; i<data.F.rows();++i)
           for (unsigned j=0;j<3;++j)
-            V_uv_vbo.row(i*3+j) = data.V_uv.row(data.F(i,j)).cast<float>();
+            V_uv_vbo.row(i*3+j) = 
+              data.V_uv.row(per_corner_uv ? 
+                data.F_uv(i,j) : data.F(i,j)).cast<float>();
       }
     }
   }

+ 1 - 0
include/igl/opengl/ViewerCore.h

@@ -8,6 +8,7 @@
 #ifndef IGL_VIEWER_VIEWER_CORE_H
 #define IGL_VIEWER_VIEWER_CORE_H
 
+#include <igl/viewer/OpenGL_state.h>
 #ifdef IGL_VIEWER_WITH_NANOGUI
 #include <igl/viewer/TextRenderer.h>
 #endif

+ 1 - 1
include/igl/opengl/glfw/Viewer.cpp

@@ -206,7 +206,7 @@ namespace glfw
     ngui->setFixedSize(Eigen::Vector2i(60,20));
 
     // Create nanogui widgets
-    nanogui::Window *window = ngui->addWindow(Eigen::Vector2i(10,10),"libIGL-Viewer");
+    /* nanogui::Window *window = */ ngui->addWindow(Eigen::Vector2i(10,10),"libIGL-Viewer");
 
     // ---------------------- LOADING ----------------------
 

+ 1 - 1
include/igl/opengl/glfw/Viewer.h

@@ -35,7 +35,7 @@
 namespace nanogui { class FormHelper; class Screen; }
 #endif
 
-class GLFWwindow;
+struct GLFWwindow;
 
 namespace igl
 {

+ 9 - 8
include/igl/sparse.cpp

@@ -24,9 +24,9 @@ IGL_INLINE void igl::sparse(
 
 #include "verbose.h"
 template <
-  class IndexVectorI, 
-  class IndexVectorJ, 
-  class ValueVector, 
+  class IndexVectorI,
+  class IndexVectorJ,
+  class ValueVector,
   typename T>
 IGL_INLINE void igl::sparse(
   const IndexVectorI & I,
@@ -108,15 +108,16 @@ IGL_INLINE Eigen::SparseMatrix<typename DerivedD::Scalar > igl::sparse(
 #ifdef IGL_STATIC_LIBRARY
 // Explicit template instantiation
 // generated by autoexplicit.sh
+#ifndef WIN32
 template void igl::sparse<Eigen::PlainObjectBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >, Eigen::Matrix<int, -1, -1, 0, -1, -1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<bool>, Eigen::Array<bool, -1, 2, 0, -1, 2> >, bool>(Eigen::PlainObjectBase<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<bool>, Eigen::Array<bool, -1, 2, 0, -1, 2> > const&, unsigned long, unsigned long, Eigen::SparseMatrix<bool, 0, int>&);
-// generated by autoexplicit.sh
-// generated by autoexplicit.sh
 template void igl::sparse<Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> >, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<bool>, Eigen::Array<bool, -1, 3, 0, -1, 3> >, bool>(Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::MatrixBase<Eigen::Matrix<int, -1, -1, 0, -1, -1> > const&, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<bool>, Eigen::Array<bool, -1, 3, 0, -1, 3> > const&, unsigned long, unsigned long, Eigen::SparseMatrix<bool, 0, int>&);
-template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, 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&, size_t, size_t, Eigen::SparseMatrix<std::complex<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<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&, size_t, size_t, Eigen::SparseMatrix<double, 0, int>&);
 #if EIGEN_VERSION_AT_LEAST(3,3,0)
 #else
 template void igl::sparse<Eigen::CwiseNullaryOp<Eigen::internal::linspaced_op<int, true>, Eigen::Matrix<int, -1, 1, 0, -1, 1> >, Eigen::Matrix<int, -1, 1, 0, -1, 1>, Eigen::CwiseNullaryOp<Eigen::internal::scalar_constant_op<bool>, Eigen::Array<bool, -1, 1, 0, -1, 1> >, bool>(Eigen::CwiseNullaryOp<Eigen::internal::linspaced_op<int, true>, 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<bool>, Eigen::Array<bool, -1, 1, 0, -1, 1> > const&, unsigned long, unsigned long, Eigen::SparseMatrix<bool, 0, int>&);
 #endif
 #endif
+
+template void igl::sparse<Eigen::Matrix<int, -1, 1, 0, -1, 1>, 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&, size_t, size_t, Eigen::SparseMatrix<std::complex<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<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&, size_t, size_t, Eigen::SparseMatrix<double, 0, int>&);
+#endif

+ 1 - 1
index.html

@@ -258,7 +258,7 @@ few labs/companies/institutions using libigl:</p>
 <h2 id="contact">Contact</h2>
 
 <p>Libigl is a group endeavor led by <a href="http://www.cs.columbia.edu/~jacobson/">Alec
-Jacobson</a> and <a href="http://www.inf.ethz.ch/personal/dpanozzo/">Daniele
+Jacobson</a> and <a href="http://cs.nyu.edu/~panozzo/">Daniele
 Panozzo</a>. Please <a href="&#109;&#97;&#105;&#108;&#x74;&#111;&#x3a;&#x61;&#x6c;&#101;&#x63;&#x6a;&#x61;&#x63;&#111;&#98;&#115;&#111;&#110;&#64;&#103;&#109;&#x61;&#105;&#108;&#x2e;&#x63;&#x6f;&#x6d;&#44;&#x64;&#x61;&#110;&#105;&#101;&#x6c;&#101;&#x2e;&#x70;&#x61;&#110;&#x6f;&#122;&#x7a;&#x6f;&#64;&#x67;&#x6d;&#x61;&#x69;&#x6c;&#x2e;&#99;&#x6f;&#x6d;">&#99;&#x6f;&#x6e;&#116;&#x61;&#99;&#x74;
 &#117;&#115;</a> if you have
 questions or comments. For troubleshooting, please post an

+ 1 - 1
python/README.md

@@ -140,7 +140,7 @@ The script depends on additional libraries (joblib, mako, clang), make sure to i
 
 Libigl is a group endeavor led by [Alec
 Jacobson](http://www.cs.columbia.edu/~jacobson/) and [Daniele
-Panozzo](http://www.inf.ethz.ch/personal/dpanozzo/). Please [contact
+Panozzo](http://cs.nyu.edu/~panozzo/). Please [contact
 us](mailto:alecjacobson@gmail.com,daniele.panozzo@gmail.com) if you have
 questions or comments. For troubleshooting, please post an
 [issue](https://github.com/libigl/libigl/issues) on github.

+ 40 - 40
python/py_igl/py_unique.cpp

@@ -32,27 +32,27 @@ m.def("unique_rows", []
 }, __doc_igl_unique,
 py::arg("A"), py::arg("C"), py::arg("IA"), py::arg("IC"));
 
-m.def("unique", []
-(
-  const std::vector<double> & A,
-  std::vector<double> & C,
-  std::vector<size_t> & IA,
-  std::vector<size_t> & IC
-)
-{
-  return igl::unique(A,C,IA,IC);
-}, __doc_igl_unique,
-py::arg("A"), py::arg("C"), py::arg("IA"), py::arg("IC"));
+//m.def("unique", []
+//(
+//  const std::vector<double> & A,
+//  std::vector<double> & C,
+//  std::vector<size_t> & IA,
+//  std::vector<size_t> & IC
+//)
+//{
+//  return igl::unique(A,C,IA,IC);
+//}, __doc_igl_unique,
+//py::arg("A"), py::arg("C"), py::arg("IA"), py::arg("IC"));
 
-m.def("unique", []
-(
-  const std::vector<double> & A,
-  std::vector<double> & C
-)
-{
-  return igl::unique(A,C);
-}, __doc_igl_unique,
-py::arg("A"), py::arg("C"));
+//m.def("unique", []
+//(
+//  const std::vector<double> & A,
+//  std::vector<double> & C
+//)
+//{
+//  return igl::unique(A,C);
+//}, __doc_igl_unique,
+//py::arg("A"), py::arg("C"));
 
 
 // int
@@ -92,24 +92,24 @@ m.def("unique_rows", []
 }, __doc_igl_unique,
 py::arg("A"), py::arg("C"), py::arg("IA"), py::arg("IC"));
 
-m.def("unique", []
-(
-  const std::vector<int> & A,
-  std::vector<int> & C,
-  std::vector<size_t> & IA,
-  std::vector<size_t> & IC
-)
-{
-  return igl::unique(A,C,IA,IC);
-}, __doc_igl_unique,
-py::arg("A"), py::arg("C"), py::arg("IA"), py::arg("IC"));
+//m.def("unique", []
+//(
+//  const std::vector<int> & A,
+//  std::vector<int> & C,
+//  std::vector<size_t> & IA,
+//  std::vector<size_t> & IC
+//)
+//{
+//  return igl::unique(A,C,IA,IC);
+//}, __doc_igl_unique,
+//py::arg("A"), py::arg("C"), py::arg("IA"), py::arg("IC"));
 
-m.def("unique", []
-(
-  const std::vector<int> & A,
-  std::vector<int> & C
-)
-{
-  return igl::unique(A,C);
-}, __doc_igl_unique,
-py::arg("A"), py::arg("C"));
+//m.def("unique", []
+//(
+//  const std::vector<int> & A,
+//  std::vector<int> & C
+//)
+//{
+//  return igl::unique(A,C);
+//}, __doc_igl_unique,
+//py::arg("A"), py::arg("C"));

+ 3 - 2
python/tcpviewer.py

@@ -16,7 +16,7 @@ def worker(viewer,lock,s):
             lock.acquire()
             slist = []
             while True:
-                buf = conn.recv(10000000)
+                buf = conn.recv(4096)
                 if not buf:
                     break
                 slist.append(buf.decode('unicode_internal','ignore'))
@@ -41,7 +41,8 @@ class TCPViewer(igl.viewer.Viewer):
         try:
             s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
             s.connect((HOST, PORT))
-            a = array.array('u',self.data.serialize())
+            ser = self.data.serialize()
+            a = array.array('u', ser)
             s.sendall(a)
             s.close()
         except:

+ 1 - 6
python/tutorial/102_DrawMesh_TCP.py

@@ -10,12 +10,7 @@ from shared import TUTORIAL_SHARED_PATH
 
 
 ## This is a test application for the TCPViewer
-
-# Launch the tcp viewer
-os.system("python ../tcpviewer.py&")
-
-# Wait for it to set up the socket
-time.sleep(1)
+# Make sure to launch the tcpviewer.py first
 
 # Read a mesh
 V = igl.eigen.MatrixXd()

+ 24 - 8
shared/cmake/CMakeLists.txt

@@ -238,25 +238,41 @@ endif()
 if(LIBIGL_WITH_EMBREE)
   set(EMBREE_DIR "${LIBIGL_EXTERNAL}/embree")
 
-  set(ENABLE_ISPC_SUPPORT OFF CACHE BOOL " " FORCE)
-  set(RTCORE_TASKING_SYSTEM "INTERNAL" CACHE BOOL " " FORCE)
-  set(ENABLE_TUTORIALS OFF CACHE BOOL " " FORCE)
-  set(ENABLE_STATIC_LIB ON CACHE BOOL " " FORCE)
-  set(ENABLE_INSTALLER OFF CACHE BOOL " " FORCE)
+  set(EMBREE_ISPC_SUPPORT OFF CACHE BOOL " " FORCE)
+  set(EMBREE_TASKING_SYSTEM "INTERNAL" CACHE BOOL " " FORCE)
+  set(EMBREE_TUTORIALS OFF CACHE BOOL " " FORCE)
+  set(EMBREE_MAX_ISA NONE CACHE STRINGS " " FORCE)
+
+  # set(ENABLE_INSTALLER OFF CACHE BOOL " " FORCE)
   if(MSVC)
-    set(USE_STATIC_RUNTIME OFF CACHE BOOL " " FORCE)
+    # set(EMBREE_STATIC_RUNTIME OFF CACHE BOOL " " FORCE)
+    set(EMBREE_STATIC_LIB OFF CACHE BOOL " " FORCE)
+  else()
+    set(EMBREE_STATIC_LIB ON CACHE BOOL " " FORCE)
   endif()
 
   add_subdirectory("${EMBREE_DIR}" "embree")
   list(APPEND LIBIGL_INCLUDE_DIRS "${EMBREE_DIR}/include")
   list(APPEND LIBIGL_EMBREE_EXTRA_LIBRARIES "embree")
   list(APPEND LIBIGL_EXTRA_LIBRARIES ${LIBIGL_EMBREE_EXTRA_LIBRARIES})
-  list(APPEND LIBIGL_DEFINITIONS "-DENABLE_STATIC_LIB")
+
+  if(NOT MSVC)
+		list(APPEND LIBIGL_DEFINITIONS "-DENABLE_STATIC_LIB")
+	endif()
+
+  if(MSVC)
+    add_custom_target(Copy-Embree-DLL ALL        # Adds a post-build event to MyTest
+        COMMAND ${CMAKE_COMMAND} -E copy_if_different  # which executes "cmake - E copy_if_different..."
+            "${CMAKE_BINARY_DIR}/libigl/embree/$<CONFIGURATION>/embree.dll"      # <--this is in-file
+          "${CMAKE_BINARY_DIR}/embree.dll")                 # <--this is out-file path	endif()
+  endif()
 
   if(LIBIGL_USE_STATIC_LIBRARY)
     CompileIGL_Module("embree" "")
     target_include_directories(igl_embree PRIVATE ${EMBREE_DIR}/include)
-    target_compile_definitions(igl_embree PRIVATE -DENABLE_STATIC_LIB)
+	if(NOT MSVC)
+		target_compile_definitions(igl_embree PRIVATE -DENABLE_STATIC_LIB)
+	endif()
   endif()
 endif()
 

+ 1 - 1
tutorial/tutorial.html.REMOVED.git-id

@@ -1 +1 @@
-2d4017ae4cf96f5ddc6c543c54d15c47418217cb
+e433fea7c89195d4086db16774eec2e6a7e8014f

+ 1 - 1
tutorial/tutorial.md.REMOVED.git-id

@@ -1 +1 @@
-70fb600fc4ac9cf8080fc3dd5b25409140700b8a
+fdd2d996ca033c6ca0452fd413e506732eb4de40