# 几何造型

ARS支持多种建模/造型方法,比如基本体造型、基于草图特征造型、布尔运算等,而这类造型算法的输出基本上都为TopoShape。

# 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

# 获取子拓扑结构

使用TopoShape::GetChildren方法可以获取指定类型的子拓扑结构的对象列表,比如获取一个体所有的面,一个面所有的边;

使用TopoShape::FindChild可以得到指定索引和类型的子拓扑对象。

# 2. 基本体造型

# 2.1 三维基本体

使用ShapeBuilder可以创建常见的三维基本体,比如球体(Sphere)、盒体(Box)、圆柱体(Cylinder)、圆锥体(Cone)、圆管体(Tube)等

基本体 ShapeBuilder方法
球体 TopoShape MakeSphere(GPnt center, double radius)
盒体 TopoShape MakeBox(GAx2 ax, double dx, double dy, double dz)
圆柱体 TopoShape MakeCylinder(GAx2 ax, double radius, double height, double angle)
圆锥体 TopoShape MakeCone(GAx2 ax, double radius, double radiusTop, double height, double angle)
圆管体 TopoShape MakeTube(GPnt center, GDir dir, double innerRadius, double thickness, double len)

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

使用SketchBuilder可以创建常见的曲线和曲面,比如直线、圆(弧)线、椭圆(弧)线、多折线,平面等

曲线对象 SketchBuilder方法
直线 TopoShape MakeLine(GPnt start, GPnt end)
TopoShape MakeCircle(GPnt center, double radius, GDir zdir)
椭圆 TopoShape MakeEllipse(GPnt center, double majorRadius, double minorRadius, GDir xdir, GDir zdir)
圆弧 TopoShape MakeArcOfCircle(...)
椭圆弧 TopoShape MakeArcOfEllipse(GElips elips, double start, double end)
B-Spline TopoShape MakeBSpline(...)
多折线 TopoShape MakePolygon(GPntList points, bool bClosed)
弹簧线 TopoShape MakeSpiral(double radius, double interval, double count, GAx3 ax)
平面对象 SketchBuilder方法
平面 TopoShape MakePlanarFace(GPln plane, double minU, double maxU, double minV, double maxV)
填充多边形 TopoShape MakePolygonFace(GPntList points)
圆角矩形 TopoShape MakeRectangle(GAx2 coord, double len, double width, double radius, bool bFiled)

# 2.3 Wire

多条相连的线可以组成Wire。

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

功能 SketchBuilder方法
单条边的Wire TopoShape MakeWire(TopoShape edge)
多条边的Wire TopoShape MakeWire(TopoShapeList edges)
打一个孔 TopoShape AddHole(TopoShape face, TopoShape wireOfHole)
打多个孔 TopoShape AddHoles(TopoShape face, TopoShapeList wiresOfHoles)

# 3. 特征造型

特征造型是近二十年来发展起来的一种新的造型方法,它是CAD第三次技术革命(参数化技术)的里程碑。 FeatureTool提供了常用的特征操作,包括拉伸(Extrude)、扫掠(Sweep)、放样(Loft)、倒直角(Chamfer)、倒圆角(Fillet)、抽壳(Thickness)、偏置(Offset)等。

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: 8/11/2020, 8:55:21 PM