Skip to content

This repository contains the source code associated with the paper Orientable Dense Cyclic Infill for Anisotropic Appearance Fabrication

License

Notifications You must be signed in to change notification settings

mfx-inria/anisotropic_appearance_fabrication

Repository files navigation

Orientable Dense Cyclic Infill for Anisotropic Appearance Fabrication - Code

Representative image of the repository

This repository contains the source code associated with the paper:

Orientable Dense Cyclic Infill for Anisotropic Appearance Fabrication

Xavier Chermain, Cédric Zanni, Jonàs Martínez, Pierre-Alexandre Hugron, and Sylvain Lefebvre

Université de Lorraine, CNRS, Inria, Loria

SIGGRAPH 2023, DOI: 10.1145/3592412

Our code has the Replicability Stamp:

Fill Space With Orientable Cycle - Our Algorithm

Overview image

Our code allows you to reproduce the results of our paper, whose objective is to fabricate anisotropic appearances with a filament printer and a glossy filament.

Our algorithm generates a continuous trajectory from an orientation field, a 2D shape, and spacing from adjacent paths. In other words, our algorithm fills a closed 2D space with an orientable cycle. The code is in the tools/fill_2d_shape.py file, and a usage example is in the tools/README.md.

The generated continuous trajectory is then given to a filament printer, which fabricates a 2D plate with oriented extruded filaments. The 2D object has an anisotropic appearance if a glossy filament is used.

Outline

Installation

Clone the Repository

To clone the code together with the iceslprinters dependency, be sure to use the --recursive flag when cloning the repository, i.e.

git clone --recursive https://github.com/mfx-inria/anisotropic_appearance_fabrication.git

If you accidentally already cloned the code without this argument, run the following command to fetch the dependency:

git submodule update --init --recursive

Install Python Module Dependencies

The code is written in Python 3.10, and it depends on

The versions specified before were used for producing the paper's results. The code may not work with Python < 3.10. A test with Python 3.6.8 was unsuccessful because pip install --user -e .`` required a setuptools`` version >= 64, and Python 3.6.8 only supports setuptools 59.6.0 at most.

You can use pip to install the dependencies. The following commands should be run from the repository root directory:

pip install --user --upgrade pip
pip install --user --upgrade "jax[cpu]"
pip install --user svgpathtools pyvista Pillow
pip install --user -e .

The most challenging dependency to install is JAX if you want GPU support. Please read its installation section for more information. The code was developed on Windows 10, with GPU support (see INSTALL_WIN10_GPU.txt for installation details).

Conda

For Conda users, you can try

conda env create -f environment.yml
conda activate fdm_aa
pip install --user -e .

to install the Python environment. On Windows, it did not work on our machine, but it works on Mac.

Results Reproduction

You can reproduce either the figure 1 or all the results of the paper on Windows by running either the script generate_results_figure_1.ps1 or the script generate_all_results.ps1, resp. Run the command Set-ExecutionPolicy -ExecutionPolicy Bypass command to make the .ps1 script runnable. By default, scripts cannot be run on PowerShell. For Linux users, use generate_results_figure_1.sh or generate_all_results.sh, resp.

The scripts generate the oriented cycles as SVG files in data/svg/cycle and as G-code files in data/gcode. You can visualize and check the paths in the generated G-code using Craftware or the online visualizer of IceSl. The G-codes are generated for a modified Creality3D CR-10S Pro with a BLTouch and direct drive extruder. The firmware used to print the results is Klipper. We recommend using an extrusion factor of 0.9 % and a filament printer with a direct drive extruder, as the trajectory has a varying length.

Note that the generated results are similar to the paper's but not identical. We refactored the code since we submitted the final version of the paper and we changed the random number generator.

OS and Backend

Our code was tested on

  • Windows 10 with GPU backend,
  • Ubuntu LTS 22.04 with CPU backend, and
  • MacOS, on a MacBook Pro M1 Max with Monterrey OS, with CPU backend.

Our code is written with JAX, which is designed for high-performance numerical computing. We chose it because it provides a familiar NumPy-style API and the same code can be executed on CPU and GPU. See the installation section of JAX to know if your OS and backend are supported.

Long Running Times

