瀏覽代碼

Merge branch 'master' of github.com:libigl/libigl

Former-commit-id: 2512a62bd9eddad1a1a574cdd55cc0fd536aa79a
Alec Jacobson 11 年之前
父節點
當前提交
afc8ef9356

+ 0 - 1
include/igl/map_vertices_to_circle.cpp

@@ -12,7 +12,6 @@
 
 IGL_INLINE void igl::map_vertices_to_circle(
   const Eigen::MatrixXd& V,
-  const Eigen::MatrixXi& F,
   const Eigen::VectorXi& bnd,
   Eigen::MatrixXd& UV)
 {

+ 0 - 1
include/igl/map_vertices_to_circle.h

@@ -26,7 +26,6 @@ namespace igl
   //   UV   #W by 2 list of 2D position on the unit circle for the vertices in b
   IGL_INLINE void map_vertices_to_circle(
   	const Eigen::MatrixXd& V,
-  	const Eigen::MatrixXi& F,
     const Eigen::VectorXi& bnd,
   	Eigen::MatrixXd& UV);
 }

+ 2 - 2
tutorial/107_Matlab/main.cpp

@@ -30,7 +30,7 @@ void plotEV(igl::Viewer& viewer, int id)
     C.row(i) << r,g,b;
   }
 
-  viewer.draw_colors(C);
+  viewer.set_colors(C);
 }
 
 // This function is called every time a keyboard button is pressed
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
   // Plot the mesh
   igl::Viewer viewer;
   viewer.callback_key_down = &key_down;
-  viewer.draw_mesh(V, F);
+  viewer.set_mesh(V, F);
 
   // Plot the first non-trivial eigenvector
   plotEV(viewer,1);

+ 2 - 2
tutorial/107_Matlab/run.sh

@@ -5,6 +5,6 @@
 
 # Tested on MAC only
 
-DYLD_LIBRARY_PATH=/Applications/MATLAB_R2012b.app/bin/maci64/
+export DYLD_LIBRARY_PATH=/Applications/MATLAB_R2012b.app/bin/maci64/
 
-./build/106_Matlab
+./build/107_Matlab

+ 1 - 1
tutorial/501_HarmonicParam/main.cpp

@@ -33,7 +33,7 @@ int main(int argc, char *argv[])
 
   // Map the boundary to a circle, preserving edge proportions
   Eigen::MatrixXd bnd_uv;
-  igl::map_vertices_to_circle(V,F,bnd,bnd_uv);
+  igl::map_vertices_to_circle(V,bnd,bnd_uv);
 
   // Harmonic parametrization for the internal vertices
   igl::harmonic(V,F,bnd,bnd_uv,1,V_uv);

+ 11 - 0
tutorial/503_ARAPParam/CMakeLists.txt

@@ -0,0 +1,11 @@
+cmake_minimum_required(VERSION 2.6)
+project(503_ARAPParam)
+
+include("../CMakeLists.shared")
+
+set(SOURCES
+${PROJECT_SOURCE_DIR}/main.cpp
+)
+
+add_executable(${CMAKE_PROJECT_NAME} ${SOURCES} ${SHARED_SOURCES})
+target_link_libraries(${CMAKE_PROJECT_NAME} ${SHARED_LIBRARIES})

+ 83 - 0
tutorial/503_ARAPParam/main.cpp

@@ -0,0 +1,83 @@
+#include <igl/readOFF.h>
+#include <igl/viewer/Viewer.h>
+#include <igl/boundary_vertices_sorted.h>
+#include <igl/map_vertices_to_circle.h>
+#include <igl/harmonic.h>
+#include <igl/svd3x3/arap.h>
+
+Eigen::MatrixXd V;
+Eigen::MatrixXi F;
+Eigen::MatrixXd V_uv;
+Eigen::MatrixXd initial_guess;
+
+bool show_uv = false;
+
+bool key_down(igl::Viewer& viewer, unsigned char key, int modifier)
+{
+  if (key == '1')
+    show_uv = false;
+  else if (key == '2')
+    show_uv = true;
+
+  if (key == 'q')
+    V_uv = initial_guess;
+
+  if (show_uv)
+    viewer.set_mesh(V_uv,F);
+  else
+    viewer.set_mesh(V,F);
+
+  viewer.compute_normals();
+
+  return false;
+}
+
+int main(int argc, char *argv[])
+{
+  // Load a mesh in OFF format
+  igl::readOFF("../shared/camelhead.off", V, F);
+
+  // Compute the initial solution for ARAP (harmonic parametrization)
+  Eigen::VectorXi bnd;
+  igl::boundary_vertices_sorted(V,F,bnd);
+  Eigen::MatrixXd bnd_uv;
+  igl::map_vertices_to_circle(V,bnd,bnd_uv);
+
+  igl::harmonic(V,F,bnd,bnd_uv,1,initial_guess);
+
+  // Add dynamic regularization to avoid to specify boundary conditions
+  igl::ARAPData arap_data;
+  arap_data.with_dynamics = true;
+  Eigen::VectorXi b  = Eigen::VectorXi::Zero(0);
+  Eigen::MatrixXd bc = Eigen::MatrixXd::Zero(0,0);
+  
+  // Initialize ARAP
+  arap_data.max_iter = 1000;
+  Eigen::MatrixXd V_2d = V.block(0,0,V.rows(),2);
+  arap_precomputation(V_2d,F,b,arap_data);
+
+
+  // Solve arap using the harmonic map as initial guess
+  V_uv = initial_guess;
+
+  arap_solve(bc,arap_data,V_uv);
+
+
+  // Scale UV to make the texture more clear
+  // V_uv *= 5;
+
+  // Plot the mesh
+  igl::Viewer viewer;
+  viewer.set_mesh(V, F);
+  viewer.set_uv(V_uv);
+  viewer.callback_key_down = &key_down;
+
+  // Disable wireframe
+  viewer.options.show_lines = false;
+
+  // Draw checkerboard texture
+  viewer.options.show_texture = true;
+
+  // Launch the viewer
+  viewer.launch();
+}

