iCAx开思工具箱

标题: CAA两个part布尔运算出错,该怎么解决,代码以贴出,请高手帮忙解决,谢谢 [打印本页]

作者: BeDemon    时间: 2017-8-18 20:45
标题: CAA两个part布尔运算出错,该怎么解决,代码以贴出,请高手帮忙解决,谢谢
//获取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);
}
}


作者: firescript    时间: 2017-8-20 09:40
CATGeoFactory            * piGeomFactory              = NULL;
................................................................................
if ( SUCCEEDED(rc) )
             {
                // Do not release this pointer
                CATDocument * pDocument = NULL ;
                pDocument = piLinkableObjectOnCombinedCurve->GetDocument();
   
                if ( NULL != pDocument )
                {
                   CATIContainerOfDocument * pIContainerOfDocument = NULL ;
                   rc = pDocument->QueryInterface(IID_CATIContainerOfDocument,
                                                      (void**)& pIContainerOfDocument );
                   if ( SUCCEEDED(rc) )
                   {
                      CATIContainer * pIContainerOnGeomContainer = NULL ;
                      rc = pIContainerOfDocument->GetResultContainer(pIContainerOnGeomContainer);
                      if ( SUCCEEDED(rc) )
                      {

                         rc = pIContainerOnGeomContainer->QueryInterface( IID_CATGeoFactory ,
                                                                       (void**) &piGeomFactory );
                         pIContainerOnGeomContainer->Release();
                         pIContainerOnGeomContainer = NULL ;
                      }

                      pIContainerOfDocument->Release();
                      pIContainerOfDocument = NULL ;
                   }
                }
                piLinkableObjectOnCombinedCurve->Release();
                piLinkableObjectOnCombinedCurve = NULL ;
             }
作者: BeDemon    时间: 2017-8-22 09:47
firescript 发表于 2017-8-20 09:40
CATGeoFactory            * piGeomFactory              = NULL;
..................................... ...

嗯,谢谢回复,这是一个问题,还有就是,布尔运算的两个Body必须在一个part下,另外问下,布尔运算后的结果怎样再挂载到Part下?




欢迎光临 iCAx开思工具箱 (https://t.icax.org/) Powered by Discuz! X3.3