NX二次开发UF_MODL_create_reparam_sheet 函数介绍

183 阅读14分钟

UF_MODL_create_reparam_sheet

Defined in: uf_modl_freeform.h 
int UF_MODL_create_reparam_sheet(int proj_type, int drv_type, int check_overlap, int num_primary, tag_t * prim_cvs, int num_cross, tag_t * cros_cvs, double * proj_vec, int num_fs, tag_t * faces, double tols [ 5 ] , tag_t * new_face, int * tol_achieved )

overview 概述

Creates a single, bicubic, b-surface, sheet body that approximates a four-sided region of several existing faces. The driver curves or B-surface must lie inside the boundary of the target surfaces. Basically, points on a "driver" surface are projected along some given vector or along the driver surface normal vectors onto the "target" faces (the ones being approximated). These projected points are then used to construct the approximating sheet body. You can think of the projection as a process of emitting a ray from each original point to hit the target faces.

The accuracy of the approximated sheet body depends on the supplied tolerances. See the section on tolerances for more information. Projection Type, Vector, and Size Limit (tol[4])

If the proj_type is set to use driver surface normal, then you do not need to supply any data for the projection vector (it is ignored if you do). Otherwise, a projection vector must be specified.

When using surface normal projections, you may supply a tolerance value (tol[4]). This value helps the algorithm decide which point on the approximating faces to use if the faces bend around and the emitted ray finds two intersection points. A value of zero causes the system to default to 10 times the interior distance tolerance. If your driver is far from the target (more than 10 times the tolerance), then you should adjust the projection size limits.

Driver Type Internally, the driver is always a b-surface. However, for convenience, we allow you to select a mesh of curves, instead of a surface. We just build a b-surface internally from this mesh of curves. Therefore, when you use curves as drivers, they must satisfy all the conditions required for building a curve-mesh free form.

The last driver type option, self-refit, provides a short-cut way to approximate a single untrimmed b-surface. You might do this if you are given a surface of high degree and you want to approximate it with a lower degree surface (the reparameterize function always outputs bicubic surfaces, i.e. surfaces of degree 3 in both the U and V directions).

Overlap Checking If this option is set to "Yes," then the system checks for and tries to handle overlapping faces. The system tries to intersect each ray with all nearby faces, and finds the "uppermost" projection point. This can be a time exhaustive process. If the overlap option is set to "No," the algorithm assumes that each emitted ray can only hit one target face, so it stops and proceeds to the next ray as soon as it finds a hit. This is less time exhaustive if the target faces do not actually overlap, or if they are close together in the regions where they do overlap.

Curves The primary and cross curves are only necessary if you indicate the driver type to be curves. The number of primary and cross curves must be at least two and less than 50. The number of curves and the curve tags are ignored if you specify a driver type other than curve. The curves are going to be used to build a curve-mesh free form. Therefore, each primary curve must intersect each of the cross curves once and only once. If you suspect your curves are inappropriate, you might want to build the curve-mesh free form body yourself before using the reparameterize function.

If you have specified a driver type of face or self-refit, than specify the appropriate face tag. Obviously, using an existing driver surface is much more convenient than using the same set of driving curves over and over again. So, if you are using the function repeatedly in a loop, it might be worth constructing the b-surface sheet body to use as a driver.

Tolerances This allows you to specify the tolerances to be used in the approximation process. The algorithm actually starts out with a very simple approximating surface (which is unlikely to be within tolerance) and then gradually makes it more complex until it is able to replicate the original shape to within the specified tolerances. Using tighter tolerances produces a more complex result, and this consumes storage space and slows down all subsequent operations. Therefore, the tolerances you use should not be any tighter than they need to be. We expect the algorithm to be used with distance tolerances of around .039 to 0.195 inches (1 to 5 mm) and angular tolerances of 2 to 20 degrees. If you use tight angular tolerances on very wavy surfaces, the algorithm generates huge number of patches. If you set both angular tolerances to 90 degrees, then angular deviation in not even checked, which greatly speeds up processing.

To achieve reasonable performance, the algorithm does not rigorously check the deviation between the approximating face and the originals. We actually just check a small array of points on each patch of the approximating face. Experience has shown that this is a reasonable way to estimate the actual error in practical cases, though one could certainly construct pathological examples where this approach would fail.

Tighter tolerances may be specified at the edges to assure better alignment with adjacent faces. Looser tolerances in the interior may be specified to allow a simpler face to be created.

Target Faces Faces can lie on a single body or on multiple bodies. Only face tags may be used. This parameter is ignored if you specified the self-refit option for driver type.

Output The function returns the tag of the created sheet body and a flag stating where the surface was able to meet tolerance. The tolerance flag has no meaning if a body was not created. The face created is a bicubic b-surface with double knots, which means it is C1 continuous

See glossary

In other words, the face is smooth, it does not have any sharp ridges or cusps. The resulting body is not associative to the input data.

