⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geutilities.h

📁 能在MDT5/6环境下对已经存在地曲面进行全部和局部区域展开
💻 H
📖 第 1 页 / 共 3 页
字号:
#ifndef GE_UTILITIES_H
#define GE_UTILITIES_H

//////////////////////////////////////////////////////////////////////////
//
// 与图形和几何实体等相关的函数
//
// Note:
//		
//////////////////////////////////////////////////////////////////////////


#include "TypeDef.h"

#ifdef _DBXEXP_
#define DLLIMPEXP __declspec(dllexport)
#else
#define DLLIMPEXP 
#endif

/*
 *	Purpose:
 *		get points from spline entity.
 *	Argument:
 *		spl		[in], spline entity pointer.
 *		pnts	[out], return points.
 */
extern DLLIMPEXP void 
getPntsFromSpline(AcDbSpline *spl,AcGePoint3dArray& pnts);


/*
 *	Purpose:
 *		get points from spline entity.
 *	Argument:
 *		spl		[in], spline entity pointer.
 *		pointnum[in], the needed point num.
 *		pnts	[out], return points.
 */
extern DLLIMPEXP void 
getPntsFromSpline(AcDbSpline *spl,AcGePoint3dArray& pnts,int pointnum);



/*
 *	Purpose:
 *		获取曲线的特征点
 *	Argument:
 *		pCurve		[in], curve pointer.
 *		pnts		[out], return points.
 *		numPoint	[in], 需要获取的特征点数,
 *					为0时取曲线所有节点处值.
 *	Return:
 *		true 成功得到曲线上的特征点, 
 *		false输入参数错误或不支持的曲线类型.
 */
extern DLLIMPEXP bool 
getPntsFromCurve(AcDbCurve *pCurve, 
				 AcGePoint3dArray& pnts, 
				 int numPoint=0);


/*
 *	Purpose:
 *		获取曲线的特征点
 *	Argument:
 *		pCurve		[in], curve pointer.
 *		pnts		[out], return points.
 *		numPoint	[in], 需要获取的特征点数,
 *					为0时取曲线所有节点处值.
 *	Return:
 *		true 成功得到曲线上的特征点, 
 *		false输入参数错误或不支持的曲线类型.
 */
extern DLLIMPEXP bool 
getPntsFromCurve(AcGeCurve3d *pCurve, 
				 AcGePoint3dArray& pnts, 
				 int numPoint=0);

/*
 *	Purpose:
 *		求数组中最小的数组元素位置索引从0开始,返回索引.
 *	Argument:
 *		arr		[in], 数组.
 *	Return:
 *		索引值.
 */
extern DLLIMPEXP int 
minArr(const AcGeDoubleArray& arr);


/*
 *	Purpose:
 *		求数组中最大的数组元素位置索引从0开始,返回索引.
 *	Argument:
 *		arr		[in], 数组.
 *	Return:
 *		索引值.
 */
extern DLLIMPEXP int 
maxArr(const AcGeDoubleArray& arr);


/*
 *	Purpose:
 *		返回该浮点数最接近的整数.
 *	Argument:
 *		x		[in], 浮点数.
 *	Return:
 *		最接近的整数.
 */
extern DLLIMPEXP int 
Round(const double& x);


/*
 *	Purpose:
 *		由三点得到平面,当返回值Acad::eOk时返回的pln才有意义.
 *	Argument:
 *		pnts	[in], 三点坐标.
 *		pln		[out], 返回平面.
 *	Return:
 *		Acad::eOk 成功.
 */
extern DLLIMPEXP Acad::ErrorStatus 
getPlaneFrom3Pnts(const AcGePoint3dArray& pnts,AcGePlane& pln);


/*
 *	Purpose:
 *		由三点得到平面,当返回值Acad::eOk时返回的pln才有意义.
 *	Argument:
 *		p1		[in], 三点坐标.
 *		p2		[in], 三点坐标.
 *		p3		[in], 三点坐标.
 *		pln		[out], 返回平面.
 *	Return:
 *		Acad::eOk 成功.
 */
