点击查看详细介绍

UF_MODL_replace_features() 函数的参数解释说明、函数详细用法,以及实例代码演示

misnn 7年前 789 0

购买与咨询 NX 二次开发视频教程,请联系微信号:13890821008  QQ号:85585969  


函数结构:
UF_MODL_replace_features
(
tag_t * original_features,
int n_original_features,
tag_t * replacement_features,
int n_replm_features,
logical return_map,
logical use_copy_of_replacement,
UF_MODL_replace_features_t * * parent_map,
int * n_parent_map
)

函数说明:
此功能替换original_features []的功能在replacement_features []特征或特征的拷贝replacement_features []如果original_features []是对机构的特点,曲线特征和基准特征。该original_features的孩子[]将重设父到replacement_features []或复印件。原有功能将被删除。original_features []可以包含:在相同的身体特征,曲线的特点,基准面和基准轴的功能。replacement_features []必须包括:对其他机构的功能(如original_features []包含对身体特征),另一条曲线特征(如果original_features []包含曲线特征)等基准面和其他基准轴功能(如果original_features []包含基准面或基准轴的功能)。需要注意的是original_features []和replacement_features []必须包含功能,是在相同的部分文件。另外,对于在身体功能,该在replacement_features每个功能亲[]必须是在replacement_features []或其他功能必须是一个功能,在original_features []最早的功能之前。parent_map通过向在original_features []在[]的地图实体对应于replacement_features []实体。除了original_features []和replacement_features []你将不得不提供地图在original_features []边和面的对应边和在replacement_features []的面孔。您将指定地图类型的对象的数组UF_MODL_replace_features_t如下所述。的孩子们original_features []将重设父到相应的副本上是在parent_map []指定的replacement_features []实体。调用带有return_map为真不执行替换该功能但返回的parent_map []的每个元素original_entity边缘都和面由original_features创建[]。只有那些边缘和脸部特写下游的特点父母在parent_map []返回。该在parent_map []所有结构replacement_entity元素是0。您必须分配适当replacement_entity为每在parent_map []返回的结构调用这个函数之前return_map假执行实际的替代。

函数参数:
第1个参数为输入:
original_features代表参数变量,tag_t * 为输入参数类型,功能阵列,以取代

第2个参数为输入:
输入int 整数型的参数,参数的变量格式为n_original_features,原有的特色,数

第3个参数为输入:
replacement_features代表参数变量,tag_t * 为输入参数类型,更换阵列功能

第4个参数为输入:
输入int 整数型的参数,参数的变量格式为n_replm_features,更换的数量特征

第5个参数为输入:
return_map代表参数变量,logical 为输入参数类型,return_map=真 - 返回在parent_map[]由original_features具有被映射到相应的边缘并面向上replacement_features[] return_map=假[]创建的边和面 - 执行替换

第6个参数为输入:
use_copy_of_replacement代表参数变量,logical 为输入参数类型,use_copy_of_replacement=假 - 使用替代功能,直接取代了原有的特色use_copy_of_replacement=真 - 复制替代的功能和使用替换功能的副本替换了原有的功能

第7个参数为输入:
parent_map代表参数变量,UF_MODL_replace_features_t * * 为输入参数类型,地图上的相应替代功能边线和面的原有特色[]创建边和面的[]

第8个参数为输入:
输入int * 整数型的参数,参数的变量格式为n_parent_map,元件中(parent_map)编号[]

UF_MODL_replace_features函数实例代码演示:

[quote]
#include <stdio.h>
#include <uf.h>
#include <uf_modl.h>
#include <uf_part.h>
#include <uf_ui.h>
#include <uf_obj.h>
#include <uf_object_types.h>

#define UF_CALL(X) (report( __FILE__, __LINE__, #X, (X)))

static int report( char *file, int line, char *call, int irc)
{
if (irc)
{
char messg[133];
printf("%s, line %d: %s\n", file, line, call);
(UF_get_fail_message(irc, messg)) ?
printf(" returned a %d\n", irc) :
printf(" returned error %d: %s\n", irc, messg);
}
return(irc);
}

