找回密码 注册 QQ登录
开思网工业级高精度在线3D打印服务

iCAx开思网

CAD/CAM/CAE/设计/模具 高清视频【积分说明】如何快速获得积分?快速3D打印 手板模型CNC加工服务在线3D打印服务,上传模型,自动报价
查看: 19125|回复: 11
打印 上一主题 下一主题

【讨论】UF_CURVE_create_trim函数怎么使?

[复制链接]
跳转到指定楼层
1
发表于 2004-2-11 09:22:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多同行朋友,交流,分享,学习。

您需要 登录 才可以下载或查看,没有帐号?注册

x
UF_CURVE_create_trim函数怎么使?
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 赞一下!赞一下!
2
发表于 2004-2-11 20:36:02 | 只看该作者
要裁减基本曲线??
3
发表于 2004-2-12 16:19:43 | 只看该作者
是,下面是程序代码:
/*CLASS UFCUST */
/*==============================================================================
  
             Copyright (c) 1999 Unigraphics Solutions Inc.
                     Unpublished - All rights reserved
================================================================================
File description:
  
    An example UG/Open program is contained in this file demonstrating
    usage of the following UG/Open interfaces:
  
    UF_CURVE_create_trim
    UF_CURVE_ask_trim
    UF_CURVE_edit_trim
    UF_CURVE_free_trim
  
    This example program:
  
    1) Creates a part file named "curve_trim".
  
    2) Creates two lines. One to be trimmed and one as the bounding string.  
       It also creates a fixed datum plane for a second bounding object.
  
    3) Creates a trim curve feature that trims the first line to the
       bounding string.  
  
    4) Retrieves the parameters of the trim curve feature.  
  
    5) Edits the trim curve feature so that the first line is now trimmed to  
       the bounding string and the fixed datum plane.  
  
    6) Frees the information retrieved from the UF_CURVE_ask_trim call.
  
==============================================================================*/
  
