iCAx开思网
标题:
CAA 选择对象后的类型转换问题
[打印本页]
作者:
liuruixiao205
时间:
2006-3-21 13:10
标题:
CAA 选择对象后的类型转换问题
如图:我得到圆柱的对象,代码如下:
_BodyAgent=new CATFeatureImportAgent("surface");
_BodyAgent->SetOrderedElementType("CATIMfTriDimResult");
_BodyAgent->AddOrderedElementType("CATBody");
_BodyAgent->AddOrderedElementType("CATIPad");
_BodyAgent->AddOrderedElementType("CATCylinder");
_BodyAgent->SetBehavior ( CATDlgEngWithPrevaluation | CATDlgEngWithCSO | CATDlgEngOneShot );
_BodyAgent->SetAgentBehavior ( MfPermanentBody | MfLastFeatureSupport | MfRelimitedFeaturization );
AddCSOClient(_BodyAgent);
CATBoolean SimVolCmd::BodySelect(void *data)
{
// TODO: Define the action associated with the transition
// ------------------------------------------------------
CATBaseUnknown_var spSelection = _BodyAgent->GetElementValue();
if(NULL_var!=spSelection)
{
spBody=spSelection;
if(spBody!=NULL)
cout<<"spBody!=Null"<<endl;
CATIAlias_var spName = NULL_var;
CATISpecObject_var spBody->QueryInterface(IID_CATIAlias,
(void**) &spName);
CATUnicodeString name = spName->GetAlias();
DlgBox->SetBodyName(name);
}
_BodyAgent->InitializeAcquisition();
return TRUE;
}
我用得到的spBody->QueryInterface(IID_CATCylinder ,(void**)&spCysinder);可是得到的对象为空,请问是什么原因?
作者:
liuruixiao205
时间:
2006-3-23 09:18
顶一下,别沉了。还急用
作者:
daoshou
时间:
2006-3-23 19:08
叮叮咚咚叮叮咚咚叮叮咚咚
作者:
acoka
时间:
2006-3-23 22:36
CATISpecObject和CATCylinder实际上是2码事吧
你得先求得CATISpecObject的CATBody,然后求其中的其中的3次元要素。然后其中哪个是CATCylinder
作者:
liuruixiao205
时间:
2006-3-24 09:18
谢谢acoka兄!
作者:
liuruixiao205
时间:
2006-3-24 10:50
如果是1次元要素可以用CATVertex->GetPoint()得到CATPoint,可我得到了CATVolume,可它里面没有成员函数,直接把它赋值给CATCylinder 又不行。应该怎么办呢?
作者:
acoka
时间:
2006-3-27 16:40
看了一下帮助
好久没做这个了,不太确定,但你可以试试看
CATCylinder* VIVSample::GetCylinderFromSpec( const CATISpecOBject_var& ispSpec)
{
CATCylinder* pCylinder = NULL;
do {
if( !ispSpec) {
break;
}
// GetBody(you can create a method named GetBodyFromFeature)
CATBody_var spSolidCylinderBody = GetBodyFromFeature( ispSpec );
if( !spBody) {
break;
}
// Get all of the 2-dim cell
CATLISTP(CATCell) cellListFace;
spSolidCylinderBody->GetAllCells(cellListFace,2);
// Get cylinder wall face
for ( int iCnt = 1; iCnt<=cellListFace.Size(); iCnt++ ) {
CATFace* pFace = (CATFace*)cellListFace[iCnt];
if( !pFace){
continue;
}
CATSurface* pSurface = pFace->GetSurface();
if ( !pSurface) {
continue;
}
if ( !pSurface->IsATypeOf( CATCylinder)) {
continue;
}
pCylinder = (CATCylinder*)pSurface;
break;
}
} while ( false);
return pCylinder;
}
欢迎光临 iCAx开思网 (https://www.icax.org/)
Powered by Discuz! X3.3