소스 검색

Merge remote-tracking branch 'upstream/master'

Former-commit-id: 93e4dbfbc3077df21d933909565258fafd8c1f89
Qingnan Zhou 9 년 전
부모
커밋
ff200d90c3

+ 3 - 0
.gitignore

@@ -75,3 +75,6 @@ optional/build
 lib
 tutorial/XXX_test/CMakeLists.txt
 tutorial/XXX_test/main.cpp
+python/py_igl/todo
+python/build
+python/.idea

+ 3 - 0
.gitmodules

@@ -4,3 +4,6 @@ url=https://github.com/libigl/nanogui.git
         fetchRecursiveSubmodules = true
         ignore = dirty
 
+[submodule "external/embree"]
+	path = external/embree
+	url = https://github.com/embree/embree.git

+ 1 - 1
include/igl/biharmonic_coordinates.cpp

@@ -142,7 +142,7 @@ IGL_INLINE bool igl::biharmonic_coordinates(
   // minimize    ½ W' A W'
   // subject to  W(b,:) = J
   return min_quad_with_fixed(
-    A,VectorXd::Zero(A.rows()).eval(),b,J,{},VectorXd(),true,W);
+    A,VectorXd::Zero(A.rows()).eval(),b,J,SparseMatrix<double>(),VectorXd(),true,W);
 }
 
 #ifdef IGL_STATIC_LIBRARY

+ 37 - 0
include/igl/hausdorff.cpp

@@ -0,0 +1,37 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 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 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#include "hausdorff.h"
+#include "point_mesh_squared_distance.h"
+
+template <
+  typename DerivedVA, 
+  typename DerivedFA,
+  typename DerivedVB,
+  typename DerivedFB,
+  typename Scalar>
+IGL_INLINE void igl::hausdorff(
+  const Eigen::PlainObjectBase<DerivedVA> & VA, 
+  const Eigen::PlainObjectBase<DerivedFA> & FA,
+  const Eigen::PlainObjectBase<DerivedVB> & VB, 
+  const Eigen::PlainObjectBase<DerivedFB> & FB,
+  Scalar & d)
+{
+  using namespace Eigen;
+  assert(VA.cols() == 3 && "VA should contain 3d points");
+  assert(FA.cols() == 3 && "FA should contain triangles");
+  assert(VB.cols() == 3 && "VB should contain 3d points");
+  assert(FB.cols() == 3 && "FB should contain triangles");
+  Matrix<Scalar,Dynamic,1> sqr_DBA,sqr_DAB;
+  Matrix<typename DerivedVA::Index,Dynamic,1> I;
+  Matrix<typename DerivedVA::Scalar,Dynamic,3> C;
+  point_mesh_squared_distance(VB,VA,FA,sqr_DBA,I,C);
+  point_mesh_squared_distance(VA,VB,FB,sqr_DAB,I,C);
+  const Scalar dba = sqr_DBA.maxCoeff();
+  const Scalar dab = sqr_DAB.maxCoeff();
+  d = sqrt(std::max(dba,dab));
+}

+ 51 - 0
include/igl/hausdorff.h

@@ -0,0 +1,51 @@
+// This file is part of libigl, a simple c++ geometry processing library.
+// 
+// Copyright (C) 2015 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 
+// obtain one at http://mozilla.org/MPL/2.0/.
+#ifndef IGL_HAUSDORFF_H
+#define IGL_HAUSDORFF_H
+#include "igl_inline.h"
+
+#include <Eigen/Dense>
+
+namespace igl 
+{
+  // HAUSDORFF compute the Hausdorff distance between mesh (VA,FA) and mesh
+  // (VB,FB). This is the 
+  //
+  // d(A,B) = max ( max min d(a,b) , max min d(b,a) )
+  //                a∈A b∈B          b∈B a∈A
+  //
+  // Inputs:
+  //   VA  #VA by 3 list of vertex positions
+  //   FA  #FA by 3 list of face indices into VA
+  //   VB  #VB by 3 list of vertex positions
+  //   FB  #FB by 3 list of face indices into VB
+  // Outputs:
+  //   d  hausdorff distance
+  //   pair  2 by 3 list of "determiner points" so that pair(1,:) is from A and
+  //     pair(2,:) is from B
+  //
+  template <
+    typename DerivedVA, 
+    typename DerivedFA,
+    typename DerivedVB,
+    typename DerivedFB,
+    typename Scalar>
+  IGL_INLINE void hausdorff(
+    const Eigen::PlainObjectBase<DerivedVA> & VA, 
+    const Eigen::PlainObjectBase<DerivedFA> & FA,
+    const Eigen::PlainObjectBase<DerivedVB> & VB, 
+    const Eigen::PlainObjectBase<DerivedFB> & FB,
+    Scalar & d);
+}
+
+#ifndef IGL_STATIC_LIBRARY
+#  include "hausdorff.cpp"
+#endif
+
+#endif
+

