zoukankan      html  css  js  c++  java
  • NX二次开发-UFUN线性变换的矩阵uf5943

    转载自 https://www.cnblogs.com/zzyfym/p/12090675.html

    #include <uf.h>
    #include <uf_ui.h>
    #include <uf_trns.h>
    
    
    //设置class_dialog选择过滤
    static int init_proc(UF_UI_selection_p_t select,void* user_data)
    {
        int num_triples = 1;
        //实体 片体
        UF_UI_mask_t mask_triples[] = {UF_solid_type,0,0};
        /* enable only lines and edges */
        if((UF_UI_set_sel_mask(select,UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC,num_triples, mask_triples)) == 0)
        {
            return (UF_UI_SEL_SUCCESS);
        }
        else
        {
            return (UF_UI_SEL_FAILURE);
        }
    }
    
    extern DllExport void ufsta( char *param, int *returnCode, int rlen )
    {
        /* Initialize the API environment */
        if( UF_CALL(UF_initialize()) )
        {
            /* Failed to initialize */
            return;
        }
    
        /* TODO: Add your application code here */
        UF_initialize();
    
        //select_with_class_dialog
        char message[]="类选择对话框";
        char title[]="按类选择:";
        int scope=UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY;
        int response=0;
        int count=0;
        tag_t* objects=NULL;
        //5943
        double translation[3]={0.0,500.0,500.0};
        double matrix_value[16]={0.0};
        /*
            绝对坐标系 的平移距离
            translation[0] x向的距离
            translation[1] y向的距离
            translation[2] z向的距离
        */
        //5947
        tag_t *objects_array=NULL;
        int move_or_copy=2;//1 - Move  2 - copy
        int dest_layer=0;//0 - the original layer,  -1 - the work layer,  1 - 256 - the specified layer
        int trace_curves=2;//轨迹曲线状态1 means on, 2 means off.
        tag_t *copies=NULL;//这是当move_or_copy等于1(移动)时不使用。当move_or_copy为2(副本)时,应设置一个为空tag_t
        tag_t trace_curve_group=NULL;//当trace_curves=2时,此处设置为null
        int status_value=0;
        //多选对话框
        UF_UI_select_with_class_dialog (message,title,scope,init_proc,NULL,&response,&count,&objects);
        //分配内存
        objects_array=(tag_t*)malloc(sizeof(tag_t)*count);
        if (response == UF_UI_OK && count > 0)
        {
            for (int i=0; i<count; i++)
            {
                objects_array[i]=objects[i];
                UF_DISP_set_highlight(objects[i], 0);
            }
    
        }
        //返回矩阵以执行线性变换,沿着  绝对坐标系  的X轴,Y轴和Z轴。
        uf5943(translation,matrix_value);
        //分配内存
        copies=(tag_t*)malloc(sizeof(tag_t)*count);
        //平移
        uf5947(matrix_value,objects_array,&count,&move_or_copy,&dest_layer,&trace_curves,copies,&trace_curve_group,&status_value);
        //释放内存
        free(copies);
        free(objects_array);
        /*
        注意:
        1.坐标系问题
            注意平移变换 这个玩意是按  绝对坐标系 方向来的(坐标系不统一时先把坐标系统一)
        2.注意内存的分配。
        3.如果是有参数的体 经过 uf5947 平移变换后变成 去参后的体。
    
        4.trace_curves 轨迹曲线状态 ps:我也不明白是什么意思,求大神什么解释
        */
    
        UF_terminate();
    
        /* Terminate the API environment */
        UF_CALL(UF_terminate());
    }
    
    Caesar卢尚宇
    2020年5月21日

  • 相关阅读:
    Hibernate + mysql 查询伪劣时:= 出现 Space is not allowed after parameter prefix ':' MySQL异常
    Linux下使用Markdown
    第十六章:Java内存模型——Java并发编程实战
    第十五章:原子变量与非阻塞机制——Java并发编程实战
    第十四章:构建自定义的同步工具——Java并发编程实战
    第十三章:显示锁——Java并发编程实战
    访问者模式——HeadFirst设计模式学习笔记
    原型模式——HeadFirst设计模式学习笔记
    第十二章:并发程序的测试——Java并发编程实战
    备忘录模式——HeadFirst设计模式学习笔记
  • 原文地址:https://www.cnblogs.com/nxopen2018/p/12933392.html
Copyright © 2011-2022 走看看