The execution time of the scripts can be considered long. For example, on Ubuntu LTS 22.04 with a CPU backend (AMD Ryzen 9 7950X 32 threads), on Windows 10 with a GPU backend (NVIDIA RTX 2080 with Intel Core i7-4770K CPU) and on MaxOS with CPU backend, the execution times of the scripts generate_results_figure_1.sh and generate_all_results.sh are around 250 seconds and 35 minutes, resp. With an AMD Ryzen Threadripper 2990WX 32-Core/64 threads CPU, the total runtime was 57 min for generate_all_results.ps1.

JAX compiles functions to speed the execution, but the compilation time is linear with the data size, as shown by the paper Dr.Jit: A Just-In-Time Compiler for Differentiable Rendering, Figure 17, top right. In addition, JAX recompiles functions each time the code is launched because the compilation cache is still an experimental feature: google/jax#13736. See the logs in data/log to know the execution and compilation times.

Warnings and Errors

XLA, used by JAX, can print a too long compilation time warning, i.e., Constant folding an instruction is taking > 1s.

When using the GPU, the following error can appear:

LLVM ERROR: IMAGE_REL_AMD64_ADDR32NB relocation requires an ordered section layout

Quick "fix": rerun.

See tensorflow/tensorflow#56207.

G-codes of the Paper's Results

We can download the G-codes of the paper's results with this link: https://drive.google.com/file/d/18oH3z5xaFOeRKn6aXpxDUmBwcsN7m1Eb/view?usp=sharing. The G-codes were generated for a modified Creality3D CR-10S Pro with a BLTouch and direct drive extruder. The firmware used to print the results is Klipper. The extrusion factor was 0.9.

Filaments and Nozzle

We test our method with the following filaments:

We used filaments with 1.75 mm diameter.

The references of the 0.4 and 0.8 nozzles are: Bondtech CHT MOS Coated Brass Nozzle.

Folder Organization

  • tools: Contain tools, e.g., fill_2d_shape.py which is the algorithm 1 of the paper. See the tools/README.md to know the tools list.
  • src: Contain the source code of the local cglib library, which contains core functionalities. You can also find tools/togcode.py's theoretically supported printers at src/ext/iceslprinters/fff.
  • data: Contain the data needed by the repository. See data/README.md for more informations. There is no data restriction usage.
  • examples: Contain a few examples of src/cglib function usage.
  • tests: Contain the tests of the local cglib library. Can be used as example usages of cglib's functions.

Anisotropic Appearance Representation

The anisotropic appearance is represented with an orientation field, defining the orientation of anisotropy for each point of a 2D shape. The most common material exhibiting an anisotropic appearance is brushed metal. The orientation of anisotropy can be seen as the brushing orientation of the metal. This input is represented as a PNG grayscale image (8 bits per pixel), whose pixel value is mapped to an orientation angle in $[-\pi / 2, \pi / 2)$. Examples of orientation/line fields are located in data/png, and a detailed description of this input can be found in the parameter description (see line_field_path parameter).

Direction Mode Maps

Paper teaser image

Four types of orientation can be prescribed with a direction mode map:

  • Parallel to the border (red areas in the previous figure),
  • orthogonal to the border (blue areas in the previous figure),
  • smoothest (yellow areas in the previous figure), or
  • constrained (color gradient areas in the previous figure).

These four modes are represented with a PNG grayscale image (8 bits per pixel), whose pixel value is mapped to one of the four modes. Examples of direction mode maps are located in data/png, and a detailed description of this input can be found in the parameter description (see line_mode_field_path parameter).

2D Shape Representation

The 2D shape is represented as a polygonal chain, encoded as a SVG file. Examples of 2D shapes are located in data/svg, and a description of this input can be found in the data/svg/README.md.

How to Cite

If you use our algorithm, please cite it using the following BibTeX entry:

@article{Chermain2023Orientable,
author = {Chermain, Xavier and Zanni, C{\'e}dric and Mart{\'i}nez, Jon{\`a}s and Hugron, Pierre-Alexandre and Lefebvre, Sylvain},
title = {Orientable Dense Cyclic Infill for Anisotropic Appearance Fabrication},
year = {2023},
volume = {42},
number = {4},
doi = {10.1145/3592412},
articleno = {68},
journal = {ACM Trans. Graph. (Proc. SIGGRAPH)},
numpages = {13}
}

License

The source code is under the BSD 3-Clause "New" or "Rivised" license. See LICENSE for more details.

Acknowledgments

We thank the reviewers of the Graphics Replicability Stamp Initiative (GRSI) for their valuable comments improving the replicability of our method.

About

This repository contains the source code associated with the paper Orientable Dense Cyclic Infill for Anisotropic Appearance Fabrication

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages