NX二次开发UF_CURVE_smooth_spline_data_st 函数介绍

159 阅读5分钟

UF_CURVE_smooth_spline_data_st

Defined in: uf_curve.h 
int UF_CURVE_smooth_spline_data_st(UF_CURVE_spline_p_t spline_data, int cont_order, double dist_toler [ 3 ] , double ang_toler, int * num_states, UF_CURVE_state_p_t * states )

overview 概述

See the documentation for UF_CURVE_smooth_spline_data for a description of smoothing. UF_CURVE_smooth_spline_data_st differs from it only in its tolerance argument, dist_toler and in the interpretation of the continuity state distance value.

3D curves are isotropic, that is, they occupy space with the same "density" in all three directions. If the curves you are smoothing are always isotropic, use UF_CURVE_smooth_spline_data.

UF_CURVE_smooth_spline_data_st smooths using a shear tolerance specification, meaning that it may have different values for x, y, and z. Use it for smoothing bcurves destined to become fin curves, which are used to trim surfaces. (See UF_BREP).

Fin curves are defined in the surface parameter, or SP, space, of some surface and thus are often called SP curves. Their existence in 3-space is a composition of their two-dimensional definition and the 3-dimensional existence of the surface. An SP curve defined on a surface has u,v coordinates, with the third coordinate (normally z) being zero, instead of x, y, z coordinates. In specifying the coordinates of the bcurves vertices, and the tolerances for smoothing, the x coordinate is the u value and the y coordinate is the v value.

SP curves for trimming surfaces are anisotropic, that is, not isotropic. They do not occupy space with the same "density" in both directions. Consider a cylinder, which has a parameterization of part units (mm or in) in u (along the axis) and angular units (radians) in v (around the axis). Thus u has the same dimensions as 3-space, but v does not, indeed the v parameter being angular causes a dependence on the radius for the correspondence between the v tolerance in 3D and in parameter space.

Suppose we have a cylinder of radius 10mm, and we want changes from smoothing restricted to .02mm. dist_toler[0] = .02 is the tolerance for u. dist_toler[1] = .02/10 is the tolerance for v (it is not an approximation). A curve along the surface in v is a circle, and so the distance along the curve (the 3D tolerance) is equal to the radius times the angle (the v tolerance). Working the algebra leads to the expression for dist_toler[1]. Similar methods work for other analytic surface types. Generally a method that yields a smaller rather than larger tolerance is preferable, like finding some approximation to the largest radius of a surface of revolution, or the radius of a cone at the larger part of where the face occupies the cone.

For a bsurface (which is anisotropic except in some very special cases), it may be necessary to select a u,v pair, get a point, offset the u,v pair by a small amount, get another point, and work the proportions to obtain the u and v deltas that correspond to the desired 3D tolerance. Surfaces can vary in their parameterization, and that affects the tolerances obtained. You have to gain some knowledge about your surfaces; surfaces made by NX dont contain variations in parameterization from one part of the surface to another, so selecting 0.5, 0.5 as the evaluation point should be sufficient.

Note: cont_order values greater than 1 are not currently supported, but may be specified.


有关平滑的描述,请参阅 UF _ CURVE _ ooth _ spline _ data 的文档。UF _ CURVE _ shine _ spline _ data _ st 与它的区别仅在于它的容差参数,dist _ toler 以及对连续状态距离值的解释。三维曲线是各向同性的,也就是说,它们在所有三个方向上都以相同的“密度”占据空间。如果你平滑的曲线总是各向同性的,那么使用 UF _ CURVE _ ooth _ spline _ data。使用剪切公差规范的 UF _ CURVE _ shine _ spline _ data _ st 平滑,这意味着它可能对 x、 y 和 z 有不同的值。使用它平滑注定要成为鳍曲线的 b 曲线,用于修剪表面。(见 UF _ BREP)。鳍曲线定义在某些曲面的表面参数或 SP 空间中,因此通常称为 SP 曲线。它们在三维空间中的存在是由它们的二维定义和曲面的三维存在构成的。定义在曲面上的 SP 曲线有 u,v 坐标,第三个坐标(通常是 z)为零,而不是 x,y,z 坐标。在指定 b 曲线顶点的坐标和平滑公差时,x 坐标是 u 值,y 坐标是 v 值。修边曲面的 SP 曲线是各向异性的,即不是各向同性的。它们不会在两个方向上以相同的“密度”占据空间。考虑一个圆柱体,它的参量化单位(毫米或英寸)为 u (沿着轴线) ,角单位(弧度)为 v (绕着轴线)。因此,u 与3-空间具有相同的维数,但是 v 不具有,实际上,v 参数是角的,因此在3D 和参数空间中,v 公差之间的对应关系依赖于半径。假设我们有一个半径为10毫米的圆柱体,我们希望从平滑限制到0.02毫米的变化。Dist _ toler [0] = .02是 u. dist _ toler [1] = .02/10是 v 的公差(它不是近似值)。沿着 v 表面的曲线是一个圆,因此沿着曲线的距离(3D 公差)等于半径乘以角度(v 公差)。使用代数可以得到 dist _ toler [1]的表达式。类似的方法也适用于其他分析曲面类型。一般来说,产生一个较小而不是较大的公差的方法是可取的,比如找到一些近似公转曲面的最大半径,或者在圆锥面占据圆锥面的较大部分处找到一个圆锥体的半径。对于一个双曲面(除了在一些非常特殊的情况下是各向异性的) ,可能需要选择一个 u,v 对,得到一个点,偏移 u,v 对一小部分,得到另一个点,并工作的比例,以获得对应于所需的3D 公差的 u 和 v 三角洲。表面的参量化可能会有所不同,从而影响所得的公差。你必须对你的表面有一些了解,由 NX 制作的表面不包含从表面的一个部分到另一个部分的参量化变化,所以选择0.5,0.5作为评价点应该足够了。注意: 目前不支持大于1的 cont _ order 值,但可以指定。

UFUN例子

获取源码例子请搜索 里海NX二次开发3000例专栏

parameters 参数

UF_CURVE_spline_p_tspline_dataInput / Outputspline to smooth
从花键到光滑
intcont_orderInputorder of continuity to get
获得连续性的顺序
doubledist_toler [ 3 ]Inputdont exceed this, x, y, z
不要超过这个,x,y,z
doubleang_tolerInputdont exceed this
不要超过这个
int *num_statesOutputnumber of states in states array
状态数组中的状态数
UF_CURVE_state_p_t *statesOutput to UF_freestates found during smoothing. The caller is responsible for freeing this by calling UF_free.
调用者通过调用 UF _ free 负责释放这些状态。