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

[二次开发] UF_MODL_check_interference的用法

[复制链接]
发表于 2007-8-13 13:37:01 | 显示全部楼层 |阅读模式 来自 大连理工大学
UF_MODL_check_interference这个函数在装配中怎么用呢,总是出错
谢谢了:)
 楼主| 发表于 2007-8-14 15:08:13 | 显示全部楼层 来自 大连理工大学
Simdroid开发平台
原来必须用原型的tag
回复 不支持

使用道具 举报

发表于 2007-8-20 14:47:20 | 显示全部楼层 来自 北京
不懂是什么
回复 不支持

使用道具 举报

发表于 2009-5-30 13:03:55 | 显示全部楼层 来自 山西太原
给你一个实例
#include <stdio.h>
#include <string.h>
#include <uf.h>
#include <uf_ui.h>
#include <uf_modl.h>
#include <uf_assem.h>
#include <uf_obj.h>
#include <uf_wave.h>
#include <uf_so.h>

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

static int report_error( char *file, int line, char *call, int irc)
{
    if (irc)
    {
        char err[133],
             msg[133];

        sprintf(msg, "*** ERROR code %d at line %d in %s:\n+++ ",
            irc, line, file);
        UF_get_fail_message(irc, err);

    /*  NOTE:  UF_print_syslog is new in V18 */

        UF_print_syslog(msg, FALSE);
        UF_print_syslog(err, FALSE);
        UF_print_syslog("\n", FALSE);
        UF_print_syslog(call, FALSE);
        UF_print_syslog(";\n", FALSE);

        if (!UF_UI_open_listing_window())
        {
            UF_UI_write_listing_window(msg);
            UF_UI_write_listing_window(err);
            UF_UI_write_listing_window("\n");
            UF_UI_write_listing_window(call);
            UF_UI_write_listing_window(";\n");
        }
    }

    return(irc);
}

/*ARGSUSED*/
static int mask_for_solid_bodies( UF_UI_selection_p_t select, void *type)
{
    UF_UI_mask_t
        mask = { UF_solid_type, 0, UF_UI_SEL_FEATURE_SOLID_BODY };

    if (!UF_CALL(UF_UI_set_sel_mask(select,
            UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, 1, &mask)))
        return (UF_UI_SEL_SUCCESS);
    else
        return (UF_UI_SEL_FAILURE);
}

static tag_t select_a_solid(char *prompt)
{
    double
        cp[3];
    int
        resp;
    tag_t
        object,
        view;

    UF_CALL(UF_UI_select_with_single_dialog( "Select a solid", prompt,
        UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, mask_for_solid_bodies, NULL, &resp,
        &object, cp, &view));

    if (resp == UF_UI_OBJECT_SELECTED || resp == UF_UI_OBJECT_SELECTED_BY_NAME)
    {
        UF_CALL(UF_DISP_set_highlight(object, 0));
        return object;
    }
    else return NULL_TAG;

}

static int select_solids(char *prompt, tag_t **solids)
{
    int
        ii,
        n,
        resp;

    UF_CALL(UF_UI_select_with_class_dialog( "Select solids", prompt,
        UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, mask_for_solid_bodies, NULL,
        &resp, &n, solids));

    for (ii = 0; ii < n; ii++)
        UF_CALL(UF_DISP_set_highlight((*solids)[ii], FALSE));

    return n;

}

static void do_it(void)
{
    int
        flag,
        ii,
        n,
        n_tools;
    tag_t
        target,
        *tools;
    double
        tol;
    uf_list_p_t
        jj, kk,
        target_faces,
        tool_faces;
    UF_MODL_intersect_info_p_t
        *intersections;

    UF_MODL_ask_distance_tolerance(&tol);

    while (((target = select_a_solid("Select Target Body")) != NULL_TAG) &&
           ((n_tools = select_solids("Select Tool Bodies", &tools)) > 0))
    {
        UF_CALL(UF_MODL_ask_body_faces(target, &target_faces));

        for (ii = 0; ii < n_tools; ii++)
        {
            UF_CALL(UF_MODL_check_interference(target, 1, &tools[ii], &flag));
            if (flag == 1)
            {
                UF_CALL(UF_MODL_ask_body_faces(tools[ii], &tool_faces));

                for (jj = target_faces; jj != NULL; jj = jj->next)
                    for (kk = tool_faces; kk != NULL; kk = kk->next)
                    {
                        UF_CALL(UF_MODL_intersect_objects(jj->eid, kk->eid,
                            tol, &n, &intersections));
                        if (n > 0) UF_free(intersections);
                    }
                UF_CALL(UF_MODL_delete_list(&tool_faces));
            }
        }
        UF_CALL(UF_MODL_delete_list(&target_faces));
        UF_free(tools);
    }
}

/*ARGSUSED*/
void ufusr(char *param, int *retcode, int paramLen)
{
    if (UF_CALL(UF_initialize())) return;
    do_it();
    UF_terminate();
}

int ufusr_ask_unload(void)
{
    return (UF_UNLOAD_IMMEDIATELY);
}
回复 不支持

使用道具 举报

发表于 2010-7-21 17:20:11 | 显示全部楼层 来自 大连理工大学
非常感谢  呵呵
回复 不支持

使用道具 举报

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

本版积分规则

Simapps系列直播

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

GMT+8, 2024-9-28 03:28 , Processed in 0.038808 second(s), 10 queries , Gzip On, MemCache On.

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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