Abstract
We present a neural architecture that takes as input a 2D or 3D shape and outputs a program that generates the shape. The instructions in our program are based on constructive solid geometry principles, i.e., a set of boolean operations on shape primitives defined recursively. Bottom-up techniques for this shape parsing task rely on primitive detection and are inherently slow since the search space over possible primitive combinations is large. In contrast, our model uses a recurrent neural network that parses the input shape in a top-down manner, which is significantly faster and yields a compact and easy-to-interpret sequence of modeling instructions. Our model is also more effective as a shape detector compared to existing state-of-the-art detection techniques. We finally demonstrate that our network can be trained on novel datasets without ground-truth program annotations through policy gradient techniques.
Introduction
While deep learning has become highly proficient at generating shapes as pixels, voxels, or point clouds, these low-level representations are often difficult for human designers to manipulate. Real-world CAD modeling typically relies on Constructive Solid Geometry (CSG)—the process of creating complex objects by combining simple shapes (primitives) using boolean logic like union, intersection, and subtraction.
Parsing a raw image back into a CSG "recipe" is traditionally a computationally expensive task. Existing "bottom-up" methods attempt to detect every possible primitive and then determine their assembly, leading to an exponential search space. CSGNet addresses this by adopting a "top-down" approach: a neural network that "reads" a shape and "writes" the program required to recreate it.
Methods
The core of CSGNet is an Encoder-Decoder architecture designed to translate visual data into a domain-specific language.
- Encoder: A standard CNN (for 2D inputs) or 3D-CNN (for 3D voxel grids) extracts a high-level feature vector from the input shape.
- Decoder: A Recurrent Neural Network (RNN), specifically using Gated Recurrent Units (GRU), processes these features to predict a sequence of instructions. These instructions follow a strict Context-Free Grammar (e.g.,
P1 = circle(x,y,r),E1 = union(P1, P2)).
Training Strategy
To achieve robust performance, the model is trained in two stages. First, Supervised Pre-training is conducted on a massive synthetic dataset where ground-truth programs are known. Second, to handle real-world data lacking original code, the model employs Reinforcement Learning (RL) via the REINFORCE algorithm. The model generates a program, renders it, and receives a "reward" based on the visual similarity (measured via Chamfer Distance) between the rendered result and the target image. This bypasses the need for a differentiable rendering engine. Finally, a visually-guided refinement step fine-tunes the coordinates and sizes of the primitives to maximize the visual fit.
Key Insights and Results
CSGNet demonstrates that programs are superior representations for geometry because they are inherently editable and resolution-independent. By using an RNN to parse the shape top-down, the model avoids the combinatorial explosion of bottom-up search, deciding the most likely first step by looking at the global shape.
Performance Metrics
- Reconstruction Accuracy: CSGNet significantly outperformed Nearest Neighbor baselines. On CAD datasets, RL fine-tuning reduced the Chamfer Distance error from 1.60 to 1.14.
- Detection Performance: Surprisingly, CSGNet acts as a superior object detector. It achieved a Mean Average Precision (mAP) of 84.3 on 2D primitive detection, surpassing Faster R-CNN's 80.1. This is because CSGNet reasons about how shapes interact (e.g., identifying a hole as a subtracted circle) rather than just identifying bounding boxes.
- Efficiency: The model is remarkably fast. While Faster R-CNN processed 5 images per second, CSGNet (with a beam size of 10) processed 80 images per second.
Conclusion
CSGNet provides a compact, interpretable, and efficient way to parse visual shapes into modeling instructions. While currently limited to a small set of basic primitives and program lengths of approximately 13 instructions, it opens the door for more sophisticated CAD automation. Future work will explore larger primitive libraries and combining top-down neural parsing with bottom-up proposals to handle more organic and complex geometries.
Summary updated