OpenCasCade(九)拓扑运算

1.1.1      拓扑运算描述

1.1.2                                                       
BRepAlgoAPI_Cut

(1)    功能说明:布尔差运算

扣除相交部分,并去除CUT SHAPE

(2)    构造函数:

public OCBRepAlgoAPI_Cut(OCTopoDS_Shape S1, OCTopoDS_Shape S2);

public OCBRepAlgoAPI_Cut(OCTopoDS_Shape S1, OCTopoDS_Shape S2, OCBOPTools_DSFiller aDSF, bool bFWD);

(3)    参数说明:

S1:Shape S2 cuts shape S1----被 CUT SHAPE

S2:Shape S2 cuts shape S1----CUT SHAPE

aDSF:布尔运算的数据结构填充器,

   BOPTools:Contains main and auxiliary classes to fill the Data Structure (DS) to provide  boolean operations between a couple BRep shapes.

           包含用于填充一对BRep图形布尔运算的数据结构的主要及辅助的类库。

bFWD:默认值为TURE;

 

(4)    实例:

OCTopoDS_Shape theSphere = new OCBRepPrimAPI_MakeSphere();

OCTopoDS_Shape theBox = new OCBRepPrimAPI_MakeBox();

OCTopoDS_Shape ShapeCut = new OCBRepAlgoAPI_Cut(theSphere, theBox).Shape();

 

1.1.3      BRepAlgoAPI_Fuse

(1)    功能说明:布尔Union运算

运算结果,是两个图形合并

与CUT类同。

 

1.1.4      BRepAlgoAPI_Section

(1)    功能说明:

计算两个拓扑SHAPE或者两个几何的相交(交集)

可以理解为,由S2切割S1,返回在S1上所切割轨迹。

(2)    构造函数:

//两个几何曲面相交

OCBRepAlgoAPI_Section(OCGeom_Surface Sf1, OCGeom_Surface Sf2, bool PerformNow);

//几何曲面与拓扑SHAPE相交

OCBRepAlgoAPI_Section(OCGeom_Surface Sf, OCTopoDS_Shape Sh, bool PerformNow);

//拓扑SHAPE与几何曲面相交

OCBRepAlgoAPI_Section(OCTopoDS_Shape Sh, OCGeom_Surface Sf, bool PerformNow);

//拓扑SHAPE与几何平面相交

OCBRepAlgoAPI_Section(OCTopoDS_Shape Sh, OCgp_Pln Pl, bool PerformNow);

//两个拓扑SHAPE相交

OCBRepAlgoAPI_Section(OCTopoDS_Shape Sh1, OCTopoDS_Shape Sh2,

bool PerformNow);

//两个拓扑SHAPE相交

OCBRepAlgoAPI_Section(OCTopoDS_Shape S1, OCTopoDS_Shape S2,

OCBOPTools_DSFiller aDSF, bool PerformNow);

(3)    参数说明:

PerformNow:是否立即执行切割动作。默认值为TRUE;

 

(4)    实例:

例1:用几何平面去切割一个拓扑圆环SHAPE,并返回圆环上的切割轨迹(红色部分)

OCTopoDS_Shape theTorus = new OCBRepPrimAPI_MakeTorus(35, 8).Shape();

OCgp_Pln aplane = new OCgp_Pln(1, 0.25, 3, 4);

OCGeom_Plane thePlane = new OCGeom_Plane(aplane);          

OCBRepAlgoAPI_Section section =

new OCBRepAlgoAPI_Section(theTorus, thePlane, false);

section.ComputePCurveOn1(true);

section.Approximation(true);

section.Build();

OCAIS_Shape asection = new OCAIS_Shape(section.Shape());

 

   

 

1.1.5      BRepAlgoAPI_Common

(1)    功能说明:布尔Intersection运算

运算结果为两个图形相交部分

与CUT类同。

 

1.1.6      BRepFeat_SplitShape

说明:

 

实例:

(1)   曲面拆分

    bool DoSplit(OCTopoDS_Shape aS1, OCTopoDS_Shape aS2)

        {          

            OCBRepAlgoAPI_Section sec = new OCBRepAlgoAPI_Section(aS1, aS2, false);

            sec.ComputePCurveOn1(true);

            sec.Approximation(true);

            sec.Build();

 

            OCTopoDS_Shape aInterCurve = sec.Shape();

           

            OCTopoDS_Face aFace = OCTopoDS.Face(aS1);

            OCBRepFeat_SplitShape ssplit = new OCBRepFeat_SplitShape(aS1);

 

            OCTopExp_Explorer ex = new OCTopExp_Explorer();

            for (ex.Init(aInterCurve, OCTopAbs_ShapeEnum.TopAbs_EDGE, OCTopAbs_ShapeEnum.TopAbs_SHAPE); ex.More(); ex.Next())

            {

                OCTopoDS_Edge aE = OCTopoDS.Edge(ex.Current());

                OCTopoDS_Shape aF = new OCTopoDS_Shape();

                if (sec.HasAncestorFaceOn1(aE, aF))

                {

                    OCTopoDS_Face aAncFace = OCTopoDS.Face(aF);

                    if (aAncFace.IsSame(aFace))

                        ssplit.Add(aE, aFace);

                }

            }

            ssplit.Build();

 

            OCTopTools_ListOfShape shapeList = ssplit.Modified(aFace);

            OCTopTools_ListIteratorOfListOfShape ite = new OCTopTools_ListIteratorOfListOfShape(shapeList);

          

            for (; ite.More(); ite.Next())

            {

                OCTopoDS_Shape aS = ite.Value();

                OCAIS_Shape aiss = new OCAIS_Shape(aS);

                context.Display(aiss, true);               

             }

            return true;

        }

 

1.1.7      BRepFeat_MakePipe

 基类为:BRepFeat_Form;

 通过基本图形生成一个Pipe;

 

 

 

1.1.8      BRepFeat_MakeLinearForm

 基类为:BRepFeat_RibSlot

 在一个平面表面上建一个肋或开凹槽;

 

 

 

1.1.9      BRepFeat_Gluer

posted @ 2011-12-13 10:59  folotus  阅读(5921)  评论(0编辑  收藏  举报