注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

信息 灵感 创新

I? =Information,Inspiration,Innovation

 
 
 

日志

 
 
关于我

we are 5. Mathematics, Computation, Programming, Engineering, and Making fun of life.

网易考拉推荐

NXOpen创建点云  

2014-06-08 22:30:21|  分类: UG NX |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
#include <math.h>
#define  PI 3.2141592654
#include <uf.h>
//#include <uf_ui.h>
//#include <uf_exit.h>
#include <NXOpen/Session.hxx>
#include <NXOpen/Part.hxx>
#include <NXOpen/PartCollection.hxx>
#include <NXOpen/Point.hxx>
#include <NXOpen/PointCollection.hxx>
#include <NXOpen/Features_BaseFeatureCollection.hxx>
#include <NXOpen/Features_PointFeatureBuilder.hxx>
using namespace NXOpen;
void CreatePoints()
{
    Session* theSession = Session::GetSession();
    Part* workPart = theSession->Parts()->Work();
    double R,theta,phi;
    int longitude,altitude;
    longitude=24;
    altitude=7;
    R=1000;
    Point3d p3d;
    Point* pp;
    Features::Feature *nullFeatures_Feature(NULL);
    Features::PointFeatureBuilder* pointFeatureBuilder1;
    NXObject *nXObject1;

    for(int i=0;i<altitude;i++)
    {
        phi=PI*(i+1)/(altitude+1);
        p3d.Z=R*cos(phi);

        for(int j=0;j<longitude;j++)
        {
            theta=j*2*PI/longitude;
            p3d.X=R*sin(phi)*cos(theta);
            p3d.Y=R*sin(phi)*sin(theta);
            pp=workPart->Points()->CreatePoint(p3d);
            pp->SetVisibility(SmartObject::VisibilityOptionVisible);
            
            pointFeatureBuilder1=workPart->BaseFeatures()->CreatePointFeatureBuilder(nullFeatures_Feature);
            pointFeatureBuilder1->SetPoint(pp);
            nXObject1 = pointFeatureBuilder1->Commit();
            pointFeatureBuilder1->Destroy();
        }
    }

    p3d=Point3d(0,0,R);
    pp=workPart->Points()->CreatePoint(p3d);
    pp->SetVisibility(SmartObject::VisibilityOptionVisible);
    pointFeatureBuilder1=workPart->BaseFeatures()->CreatePointFeatureBuilder(nullFeatures_Feature);
    pointFeatureBuilder1->SetPoint(pp);
    nXObject1 = pointFeatureBuilder1->Commit();
    pointFeatureBuilder1->Destroy();

    p3d=Point3d(0,0,-R);
    pp=workPart->Points()->CreatePoint(p3d);
    pp->SetVisibility(SmartObject::VisibilityOptionVisible);
    pointFeatureBuilder1=workPart->BaseFeatures()->CreatePointFeatureBuilder(nullFeatures_Feature);
    pointFeatureBuilder1->SetPoint(pp);
    nXObject1 = pointFeatureBuilder1->Commit();
    pointFeatureBuilder1->Destroy();
}

//入口函数
extern DllExport void ufsta( char *param, int *returnCode, int rlen)
{
    if(UF_initialize()) 
        return;
    //Add your code here
    CreatePoints();
    UF_terminate();
}
//退出函数
extern int ufusr_ask_unload()
{
    return UF_UNLOAD_IMMEDIATELY;
}
大概的效果如下:
CX_0608_222229

  评论这张
 
阅读(621)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2016