iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 21708|回复: 1
打印 上一主题 下一主题

新人求助-大家帮忙看看代码哪儿出错了啊?

[复制链接]
跳转到指定楼层
楼主
发表于 2012-12-31 14:53:56 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
求大神指点。。。刚接触二次开发,照例子做,生成一个NURBS曲面,代码贴进去后,调试没错误,但CATIA显示“单击确定终止”,看不出错误啊
代码如下:
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
CATDocument*pDoc = pEditor->GetDocument();
CATIContainerOfDocument_var spConODocs = pDoc;
CATIContainer* spCGMContainer= NULL;
HRESULT hr = spConODocs->GetResultContainer(spCGMContainer);
CATGeoFactory_var piGeomFactory = spCGMContainer;
int nbPoleU = 5;
int nbPoleV = 5;
CATMathGridOfPoints gridOfPoints(nbPoleU,nbPoleV);
   
// Row 0
gridOfPoints.SetPoint(CATMathPoint( 0., 0., 0.),0,0);
gridOfPoints.SetPoint(CATMathPoint(10., 0., 0.),0,1);
gridOfPoints.SetPoint(CATMathPoint(20., 0., 0.),0,2);
gridOfPoints.SetPoint(CATMathPoint(30., 0., 0.),0,3);
gridOfPoints.SetPoint(CATMathPoint(40., 0., 0.),0,4);
   
// Row 1
gridOfPoints.SetPoint(CATMathPoint( 0.,10., 0.),1,0);
gridOfPoints.SetPoint(CATMathPoint(10.,10.,-10.),1,1);
gridOfPoints.SetPoint(CATMathPoint(20.,10.,-10.),1,2);
gridOfPoints.SetPoint(CATMathPoint(30.,10.,-10.),1,3);
gridOfPoints.SetPoint(CATMathPoint(40.,10., 0.),1,4);
   
// Row 2
gridOfPoints.SetPoint(CATMathPoint( 0.,20., 0.),2,0);
gridOfPoints.SetPoint(CATMathPoint(10.,20.,-40.),2,1);
gridOfPoints.SetPoint(CATMathPoint(20.,20.,-40.),2,2);
gridOfPoints.SetPoint(CATMathPoint(30.,20., -40.),2,3);
gridOfPoints.SetPoint(CATMathPoint(40.,20., 0.),2,4);
   
// Row 4
gridOfPoints.SetPoint(CATMathPoint( 0.,30., 0.),3,0);
gridOfPoints.SetPoint(CATMathPoint(10.,30., -10.),3,1);
gridOfPoints.SetPoint(CATMathPoint(20.,30., -10.),3,2);
gridOfPoints.SetPoint(CATMathPoint(30.,30., -10.),3,3);
gridOfPoints.SetPoint(CATMathPoint(40.,30., 0.),3,4);
   
// Row 5
gridOfPoints.SetPoint(CATMathPoint( 0.,40., 0.),4,0);
gridOfPoints.SetPoint(CATMathPoint(10.,40., 0.),4,1);
gridOfPoints.SetPoint(CATMathPoint(20.,40., 0.),4,2);
gridOfPoints.SetPoint(CATMathPoint(30.,40., 0.),4,3);
gridOfPoints.SetPoint(CATMathPoint(40.,40., 0.),4,4);
//This code creates the knot vectors:
CATLONG32 IsPeriodic= 0;
CATLONG32 Degree= 4;
CATLONG32 KnotsCount= 2;
double Knots[]= {0.,10.};
CATLONG32 Multiplicities[]= {5,5};
CATLONG32 IndexOffset= 1;
   
CATKnotVector NonUniformU(Degree,IsPeriodic,KnotsCount,Knots,
Multiplicities,IndexOffset);
CATKnotVector NonUniformV(Degree,IsPeriodic,KnotsCount,Knots,
Multiplicities,IndexOffset);

CATLONG32 isRational=1;
double * aWeights=new double[nbPoleU*nbPoleV];
for (int i = 0; i < nbPoleU*nbPoleV; i++)
{
aWeights[i] = 1.;
}
CATNurbsSurface * piSurf1 = piGeomFactory->CATCreateNurbsSurface(NonUniformU, NonUniformV,isRational,gridOfPoints,aWeights);

delete [] aWeights;
aWeights = NULL;

CATSurLimits surMaxLimits ;
piSurf1->GetMaxLimits(surMaxLimits) ;
   
CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();
CATTopData topdata(pConfig);
   
CATTopSkin * pSkinOpe =::CATCreateTopSkin(piGeomFactory,&topdata,piSurf1,&surMaxLimits);
pSkinOpe->Run();

CATBody * piSkinBody = pSkinOpe->GetResult();

delete pSkinOpe;
pSkinOpe=NULL;
//Next you will instanciate the datum from the CATBody:
CATIDatumFactory_var spDatumFactory= NULL_var;
spDatumFactory = spCGMContainer;
CATISpecObject* oDatumFeature;
spDatumFactory->InstanciateDatum(piSkinBody, oDatumFeature);
CATISpecObject_var spCurObj = oDatumFeature;
oDatumFeature->Update();
CATIPrtProceduralView_var aa=spCurObj;
aa->InsertInProceduralView();
pConfig->Release();
}

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
发表于 2013-3-22 09:56:23 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-12-22 23:21 , Processed in 0.015359 second(s), 8 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表