WuYongJie 5821d73291 初始提交:3D家具安装展示系统
包含:
- furniture-3d-system:Next.js 16 全栈应用(资产中心、产品管理、3D装配动画)
- autocad-plugin:AutoCAD 家具导出插件源码
- 资产中心改造:编辑弹窗化、删除功能、Toast反馈、自定义Select组件

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-02 14:00:19 +08:00

54 lines
1.6 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Autodesk.AutoCAD.Geometry;
namespace FurnitureExporter;
/// <summary>
/// Brep 面的 Surface 有时会被包装成 ExternalBoundedSurface/OffsetSurface 等“修剪/偏移”表面。
/// 这会导致直接用 `surface is Cylinder/Plane` 判断失效,从而漏检孔位/倒角等特征。
///
/// 这里提供一个统一的“剥壳”工具,把 Surface 还原为最底层的几何表面类型。
/// </summary>
internal static class BrepSurfaceUtils
{
// 防御:最多剥 8 层,避免异常几何导致递归/循环
private const int MaxUnwrapDepth = 8;
public static Surface Unwrap(Surface surface)
{
var current = surface;
for (int i = 0; i < MaxUnwrapDepth; i++)
{
if (current == null)
{
break;
}
// 最常见:Brep Face 的表面是“修剪面”,真正的几何在 BaseSurface
if (current is ExternalBoundedSurface ebs && ebs.BaseSurface != null)
{
current = ebs.BaseSurface;
continue;
}
// 偏移面:原始几何在 OriginalSurface
if (current is OffsetSurface os && os.OriginalSurface != null)
{
current = os.OriginalSurface;
continue;
}
// 外部面:如果是 NativeSurface,则真实几何在 nativeSurface
if (current is ExternalSurface es && es.IsNativeSurface && es.nativeSurface != null)
{
current = es.nativeSurface;
continue;
}
break;
}
return current ?? surface;
}
}