zoukankan      html  css  js  c++  java
  • 创建圆柱

    //Create_cyl ?C:Program Files (x86)Microsoft Visual Studio2019CommunityCommon7IDEVCVCWizardsNXOpenCPP	emplates1033
    oot.txt
    // Mandatory UF Includes
    #include "C:\all_uf.h"
    #include "headfile.h"
    
    
    static int select_filter_proc_fn(tag_t object, int type[3], void* user_data, UF_UI_selection_p_t select)
    {
        UF_CURVE_arc_t arc_coords;
        UF_CURVE_ask_arc_data(object, &arc_coords);
        double Sp = arc_coords.start_angle * RADEG;
        double Ep = arc_coords.end_angle * RADEG;
        double ang = Ep - Sp;
        if (!object)
            return UF_UI_SEL_REJECT;
        else if (object && ang >= 180)
            return UF_UI_SEL_ACCEPT;
    }
    
    static int init_proc_arc(UF_UI_selection_p_t select, void* user_data)
    {
        int  errorCode = 0;
        int  num_triples = 1;
        UF_UI_mask_t mask_triples[] = { UF_circle_type,UF_circle_open_subtype, 0 };
        errorCode = UF_UI_set_sel_mask(select, UF_UI_SEL_MASK_CLEAR_AND_ENABLE_SPECIFIC, num_triples, mask_triples);
        if ((UF_UI_set_sel_procs(select, select_filter_proc_fn, NULL, user_data)) == 0)
            return UF_UI_SEL_SUCCESS;
        else
            return UF_UI_SEL_FAILURE;
    }
    
    double mins(double a, double b)
    {
        return a < b ? a : b;
    }
    
    struct Myarc_center
    {
        tag_t tag;
        double XX;
        double YY;
        double ZZ;
        double radiu;
    };
    
    struct Myarc_center1
    {
        double XX;
        double YY;
        double ZZ;
    };
    
    void removeDuplication1(std::vector<Myarc_center1>& theDatas)
    {
        std::vector<Myarc_center1> tempDatas;
        bool OnOff;
        for (int i = 0; i < (int)theDatas.size(); i++)
        {
            OnOff = false;
            for (int j = 0; j < (int)tempDatas.size(); j++)
            {
                if (theDatas[i].XX == tempDatas[j].XX && theDatas[i].YY == tempDatas[j].YY && theDatas[i].ZZ == tempDatas[j].ZZ)
                {
                    OnOff = true;
                    break;
                }
            }
            if (OnOff == false)
            {
    
                tempDatas.push_back(theDatas[i]);
            }
        }
        //容器交换
        theDatas.swap(tempDatas);
    }
    
    //------------------------------------------------------------------------------
    // Do something
    //------------------------------------------------------------------------------
    void LXQ::Create_cyl()
    {
        // TODO: add your code here
        UF_initialize();
        char sCue[] = "选择要创建圆柱的圆弧";
        char sTitle[] = "创建圆柱";
        int iScope = UF_UI_SEL_SCOPE_NO_CHANGE;
        int iResponse;
        tag_t* tObject;
        int count = 0;
        UF_UI_select_with_class_dialog(sCue, sTitle, iScope, init_proc_arc, NULL, &iResponse, &count, &tObject);
        if (iResponse == 2 && tObject != nullptr)
        {
            vector<Myarc_center> arcv;
            vector<Myarc_center1>arcd;
            for (size_t i = 0; i < count; i++)
            {
                UF_CURVE_arc_t arc_coords;
                UF_CURVE_ask_arc_data(tObject[i], &arc_coords);
                Myarc_center arcc;
                Myarc_center1 rcc;
                arcc.tag = tObject[i];
                arcc.XX = round(arc_coords.arc_center[0]*1000)/1000;
                arcc.YY = round(arc_coords.arc_center[1] * 1000) / 1000;
                arcc.ZZ = round(arc_coords.arc_center[2] * 1000) / 1000;
                arcc.radiu = round(arc_coords.radius * 1000) / 1000;
                rcc.XX = round(arc_coords.arc_center[0] * 1000) / 1000;
                rcc.YY = round(arc_coords.arc_center[1] * 1000) / 1000;
                rcc.ZZ = round(arc_coords.arc_center[2] * 1000) / 1000;
                arcv.push_back(arcc);
                arcd.push_back(rcc);
            }
            removeDuplication1(arcd);//找到中心坐标
    
            int ijunk[2], resp, doubles[2] = { 201,201 };
            double user[2] = { 1.0,20.0 };
            char menu[2][16] = { "圆柱向上高度","圆柱向下高度" }, user_input[2][31] = { "","" };
            resp = uc1613("创建圆柱,刘小庆开发", menu, 2, ijunk, user, user_input, doubles);
            if (resp > 2)
            {
                //tag_t     partition = NULL_TAG;
                //UF_PS_create_partition(&partition);
                for (size_t i = 0; i < arcd.size(); i++)
                {
                    vector<double>tmp1;
                    for (size_t j = 0; j < arcv.size(); j++)
                    {
                        if (arcd[i].XX == arcv[j].XX && arcd[i].YY == arcv[j].YY && arcd[i].ZZ == arcv[j].ZZ)//圆心相同
                            tmp1.push_back(arcv[j].radiu);
                    }
                    sort(tmp1.begin(), tmp1.end());//排序
                    double origin[3] = { arcd[i].XX ,arcd[i].YY ,arcd[i].ZZ + user[0] };
                    double height = user[0] + user[1];
    //                  tag_t cy = NULL_TAG;
    //                  char heights[123] = "";
    //                  sprintf_s(heights, "%f", user[0] + user[1]);
    //                  double dir[3] = { 0.0,0.0,-1.0 };
    //                  
                    L_modl::Pk_create_cyl(origin, height, tmp1[0], -1.0);
                    //UF_CALL(UF_MODL_create_cyl1(UF_NULLSIGN, origin, heights, turnf(tmp1[0] * 2), dir, &cy));
                    tmp1.clear();
                    tmp1.shrink_to_fit();
                }
                for (size_t i = 0; i < count; i++)
                {
                    UF_DISP_set_highlight(tObject[i], 0);
                }
            }
            else
                return;
            char aa[132] = "";
            sprintf_s(aa, "创建了%d个圆柱!", (int)arcd.size());
            p(aa);
            arcv.clear();
            arcv.shrink_to_fit();
            arcd.clear();
            arcd.shrink_to_fit();
        }
        else
            return;
    
        UF_terminate();
    }
    
    //------------------------------------------------------------------------------
  • 相关阅读:
    css技巧和经验列表
    CSS3嵌入字体@font-face调用字体
    新闻列表单行滚动(多行显示)简洁向上滚动js效果
    打破构图的平衡!增强设计感染力
    何以双十(补昨天)
    MySQL5.7 基于二进制包的安装
    Nginx Log日志统计分析常用命令
    MySQL错误代码大全
    MVC4中的Display Mode简介
    ReadOnly关键字修饰的变量可以修改,只是不能重新分配
  • 原文地址:https://www.cnblogs.com/liuxiaoqing1/p/14750684.html
Copyright © 2011-2022 走看看