|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
我用CATDistanceMinBodyBody接口的GetDistance()来获取两直线之间的最短距离,然后我想获得实现这最短距离的两个点,我用的是GetPoints( CATPoint*& oPoint1, CATPoint*& oPoint2) ,但结果oPoint1和oPoint2是空的,我想请问这是为什么呀?直线的类型是GSMLine。具体代码如下:
CATISpecObject_var TheLine1 = pIDescendantOnOpenBody1->GetChildAtPosition(1);
CATISpecObject_var TheLine2 = pIDescendantOnOpenBody1->GetChildAtPosition(14);
CATGeoFactory* pGeomFactory = ::CATCreateCGMContainer();
CATSoftwareConfiguration *pConfig = NULL;
pConfig = new CATSoftwareConfiguration();
CATCGMJournalList *pJournal = NULL;
pJournal = new CATCGMJournalList();
CATTopData* pTopoData = NULL;
pTopoData = new CATTopData(pConfig,pJournal);
CATIGeometricalElement_var spGeoLine1 = TheLine1;
CATIGeometricalElement_var spGeoLine2 = TheLine2;
CATBody* pBodyLine1 = spGeoLine1->GetBodyResult();
CATBody* pBodyLine2 = spGeoLine2->GetBodyResult();
if(pBodyLine1 == NULL || pBodyLine2 == NULL)
{
cout<<"Error in Inputs !"<<endl;
}
CATDistanceMinBodyBody *pDistanceMinMin = NULL;
pDistanceMinMin = CATCreateDistanceMinTopo(pGeomFactory,pTopoData,pBodyLine1,pBodyLine2,BASIC);
double totallength = 0.0;
totallength = pDistanceMinMin->GetDistance(); //得出最短距离
cout << "totallength "<< totallength << endl;
CATPoint *oPoint1 = NULL;
CATPoint *oPoint2 = NULL;
pDistanceMinMin -> GetPoints(oPoint1,oPoint2);//获取实现最短距离的两个点
if (NULL == oPoint1)
{
cout<<"oPoint1为空"<<endl;
}
cout << "The X cordinate is :" << oPoint1 -> GetX() << endl;
最短距离能够正确得到,但输出oPoint1为空。
|
|