|
马上注册,结交更多同行朋友,交流,分享,学习。
您需要 登录 才可以下载或查看,没有帐号?注册
x
总的思路是获得面后转换为nurbs曲面,CATSurface有获得节点信息的函数GetKnotVectorU/V,CATNurbsSurface有获得控制点的函数GetOneControlPoint(CATLONG,CATLONG,CATMathPoint),节点好像是对的,但是控制点的输出很奇怪,很多零。请我呢有人知道怎么解决这个问题吗?可能我的思路也是有问题的,不知道有没有其他办法。目的就是获得曲面的表示。
if ( _spSurface != NULL )
{
CATSurface *_SurfaceToBeInvented;
HRESULT rc = _spSurface->QueryInterface(IID_CATSurface , (void**)&_SurfaceToBeInvented);
if (FAILED(rc))
{
return;
}
if (_SurfaceToBeInvented==NULL)return;
if (SUCCEEDED(rc))
{
const CATKnotVector *KV4DEG=_SurfaceToBeInvented->GetKnotVectorU();
const CATKnotVector *KV4DEGV=_SurfaceToBeInvented->GetKnotVectorV();
if (KV4DEG!=NULL&&KV4DEGV!=NULL)
{
const double * Knots4DEG = NULL;
KV4DEG->GetKnots(Knots4DEG);
const double * Knots4DEGV = NULL;
KV4DEGV->GetKnots(Knots4DEGV);
CATLONG32 NbKnots4DEG = KV4DEG->GetNumberOfKnots();
CATLONG32 NbOfCPs4DEG = KV4DEG->GetNumberOfControlPoints();
CATLONG32 NewNbArcs4DEG = KV4DEG->GetNumberOfArcs();
CATLONG32 NewDegree4DEG = KV4DEG->GetDegree();
CATLONG32 NbKnots4DEGV = KV4DEGV->GetNumberOfKnots();
CATLONG32 NbOfCPs4DEGV = KV4DEGV->GetNumberOfControlPoints();
CATLONG32 NewNbArcs4DEGV = KV4DEGV->GetNumberOfArcs();
CATLONG32 NewDegree4DEGV = KV4DEGV->GetDegree();
CATGeoFactory* piGeomFactory = ::CATCreateCGMContainer() ;
if (NULL==piGeomFactory) return;
CATSurLimits surLimits;
_SurfaceToBeInvented->GetLimits(surLimits);
CATSurFittingToNurbsSur * pSurFitting1 =
::CATCreateSurFittingToNurbsSur(piGeomFactory,
_SurfaceToBeInvented,
surLimits,
0.001,
0,
ADVANCED);
if (NULL==pSurFitting1)
{
::CATCloseCGMContainer(piGeomFactory);
return;
}
if (_SurfaceToBeInvented!=NULL)
{
_SurfaceToBeInvented->Release();
_SurfaceToBeInvented=NULL;
}
pSurFitting1->Run();
CATNurbsSurface * pNurbsSurf1=NULL;
pNurbsSurf1= pSurFitting1->GetNurbsSurface();
if (NULL==pNurbsSurf1)
{
::CATCloseCGMContainer(piGeomFactory);
return ;
}
if (NULL!=pNurbsSurf1)
{
CATMathPoint * tabOfCPs = new CATMathPoint [NbOfCPs4DEG*NbOfCPs4DEGV];
for (CATLONG32 i=0; i<NbOfCPs4DEG; i++)
{
for(CATLONG32 j=0;j<NbOfCPs4DEGV;j++)
{
pNurbsSurf1->GetOneControlPoint(i+1, j+1,tabOfCPs[i+j]);
}
}
}
if (pSurFitting1!=NULL)
{
delete pSurFitting1;
pSurFitting1=NULL;
}
::CATCloseCGMContainer(piGeomFactory);
|
|