文章作者:里海
来源网站:https://blog.csdn.net/WangPaiFeiXingYuan


UF_MODL_ask_minimum_dist

Defined in: uf_modl.h 
int UF_MODL_ask_minimum_dist(tag_t object1, tag_t object2, int guess1_given, double guess1 [ 3 ] , int guess2_given, double guess2 [ 3 ] , double * min_dist, double pt_on_obj1 [ 3 ] , double pt_on_obj2 [ 3 ] )

overview 概述

UF_MODL_ask_minimum_dist finds the minimum distance between a pair of objects.
The objects can be:
1. any combination of points, curves, planes, edges, faces or bodies.
2. a faceted body and another faceted body or a solid edge, face
or body or a point
For objects not listed in 1, the error INVALID_ENTITY_TYPE is returned.
If an attempt is made to measure between a faceted body and an object
not listed in 2, the error UNSUITABLE_OBJECT_TYPES is returned.
The function returns a pair of points (one for each object)
at which the minimum distance is attained.
The user can optionally specify a point on or near each object that is
considered to be a good guess for the nearest point. The guess point
is ignored if either object is a faceted or solid body.
Or, the user can find the distance to specified point coordinates
by setting the object tag to NULL_TAG and inputting the point coordinates
as the “guess” point.
If either of the objects has a tolerance associated with it, the distance
value may only be acccurate to within that tolerance.
When a faceted body is involved in the measurement, the result may
not be as accurate as that obtained with the equivalent solid body.
It is recommended that UF_MODL_ask_minimum_dist_2 be used in this
case, as an extra argument is provided to output the accuracy of the
measurement.

UF _ MODL _ ask _ limit _ dist 查找一对对象之间的最小距离。对象可以是: 1。任何点、曲线、平面、边、面或身体的组合。2.对于未列在1中的对象,返回错误 INVALID _ ENTITY _ TYPE。如果尝试在刻面体和2中未列出的对象之间进行度量,则返回错误 UNSUITABLE _ OBJECT _ TYPES。函数返回一对点(每个对象一个) ,在这对点上达到最小距离。用户可以选择在每个对象上或附近指定一个点,这被认为是对最近点的一个很好的猜测。如果对象是平面体或实体体,则忽略猜测点。或者,用户可以通过将对象标记设置为 NULL _ TAG 并输入点坐标作为“猜测”点来找到到指定点坐标的距离。如果任何一个物体具有与之相关的公差,则距离值可能只在该公差范围内准确。当一个多面体参与测量时,结果可能不如用等效实体得到的结果精确。建议在这种情况下使用 UF _ MODL _ ask _ best _ dist _ 2,因为它提供了一个额外的参数来输出测量的准确性。

UFUN例子

欢迎订阅《里海NX二次开发3000例专栏》https://blog.csdn.net/wangpaifeixingyuan/category_8840986.html,点击链接扫码即可订阅(持续更新中)。已经有几百人订阅,订阅是永久的,无限期阅读,如需帮助请私信

parameters 参数

tag_t object1 Input First object (if NULL_TAG, the point coordinates in guess1 are used instead)
第一个对象(如果 NULL _ TAG,则使用 guess1中的点坐标)
tag_t object2 Input Second object (if NULL_TAG, the point coordinates in guess2 are used instead) If object1 and object2 are both NULL_TAG the distance from guess1 to guess2 is computed.
第二个对象(如果是 NULL _ TAG,则使用 guess2中的点坐标)如果 object1和 object2都是 NULL _ TAG,则计算从 guess1到 guess2的距离。
int guess1_given Input 1 - if a guess point for object1 is specified 0 otherwise Ignored if object1 is a body
1-如果对象1的猜测点被指定为0,否则忽略对象1是一个主体
double guess1 [ 3 ] Input Guess for the nearest point on object1, or point coordinates to use in the distance computation if object1 is a NULL_TAG. Ignored if object1 is a body.
如果 object1是 NULL _ TAG,则猜测 object1上最近的点,或者在距离计算中使用的点坐标。如果 object1是主体,则忽略它。
int guess2_given Input 1 - if a guess point for object2 is specified 0 otherwise Ignored if object2 is a body
1-如果对象2的猜测点被指定为0,否则忽略对象2是一个主体
double guess2 [ 3 ] Input Guess for the nearest point on object2, or point coordinates to use in the distance computation if object2 is a NULL_TAG. Ignored if object2 is a body.
如果 object2是 NULL _ TAG,则猜测 object2上最近的点,或者在距离计算中使用的点坐标。如果 object2是主体,则忽略它。
double * min_dist Output Resultant minimum distance.
最小距离。
double pt_on_obj1 [ 3 ] Output Minimum distance Point on object1.
物体上的最小距离点1。
double pt_on_obj2 [ 3 ] Output Minimum distance Point on object2.
物体上的最小距离点2。

>>> 返回目录

分割

C++语言在UG二次开发中的应用及综合分析

  1. C++ 是C语言的扩展,它既可以执行C语言的过程化程序设计,也可以进行以抽象数据类型为特点的基于对象的设计,以及面向对象的程序设计。C++ 在处理问题规模上具有很大的适应性。
  2. C++不仅具有计算机高效运行的实用性特征,并且致力于提升大规模程序的编程质量以及程序设计语言的问题描述能力。

