局部坐标系下的重心,单位为m。由于V6对Product的打开机制是VisualMode,故获取速度会很慢。
ExportedByARKGlobal void GetCoG(CATIPLMNavOccurrence *ipOcc,double *oaCog)
{
CATApplicationFrame *pappFrame = CATApplicationFrame::GetFrame();
CATIAApplication *ptApp = NULL;
pappFrame -> QueryInterface(IID_CATIAApplication, (void**) &ptApp);
CATIAEditor *ptEditor = NULL;
ptApp -> get_ActiveEditor(ptEditor);
CATIAService *pService=NULL;
UString servicename("InertiaService");
CATBSTR servicenameBSTR;
servicename.ConvertToBSTR(&servicenameBSTR);
ptEditor -> GetService(servicenameBSTR,pService);
ReleaseInterface(ptEditor);
CATIAInertiaService *pInerService=(CATIAInertiaService *)pService;
CATIPLMNavInstance *pInstOnOcc=NULL;
ipOcc -> GetRelatedInstance(pInstOnOcc);
CATIPLMNavReference *pRefOnOcc=NULL;
pInstOnOcc -> GetReferenceInstanceOf(pRefOnOcc);
ReleaseInterface(pInstOnOcc);
CATIPrdOccurrenceMngt* pOccMngt = NULL;
CATPrdGetOccurrenceMngt(pOccMngt);
CATIPLMNavOccurrence_var spOccOnRef;
pOccMngt -> GetOrCreateRootOccurrence(pRefOnOcc,spOccOnRef);
ReleaseInterface(pRefOnOcc);
ReleaseInterface(pOccMngt);
CATIABase *pRefBase=NULL;
spOccOnRef -> QueryInterface(IID_CATIABase,(void**)&pRefBase);
CATIAInertia *pInertia=NULL;
pInerService -> GetInertiaElement(pRefBase,pInertia);
pInertia -> GetCOGPosition(oaCog[0],oaCog[1],oaCog[2]);
ReleaseInterface(pInertia);
ReleaseInterface(pRefBase);
ReleaseInterface(pService);
ReleaseInterface(ptApp);
}