CAA判断点(特征)是否在曲线(特征)线上

版本为 CAA V6,未验证V5是否可行

采用了函数CATIMeasurableInContext::MinimumDistance,对象接口需为曲线特征转换而来;输入为数学点,输出为曲线上距离该点的最近的数学点及其最近距离。当距离小于误差范围,即认为点在曲线上。事实上,若点在曲线上,返回的距离值为0.

 

int IsPointOnCurve(const CATBaseUnknown_var & ispPoint, const CATBaseUnknown_var & ispCurve)
{
	CATIMeasurableInContext_var spMeasurablePoint = ispPoint;
	CATIMeasurableInContext_var spMeasurableCurve = ispCurve;
	if (NULL_var==spMeasurablePoint || NULL_var==spMeasurableCurve)	return 1;

	CATMathPoint mPt;	spMeasurablePoint->GetPoint(mPt);

	double dDis=-1;
	double dError=0.001;
	CATMathPoint mTemp;
	spMeasurableCurve->MinimumDistance(mPt, dDis, mTemp);
	if (dDis>=0 && dDis<=dError)
	{
		return 0;
	}

	return 2;
}

 

你可能感兴趣的:(CAA,CATIA)