├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── LICENSE ├── README.md ├── cmake ├── FindLIBIGL.cmake └── libigl.cmake ├── data ├── elephant.pwn ├── hand.pwn └── sphere.pwn ├── grade.sh ├── images ├── elephant-mesh.jpg ├── elephant-points-normals.jpg ├── primary-grid.jpg ├── staggered-grid-x-and-y.jpg ├── staggered-grid-x.jpg ├── staggered-grid.ai ├── trilinear-interpolation.jpg ├── trilinear-interpolation.pdf └── trilinear-interpolation.svg ├── include ├── fd_grad.h ├── fd_interpolate.h ├── fd_partial_derivative.h └── poisson_surface_reconstruction.h ├── main.cpp ├── papers └── poisson-surface-reconstruction.pdf ├── src ├── fd_grad.cpp ├── fd_interpolate.cpp ├── fd_partial_derivative.cpp └── poisson_surface_reconstruction.cpp ├── test.sh └── tex ├── 03a56bc7e563c16280f1195482f10205.svg ├── 05af85763c308fe9dfd93f44e8149a59.svg ├── 08b11f4adf974a9005ff55cc8902bb6b.svg ├── 0c8c492bada7dbc998c2939499c8dd3f.svg ├── 0ee0c8e0c23693d9c6b800197f53ea56.svg ├── 11420dc7bbad910d2c10985d1b742ea8.svg ├── 17fd0995c494e4eb8497758396409438.svg ├── 190806857015e55cba624fe6a29d20ec.svg ├── 1e500ed0738135b9e26f388580e20b32.svg ├── 2721b133f6f6619c279972b564b09689.svg ├── 2ad9d098b937e46f9f58968551adac57.svg ├── 2bbf4eee68fd087c4e89458ffc858ecb.svg ├── 2c4bc71f5a8a9a81f5cf264007714e41.svg ├── 2ca7f2cd2542e5d50a1ca0023d729ff8.svg ├── 2eacd907c22e9ad1db070a00eef0f2cd.svg ├── 2f11c6120fcb1f7a8dd90b5a25a7216b.svg ├── 322d8f61a96f4dd07a0c599482268dfe.svg ├── 3236f157a53b70469c7a6de44c7d21f0.svg ├── 332cc365a4987aacce0ead01b8bdcc0b.svg ├── 34443414f341f1768e4a3663859ea298.svg ├── 380c103b60c66d6420ec8923cdc6e6e8.svg ├── 384591906555413c452c93e493b2d4ec.svg ├── 3ae9f01dc94f6f227393748350a53b77.svg ├── 3cec78ebec6c7208cc0c77bdbe913bf8.svg ├── 3cf4fbd05970446973fc3d9fa3fe3c41.svg ├── 3e2a76e23fe9c67f0c6a1d099d494151.svg ├── 40ecdbad5a9ebcc6dae0bf86ffeddff6.svg ├── 41bf049c525434295c5c91ab03d41324.svg ├── 437fbd49ccec7ed33a81f87d3df7d43a.svg ├── 4636475863bb81bba2dddef66b454bdc.svg ├── 4695cb3c40f1831d62ab5a07ecb94255.svg ├── 473d4a136e73dec1b14f253176da2f53.svg ├── 47486f504760931f80d59be4c7e5f4d4.svg ├── 4772bc64bc27c6be242900b098354180.svg ├── 4870d18d47ab6d0e32510c4b1ccf4927.svg ├── 492a25e9363c8fec347ccd7b6ed47b5f.svg ├── 4d62a3e4e599acad7cc1af2f73ad0543.svg ├── 517cbc8a282a06299b941df2bf4ad9f2.svg ├── 5439c1794588f864d0fcccab4d28f058.svg ├── 54598fd8e0d7e440dfa0c17e17f8be10.svg ├── 55a049b8f161ae7cfeb0197d75aff967.svg ├── 5f3cc59831e6b4aef298a2dacada3fe7.svg ├── 66db0c1cae14fe5e2a13f61b3b03d67a.svg ├── 6a2b92e3660606561092ff62529e4533.svg ├── 6e9103d18236e9931449ce1f3a303f5c.svg ├── 73adb055289ee2e3d0fed569b21285ff.svg ├── 7416b17310610b48b6251c3362319484.svg ├── 764485b6489c166576a9c344e1f9cec2.svg ├── 7692e3f86410f1343c20d3bc0f95b02c.svg ├── 76c0bc21c84b795247769888ea687c90.svg ├── 793a1b090156858c6786a258487ce31c.svg ├── 7aed918aa12a276a602e30e90b0b109d.svg ├── 7da1a14aa73a72098c04b81d8feed597.svg ├── 7ff3dcedb9ca37b4fa9ef4b6aeb87111.svg ├── 81ee55d5839b20e95d03b438b3a60dbd.svg ├── 8307d3640b2448d0bee6f177cbda22dc.svg ├── 868935999c53fb48a44bf30d3a3c1079.svg ├── 894fe1065bc022997ddadbf01f0cf213.svg ├── 8a567299f0c8eee3484004a8814e0a9d.svg ├── 8c063c3e6477d6dc92852a303442db8f.svg ├── 8c2d642b999ade726977a143fdb6419e.svg ├── 8fc2223d19b0886790872904d6b97578.svg ├── 8ff5d71a18238a4be365916ca7d05d68.svg ├── 916be6a7b04723c1976ee484e8749dba.svg ├── 96eb4872da7497e849abf83ebc451a99.svg ├── 97264e77606b79af66ff5c3064a3d179.svg ├── 980fcd4213d7b5d2ffcc82ec78c27ead.svg ├── 985e9d424986b945b21cbfc30f69ee2c.svg ├── 98a6924bf931c3807f8deddadd870393.svg ├── 99d0a596e92be38901109a081d07d64f.svg ├── a9a3a4a202d80326bda413b5562d5cd1.svg ├── abba53cfa4754e0fb3447fe5e0be0b78.svg ├── ae44fa1818647ed39ba79b316ce5dd87.svg ├── af1a2017f0a516c71e45ba5be7345029.svg ├── b1467b64271e0e80be78cc8537d840cb.svg ├── b56595d2a30a0af329086562ca12d521.svg ├── b999fa3230bc59907de3384d2a0a1ab2.svg ├── ba3f16549018145cc787dd0e73df1c2b.svg ├── bb9905f60ed7973f6bb9b104a3cfb901.svg ├── bccab73005d96290c8ef588703533a21.svg ├── bd8a3a3788c7e885e5bb709066e6888a.svg ├── c3f6ab15dfc4f9089c52bc6258c8a0b6.svg ├── c4ca9607e0256b282b5cdabc3a37e938.svg ├── c65df61fee36c4a70fabfa1397a6b34c.svg ├── c888b5dd080ec7f68a997efb3ed6b96b.svg ├── cffca7c1479a119f8929bf5726372e56.svg ├── d2b4c9acbd841c2d920f43cbd427168b.svg ├── d30a65b936d8007addc9c789d5a7ae49.svg ├── d704526aa8d189d72fa711747b30ed72.svg ├── da5edae1fb4f79cabe92a9ab16962ad7.svg ├── daa72bcc65930e39126b00858df4e55c.svg ├── db65455e0997a15786a1a40f16d5f8fa.svg ├── dcf8770cd411ce907b99ca3bea200f9e.svg ├── de359c205c9bfe1240b157e694922b0f.svg ├── deceeaf6940a8c7a5a02373728002b0f.svg ├── e611a18d5ae8daa7807f07b9889155d0.svg ├── e89a81a146afd2d4c13849f2ce122376.svg ├── eab7528ff6cda4ba4cabe93ba6c4d2ea.svg ├── ecb02abb9d3c72a23e6c3e776b8f3b53.svg ├── eea7dd94c059c1b0a4871b27e5226110.svg ├── f0c74577699a7ca84f8d507f9fd49d62.svg ├── f4bae048ad3b65d9c8410d826fcd521d.svg ├── f4e5add43718dd0d01e8a2cf425322f8.svg ├── f5635624df56862986d167f2d91cc6e6.svg ├── f5c9eb9c5fad33ab1f8895e3863d1d88.svg ├── f6fc3ac36dff143d4aac9d145fadc77e.svg ├── f8418a00a5940164cc6a57d88beceeab.svg ├── f93ce33e511096ed626b4719d50f17d2.svg ├── fc0332b4de4ffb25b3d11d449336566b.svg └── ffd3200af88dde1e39d8a5b6c2cc16ec.svg /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | *.smod 19 | 20 | # Compiled Static libraries 21 | *.lai 22 | *.la 23 | *.a 24 | *.lib 25 | 26 | # Executables 27 | *.exe 28 | *.out 29 | *.app 30 | 31 | *.un~ 32 | *.swo 33 | *.swp 34 | build/* 35 | *.DS_Store 36 | solution/*.cpp 37 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/.gitmodules -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(mesh-reconstruction) 3 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) 4 | 5 | ### libIGL options: choose between header only and compiled static library 6 | option(LIBIGL_USE_STATIC_LIBRARY "Use libigl as static library" OFF) 7 | option(LIBIGL_GLFW "Use GLFW" ON) 8 | 9 | include(libigl) 10 | 11 | # Add your project files 12 | include_directories("include/") 13 | if(USE_SOLUTION) 14 | file(GLOB SRCFILES solution/*.cpp) 15 | else() 16 | file(GLOB SRCFILES src/*.cpp) 17 | endif() 18 | 19 | add_library(core ${SRCFILES}) 20 | target_link_libraries(core igl::core igl::glfw ) 21 | 22 | add_executable(mesh-reconstruction "main.cpp") 23 | target_link_libraries(mesh-reconstruction core igl::core igl::opengl igl::glfw ) 24 | -------------------------------------------------------------------------------- /cmake/FindLIBIGL.cmake: -------------------------------------------------------------------------------- 1 | # - Try to find the LIBIGL library 2 | # Once done this will define 3 | # 4 | # LIBIGL_FOUND - system has LIBIGL 5 | # LIBIGL_INCLUDE_DIR - **the** LIBIGL include directory 6 | if(LIBIGL_FOUND) 7 | return() 8 | endif() 9 | 10 | find_path(LIBIGL_INCLUDE_DIR igl/readOBJ.h 11 | HINTS 12 | ENV LIBIGL 13 | ENV LIBIGLROOT 14 | ENV LIBIGL_ROOT 15 | ENV LIBIGL_DIR 16 | PATHS 17 | ${CMAKE_SOURCE_DIR}/../.. 18 | ${CMAKE_SOURCE_DIR}/.. 19 | ${CMAKE_SOURCE_DIR} 20 | ${CMAKE_SOURCE_DIR}/libigl 21 | ${CMAKE_SOURCE_DIR}/../libigl 22 | ${CMAKE_SOURCE_DIR}/../../libigl 23 | /usr 24 | /usr/local 25 | /usr/local/igl/libigl 26 | PATH_SUFFIXES include 27 | ) 28 | 29 | include(FindPackageHandleStandardArgs) 30 | find_package_handle_standard_args(LIBIGL 31 | "\nlibigl not found --- You can download it using:\n\tgit clone --recursive https://github.com/libigl/libigl.git ${CMAKE_SOURCE_DIR}/../libigl" 32 | LIBIGL_INCLUDE_DIR) 33 | mark_as_advanced(LIBIGL_INCLUDE_DIR) 34 | 35 | list(APPEND CMAKE_MODULE_PATH "${LIBIGL_INCLUDE_DIR}/../cmake") 36 | include(libigl) 37 | -------------------------------------------------------------------------------- /cmake/libigl.cmake: -------------------------------------------------------------------------------- 1 | if(TARGET igl::core) 2 | return() 3 | endif() 4 | 5 | include(FetchContent) 6 | message(STATUS "Finding/Downloading libigl...") 7 | FetchContent_Declare( 8 | libigl 9 | GIT_REPOSITORY https://github.com/libigl/libigl.git 10 | GIT_TAG v2.4.0 11 | ) 12 | FetchContent_MakeAvailable(libigl) 13 | -------------------------------------------------------------------------------- /grade.sh: -------------------------------------------------------------------------------- 1 | if [ $# -le 0 ]; then 2 | echo "Invalid argument, expect: ./grade.sh [id]" 3 | exit 1 4 | fi 5 | 6 | cd build"_$1" 7 | ./mesh-reconstruction 8 | ./mesh-reconstruction ../data/elephant.pwn 9 | 10 | # # cp base_include/* include/ 11 | # cp submission/"$1/"*.cpp src/ 12 | # cp submission/"$1/"*.h include/ 13 | # mkdir build"_$1" 14 | # cd build"_$1" 15 | # cmake .. -DCMAKE_BUILD_TYPE=Release 16 | # make -j8 17 | 18 | 19 | # ./a1-mass-spring-1d 20 | # ./a1-mass-spring-1d rk 21 | # ./a1-mass-spring-1d be 22 | # ./a1-mass-spring-1d se 23 | # cp ./a1-mass-spring-1d ./a1-mass-spring-1d"_$1" 24 | # cd .. 25 | -------------------------------------------------------------------------------- /images/elephant-mesh.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/elephant-mesh.jpg -------------------------------------------------------------------------------- /images/elephant-points-normals.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/elephant-points-normals.jpg -------------------------------------------------------------------------------- /images/primary-grid.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/primary-grid.jpg -------------------------------------------------------------------------------- /images/staggered-grid-x-and-y.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/staggered-grid-x-and-y.jpg -------------------------------------------------------------------------------- /images/staggered-grid-x.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/staggered-grid-x.jpg -------------------------------------------------------------------------------- /images/staggered-grid.ai: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/staggered-grid.ai -------------------------------------------------------------------------------- /images/trilinear-interpolation.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/trilinear-interpolation.jpg -------------------------------------------------------------------------------- /images/trilinear-interpolation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/alecjacobson/geometry-processing-mesh-reconstruction/0d1eeab5bad508c86166fb4a65c60b2457527b36/images/trilinear-interpolation.pdf -------------------------------------------------------------------------------- /images/trilinear-interpolation.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 10 | 11 | 12 | 14 | 15 | 16 | 17 | 20 | 23 | 26 | 29 | 32 | 35 | 38 | 41 | 44 | 47 | 50 | 53 | 56 | 57 | -------------------------------------------------------------------------------- /include/fd_grad.h: -------------------------------------------------------------------------------- 1 | #ifndef FD_GRAD_H 2 | #define FD_GRAD_H 3 | #include 4 | // Construct a gradient matrix for a finite-difference grid 5 | // 6 | // Inputs: 7 | // nx number of grid steps along the x-direction 8 | // ny number of grid steps along the y-direction 9 | // nz number of grid steps along the z-direction 10 | // h grid step size 11 | // Outputs: 12 | // G (nx-1)*ny*nz+ nx*(ny-1)*nz+ nx*ny*(nz-1) by nx*ny*nz sparse gradient 13 | // matrix: G = [Dx;Dy;Dz] 14 | // 15 | // See also: fd_partial_derivative.h 16 | void fd_grad( 17 | const int nx, 18 | const int ny, 19 | const int nz, 20 | const double h, 21 | Eigen::SparseMatrix & G); 22 | #endif 23 | -------------------------------------------------------------------------------- /include/fd_interpolate.h: -------------------------------------------------------------------------------- 1 | #ifndef FD_INTERPOLATE_H 2 | #define FD_INTERPOLATE_H 3 | #include 4 | #include 5 | // Construct a matrix of trilinear interpolation weights for a 6 | // finite-difference grid at a given set of points 7 | // 8 | // Inputs: 9 | // nx number of grid steps along the x-direction 10 | // ny number of grid steps along the y-direction 11 | // nz number of grid steps along the z-direction 12 | // h grid step size 13 | // corner list of bottom-left-front corner position of grid 14 | // P n by 3 list of query point locations 15 | // Outputs: 16 | // W n by (nx*ny*nz) sparse weights matrix 17 | // 18 | void fd_interpolate( 19 | const int nx, 20 | const int ny, 21 | const int nz, 22 | const double h, 23 | const Eigen::RowVector3d & corner, 24 | const Eigen::MatrixXd & P, 25 | Eigen::SparseMatrix & W); 26 | #endif 27 | -------------------------------------------------------------------------------- /include/fd_partial_derivative.h: -------------------------------------------------------------------------------- 1 | #ifndef FD_PARTIAL_DERIVATIVE_H 2 | #define FD_PARTIAL_DERIVATIVE_H 3 | #include 4 | // Construct a partial derivative matrix for a finite-difference grid in a 5 | // given direction. Derivative are computed using first-order differences onto 6 | // a staggered grid 7 | // 8 | // Inputs: 9 | // nx number of grid steps along the x-direction 10 | // ny number of grid steps along the y-direction 11 | // nz number of grid steps along the z-direction 12 | // h grid step size 13 | // dir index indicating direction: 0-->x, 1-->y, 2-->z 14 | // Outputs: 15 | // D m by nx*ny*nz sparse partial derivative matrix, where: 16 | // m = (nx-1)*ny*nz if dir = 0 17 | // m = nx*(ny-1)*nz if dir = 1 18 | // m = nx*ny*(nz-1) otherwise (if dir = 2) 19 | // 20 | // See also: fd_partial_derivative.h 21 | void fd_partial_derivative( 22 | const int nx, 23 | const int ny, 24 | const int nz, 25 | const double h, 26 | const int dir, 27 | Eigen::SparseMatrix & D); 28 | #endif 29 | -------------------------------------------------------------------------------- /include/poisson_surface_reconstruction.h: -------------------------------------------------------------------------------- 1 | #ifndef POISSON_SURFACE_RECONSTRUCTION_H 2 | #define POISSON_SURFACE_RECONSTRUCTION_H 3 | #include 4 | 5 | // Takes input sample points P and input normals N 6 | // and gives a watertight mesh using a simplified 7 | // version of [Kazhdan et. al 2006] 8 | // 9 | // Inputs: 10 | // P #P by 3 list of input points 11 | // N #P by 3 list of input normals associated with each point in P 12 | // Outputs: 13 | // V #V by 3 list of mesh vertex positions 14 | // F #F by 3 list of mesh triangle indinces into V 15 | // 16 | void poisson_surface_reconstruction( 17 | const Eigen::MatrixXd & P, 18 | const Eigen::MatrixXd & N, 19 | Eigen::MatrixXd & V, 20 | Eigen::MatrixXi & F); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "poisson_surface_reconstruction.h" 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | int main(int argc, char *argv[]) 13 | { 14 | // Load in points + normals from .pwn file 15 | Eigen::MatrixXd P,N; 16 | { 17 | Eigen::MatrixXd D; 18 | std::vector > vD; 19 | std::string line; 20 | std::fstream in; 21 | in.open(argc>1?argv[1]:"../data/hand.pwn"); 22 | while(in) 23 | { 24 | std::getline(in, line); 25 | std::vector row; 26 | std::stringstream stream_line(line); 27 | double value; 28 | while(stream_line >> value) row.push_back(value); 29 | if(!row.empty()) vD.push_back(row); 30 | } 31 | if(!igl::list_to_matrix(vD,D)) return EXIT_FAILURE; 32 | assert(D.cols() == 6 && "pwn file should have 6 columns"); 33 | P = D.leftCols(3); 34 | N = D.rightCols(3); 35 | } 36 | 37 | // Reconstruct mesh 38 | Eigen::MatrixXd V; 39 | Eigen::MatrixXi F; 40 | poisson_surface_reconstruction(P,N,V,F); 41 | 42 | // Create a libigl Viewer object to toggle between point cloud and mesh 43 | igl::opengl::glfw::Viewer viewer; 44 | std::cout< & G) 9 | { 10 | //////////////////////////////////////////////////////////////////////////// 11 | // Add your code here 12 | //////////////////////////////////////////////////////////////////////////// 13 | } 14 | -------------------------------------------------------------------------------- /src/fd_interpolate.cpp: -------------------------------------------------------------------------------- 1 | #include "fd_interpolate.h" 2 | 3 | void fd_interpolate( 4 | const int nx, 5 | const int ny, 6 | const int nz, 7 | const double h, 8 | const Eigen::RowVector3d & corner, 9 | const Eigen::MatrixXd & P, 10 | Eigen::SparseMatrix & W) 11 | { 12 | //////////////////////////////////////////////////////////////////////////// 13 | // Add your code here 14 | //////////////////////////////////////////////////////////////////////////// 15 | } 16 | -------------------------------------------------------------------------------- /src/fd_partial_derivative.cpp: -------------------------------------------------------------------------------- 1 | #include "fd_partial_derivative.h" 2 | 3 | void fd_partial_derivative( 4 | const int nx, 5 | const int ny, 6 | const int nz, 7 | const double h, 8 | const int dir, 9 | Eigen::SparseMatrix & D) 10 | { 11 | //////////////////////////////////////////////////////////////////////////// 12 | // Add your code here 13 | //////////////////////////////////////////////////////////////////////////// 14 | } 15 | -------------------------------------------------------------------------------- /src/poisson_surface_reconstruction.cpp: -------------------------------------------------------------------------------- 1 | #include "poisson_surface_reconstruction.h" 2 | #include 3 | #include 4 | 5 | void poisson_surface_reconstruction( 6 | const Eigen::MatrixXd & P, 7 | const Eigen::MatrixXd & N, 8 | Eigen::MatrixXd & V, 9 | Eigen::MatrixXi & F) 10 | { 11 | //////////////////////////////////////////////////////////////////////////// 12 | // Construct FD grid, CONGRATULATIONS! You get this for free! 13 | //////////////////////////////////////////////////////////////////////////// 14 | // number of input points 15 | const int n = P.rows(); 16 | // Grid dimensions 17 | int nx, ny, nz; 18 | // Maximum extent (side length of bounding box) of points 19 | double max_extent = 20 | (P.colwise().maxCoeff()-P.colwise().minCoeff()).maxCoeff(); 21 | // padding: number of cells beyond bounding box of input points 22 | const double pad = 8; 23 | // choose grid spacing (h) so that shortest side gets 30+2*pad samples 24 | double h = max_extent/double(30+2*pad); 25 | // Place bottom-left-front corner of grid at minimum of points minus padding 26 | Eigen::RowVector3d corner = P.colwise().minCoeff().array()-pad*h; 27 | // Grid dimensions should be at least 3 28 | nx = std::max((P.col(0).maxCoeff()-P.col(0).minCoeff()+(2.*pad)*h)/h,3.); 29 | ny = std::max((P.col(1).maxCoeff()-P.col(1).minCoeff()+(2.*pad)*h)/h,3.); 30 | nz = std::max((P.col(2).maxCoeff()-P.col(2).minCoeff()+(2.*pad)*h)/h,3.); 31 | // Compute positions of grid nodes 32 | Eigen::MatrixXd x(nx*ny*nz, 3); 33 | for(int i = 0; i < nx; i++) 34 | { 35 | for(int j = 0; j < ny; j++) 36 | { 37 | for(int k = 0; k < nz; k++) 38 | { 39 | // Convert subscript to index 40 | const auto ind = i + nx*(j + k * ny); 41 | x.row(ind) = corner + h*Eigen::RowVector3d(i,j,k); 42 | } 43 | } 44 | } 45 | Eigen::VectorXd g = Eigen::VectorXd::Zero(nx*ny*nz); 46 | 47 | //////////////////////////////////////////////////////////////////////////// 48 | // Add your code here 49 | //////////////////////////////////////////////////////////////////////////// 50 | 51 | //////////////////////////////////////////////////////////////////////////// 52 | // Run black box algorithm to compute mesh from implicit function: this 53 | // function always extracts g=0, so "pre-shift" your g values by -sigma 54 | //////////////////////////////////////////////////////////////////////////// 55 | igl::copyleft::marching_cubes(g, x, nx, ny, nz, V, F); 56 | } 57 | -------------------------------------------------------------------------------- /test.sh: -------------------------------------------------------------------------------- 1 | while IFS= read -r line; do 2 | 3 | echo "$line" 4 | cp submission/"$line/"*.cpp src/ 5 | # cp submission/"$line/"*.h include/ 6 | 7 | mkdir build"_$line" 8 | cd build"_$line" 9 | cmake .. -DCMAKE_BUILD_TYPE=Release 10 | make -j8 11 | 12 | cd ../ 13 | 14 | # exit 0 15 | 16 | done < hw2-namelist.txt 17 | 18 | 19 | # for d in * ; do 20 | 21 | # # echo "$d" 22 | # # # # # cp base_include/* include/ 23 | # # cp $d/*.cpp src/ 24 | # # # # cp submission/"$d/"*.h include/ 25 | # # # mkdir ../build"_$d" 26 | # # # cd ../build"_$d" 27 | # # # cmake .. -DCMAKE_BUILD_TYPE=Release 28 | # # # make -j8 29 | # # # cd ../submission 30 | 31 | # # echo $d/ 32 | 33 | # # # cd $d/ 34 | 35 | # # name = basename $d 36 | # echo $d >> ../hw2-namelist.txt 37 | 38 | # # exit 0 39 | 40 | # done -------------------------------------------------------------------------------- /tex/05af85763c308fe9dfd93f44e8149a59.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/08b11f4adf974a9005ff55cc8902bb6b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tex/0ee0c8e0c23693d9c6b800197f53ea56.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tex/1e500ed0738135b9e26f388580e20b32.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/2721b133f6f6619c279972b564b09689.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/2ad9d098b937e46f9f58968551adac57.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/2bbf4eee68fd087c4e89458ffc858ecb.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tex/2eacd907c22e9ad1db070a00eef0f2cd.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tex/2f11c6120fcb1f7a8dd90b5a25a7216b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/322d8f61a96f4dd07a0c599482268dfe.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/332cc365a4987aacce0ead01b8bdcc0b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/380c103b60c66d6420ec8923cdc6e6e8.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/384591906555413c452c93e493b2d4ec.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/3cf4fbd05970446973fc3d9fa3fe3c41.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/3e2a76e23fe9c67f0c6a1d099d494151.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tex/40ecdbad5a9ebcc6dae0bf86ffeddff6.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tex/41bf049c525434295c5c91ab03d41324.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/4636475863bb81bba2dddef66b454bdc.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tex/4695cb3c40f1831d62ab5a07ecb94255.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tex/473d4a136e73dec1b14f253176da2f53.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/4870d18d47ab6d0e32510c4b1ccf4927.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/5439c1794588f864d0fcccab4d28f058.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tex/55a049b8f161ae7cfeb0197d75aff967.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/5f3cc59831e6b4aef298a2dacada3fe7.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/6e9103d18236e9931449ce1f3a303f5c.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tex/7aed918aa12a276a602e30e90b0b109d.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/81ee55d5839b20e95d03b438b3a60dbd.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/894fe1065bc022997ddadbf01f0cf213.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /tex/8fc2223d19b0886790872904d6b97578.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tex/916be6a7b04723c1976ee484e8749dba.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/96eb4872da7497e849abf83ebc451a99.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tex/980fcd4213d7b5d2ffcc82ec78c27ead.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/985e9d424986b945b21cbfc30f69ee2c.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/98a6924bf931c3807f8deddadd870393.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/a9a3a4a202d80326bda413b5562d5cd1.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/abba53cfa4754e0fb3447fe5e0be0b78.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/ae44fa1818647ed39ba79b316ce5dd87.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/af1a2017f0a516c71e45ba5be7345029.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tex/b1467b64271e0e80be78cc8537d840cb.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /tex/b56595d2a30a0af329086562ca12d521.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/ba3f16549018145cc787dd0e73df1c2b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/bccab73005d96290c8ef588703533a21.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/bd8a3a3788c7e885e5bb709066e6888a.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /tex/c65df61fee36c4a70fabfa1397a6b34c.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tex/c888b5dd080ec7f68a997efb3ed6b96b.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/cffca7c1479a119f8929bf5726372e56.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/d30a65b936d8007addc9c789d5a7ae49.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/de359c205c9bfe1240b157e694922b0f.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /tex/deceeaf6940a8c7a5a02373728002b0f.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/ecb02abb9d3c72a23e6c3e776b8f3b53.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/f0c74577699a7ca84f8d507f9fd49d62.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /tex/f4e5add43718dd0d01e8a2cf425322f8.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /tex/f6fc3ac36dff143d4aac9d145fadc77e.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /tex/f8418a00a5940164cc6a57d88beceeab.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tex/f93ce33e511096ed626b4719d50f17d2.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | --------------------------------------------------------------------------------