1.1 描述
n shape为基类;
n Vertex顶点: 一种0维形状对应于几何中的点;
n edge边: 一种形状对应一条曲线,并在每个末端通过一个顶点来约束;
n wire线框:一个通过顶点互连的边的序列;
n face面:部分(二维)平面或者(三维)表面,被一个闭合线框约束;
n shell壳(qiao):线框边界线的边连接的面的集合;
n solid实体:与一个壳绑定的三维空间的一部分;
n Compound solid复合实体:实体的集合;
1.2 OCBRepBuilderAPI_MakeVertex
建立拓扑的Vertex。
例:
OCTopoDS_Vertex V3;
OCgp_Pnt P = new OCgp_Pnt(-12, 8, -4);
OCBRepBuilderAPI_MakeVertex MV = new OCBRepBuilderAPI_MakeVertex(P);
V3 = MV.Vertex();
1.3 OCBRepBuilderAPI_MakeEdge
建立拓扑的Edge。
例1: 两个几何点生成边
OCTopoDS_Edge BlueEdge, YellowEdge, WhiteEdge, RedEdge, GreenEdge;
BlueEdge = new OCBRepBuilderAPI_MakeEdge(
new OCgp_Pnt(-80, -50, -20), new OCgp_Pnt(-30, -60, -60)).Edge();
例2:两个拓扑Vertex生成边
OCTopoDS_Edge YellowEdge
OCTopoDS_Vertex V1, V2
V1 = new OCBRepBuilderAPI_MakeVertex(new OCgp_Pnt(-20, 10, -30)).Vertex();
V2 = new OCBRepBuilderAPI_MakeVertex(new OCgp_Pnt(10, 7, -25)).Vertex();
YellowEdge = new OCBRepBuilderAPI_MakeEdge(V1, V2).Edge();
例3:用几何直线生成边
OCgp_Lin line;
line= new OCgp_Lin(new OCgp_Ax1(new OCgp_Pnt(10, 10, 10),
new OCgp_Dir(1, 0, 0)));
OCTopoDS_Edge WhiteEdge = new OCBRepBuilderAPI_MakeEdge(line, -20, 10).Edge();
例4:用椭圆弧生成边
OCTopoDS_Edge RedEdge;
OCgp_Elips Elips =
new OCgp_Elips(new OCgp_Ax2(new OCgp_Pnt(10, 0, 0), new OCgp_Dir(1, 1, 1)), 60, 30);
RedEdge = new OCBRepBuilderAPI_MakeEdge(Elips, 0, System.Math.PI / 2).Edge();
例5:贝赛尔曲线生成边
OCGeom_BezierCurve curve = new OCGeom_BezierCurve(array);
OCBRepBuilderAPI_MakeEdge MEdge = new OCBRepBuilderAPI_MakeEdge(curve);
OCTopoDS_Edge GreenEdge = MEdge.Edge();
1.4 OCBRepBuilderAPI_MakeWire
建立拓扑的线框Wire。
例1:一条边生成线框
OCTopoDS_Edge Edge1;
OCTopoDS_Wire RedWire = new OCBRepBuilderAPI_MakeWire(Edge1).Wire();
例2:二两边生成线框
OCTopoDS_Edge ExistingWire;
OCTopoDS_Edge Edge3;
OCBRepBuilderAPI_MakeWire MW1 =
new OCBRepBuilderAPI_MakeWire(ExistingWire, Edge3);
if (MW1.IsDone())//是否可以生成线框
{
OCTopoDS_Wire YellowWire = MW1.Wire();
}
例3:线框与若干边组成线框
OCTopoDS_Wire ExistingWire2;
OCTopoDS_Edge Edge5,Edge6,Edge7;
OCBRepBuilderAPI_MakeWire MW = new OCBRepBuilderAPI_MakeWire();
MW.Add(ExistingWire2);
MW.Add(Edge5);
MW.Add(Edge6);
MW.Add(Edge7);
if (MW.IsDone())
{
OCTopoDS_Wire WhiteWire = MW.Wire();
}
1.5 OCBRepBuilderAPI_MakeFace
创建拓扑面;
例1:几何球面生成拓扑面
OCgp_Sphere sphere;
OCTopoDS_Face WhiteFace =
new OCBRepBuilderAPI_MakeFace(sphere, 0.1, 0.7, 0.2, 0.9).Face();
例2:Bspline曲面生成拓扑面
OCGeom_BSplineSurface curve ;
OCTopoDS_Face RedFace = new OCBRepBuilderAPI_MakeFace(curve).Face();
例3:闭合的线框形面拓扑面
OCTopoDS_Wire YellowWire = MW1.Wire();
OCTopoDS_Face BrownFace = new OCBRepBuilderAPI_MakeFace(YellowWire, false).Face();
1.6 OCBRepBuilderAPI_MakeShell
创建拓扑壳;
例1:BSpline曲面生成Shell
OCGeom_BSplineSurface BSpline;
OCTopoDS_Shell aShell = new OCBRepBuilderAPI_MakeShell(BSpline, false).Shell();
1.7 OCBRep_Builder
1.8 OCBRepBuilderAPI_Sewing
拓扑对象的缝合;
可以通过调节该类的第一个参数,来调整缝合连接部的精度;
例1:
OCTopoDS_Face FirstShape;
OCTopoDS_Face SecondShape;
OCBRepBuilderAPI_Sewing aMethod =
new OCBRepBuilderAPI_Sewing(0.000001, true, true, true, false);
aMethod.Add(FirstShape);
aMethod.Add(SecondShape);
aMethod.Perform();
OCTopoDS_Shape sewedShape = aMethod.SewedShape();
例2:闭合的SHELL缝合成SOLID
OCBRepBuilderAPI_Sewing sew = new OCBRepBuilderAPI_Sewing(0.01, true, true, true, false);
sew.Add(shell);
sew.Perform();
OCTopoDS_Shape shape = sew.SewedShape();
shape.Reverse();
solid = new OCTopoDS_Solid();
builder.MakeSolid(solid);
builder.Add(solid, shape);
1.9 OCBRep_Tool
实用的拓扑工具类—静态类;
(1) 拓扑边到几何线的转换;
public static OCGeom_Curve Curve(OCTopoDS_Edge E, ref double First, ref double Last);
(2) 拓扑面转换为几何面
public static OCGeom_Surface Surface(OCTopoDS_Face F);
public static OCGeom_Surface Surface(OCTopoDS_Face F, OCTopLoc_Location L);
1.10 OCBRepExtrema_DistShapeShape
拓扑极值运算。
可用于拓扑求交等。
例:曲线被曲线拆分
1.11 基本几何体拓扑对象
(1) 以下是基本几何的拓扑生成方式,包括立方体,椎体,柱体,球体等
n OCBRepPrimAPI_MakeBox
n OCBRepPrimAPI_MakeCylinder
n OCBRepPrimAPI_MakeCone
n OCBRepPrimAPI_MakeSphere
n OCBRepPrimAPI_MakeTorus
n OCBRepPrimAPI_MakeWedge
(2) 实例
例1:生成一个立方体并显示在VIEW中
OCAIS_InteractiveContext context;
OCTopoDS_Shape B1 = new OCBRepPrimAPI_MakeBox(200.0, 150.0, 100.0).Shape();
OCAIS_Shape aBox1 = new OCAIS_Shape(B1);
context.SetMaterial(aBox1, OCGraphic3d_NameOfMaterial.Graphic3d_NOM_PLASTIC, false);
context.SetColor(aBox1, OCQuantity_NameOfColor.Quantity_NOC_GREEN, false);
context.Display(aBox1, true);