Files
ViewDesignEngine/include/vde/brep/brep.h
T
茂之钳 8a19e265cd
CI / Build & Test (push) Failing after 40s
CI / Release Build (push) Failing after 1m31s
feat(v2.0.0): Sprint 10 — B-Rep完善 + STEP导入/导出 + 布尔运算 + 验证
S10-A: B-Rep modeling 补齐
- fillet: 恒定半径滚动球倒圆(NURBS 曲面构建 + 相邻面裁剪)
- chamfer: 等距倒角(平面偏移 + 倒角面构建)
- shell: 完整抽壳(顶点偏移 + 内外面 + 开口侧壁)

S10-B: STEP AP203/AP214 导入
- ISO 10303-21 解析器(1,424 行)
- 支持 14 种几何实体 → NurbsCurve/NurbsSurface 转换
- 完整拓扑链:VERTEX_POINT → EDGE_CURVE → EDGE_LOOP → ADVANCED_FACE → CLOSED_SHELL → MANIFOLD_SOLID_BREP
- 装配支持:NEXT_ASSEMBLY_USAGE_OCCURRENCE + CONTEXT_DEPENDENT_SHAPE_REPRESENTATION

S10-C.1: STEP AP214 导出
- export_step / export_step_file
- 曲线/曲面类型自动检测简化输出

S10-C.2: B-Rep 级布尔运算
- brep_union / brep_intersection / brep_difference
- 面-面求交 + 内/外分类 + 面缝合

S10-C.3: B-Rep 工程验证
- ValidationResult: 水密性/悬边/自相交/方向一致性/欧拉示性数

测试: 5 个新测试文件,47 项测试(modeling/STEP导入/导出/布尔/验证)

修改: 7 files (+576/-47) | 新增: 13 files (4,141 行)
总计: +4,670 行
2026-07-24 05:18:52 +00:00

78 lines
3.1 KiB
C++

#pragma once
#include "vde/core/point.h"
#include "vde/core/aabb.h"
#include "vde/curves/nurbs_curve.h"
#include "vde/curves/nurbs_surface.h"
#include "vde/mesh/halfedge_mesh.h"
#include <vector>
#include <memory>
#include <string>
namespace vde::brep {
using core::Point3D;
using core::Vector3D;
using core::AABB3D;
enum class CurveType { Line, Circle, Bezier, BSpline, Nurbs };
struct TopoVertex { int id; Point3D point; double tolerance = 1e-6; };
struct TopoEdge {
int id, v_start, v_end;
std::shared_ptr<curves::NurbsCurve> curve;
bool reversed = false;
};
struct TopoLoop { int id; std::vector<int> edges; bool is_outer = true; };
struct TopoFace { int id, surface_id; std::vector<int> loops; bool reversed = false; };
struct TopoShell { int id; std::vector<int> faces; bool closed = true; };
struct TopoBody { int id; std::vector<int> shells; std::string name; };
class BrepModel {
public:
BrepModel() = default;
int add_vertex(const Point3D& p);
int add_edge(int v0, int v1);
int add_edge(int v0, int v1, const curves::NurbsCurve& curve);
int add_loop(const std::vector<int>& edges, bool outer = true);
int add_face(int surface_id, const std::vector<int>& loops);
int add_shell(const std::vector<int>& faces, bool closed = true);
int add_body(const std::vector<int>& shells, const std::string& name = "");
int add_surface(const curves::NurbsSurface& surf);
[[nodiscard]] size_t num_vertices() const { return vertices_.size(); }
[[nodiscard]] size_t num_edges() const { return edges_.size(); }
[[nodiscard]] size_t num_faces() const { return faces_.size(); }
[[nodiscard]] size_t num_bodies() const { return bodies_.size(); }
// Look up vertex by array index (faster, for sequential access)
[[nodiscard]] const TopoVertex& vertex(int id) const { return vertices_[id]; }
// Look up vertex by unique ID (correct for ID-based references from edge data)
[[nodiscard]] const TopoVertex& vertex_by_id(int id) const;
[[nodiscard]] const TopoEdge& edge(int id) const { return edges_[id]; }
[[nodiscard]] const TopoFace& face(int id) const { return faces_[id]; }
[[nodiscard]] const curves::NurbsSurface& surface(int id) const { return surfaces_[id]; }
[[nodiscard]] core::AABB3D bounds() const;
[[nodiscard]] bool is_valid() const;
[[nodiscard]] mesh::HalfedgeMesh to_mesh(double deflection = 0.01) const;
[[nodiscard]] std::vector<int> face_edges(int face_id) const;
[[nodiscard]] std::vector<int> edge_faces(int edge_id) const;
[[nodiscard]] std::vector<int> vertex_edges(int vertex_id) const;
[[nodiscard]] size_t num_surfaces() const { return surfaces_.size(); }
[[nodiscard]] const TopoLoop& loop_by_id(int id) const;
[[nodiscard]] const std::vector<TopoLoop>& all_loops() const { return loops_; }
private:
std::vector<TopoVertex> vertices_;
std::vector<TopoEdge> edges_;
std::vector<TopoLoop> loops_;
std::vector<TopoFace> faces_;
std::vector<TopoShell> shells_;
std::vector<TopoBody> bodies_;
std::vector<curves::NurbsSurface> surfaces_;
int next_id_ = 0;
};
} // namespace vde::brep