yijiangh / InverseCSG

Code mirror of the paper: InverseCSG: Automatic Conversion of 3D Models to CSG Trees

Home Page:https://people.csail.mit.edu/taodu/csg/csg.pdf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InverseCSG: automatic conversion of 3D models to CSG trees

CI

This folder provides a snapshot of the code with the paper "InverseCSG: automatic conversion of 3D models to CSG trees" when it was submitted to Siggraph Asia 2018.

The current repository is modified from the original code snapshot recovered from the supplementary material hosted on the ACM digital library. Any changes in this repo are those of the authors of this forked repo and do not necessarily reflect the views of the original authors.

Platform

Dependencies

  • C++ toolchain: sudo apt-get install build-essential autoconf libtool flex bison mercurial zsh cmake.
  • Python 3.7+ (required by the latest sklearn)
    • using a python distribution within a conda environment is highly recommended. You can follow this tutorial to install miniconda on an ubuntu OS instance. Then, create and activate a conda environment with python 3.7 by:
    conda create -n inv_csg_env python=3.7 
    conda activate inv_csg_env
    python3 --version
    # you should see "Python 3.7.7"
    
  • The latest Sketch.
  • Java >= 1.8 (needed by Sketch).
  • maven >= 2.2.1 (needed by Sketch).

Installation

Automatic installation

The easiest way is to navigate to the root folder and run:

python3 install.py -d <build_folder>
# e.g. python3 install.py -d ./build

where build_folder can be any folder that you have write access to. We recommend you use a build_folder outside the root folder. This Python script will compile the source code in cpp/ and attempt to install any missing dependencies, which might need your sudo privilege.

You can see more options by python3 install.py -h.

Manual installation

You can also choose to do a manual installation if `install.py` fails to finish successfully.
  • Run

    sudo apt-get install build-essential autoconf libtool flex bison mercurial zsh cmake
  • Navigate to your build_folder, create a cpp subfolder, and compile the C++ code:

    cd <build_folder>
    mkdir cpp
    cd cpp
    cmake <root_folder>/cpp
    make
  • Follow the instructions in sketch-backend and sketch-frontend to install Sketch. More info can be found at Prof. Armando Solar-Lezama's webpage.

Test

If the installation is successful, you can navigate to the root folder and try running:

python3 run_tests.py <build_folder> one_cube

This solves a simple cube. The whole process should finish within a minute. You can replace one_cube with other example names rerun the command. Please see run_tests.py for all example names.

If you want to see some quick results, you can try:

python3 run_tests.py <build_folder> ex_011
python3 run_tests.py <build_folder> ex_067
python3 run_tests.py <build_folder> ex_096
python3 run_tests.py <build_folder> ex_144
python3 run_tests.py <build_folder> ex_145

Examples

The dataset of our 50 CAD models can be found in the example folder.

Solutions

The solutions to all of our examples are in the solution folder. Each subfolder has two SCAD files: sketch.scad is the output of our method before simplification, and sketch_final.scad is the final resuls after simplification.

When you use OpenSCAD to open and render these solutions, you will notice there are a lot of degenerated planes. These planes come from a CSG intersection or difference operation that applies to two solids with same dimensions. To illustrate this point, consider subtracting a cylinder from the center of a cube that happens to have the same height, then the top and bottom circles of the cylinder can be either considered inside or outside the solution and the behavior is therefore undefined. As a result, these artifacts do not mean our solutions have an volumetric error.

Citation

If you find this work useful, please cite:

@article{du2018inversecsg,
  title={Inversecsg: Automatic conversion of 3d models to csg trees},
  author={Du, Tao and Inala, Jeevana Priya and Pu, Yewen and Spielberg, Andrew and Schulz, Adriana and Rus, Daniela and Solar-Lezama, Armando and Matusik, Wojciech},
  journal={ACM Transactions on Graphics (TOG)},
  volume={37},
  number={6},
  pages={1--16},
  year={2018},
  publisher={ACM New York, NY, USA}
}

About

Code mirror of the paper: InverseCSG: Automatic Conversion of 3D Models to CSG Trees

https://people.csail.mit.edu/taodu/csg/csg.pdf


Languages

Language:C++ 51.4%Language:OpenSCAD 31.0%Language:Python 15.1%Language:MATLAB 2.5%Language:CMake 0.1%