马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
//获取CATBody
CATFrmEditor* pEditor = CATFrmEditor::GetCurrentEditor();
CATDocument *pDoc = pEditor->GetDocument();
CATIDocRoots* piDocRootsOnDoc = NULL;
HRESULT rc = pDoc->QueryInterface(IID_CATIDocRoots,
(void**) &piDocRootsOnDoc);
CATListValCATBaseUnknown_var* pRootProducts = piDocRootsOnDoc->GiveDocRoots();
CATIProduct_var spRootProduct = NULL_var;
if (pRootProducts && pRootProducts->Size())
{
spRootProduct = (*pRootProducts)[1];
}
CATIProduct *piProductOnRoot = NULL;
rc = spRootProduct->QueryInterface(IID_CATIProduct,
(void**) &piProductOnRoot);
CATIProduct_var spRef = piProductOnRoot ->GetReferenceProduct();
CATBody_var ResultBody;
CATILinkableObject * piLinkableObject = NULL;
HRESULT rc = spRef->QueryInterface( IID_CATILinkableObject, (void**)& piLinkableObject );
CATDocument * pDocument = NULL ;
pDocument = piLinkableObject->GetDocument();
CATIContainerOfDocument * pIContainerOfDocumentOnDoc = NULL;
rc = pDocument->QueryInterface(IID_CATIContainerOfDocument, (void**)&pIContainerOfDocumentOnDoc);
CATIContainer * pContainer = NULL ;
rc = pIContainerOfDocumentOnDoc->GetResultContainer(pContainer);
CATIPrtContainer *pSpecContainer = NULL;
rc = pContainer->QueryInterface(IID_CATIPrtContainer, (void**)&pSpecContainer) ;
CATIPrtPart_var spPart = pSpecContainer->GetPart();
pSpecContainer->Release();
pSpecContainer = NULL ;
CATIPartRequest *pPartAsRequest = 0;
rc = spPart->QueryInterface(IID_CATIPartRequest, (void**)&pPartAsRequest) ;
CATLISTV(CATBaseUnknown_var) BodyList;
pPartAsRequest->GetSolidBodies(CATUnicodeString(" "), BodyList);
for(int curSetIdx=1; curSetIdx<=BodyList.Size(); curSetIdx++)
{
CATBaseUnknown_var CurrentSet = BodyList[curSetIdx] ;
CATIBodyRequest *pBodyRequestOnCurrentSet = NULL;
rc = CurrentSet->QueryInterface(IID_CATIBodyRequest, (void**)&pBodyRequestOnCurrentSet);CATLISTV(CATBaseUnknown_var) pListResult;
rc = pBodyRequestOnCurrentSet->GetResults(CATUnicodeString(" "), pListResult);
CATBaseUnknown_var CurrentFeat = pListResult[1] ;
CATIGeometricalElement *pGeomEltOnCurFeat = 0;
rc = CurrentFeat->QueryInterface(IID_CATIGeometricalElement, (void**)&pGeomEltOnCurFeat);
ResultBody = pGeomEltOnCurFeat->GetBodyResult();
}
//下面是进行布尔操作
CATSoftwareConfiguration * pConfig = new CATSoftwareConfiguration();
CATTopData topdata(pConfig);
CATGeoFactory* piGeomFactory = CATCreateCGMContainer() ;
CATDynBoolean* pOperatorBool = CATCreateDynBoolean(piGeomFactory,&topdata,CATBoolUnion,body1,body2);
if(pOperatorBool!=NULL)
{
pOperatorBool->Run();
CATBody* resultBody = pOperatorBool->GetResult();
if(resultBody==NULL)
{
MessageBox(NULL,_T("fail!"),_T("通知消息"),NULL);
}
}
|