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

📄 csdareamethod.h

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

#include <gept2dar.h>
#include <genurbsf.h>	// AcGeNurbsCurve
#include <genurb3d.h>	// AcGeNurbsCurve3d
#include "TypeDef.h"

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

// 曲面展开数据结构
struct DLLIMPEXP CSDData {
	CSDData() { // 定义各变量缺省值
		bFullD = false;
		bAutoOCenter = false;
		nU = 20;
		nV = 20;
		dCenter = AcGePoint2d::kOrigin;
		dCenterZ = 0.0;
		bDevInner = false;
		nTol = 10;
//		bIsReversed = false;
	}
	AcGeNurbSurface		oBaseSurf;	// 原曲面基面
	ChGeLoop3dArray		oSurfLoops; // 原曲面loop,第一个为外,其余为内
	bool				bFullD;		// 是否全部区域展开
	bool				bAutoOCenter;// 是否由程序自动确定曲面展开中心,当bFullD=true时有效
	AcGePoint3d			oCenter;	// 原曲面展开中心
	AcGeInterval		oEvalU;     // u向原曲面展开部分的起始u和截止u值
	AcGeInterval		oEvalV;     // v向原曲面展开部分的起始v和截止v值
	int					nU;			// u方向分网数,离散点数为nU+1
	int					nV;			// v方向分网数,离散点数为nV+1
	AcGePoint2d			dCenter;	// 展开平面中心
	double				dCenterZ;	// 展开平面在空间中Z向坐标
	bool				bDevInner;	// 是否展开内轮廓
//	bool				bIsReversed;// 展开平面法向是否为Z+,true为Z-,false为Z+
	int					nTol;       // 在判断相等时,误差为参考量的1/nTol,即tol=tolRef/nTol
									// 参考量为离散点最小间距
};

/*
 * dists[0]: 中心点处v线上距离中心点u负方向的距离
 * dists[1]: 中心点处v线上距离中心点u正方向的距离
 * dists[2]: 中心点处u线上距离中心点v负方向的距离
 * dists[3]: 中心点处u线上距离中心点v正方向的距离
 * 由展开数据和上述距离计算得到展开区域参数[(u1,u2),(v1,v2)],
 * 以及是否全部区域展开
 * 输入和输出都在data中
 */
DLLIMPEXP bool 
getEvalSection(CSDData& data,const AcGeDoubleArray& dists);

// 曲面展开几何对象
class  DLLIMPEXP CSDAreaISO
{
public:
	CSDAreaISO();
	CSDAreaISO(CSDAreaISO& csd);
	~CSDAreaISO();

	// 设置曲面展开参数
	bool set(const CSDData& data);

	// 判断展开平面方向方向,true为Z-, false为Z+
//	bool isReversed();
	// 判断点是否在原曲面上
	bool isOnOBaseSurf(const AcGePoint3d& op) const;
	// 判断点是否在展开平面上
	bool isOnDBaseSurf(const AcGePoint2d& dp) const;
	bool isOnDBaseSurf(const AcGePoint3d& dp) const;
	// 是否已经设置了展开参数
	bool isDefined(void) const;

	// 映射曲面上一点到展开平面上,注意op必须是曲面上的点,否则可能错误
	bool mapPointToD(const AcGePoint3d& op,AcGePoint2d& dp);
	bool mapPointToD(const AcGePoint3d& op,AcGePoint3d& dp);
	// 如果bIfForcedMap=true,则当某个点不能映射时,继续映射下一个点,否则返回错误,dc置空
	bool mapPointsToD(const AcGePoint3dArray& oc,AcGePoint2dArray& dc,bool bIfForcedMap=true);
	bool mapPointsToD(const AcGePoint3dArray& oc,AcGePoint3dArray& dc,bool bIfForcedMap=true);
	// 映射展开平面上一点到曲面上,成功返回true
	bool mapPointToO(const AcGePoint2d& dp,AcGePoint3d& op);
	bool mapPointToO(const AcGePoint3d& dp,AcGePoint3d& op);
	bool mapPointsToO(const AcGePoint2dArray& dc,AcGePoint3dArray& oc,bool bIfForcedMap=true);
	bool mapPointsToO(const AcGePoint3dArray& dc,AcGePoint3dArray& oc,bool bIfForcedMap=true);

	// 获取初始指定中心
	double getDPlaneZ() {return dCenterZ;}
	AcGePoint3d getOCenter() {return oCenter;}
	AcGePoint2d getDCenter() {return dCenter;}
	// 获取离散点中心
	AcGePoint3d getORCenter() {return oRCenter;}
	AcGePoint2d getDRCenter() {return dRCenter;}
	// 获取计算区域
	void getEvalSection(AcGeInterval& u, AcGeInterval& v)
	{  u = oEvalU; v = oEvalV;	}
	// 获取离散化UV方向分割数,u方向分网数
	int getNU() {return nU;}
	int getNV() {return nV;}
	// 获取中心点所在位置
	int getPosCU() {return posCU;}
	int getPosCV() {return posCV;}
	// 获取误差值
	double getTol() { return dTol; }
	// 获取误差因子
	int getNTol() { return nTol; }
	// 得到原曲面属性
	AcGeNurbSurface getOBaseSurf() {return oBaseSurf;}
	void getOSurfLoops(ChGeLoop3dArray& loops) { loops = oSurfLoops; }
	bool getCSDData(CSDData& data);
	// 得到展开面属性
	bool getDSurfLoops(ChGeLoop3dArray& loops);
	void getDSurfLoops(ChGeLoop2dArray& loops) { loops = dSurfLoops; }
	bool getDBaseSurfLoop(ChGeLoop2d& loop);

private:

	// 计算原曲面loops在参数空间上的loops
	void evalOParamLoops();
	// 原曲面网格离散化,并计算原曲面展开中心点对应的离散网格点位置,
	// 得到真正的原曲面展开中心oRCenter
	void evalOPnts();
	// 计算展开中心周围四点对应的展开平面顶点
	void eval4PntsArdCenter();
	// 计算第Ⅰ区头两排顶点,要求先执行eval4PntsArdCenter
	void eval1stSecRow();
	// 计算第Ⅱ区头两列顶点
	void eval2ndSecCol();
	// 计算第Ⅲ区头两排顶点
	void eval3rdSecRow();
	// 计算第Ⅳ区头两列顶点
	void eval4thSecCol();
	// 计算第Ⅰ区其他顶点,要求先执行eval1stSecRow()和eval2ndSecCol()
	void eval1stSecOth();
	// 计算第Ⅱ区其他顶点,……
	void eval2ndSecOth();
	// 计算第Ⅲ区其他顶点,……
	void eval3rdSecOth();
	// 计算第Ⅳ区其他顶点,……
	void eval4thSecOth();
	// 计算展开平面上点及真实展开中心dRCenter
	void evalDPnts();
	// 计算判断相等时的误差
	void evalTol();
	// 计算展开平面顶点
	void evalPnts();
	// 生成展开平面四条边线
	void genDSurf();
	// 曲面展开计算
	void eval();
	// 映射左下三角形内的点到展开平面
	bool mapLeftBottToD(int posu,int posv, const AcGePoint3d& op, AcGePoint2d& dp);
	// 映射右上三角形内的点到展开平面
	bool mapRightUpToD(int posu,int posv, const AcGePoint3d& op, AcGePoint2d& dp);
	// 映射左下三角形内的点到原始平面
	bool mapLeftBottToO(int posu,int posv, const AcGePoint2d& dp, AcGePoint3d& op);
	// 映射右上三角形内的点到原始平面
	bool mapRightUpToO(int posu,int posv, const AcGePoint2d& dp, AcGePoint3d& op);

protected:

	AcGeNurbSurface		oBaseSurf;	// 原曲面基面
	ChGeLoop3dArray		oSurfLoops; // 原曲面loop,第一个为外,其余为内
	bool				bFullD;		// 是否全部区域展开
	bool				bAutoOCenter; // 是否自动计算原曲面展开中心
	bool				bDevInner;	// 是否展开内轮廓
	int					nU;			// u方向分网数,离散点数为nU+1
	int					nV;			// v方向分网数,离散点数为nV+1
	AcGePoint3d			oCenter;	// 原曲面展开中心
	AcGeInterval		oEvalU;     // u向原曲面展开部分的起始u和截止u值
	AcGeInterval		oEvalV;     // v向原曲面展开部分的起始v和截止v值

	AcGePoint3dArray	oPntArr;	// 原曲面展开区域离散点数组
	AcGePoint3d			oRCenter;	// 原曲面展开中心在数组中最接近的离散点
	int					posCU;		// u方向展开中心位置[0,nU-1]
	int					posCV;		// V方向展开中心位置[0,nV-1]

	AcGeNurbSurface		dBaseSurf;		// 展开面基面
	ChGeLoop2dArray		dSurfLoops;     // 展开面loop,第一个为外,其余为内
	AcGeKnotVector		dBaseSurfParamU;// 展开面U向参数
	AcGeKnotVector		dBaseSurfParamV;// 展开面V向参数
	AcGePoint2dArray	dPntArr;	    // 展开面离散点数组

	AcGePoint2d			dCenter;	// 展开平面中心
	AcGePoint2d			dRCenter;	// 展开平面中心点最接近的离散点
	double				dCenterZ;	// 展开平面在空间中Z向坐标

	int					nSingularity;	// 原曲面顶点重合性
	// 0 - 没有重合顶点,
	// 1 - P(0,0)与P(nU,0)重合,   2 - P(nU,0)与P(nU,nV)重合
	// 3 - P(nU,nV)与P(0,nV)重合, 4 - P(0,nV)与(0,0)重合
	AcGePoint3d			oSingularity;	// 原曲面上的重合顶点
	AcGePoint2d			dSingularity;	// 展开曲面上的重合顶点

	int					nTol;       // 误差因子, 在判断相等时,误差为参考量的1/nTol,即tol=tolRef/nTol
									// 参考量为离散点最小间距
	double				dTol;		// 曲面和展开平面上在判断相等时的误差
//	bool				bIsReversed;// 展开平面法向是否为Z+,true为Z-,false为Z+

private:
	ChGeLoop2dArray		oSurfTrimmedLoops2d; // 展开面参数域上loop被计算域剪切后,第一个为外,其余为内
	AcGePoint3dArray	pntArr1;	// 原曲面临时顶点数组
	AcGePoint2dArray	pntArr2;	// 展开平面临时顶点数组
};

#endif

⌨️ 快捷键说明

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