在 OpenCASCADE 中将 TopoDS_Face 向量转换为 TopoDS_Shape 向量
OCCUtils 提供 Shapes::FromFaces 来在 OpenCASCADE 中将 std::vector<TopoDS_Face> 转换为 std::vector<TopoDS_Shape>:
from_faces_example.cpp
#include <occutils/Shape.hxx>
using namespace OCCUtils;
std::vector<TopoDS_Face> faces = /* ... */;
std::vector<TopoDS_Shape> shapes = Shapes::FromFaces(faces);如果你需要在不使用 OCCUtils 的情况下手动操作,使用此代码片段:
from_faces_manual_copy.cpp
#include <algorithm>
// 创建返回向量
std::vector<TopoDS_Shape> shapes;
shapes.reserve(faces.size());
// 执行复制
std::copy(faces.begin(), faces.end(), std::back_inserter(shapes));Check out similar posts by category:
OpenCASCADE
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow