UF_CURVE_smooth_spline_data
Defined in: uf_curve.h
int UF_CURVE_smooth_spline_data(UF_CURVE_spline_p_t spline_data, int cont_order, double distance_toler, double angle_toler, int * num_states, UF_CURVE_state_p_t * states )
overview 概述
Makes a spline continuous to cont_order, if possible.
The order of continuity may be any positive integer up to (but not including) the degree of the spline (the degree is order-1).
NOTE: cont_order values greater than 1 are not currently supported, but may be specified.
Curves created interactively by NX, by creating a curve directly or through modeling a solid body, do not need this function. Only if you manage to create a curve with a corner, as by joining two splines, is it possible to create a curve that would be affected by this function.
The spline must be C0 before calling this function, but it may have degeneracies. C0 means continuous to order zero, which means that it has no gaps. Splines that have end knots with a multiplicity greater than the order of the spline, or have interior knots with a multiplicity greater than the degree of the spline, may have gaps. Such splines are not of general utility in CAD/CAM work. The creation function (UF_CURVE_create_spline) will not create them and this function will not smooth them. They can be fixed using UF_CURVE_fix_spline_data, and then smoothed if necessary.
Specification of a given cont_order implies that all lower order continuities are desired. The order of continuity is the highest order derivative that is required to exist at all points of the spline. At any point in the spline, if cont_order cannot be achieved, the highest continuity within tolerance is achieved. If C1 cannot be achieved, G1 is achieved within tolerance and a state code is returned. If G1 cannot be achieved a state code is returned. Whatever can be smoothed within tolerance is returned even if the entire spline cannot be done. States are returned for all conditions found in the spline.
Any knot that has a multiplicity high enough to make it possible for the spline to be discontinuous to the given order at the corresponding pole is checked. If the pole can be treated in such a way as to make it continuous to the given order without changing the shape more than toler, it is made so.
Think of discontinuities as 'corners'. A discontinuity in the first derivative is what one most often thinks of as a corner; it is readily visualized. A discontinuity in the second derivative is similar to a discontinuity in the first derivative, that is, it is a corner, but it is a corner in the first derivative. Basically, a knot of multiplicity order-n means the curve is potentially discontinuous in the nth derivative. It now becomes apparent what C0 comes from: it means continuity in the 'zero-th derivative', referring to the condition introduced by a knot of multiplicity order (or greater), which is a potential gap in the curve. Open curves, and some closed curves, have knots of multiplicity order at the ends, where they are not C0, because, naturally, they stop.
If the spline is closed the closure is also checked and smoothed if within tolerance.
Continuity is achieved using a mathematical process called knot removal. Geometric continuity (G1) is achieved by moving the poles.
Use this function conservatively. In particular, if simplification is to be done when the geometry is attached or edited on a body topology, be aware that smoothing may make the spline's equivalent curve (such as a circle) unrecognizable to the simplifier. One of two things might happen:
-
The curve may be modified in its point and knot content so as not to match the patterns that the simplifier uses to recognize simplifiable curves, or,
-
If the smoothing tolerance is large enough, it may be modified so that it is out of matching tolerance on the possible simplified curve.
Consult a textbook on NURBS curves (NX splines are NURBS curves) for more information on continuity and the interpretaion of the knot vector. One such book is "The NURBS Book," by Piegl and Tiller, Springer Verlag, 1995. The first 100 pages provide a good grounding.
如果可能,使样条连续到 cont _ order。连续性的次序可以是任何正整数,直到(但不包括)样条的次数(次数为 -1)。注意: 目前不支持大于1的 cont _ order 值,但可以指定。由 NX 交互式创建的曲线,通过直接创建曲线或通过建模一个实体,不需要这个功能。只有当你设法创建一条带角的曲线,就像连接两个样条一样,才有可能创建一条会受到这个函数影响的曲线。在调用这个函数之前,样条必须是 C0,但它可能具有简并性。C0意味着连续到零,这意味着它没有间隙。如果样条的末端节点的多样性大于样条的顺序,或者样条的内部节点的多样性大于样条的度,则可能有间隙。这样的样条在 CAD/CAM 工作中没有通用性。创建函数(UF _ CURVE _ create _ spline)不会创建它们,这个函数也不会平滑它们。它们可以使用 UF _ CURVE _ fix _ spline _ data 进行修正,然后在必要时进行平滑。指定给定的 cont _ order 意味着需要所有的低阶连续性。连续阶是样条曲线上所有点都必须存在的最高阶导数。在样条曲线的任意一点上,如果不能达到 cont _ order,则可以达到公差范围内的最高连续性。如果不能实现 C1,则在允许范围内实现 G1,并返回状态代码。如果不能实现 G1,则返回状态代码。即使不能完成整个样条曲线,也会返回在公差范围内可以平滑的内容。对于样条中找到的所有条件,返回状态。检查任何具有足够高的多重性,使得样条曲线在对应的极点处不连续于给定次序的节点。如果可以这样对待杆,使其连续到给定的顺序而不改变形状多于公差,它就是这样做的。把不连续性想象成“角落”。一阶导数中的不连续性是人们通常认为的角; 它很容易被视觉化。二阶导数中的不连续性类似于一阶导数中的不连续性,也就是说,它是一个角,但它是一阶导数中的一个角。基本上,多重数阶的结-n 意味着曲线在 n 阶导数中可能是不连续的。现在很明显 C0来自于什么: 它意味着“零阶导数”的连续性,指的是由一个多重数阶(或更大)的结引入的条件,这是曲线中的一个势差。开放曲线和一些封闭曲线,在两端有多重次序的节点,它们不是 C0,因为它们自然地停止了。如果花键是闭合的,那么闭包也会被检查,如果在公差范围内则会被平滑。连续性是通过一个叫做结移除的数学过程来实现的。几何连续性(G1)是通过移动两极来实现的。谨慎使用此函数。特别是,如果简化要做的时候,几何附加或编辑的体拓扑,请注意,平滑可能使样条的等效曲线(如圆)无法识别的简化。有两种情况可能发生: 1。曲线可以修改其点和结的内容,以便不匹配的模式,简化程序使用来识别简化曲线,或,2。如果平滑公差足够大,可以对其进行修改,使其在可能的简化曲线上超出匹配公差。参考 NURBS 曲线教科书(NX 样条是 NURBS 曲线)了解更多关于连续性和节点矢量的解释。一本这样的书是“ NURBS 书”,由皮格尔和蒂勒,斯普林格出版社,1995年。前100页提供了一个良好的基础。
UFUN例子
获取源码例子请搜索 里海NX二次开发3000例专栏
parameters 参数
| UF_CURVE_spline_p_t | spline_data | Input / Output | spline data to make continuous 样条数据,使连续 |
| int | cont_order | Input | order of continuity to achieve 实现连续性的顺序 |
| double | distance_toler | Input | tolerance; smoothing is done if the deviation in shape introduced is less than this amout. Zero indicates use NX modelling resolution. 公差; 如果引入的形状偏差小于此数值,则进行平滑处理。零表示使用 NX 建模分辨率。 |
| double | angle_toler | Input | tolerance; smoothing is done if the angle between tangents at the joint is less than this amount. Zero indicates use NX modelling resolution. 公差; 如果连接处的切线之间的夹角小于这个数值,则进行平滑。零表示使用 NX 建模分辨率。 |
| int * | num_states | Output | number of states in returned states array 返回状态数组中的状态数 |
| UF_CURVE_state_p_t * | states | Output to UF_free | Pointer to array pointer for joints where continuity could not be achieved within tolerance. This must be freed by calling UF_free. May also contain knot fixup states. 对于连续性不能在公差范围内达到的连接,指向数组指针的指针。这必须通过调用 UF _ free 来释放。也可能包含结修复状态。 |