45 lines
1.3 KiB
C++
45 lines
1.3 KiB
C++
#pragma once
|
||
#include "vde/mesh/halfedge_mesh.h"
|
||
|
||
namespace vde::mesh {
|
||
using core::Point2D;
|
||
using core::Point3D;
|
||
using core::Vector3D;
|
||
|
||
/**
|
||
* @brief 布尔运算类型(CSG 组合)
|
||
* @ingroup mesh
|
||
*/
|
||
enum class BooleanOp {
|
||
Union, ///< A ∪ B 并集
|
||
Intersection, ///< A ∩ B 交集
|
||
Difference, ///< A \ B 差集
|
||
SymDiff ///< A Δ B 对称差集
|
||
};
|
||
|
||
/**
|
||
* @brief 三角网格布尔运算
|
||
*
|
||
* 对两个封闭三角网格执行 CSG(Constructive Solid Geometry)布尔操作。
|
||
* 内部流程:
|
||
* 1. 计算两个网格的三角形-三角形交线
|
||
* 2. 沿交线细分三角形(conforming 三角化)
|
||
* 3. 根据布尔类型对每个子面片做内/外分类
|
||
* 4. 缝合属于结果的部分形成新网格
|
||
*
|
||
* @param a 第一个三角网格(必须为封闭流形)
|
||
* @param b 第二个三角网格(必须为封闭流形)
|
||
* @param op 布尔运算类型
|
||
* @return 结果三角网格
|
||
*
|
||
* @note 要求输入网格为封闭流形(watertight),否则分类不可靠
|
||
* @code{.cpp}
|
||
* auto result = mesh_boolean(cube, sphere, BooleanOp::Difference);
|
||
* // result = 立方体减去球体的交集部分
|
||
* @endcode
|
||
* @ingroup mesh
|
||
*/
|
||
HalfedgeMesh mesh_boolean(const HalfedgeMesh& a, const HalfedgeMesh& b, BooleanOp op);
|
||
|
||
} // namespace vde::mesh
|