extern DLLIMPEXP Acad::ErrorStatus 
getPlaneFrom3Pnts(const AcGePoint3d& p1, const AcGePoint3d& p2,
				  const AcGePoint3d& p3,AcGePlane& pln);


/*
 *	Purpose:
 *		由平面三点求三角形面积,p1,p2,p3呈逆时针排列.
 *	Argument:
 *		p1		[in], 三点坐标.
 *		p2		[in], 三点坐标.
 *		p3		[in], 三点坐标.
 *	Return:
 *		三角形面积.
 */
extern DLLIMPEXP double 
triangleArea(const AcGePoint2d& p1, 
			 const AcGePoint2d& p2, 
			 const AcGePoint2d& p3);



/*
 *	Purpose:
 *		由平面三点求三角形面积,p1,p2,p3呈逆时针排列.
 *	Argument:
 *		p1		[in], 三点坐标.
 *		p2		[in], 三点坐标.
 *		p3		[in], 三点坐标.
 *	Return:
 *		三角形面积.
 */
extern DLLIMPEXP double 
triangleArea(const AcGePoint3d& p1, const AcGePoint3d& p2, const AcGePoint3d& p3);


/*
 *	Purpose:
 *		 倒转点数组的数组.
 *	Argument:
 *		pntsArr		[in][out], 点数组的数组.
 *	Return:
 *		三角形面积.
 */
extern DLLIMPEXP void 
reverse(ChGePnts2dArray& pntsArr);

/*
 *	Purpose:
 *		 倒转点数组的数组.
 *	Argument:
 *		pntsArr		[in][out], 点数组的数组.
 *	Return:
 *		三角形面积.
 */
extern DLLIMPEXP void 
reverse(ChGePnts3dArray& pntsArr);

/*
 *	Purpose:
 *		判断矢量从vec1到vec2是否顺时针.
 *	Argument:
 *		vec1	[in], 矢量1.
 *		vec2	[in], 矢量2.
 *	Return:
 *		顺时针返回kTrue,否则返回kFalse.
 */
extern DLLIMPEXP Adesk::Boolean 
isClockwise(const AcGeVector2d& vec1, const AcGeVector2d& vec2);



/*
 *	Purpose:
 *		判断点pnt是否在直线line的右手边.
 *	Argument:
 *		line	[in], 直线.
 *		pnt		[in], 点.
 *	Return:
 *		在右手边返回true,否则返回false.
 */
extern DLLIMPEXP Adesk::Boolean 
isClockwise(const AcGeLine2d& line, const AcGePoint2d& pnt);



/*
 *	Purpose:
 *		判断点pnt是否在直线p1p2的右手边.
 *	Argument:
 *		p1		[in], 直线第一点.
 *		p2		[in], 直线第二点.
 *		pnt		[in], 点.
 *	Return:
 *		在右手边返回true,否则返回false.
 */
extern DLLIMPEXP Adesk::Boolean 
isClockwise(const AcGePoint2d& pnt,const AcGePoint2d& p1,const AcGePoint2d& p2);



/*
 *	Purpose:
 *		判断曲面上点相对曲线的方向.
 *	Argument:
 *		surf		[in], 曲面.
 *		curve		[in], 曲面上曲线点数组.
 *		dirPnt		[in], 曲面上点.
 *	Return:
 *		在右手边返回true,否则返回false.
 */
extern  DLLIMPEXP bool 
isClockwise(const AcGeNurbSurface& surf,const AcGePoint3dArray& curve,const AcGePoint3d& dirPnt);



/*
 *	Purpose:
 *		判断点相对于线段的位置. 2d
 *	Argument:
 *		p		[in], 需判断的点.
 *		p1		[in], 线段的第一点.
 *		p2		[in], 线段的第二点.
 *	Return:
 *		点在线段上,return 0;
 *		点与线段第一点重合,return 1;
 *		点与线段第二点重合,return 2;
 *		点在线段延长线上,return 3;
 *		点在线段外,return -1;
 */
extern DLLIMPEXP int 
pointPosToLine(const AcGePoint2d& p,const AcGePoint2d& p1,const AcGePoint2d& p2);


/*
 *	Purpose:
 *		判断点相对于线段的位置. 3d
 *	Argument:
 *		p		[in], 需判断的点.
 *		p1		[in], 线段的第一点.
 *		p2		[in], 线段的第二点.
 *	Return:
 *		点在线段上,return 0;
 *		点与线段第一点重合,return 1;
 *		点与线段第二点重合,return 2;
 *		点在线段延长线上,return 3;
 *		点在线段外,return -1;
 */
extern DLLIMPEXP int 
pointPosToLine(const AcGePoint3d& p,const AcGePoint3d& p1,const AcGePoint3d& p2);



/*
 *	Purpose:
 *		判断点pnt相对于三角形pnts的位置.
 *	Argument:
 *		pnt		[in], 需判断的点.
 *		pnts	[in], 三角形三顶点, 点逆时针排列p1p2p3.
 *	Return:
 *		点与三角形顶点重合,对应p1p2p3分别返回1,2,3;
 *		点在三角形边上,对应p1p2,p2p3,p3p1分别返回4,5,6;
 *		点三角形内,返回0;
 *		点三角形外,返回-1;
 */
extern DLLIMPEXP int 
pointPosToTriangle(const AcGePoint2d& pnt,AcGePoint2dArray& pnts);


/*
 *	Purpose:
 *		由面积等比原则,通过三角形p1p2p3内一点p4,及对应得三角形
 *		r1r2r3,得出对应的点r4.
 *	Argument:
 *		pnts1	[in], 三角形顶点p1p2p3及其内一点p4数组.
 *		pnts2	[in][out], 三角形顶点r1r2r3及其内一点r4数组,
 *				其中r4为返回值.
 */
extern DLLIMPEXP bool 
mapPointInTriangle(AcGePoint2dArray& pnts1,AcGePoint2dArray& pnts2);

/*
 *	Purpose:
 *		由面积等比原则,通过三角形p1p2p3内或上一点p4,及对应得三角形
 *		r1r2r3,得出对应的点r4.
 *	Argument:
 *		pnts1	[in], 三角形顶点p1p2p3及其内一点p4数组.
 *		pnts2	[in][out], 三角形顶点r1r2r3及其内一点r4数组,
 *				其中r4为返回值.
 *		bIfMapOut [in], 当点在三角形外时,是否认为是其内的点来计算
 *  Return:
 *		成功true, 输入参数不正确或点在三角形外false
 *		当bIfMapOut=true时,会得出一个结果,但仍然返回false
 */
extern DLLIMPEXP bool 
mapPointTriangle(AcGePoint2dArray& pnts1,AcGePoint2dArray& pnts2, bool bIfMapOut=false);


/*
 *	Purpose:
 *		由面积等比原则,通过线段p1p2内一点p3及对应的线段r1r2,
 *		得出r1r2上对应的点r3.
 *	Argument:
 *		pnts1	[in], 线段顶点p1p2及其内一点p3数组,
 *				注意p3必须是线段内的点.
 *		pnts2	[in][out], 线段顶点r1r2及其内一点r3数组,
 *				其中r3为返回值.
 */
extern DLLIMPEXP void 
mapPointInLine(AcGePoint2dArray& pnts1,AcGePoint2dArray& pnts2);