在UG二次开发中,C++语言具有以下特点

  1. C++语言支持多种程序设计风格
  2. C++的许多特性以库的形式存在,保证了语言的简洁和开发运行的效率
  3. 与C语言相比,C++引入了面向对象的概念,使得UG二次开发的人机交互界面更加简洁
  4. 通过借助UG自带的2000多种API函数,结合高级语言C++以及编程软件Visual Studio,可以对UG进行二次开发
  5. 需要注意的是,市场上的Visual Studio和UG版本众多,并非所有版本都能兼容

程序设计过程通常包括以下步骤:

  1. 问题分析:对要解决的问题进行深入的分析,理解问题的具体需求和限制。
  2. 需求定义:明确程序的目标和功能,包括用户需求、系统需求等。
  3. 设计:根据需求进行设计,包括算法设计、数据结构设计、界面设计等。
  4. 编码:根据设计的结果,使用一种编程语言将程序代码实现出来。
  5. 测试:通过各种测试方法来确保程序的正确性,包括单元测试、集成测试、系统测试等。
  6. 维护:对程序进行修改和完善,以解决可能出现的问题或满足新的需求。
  7. 文档编写:编写程序文档,描述程序的功能、操作方法、注意事项等。

以下是一个创建体素特征(块、柱、锥、球)的二次开发例子

#include <stdio.h>
#include <stdarg.h>
#include <uf_modl_primitives.h>
#include <uf_ui_ugopen.h>
#include <uf.h>
#include <uf_defs.h>
//封装打印函数,用于将信息打印到信息窗口
//QQ3123197280
int ECHO(const char* szFormat, ...)
{
	char szMsg[5000] = "";
	va_list arg_ptr;
	va_start(arg_ptr, szFormat);
	vsprintf_s(szMsg, szFormat, arg_ptr);
	va_end(arg_ptr);
	UF_UI_open_listing_window();
	
	UF_UI_write_listing_window(szMsg);
	return 0;
}
extern DllExport void ufusr(char* param, int* returnCode, int rlen)
{
	UF_initialize();
	//创建块
	UF_FEATURE_SIGN sign = UF_NULLSIGN;
	//块起点相对于ABS
	double block_orig[3] = { 0.0,0.0,0.0 };
	//方向相对于WCS
	char* block_len[3] = { "10", "30", "10" };
	tag_t blk_obj;//体特征
	UF_MODL_create_block1(sign, block_orig, block_len, &blk_obj);
	int iEdit = 0;  
	char* size[3];
	UF_MODL_ask_block_parms(blk_obj, iEdit, size);
	ECHO("%s,%s,%s\n", size[0], size[1], size[2]);//输出: p6=10,p7=30,p8=10
	//创建圆柱
	UF_FEATURE_SIGN sign1 = UF_NULLSIGN;
	double origin[3] = { 10.0,0.0,10.0 };
	char  height[] = "20";
	char  diam[] = "10";
	double direction[3] = { 0,0,1 };//方向
	tag_t  cyl_obj_id;
	UF_MODL_create_cyl1(sign1, origin, height, diam, direction, &cyl_obj_id);
	int iEdit2 = 0;  
	char* cDiameter;
	char* cHeight;
	UF_MODL_ask_cylinder_parms(cyl_obj_id, iEdit2, &cDiameter, &cHeight);
	ECHO("%s,%s\n", cDiameter, cHeight);//输出:p9=10,p10=20
	UF_free(cDiameter);
	UF_free(cHeight);
	//创建圆锥
	UF_FEATURE_SIGN sign2 = UF_NULLSIGN;
	double origin2[3] = { 0.0,0.0,10.0 };
	char  height2[] = "20";
	char* diam2[2] = { "10" ,"5" };
	double direction2[3] = { 0,0,1 };//方向
	tag_t  cone_obj_id;
	UF_MODL_create_cone1(sign2, origin2, height2, diam2, direction2, &cone_obj_id);
	int iEdit3 = 0;  
	char* cD1;
	char* cD2;
	char* cH;
	char* cAngle;
	UF_MODL_ask_cone_parms(cone_obj_id, iEdit3, &cD1, &cD2, &cH, &cAngle);
	ECHO("%s,%s,%s,%s\n", cD1, cD2, cH, cAngle);//输出:p11=10,p12=5,p13=20,p14=7.1250163489018
	UF_free(cD1);
	UF_free(cD2);
	UF_free(cH);
	UF_free(cAngle);
	//创建球
	UF_FEATURE_SIGN sign3 = UF_NULLSIGN;
	double douCenter2[3] = { 0.0,0.0,30.0 };
	char  cDiam[] = "8";
	tag_t  sphere_obj_id;
	UF_MODL_create_sphere1(sign3, douCenter2, cDiam, &sphere_obj_id);
	int iEdit4 = 0;  
	char* cDiam_parm;
	UF_MODL_ask_sphere_parms(sphere_obj_id, iEdit4, &cDiam_parm);
	ECHO("%s\n", cDiam_parm);//输出:p15=8
	UF_free(cDiam_parm);
	UF_terminate();
}
extern int ufusr_ask_unload(void)
{
	return (UF_UNLOAD_IMMEDIATELY);
}

效果:
效果

Logo

分享最新的 NVIDIA AI Software 资源以及活动/会议信息,精选收录AI相关技术内容,欢迎大家加入社区并参与讨论。

更多推荐