iCAx开思工具箱

标题: 【讨论】UF_CURVE_create_trim函数怎么使? [打印本页]

作者: wangchengjia    时间: 2004-2-11 09:22
标题: 【讨论】UF_CURVE_create_trim函数怎么使?
UF_CURVE_create_trim函数怎么使?
作者: pinkwall    时间: 2004-2-11 20:36
要裁减基本曲线??
作者: wangchengjia    时间: 2004-2-12 16:19
是,下面是程序代码:
/*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类型不匹配
作者: pinkwall    时间: 2004-2-13 15:02
view是一个定义为UF_MODL_vector_type_t的 结构体
好好看看帮助
作者: wangchengjia    时间: 2004-2-13 16:38
UF_MODL_vector_type_t 结构体的成员变量是怎么定义的?
作者: wangchengjia    时间: 2004-2-13 16:44
(void *)0怎么转化为 UF_MODL_vector_type_t
作者: pinkwall    时间: 2004-2-13 18:04
UF_MODL_vector_type_t  看  uf_modl.h里面的  type
写的很详细
  
不可能将 UF_MODL_vector_type_t  转成void*
  
除非直接将view = NULL
不过这样估计编译能通过,不过运行是要报错的
作者: wangchengjia    时间: 2004-2-16 08:58
uf_modl.h里面没有UF_MODL_vector_type_t,怎样能使UF_CURVE_create_trim函数好使呀,请举个例子。
作者: pinkwall    时间: 2004-2-16 16:15
sorry在uf_modl_smd.h里面
  
最近写论文呢几天后交搞儿,没时间做例子,你先研究着
  
我写完看看能不能搞个例子
作者: wangchengjia    时间: 2004-2-16 16:31
uf_modl_smd.h这里也没有呀,UF_MODL_vector_type_t结构体的 定义你给我上传一个好吗?
作者: pinkwall    时间: 2004-2-16 17:07
struct UF_MODL_vector_s
Overview
  
The following structure allows definition of a vector
with a variety of options. Note that associativity to
any data is not maintained unless otherwise specified.
  
Data Members
reverse_vector
int reverse_vector
Indicates if the vector calculated should then be reversed before being used. If zero, the vector is not reversed. Any other value will reverse the vector.
  
vector_type
UF_MODL_vector_type_t vector_type
Indication of which structure is being used to define the vector.
  
defined_by
UF_MODL_vector_defined_by_union_t defined_by
The definition of the vector.
  
  
作者: pinkwall    时间: 2004-2-16 17:07
UF_MODL_vector_type_e
enum UF_MODL_vector_type_e  
  
The following enum is used in the UF_MODL_vector structure
to specify how the vector is being defined.
  
UF_MODL_VECTOR_DIRECTION   
   
UF_MODL_VECTOR_AXIS   
   
UF_MODL_VECTOR_FACE_NORMAL   
   
UF_MODL_VECTOR_TWO_POINTS   
   
UF_MODL_VECTOR_PLANE_OF_CURVES   
   
UF_MODL_VECTOR_FACE_NORMALS   
   
UF_MODL_VECTOR_DIRECTION_EXACT_GEOMETRY   
   
UF_MODL_VECTOR_AXIS_EXACT_GEOMETRY   
   
UF_MODL_VECTOR_FACE_NORMALS_EXACT_GEOMETRY  




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3