The sheet body may not reach tolerance if, during the approximation process, one of the patches is found to be smaller in width or length than the inside distance tolerance. This usually indicates a perturbation or other anomaly in a region of one of the input faces. You may wish to analyze the resulting face for deviations, validity, and shape. The algorithm does not really make any attempt to preserve the "character" of the input faces, it just tries to stay within tolerance. Small features sometimes get smoothed away and extraneous wrinkles may be introduced, especially in areas with tight curvature.

Tips and Techniques The algorithm assumes that your input faces are reasonably clean. It is designed to handle certain types of anomalies, such as small gaps (up to approximately 1mm) overlaps, providing the overlapping faces are roughly the same height, very thin faces (up to 0.1 mm wide) and duplicate faces.

In all of the figures that follow in this tips and techniques section we show a side view of the driver surface and target faces. The driver surface is always shown above the target faces. However, the approximation process has difficulties handling input data in which there are extraneous faces that are at different heights from the desired face.

overlapping faces that are at different heights faces that have not been properly trimmed back (for example, when filleted) sharp ridges, where faces do not join smoothly backdrafts and undercuts nearly vertical walls. For simple shapes, with loose tolerances, a brute force approach, using just four drive curves, might work okay. But taking some care in the constructing drive curves is usually worth the extra effort. If your target face includes feature lines like long ridges or valleys with small radius of curvature in one direction, you should try to construct driver curves that run roughly parallel to these. This makes it much easier for the algorithm to achieve tolerance using a reasonably small number of patches. It may be a good idea to build several approximating faces, and then sew them together, instead of trying to approximate the entire area with a single face. This often produces less data and smaller models. One reason for this is the natural patch structure for b-surfaces. The "seams" between patches on a single surface must always run all the way across the surface, from one edge to the opposite edge. This means that any complexity that gets introduced into the surface in one area propagates across the entire surface. If you approximate different regions separately, you can sew the approximating face together into a sheet body.
创建一个单一的、双三次的、 b 表面的工作表主体,该工作表主体近似于几个现有工作面的四边形区域。驱动曲线或 B 曲面必须位于目标曲面的边界内。基本上,“驱动器”表面上的点沿着一些给定的向量或者沿着驱动器表面的法向量投影到“目标”表面(被近似的表面)。这些投影点,然后用来建立近似板体。您可以将投影看作是从每个原始点发射射线以击中目标面的过程。近似板体的精度取决于所提供的公差。有关更多信息,请参见公差部分。如果 proj _ Type 被设置为使用驱动器曲面法线,那么您不需要为投影向量提供任何数据(如果您这样做,它将被忽略)。否则,必须指定投影向量。当使用表面法线投影时,您可以提供一个公差值(tol [4])。这个值可以帮助算法决定在近似面上使用哪个点,如果面弯曲并且发射的光线找到两个交点。如果值为零,则系统默认值为内部距离公差的10倍。如果您的驱动程序远离目标(超过10倍的公差) ,那么您应该调整投影大小的限制。驱动程序类型在内部,驱动程序始终是一个 b 表面。然而,为了方便起见,我们允许您选择曲线网格,而不是曲面。我们只需要在内部构建一个 B 曲面就可以了。因此,当您使用曲线作为驱动程序时,它们必须满足构建曲线网格自由格式所需的所有条件。最后的驱动程序类型选项,自修复,提供了一个近似未修剪的单个 b 表面的捷径方法。如果给定一个高度曲面,你想用一个低度曲面来近似它,你可以这样做(重新参数化函数总是输出双三次曲面,即 U 和 V 两个方向的3度曲面)。重叠检查如果这个选项被设置为“是”,那么系统检查并尝试处理重叠的面。该系统试图与所有附近的面相交的每一条射线,并找到“最上面”的投影点。这可能是一个耗尽时间的过程。如果重叠选项设置为“ No”,则算法假定每个发射的射线只能击中一个目标面,因此一旦发现击中,它就会停止并继续向下一个射线发射。如果目标面实际上并没有重叠,或者如果它们在重叠的区域靠得很近,这样就不会耗费太多时间。曲线主曲线和交叉曲线只有当你指出驱动器类型是曲线时才是必要的。主曲线和交叉曲线的数目必须至少为2条,小于50条。如果指定曲线以外的驱动程序类型,则忽略曲线的数量和曲线标记。曲线将被用来建立一个曲线网格自由形式。因此,每条主曲线必须与每条交叉曲线相交一次,而且只能相交一次。如果您怀疑您的曲线是不适当的,您可能希望在使用重新参数化函数之前自己构建曲线网格自由形体。如果指定了驱动程序类型的面部或自修复,则指定适当的面部标记。显然,使用现有的驱动器表面要比一遍又一遍地使用同一组驱动曲线方便得多。因此,如果您在循环中重复使用该函数,那么可能值得构造用作驱动程序的 b-Surface 工作表主体。公差这允许你指定在近似过程中使用的公差。该算法实际上从一个非常简单的近似曲面(不太可能在公差范围内)开始,然后逐渐使其变得更加复杂,直到能够将原始形状复制到规定的公差范围内。使用更严格的公差会产生更复杂的结果,这会消耗存储空间并减慢所有后续操作的速度。因此,您使用的公差不应该比它们需要的更紧。我们希望该算法能够用于大约0.039到0.195英寸(1到5毫米)的距离公差和2到20度的角度公差。如果在非常波浪的表面上使用紧密的角度公差,算法会生成大量的补丁。如果你设置两个角度公差为90度,那么角度偏差在甚至没有检查,这大大加快了处理。为了达到合理的性能,该算法没有严格检查逼近面与原始面之间的偏差。我们实际上只是检查一个小数组的点在每个补丁的近似脸。经验表明,这是在实际情况下估计实际误差的一种合理方法,尽管人们当然可以在这种方法失败的情况下构建病理学实例。可以在边缘指定更紧的公差,以确保与相邻面更好地对齐。可以指定内部较松的公差,以便创建更简单的面。目标面孔可以在一个身体上或在多个身体上。只能使用面部标签。如果为驱动程序类型指定了自修复选项,则忽略此参数。输出函数返回创建的工作表主体的标记和一个标志,说明表面在哪里能够满足公差。如果没有创建主体,容忍标志就没有任何意义。创建的面是一个双三次 B 型面带有双节,这意味着它是 C1连续见词汇表换句话说,面是光滑的,它没有任何尖锐的脊或尖端。生成的主体与输入数据不关联。如果在近似过程中,发现其中一块贴片的宽度或长度小于内部距离公差,则板体可能达不到公差。这通常表示在一个输入面的一个区域中的一个扰动或其他异常。您可能希望分析结果表面的偏差、有效性和形状。该算法并没有真正尝试保留输入面的“字符”,它只是试图保持在容忍的范围内。小的特征有时会得到平滑和无关的皱纹可能会引入,特别是在地区与紧曲率。提示和技巧该算法假设您的输入面相当干净。它被设计用于处理特定类型的异常,例如小间隙(大约1毫米)重叠,提供重叠面大致相同的高度,非常薄的面(大约0.1毫米宽)和重复的面。在本技巧和技术部分的所有图片中,我们展示了驾驶员表面和目标面的侧面图。驱动程序表面总是显示在目标表面的上方。然而,近似过程有困难处理的输入数据,其中有无关的面,在不同的高度从理想的面。在不同高度上有重叠的表面,表面没有被适当地修剪(例如,当切成圆角时)锋利的脊状突起,表面没有连接平滑的回流线,削弱了几乎垂直的墙壁。对于公差较小的简单形状,只使用四条驱动曲线的蛮力方法可能还行。但是在构造驱动曲线时要小心,这通常是值得付出额外的努力的。如果你的目标面包括一些特征线,比如在一个方向上具有小半径曲率的长山脊或山谷,你应该尝试构建与这些特征线大致平行的驱动曲线。这使得算法更容易实现公差使用合理的少量补丁。这可能是一个好主意,建立几个近似的面,然后把它们缝在一起,而不是试图用一个单一的面来近似整个区域。这通常会产生更少的数据和更小的模型。其中一个原因是 b-曲面的自然斑块结构。单个表面上的补丁之间的“接缝”必须始终贯穿整个表面,从一个边缘到相反的边缘。这意味着,任何复杂性被引入到表面的一个区域,传播到整个表面。如果分别对不同的区域进行近似,可以将近似的面缝在一起形成一个片状体。

