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:
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.
- Installation
- Results Reproduction
- Folder Organization
- Anisotropic Appearance Representation
- 2D Shape Representation
- How to Cite
- License
- Acknowledgments
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
The code is written in Python 3.10, and it depends on
- JAX 0.3.17,
- svgpathtools 1.6,
- pyvista 0.39,
- Pillow 9.5, and
- the local library
src/cglib
.
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).
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.
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.
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.
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: jax-ml/jax#13736. See the logs in data/log
to know the execution and compilation times.
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.
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.
We test our method with the following filaments:
- Arianeplast
- Clear PETG, FPETGTR1175 (used for roughness measurements, Sec. 3)
- PLA+ Bleu/Gris. FPLABLGR2175 (used for roughness measurements, Sec. 3)
- Form Futura
- High Gloss PLA
- Gold (Fig. 4, 12 middle, 15 bunny and teapot)
- Silver (Fig. 1, 2, 12 right, 13, 15 QR code)
- Silk Gloss PLA Brillant Blue (used for roughness measurements, Sec. 3, Fig. 5)
- HDglass PETG. See Through Red (used for roughness measurements, Sec. 3)
- High Gloss PLA
- Polymaker. PolyLite PLA. Silk Blue (Fig. 11, 12 left, 15 monkey and dragon)
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.
tools
: Contain tools, e.g.,fill_2d_shape.py
which is the algorithm 1 of the paper. See thetools/README.md
to know the tools list.src
: Contain the source code of the localcglib
library, which contains core functionalities. You can also findtools/togcode.py
's theoretically supported printers atsrc/ext/iceslprinters/fff
.data
: Contain the data needed by the repository. Seedata/README.md
for more informations. There is no data restriction usage.examples
: Contain a few examples ofsrc/cglib
function usage.tests
: Contain the tests of the localcglib
library. Can be used as example usages ofcglib
's functions.
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 line_field_path
parameter).
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).
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.
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}
}
The source code is under the BSD 3-Clause "New" or "Rivised" license. See LICENSE for more details.
We thank the reviewers of the Graphics Replicability Stamp Initiative (GRSI) for their valuable comments improving the replicability of our method.