zoukankan      html  css  js  c++  java
  • NXOpen 特征、体、线、圆弧、点通过迭代器遍历

    #include <NXOpen/Session.hxx>                  
    #include <NXOpen/Part.hxx>                     
    #include <NXOpen/PartCollection.hxx> 

    #include <NXOpen/Features_FeatureCollection.hxx>

    #include <NXOpen/Features_Feature.hxx>         
    #include <NXOpen/Features_CylinderBuilder.hxx> 
    #include <NXOpen/Features_FeatureCollection.hxx>
    #include <NXOpen/Features_FeatureBuilder.hxx>

    #include <NXOpen/Body.hxx>
    #include <NXOpen/BodyCollection.hxx>
    #include <NXOpen/Line.hxx>
    #include <NXOpen/LineCollection.hxx>
    #include <NXOpen/Point.hxx>
    #include <NXOpen/PointCollection.hxx>
    #include <NXOpen/Arc.hxx>
    #include <NXOpen/ArcCollection.hxx>

    #include <NXOpen/ListingWindow.hxx>

        workPart = theSession->Parts()->Work();

     theSession->ListingWindow()->Open();  //打开信息窗口

     char msg [256];

     Features::Feature* thefeature;
     Features::FeatureCollection *features=workPart->Features();//迭代
     Features::FeatureCollection::iterator itr=features->begin();//获得第一个特征
     std::vector<tag_t> FeatureVecotor;
     for (;itr!=features->end();++itr)        //循环获得所有特征
     {
      thefeature=(*itr); //获得特征赋值给featuresList
      //theSession->ListingWindow()->WriteLine("特征类型:"+thefeature->FeatureType()); //获得特征类型打印
      FeatureVecotor.push_back(thefeature->Tag());
     }
     //遍历body
     std::vector<tag_t> BodyVecotor;
     BodyCollection *bodys = workPart->Bodies();
     for (BodyCollection::iterator itebody = bodys->begin();itebody !=bodys->end();itebody++)
     {
       Body *body=(*itebody);
       BodyVecotor.push_back(body->Tag());
     }
     //遍历line
     std::vector<tag_t> LineVecotor;
     LineCollection *lines = workPart->Lines();
     for (LineCollection::iterator linesite = lines->begin();linesite !=lines->end();linesite++)
     {
      Line *line =(*linesite);
      LineVecotor.push_back(line->Tag());
     }
     //遍历Arc
     std::vector<tag_t> ArcVecotor;
     ArcCollection *arcs = workPart->Arcs();
     for (ArcCollection::iterator arcsite = arcs->begin();arcsite !=arcs->end();arcsite++)
     {
      Arc *arc =(*arcsite);
      arc->Highlight();
      ArcVecotor.push_back(arc->Tag());
     }
     //遍历point
     std::vector<tag_t> PointVecotor;
     PointCollection *points = workPart->Points();
     for (PointCollection::iterator pointsite = points->begin();pointsite !=points->end();pointsite++)
     {
      Point *point =(*pointsite);
      //point->Highlight();
      PointVecotor.push_back(point->Tag());
     }

     sprintf ( msg , "特征的数量:%d",FeatureVecotor.size());
     theSession->ListingWindow()->WriteLine( msg);
     sprintf ( msg , "体的数量:%d",BodyVecotor.size());
     theSession->ListingWindow()->WriteLine( msg);
     sprintf ( msg , "线的数量:%d",LineVecotor.size());
     theSession->ListingWindow()->WriteLine( msg);
     sprintf ( msg , "圆弧的数量:%d",ArcVecotor.size());
     theSession->ListingWindow()->WriteLine( msg);
     sprintf ( msg , "点的数量:%d",PointVecotor.size());
     theSession->ListingWindow()->WriteLine( msg);

    怡宁塑胶模具设计
  • 相关阅读:
    BOZJ 3551&BZOJ 3545 kruskal重构树
    [Poi2014]FarmCraft
    NOIP 2015 斗地主
    POJ 1704 Georgia and Bob
    BZOJ 1409 快速幂+欧拉定理
    最长公共子序列(LCS)
    神奇的口袋(百练2755)
    最长上升子序列(LIS)
    《Single Image Haze Removal Using Dark Channel Prior》去雾代码实现分析
    MATLAB中的nargin与varargin
  • 原文地址:https://www.cnblogs.com/hqsalanhuang/p/14458586.html
Copyright © 2011-2022 走看看