UFUN例子

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

parameters 参数

intproj_typeInputType of projection 0 = Use input vector 1 = Use driver surface normal
投影类型0 = 使用输入向量1 = 使用驱动器曲面法线
intdrv_typeInputType of drive 0 = Curves 1 = Face (B-surface type) 2 = Self-refit (B-surface type)
驱动器类型0 = 曲线1 = 面(B 表面类型)2 = 自修(B 表面类型)
intcheck_overlapInputFlag for controlling the overlap checking 0 = No 1 = Yes
控制重叠检查的标志0 = No 1 = Yes
intnum_primaryInputNumber of primary curves
主曲线数
tag_t *prim_cvsInputObject identifiers of the primary curves (face object identifier, if drv_typ != 0)
主曲线的对象标识符(face 对象标识符,如果 drv _ type! = 0)
intnum_crossInputNumber of cross curves
交叉曲线数
tag_t *cros_cvsInputObject identifiers of the cross curves
交叉曲线的对象标识符
double *proj_vecInputProjection vector
投影矢量
intnum_fsInputNumber of target faces
目标面数
tag_t *facesInputObject identifiers of the target faces
目标面的对象标识符
doubletols [ 5 ]InputTolerances: [0] = Distance tolerance in interior of surface [1] = Angular tolerance (in degrees) in interior of surface [2] = Outside edge distance tolerance [3] = Outside edge angular tolerance (in degrees) [4] = Projection size limit (0 - if no limit)
公差: [0] = 表面内部的距离公差[1] = 表面内部的角公差(度)[2] = 外边缘距离公差[3] = 外边缘角公差(度)[4] = 投影尺寸限制(0-如果没有限制)
tag_t *new_faceOutputObject identifier of the resultant face
结果面的对象标识符
int *tol_achievedOutputFlag indicating that the resultant face achieved the tolerance requirements. 0 = No 1 = Yes
标志,表明合成的工作面达到了公差要求。0 = No 1 = Yes