zoukankan      html  css  js  c++  java
  • NXOpen 测量最小距离,再利用C++ 排序

    头文件

    #include <algorithm>//比大小的头文件

    double distance;
    std::vector<double> measureValue;//测量的值(double型)

    for ( int i = 0 ; i < edges.size(); i ++ )
    {
    Edge *edge1 = edges[i];
    NXObject *nullNXObject(NULL);
    MeasureDistanceBuilder *measureDistanceBuilder1;
    measureDistanceBuilder1 = workPart->MeasureManager()->CreateMeasureDistanceBuilder(nullNXObject);

    measureDistanceBuilder1->SetMtype(MeasureDistanceBuilder::MeasureTypeMinimum);
    measureDistanceBuilder1->Object1()->SetValue(edge1);

    DatumPlane *datumPlane1(dynamic_cast<DatumPlane *>(workPart->Datums()->FindObject(datumPlanefeature1->JournalIdentifier())));
    measureDistanceBuilder1->Object2()->SetValue(datumPlane1);

    Unit *unit1(dynamic_cast<Unit *>(workPart->UnitCollection()->FindObject("MilliMeter")));
    MeasureDistance *measureDistance1;
    measureDistance1 = workPart->MeasureManager()->NewDistance(unit1, MeasureManager::MeasureTypeMinimum, edge1, datumPlane1);

    Measure *measure1;
    measure1 = measureDistance1->CreateFeature();

    distance = measureDistance1->Value();//获取测量的值
    if ( distance > 0 )
    {
    measureValue.push_back(distance);//获取的值塞到容器
    }
    measureDistanceBuilder1->Destroy();

    }

    sort(measureValue.begin(),measureValue.end());//排序,从小到大排

    reverse(measureValue.begin(),measureValue.end());//reverse函数功能是逆序(或反转)

    char msgmeasureValue[256];
    for ( int i = 0 ; i < measureValue.size(); i ++ )
    {
    sprintf(msgmeasureValue, "边的距离:%.2f",measureValue[i]);
    theSession->ListingWindow()->WriteLine( msgmeasureValue);
    }

    怡宁塑胶模具设计
  • 相关阅读:
    强连通 HDU 1827
    强联通 HDU 2767 3836
    强连通 HDU 1269
    网络流 poj 2135
    强联通 poj 2762
    android20-[【转】Android的EditText自动获取焦点并弹出输入法问题]
    windows开发中的一点总结
    android19
    android18
    android17
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14529670.html
Copyright © 2011-2022 走看看