在 OpenCASCADE 中将 TopoDS_Solid 向量转换为 TopoDS_Shape 向量
OCCUtils 提供 Shapes::FromSolids 来在 OpenCASCADE 中将 std::vector<TopoDS_Solid> 转换为 std::vector<TopoDS_Shape>:
from_solids_example.cpp
#include <occutils/Shape.hxx>
using namespace OCCUtils;
std::vector<TopoDS_Solid> solids = /* ... */;
std::vector<TopoDS_Shape> shapes = Shapes::FromSolids(solids);如果你需要在不使用 OCCUtils 的情况下手动操作,使用此代码片段:
from_solids_manual.cpp
#include <algorithm>
// 创建返回向量
std::vector<TopoDS_Shape> shapes;
shapes.reserve(solids.size());
// 执行复制
std::copy(solids.begin(), solids.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