Abstract
Constructive Solid Geometry (CSG) defines complex shapes by recursively applying boolean operations on primitives. We present CSGNet, a deep network architecture that takes a 2D or 3D shape as input and outputs a CSG program. Parsing shapes into CSG programs yields compact, interpretable models, but the search space is prohibitively large. CSGNet uses a convolutional encoder and recurrent decoder to map shapes to instructions in a feed-forward manner, significantly faster than bottom-up approaches. We investigate two architectures: a vanilla CNN-RNN and a stack-augmented version. The stack augmentation improves reconstruction quality and learning efficiency. Finally, we demonstrate that CSGNet can be trained on novel datasets without program annotations using policy gradient techniques.
Introduction
In geometric modeling, Constructive Solid Geometry (CSG) is a fundamental technique where complex objects are constructed by applying boolean operations—union, intersection, and subtraction—to simple primitives like spheres, cylinders, and cubes. While low-level representations like voxel grids or point clouds are common in deep learning, they lack the semantic interpretability and editability inherent in CSG.
The "inverse CSG" problem—reconstructing the sequence of operations that produced a given shape—is computationally expensive. Traditional methods rely on exhaustive or heuristic searches through an exponential space of possible programs. CSGNet addresses this by treating shape parsing as a translation task, mapping visual input directly to a sequence of modeling instructions.
Architectural Design
The authors propose two primary neural architectures for shape parsing:
- CSGNet (Vanilla): This model follows a standard encoder-decoder paradigm. A Convolutional Neural Network (CNN) encodes the input shape (2D image or 3D voxel grid) into a latent feature vector. A Recurrent Neural Network (RNN), specifically a Gated Recurrent Unit (GRU), then decodes this vector into a sequence of program tokens.
- CSGNetStack: This advanced variant introduces an explicit execution stack. Instead of relying solely on the initial encoding, the model observes the "rendered" state of the program-in-progress at each step. This visual feedback acts as a memory module, allowing the decoder to reason about what has already been built before selecting the next primitive or operation.
The inclusion of the stack significantly enhances performance. Empirically, CSGNetStack achieved higher accuracy with only 5% of the training data compared to the vanilla model using the full dataset, highlighting the efficiency of providing explicit state information to the network.
Training Methodologies
CSGNet can be trained using different paradigms depending on data availability:
- Supervised Learning: When ground-truth programs are available (e.g., in synthetic datasets), the model is trained using standard cross-entropy loss to match the target program sequence.
- Reinforcement Learning (RL): For real-world datasets like CAD models from the Trimble 3D Warehouse, which lack program labels, the authors employ the REINFORCE algorithm. The model receives a reward based on the Chamfer Distance or Intersection-over-Union (IoU) between the target shape and the shape rendered by the predicted program.
- Refinement: A post-processing step fine-tunes the continuous parameters (position, scale) of the predicted primitives to further maximize the visual similarity to the input.
Key Results and Insights
The research demonstrates several advantages of neural shape parsing:
- Amortized Inference: By learning the mapping from shapes to programs, CSGNet replaces slow search processes with a fast, feed-forward pass. This makes it orders of magnitude faster than traditional optimization-based inverse CSG methods.
- Superior Primitive Detection: CSGNet outperforms specialized object detectors like Faster R-CNN in identifying primitives. The authors suggest that by reasoning about how parts combine to form a whole, the model gains a more robust understanding of geometry than detectors that look at parts in isolation.
- Generalization: The model successfully parses complex 2D web logos and 3D CAD models, showing that RL-based domain adaptation allows it to generalize beyond synthetic training data.
Conclusion and Future Work
CSGNet provides a bridge between raw geometric data and interpretable CAD-like representations. While currently limited by a fixed grammar and challenges with very long programs, it represents a significant step toward automated reverse engineering of 3D designs. Future work may involve expanding the grammar to include more complex operations like sweeps or free-form deformations, further narrowing the gap between raw scans and professional modeling software.
Summary updated