# # 几何造型

## # 1. 拓扑对象

TopoShape用于表示几何拓扑对象，可以表示顶点、边、面，也可以表示体、复合体。通过TopoShape::GetShapeType方法可以得到其表达的类型。

``````namespace AnyCAD.Foundation
{
public enum EnumTopoShapeType
{
Topo_COMPOUND = 0,
Topo_COMPSOLID = 1,
Topo_SOLID = 2,
Topo_SHELL = 3,
Topo_FACE = 4,
Topo_WIRE = 5,
Topo_EDGE = 6,
Topo_VERTEX = 7,
Topo_SHAPE = 8
}
}
``````
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

### # 获取直接的孩子拓扑结构

TopoExplor (opens new window)::GetSubShapes可以获取所有的孩子节点。

## # 2. 基本体造型

### # 2.2 三维曲线、平面几何对象

TopoShape MakeCircle(GPnt center, double radius, GDir zdir)

B-Spline TopoShape MakeBSpline(...)

### # 2.3 Wire

Wire一般用来表示面的边界，比如外边界、内孔的边界。 Wire也可以表示一条由多个边组成的复杂的路径。

## # 3. 特征造型

``````namespace AnyCAD.Foundation
{
public class FeatureTool
{
// 对所有的边倒直角
public static TopoShape Chamfer(TopoShape shape, double dis1, double dis2);

// 对指定的边倒直角
public static TopoShape Chamfer(TopoShape shape, Uint32List edgeIdx, DoubleList dis1, DoubleList dis2);

public static TopoShape Evolved(TopoShape section, TopoShape path, EnumGeomJoinType joinType, bool bSolid);

public static TopoShape Extrude(TopoShape base_, double height, GDir _dir);
// 对所有的边倒圆角
public static TopoShape Fillet(TopoShape shape, double radius);
// 对指定的边倒圆角
public static TopoShape Fillet(TopoShape shape, Uint32List edgeIdx, DoubleList radius);

// 放样
public static TopoShape Loft(TopoShape wireA, TopoShape wireB, bool bSolid);
public static TopoShape Loft(TopoShapeList sketches, bool bSolid, bool bCheckCompatibility);

public static TopoShape OffsetShape(TopoShape shape, double offset, EnumGeomJoinType jointType);
// 曲线偏置
public static TopoShape OffsetWire(TopoShape wire, double offset, double altitude, EnumGeomJoinType jointType, bool openning);

// 回转扫掠
public static TopoShape Revol(TopoShape base_, GAx1 ax, double angle);

// 扫掠
public static TopoShape Sweep(TopoShape section, TopoShape path, EnumGeomFillTrihedron type);
public static TopoShape SweepByEvolution(TopoShape section, TopoShape path, TopoShape evolutionSpline, bool bSolid);
public static TopoShape SweepByFrenet(TopoShape section, TopoShape path, EnumSweepTransitionMode mode, bool bSolid);
public static TopoShape SweepByFrenet(TopoShape section, TopoShape path, EnumSweepTransitionMode mode, bool bSolid, bool wthContact, bool wthCorrection);
public static TopoShape SweepByFrenet(TopoShape section, TopoShape path, EnumSweepTransitionMode mode, bool bSolid, bool wthContact);
public static TopoShape SweepByFrenet2(TopoShapeList sections, TopoShape path, EnumSweepTransitionMode mode, bool bSolid);

// 对指定的面抽壳
public static TopoShape Thickness(TopoShape solid, double offset, Uint32List faceIdx);
}
}

``````
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

## # 4. 布尔运算

BooleanTool提供了交（Common）、差（Cut）、并（Fuse）三种布尔运算工具

``````namespace AnyCAD.Foundation
{
public class BooleanTool
{
// A & B
public static TopoShape Common(TopoShape shapeA, TopoShape shapeB);
// A - B
public static TopoShape Cut(TopoShape shapeA, TopoShape shapeB);
// A + B
public static TopoShape Fuse(TopoShape shapeA, TopoShape shapeB);
}
}
``````
1
2
3
4
5
6
7
8
9
10
11
12

## # 5. 投影

ProjectionTool 提供了点到曲线、点到曲面、曲线到曲面、曲线到平面的投影计算。

``````namespace AnyCAD.Foundation
{
public class ProjectionTool
{
// 点到曲线
public static ProjCurveResult ProjectOnCurve(GPnt point, TopoShape curve, double tolerance);
// 点到曲面
public static ProjSurfaceResult ProjectOnSurface(GPnt point, TopoShape surface, double tolerance);

// 点到平面
public static TopoShape ProjectOnPlane(TopoShape curve, GPnt planePosition, GDir planeDir, GDir projDir);
public static TopoShape ProjectOnPlane(TopoShape curve, GPnt planePosition, GDir planeDir);

// 曲线到曲面
public static TopoShape ProjectOnSurface(TopoShape curve, TopoShape surface, bool faceBoundaries);
public static TopoShape ProjectOnSurface(TopoShape curve, TopoShape surface);

}
}
``````
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

## # 6. 小结

• 根据参数从无到有创建模型
• ShapeBuilder
• SketchBuilder
• 在已有模型的基础上创建
• FeatureTool
• BooleanTool
• ProjectionTool
Last Updated: 1/5/2022, 10:57:55 AM