static void do_ugopen_api(void)
{
int units= UF_PART_METRIC;
char *part_name="replace_features";
tag_t part_tag,
cyl_tag,
cone_tag,
offset_tag;
double origin[3] = { 0.0, 0.0, 0.0 };
char *height="1.0";
char *diam="1.0";
char *cone_dia[2] = {"1.0", "2.0"};
double direction[3] = { 0.0, 0.0, 1.0 };
char *offset = "0.1";
uf_list_p_t flist;
UF_MODL_replace_features_t * replm_map=NULL;
int n_replm_map, i;

UF_PART_new(part_name, units, &part_tag);

/* Create a cone and a cylinder
*/
UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, origin, height, diam, direction, &cyl_tag));
UF_CALL(UF_MODL_create_cone1(UF_NULLSIGN,origin, height, cone_dia, direction, &cone_tag));

/* Offset faces of the cylinder by 0.1"
*/
UF_CALL(UF_MODL_create_list(&flist));
UF_CALL(UF_MODL_put_list_item(flist,cyl_tag));
UF_CALL(UF_MODL_create_feature_offset(offset, flist, &offset_tag));
UF_CALL(UF_MODL_delete_list(&flist));

/* Get a list of entities that must be mapped. This will be all the faces of the
cylinder that are being used by the offset feature
*/
UF_CALL(UF_MODL_replace_features(&cyl_tag, 1,
&cone_tag, 1,
true,
false,
&replm_map,
&n_replm_map ));

/* Since the parents of the offset will be replaced to faces on the copy of the cone feature,
Get the faces on the replacement feature from the user for the offset.
*/
for (i=0; i<n_replm_map; i++)
{
char *message="Select object on cone that corresponds to the highlighted object";
UF_UI_selection_options_t opts;
UF_UI_mask_t mask;
tag_t object, view;
double cursor[3];
int type, subtype, response;

UF_CALL(UF_DISP_set_highlight( replm_map[i].original_entity, 1));

/* Set up selection options for the replacement entity
*/
UF_CALL(UF_OBJ_ask_type_and_subtype(replm_map[i].original_entity, &type, &subtype));
opts.other_options = 0;
opts.reserved = NULL;
opts.num_mask_triples = 1;
opts.mask_triples = &mask;

if (subtype == UF_solid_face_subtype)
opts.mask_triples->solid_type = UF_UI_SEL_FEATURE_ANY_FACE;
else if (subtype == UF_solid_edge_subtype)
opts.mask_triples->solid_type = UF_UI_SEL_FEATURE_ANY_EDGE;
opts.mask_triples->object_type = type;
opts.mask_triples->object_subtype = subtype;
opts.scope = UF_UI_SEL_SCOPE_WORK_PART;

/* Select the replacement entity
*/
UF_CALL(UF_UI_select_single(message,&opts,&response, &object,cursor,&view));
UF_CALL(UF_DISP_set_highlight( replm_map[i].original_entity, 0));
UF_CALL(UF_DISP_set_highlight( replm_map[i].replacement_entity, 0));
if (response==1 || response==2)
break;

replm_map[i].replacement_entity=object;
}
/* Replace the cylinder with a copy of the cone
*/
if (i==n_replm_map)
UF_CALL(UF_MODL_replace_features(&cyl_tag, 1,
&cone_tag, 1,
false,
true,
&replm_map,
&n_replm_map ));

UF_free ( replm_map );


}


/*ARGSUSED*/
void ufusr(char *param, int *retcode, int param_len)
{
if (!UF_CALL(UF_initialize()))
{
do_ugopen_api();
UF_CALL(UF_terminate());
}
}

int ufusr_ask_unload(void)
{
return (UF_UNLOAD_IMMEDIATELY);
}


[/quote]

0

最新回复 (0)
请登录后发表新帖