找回密码
 注册
Simdroid-非首页
查看: 100|回复: 1

[二次开发] UG干涉检查程序

[复制链接]
发表于 2012-11-14 10:00:36 | 显示全部楼层 |阅读模式 来自 江苏南京
请教各位,如何实现基于C++的UG干涉检查程序?
现有一例子,不是很明白
#include <stdio.h>
#include <uf.h>
#include <uf_part.h>
#include <uf_defs.h>
#include <uf_modl.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)
{

  char    *edge_length[3] = {"5.0", "5.0", "5.0"};
  char    *prtnam = "check_interference";
  char    *dia = "3.0";
  char    *height = "10.0";
  
  double  cyl_dir[3] = {0.0, 0.0, 1.0};

  double  origin[3] = {0.0, 0.0, 0.0};

  int     num_tools;
  int     results[2];
        
  tag_t   target;
  tag_t   tools[2];
  tag_t   feat_tag;
  tag_t   part_tag;

  UF_FEATURE_SIGN create = UF_NULLSIGN;
  

  /* Open a new part */
  UF_CALL( UF_PART_new(prtnam, METRIC, &part_tag) );

  /* Create a block of dimensions 5, 5, 5 */
  UF_CALL(UF_MODL_create_block1(create, origin, edge_length, &feat_tag));
  UF_CALL(UF_MODL_ask_feat_body(feat_tag, &target))   ;

  /* Create a cylinder */
  UF_CALL(UF_MODL_create_cyl1(create, origin, height, dia, cyl_dir, &feat_tag));
  UF_CALL(UF_MODL_ask_feat_body(feat_tag, &tools[0]));
  
  /* Create another cylinder not intersecting block */
  origin[0] = 10.0;
  origin[1] = 0.0;
  origin[2] = 0.0;
  UF_CALL(UF_MODL_create_cyl1(create, origin, height, dia, cyl_dir, &feat_tag));
  UF_CALL(UF_MODL_ask_feat_body(feat_tag, &tools[1]));
  
  /* check interference of the tool bodies against the target */
  num_tools = 2;
  UF_CALL(UF_MODL_check_interference( target, num_tools, tools, results ));
  
  if (results[0] != 1 || results[1] != 2)
     printf("*** ERROR from UF_MODL_check_interference ***\n");
  

}

/*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);
}
发表于 2012-12-3 12:32:46 | 显示全部楼层 来自 上海
Simdroid开发平台
不知道你哪里不明白啊?程序部署很清楚了吗?
回复 不支持

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|小黑屋|联系我们|仿真互动网 ( 京ICP备15048925号-7 )

GMT+8, 2024-6-16 14:51 , Processed in 0.026199 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表