# 构造实体几何

构造实体几何（constructive solid geometry，CSG）是一种实体建模技术，它通过集合运算——并集、交集和差集——配合定位与尺寸变换，把长方体、球体、圆柱体、圆锥体和圆环体等较简单的实体基本体组合成复杂的三维物体。<sup>[1](https://www.sathyabama.ac.in/sites/default/files/course-material/2020-10/note_1493621926_0.pdf)</sup><sup> • </sup><sup>[2](https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/model/csg.html)</sup> 它是计算机辅助设计（CAD）中两大主流表示方案之一，另一方案为边界表示（B-Rep），后者通过面、边和顶点显式地存储实体。<sup>[3](https://doi.org/10.1016/j.camwa.2017.01.027)</sup>

| 关键事实 | 细节 |
|---|---|
| 定义 | 复杂实体（表面与内部一并）被建模为较简单对象的布尔组合<sup>[4](https://collaborate.princeton.edu/en/publications/an-efficient-algorithm-for-finding-the-csg-representation-of-a-si/)</sup> |
| 数据结构 | 一棵二叉树（CSG 树），其终端节点是基本体，非终端节点是正则化布尔运算：并集、差集、交集<sup>[5](https://www.globalspec.com/reference/62783/203279/chapter-11-complex-model-construction)</sup> |
| 典型基本体 | 长方体、球体、圆柱体、圆锥体和圆环体，在调用布尔算子之前先完成定位和尺寸设定<sup>[1](https://www.sathyabama.ac.in/sites/default/files/course-material/2020-10/note_1493621926_0.pdf)</sup> |
| 对机械零件的覆盖能力 | 在一项针对机械要素的调查中，90% 至 95% 的零件都能用这些简单基本体通过 CSG 准确表示<sup>[1](https://www.sathyabama.ac.in/sites/default/files/course-material/2020-10/note_1493621926_0.pdf)</sup> |
| 制造类比 | 差集相当于钻孔或机加工；并集相当于焊接一类的操作<sup>[1](https://www.sathyabama.ac.in/sites/default/files/course-material/2020-10/note_1493621926_0.pdf)</sup> |
| 边界求值 | 各基本体的表面通过边界求值过程组合起来，得到物体的面、边和顶点<sup>[6](https://archive.nptel.ac.in/content/storage2/courses/107103012/module8/lec1.pdf)</sup> |
| 配套表示 | B-Rep 显式存储边界；边界模型可由 CSG 描述自动导出，通常用于图形显示<sup>[3](https://doi.org/10.1016/j.camwa.2017.01.027)</sup><sup> • </sup><sup>[7](https://www.cl.cam.ac.uk/~afb21/publications/masters/node23.html)</sup> |

## CSG 树

完整的表示以二叉树的形式存储。叶节点存放简单形状，即基本体，它们在空间中已被设定尺寸和位置；每个分支节点存放一个布尔算子：并集、差集或交集。<sup>[5](https://www.globalspec.com/reference/62783/203279/chapter-11-complex-model-construction)</sup> 因此，一个实体就是对一组已实例化并经过变换的基本体施加布尔运算的结果。<sup>[2](https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/model/csg.html)</sup> 每个基本体本身就是一个合法的 CSG 模型，由一组通常闭合且可定向的表面所界定。<sup>[6](https://archive.nptel.ac.in/content/storage2/courses/107103012/module8/lec1.pdf)</sup>

这些运算是对基本体所占据体积的集合运算，而不仅仅是对其表面，因此 CSG 模型既刻画物体的边界，也刻画其内部。这正是它与边界表示的本质区别——后者显式描述表面，而内部只是隐含的。<sup>[4](https://collaborate.princeton.edu/en/publications/an-efficient-algorithm-for-finding-the-csg-representation-of-a-si/)</sup>

## 与边界表示的关系

没有哪一种表示能适用于所有应用，因此常常需要在两者之间转换，许多 CAD 系统采用混合表示，将 B-Rep 与过程式或 CSG 风格的建模结合起来。<sup>[4](https://collaborate.princeton.edu/en/publications/an-efficient-algorithm-for-finding-the-csg-representation-of-a-si/)</sup><sup> • </sup><sup>[3](https://doi.org/10.1016/j.camwa.2017.01.027)</sup> 边界模型可由 CSG 描述自动导出，这种做法常用于显示。<sup>[7](https://www.cl.cam.ac.uk/~afb21/publications/masters/node23.html)</sup> 反方向——从边界表示恢复出合法的 CSG 树——是更困难的问题；相关算法接受由分段隐式曲面构成的合法边界模型并计算出半空间 CSG 表示，这类工作可支撑逆向工程及其他实体建模任务。<sup>[8](https://www.sciencedirect.com/science/article/abs/pii/S0010448586800033)</sup>

时任 IBM 托马斯·J·沃森研究中心设计自动化科学项目研究员的雅罗斯瓦夫·R·罗西尼亚克（Jaroslaw R. Rossignac）在 1986 年的一篇研讨会论文中提出，基于 CSG 与 B-Rep 双重表示的系统似乎最适合机械零件建模，因为工业设计依赖于通过友好的图形交互来指定和编辑参数化模型。<sup>[9](https://doi.org/10.1145/319120.319129)</sup>

这两种方案在支持形式化验证的方式上也有所不同。CSG 允许代数表示，便于认证工具直接应用；基于 B-Rep 或选择性几何复形的建模器不再用方程与不等式系统来表示实体，这种代数表示的缺失使几何模型和建模软件难以认证。<sup>[10](https://www.sciencedirect.com/science/article/pii/S0010448515000494)</sup>

## 求值与算法

计算 CSG 模型的边界称为边界求值，它把各基本体的表面组合起来，生成最终物体的面、边和顶点。<sup>[6](https://archive.nptel.ac.in/content/storage2/courses/107103012/module8/lec1.pdf)</sup> 这一问题催生了大量算法文献：最近一篇关于三维几何建模中布尔运算的综述涵盖了 1984 年至 2025 年间针对 CSG、B-Rep、多边形网格、二叉空间分割（BSP）树、隐式、体积及混合等各类表示所发展的技术。<sup>[11](https://www.sciencedirect.com/science/article/pii/S0010448526000515)</sup> 特殊情形有其专门方法；对于三角化多面体基本体，菲利普·M·哈伯德（Philip M. Hubbard）1990 年的布朗大学技术报告提出了一种面向三角化输入的 CSG 算法，全局处理多面体之间的相交，并在将一个多面体相对于另一个进行分类时避免使用射线投射，其性能显著优于已发表的对比算法。<sup>[12](https://cs.brown.edu/research/pubs/techreports/reports/CS-90-07.html)</sup>

由于 CSG 模型是一种隐式的、过程式的描述，它可以无须先构建网格而直接求值。CSG 模型可直接转换为有符号距离函数（SDF）等隐式形式——该函数把空间中每一点映射到它到曲面的有符号距离——随后可用于基于隐式的建模系统。<sup>[13](https://www.sciencedirect.com/science/article/abs/pii/S0010448523001872)</sup> 在仿真中，有限胞元法（FCM）直接使用隐式 CSG 描述，从而简化了原本是 CAD 建模与数值分析之间瓶颈的网格划分步骤；替代做法是把 CSG 模型转换为 B-Rep 模型以获得有限元网格。<sup>[3](https://doi.org/10.1016/j.camwa.2017.01.027)</sup><sup> • </sup><sup>[14](https://arxiv.org/abs/1809.09942)</sup>

## 应用

**机械 CAD。** CSG 是许多传统 CAD 系统采用的建模范式：其工作流程对实体基本体施加任意多次布尔运算，将其融合或切除，直至产生最终形状。<sup>[15](https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Constructive_solid_geometry.md)</sup> FreeCAD 的“零件工作台”（Part Workbench）即按此方法使用长方体、圆柱体和球体等基本体，而其“零件设计工作台”（PartDesign Workbench）采用较新的特征编辑方式，在一个基础实体上依次施加参数化变换。<sup>[15](https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Constructive_solid_geometry.md)</sup> 布尔运算也出现在建筑软件中，用于在墙体上开出门窗洞口。<sup>[16](https://howthingswork.dev/chapters/boolean-ops)</sup>

**分析与仿真。** OpenMC 蒙特卡罗粒子输运程序依靠 CSG 来表示亚原子粒子穿行的实体，这推动了对 CSG 树（包括含无界基本体的树）的高效点包含算法的研究。<sup>[17](https://arxiv.org/abs/2406.13030)</sup>

**基于学习的形状建模。** 由于 CSG 程序是形状的一种紧凑且可解释的生成模型，将形状解析为 CSG 程序是机器学习研究的一个目标。CSGNe 是一个带有卷积编码器和循环解码器的深度网络，以前馈方式把二维或三维形状映射为 CSG 程序，速度显著快于自底向上的方法；其一个变体增加了基于程序执行栈的显式记忆模块，提升了重建质量和学习效率。<sup>[18](https://arxiv.org/abs/1912.11393)</sup> 相关工作使布尔构造本身可微：DiffCSG 通过光栅化执行 CSG，因为底层布尔运算通常由复杂的黑箱网格处理库完成，从而在机器学习环境中实现对 CSG 基本体的直接编辑和基于图像的编辑。<sup>[19](https://arxiv.org/abs/2409.01421)</sup>

## 变体与扩展

基本方案已在若干方向上得到推广。过程式建模（PM）与 CSG 密切相关，但以额外的运算和基本体对其加以扩展。<sup>[3](https://doi.org/10.1016/j.camwa.2017.01.027)</sup> 更一般的基本体来自扫掠：让一个实体沿空间中的曲线移动，或让一条平面曲线绕其所在平面内的一条轴旋转；这类形状有助于为过渡曲面、机床切除的体积以及机器人系统建模。<sup>[1](https://www.sathyabama.ac.in/sites/default/files/course-material/2020-10/note_1493621926_0.pdf)</sup> 基于半空间的构造方式从一组半空间构建实体，每个半空间或为平面、球体这样的简单基本体，或为自由形式隐式曲面；杜、周、卡尔和朱提出的边界采样半空间表示保持了 CSG 风格的构造方式而不设显式边界结构，但用每个半空间边界上稀疏放置的采样点取代了布尔表达式。<sup>[20](https://www.researchgate.net/publication/355019970_Boundary-sampled_halfspaces_a_new_representation_for_constructive_solid_modeling)</sup> CSG 思想还扩展到隐式曲面建模：一种面向骨架隐式曲面的多边形化算法纳入了混合隐式对象组之间的 CSG 运算，得到一种称为布尔复合软体（Boolean Compound Soft Object）的曲面定义，由并集、交集和集合差算子构建。<sup>[21](https://doi.org/10.1142/S0218654396000142)</sup>

## References

1. [CAD/CAM course notes, Sathyabama Institute of Science and Technology](https://www.sathyabama.ac.in/sites/default/files/course-material/2020-10/note_1493621926_0.pdf)
2. [Constructive Solid Geometry, C. C. Hsu (Shene), Michigan Technological University, CS 3621 notes](https://pages.mtu.edu/~shene/COURSES/cs3621/NOTES/model/csg.html)
3. [From geometric design to numerical analysis: A direct approach using the Finite Cell Method on Constructive Solid Geometry, Computers & Mathematics with Applications 74(7), 2017](https://doi.org/10.1016/j.camwa.2017.01.027)
4. [An efficient algorithm for finding the CSG representation of a simple polygon, Princeton University](https://collaborate.princeton.edu/en/publications/an-efficient-algorithm-for-finding-the-csg-representation-of-a-si/)
5. [Chapter 11: Complex Model Construction, GlobalSpec](https://www.globalspec.com/reference/62783/203279/chapter-11-complex-model-construction)
6. [Introduction to CAD, NPTEL course notes, module 8](https://archive.nptel.ac.in/content/storage2/courses/107103012/module8/lec1.pdf)
7. [Constructive Solid Geometry, University of Cambridge Computer Laboratory masters thesis chapter](https://www.cl.cam.ac.uk/~afb21/publications/masters/node23.html)
8. [Boundary to constructive solid geometry mappings: A focus on 2D issues, Computer-Aided Design](https://www.sciencedirect.com/science/article/abs/pii/S0010448586800033)
9. [Jaroslaw R. Rossignac (1987). Constraints in constructive solid geometry, I3D '86, pp. 93–110](https://doi.org/10.1145/319120.319129)
10. [Extending CSG with projections: Towards formally certified geometric modeling, Computer-Aided Design](https://www.sciencedirect.com/science/article/pii/S0010448515000494)
11. [A survey of Boolean operations in 3D geometric modeling, Computer-Aided Design](https://www.sciencedirect.com/science/article/pii/S0010448526000515)
12. [Philip M. Hubbard (1990). Constructive Solid Geometry for Triangulated Polyhedra, Brown University Tech Report CS-90-07](https://cs.brown.edu/research/pubs/techreports/reports/CS-90-07.html)
13. [A Survey of Methods for Converting Unstructured Data to CSG Models, Computer-Aided Design](https://www.sciencedirect.com/science/article/abs/pii/S0010448523001872)
14. [A design-through-analysis approach using the Finite Cell Method, ECCOMAS Congress 2016](https://arxiv.org/abs/1809.09942)
15. [Constructive solid geometry, FreeCAD documentation](https://github.com/FreeCAD/FreeCAD-documentation/blob/main/wiki/Constructive_solid_geometry.md)
16. [Boolean operations, How Things Work: A Visual Guide to Technology](https://howthingswork.dev/chapters/boolean-ops)
17. [Point containment algorithms for constructive solid geometry with unbounded primitives, arXiv:2406.13030](https://arxiv.org/abs/2406.13030)
18. [Gopal Sharma et al. (2019). Neural Shape Parsers for Constructive Solid Geometry, arXiv:1912.11393](https://arxiv.org/abs/1912.11393)
19. [DiffCSG: Differentiable CSG via Rasterization, arXiv:2409.01421](https://arxiv.org/abs/2409.01421)
20. [Xingyi Du, Qingnan Zhou, Nathan A. Carr, Tao Ju (2021). Boundary-Sampled Halfspaces: A New Representation for Constructive Solid Modeling, ACM Transactions on Graphics 40(4)](https://www.researchgate.net/publication/355019970_Boundary-sampled_halfspaces_a_new_representation_for_constructive_solid_modeling)
21. [Brian Wyvill, Kees van Overveld (1996). Polygonization of Implicit Surfaces with Constructive Solid Geometry, International Journal of Shape Modeling](https://doi.org/10.1142/S0218654396000142)

---
*Initially written Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 几何学与拓扑学 › Computational and algorithmic geometry

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/constructive-solid-geometry

English original: https://www.edgepedia.org/constructive-solid-geometry
