iCAx开思工具箱

标题: 拓扑相交出错 请高手指点 帮俺看看源代码! [打印本页]

作者: daiff2008    时间: 2010-12-13 13:18
标题: 拓扑相交出错 请高手指点 帮俺看看源代码!
代码如下:
HRESULT GetIntersectPoint(const CATISpecObject_var &spMainbodyFeature,const CATISpecObject_var &spLineObj)
{
   CATLISTP(CATPoint) LISTPoint = NULL;
   HRESULT rc = S_OK;
   CATBody_var spMainFeaturebody = NULL_var;
   CATBody_var spLineObjBody = NULL_var;

  spMainFeaturebody = GetBodyFromFeature(spMainbodyFeature);
  if (spMainbodyFeature == NULL_var)
  {
    cout<<"Error:GetBodyFromFeature(spMainbodyFeature,spMainFeaturebody)"<<endl;
return E_FAIL;
  }
  cout<<"Get spMainFeaturebody Successful"<<endl;
  rc = GetBodyFromFeature(spLineObj,spLineObjBody);
  if (FAILED(rc)||(spLineObjBody == NULL_var))
   {
    cout<<"Error:GetBodyFromFeature(spLineObj,spLineObjBody)"<<endl;
    return rc;
   }
  cout<<"Get spLineObjbody Successful"<<endl;
CATLISTP(CATCell) LISTCell1;
spLineObjBody->GetAllCells(LISTCell1,1);
if (LISTCell1.Size() <= 0)
{
  cout<<"can't get line body"<<endl;
  return E_FAIL;
}
cout<<"LISTCell1.Size() = "<<LISTCell1.Size()<<endl;

CATLISTP(CATCell) LISTCell2;
spMainFeaturebody->GetAllCells(LISTCell2,2);
if (LISTCell2.Size() <= 0)
{
  cout<<"can't get surface body"<<endl;
  return E_FAIL;
}
cout<<"LISTCell2.Size() = "<<LISTCell2.Size()<<endl;
CATBody* piLineBody = spLineObjBody;
CATBody* piMainFeaturebody = spMainFeaturebody;

cout<<"get piLineBody and piMainfeaturebody successful"<<endl;
CATSoftwareConfiguration* piConfig = new CATSoftwareConfiguration();
CATTopData topData(piConfig);
CATTopData* ptopData = &topData;
CATGeoFactory* piGeomFactory = ::CATCreateCGMContainer() ;
if (NULL == piGeomFactory)
{
  cout<<"Error:::CATCreateCGMContainer()"<<endl;
   return E_FAIL;
}
CATHybIntersect* pHyIntersect =  CATCreateTopIntersect(piGeomFactory,ptopData,piLineBody,piMainFeaturebody);//这句出错,输入对象不能引用
if (NULL == pHyIntersect) return E_FAIL;
  pHyIntersect->Run();
CATBody* piIntersectBody = pHyIntersect->GetResult();
if (piIntersectBody == NULL)
{
cout<<"Error:piIntersectBody == NULL"<<endl;
return E_FAIL;
}
cout<<"Get Intersectbody successful"<<endl;
  return rc;
}
求高手指点


作者: nuaagaoge    时间: 2010-12-13 21:32
今天难得有时间,首先声明,我不是高手,其次,你的代码,没有认真看,但是我想问的是,你这如果是交互式编程,为何出现CATGeoFactory* piGeomFactory = ::CATCreateCGMContainer() ;

作者: daiff2008    时间: 2010-12-14 10:34
非常感谢楼上的回复!
  我是在批处理程序中,测试拓扑相交。我现在要编程有大量的相交操作,如果用CATIA自带命令的相交操作就需要大量的更新和判断,这样速度就非常慢!
  现在每次测试时,就出现这种错误,“输入的对象不能引用”。
求指点迷津!


作者: daiff2008    时间: 2010-12-14 14:18
11111111111111111111111






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