+ 3 - 2
include/igl/integrable_polyvector_fields.cpp

@@ -190,7 +190,8 @@ makeFieldCCW(Eigen::MatrixXd &sol3D)
   {
     //take all 4 vectors (including opposites) and pick two that are in ccw order
     all << sol3D.row(fi), -sol3D.row(fi);
-    igl::sort_vectors_ccw(all, FN.row(fi).eval(), order, true, t);
+	Eigen::VectorXi inv_order_unused;
+    igl::sort_vectors_ccw(all, FN.row(fi).eval(), order, true, t, false, inv_order_unused);
     //if we are in a constrained face, we need to make sure that the first vector is always the same vector as in the constraints
     if(is_constrained_face[fi])
     {
@@ -240,7 +241,7 @@ computeInteriorEdges()
   // Flag border edges
   numInteriorEdges = 0;
   isBorderEdge.setZero(numE,1);
-  indFullToInterior = -1.*Eigen::VectorXi::Ones(numE,1);
+  indFullToInterior = -1*Eigen::VectorXi::Ones(numE,1);
 
   for(unsigned i=0; i<numE; ++i)
   {

+ 4 - 2
include/igl/polyvector_field_matchings.cpp

@@ -24,8 +24,10 @@ IGL_INLINE void igl::polyvector_field_matching(
   Eigen::Matrix<typename DerivedS::Scalar,1,Eigen::Dynamic> ua (1,N*3); ua <<_ua, -_ua;
   Eigen::Matrix<typename DerivedS::Scalar,1,Eigen::Dynamic> ub (1,N*3); ub <<_ub, -_ub;
   Eigen::Matrix<typename DerivedM::Scalar,Eigen::Dynamic,1> order_a, order_b;
-  igl::sort_vectors_ccw(ua, na, order_a);
-  igl::sort_vectors_ccw(ub, nb, order_b);
+  Eigen::Matrix<typename DerivedS::Scalar, 1, Eigen::Dynamic> sorted_unused;
+  Eigen::VectorXi inv_order_unused;
+  igl::sort_vectors_ccw(ua, na, order_a,false,sorted_unused,false,inv_order_unused);
+  igl::sort_vectors_ccw(ub, nb, order_b,false,sorted_unused,false,inv_order_unused);
 
   //checking all possible circshifts of order_b as matches for order_a
   Eigen::Matrix<typename DerivedM::Scalar,Eigen::Dynamic,Eigen::Dynamic> all_matches(N,N);

+ 2 - 2
include/igl/sort.cpp

@@ -174,8 +174,8 @@ IGL_INLINE void igl::sort2(
     Index & bi = (dim==1 ? IX(1,i) : IX(i,1));
     if((ascending && a>b) || (!ascending && a<b))
     {
-      swap(a,b);
-      swap(ai,bi);
+      std::swap(a,b);
+      std::swap(ai,bi);
     }
   }
 }

+ 4 - 4
include/igl/sort_vectors_ccw.h

@@ -35,10 +35,10 @@ namespace igl {
                                    const Eigen::PlainObjectBase<DerivedS>& P,
                                    const Eigen::PlainObjectBase<DerivedS>& N,
                                    Eigen::PlainObjectBase<DerivedI> &order,
-                                   const bool do_sorted = false,
-                                   Eigen::PlainObjectBase<DerivedS> &sorted = *(Eigen::PlainObjectBase<DerivedS>*)NULL,
-                                   const bool do_inv_order = false,
-                                   Eigen::PlainObjectBase<DerivedI> &inv_order = *(Eigen::PlainObjectBase<DerivedI> *)NULL);
+                                   const bool do_sorted,
+                                   Eigen::PlainObjectBase<DerivedS> &sorted,
+                                   const bool do_inv_order,
+                                   Eigen::PlainObjectBase<DerivedI> &inv_order);
 };
 
 

+ 1 - 0
include/igl/xml/serialize_xml.cpp

@@ -7,6 +7,7 @@
 // obtain one at http://mozilla.org/MPL/2.0/.
 
 #include "serialize_xml.h"
+#include <iterator>
 
 namespace igl
 {

+ 1 - 1
optional/CMakeLists.txt

@@ -75,7 +75,7 @@ else (MATLAB_FOUND)
 endif(MATLAB_FOUND)
 
 ## Check for EMBREE, if not available skip the examples that depends on it
-find_package(EMBREE QUIET)
+find_package(EMBREEH QUIET)
 if (EMBREE_FOUND)
   include_directories( ${EMBREE_INCLUDE_DIR})
 else (EMBREE_FOUND)

+ 1 - 5
tutorial/606_AmbientOcclusion/CMakeLists.txt

@@ -3,13 +3,9 @@ project(606_AmbientOcclusion)
 
 include("../CMakeLists.shared")
 
-find_package(EMBREE REQUIRED)
-
-include_directories(${EMBREE_INCLUDE_DIRS})
-
 set(SOURCES
 ${PROJECT_SOURCE_DIR}/main.cpp
 )
 
 add_executable(${PROJECT_NAME}_bin ${SOURCES} ${SHARED_SOURCES})
-target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES} ${EMBREE_LIBRARIES})
+target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES})

+ 1 - 5
tutorial/607_Picking/CMakeLists.txt

@@ -3,13 +3,9 @@ project(607_Picking)
 
 include("../CMakeLists.shared")
 
-find_package(EMBREE REQUIRED)
-
-include_directories(${EMBREE_INCLUDE_DIRS})
-
 set(SOURCES
 ${PROJECT_SOURCE_DIR}/main.cpp
 )
 
 add_executable(${PROJECT_NAME}_bin ${SOURCES} ${SHARED_SOURCES})
-target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES} ${EMBREE_LIBRARIES})
+target_link_libraries(${PROJECT_NAME}_bin ${SHARED_LIBRARIES})

+ 25 - 4
tutorial/CMakeLists.txt

@@ -47,6 +47,27 @@ include_directories("../external/nanogui/include")
 include_directories("../external/nanogui/ext/nanovg/src")
 list(APPEND SHARED_LIBRARIES "nanogui" "glfw")
 
+#Compile embree
+option(ENABLE_ISPC_SUPPORT " " OFF)
+option(RTCORE_TASKING_SYSTEM " " INTERNAL)
+
+IF(NOT MSVC) # embree static build is broken on visual studio
+	option(ENABLE_STATIC_LIB " " ON)
+	set(ENABLE_STATIC_LIB ON CACHE BOOL "force static build of embree" FORCE)
+ENDIF(NOT MSVC)
+
+IF(MSVC)
+	option(USE_STATIC_RUNTIME " " OFF)
+	set(USE_STATIC_RUNTIME OFF CACHE BOOL "disable changes in the runtime for VS" FORCE)
+ENDIF(MSVC)
+
+option(ENABLE_TUTORIALS " " OFF)
+
+add_subdirectory("../external/embree/" "embree")
+include_directories("../external/embree/include")
+list(APPEND SHARED_LIBRARIES "embree")
+
+
 message(STATUS "Linking with: ${LIBIGL_LIBRARIES}")
 list(APPEND SHARED_LIBRARIES ${LIBIGL_LIBRARIES})
 
@@ -112,10 +133,10 @@ if(MATLAB_FOUND)
 endif(MATLAB_FOUND)
 add_subdirectory("604_Triangle")
 add_subdirectory("605_Tetgen")
-if(EMBREE_FOUND)
-  add_subdirectory("606_AmbientOcclusion")
-  add_subdirectory("607_Picking")
-endif(EMBREE_FOUND)
+
+add_subdirectory("606_AmbientOcclusion")
+add_subdirectory("607_Picking")
+
 if(LIM_FOUND)
   add_subdirectory("608_LIM")
 endif(LIM_FOUND)

+ 26 - 0
tutorial/cmake/FindEMBREEH.cmake

@@ -0,0 +1,26 @@
+#
+# Try to find EMBREE header files
+# Once done this will define
+#
+# EMBREE_FOUND           - system has EMBREE
+# EMBREE_INCLUDE_DIRS    - the EMBREE include directories
+
+FIND_PATH(EMBREE_INCLUDE_DIR embree2/rtcore.h
+	  PATHS
+		${PROJECT_SOURCE_DIR}/../../external/embree/include
+		${PROJECT_SOURCE_DIR}/../external/embree/include
+		${PROJECT_SOURCE_DIR}/../libigl/external/embree/include
+		NO_DEFAULT_PATH
+    )
+
+if(EMBREE_INCLUDE_DIR)
+	set(EMBREE_FOUND TRUE)
+endif(EMBREE_INCLUDE_DIR)
+
+IF (EMBREE_FOUND)
+   message(STATUS "Found EMBREE: ${EMBREE_INCLUDE_DIR}")
+
+   SET(EMBREE_INCLUDE_DIRS ${EMBREE_INCLUDE_DIR} ${EMBREE_INCLUDE_DIR}/embree)
+ELSE (EMBREE_FOUND)
+    message(STATUS "could NOT find EMBREE")
+ENDIF (EMBREE_FOUND)

+ 0 - 30
tutorial/compile_dependencies_linux.sh

@@ -1,30 +0,0 @@
-sudo apt-get install git
-sudo apt-get install build-essential
-sudo apt-get install libeigen3-dev
-sudo apt-get install cmake
-sudo apt-get install libx11-dev
-sudo apt-get install mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev
-sudo apt-get install libxrandr-dev
-sudo apt-get install libxi-dev
-sudo apt-get install freeglut3-dev
-sudo apt-get install libxmu-dev
-sudo apt-get install libblas-dev libsuitesparse-dev
-
-cd ../external/AntTweakBar/src/
-rm ../lib/*.a
-make
-
-cd ../../glfw/
-cmake -DCMAKE_BUILD_TYPE=Release .
-rm src/*.a
-make
-
-cd ../embree/
-rm -fr build
-mkdir build
-cd build
-cp ../ispc/ispc-v1.8.1-linux ispc
-cmake -DCMAKE_BUILD_TYPE=Release ../
-make
-
-cd ../../../tutorial

+ 0 - 18
tutorial/compile_dependencies_macosx.sh

@@ -1,18 +0,0 @@
-cd ../external/AntTweakBar/src/
-rm ../lib/*.a
-make -f makefile.osx.igl
-
-cd ../../glfw/
-cmake -DCMAKE_BUILD_TYPE=Release .
-rm src/*.a
-make
-
-cd ../embree/
-rm -fr build
-mkdir build
-cd build
-cp ../ispc/ispc-v1.8.1-osx ispc
-cmake -DCMAKE_BUILD_TYPE=Release ../
-make -j 16
-
-cd ../../../tutorial

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

@@ -1 +1 @@
-cd3c4039d1681abb39b6ab52f893a9649f6b16a5
+76a3c2f5ee343b08f1160182591a08472860030e

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

@@ -1 +1 @@
-4025d5bc12754b04d580b8b65e9760a2d29d3b62
+5fc7b26c782211bff5326b46b3eda0806a2aca0a