+ 1 - 7
tutorial/cmake/FindLIBIGL.cmake

@@ -5,11 +5,6 @@
 #  LIBIGL_INCLUDE_DIR - the LIBIGL include directory
 #  LIBIGL_SOURCES - the LIBIGL source files
 
-
-if(LIBIGL_INCLUDE_DIR AND LIBIGL_SOURCES)
-   set(LIBIGL_FOUND TRUE)
-else(LIBIGL_INCLUDE_DIR AND LIBIGL_SOURCES)
-
 FIND_PATH(LIBIGL_INCLUDE_DIR igl/readOBJ.h
    /usr/include
    /usr/local/include
@@ -24,6 +19,7 @@ FIND_PATH(LIBIGL_INCLUDE_DIR igl/readOBJ.h
 
 if(LIBIGL_INCLUDE_DIR)
    set(LIBIGL_FOUND TRUE)
+   set(LIBIGL_INCLUDE_DIR ${LIBIGL_INCLUDE_DIR}  ${LIBIGL_INCLUDE_DIR}/../external/Singular_Value_Decomposition)
    add_definitions(-DIGL_HEADER_ONLY)
    #set(LIBIGL_SOURCES
    #   ${LIBIGL_INCLUDE_DIR}/igl/viewer/Viewer.cpp
@@ -41,5 +37,3 @@ else(LIBIGL_FOUND)
 endif(LIBIGL_FOUND)
 
 MARK_AS_ADVANCED(LIBIGL_INCLUDE_DIR LIBIGL_LIBRARIES IGL_VIEWER_SOURCES)
-
-endif(LIBIGL_INCLUDE_DIR AND LIBIGL_SOURCES)

+ 5 - 0
tutorial/compile_example_xcode.sh

@@ -0,0 +1,5 @@
+rm -fr buildXcode
+mkdir buildXcode
+cd buildXcode
+cmake -GXcode ../
+open buildXcode/*.xcodeproj

+ 59 - 0
tutorial/shared/planexy.off

@@ -0,0 +1,59 @@
+OFF
+25 32 0
+1 1 0 
+-1 1 0
+1 -1 0
+-1 -1 0
+1 0 0
+0 1 0
+-1 0 0
+0 -1 0
+0 0 0
+1 0.5 0 
+-0.5 1 0
+-1 -0.5 0
+0.5 -1 0
+1 -0.5 0
+0.5 1 0
+-1 0.5 0
+-0.5 -1 0
+0 -0.5 0
+0 0.5 0
+0.5 0 0
+-0.5 0 0
+-0.5 -0.5 0
+0.5 -0.5 0
+0.5 0.5 0
+-0.5 0.5 0
+3 11 3 16
+3 17 7 12
+3 18 8 19
+3 15 6 20
+3 21 16 7
+3 20 21 17
+3 6 11 21
+3 22 12 2
+3 19 22 13
+3 8 17 22
+3 23 19 4
+3 14 23 9
+3 5 18 23
+3 24 20 8
+3 10 24 18
+3 1 15 24
+3 21 11 16
+3 22 17 12
+3 23 18 19
+3 24 15 20
+3 17 21 7
+3 8 20 17
+3 20 6 21
+3 13 22 2
+3 4 19 13
+3 19 8 22
+3 9 23 4
+3 0 14 9
+3 14 5 23
+3 18 24 8
+3 5 10 18
+3 10 1 24