SpaceClaim二次开发(5)

目录

第七章 Geometry and Topology(几何与拓扑)

        7.1 无界几何体和修剪对象

        7.2 拓扑

        7.3 文档对象和几何图形

        7.4 设计曲线

        7.5 设计体

        7.6 通用shape


        本章主要介绍SpaceClaim二次开发文档的第七章。(使用的翻译,如有错误,敬请指正)

第七章 Geometry and Topology(几何与拓扑)

        7.1 无界几何体和修剪对象

        在SpaceClaim中,几何在概念上是无限的,例如,平面无限延伸,球体是完整的,而线是无限长的。在此之上,还有修剪对象,它们是有界的,因此提供了额外的属性:

        ITrimmedCurve -有界曲线。它提供了长度和参数边界。

        ITrimmedSurface -有界曲面。它提供“面积”、“周长”和参数化BoxUV。

        ITrimmedSpace -3D空间的有界区域。它提供体积和表面积。

        所有这些都继承自IBounded,IBounded提供了GetBoundingBox。

        修剪的曲线具有返回曲线的几何属性,修剪的曲面具有返回曲面的几何属性。修剪区域甚至具有返回表示所有笛卡尔3D空间的Space对象的Geometry属性。

        修剪的曲线和修剪的曲面也具有IsReversed属性,该属性告诉您对象的方向是否与其几何体的方向相反。修剪曲线的方向是它的方向,而修剪曲面的方向是它的法线朝向的方向。

        7.2 拓扑

        模型的拓扑由Body、Face和Edge对象组成,沿着还有其他对象(壳、环、鳍和顶点),这些对象详细描述了它们的连接方式。

        Body继承自ITrimmedSpace。它还提供面和边。

        Face继承自ITrimmedSurface。它还提供了周围的边缘。

        Edge继承自ITrimmedCurve。它还提供相邻的面。

        拓扑类比它们实现的修剪对象接口具有更多的信息:

        修剪的对象接口没有连通性的概念。

        虽然它们可以分别返回面积和体积,但ITrimmedSurface和ITrimmedSpace并没有说明它们边界的形状。(With ITrimmedCurve,则边界本身没有形状,因为曲线只是由参数值限制。)

        7.3 文档对象和几何图形

        拓扑对象(Body、Face、Edge等)和几何体对象(平面、圆柱体、直线等)不是doc对象。它们不是父子层次结构的一部分,也没有名字对象或更新状态。它们是较低级别的对象,因为它们可能被doc对象引用,但它们本身并不了解文档和doc对象。

        您可以构造几何体、修剪对象甚至实体,以便执行几何计算,而无需修改文档:

public static void Example() {

// create infinite line with zero parameter at the origin 在原点创建零参数的无限长直线
Line line = Line.Create(Point.Origin, Direction.DirX);

// create line segment from (-0.01, 0, 0) to (0.01, 0, 0) 创建从(-0.01,0,0)到(0.01,0,0)的线段
ITrimmedCurve trimmedCurve = CurveSegment.Create(line, Interval.Create(-0.01, 0.01));
Debug.Assert(Accuracy.EqualLengths(trimmedCurve.Length, 0.02));

// find closest point to (0.05, 0.05, 0) 找到最接近(0.05,0.05,0)的点
CurveEvaluation eval = trimmedCurve.ProjectPoint(Point.Create(0.05, 0.05, 0));

// closest point on line segment should be (0.01, 0, 0) 线段上最近的点应为(0.01,0,0)
Debug.Assert(eval.Point == Point.Create(0.01, 0, 0));
}

        当您创建文档对象时,文档将被修改。例如,可以从修剪的曲线创建设计曲线。

        7.4 设计曲线

        设计曲线是最终用户所指的草图曲线。为了与设计实体、设计面和设计边保持一致,在API中将它们称为设计曲线。

        DesignCurve是一个doc对象,它有一个修剪过的曲线Shape。

public static void Example(Part part) {
Line line = Line.Create(Point.Origin, Direction.DirX);
ITrimmedCurve shape = CurveSegment.Create(line, Interval.Create(-0.01, 0.01));

// create a design curve
DesignCurve desCurve = DesignCurve.Create(part, Plane.PlaneXY, shape);

// the Shape property returns the trimmed curve Shape属性返回修剪的曲线
Debug.Assert(Accuracy.EqualLengths(desCurve.Shape.Length, 0.02));

// override the layer color 覆盖层颜色
desCurve.SetColor(null, Color.DarkSalmon);
}

        设计曲线具有修剪曲线概念之外的其他特性,例如图层、颜色替代和名称。

        7.5 设计体

        就像DesignCurve是一个doc对象,它有一个类型为ITrimmedCurve的Shape,实体也有类似的模式:

        DesignBody具有Body类型的Shape。

        DesignFace具有类型为Face的Shape。

        DesignEdge具有Edge类型的Shape。

        这只适用于这些文档对象主文件。对于相应的常规对象,可用的信息较少:

        IDesignBody具有类型为ITrimmedSpace的Shape。

        IDesignFace具有类型为ITrimmedSurface的Shape。

        IDesignEdge具有类型为ITrimmedCurve的Shape。

        这意味着,您只能从master访问详细的拓扑信息,例如循环和鳍:

public static void Example(IDesignFace desFace) {

// we can get the area from the ITrimmedSurface shape 我们可以从ITrimmedSurface形状中得到面积
double area = desFace.Shape.Area;

// but to access loops, we need to use the master 但要访问循环,我们需要使用主
DesignFace desFaceMaster = desFace.Master;

// if we access geometry, remember we are now in master-space 如果我们访问几何,请记住我们现在在主空间中
Matrix transToMaster = desFace.TransformToMaster;
DesignBody desBodyMaster = desFaceMaster.Parent;

// the master Shape is a Face rather than an ITrimmedSurface 主图形是面而不是ITrimmedSurface
Face face = desFaceMaster.Shape;
foreach (Loop loop in face.Loops)
foreach (Fin fin in loop.Fins) {
Edge edge = fin.Edge;

// get from shape back to doc object master 从形状返回到doc对象master
DesignEdge desEdgeMaster = desBodyMaster.GetDesignEdge(edge);

// from master to occurrence equivalent to desFace 从master到与desFace等效的引用
IDesignEdge desEdge = desEdgeMaster.GetOccurrence(desFace);
}
}

         但是,通用接口在doc对象级别提供了一些方便的连接性遍历:

public static void Example(IDesignFace desFace) {
IDesignBody desBody = desFace.Parent;

// the Edge property returns the edges in the face boundary 边属性返回面边界中的边
foreach (IDesignEdge desEdge in desFace.Edges) {
Debug.Assert(desEdge.Parent == desBody);

// the Faces property returns the faces that meet at this edge 面属性返回在此边相交的面
Debug.Assert(desEdge.Faces.Contains(desFace));
}
}
        7.6 通用shape

        shape也适用于具有未修剪几何体的文档对象,例如基准平面。DatumPlane实现了IHasSurfaceShape,它的Shape是一个ISurfaceShape,这并不奇怪。将其与DesignFace进行比较,后者实现了IHasTrimmedSurface并具有类型为ITrimmedSurface的Shape。存在此平行路径是因为IHasTrimmedSurface是从IHasSurfaceShape派生的,而ITrimmedSurface是从ISurfaceShape派生的。因此,无论几何体是未修剪的还是修剪的,总是有两步遍历,首先到Shape,然后到Geometry:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值