/*
 *	Purpose:
 *		由面积等比原则,通过线段p1p2内一点p3及对应的线段r1r2,
 *		得出r1r2上对应的点r3.
 *	Argument:
 *		pnts1	[in], 线段顶点p1p2及其内一点p3数组,
 *				注意p3必须是线段内的点.
 *		pnts2	[in][out], 线段顶点r1r2及其内一点r3数组,
 *				其中r3为返回值.
 */
extern DLLIMPEXP void 
mapPointInLine(AcGePoint3dArray& pnts1,AcGePoint2dArray& pnts2);

/*
 *	Purpose:
 *		由面积等比原则,通过线段p1p2内一点p3及对应的线段r1r2,
 *		得出r1r2上对应的点r3.
 *	Argument:
 *		pnts1	[in], 线段顶点p1p2及其内一点p3数组,
 *				注意p3必须是线段内的点.
 *		pnts2	[in][out], 线段顶点r1r2及其内一点r3数组,
 *				其中r3为返回值.
 */
extern DLLIMPEXP void 
mapPointInLine(AcGePoint2dArray& pnts1,AcGePoint3dArray& pnts2);


/*
 *	Purpose:
 *		由面积等比原则,通过三角形p1p2p3上(顶点或边上)一点p4,
 *		及对应得三角形r1r2r3,得出对应的点r4.
 *	Argument:
 *		pnts	[in], 三角形顶点p1p2p3及需判断点p数组.
 *				三角形顶点逆时针排列.
 *		pos		[in], p4在三角形上的位置, 由pointPosToTriangle()得到
 *		mpnts	[in][out], 映射三角形顶点mp1mp2mp3及映射点mp数组,
 *				其中mp为返回值.
 *	Return:
 *		true 点是在三角形上
 */
extern DLLIMPEXP bool 
mapPointOnTriangle(AcGePoint2dArray& pnts, int pos, AcGePoint2dArray& mpnts);


/*
 *	Purpose:
 *		verify if point is on curve.
 *	Argument:
 *		pnt		[in], point positon.
 *		curve	[in], nurbcurve.
 *		tol		[in], tolerance.
 *	Return:
 *		kTrue 点是在曲线上
 */
extern DLLIMPEXP Adesk::Boolean 
isOnCurve(const AcGePoint2d& pnt, const AcGeNurbCurve2d& curve,const double& tol=AcGeContext::gTol.equalPoint());

/*
 *	Purpose:
 *		verify if point is on curve.
 *	Argument:
 *		pnt		[in], point position.
 *		ply	    [in], polyline.
 *		tol		[in], tolerance.
 *	Return:
 *		kTrue 点是在多段线上
 */
extern DLLIMPEXP Adesk::Boolean 
isOnCurve(const AcGePoint2d& pnt, const AcGePolyline2d& ply,const double& tol=AcGeContext::gTol.equalPoint());

/*
 *	Purpose:
 *		verify if point is on the right of polyline curve.
 *	Argument:
 *		pnt		[in], point positon.
 *		ply		[in], curve.
 *	Return:
 *		kTrue if point on the right of curve, otherwise kFalse.
 */
extern DLLIMPEXP Adesk::Boolean 
isClockwise(const AcGePoint2d& pnt, const AcGePolyline2d& ply);

/*
 *	Purpose:
 *		verify if point is on the right of curve.
 *	Argument:
 *		pnt		[in], point positon.
 *		spl		[in], curve.
 *	Return:
 *		kTrue if point on the right of curve, otherwise kFalse.
 */
extern DLLIMPEXP Adesk::Boolean 
isClockwise(const AcGePoint2d& pnt, const AcGeNurbCurve2d& spl);


/*
/ *
*	Purpose:
*		verify if point is on the right of curve.
*	Argument:
*		pnt		[in], point positon.
*		crv		[in], curve.
*	Return:
*		kTrue if point on the right of curve, otherwise kFalse.
* /
extern DLLIMPEXP Adesk::Boolean 
isClockwise(const AcGePoint2d& pnt, const AcGeCurve2d& crv);
*/



/*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -