opencascade如何用一个面裁剪另外一个面(2)

opencascade如何用一个面裁剪另外一个面(2)


原文链接

void split_plane_by_plane(TopoDS_Shape tool_face, TopoDS_Shape object_tool)
{
    // Build section by the split plane for the cylinder.
	BRepAlgoAPI_Section aSection(object_tool, tool_face, Standard_False);
    aSection.ComputePCurveOn1(Standard_True);
    aSection.Approximation(Standard_True);
    aSection.Build();

    // Split the cylinder shape.
    BRepFeat_SplitShape aShapeSpliter(object_tool);
    for (TopExp_Explorer i(aSection.Shape(), TopAbs_EDGE); i.More(); i.Next())
    {
        TopoDS_Shape anEdge = i.Current();
        TopoDS_Shape aFace;
        if (aSection.HasAncestorFaceOn1(anEdge, aFace))
        {
            TopoDS_Edge E = TopoDS::Edge(anEdge);
            TopoDS_Face F = TopoDS::Face(aFace);
            aShapeSpliter.Add(E, F);
        }
    }
    aShapeSpliter.Build();

    // Rebuild left and right shape.
    BRep_Builder aBuilder;
    TopoDS_Compound aLeftCompound;
    TopoDS_Compound aRightCompound;

    aBuilder.MakeCompound(aLeftCompound);
    aBuilder.MakeCompound(aRightCompound);

    // Left shape.
    TopTools_MapOfShape aLeftShapeMap;
    const TopTools_ListOfShape& aLeftShapes = aShapeSpliter.Left();
    for (auto i = aLeftShapes.cbegin(); i != aLeftShapes.cend(); i++)
    {
        aLeftShapeMap.Add(*i);
        aBuilder.Add(aLeftCompound, *i);
        display(aLeftCompound);
    }

    // Right shape.
    TopTools_IndexedMapOfShape aShapeMap;
    TopExp::MapShapes(aShapeSpliter.Shape(), TopAbs_FACE, aShapeMap);

    for (auto i = aShapeMap.cbegin(); i != aShapeMap.cend(); i++)
    {
        if (!aLeftShapeMap.Contains(*i))
        {
            aBuilder.Add(aRightCompound, *i);
            display(aRightCompound);
        }
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值