#include <stdio.h>
#include <uf.h>
#include <uf_curve.h>
#include <uf_modl.h>
#include <uf_part.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 error,trim_string[1],trim_dir[1],bound_string[1],bound_dir[1];
    tag_t lines[3],trim_curve_feat,datum,part_tag;
    double plane_origin[3],plane_norm[3];
    UF_CURVE_line_t line_coords;
    UF_CURVE_trim_t trim_curve_info,out_trim_curve_info;
    UF_CURVE_trim_mult_t out_info;
    char *prtnam = "curve_trim";  
  
    UF_CALL( UF_PART_new(prtnam, METRIC, [$part_tag) )]
  
    /*
      Create three lines and a datum plane.
    */
    line_coords.start_point[0] =  0.0; line_coords.end_point[0] = 20.0;
    line_coords.start_point[1] =  0.0; line_coords.end_point[1] = 10.0;
    line_coords.start_point[2] =  0.0; line_coords.end_point[2] =  0.0;
    UF_CALL(UF_CURVE_create_line([$line_coords,&lines[0]))]
  
    line_coords.start_point[0] = 20.0; line_coords.end_point[0] = 30.0;
    line_coords.start_point[1] = 10.0; line_coords.end_point[1] =  0.0;
    line_coords.start_point[2] =  0.0; line_coords.end_point[2] =  0.0;
    UF_CALL(UF_CURVE_create_line([$line_coords,&lines[1]))]
  
    line_coords.start_point[0] = -5.0; line_coords.end_point[0] = 35.0;
    line_coords.start_point[1] =  5.0; line_coords.end_point[1] =  5.0;
    line_coords.start_point[2] =  0.0; line_coords.end_point[2] =  0.0;
    UF_CALL(UF_CURVE_create_line([$line_coords,&lines[2]))]
  
    plane_origin[0] = 15.0; plane_origin[1] = 0.0; plane_origin[2] = 0.0;
    plane_norm[0] = 1.0; plane_norm[1] = 0.0; plane_norm[2] = 0.0;
    UF_CALL(UF_MODL_create_fixed_dplane(plane_origin,plane_norm,[$datum))]
  
    /*
      Fill in arrays to be used in string definition.
    */
    trim_string[0] = 2; trim_dir[0] = 1;
  
    /*
      Fill in trim curve structure information to trim the first line
      to the second line as a bounding string.
    */
    trim_curve_info.string_to_trim.num = 1;
    trim_curve_info.string_to_trim.string = trim_string;
    trim_curve_info.string_to_trim.dir = trim_dir;
    trim_curve_info.string_to_trim.id = lines;
  
    trim_curve_info.spline_extend_opt = UF_CURVE_EXTEND_NATURAL;
    trim_curve_info.trim_type = UF_CURVE_TRIM_TO_ONE_BOUND;
    UF_MODL_ask_distance_tolerance([$trim_curve_info.tolerances[0])]
    UF_MODL_ask_angle_tolerance([$trim_curve_info.tolerances[1])]
  
    /*
      Fill in arrays to be used in bound definition.
    */
    bound_string[0] = 1; bound_dir[0] = 1;
  
    /*
      Fill in bounding information.
    */
    trim_curve_info.trim_to.one_bound.string_trim_extend_end = UF_CURVE_TRIM_EXTEND_START;
  
    trim_curve_info.trim_to.one_bound.bound.string.num = 1;
    trim_curve_info.trim_to.one_bound.bound.string.string = bound_string;
    trim_curve_info.trim_to.one_bound.bound.string.dir = bound_dir;
    trim_curve_info.trim_to.one_bound.bound.string.id = [$lines[2]]
    trim_curve_info.trim_to.one_bound.bound.use_suggested = FALSE;
    trim_curve_info.trim_to.one_bound.view = (void *)0;
  
    trim_curve_info.trim_to.one_bound.bound.object = NULL_TAG;
    trim_curve_info.trim_to.one_bound.trim_bound = TRUE;
  
    /*
      Create the trim curve feature.
    */
    error = UF_CURVE_create_trim([$trim_curve_info, &out_info, &trim_curve_feat)]
  
    if (error == UF_CURVE_TRIM_MULT_PTS)
    {
        printf("Multiple intersections found\n");
  
        /*
          Use first intersection point as suggested point.
        */
        trim_curve_info.trim_to.one_bound.bound.use_suggested = TRUE;
        trim_curve_info.trim_to.one_bound.bound.suggested_point[0] = out_info.bound1_pts[0];
        trim_curve_info.trim_to.one_bound.bound.suggested_point[1] = out_info.bound1_pts[1];
        trim_curve_info.trim_to.one_bound.bound.suggested_point[2] = out_info.bound1_pts[2];
  
        if (out_info.bound1_pts)
        {
            UF_free(out_info.bound1_pts);
        }
  
        if (out_info.bound2_pts)
        {
            UF_free(out_info.bound2_pts);
        }
  
        UF_CALL(UF_CURVE_create_trim([$trim_curve_info, &out_info, &trim_curve_feat))]
    }
  
    printf("Trim curve feature created\n");
  
    /*
      Ask the parameters of the trim curve feature just created.
    */
    UF_CALL(UF_CURVE_ask_trim(trim_curve_feat, [$out_trim_curve_info))]
  
    printf("Trim curve feature parameters retrieved\n");
  
    /*
      Transfer some of the retrieved parameters to the trim curve
      information structure.  
      Reset other information in the structure so that the first line  
      will now be trimmed so that the portion of the line outside the
      bounding string and the datum plane will be trimmed away.
    */
    trim_curve_info.string_to_trim = out_trim_curve_info.string_to_trim;
    trim_curve_info.trim_type = UF_CURVE_TRIM_TO_TWO_BOUND;
    trim_curve_info.trim_to.two_bound.string_extend_end = UF_CURVE_TRIM_EXTEND_START;
    trim_curve_info.trim_to.two_bound.string_trim_option = UF_CURVE_TRIM_OUTSIDE;
    trim_curve_info.trim_to.two_bound.bound1.string =  
        out_trim_curve_info.trim_to.one_bound.bound.string;
    trim_curve_info.trim_to.two_bound.bound1.object = NULL_TAG;
    trim_curve_info.trim_to.two_bound.bound2.string.num = 0;
    trim_curve_info.trim_to.two_bound.bound2.object = datum;
    trim_curve_info.trim_to.two_bound.bound2.use_suggested = FALSE;
    trim_curve_info.trim_to.two_bound.view = (void *)0;
  
    trim_curve_info.trim_to.two_bound.trim_bound = TRUE;
  
    /*
      Edit the trim curve feature.
    */
    UF_CALL(UF_CURVE_edit_trim(trim_curve_feat, [$trim_curve_info))]
  
    /*
      Update the model.
    */
    UF_CALL(UF_MODL_update());
  
    printf("Trim curve feature edited, and model updated\n");
  
    /*
      Free the retrieved information.
    */
    UF_CALL(UF_CURVE_free_trim([$out_trim_curve_info))]
  
    printf("Trim curve feature information freed, and example completed.\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);
}
  
编译后说trim_curve_info.trim_to.two_bound.view 和 (void *)0类型不匹配
4
发表于 2004-2-13 15:02:11 | 只看该作者
view是一个定义为UF_MODL_vector_type_t的 结构体
好好看看帮助
5
发表于 2004-2-13 16:38:50 | 只看该作者
UF_MODL_vector_type_t 结构体的成员变量是怎么定义的?
6
发表于 2004-2-13 16:44:57 | 只看该作者
(void *)0怎么转化为 UF_MODL_vector_type_t
7
发表于 2004-2-13 18:04:57 | 只看该作者
UF_MODL_vector_type_t  看  uf_modl.h里面的  type
写的很详细
  
不可能将 UF_MODL_vector_type_t  转成void*
  
除非直接将view = NULL
不过这样估计编译能通过,不过运行是要报错的
8
发表于 2004-2-16 08:58:12 | 只看该作者
uf_modl.h里面没有UF_MODL_vector_type_t,怎样能使UF_CURVE_create_trim函数好使呀,请举个例子。
9
发表于 2004-2-16 16:15:14 | 只看该作者
sorry在uf_modl_smd.h里面
  
最近写论文呢几天后交搞儿,没时间做例子,你先研究着
  
我写完看看能不能搞个例子
10
发表于 2004-2-16 16:31:20 | 只看该作者
uf_modl_smd.h这里也没有呀,UF_MODL_vector_type_t结构体的 定义你给我上传一个好吗?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

3D打印手板模型快速制作服务,在线报价下单!

QQ 咨询|手机版|联系我们|iCAx开思网  

GMT+8, 2024-12-25 21:18 , Processed in 0.032780 second(s), 10 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

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