Open Cascade中的布爾操作
Modeling Algorithms Boolean Operations
eryar@163.com
布爾操作(Boolean Operations)是通過兩個形狀(S1,S2)的組合來生成新的形狀。布爾操作有如下幾種類型:
u 并集操作Fusion:Gets all the points in S1 or S2;
u 交集操作Common:Gets all the points in S1 and S2;
u 差集操作Cut S1 by S2:Gets all the points in S1 and not in S2;
下圖所示為三種布爾操作:
1. BRepAlgoAPI_BooleanOperation
類BRepAlgoAPI_BooleanOperation是布爾操作的基類。
2. BRepAlgoAPI_Fuse
類BRepAlgoAPI_Fuse執行布爾并集操作。如下所示:
TopoDS_Shape theBox1 = BRepPrimAPI_MakeBox(50,200,70);
TopoDS_Shape theBox2 = BRepPrimAPI_MakeBox(-30,150,70);
TopoDS_Shape FusedShape = BRepAlgoAPI_Fuse(theBox1,theBox2);
Fuse two boxes
3. BRepAlgoAPI_Common
類BRepAlgoAPI_Common執行布爾交集操作,如下所示:
gp_Ax2 axe(gp_Pnt(10,10,10),gp_Dir(1,2,1));
TopoDS_Shape theBox = BRepPrimAPI_MakeBox(axe,60,80,100);
TopoDS_Shape theWedge = BRepPrimAPI_MakeWedge(60.,100.,80.,20.);
TopoDS_Shape theCommonSurface = BRepAlgoAPI_Common(theBox,theWedge);
Compute the common surface
4. BRepAlgoAPI_Cut
類BRepAlgoAPI_Cut執行布爾差集操作,如下所示:
TopoDS_Shape theBox = BRepPrimAPI_MakeBox(200,40,40);
TopoDS_Shape theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100,20,20),80);
TopoDS_Shape ShapeCut = BRepAlgoAPI_Cut(theSphere,theBox);
5. BRepAlgoAPI_Section