Code Monkey home page Code Monkey logo

manifold's Introduction

Watertight Manifold

Source code for the paper:

Huang, Jingwei, Hao Su, and Leonidas Guibas. Robust Watertight Manifold Surface Generation Method for ShapeNet Models., arXiv preprint arXiv:1802.01698 (2018).

News!

An advanced version has been released in this new repo.

ShapeNet Manifold Dataset

We prepare the manifold data for 13 categories from ShapeNetCore. You can download them by running the following script.

wget http://download.cs.stanford.edu/orion/Shapenet_Manifold/categories.txt
wget -i categories.txt

Install and Run

For Linux and Mac users, run sh demo.sh to build and try the manifold example.

Install

git clone --recursive -j8 git://github.com/hjwdzh/Manifold
cd Manifold
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make

Manifold Software

We take a triangle mesh "input.obj" and generate a manifold "output.obj". The resolution is the number of leaf nodes of octree. The face number increases linearly with the resolution.

./manifold input.obj output.obj [resolution (Default 20000)]

Simplify Algorithm

Our manifold software generates uniform manifold. For efficiency purpose, a mesh simplification can be used.

./simplify -i input.obj -o output.obj [-m] [-f face_num] [-c max_cost] [-r max_ratio]

Where:

  -m            Turn on manifold check, we don't output model if check fails
  -f face_num   Add termination condition when current_face_num <= face_num
  -c max_cost   Add termination condition when quadric error >= max_cost
  -r max_ratio  Add termination condition when current_face_num / origin_face_num <= max_ratio

Example:

./simplify -i input.obj -o output.obj -m -c 1e-2 -f 10000 -r 0.2

Authors

© Jingwei Huang, Stanford University

IMPORTANT: If you use this software please cite the following in any resulting publication:

@article{huang2018robust,
  title={Robust Watertight Manifold Surface Generation Method for ShapeNet Models},
  author={Huang, Jingwei and Su, Hao and Guibas, Leonidas},
  journal={arXiv preprint arXiv:1802.01698},
  year={2018}
}

manifold's People

Contributors

hjwdzh avatar quebin31 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

manifold's Issues

Crash when processing a post-processed shapenet file

Hi,
I've postprocessed shapenet models, using the mesh fusion ( https://github.com/davidstutz/mesh-fusion ) library, in order to add "thickness" to the shapenet model to avoid very thin regions.

Here is an example:
u1e22cc04-7c4d-4ed5-bda3-8ff8067f22ee.zip

When I later try to simplify them (and keep them watertight), I get a crash with the simplify tool:

simplify -i u1e22cc04-7c4d-4ed5-bda3-8ff8067f22ee.obj -o u1e22cc04-7c4d-4ed5-bda3-8ff8067f22ee_65536.obj -m -f 65536

