//采用代理交互式获取样条
CATPathElement*pPath=_pPathElementAgent->GetValue();
int index=pPath->GetSize()-1;
CATBaseUnknown *pElement=(*pPath)[index];
CATIGeometricalElement_var spGeoEle=NULL_var;
if(SUCCEEDED(pElement->QueryInterface(IID_CATIGeometricalElement,(void**)&spGeoEle))){
CATBody_var spBdoy=NULL_var;
spBdoy=spGeoEle->GetBodyResult();
/*CATLISTP(CATCell)oListCell;*/
CATLocation local=CATLocationIn3DSpace;
CATDomain*pDomain=spBdoy->GetDomain(1,&local);
CATCell*pCell=pDomain->GetCell(1);
//将曲线转化为NUBRS样条曲线
CATGeoFactory*pGeoFac=pCell->GetContainer();
CATSoftwareConfiguration *pSoftConfig=new CATSoftwareConfiguration();//释放该指针时采用Release,CATSoftWareConfiguration的析构函数为保护类型,采用delete释放会出错
CATTopData TopData(pSoftConfig);
CATTopCrvToNurbsCrvOperator*pCrvToNubrsOper=CATCreateTopCrvToNurbsCrvOperator(pGeoFac,&TopData,spBdoy,pCell);
if (!pCrvToNubrsOper)
{
cout<<"operator failed"<<endl;
return TRUE;
}
pCrvToNubrsOper->SetMaxDegree(3);
pCrvToNubrsOper->SetMaxArcs(3);
pCrvToNubrsOper->SetRationalAbility(0);
pCrvToNubrsOper->Set3DOutputDimension(TRUE);//默认情况下,创建曲线为PCurve,需要设定支撑面
pCrvToNubrsOper->Run();
CATBody*pNubrsBody=pCrvToNubrsOper->GetResult();
if (!pNubrsBody)
{
cout<<"get nubrs body error"<<endl;
return TRUE;
}
CATLISTP(CATCell)oCellList;
pNubrsBody->GetAllCells(oCellList,1);
if (oCellList.Size())
{
CATCurve*pCurve=(CATCurve*)oCellList[1]->GetGeometry();
if (!pCurve)
{
cout<<"get pCurve pointer failed"<<endl;
return TRUE;
}
const CATKnotVector *KnotVec=NULL;
KnotVec=pCurve->GetKnotVector();
cout<<KnotVec->GetDegree()<<endl;
}
pGeoFac->Remove(pNubrsBody,CATICGMContainer::RemoveDependancies);//pNubrsBody 不需要保留,采用CATIGSMContainer的Remove方法
pSoftConfig->Release();
delete pCrvToNubrsOper;
pCrvToNubrsOper=NULL;
}
_pNotify=new CATDlgNotify(CATApplicationFrame::GetFrame()->GetMainWindow(),"Warning");
_pNotify->SetText("数据提取结束");
_pNotify->SetVisibility(CATDlgShow);
return TRUE;
样条曲线转换为NUBRS曲线
最新推荐文章于 2022-07-11 19:51:38 发布