# # 模型分析

ARS提供拓扑分析、几何（曲线、曲面）分析、特征识别等多种分析API，以应用于模型应用阶段，比如机械加工、激光切割、机器人仿真等。

## # 1. 拓扑分析

### # 1.1 获取所有的子拓扑对象

• 使用TopoShape::GetChildren(EnumTopoShapeType subType)可以获取指定类型的拓扑对象
``````        public void ListchildrenTree(TopoShape shape)
{
TopoShapeList children = TopoExplor.GetSubShapes(shape);
foreach(var child in children)
{
// do something for child
ListchildrenTree(child);
}
}
``````
1
2
3
4
5
6
7
8
9
• 使用TopoExplor::GetSubShapes(TopoShape shape)获取直接子节点，可能不是同类型的

### # 1.2 根据索引获取指定的拓扑对象

``````        TopoShape shape ...
// 获取第0个Edge
var child = shape.FindChild(EnumTopoShapeType.Topo_EDGE, 0);

``````
1
2
3
4

## # 2. 曲线分析

``````            var pc = new ParametricCurve(ellipse);
for (double param = pc.FirstParameter(), endParam = pc.LastParameter(); param < endParam; param += 0.2)
{
var value = pc.D1(param);  // 一阶导数
var pos = value.GetPoint();
var vec = value.GetVectors()[0]; //切线
...
}
``````
1
2
3
4
5
6
7
8

``````        var pc = new ParametricCurve(edge);
// 每距离0.1的长度采样一个点
var points = pc.SplitByUniformLength(0.1f, GP.Resolution());
...
``````
1
2
3
4

## # 3. 曲面分析

``````        var ps = new ParametricSurface(face);
for(double u = ps.FirstUParameter(), endU = ps.LastUParameter(); u<endU; u+= 0.1)
for(double v = ps.FirstVParameter(), endV = ps.LastVParameter(); v<endV; v+=0.1)
{
var value = ps.D1(u, v);
var pos = value.GetPoint();
var vecU = value.GetVectors()[0];  // u方向切线
var vecV = value.GetVectors()[1];  // v方向切线
...
}
``````
1
2
3
4
5
6
7
8
9
10

## # 4. 特征识别

### # 4.1 面上孔识别

``````        var exp = new WireExplor(face);
var innerWires = exp.GetInnerWires();
var outWire = exp.GetOuterWire();
``````
1
2
3

## # 5. 距离计算

TIP

``````            ExtremaShapeShape ess = new ExtremaShapeShape();
if (!ess.Initialize(shape, shape2, 0.001))
return;

var pt1 = ess.GetPointOnShape1(0);
var pt2 = ess.GetPointOnShape2(0);

var line = SketchBuilder.MakeLine(pt1, pt2);
``````
1
2
3
4
5
6
7
8

## # 6. 小结

Last Updated: 1/5/2022, 10:57:55 AM