simplify: /home/noamgat/hdd/Manifold/3rd/igl/per_vertex_point_to_plane_quadrics.cpp:83: igl::per_vertex_point_to_plane_quadrics(const MatrixXd&, const MatrixXi&, const MatrixXi&, const MatrixXi&, const MatrixXi&, std::vector<std::tuple<Eigen::Matrix<double, -1, -1, 0, -1, -1>, Eigen::Matrix<double, 1, -1, 1, 1, -1>, double> >&)::<lambda(const RowVectorXd&, const MatrixXd&, double)>: Assertion `std::abs(S.row(j).dot(ei)) < 1e-10' failed.
Aborted (core dumped)

This is consistent across all models. They are watertight (MeshlabServer is able to compute their volume, which is only possible for watertight meshes).

Any idea why this is happening?

Closest Point

In the function Model_OBJ::Closest_Point( const glm::dvec3 *triangle, const glm::dvec3 &sourcePosition ), We classify closest point according (s + t < det ) and sign(s) , sign(r), sign(d). I cannot catch them, Could you give me some guidance on it? Thank you!

High resolution puts triangles on octree sides?

Hi, here is a probably simple question about manifold:

I have a mesh that with resolution 20000 looks like this:

image

But with resolution 500000 it degenerates like this:

image

Notice how "cuboid structures" form, instead of the mesh being a continuous surface?

Up close it looks like this from the side:

image

Do you know why this happens?

cmake does not generate makefile on windows

Hi,

I am trying to setup this up on windows machine. below is the output of cmake command -

$ cmake ..
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.24.28315.0
-- The CXX compiler identification is MSVC 19.24.28315.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/jay/Lab/Manifold/build

then i tried to run make command, got this error -

$ make
make: *** No targets specified and no makefile found.  Stop.

I tried this but no luck -

$ cmake -G "Visual Studio 16 2019" ..
-- The C compiler identification is MSVC 19.24.28315.0
-- The CXX compiler identification is MSVC 19.24.28315.0
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.24.28314/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/jay/Lab/Manifold/build

I tried this also but didn't work -

$ cmake .. -G"Unix Makefiles"
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.


CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.


-- Configuring incomplete, errors occurred!
See also "C:/Users/jay/Lab/Manifold/build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/jay/Lab/Manifold/build/CMakeFiles/CMakeError.log".

Can anyone please help/guide.

simplify: Assertion failed: "V should have 3 columns"

The simplify program crashes on this obj.

My input:

Manifold/build/simplify -i teapot.obj -o tea.obj -m -f 1000

output:

Output is a manifold!
Assertion failed: (V.cols() == 3 && "V should have 3 columns"), function writeOBJ, file /Users/bilibili/code/sphere-set/Manifold/3rd/igl/writeOBJ.cpp, line 108.
Abort trap: 6

I used sh demo.sh to build it on macOS 10.14.6 (clang-1001.0.46.4).

Not really a big issue for me, since I can simplify other objs as well as outputs from manifold. But I guess there's something that can be fixed.

Missing "cd Manifold"

Hey,
thank you very much for your code and the help. In the installation guide, you missed to write 'cd Manifold' before 'mkdir build'. It might be clear for cmake-experienced people but I have spent hours to find the mistake.

If you could correct this, it would be really great. Thank you!

cannot handle a single plane & artifacts

Thanks for the useful implementation.

However, it seems that sometimes the code cannot handle the single planes, where the cubes failed to intersect with the plane.
Screenshot from 2020-04-19 23-51-44

Also, there seems to be some strange artifacts.
Input:
Screenshot from 2020-04-19 23-49-23

Sharp output without projection:
Screenshot from 2020-04-19 23-49-19
Is there any explanation for the artifacts?

Unsupported file format: .

I used simplify on ModelNet40 files converted to obj format, but all of them had the following problems
Output is a manifold!
Unsupported file format: ..
input file:/home/lw/3D/MeshNet2/datasets/ModelNet40_obj/airplane/train/airplane_0006.obj
output path:ModelNet40/airplane/train/

Python binding available

Hello there, although I'm not actively using this code anymore if anyone is here looking for python bindings you might have a look at the wrapper I did some time ago.

I hope this helps!

Best wishes and thanks for sharing your implementation, feel free to close this issue

How to use the bvh

Dear author,

I noticed you seem to have implemented the bvh algorithm but it failed in some test cases. is the implementation complete?

Cheers,

Little wrong with readme.md

git clone --recursive -j8 git://github.com/hjwdzh/Manifold
cd Manifold
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release
make
image

Here should be
git clone --recursive -j8 https://github.com/hjwdzh/Manifold.git cd Manifold mkdir build cd build cmake .. -D CMAKE_BUILD_TYPE=Release

Maybe missing a space.
And for some reason, I can use
git clone --recursive -j8 https://github.com/hjwdzh/Manifold.git Cloning into 'Manifold'... remote: Enumerating objects: 2121, done. remote: Total 2121 (delta 0), reused 0 (delta 0), pack-reused 2121 Receiving objects: 100% (2121/2121), 4.45 MiB | 5.57 MiB/s, done. Resolving deltas: 100% (521/521), done.

but this will fail:
git clone --recursive -j8 git://github.com/hjwdzh/Manifold.git Cloning into 'Manifold'... fatal: unable to connect to github.com: github.com[0: 20.205.243.166]: errno=Unknown error

[fixed] Problem with installation

Hey there!

When i run the sh demo.sh I get the following error:
[...]
[ 28%] Linking CXX executable simplify
CMakeFiles/simplify.dir/src/simplify.cpp.o: In function _ZNSt6threadC1IRKZN3igl12parallel_forImZNS1_12parallel_forImZNS1_16unique_simplicesIN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_NS6_IiLin1ELi1ELi0ELin1ELi1EEES8_EEvRKNS5_10MatrixBaseIT_EERNS5_15PlainObjectBaseIT0_EERNSE_IT1_EERNSE_IT2_EEEUlRmE_EEbSA_RKSF_mEUlmE_ZNS3_ImSP_EEbSA_SR_mEUlmmE0_SS_EEbSA_SR_RKSI_RKSL_mEUlmmmE_JSO_SO_SO_EEEOSA_DpOT0_': simplify.cpp:(.text._ZNSt6threadC2IRKZN3igl12parallel_forImZNS1_12parallel_forImZNS1_16unique_simplicesIN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_NS6_IiLin1ELi1ELi0ELin1ELi1EEES8_EEvRKNS5_10MatrixBaseIT_EERNS5_15PlainObjectBaseIT0_EERNSE_IT1_EERNSE_IT2_EEEUlRmE_EEbSA_RKSF_mEUlmE_ZNS3_ImSP_EEbSA_SR_mEUlmmE0_SS_EEbSA_SR_RKSI_RKSL_mEUlmmmE_JSO_SO_SO_EEEOSA_DpOT0_[_ZNSt6threadC5IRKZN3igl12parallel_forImZNS1_12parallel_forImZNS1_16unique_simplicesIN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_NS6_IiLin1ELi1ELi0ELin1ELi1EEES8_EEvRKNS5_10MatrixBaseIT_EERNS5_15PlainObjectBaseIT0_EERNSE_IT1_EERNSE_IT2_EEEUlRmE_EEbSA_RKSF_mEUlmE_ZNS3_ImSP_EEbSA_SR_mEUlmmE0_SS_EEbSA_SR_RKSI_RKSL_mEUlmmmE_JSO_SO_SO_EEEOSA_DpOT0_]+0xd5): undefined reference to pthread_create'
CMakeFiles/simplify.dir/src/simplify.cpp.o: In function _ZNSt6threadC1IRKZN3igl12parallel_forImZNS1_12parallel_forImZNS1_16unique_simplicesIN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_NS6_IiLin1ELi1ELi0ELin1ELi1EEES8_EEvRKNS5_10MatrixBaseIT_EERNS5_15PlainObjectBaseIT0_EERNSE_IT1_EERNSE_IT2_EEEUlRmE_EEbSA_RKSF_mEUlmE_ZNS3_ImSP_EEbSA_SR_mEUlmmE0_SS_EEbSA_SR_RKSI_RKSL_mEUlmmmE_JSO_RKmSO_EEEOSA_DpOT0_': simplify.cpp:(.text._ZNSt6threadC2IRKZN3igl12parallel_forImZNS1_12parallel_forImZNS1_16unique_simplicesIN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_NS6_IiLin1ELi1ELi0ELin1ELi1EEES8_EEvRKNS5_10MatrixBaseIT_EERNS5_15PlainObjectBaseIT0_EERNSE_IT1_EERNSE_IT2_EEEUlRmE_EEbSA_RKSF_mEUlmE_ZNS3_ImSP_EEbSA_SR_mEUlmmE0_SS_EEbSA_SR_RKSI_RKSL_mEUlmmmE_JSO_RKmSO_EEEOSA_DpOT0_[_ZNSt6threadC5IRKZN3igl12parallel_forImZNS1_12parallel_forImZNS1_16unique_simplicesIN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_NS6_IiLin1ELi1ELi0ELin1ELi1EEES8_EEvRKNS5_10MatrixBaseIT_EERNS5_15PlainObjectBaseIT0_EERNSE_IT1_EERNSE_IT2_EEEUlRmE_EEbSA_RKSF_mEUlmE_ZNS3_ImSP_EEbSA_SR_mEUlmmE0_SS_EEbSA_SR_RKSI_RKSL_mEUlmmmE_JSO_RKmSO_EEEOSA_DpOT0_]+0xd5): undefined reference to pthread_create'
CMakeFiles/simplify.dir/src/simplify.cpp.o: In function _ZNSt6threadC1IRKZN3igl12parallel_forIiZNS1_12parallel_forIiZNS1_5sort3IN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_S7_EEvRKNS5_9DenseBaseIT_EEibRNS5_15PlainObjectBaseIT0_EERNSD_IT1_EEEUlRKiE_EEbS9_RKSE_mEUlmE_ZNS3_IiSM_EEbS9_SO_mEUlimE0_SP_EEbS9_SO_RKSH_RKT2_mEUliimE_JRiSZ_RmEEEOS9_DpOT0_': simplify.cpp:(.text._ZNSt6threadC2IRKZN3igl12parallel_forIiZNS1_12parallel_forIiZNS1_5sort3IN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_S7_EEvRKNS5_9DenseBaseIT_EEibRNS5_15PlainObjectBaseIT0_EERNSD_IT1_EEEUlRKiE_EEbS9_RKSE_mEUlmE_ZNS3_IiSM_EEbS9_SO_mEUlimE0_SP_EEbS9_SO_RKSH_RKT2_mEUliimE_JRiSZ_RmEEEOS9_DpOT0_[_ZNSt6threadC5IRKZN3igl12parallel_forIiZNS1_12parallel_forIiZNS1_5sort3IN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_S7_EEvRKNS5_9DenseBaseIT_EEibRNS5_15PlainObjectBaseIT0_EERNSD_IT1_EEEUlRKiE_EEbS9_RKSE_mEUlmE_ZNS3_IiSM_EEbS9_SO_mEUlimE0_SP_EEbS9_SO_RKSH_RKT2_mEUliimE_JRiSZ_RmEEEOS9_DpOT0_]+0xc6): undefined reference to pthread_create'
CMakeFiles/simplify.dir/src/simplify.cpp.o: In function _ZNSt6threadC1IRKZN3igl12parallel_forIiZNS1_12parallel_forIiZNS1_5sort3IN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_S7_EEvRKNS5_9DenseBaseIT_EEibRNS5_15PlainObjectBaseIT0_EERNSD_IT1_EEEUlRKiE_EEbS9_RKSE_mEUlmE_ZNS3_IiSM_EEbS9_SO_mEUlimE0_SP_EEbS9_SO_RKSH_RKT2_mEUliimE_JRiSL_RmEEEOS9_DpOT0_': simplify.cpp:(.text._ZNSt6threadC2IRKZN3igl12parallel_forIiZNS1_12parallel_forIiZNS1_5sort3IN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_S7_EEvRKNS5_9DenseBaseIT_EEibRNS5_15PlainObjectBaseIT0_EERNSD_IT1_EEEUlRKiE_EEbS9_RKSE_mEUlmE_ZNS3_IiSM_EEbS9_SO_mEUlimE0_SP_EEbS9_SO_RKSH_RKT2_mEUliimE_JRiSL_RmEEEOS9_DpOT0_[_ZNSt6threadC5IRKZN3igl12parallel_forIiZNS1_12parallel_forIiZNS1_5sort3IN5Eigen6MatrixIiLin1ELin1ELi0ELin1ELin1EEES7_S7_EEvRKNS5_9DenseBaseIT_EEibRNS5_15PlainObjectBaseIT0_EERNSD_IT1_EEEUlRKiE_EEbS9_RKSE_mEUlmE_ZNS3_IiSM_EEbS9_SO_mEUlimE0_SP_EEbS9_SO_RKSH_RKT2_mEUliimE_JRiSL_RmEEEOS9_DpOT0_]+0xc6): undefined reference to pthread_create'
collect2: error: ld returned 1 exit status
CMakeFiles/simplify.dir/build.make:94: recipe for target 'simplify' failed
make[2]: *** [simplify] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/simplify.dir/all' failed
make[1]: *** [CMakeFiles/simplify.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Any ideas on why that happens or how to fix that?

Best,
Jeremy

EDIT: adding -pthread to:
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pthread")
in CMakeLists.txt fixes it (Kudos to Simon Donne)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.