opencascade如何用一个面裁剪另外一个面
opencascade如何用一个面裁剪另外一个面
void trim_plane_by_plane_2(TopoDS_Shape aS1, TopoDS_Shape aS2) { BRepAlgoAPI_Section sec(aS1, aS2, false); sec.ComputePCurveOn1(true); sec.Approximation(true); sec.Build(); TopoDS_Shape aInterCurve = sec.Shape(); TopoDS_Face aFace = TopoDS::Face(aS1); BRepFeat_SplitShape ssplit(aS1); TopExp_Explorer ex; for (ex.Init(aInterCurve, TopAbs_EDGE, TopAbs_SHAPE); ex.More(); ex.Next()) { TopoDS_Edge aE = TopoDS::Edge(ex.Current()); TopoDS_Shape aF; if (sec.HasAncestorFaceOn1(aE, aF)) { TopoDS_Face aAncFace = TopoDS::Face(aF); if (aAncFace.IsSame(aFace)) ssplit.Add(aE, aFace); } } ssplit.Build(); TopTools_ListOfShape shapeList = ssplit.Modified(aFace); TopTools_ListIteratorOfListOfShape ite(shapeList); for (; ite.More(); ite.Next()) { TopoDS_Shape aS = ite.Value(); Handle(AIS_Shape) aiss = new AIS_Shape(aS); m_context->Display(aiss, true); } }
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); } } }
opencascade如何用一个面裁剪另外一个面(2)_hasancestorfaceon1-CSDN博客
voidsplit_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);}}}
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 【自荐】一款简洁、开源的在线白板工具 Drawnix