opencascade(十一) 几何算法
1.1 OCGeomAPI_IntCS
(1) 功能说明:线面求交
(2) 构造函数:
public OCGeomAPI_IntCS(OCGeom_Curve C, OCGeom_Surface S)
(3) 主要方法:
public bool IsDone();//求交是否执行成功
public int NbPoints();//曲线与曲面有多少个交点
public int NbSegments();//曲线与曲面有多少个相交的线段(有代验证)
public OCgp_Pnt Point(int Index);//获取交点
public OCGeom_Curve Segment(int Index);//获取线段
(4) 实例
OCGeom_BSplineCurve SPL; OCGeom_BSplineSurface BSS1;
OCGeomAPI_IntCS CS = new OCGeomAPI_IntCS(SPL, BSS1);
OCGeom_Curve segment;
if (CS.IsDone())
{
int NbSeg = CS.NbSegments();
//取线段并显示
for (int k = 1; k <= NbSeg; k++)
{
segment = CS.Segment(k);
OCBRepBuilderAPI_MakeEdge MEdge1 =
new OCBRepBuilderAPI_MakeEdge(segment);
OCAIS_Shape aCurve1 = new OCAIS_Shape(MEdge1.Edge());
context.Display(aCurve1, false);
}
//取交点并显示
for (int k = 1; k <= CS.NbPoints(); k++)
{
OCgp_Pnt aPoint = CS.Point(k);
OCTopoDS_Vertex V1 = new OCBRepBuilderAPI_MakeVertex(aPoint).Vertex();
OCAIS_Shape Point1 = new OCAIS_Shape(V1);
context.Display(Point1, false);
}
}
1.2 OCGeomAPI_IntSS
(1) 功能说明:面面求交
(2) 构造函数:
public OCGeomAPI_IntSS(OCGeom_Surface S1, OCGeom_Surface S2, double Tol)
参数:TOL,定义曲线计算的精确度,默认值为:1.0e-7
(3) 主要方法:
public bool IsDone();//是否求交成功
public OCGeom_Curve Line(int Index);//返回曲线相交的曲线
public int NbLines();//曲线求交产生多少条线
(4) 实例
OCGeomFill_BSplineCurves BSS,BSS1;
OCGeomAPI_IntSS SS = new OCGeomAPI_IntSS(BSS, BSS1, 1.0e-7);
OCGeom_Curve segment;
if (SS.IsDone())
{
int NbSeg = SS.NbLines();
for (int k = 1; k <= NbSeg; k++)
{
segment = SS.Line(k);
OCBRepBuilderAPI_MakeEdge MEdge1 = new OCBRepBuilderAPI_MakeEdge(segment);
OCAIS_Shape aCurve1 = new OCAIS_Shape(MEdge1.Edge());
context.Display(aCurve1, false);
}
}
1.3 OCGeomAPI_ExtremaCurveCurve
(1) 功能说明:两条曲线求极值,可用于曲线的求交