3675 lines
96 KiB
C++
3675 lines
96 KiB
C++
// PipeStyle.cpp: implementation of the CPipeStyle1 class.
|
||
//
|
||
//////////////////////////////////////////////////////////////////////
|
||
|
||
#include "stdafx.h"
|
||
|
||
#include "PipeStyle1.h"
|
||
#include "math.h"
|
||
#include "geassign.h"
|
||
#include "PipeTools.h"
|
||
#include "GlobalFunction.h"
|
||
|
||
#ifdef _DEBUG
|
||
#undef THIS_FILE
|
||
static char THIS_FILE[]=__FILE__;
|
||
#define new DEBUG_NEW
|
||
#endif
|
||
|
||
#define _PI 3.14159265358979323846
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Construction/Destruction
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 默认构造函数
|
||
CPipeStyle1::CPipeStyle1()
|
||
{
|
||
m_rectStartPt[X] = 0;
|
||
m_rectStartPt[Y] = 0;
|
||
m_rectStartPt[Z] = 0;
|
||
m_rectEndPt[X] = 0;
|
||
m_rectEndPt[Y] = 0;
|
||
m_rectEndPt[Z] = 0;
|
||
|
||
m_nDist = 0;
|
||
m_iLeftDist = 0; // 四边间距
|
||
m_iTopDist = 0;
|
||
m_iRightDist = 0;
|
||
m_iBottomDist = 0;
|
||
|
||
m_dbPGAng = 0.0;
|
||
m_nEntryType = 0;
|
||
m_dbArcRadius = 0.0; // 圆弧半径
|
||
m_dCentRadius = 0.0;
|
||
|
||
m_nColorInd = 4; // 颜色,sg add
|
||
m_bWeight = FALSE; // 是否加粗
|
||
m_bIsHorz = FALSE;
|
||
m_dLineWeight = 0.35; // 线宽
|
||
m_dDistToWall = 100.0; // 距墙距离
|
||
|
||
InitVirtaulRect(); // sg modify
|
||
}
|
||
|
||
// 统一间距
|
||
CPipeStyle1::CPipeStyle1(XPoint rectStartPt, XPoint rectEndPt, int nDist,
|
||
double dbPGAng, int nEntryType, double dDist,
|
||
double dRadius, BOOL bWeight, double dLineWeight,
|
||
int nColorIndex)
|
||
{
|
||
ads_point_set(rectStartPt, m_rectStartPt);
|
||
ads_point_set(rectEndPt, m_rectEndPt);
|
||
|
||
m_nDist = nDist;
|
||
m_iLeftDist = nDist; // 四边间距
|
||
m_iTopDist = nDist;
|
||
m_iRightDist = nDist;
|
||
m_iBottomDist = nDist;
|
||
|
||
m_dbPGAng = dbPGAng;
|
||
m_nEntryType = nEntryType;
|
||
m_dbArcRadius = dRadius; // 圆弧半径
|
||
m_dCentRadius = dRadius;
|
||
|
||
m_nColorInd = nColorIndex; // 颜色,sg add
|
||
m_bWeight = bWeight; // 是否加粗
|
||
m_dLineWeight = dLineWeight; // 线宽
|
||
m_dDistToWall = dDist; // 距墙距离
|
||
m_bIsHorz = FALSE;
|
||
|
||
InitVirtaulRect();
|
||
}
|
||
|
||
// 不统一间距
|
||
CPipeStyle1::CPipeStyle1(XPoint rectStartPt, XPoint rectEndPt, XPoint pipePickEntry, BOOL bSameDist, int nLeftDist,
|
||
int nRightDist, int nTopDist, int nBottomDist, double dbPGAng, int nEntryType, double dDist,
|
||
double dRadius, double dBorderLeftWidth, double dBorderRightWidth, double dBorderUpWidth,
|
||
double dBorderDownWidth, double dBorderLeftDist, double dBorderRightDist, double dBorderUpDist,
|
||
double dBorderDownDist, BOOL bWeight, double dLineWeight, int nColorIndex)
|
||
{
|
||
ads_point_set(rectStartPt, m_rectStartPt);
|
||
ads_point_set(rectEndPt, m_rectEndPt);
|
||
|
||
m_nDist = nLeftDist;
|
||
m_iLeftDistT = nLeftDist; // 四边间距
|
||
m_iTopDistT = nTopDist;
|
||
m_iRightDistT = nRightDist;
|
||
m_iBottomDistT = nBottomDist;
|
||
|
||
m_dbPGAng = dbPGAng;
|
||
m_nEntryType = nEntryType;
|
||
m_dbArcRadius = dRadius; // 圆弧半径
|
||
m_dCentRadius = dRadius;
|
||
|
||
m_nColorInd = nColorIndex; // 颜色,sg add
|
||
m_bWeight = bWeight; // 是否加粗
|
||
m_dLineWeight = dLineWeight; // 线宽
|
||
m_dDistToWall = dDist; // 距墙距离
|
||
m_bIsHorz = FALSE;
|
||
|
||
// add by myy 2014-11-12
|
||
m_dBorderLeftWidthT = dBorderLeftWidth;
|
||
m_dBorderRightWidthT = dBorderRightWidth;
|
||
m_dBorderUpWidthT = dBorderUpWidth;
|
||
m_dBorderDownWidthT = dBorderDownWidth;
|
||
|
||
if( bSameDist )
|
||
{
|
||
m_dBorderLeftDistT = nLeftDist;
|
||
m_dBorderRightDistT = nLeftDist;
|
||
m_dBorderUpDistT = nLeftDist;
|
||
m_dBorderDownDistT = nLeftDist;
|
||
|
||
m_iLeftDistT = nLeftDist; // 四边间距
|
||
m_iTopDistT = nLeftDist;
|
||
m_iRightDistT = nLeftDist;
|
||
m_iBottomDistT = nLeftDist;
|
||
}
|
||
else
|
||
{
|
||
m_dBorderLeftDistT = dBorderLeftDist;
|
||
m_dBorderRightDistT = dBorderRightDist;
|
||
m_dBorderUpDistT = dBorderUpDist;
|
||
m_dBorderDownDistT = dBorderDownDist;
|
||
}
|
||
|
||
m_ptPickEntry = pipePickEntry;
|
||
m_bDefaultEntry = FALSE;
|
||
m_bSameDist = bSameDist;
|
||
// add end
|
||
|
||
InitVirtaulRect();
|
||
|
||
ReAllocateDist(); // add by cq
|
||
}
|
||
|
||
// 初始化矩形中的数据,用于构造函数
|
||
void CPipeStyle1::InitVirtaulRect()
|
||
{
|
||
m_pCenLine = NULL;
|
||
m_nNum = 0; // 一边的盘管数(n)
|
||
m_dbCenDist = 0.0; // 中心线间距
|
||
|
||
m_dbDiagAng = 0.0; // 对角线与矩形夹角的锐角
|
||
m_dbDiagDist = 0.0; // 对角线长度
|
||
m_dbShortDist = 0.0; // 矩形短边长度
|
||
m_dbLongDist = 0.0; // 矩形长边长度
|
||
m_dbAssisAng = 0.0;
|
||
m_dbNormAng = 0.0;
|
||
m_iLeftNum = m_iRightNum = m_iTopNum = m_iBottomNum = 0;
|
||
m_iDrawInterL = m_iDrawInterR = m_iDrawInterB = m_iDrawInterT = 0;
|
||
}
|
||
|
||
CPipeStyle1::~CPipeStyle1()
|
||
{
|
||
int i(0); // sg modify
|
||
for (i = 0; i < m_LineArrAp.GetSize(); i++)
|
||
{
|
||
if (m_LineArrAp[i] != NULL)
|
||
{
|
||
delete m_LineArrAp[i];
|
||
}
|
||
}
|
||
m_LineArrAp.RemoveAll();
|
||
|
||
for (i = 0; i < m_LineArr1.GetSize(); i++)
|
||
{
|
||
if (m_LineArr1[i] != NULL)
|
||
{
|
||
delete m_LineArr1[i];
|
||
}
|
||
}
|
||
m_LineArr1.RemoveAll();
|
||
|
||
for (i = 0; i < m_LineArr2.GetSize(); i++)
|
||
{
|
||
if (m_LineArr2[i] != NULL)
|
||
{
|
||
delete m_LineArr2[i];
|
||
}
|
||
}
|
||
m_LineArr2.RemoveAll();
|
||
|
||
for (i = 0; i < m_LineArr3.GetSize(); i++)
|
||
{
|
||
if(m_LineArr3[i] != NULL)
|
||
{
|
||
delete m_LineArr3[i];
|
||
}
|
||
}
|
||
m_LineArr3.RemoveAll();
|
||
|
||
for (i = 0; i < m_LineArr4.GetSize(); i++)
|
||
{
|
||
if(m_LineArr4[i] != NULL)
|
||
{
|
||
delete m_LineArr4[i];
|
||
}
|
||
}
|
||
m_LineArr4.RemoveAll();
|
||
|
||
if (m_pCenLine != NULL)
|
||
{
|
||
delete m_pCenLine;
|
||
m_pCenLine = NULL;
|
||
}
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// Set、Get函数
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 设置起点
|
||
void CPipeStyle1::SetStartPt(ads_point rectStartPt)
|
||
{
|
||
ads_point_set(rectStartPt, m_rectStartPt);
|
||
}
|
||
|
||
// 设置间距,未使用
|
||
void CPipeStyle1::SetDist(int nDist)
|
||
{
|
||
m_nDist = nDist;
|
||
m_iLeftDist = nDist; // 四边间距
|
||
m_iTopDist = nDist;
|
||
m_iRightDist = nDist;
|
||
m_iBottomDist = nDist;
|
||
}
|
||
|
||
// 设置盘管角度
|
||
void CPipeStyle1::SetPGAng(double dbPGAng)
|
||
{
|
||
m_dbPGAng = dbPGAng;
|
||
}
|
||
|
||
// 设置出口方向
|
||
void CPipeStyle1::SetEntryType(int nEntryType)
|
||
{
|
||
m_nEntryType = nEntryType;
|
||
}
|
||
|
||
// 设置曲率半径
|
||
void CPipeStyle1::SetArcRadius(double dRadius)
|
||
{
|
||
m_dbArcRadius = dRadius;
|
||
}
|
||
|
||
// 设置是否加粗显示
|
||
void CPipeStyle1::SetWeightShow(BOOL bWeight)
|
||
{
|
||
m_bWeight = bWeight;
|
||
}
|
||
|
||
// 设置线宽
|
||
void CPipeStyle1::SetLineWeight(double dLineWeight)
|
||
{
|
||
m_dLineWeight = dLineWeight;
|
||
}
|
||
|
||
// 设置距墙距离
|
||
void CPipeStyle1::SetDistToWall(double dDist)
|
||
{
|
||
m_dDistToWall = dDist;
|
||
}
|
||
|
||
// 获取中心部分间距,用于倒角
|
||
double CPipeStyle1::GetCenterDist()
|
||
{
|
||
if (m_nNum == 1)
|
||
{
|
||
return (m_dbShortDist - 2*m_dDistToWall)/2;
|
||
}
|
||
else
|
||
{
|
||
return m_dbCenDist;
|
||
}
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 构造虚拟矩形的函数
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 将矩形转换为躺倒的矩形
|
||
void CPipeStyle1::NormalizeRect()
|
||
{
|
||
double dbDist12 = acutDistance(m_ptLB, m_ptLT), // 1、2点间距离
|
||
dbDist14 = acutDistance(m_ptLB, m_ptRB); // 1、4点间距离
|
||
if (dbDist12 <= dbDist14)
|
||
{
|
||
return;
|
||
}
|
||
|
||
m_dbDiagAng = 0.5*_PI - m_dbDiagAng;
|
||
GetVirtaulRect();
|
||
|
||
m_nEntryType += 2; // 调整出口方向
|
||
if (m_nEntryType == 9)
|
||
{
|
||
m_nEntryType = 1;
|
||
}
|
||
else if (m_nEntryType == 10)
|
||
{
|
||
m_nEntryType = 2;
|
||
}
|
||
m_dbNormAng = 0.5*_PI;
|
||
}
|
||
|
||
// 矩形的中心点m_CenterPt
|
||
void CPipeStyle1::GetCenterPt()
|
||
{
|
||
m_CenterPt[X] = (m_rectStartPt[X]+m_rectEndPt[X])/2;
|
||
m_CenterPt[Y] = (m_rectStartPt[Y]+m_rectEndPt[Y])/2;
|
||
m_CenterPt[Z] = (m_rectStartPt[Z]+m_rectEndPt[Z])/2;
|
||
}
|
||
|
||
// 得到对角线的锐角m_dbDiagAng
|
||
void CPipeStyle1::GetDiagAng()
|
||
{
|
||
m_dbDiagAng = acutAngle(m_rectStartPt, m_CenterPt) - m_dbPGAng;
|
||
m_dbDiagAng = AngleRangeTo2PI(m_dbDiagAng);
|
||
|
||
if (m_dbDiagAng >= 0.5*_PI && m_dbDiagAng <_PI)
|
||
{
|
||
m_dbDiagAng = _PI - m_dbDiagAng;
|
||
}
|
||
else if (m_dbDiagAng >= _PI && m_dbDiagAng < 1.5*_PI)
|
||
{
|
||
m_dbDiagAng = m_dbDiagAng - _PI;
|
||
}
|
||
else if (m_dbDiagAng >= 1.5*_PI && m_dbDiagAng < 2*_PI)
|
||
{
|
||
m_dbDiagAng = 2*_PI - m_dbDiagAng;
|
||
}
|
||
}
|
||
|
||
// 得到矩形边长m_dbDiagDist、m_dbShortDist、m_dbLongDist
|
||
void CPipeStyle1::GetLengthofSide()
|
||
{
|
||
m_dbDiagDist = acutDistance(m_rectStartPt, m_rectEndPt); // 对角线长度
|
||
|
||
double dbDist12 = fabs(m_dbDiagDist*sin(m_dbDiagAng)), // 1、2点间距离
|
||
dbDist14 = fabs(m_dbDiagDist*cos(m_dbDiagAng)); // 1、4点间距离
|
||
m_dbShortDist = min(dbDist12, dbDist14); // 短边
|
||
m_dbLongDist = max(dbDist12, dbDist14); // 长边
|
||
}
|
||
|
||
// 虚拟矩形的四个顶点m_ptLB、m_ptLT、m_ptRT、m_ptRB
|
||
void CPipeStyle1::GetVirtaulRect()
|
||
{
|
||
acutPolar(m_CenterPt, _PI+m_dbDiagAng, m_dbDiagDist/2, m_ptLB);
|
||
acutPolar(m_CenterPt, _PI-m_dbDiagAng, m_dbDiagDist/2, m_ptLT);
|
||
acutPolar(m_CenterPt, m_dbDiagAng, m_dbDiagDist/2, m_ptRT);
|
||
acutPolar(m_CenterPt, -m_dbDiagAng, m_dbDiagDist/2, m_ptRB);
|
||
}
|
||
|
||
// 将虚拟点转换到真实坐标
|
||
void CPipeStyle1::TransToActualPt(ads_point point, ads_point retPt)
|
||
{
|
||
double dbDist = acutDistance(m_CenterPt, point),
|
||
dAng = acutAngle(m_CenterPt, point);
|
||
acutPolar(m_CenterPt, m_dbPGAng+dAng+m_dbNormAng, dbDist, retPt);
|
||
}
|
||
|
||
// 将真实坐标转换到虚拟点
|
||
void CPipeStyle1::TransToVirtualPt(ads_point point, ads_point retPt)
|
||
{
|
||
double dbDist = acutDistance(m_CenterPt, point),
|
||
dAng = acutAngle(m_CenterPt, point);
|
||
acutPolar(m_CenterPt, dAng-m_dbPGAng-m_dbNormAng, dbDist, retPt);
|
||
}
|
||
|
||
// 根据出口方向不同,获取左右、上下边长度
|
||
// dDistLR:左右长度;dDistTB:上下长度;bDelToWall:制是否自动去掉距墙距离
|
||
void CPipeStyle1::GetLengthofLRandTBSide(double &dDistLR, double &dDistTB,
|
||
BOOL bDelToWall)
|
||
{
|
||
double dbDist12 = acutDistance(m_ptLB, m_ptLT), // 1、2点间距离,上下
|
||
dbDist14 = acutDistance(m_ptLB, m_ptRB); // 1、4点间距离,左右
|
||
if ((2 == m_nEntryType) || (3 == m_nEntryType) || (6 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
dDistLR = dbDist12;
|
||
dDistTB = dbDist14;
|
||
}
|
||
else
|
||
{
|
||
dDistLR = dbDist14;
|
||
dDistTB = dbDist12;
|
||
}
|
||
|
||
if (bDelToWall) // 是否自动去掉距墙距离
|
||
{
|
||
dDistLR -= m_dDistToWall*2;
|
||
dDistTB -= m_dDistToWall*2;
|
||
}
|
||
}
|
||
|
||
// 计算盘管左侧的线条数量及中心线长度
|
||
void CPipeStyle1::CalcLeftLines()
|
||
{
|
||
// add by hh 2013-1-15 降低计算精度 避免出现盘管中心位置间隙过大的问题
|
||
static double dPrec = 1e-3;
|
||
|
||
// 计算左侧线条数量
|
||
double dDistHorz, dDistVert;
|
||
GetLengthofLRandTBSide(dDistHorz, dDistVert);
|
||
|
||
int iLeftNum = m_iLeftNum,
|
||
iRightNum = m_iRightNum,
|
||
iTopNum = m_iTopNum,
|
||
iBottomNum = m_iTopNum; // 实际上边界区绘制的圈数
|
||
// modify begin
|
||
// int iLeftSrc = 1;
|
||
// double dVertDist = dDistVert - 2 * m_iTopDist;
|
||
// while(1)
|
||
// {
|
||
// dVertDist -= (m_iTopDist + m_iBottomDist);
|
||
// if(1e-6 >= dVertDist)
|
||
// break;
|
||
// iLeftSrc++;
|
||
// }
|
||
// iLeftSrc += 2;
|
||
int iLeftSrc = 1;
|
||
double dTopDist, dBottomDist;
|
||
dTopDist = ((iTopNum>0 && iTopNum--)?m_dBorderUpDist:m_iTopDist);
|
||
double dVertDist = dDistVert - dTopDist;
|
||
dTopDist = ((iTopNum>0 && iTopNum--)?m_dBorderUpDist:m_iTopDist);
|
||
dVertDist -= dTopDist;
|
||
for(;;)
|
||
{
|
||
dTopDist = ((iTopNum>0 && iTopNum--)?m_dBorderUpDist:m_iTopDist);
|
||
dBottomDist = ((iBottomNum>0 && iBottomNum--)?m_dBorderDownDist:m_iBottomDist);
|
||
|
||
dVertDist -= (dTopDist + dBottomDist);
|
||
if(1e-6 >= dVertDist)
|
||
break;
|
||
++iLeftSrc;
|
||
}
|
||
iLeftSrc += 2;
|
||
// modify end by cq 2015-4-3 17:04:10 增加边界区
|
||
|
||
// 确定中心线方向及长度
|
||
// double iMinHorz = min(m_iLeftDist, m_iRightDist);
|
||
// double iMinVert = min(m_iTopDist, m_iBottomDist);
|
||
//. double dCentDist = 0;
|
||
double dLeftDist = (iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
double dRightDist = (iRightNum>0?m_dBorderRightDist:m_iRightDist);
|
||
dTopDist = (iTopNum>0?m_dBorderUpDist:m_iTopDist);
|
||
dBottomDist = (iBottomNum>0?m_dBorderDownDist:m_iBottomDist);
|
||
double iMinHorz = min(dLeftDist, dRightDist);
|
||
double iMinVert = min(dTopDist, dBottomDist);
|
||
double dCentDist = 0;
|
||
// modify end by cq 2015-4-3 17:04:10 增加边界区
|
||
|
||
// 横向中心线
|
||
// int iLeftHorz = iLeftSrc;
|
||
// do{
|
||
// //dCentDist = dDistHorz - (iLeftHorz - 1) * m_iLeftDist
|
||
// // - (iLeftHorz - 2) * m_iRightDist;
|
||
// // 中心线折半(见下)计算时,可能会出现少计算一圈的情况,
|
||
// // 不折半时(见上),部分情况绘制的图形不够美观。
|
||
// dCentDist = (dDistHorz - (iLeftHorz - 1) * m_iLeftDist
|
||
// - (iLeftHorz - 2) * m_iRightDist) / 2;
|
||
// iLeftHorz--;
|
||
// } while (-dPrec > (dCentDist - iMinHorz));
|
||
// // } while (dCentDist < iMinHorz);
|
||
// iLeftHorz++;
|
||
double dDistTempL, dDistTempR;
|
||
int iLeftHorz = iLeftSrc;
|
||
do{
|
||
if( m_iLeftNum > iLeftHorz-2 ){
|
||
dLeftDist = m_dBorderLeftDist;
|
||
dDistTempL = (iLeftHorz-1) * m_dBorderLeftDist;
|
||
}else{
|
||
dLeftDist = m_iLeftDist;
|
||
dDistTempL = m_iLeftNum*m_dBorderLeftDist + (iLeftHorz-1-m_iLeftNum)*m_iLeftDist;
|
||
}
|
||
|
||
if( m_iRightNum > iLeftHorz-3 ){
|
||
dRightDist = m_dBorderRightDist;
|
||
dDistTempR = (iLeftHorz-2) * m_dBorderRightDist;
|
||
}else{
|
||
dRightDist = m_iRightDist;
|
||
dDistTempR = m_iRightNum*m_dBorderRightDist + (iLeftHorz-2-m_iRightNum)*m_iRightDist;
|
||
}
|
||
dCentDist = (dDistHorz-dDistTempL-dDistTempR)/2;
|
||
iLeftHorz--;
|
||
iMinHorz = min(dLeftDist, dRightDist);
|
||
} while (-dPrec > (dCentDist - iMinHorz));
|
||
iLeftHorz++;
|
||
int iLeftVert = iLeftHorz;
|
||
// modify end by cq 2015-4-3 17:04:10 增加边界区
|
||
|
||
// int iTopHorz = iLeftHorz - 1;
|
||
// do{
|
||
// dCentDist = (dDistVert - (iTopHorz - 1) * m_iTopDist
|
||
// - (iTopHorz - 2) * m_iBottomDist) / 2;
|
||
// iTopHorz--;
|
||
// } while(-dPrec > (dCentDist - iMinVert));
|
||
// // } while(dCentDist < iMinVert);
|
||
// iTopHorz++;
|
||
// iLeftHorz = iTopHorz + 1;
|
||
double dDistTempT, dDistTempB;
|
||
int iTopHorz = iLeftHorz - 1;
|
||
do{
|
||
if( m_iTopNum > iTopHorz-2 ){
|
||
dTopDist = m_dBorderUpDist;
|
||
dDistTempT = (iTopHorz-1) * m_dBorderUpDist;
|
||
}else{
|
||
dTopDist = m_iTopDist;
|
||
dDistTempT = m_iTopNum*m_dBorderUpDist + (iTopHorz-1-m_iTopNum)*m_iTopDist;
|
||
}
|
||
|
||
if( m_iBottomNum > iTopHorz-3 ){
|
||
dBottomDist = m_dBorderDownDist;
|
||
dDistTempB = (iTopHorz-2) * m_dBorderDownDist;
|
||
}else{
|
||
dBottomDist = m_iBottomDist;
|
||
dDistTempB = m_iBottomNum*m_dBorderDownDist + (iTopHorz-2-m_iBottomNum)*m_iBottomDist;
|
||
}
|
||
dCentDist = (dDistVert-dDistTempT-dDistTempB)/2;
|
||
iTopHorz--;
|
||
iMinVert = min(dTopDist, dBottomDist);
|
||
} while(-dPrec > (dCentDist - iMinVert));
|
||
iTopHorz++;
|
||
iLeftHorz = iTopHorz + 1;
|
||
// modify end by cq 2015-4-3 17:04:10 增加边界区
|
||
|
||
// 纵向中心线
|
||
// int iLeftVert = iLeftSrc;
|
||
// do{
|
||
// dCentDist = (dDistHorz - (iLeftVert - 1) * m_iLeftDist
|
||
// - (iLeftVert - 2) * m_iRightDist) / 2;
|
||
// iLeftVert--;
|
||
// } while (-dPrec > (dCentDist - iMinHorz));
|
||
// // } while (dCentDist < iMinHorz);
|
||
// iLeftVert++;
|
||
iLeftVert = iLeftSrc;
|
||
do{
|
||
if( m_iLeftNum > iLeftVert-2 ){
|
||
dLeftDist = m_dBorderLeftDist;
|
||
dDistTempL = (iLeftVert-1) * m_dBorderLeftDist;
|
||
}else{
|
||
dLeftDist = m_iLeftDist;
|
||
dDistTempL = m_iLeftNum*m_dBorderLeftDist + (iLeftVert-1-m_iLeftNum)*m_iLeftDist;
|
||
}
|
||
|
||
if( m_iRightNum > iLeftVert-3 ){
|
||
dRightDist = m_dBorderRightDist;
|
||
dDistTempR = (iLeftVert-2) * m_dBorderRightDist;
|
||
}else{
|
||
dRightDist = m_iRightDist;
|
||
dDistTempR = m_iRightNum*m_dBorderRightDist + (iLeftVert-2-m_iRightNum)*m_iRightDist;
|
||
}
|
||
dCentDist = (dDistHorz-dDistTempL-dDistTempR)/2;
|
||
iLeftVert--;
|
||
iMinHorz = min(dLeftDist, dRightDist);
|
||
} while (-dPrec > (dCentDist - iMinHorz));
|
||
iLeftVert++;
|
||
// modify end by cq 2015-4-3 17:04:10 增加边界区
|
||
|
||
// int iTopVert = iLeftVert;
|
||
// do{
|
||
// //dCentDist = dDistVert - (iTopVert - 1) * m_iTopDist
|
||
// // - (iTopVert - 2) * m_iBottomDist;
|
||
// dCentDist = (dDistVert - (iTopVert - 1) * m_iTopDist
|
||
// - (iTopVert - 2) * m_iBottomDist) / 2;
|
||
// iTopVert--;
|
||
// } while(-dPrec > (dCentDist - iMinVert));
|
||
// // } while(dCentDist < iMinVert);
|
||
// iTopVert++;
|
||
// iLeftVert = iTopVert;
|
||
int iTopVert = iLeftVert;
|
||
do{
|
||
if( m_iTopNum > iTopVert-2 ){
|
||
dTopDist = m_dBorderUpDist;
|
||
dDistTempT = (iTopVert-1) * m_dBorderUpDist;
|
||
}else{
|
||
dTopDist = m_iTopDist;
|
||
dDistTempT = m_iTopNum*m_dBorderUpDist + (iTopVert-1-m_iTopNum)*m_iTopDist;
|
||
}
|
||
|
||
if( m_iBottomNum > iTopVert-3 ){
|
||
dBottomDist = m_dBorderDownDist;
|
||
dDistTempB = (iTopVert-2) * m_dBorderDownDist;
|
||
}else{
|
||
dBottomDist = m_iBottomDist;
|
||
dDistTempB = m_iBottomNum*m_dBorderDownDist + (iTopVert-2-m_iBottomNum)*m_iBottomDist;
|
||
}
|
||
dCentDist = (dDistVert-dDistTempT-dDistTempB)/2;
|
||
iTopVert--;
|
||
iMinVert = min(dTopDist, dBottomDist);
|
||
} while(-dPrec > (dCentDist - iMinVert));
|
||
iTopVert++;
|
||
iLeftVert = iTopVert;
|
||
// modify end by cq 2015-4-3 17:04:10 增加边界区
|
||
|
||
m_nNum = max(iLeftHorz, iLeftVert); // 左侧线条数量
|
||
m_bIsHorz = (m_nNum != max(iTopHorz, iTopVert)); // 中心线方向
|
||
|
||
// 中心线长度
|
||
double dCent1 = 0, dCent2 = 0;
|
||
|
||
if(1 >= m_nNum)
|
||
{
|
||
dCent1 = dDistHorz / 2;
|
||
dCent2 = dDistVert / 2;
|
||
}
|
||
// else
|
||
// {
|
||
// dCent1 = (dDistHorz - (m_nNum - 1) * m_iLeftDist
|
||
// - (m_nNum - 2) * m_iRightDist) / 2;
|
||
//
|
||
// if(!m_bIsHorz)
|
||
// dCent2 = (dDistVert - (m_nNum - 1) * m_iTopDist
|
||
// - (m_nNum - 2) * m_iBottomDist) / 2;
|
||
// else
|
||
// dCent2 = (dDistVert - (m_nNum - 2) * m_iTopDist
|
||
// - (m_nNum - 3) * m_iBottomDist) / 2;
|
||
// }
|
||
else
|
||
{
|
||
if( m_iLeftNum > m_nNum-2 ){
|
||
dDistTempL = (m_nNum-1) * m_dBorderLeftDist;
|
||
}else{
|
||
dDistTempL = m_iLeftNum*m_dBorderLeftDist + (m_nNum-1-m_iLeftNum)*m_iLeftDist;
|
||
}
|
||
if( m_iRightNum > m_nNum-3 ){
|
||
dDistTempR = (m_nNum-2) * m_dBorderRightDist;
|
||
}else{
|
||
dDistTempR = m_iRightNum*m_dBorderRightDist + (m_nNum-2-m_iRightNum)*m_iRightDist;
|
||
}
|
||
dCent1 = (dDistHorz-dDistTempL-dDistTempR)/2;
|
||
|
||
if(!m_bIsHorz)
|
||
{
|
||
if( m_iTopNum > m_nNum-2 ){
|
||
dDistTempT = (m_nNum-1) * m_dBorderUpDist;
|
||
}else{
|
||
dDistTempT = m_iTopNum*m_dBorderUpDist + (m_nNum-1-m_iTopNum)*m_iTopDist;
|
||
}
|
||
if( m_iBottomNum > m_nNum-3 ){
|
||
dDistTempB = (m_nNum-2) * m_dBorderDownDist;
|
||
}else{
|
||
dDistTempB = m_iBottomNum*m_dBorderDownDist + (m_nNum-2-m_iBottomNum)*m_iBottomDist;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if( m_iTopNum > m_nNum-3 ){
|
||
dDistTempT = (m_nNum-2) * m_dBorderUpDist;
|
||
}else{
|
||
dDistTempT = m_iTopNum*m_dBorderUpDist + (m_nNum-2-m_iTopNum)*m_iTopDist;
|
||
}
|
||
if( m_iBottomNum > m_nNum-4 ){
|
||
dDistTempB = (m_nNum-3) * m_dBorderDownDist;
|
||
}else{
|
||
dDistTempB = m_iBottomNum*m_dBorderDownDist + (m_nNum-3-m_iBottomNum)*m_iBottomDist;
|
||
}
|
||
}
|
||
dCent2 = (dDistVert-dDistTempT-dDistTempB)/2;
|
||
}
|
||
// modify end by cq 2015-4-3 17:04:10 增加边界区
|
||
|
||
if(m_bIsHorz)
|
||
m_dbCenDist = dCent2;
|
||
else
|
||
m_dbCenDist = dCent1;
|
||
|
||
// 计算中心线圆弧曲率
|
||
if(1e-6 < fabs(m_dbArcRadius))
|
||
{
|
||
m_dCentRadius = min(dCent1, dCent2) / 2.0;
|
||
|
||
if(m_dCentRadius > m_dbArcRadius)
|
||
{
|
||
m_dCentRadius = m_dbArcRadius;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 修正直线长度(负数修正为0,正数不作处理)
|
||
inline void CPipeStyle1::ReviseLen(double& dLen)
|
||
{
|
||
if(1e-5 >= dLen)
|
||
{
|
||
dLen = 0;
|
||
}
|
||
}
|
||
|
||
// 计算每一圈管线实际的曲率半径 iLineIndex 从0开始 0 代表最外圈,bShortSide = TRUE时取得短边曲率 FALSE取得长边曲率
|
||
double CPipeStyle1::GetFilletRadius(int iLineIndex, BOOL bShortSide)
|
||
{
|
||
if(1e-6 > m_dbArcRadius)
|
||
return 0;
|
||
|
||
double dRadius, dDistHorz, dDistVert;
|
||
GetLengthofLRandTBSide(dDistHorz, dDistVert);
|
||
|
||
if(0 > iLineIndex)
|
||
iLineIndex = 0;
|
||
|
||
if(m_bIsHorz)
|
||
{
|
||
if(1 == m_nNum)
|
||
dRadius = m_dCentRadius;//dDistVert / 2;
|
||
else
|
||
{
|
||
double dTopLen, dBottomLen;
|
||
if( m_iTopNum > iLineIndex-1 )
|
||
dTopLen = iLineIndex * m_dBorderUpDist;
|
||
else
|
||
dTopLen = m_iTopNum*m_dBorderUpDist + (iLineIndex-m_iTopNum)*m_iTopDist;
|
||
if(bShortSide || 1 >= iLineIndex)
|
||
{
|
||
if( m_iBottomNum > iLineIndex-1 )
|
||
dBottomLen = iLineIndex * m_dBorderDownDist;
|
||
else
|
||
dBottomLen = m_iBottomNum*m_dBorderDownDist + (iLineIndex-m_iBottomNum)*m_iBottomDist;
|
||
//dRadius = (dDistVert - iLineIndex * (m_iTopDist + m_iBottomDist)) / 2;
|
||
}
|
||
else
|
||
{
|
||
if( m_iBottomNum > iLineIndex-3 )
|
||
dBottomLen = (iLineIndex - 2) * m_dBorderDownDist;
|
||
else
|
||
dBottomLen = m_iBottomNum*m_dBorderDownDist + (iLineIndex-2-m_iBottomNum)*m_iBottomDist;
|
||
//dRadius = (dDistVert - iLineIndex * m_iTopDist - (iLineIndex - 2) * m_iBottomDist) / 2;
|
||
}
|
||
dRadius = (dDistVert - dTopLen - dBottomLen) / 2;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if(1 == m_nNum)
|
||
dRadius = m_dCentRadius;//dDistHorz / 2;
|
||
else
|
||
{
|
||
double dLeftLen, dRightLen;
|
||
if( m_iLeftNum > iLineIndex-1 )
|
||
dLeftLen = iLineIndex * m_dBorderLeftDist;
|
||
else
|
||
dLeftLen = m_iLeftNum*m_dBorderLeftDist + (iLineIndex-m_iLeftNum)*m_iLeftDist;
|
||
if(bShortSide || 1 >= iLineIndex)
|
||
{
|
||
if( m_iRightNum > iLineIndex-1 )
|
||
dRightLen = iLineIndex * m_dBorderRightDist;
|
||
else
|
||
dRightLen = m_iRightNum*m_dBorderRightDist + (iLineIndex-m_iRightNum)*m_iRightDist;
|
||
//dRadius = (dDistHorz - iLineIndex * (m_iLeftDist + m_iRightDist)) / 2;
|
||
}
|
||
else
|
||
{
|
||
if( m_iRightNum > iLineIndex-1 )
|
||
dRightLen = iLineIndex * m_dBorderRightDist;
|
||
else
|
||
dRightLen = m_iRightNum*m_dBorderRightDist + (iLineIndex-m_iRightNum)*m_iRightDist;
|
||
//dRadius = (dDistHorz - iLineIndex * m_iLeftDist - (iLineIndex - 2) * m_iRightDist) / 2;
|
||
}
|
||
dRadius = (dDistVert - dLeftLen - dRightLen) / 2;
|
||
}
|
||
}
|
||
if(dRadius > m_dbArcRadius || dRadius < 1e-6)
|
||
{
|
||
dRadius = m_dbArcRadius;
|
||
}
|
||
|
||
return dRadius;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 主函数
|
||
//////////////////////////////////////////////////////////////////////
|
||
// TDbFloorPipe::ExplodeOrDraw2d中调用的绘制函数
|
||
bool CPipeStyle1::DrawPGLine(XExplodeDraw &dc, AcDbObjectId idRetLayer/* = AcDbObjectId::kNull*/)
|
||
{
|
||
// 1、对输入数据的合理性进行检查
|
||
if (abs(m_nDist) <= 0)
|
||
{
|
||
acutPrintf(_T("\n间距错误"));
|
||
return false;
|
||
}
|
||
if (m_nEntryType < 1 || m_nEntryType > 8)
|
||
{
|
||
acutPrintf(_T("\n入口类型错误"));
|
||
return false;
|
||
}
|
||
// 2、构造一个虚拟的外包“矩形”
|
||
GetCenterPt(); // 得到中心点m_CenterPt
|
||
GetDiagAng(); // 得到对角线锐角m_dbDiagAng
|
||
// 得到矩形边长m_dbDiagDist、m_dbShortDist、m_dbLongDist
|
||
GetLengthofSide();
|
||
// 虚拟矩形的四个顶点m_ptLB、m_ptLT、m_ptRT、m_ptRB
|
||
GetVirtaulRect();
|
||
|
||
NormalizeRect(); // 3、把虚拟矩形放倒
|
||
|
||
double nDistLR(0), // 左右长度
|
||
nDistTB(0); // 上下长度
|
||
GetLengthofLRandTBSide(nDistLR, nDistTB); // 4、得到左右、上下长度
|
||
|
||
// 5、计算盘管总共几排,初算m_nNum
|
||
double nBigLR = max(m_iLeftDist, m_iRightDist), // 得到左右、上下中较大的间距
|
||
nBigTB = max(m_iTopDist, m_iBottomDist);
|
||
double nBig = max(nBigLR, nBigTB); // 得到所有间距中最大值
|
||
|
||
// int nNum1 = (int)(nDistLR / (m_iLeftDist + m_iRightDist) * 2),
|
||
// nNum2 = (int)(nDistTB / (m_iTopDist + m_iBottomDist) * 2),
|
||
// nNum = min(nNum1, nNum2); // 较小值(大致能分几个区域)
|
||
double dLeftDist = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
double dRightDist = (m_iRightNum>0?m_dBorderRightDist:m_iRightDist);
|
||
double dTopDist = (m_iTopNum>0?m_dBorderUpDist:m_iTopDist);
|
||
double dBottomDist = (m_iBottomNum>0?m_dBorderDownDist:m_iBottomDist);
|
||
int nNum1 = (int)(nDistLR / (dLeftDist + dRightDist) * 2),
|
||
nNum2 = (int)(nDistTB / (dTopDist + dBottomDist) * 2),
|
||
nNum = min(nNum1, nNum2); // 较小值(大致能分几个区域)
|
||
|
||
// change by hh 2010-11-29
|
||
CalcLeftLines();
|
||
|
||
/*
|
||
m_nNum = int((nNum+1) / 2); // 每组“线”的数量
|
||
|
||
// 6、复算m_nNum,并计算中心长度m_dbCenDist
|
||
// m_dbCenDist、dbCenDist2为左右、上下2段长度, 但此时还不清楚究竟是哪一个
|
||
double dbCenDist2(0);
|
||
if (nNum == nNum1)
|
||
{
|
||
do
|
||
{
|
||
m_dbCenDist = (nDistLR - m_nNum*m_iLeftDist - (m_nNum-1)*m_iRightDist)/2;
|
||
dbCenDist2 = (nDistTB - (m_nNum-1)*m_iTopDist - (m_nNum-2)*m_iBottomDist)/2;
|
||
m_nNum--;
|
||
} // 中心长度不能小于间距, 不能小于2个半径
|
||
while ((m_dbCenDist*2 < nBigLR) || (m_dbCenDist*2 < 4*m_dbArcRadius)
|
||
|| (dbCenDist2*2 < 4*m_dbArcRadius));
|
||
m_nNum++; // 多执行了一次
|
||
|
||
double nDist1 = nDistLR - (m_nNum-1) * (m_iLeftDist+m_iRightDist),
|
||
nDist2 = nDistTB - (m_nNum-1) * (m_iTopDist+m_iBottomDist);
|
||
if (nDist1 > nDist2) // 注: 计算盘管中心是横管还是竖管, 中心长度要匹配
|
||
{
|
||
m_dbCenDist = dbCenDist2;
|
||
}
|
||
}
|
||
else if (nNum == nNum2)
|
||
{
|
||
do
|
||
{
|
||
m_dbCenDist = (nDistTB - (m_nNum-1)*m_iTopDist - (m_nNum-2)*m_iBottomDist)/2;
|
||
dbCenDist2 = (nDistLR - m_nNum*m_iLeftDist - (m_nNum-1)*m_iRightDist)/2;
|
||
m_nNum--;
|
||
}
|
||
while ((m_dbCenDist*2 < nBigTB) || (m_dbCenDist*2 < 4*m_dbArcRadius)
|
||
|| (dbCenDist2*2 < 4*m_dbArcRadius));
|
||
m_nNum++; // 多执行了一次
|
||
|
||
double nDist1 = nDistLR - (m_nNum-1) * (m_iLeftDist+m_iRightDist),
|
||
nDist2 = nDistTB - (m_nNum-1) * (m_iTopDist+m_iBottomDist);
|
||
if (nDist1 < nDist2)
|
||
{
|
||
m_dbCenDist = dbCenDist2;
|
||
}
|
||
}
|
||
*/
|
||
|
||
if (nNum < 3) // 7、初始化LINEARR数组
|
||
{
|
||
if (!DrawSingle()) // 画一圈
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!DrawMulti())
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
int i(0); // sg modify
|
||
AcDbObjectId idOrigLayer = dc.GetLayerId();
|
||
for (i = 0; i < m_LineArr1.GetSize(); i++) // 8、绘制左边所有管线
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
|
||
m_LineArr1[i]->DrawTheLine(dc, m_bWeight, m_nColorInd, m_dLineWeight);
|
||
}
|
||
for (i = 0; i < m_LineArrAp.GetSize(); i++)
|
||
{
|
||
if( i != 3 && idRetLayer.isValid() )
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
m_LineArrAp[i]->DrawTheLine(dc, m_bWeight, m_nColorInd, m_dLineWeight);
|
||
}
|
||
for (i = 0; i < m_LineArr2.GetSize(); i++) // 绘制上面所有管线
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
|
||
m_LineArr2[i]->DrawTheLine(dc, m_bWeight, m_nColorInd, m_dLineWeight);
|
||
}
|
||
for (i = 0; i < m_LineArr3.GetSize(); i++) // 绘制右边所有管线
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
|
||
m_LineArr3[i]->DrawTheLine(dc, m_bWeight, m_nColorInd, m_dLineWeight);
|
||
}
|
||
for (i = 0; i < m_LineArr4.GetSize(); i++) // 绘制下面所有管线
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
|
||
m_LineArr4[i]->DrawTheLine(dc, m_bWeight, m_nColorInd, m_dLineWeight);
|
||
}
|
||
|
||
if (m_pCenLine != NULL) // 9、绘制中间最后一段直线
|
||
{
|
||
if (idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
|
||
m_pCenLine->DrawTheLine(dc, m_bWeight, m_nColorInd, m_dLineWeight);
|
||
}
|
||
dc.SetLayer(idOrigLayer);
|
||
|
||
if (!CreateArcArr(dc, idRetLayer)) // 10、绘制管线连接出的弧线
|
||
{
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
bool CPipeStyle1::DrawSingle()
|
||
{
|
||
m_nNum = 1;
|
||
CreateLeftLineArr(1);
|
||
CreateTopLineArr();
|
||
CreateRightLineArr();
|
||
CreateBottomLineArr();
|
||
return true;
|
||
}
|
||
|
||
bool CPipeStyle1::DrawMulti()
|
||
{
|
||
double nBigLR = max(m_iLeftDist, m_iRightDist), // 得到左右、上下中较大的间距
|
||
nBigTB = max(m_iTopDist, m_iBottomDist);
|
||
|
||
double nDist(1);
|
||
if ((m_nEntryType == 2) || (m_nEntryType == 3) || (m_nEntryType == 6)
|
||
|| (m_nEntryType == 7))
|
||
{
|
||
nDist = nBigLR;
|
||
}
|
||
else
|
||
{
|
||
nDist = nBigTB;
|
||
}
|
||
|
||
double dbWidth(0);
|
||
if ((m_nEntryType == 1) || (m_nEntryType == 4) || (m_nEntryType == 5)
|
||
|| (m_nEntryType == 8))
|
||
{
|
||
dbWidth = m_dbLongDist - 2*m_dDistToWall - (2*m_nNum-1)*nDist - 2*m_dbArcRadius;
|
||
}
|
||
else
|
||
{
|
||
dbWidth = m_dbLongDist - (2*m_nNum-1)*nDist - 2*m_dbArcRadius;
|
||
}
|
||
|
||
if (fabs(dbWidth) < 0) // 注:不理解,为什么要判断绝对值是否小于0?
|
||
{
|
||
return false;
|
||
}
|
||
|
||
CreateLeftLineArr(m_nNum); // 初始化LINEARR数组
|
||
CreateTopLineArr();
|
||
CreateRightLineArr();
|
||
CreateBottomLineArr();
|
||
if (m_nNum > 1)
|
||
{
|
||
CreateCenterLine(); // 绘制中心线
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 初始化LINEARR数组
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 左,m_LineArr1
|
||
void CPipeStyle1::CreateLeftLineArr(int nNum)
|
||
{
|
||
//////////第一根线//////////
|
||
double dbLen(0); // 直线长度
|
||
ads_point StartPtIn; // 入口起点
|
||
double dArcRadius = GetFilletRadius(0); // 当前圈的曲率 短边
|
||
switch(m_nEntryType) // 对入口方向进行判断
|
||
{
|
||
case 1:
|
||
dbLen = m_dbShortDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = 0.0;
|
||
acutPolar(m_ptLB, 0, m_dDistToWall, StartPtIn);
|
||
break;
|
||
case 2:
|
||
dbLen = m_dbLongDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = 0.5*_PI;
|
||
acutPolar(m_ptLB, 0.5*_PI, m_dDistToWall, StartPtIn);
|
||
break;
|
||
case 3:
|
||
dbLen = m_dbLongDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = 1.5*_PI;
|
||
acutPolar(m_ptLT, 1.5*_PI, m_dDistToWall, StartPtIn);
|
||
break;
|
||
case 4:
|
||
dbLen = m_dbShortDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = 0.0;
|
||
acutPolar(m_ptLT, 0, m_dDistToWall, StartPtIn);
|
||
break;
|
||
case 5:
|
||
dbLen = m_dbShortDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = _PI;
|
||
acutPolar(m_ptRT, _PI, m_dDistToWall, StartPtIn);
|
||
break;
|
||
case 6:
|
||
dbLen = m_dbLongDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = 1.5*_PI;
|
||
acutPolar(m_ptRT, 1.5*_PI, m_dDistToWall, StartPtIn);
|
||
break;
|
||
case 7:
|
||
dbLen = m_dbLongDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = 0.5*_PI;
|
||
acutPolar(m_ptRB, 0.5*_PI, m_dDistToWall, StartPtIn);
|
||
break;
|
||
case 8:
|
||
dbLen = m_dbShortDist - m_dDistToWall - dArcRadius;
|
||
m_dbAssisAng = _PI;
|
||
acutPolar(m_ptRB, _PI, m_dDistToWall, StartPtIn);
|
||
break;
|
||
default:
|
||
return;
|
||
}
|
||
if(1e-5 >= dbLen)
|
||
dbLen = 100;
|
||
|
||
double dTemp(m_dbAssisAng + 0.5*_PI); // 临时辅助角度用
|
||
if ((2 == m_nEntryType) || (4 == m_nEntryType) || (6 == m_nEntryType) ||
|
||
(8 == m_nEntryType))
|
||
{
|
||
dTemp = m_dbAssisAng - 0.5*_PI;
|
||
}
|
||
|
||
ads_point actPt; // 实际点
|
||
TransToActualPt(StartPtIn, actPt);
|
||
|
||
int iLeftNum = m_iLeftNum;
|
||
double dLeftDist = ((iLeftNum>0 && iLeftNum--)?m_dBorderLeftDist:m_iLeftDist);
|
||
CPipeLine *line1 = new CPipeLine(actPt, m_dbPGAng, dbLen, dTemp, m_dbNormAng);
|
||
if( m_bEntrType ) // 按照之前的八个方向绘制
|
||
{
|
||
m_LineArr1.Add(line1); // 第一根线
|
||
}
|
||
else
|
||
{
|
||
// 绘制封口线
|
||
ads_point ptEnter, ptVir;
|
||
acutPolar(actPt, dTemp+m_dbPGAng+m_dbNormAng, m_dDistToWall, ptEnter);
|
||
double dArcRadius = m_dbArcRadius;
|
||
if( dArcRadius*2 - dLeftDist > -1e-6 )
|
||
{
|
||
dArcRadius = dLeftDist/3.0;
|
||
}
|
||
TransToVirtualPt(ptEnter, ptVir);
|
||
acutPolar(ptVir, m_dbAssisAng, dArcRadius, ptVir);
|
||
TransToActualPt(ptVir, ptEnter);
|
||
CPipeLine *lineAp = new CPipeLine(ptEnter, m_dbPGAng, dLeftDist-dArcRadius*2, m_dbAssisAng, m_dbNormAng);
|
||
m_LineArrAp.Add(lineAp);
|
||
|
||
// 绘制入水、出水点
|
||
ads_point ptStart, ptEnd;
|
||
line1->GetStartPt(ptStart);
|
||
line1->GetEndPt(ptEnd);
|
||
XLine pLine(ptStart, ptEnd);
|
||
XPoint ptProj; // 得到的投影点
|
||
m_ptPickEntry.Project(&pLine, ptProj);
|
||
dArcRadius = m_dbArcRadius;
|
||
if( dArcRadius*2 - m_dDistToWall > -1e-6 )
|
||
{
|
||
dArcRadius = m_dDistToWall/2;
|
||
}
|
||
ads_point ptReturn, ptSupply, ptProjT;
|
||
TransToVirtualPt(ptProj, ptProjT);
|
||
acutPolar(ptProjT, m_dbAssisAng, -dArcRadius, ptProjT);
|
||
TransToActualPt(ptProjT, ptProjT);
|
||
acutPolar(ptProj, dTemp+m_dbPGAng+m_dbNormAng, dLeftDist/2+dArcRadius, ptReturn);
|
||
acutPolar(ptProj, dTemp+m_dbPGAng+m_dbNormAng, -dLeftDist/2-dArcRadius, ptSupply);
|
||
acutPolar(ptProjT, dTemp+m_dbPGAng+m_dbNormAng, dLeftDist/2, ptStart);
|
||
acutPolar(ptProjT, dTemp+m_dbPGAng+m_dbNormAng, -dLeftDist/2, ptEnd);
|
||
if( acutDistance(ptStart, ptEnter) - acutDistance(ptEnd, ptEnter) > 1e-6 )
|
||
{ // ptStart端是回水端
|
||
acutPolar(ptProj, dTemp+m_dbPGAng+m_dbNormAng, -dLeftDist/2-dArcRadius, ptReturn);
|
||
acutPolar(ptProj, dTemp+m_dbPGAng+m_dbNormAng, dLeftDist/2+dArcRadius, ptSupply);
|
||
acutPolar(ptProjT, dTemp+m_dbPGAng+m_dbNormAng, -dLeftDist/2, ptStart);
|
||
acutPolar(ptProjT, dTemp+m_dbPGAng+m_dbNormAng, dLeftDist/2, ptEnd);
|
||
}
|
||
// 重新绘制第一条线
|
||
line1->GetStartPt(ptProjT);
|
||
line1->SetStartPt(ptSupply);
|
||
m_LineArr1.Add(line1); // 第一根线
|
||
lineAp = new CPipeLine;
|
||
lineAp->SetStartPt(ptProjT);
|
||
lineAp->SetEndPt(ptReturn);
|
||
m_LineArrAp.Add(lineAp);
|
||
|
||
// 绘制 供水、回水线
|
||
lineAp = new CPipeLine(ptStart, m_dbPGAng, -m_dDistToWall+dArcRadius, m_dbAssisAng, m_dbNormAng);
|
||
ads_point ptDrawReturn, ptDrawSupply;
|
||
lineAp->GetEndPt(ptDrawReturn);
|
||
if( !!m_ptDrawReturn )
|
||
lineAp->SetEndPt(m_ptDrawReturn);
|
||
else
|
||
m_ptDrawReturn = ptDrawReturn;
|
||
m_LineArrAp.Add(lineAp);
|
||
lineAp = new CPipeLine(ptEnd, m_dbPGAng, -m_dDistToWall+dArcRadius, m_dbAssisAng, m_dbNormAng);
|
||
lineAp->GetEndPt(ptDrawSupply);
|
||
if( !!m_ptDrawSupply )
|
||
lineAp->SetEndPt(m_ptDrawSupply);
|
||
else
|
||
m_ptDrawSupply = ptDrawSupply;
|
||
m_LineArrAp.Add(lineAp);
|
||
}
|
||
|
||
//////////第二根线//////////
|
||
ads_point StartPtOut; // 出口终点
|
||
// modify begin
|
||
//acutPolar(StartPtIn, m_dbAssisAng, m_iLeftDist, StartPtOut);
|
||
acutPolar(StartPtIn, m_dbAssisAng, dLeftDist, StartPtOut);
|
||
// modify end by cq
|
||
TransToActualPt(StartPtOut, actPt);
|
||
|
||
double dLastShortRadius = dArcRadius; // 保存第0圈曲率
|
||
dArcRadius = GetFilletRadius(1); // 第1圈曲率
|
||
|
||
// 计算第二条直线的长度
|
||
int iTopNum = m_iTopNum;
|
||
double dTopDist = ((iTopNum>0 && iTopNum--)?m_dBorderUpDist:m_iTopDist);
|
||
if (m_nNum == 1) // 只有一圈
|
||
{
|
||
dbLen = m_dDistToWall; // 只有一圈时 长度默认为距墙距离
|
||
//dbLen = m_dDistToWall - m_dbArcRadius;
|
||
}
|
||
else
|
||
{
|
||
if(2 == m_nNum)
|
||
dbLen = dbLen + dLastShortRadius - dTopDist - m_dCentRadius;
|
||
else
|
||
dbLen = dbLen + dLastShortRadius - dTopDist - dArcRadius;
|
||
}
|
||
ReviseLen(dbLen);
|
||
|
||
XPoint ptSecondPt = actPt; // 先记下点
|
||
CPipeLine *line2 = new CPipeLine(actPt, m_dbPGAng, dbLen, dTemp, m_dbNormAng);
|
||
m_LineArr1.Add(line2); // 第二根线
|
||
|
||
//////////其余的管线//////////
|
||
//double nDistLR(0), // 左右长度
|
||
// nDistTB(0); // 上下长度
|
||
// 根据出口方向,得左右、上下长度,并自动减去“距墙距离”
|
||
//GetLengthofLRandTBSide(nDistLR, nDistTB);
|
||
|
||
//double nDist1 = nDistLR - (m_nNum-1)*(m_iLeftDist + m_iRightDist),
|
||
// nDist2 = nDistTB - (m_nNum-1)*(m_iTopDist + m_iBottomDist);
|
||
|
||
// 取得左侧第三条直线的长度(包含曲率半径)
|
||
double dSrcLen = 0;
|
||
if(1 == m_nEntryType || 4 == m_nEntryType || 5 == m_nEntryType || 8 == m_nEntryType)
|
||
{
|
||
dSrcLen = m_dbShortDist - 2*m_dDistToWall - dTopDist;
|
||
}else{
|
||
dSrcLen = m_dbLongDist - 2*m_dDistToWall - dTopDist;
|
||
}
|
||
dTopDist = ((iTopNum>0 && iTopNum--)?m_dBorderUpDist:m_iTopDist);
|
||
dSrcLen -= dTopDist;
|
||
double dLastLongRadius = GetFilletRadius(1, FALSE); // 上一圈长边曲率
|
||
double dArcLongRadius = 0;
|
||
|
||
// 绘制左侧其余的管线
|
||
// change by hh 2010-11-29
|
||
// for (int i = 2; i < nNum+1; i++)
|
||
int iBottomNum = m_iBottomNum;
|
||
double dBottomDist = 0;
|
||
for (int i = 2; i < nNum; i++)
|
||
{
|
||
dArcRadius = GetFilletRadius(i); // 当前圈短边曲率
|
||
dArcLongRadius = GetFilletRadius(i, FALSE); // 当前圈长边曲率
|
||
|
||
ads_point lastPt, virPt; // 前一直线的起点、虚拟点
|
||
m_LineArr1[i-1]->GetStartPt(lastPt);
|
||
TransToVirtualPt(lastPt, virPt);
|
||
|
||
ads_point pt;
|
||
//acutPolar(virPt, m_dbAssisAng, m_iLeftDist, pt);
|
||
dLeftDist = ((iLeftNum>0 && iLeftNum--)?m_dBorderLeftDist:m_iLeftDist);
|
||
acutPolar(virPt, m_dbAssisAng, dLeftDist, pt); // cq
|
||
|
||
if (i == nNum - 1) // 最后一条
|
||
{
|
||
// 计算直线长度
|
||
if (m_bIsHorz)
|
||
dbLen = m_dbCenDist - 2 * m_dCentRadius;
|
||
else
|
||
dbLen = dSrcLen - m_dCentRadius - dArcLongRadius;
|
||
|
||
// 计算起点坐标
|
||
if(2 == i)
|
||
{
|
||
acutPolar(pt, dTemp, m_dDistToWall + (m_bIsHorz ? m_dCentRadius : dArcLongRadius), pt);
|
||
}
|
||
else
|
||
{
|
||
if (m_bIsHorz)
|
||
acutPolar(pt, dTemp, m_dCentRadius + dBottomDist - GetFilletRadius(i - 1, FALSE), pt);
|
||
else
|
||
acutPolar(pt, dTemp, dArcLongRadius + dBottomDist - dLastLongRadius, pt);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 计算直线长度
|
||
if(m_bIsHorz)
|
||
dbLen = dSrcLen - 2 * dArcLongRadius;
|
||
else
|
||
dbLen = dSrcLen - dArcRadius - dArcLongRadius;
|
||
|
||
// 计算起点坐标
|
||
if(2 == i)
|
||
acutPolar(pt, dTemp, m_dDistToWall + dArcLongRadius, pt);
|
||
else
|
||
acutPolar(pt, dTemp, dArcLongRadius + dBottomDist - dLastLongRadius, pt);
|
||
}
|
||
ReviseLen(dbLen);
|
||
|
||
TransToActualPt(pt, actPt);
|
||
CPipeLine *line = new CPipeLine(actPt, m_dbPGAng, dbLen, dTemp, m_dbNormAng);
|
||
m_LineArr1.Add(line);
|
||
|
||
// 保存数据
|
||
dLastLongRadius = dArcLongRadius; // 上一圈长边曲率
|
||
//dSrcLen -= (m_iTopDist + m_iBottomDist);
|
||
dTopDist = (iTopNum>0 && iTopNum--)?m_dBorderUpDist:m_iTopDist;
|
||
dBottomDist = (iBottomNum>0 && iBottomNum--)?m_dBorderDownDist:m_iBottomDist;
|
||
dSrcLen -= (dTopDist + dBottomDist); // cq
|
||
}
|
||
|
||
if( m_iBottomNum==0 )
|
||
m_iDrawInterB = 1;
|
||
else if( iBottomNum > 0 )
|
||
m_iDrawInterB = 0;
|
||
else
|
||
m_iDrawInterB = 2;
|
||
|
||
// mcl add 2010.11.17 修正供回水起始点位置,不再多出一个 距墙 的长度
|
||
if (m_LineArr1.GetSize() > 1)
|
||
{
|
||
double dDistTemp(0);
|
||
if( !m_bEntrType )
|
||
{
|
||
dLeftDist = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
dDistTemp = GetFilletRadius(0);
|
||
if( dDistTemp*2 - dLeftDist > -1e-6 )
|
||
{
|
||
dDistTemp = dLeftDist/3.0;
|
||
}
|
||
}
|
||
ads_point ptNewStart;
|
||
if( m_bEntrType )
|
||
{
|
||
if (m_LineArr1[0] != NULL )
|
||
{
|
||
m_LineArr1[0]->GetStartPt(ptNewStart);
|
||
acutPolar(ptNewStart, dTemp+m_dbPGAng + m_dbNormAng, m_dDistToWall+dDistTemp, ptNewStart);
|
||
if (!!m_ptDrawSupply)
|
||
{
|
||
m_LineArr1[0]->SetStartPt(m_ptDrawSupply);
|
||
}
|
||
else
|
||
{
|
||
m_LineArr1[0]->SetStartPt(ptNewStart);
|
||
}
|
||
m_ptDrawSupply = ptNewStart;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (m_LineArrAp[1] != NULL )
|
||
{
|
||
m_LineArrAp[1]->GetStartPt(ptNewStart);
|
||
acutPolar(ptNewStart, dTemp+m_dbPGAng + m_dbNormAng, m_dDistToWall+dDistTemp, ptNewStart);
|
||
m_LineArrAp[1]->SetStartPt(ptNewStart);
|
||
}
|
||
}
|
||
|
||
if (m_LineArr1[1] != NULL)
|
||
{
|
||
m_LineArr1[1]->GetStartPt(ptNewStart);
|
||
acutPolar(ptNewStart, dTemp+m_dbPGAng + m_dbNormAng, m_dDistToWall+dDistTemp, ptNewStart);
|
||
if( !!m_ptDrawReturn && m_bEntrType )
|
||
{
|
||
m_LineArr1[1]->SetStartPt(m_ptDrawReturn);
|
||
}
|
||
else
|
||
{
|
||
m_LineArr1[1]->SetStartPt(ptNewStart);
|
||
}
|
||
if( m_bEntrType )
|
||
m_ptDrawReturn = ptNewStart;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 上,m_LineArr2
|
||
void CPipeStyle1::CreateTopLineArr()
|
||
{
|
||
//double nDistLR(0), // 左右长度
|
||
// nDistTB(0); // 上下长度
|
||
// 根据出口方向,得左右、上下长度,并自动减去“距墙距离”
|
||
//GetLengthofLRandTBSide(nDistLR, nDistTB);
|
||
|
||
int nSize = (int)m_LineArr1.GetSize();
|
||
if(m_bIsHorz)
|
||
nSize--;
|
||
if(1 == m_nNum && 0 < nSize)
|
||
nSize = 1;
|
||
|
||
//double nDist1 = nDistLR - (m_nNum-1)*(m_iLeftDist + m_iRightDist),
|
||
// nDist2 = nDistTB - (m_nNum-1)*(m_iTopDist + m_iBottomDist);
|
||
//if ((nDist1 < nDist2) && (m_nNum != 1)) // 注:m_nNum=1时,只绘制一个上边
|
||
//{
|
||
// nSize++;
|
||
//}
|
||
|
||
double dbLen = 0; // 直线长
|
||
double dSrcLen = 0; // 上侧直线长度(包含曲率半径)
|
||
if(1 == m_nEntryType || 5 == m_nEntryType || 4 == m_nEntryType || 8 == m_nEntryType)
|
||
dSrcLen = m_dbLongDist - 2 * m_dDistToWall;
|
||
else
|
||
dSrcLen = m_dbShortDist - 2 * m_dDistToWall;
|
||
|
||
// change by hh 2010-11-29
|
||
//for (int i = 0; i < nSize-1; i++)
|
||
|
||
double dArcRadius = 0;
|
||
double dArcLongRadius = 0;
|
||
// 绘制上侧管线
|
||
double dLeftDist, dRightDist;
|
||
int iLeftNum = m_iLeftNum,
|
||
iRightNum = m_iRightNum;
|
||
for (int i = 0; i < nSize; i++)
|
||
{
|
||
dArcRadius = GetFilletRadius(i);
|
||
dArcLongRadius = GetFilletRadius(i, FALSE);
|
||
|
||
ads_point lastPt, virPt, actPt, pt; // 前一组直线的终点、虚拟点、实际点
|
||
m_LineArr1[i]->GetEndPt(lastPt);
|
||
TransToVirtualPt(lastPt, virPt);
|
||
|
||
if (nSize - 1 == i) // 最后一条
|
||
{
|
||
// 计算长度
|
||
if(1 == m_nNum) // 单圈
|
||
{
|
||
dbLen = dSrcLen - 2 * dArcRadius;
|
||
}
|
||
else
|
||
{
|
||
if(m_bIsHorz)
|
||
dbLen = dSrcLen - m_dCentRadius - dArcLongRadius;
|
||
else
|
||
dbLen = m_dbCenDist - 2 * m_dCentRadius;
|
||
}
|
||
|
||
// 计算起点坐标
|
||
acutPolar(virPt, m_dbAssisAng, m_bIsHorz ? dArcLongRadius : m_dCentRadius, pt);
|
||
if(1 == m_nEntryType || 3 == m_nEntryType || 5 == m_nEntryType || 7 == m_nEntryType)
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_bIsHorz ? dArcLongRadius : m_dCentRadius, pt);
|
||
else
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_bIsHorz ? dArcLongRadius : m_dCentRadius, pt);
|
||
}
|
||
else
|
||
{
|
||
// 计算长度
|
||
if(m_bIsHorz)
|
||
dbLen = dSrcLen - dArcRadius - dArcLongRadius;
|
||
else
|
||
dbLen = dSrcLen - 2 * dArcRadius;
|
||
|
||
// 计算起点坐标
|
||
acutPolar(virPt, m_dbAssisAng, m_bIsHorz ? dArcLongRadius : dArcRadius, pt);
|
||
if(1 == m_nEntryType || 3 == m_nEntryType || 5 == m_nEntryType || 7 == m_nEntryType)
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_bIsHorz ? dArcLongRadius : dArcRadius, pt);
|
||
else
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_bIsHorz ? dArcLongRadius : dArcRadius, pt);
|
||
}
|
||
ReviseLen(dbLen);
|
||
|
||
CPipeLine *line = NULL;
|
||
TransToActualPt(pt, actPt);
|
||
line = new CPipeLine(actPt, m_dbPGAng, dbLen, 0+m_dbAssisAng, m_dbNormAng);
|
||
/*
|
||
switch(m_nEntryType)
|
||
{
|
||
case 1:
|
||
case 3:
|
||
case 5:
|
||
case 7:
|
||
{
|
||
if (i == 0) // 第一根线
|
||
{
|
||
if ((1 == m_nEntryType) || (5 == m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*(m_dDistToWall+m_dbArcRadius);
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*(m_dDistToWall+m_dbArcRadius);
|
||
}
|
||
}
|
||
else if (i == nSize-2) // 最后一根线
|
||
{
|
||
// if (nDist1 > nDist2)
|
||
if (m_bIsHorz)
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = fabs(m_dbCenDist - 2*m_dbArcRadius);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
|
||
acutPolar(virPt, m_dbAssisAng, m_dbArcRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_dbArcRadius, pt);
|
||
TransToActualPt(pt, actPt);
|
||
line = new CPipeLine(actPt, m_dbPGAng, dbLen, 0+m_dbAssisAng, m_dbNormAng);
|
||
}
|
||
break;
|
||
case 2:
|
||
case 4:
|
||
case 6:
|
||
case 8:
|
||
{
|
||
if (i == 0) // 第一根线
|
||
{
|
||
if ((4 == m_nEntryType) || (8 == m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*(m_dDistToWall+m_dbArcRadius);
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*(m_dDistToWall+m_dbArcRadius);
|
||
}
|
||
}
|
||
else if (i == nSize-2) // 最后一根线
|
||
{
|
||
switch(m_nEntryType)
|
||
{
|
||
case 4:
|
||
case 8:
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
break;
|
||
case 2:
|
||
case 6:
|
||
//if (nDist1 > nDist2)
|
||
if (m_bIsHorz)
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = fabs(m_dbCenDist - 2*m_dbArcRadius);
|
||
}
|
||
break;
|
||
default:
|
||
return;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
|
||
acutPolar(virPt, m_dbAssisAng, m_dbArcRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_dbArcRadius, pt);
|
||
TransToActualPt(pt, actPt);
|
||
line = new CPipeLine(actPt, m_dbPGAng, dbLen, 0+m_dbAssisAng, m_dbNormAng);
|
||
}
|
||
break;
|
||
default:
|
||
return;
|
||
}*/
|
||
m_LineArr2.Add(line);
|
||
//dSrcLen -= (m_iLeftDist + m_iRightDist);
|
||
dLeftDist = ((iLeftNum>0 && iLeftNum--)?m_dBorderLeftDist:m_iLeftDist);
|
||
dRightDist = ((iRightNum>0 && iRightNum--)?m_dBorderRightDist:m_iRightDist);
|
||
dSrcLen -= (dLeftDist + dRightDist); // cq
|
||
}
|
||
|
||
if( m_iLeftNum==0 )
|
||
m_iDrawInterL = 1;
|
||
else if( iLeftNum > 0 )
|
||
m_iDrawInterL = 0;
|
||
else
|
||
m_iDrawInterL = 2;
|
||
}
|
||
|
||
// 右,m_LineArr4
|
||
void CPipeStyle1::CreateRightLineArr()
|
||
{
|
||
//double nDistLR(0), // 左右长度
|
||
// nDistTB(0); // 上下长度
|
||
// 根据出口方向,得左右、上下长度,并自动减去“距墙距离”
|
||
//GetLengthofLRandTBSide(nDistLR, nDistTB);
|
||
|
||
int nSize = (int)m_LineArr2.GetSize();
|
||
if(!m_bIsHorz)
|
||
nSize--;
|
||
if(1 == m_nNum && 0 < m_LineArr2.GetSize())
|
||
nSize = 1;
|
||
|
||
//double nDist1 = nDistLR - (m_nNum-1)*(m_iLeftDist + m_iRightDist),
|
||
// nDist2 = nDistTB - (m_nNum-1)*(m_iTopDist + m_iBottomDist);
|
||
//if ((nDist1 < nDist2) && (m_nNum != 1)) // 注:m_nNum=1时,只绘制一个右边
|
||
//{
|
||
// nSize--;
|
||
//}
|
||
|
||
double dTemp(m_dbAssisAng - 0.5*_PI); // 临时辅助角度用
|
||
if ((2 == m_nEntryType) || (4 == m_nEntryType) || (6 == m_nEntryType) ||
|
||
(8 == m_nEntryType))
|
||
{
|
||
dTemp = m_dbAssisAng + 0.5*_PI;
|
||
}
|
||
|
||
double dbLen = 0; // 直线长度
|
||
double dSrcLen = 0; // 右侧直线长度(包含曲率半径)
|
||
if(1 == m_nEntryType || 5 == m_nEntryType || 4 == m_nEntryType || 8 == m_nEntryType)
|
||
dSrcLen = m_dbShortDist - 2 * m_dDistToWall;
|
||
else
|
||
dSrcLen = m_dbLongDist - 2 * m_dDistToWall;
|
||
|
||
double dArcRadius = GetFilletRadius(0);
|
||
double dArcLongRadius = 0;
|
||
// 绘制右侧管线
|
||
double dTopDist, dBottomDist;
|
||
int iTopNum = m_iTopNum,
|
||
iBottomNum = m_iBottomNum;
|
||
for (int i = 0; i < nSize; i++)
|
||
{
|
||
dArcRadius = GetFilletRadius(i);
|
||
dArcLongRadius = GetFilletRadius(i + 2, FALSE);
|
||
|
||
ads_point lastPt, virPt, actPt, pt; // 前一组直线的终点、虚拟点、实际点
|
||
m_LineArr2[i]->GetEndPt(lastPt);
|
||
TransToVirtualPt(lastPt, virPt);
|
||
|
||
if(nSize - 1 == i) // 最后一根
|
||
{
|
||
// 计算长度
|
||
if(1 == m_nNum) // 单圈
|
||
{
|
||
dbLen = dSrcLen - 2 * dArcRadius;
|
||
}
|
||
else
|
||
{
|
||
if(m_bIsHorz)
|
||
dbLen = m_dbCenDist - 2 * m_dCentRadius;
|
||
else
|
||
dbLen = dSrcLen - dArcRadius - m_dCentRadius;
|
||
}
|
||
|
||
// 计算起点坐标
|
||
acutPolar(virPt, dTemp, (m_bIsHorz && 1 != m_nNum) ? m_dCentRadius : dArcRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng, (m_bIsHorz && 1 != m_nNum) ? m_dCentRadius : dArcRadius, pt);
|
||
}
|
||
else
|
||
{
|
||
// 计算长度
|
||
if(m_bIsHorz)
|
||
dbLen = dSrcLen - 2 * dArcRadius;
|
||
else
|
||
dbLen = dSrcLen - dArcRadius - dArcLongRadius;
|
||
|
||
// 计算起点坐标
|
||
acutPolar(virPt, dTemp, dArcRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng, dArcRadius, pt);
|
||
}
|
||
ReviseLen(dbLen);
|
||
|
||
TransToActualPt(pt, actPt);
|
||
CPipeLine *line = new CPipeLine(actPt, m_dbPGAng, dbLen, dTemp, m_dbNormAng);
|
||
m_LineArr3.Add(line);
|
||
|
||
// dSrcLen -= (m_iTopDist + m_iBottomDist);
|
||
dTopDist = ((iTopNum>0 && iTopNum--)?m_dBorderUpDist:m_iTopDist);
|
||
dBottomDist = ((iBottomNum>0 && iBottomNum--)?m_dBorderDownDist:m_iBottomDist);
|
||
dSrcLen -= (dTopDist + dBottomDist); // cq
|
||
}
|
||
|
||
if( m_iTopNum==0 )
|
||
m_iDrawInterT = 1;
|
||
else if( iTopNum > 0 )
|
||
m_iDrawInterT = 0;
|
||
else
|
||
m_iDrawInterT = 2;
|
||
}
|
||
|
||
// 下,m_LineArr3
|
||
void CPipeStyle1::CreateBottomLineArr()
|
||
{
|
||
//double nDistLR(0), // 左右长度
|
||
// nDistTB(0); // 上下长度
|
||
// 根据出口方向,得左右、上下长度,并自动减去“距墙距离”
|
||
//GetLengthofLRandTBSide(nDistLR, nDistTB);
|
||
|
||
int nSize = (int)m_LineArr3.GetSize();
|
||
if(m_bIsHorz)
|
||
nSize--;
|
||
if(1 == m_nNum && 0 < m_LineArr3.GetSize())
|
||
nSize = 1;
|
||
|
||
//double nDist1 = nDistLR - (m_nNum-1)*(m_iLeftDist + m_iRightDist),
|
||
// nDist2 = nDistTB - (m_nNum-1)*(m_iTopDist + m_iBottomDist);
|
||
//if ((nDist1 > nDist2) && (m_nNum != 1)) // 注:m_nNum=1时,只绘制一个右边
|
||
//{
|
||
// nSize--;
|
||
//}
|
||
|
||
double dbLen = 0; // 直线长
|
||
double dSrcLen = 0; // 下侧直线长度(包含曲率半径)
|
||
int iLeftNum = m_iLeftNum,
|
||
iRightNum = m_iRightNum;
|
||
double dLeftDist = ((iLeftNum>0 && iLeftNum--)?m_dBorderLeftDist:m_iLeftDist);
|
||
double dRightDist;
|
||
if(1 == m_nEntryType || 5 == m_nEntryType || 4 == m_nEntryType || 8 == m_nEntryType)
|
||
dSrcLen = m_dbLongDist - 2 * m_dDistToWall - dLeftDist;
|
||
else
|
||
dSrcLen = m_dbShortDist - 2 * m_dDistToWall - dLeftDist;
|
||
dLeftDist = ((iLeftNum>0 && iLeftNum--)?m_dBorderLeftDist:m_iLeftDist);
|
||
dSrcLen -= dLeftDist;
|
||
|
||
double dArcLongRadius = 0;
|
||
double dArcShortRadius = 0;
|
||
for (int i = 0; i < nSize; i++)
|
||
{
|
||
dArcShortRadius = GetFilletRadius(i);
|
||
dArcLongRadius = GetFilletRadius(i + 2, FALSE);
|
||
|
||
ads_point lastPt, virPt, actPt, pt; // 前一组直线的终点,虚拟点,实际点
|
||
m_LineArr3[i]->GetEndPt(lastPt);
|
||
TransToVirtualPt(lastPt, virPt);
|
||
|
||
// change by hh 2010-11-29
|
||
if(nSize - 1 == i) // 最后一条
|
||
{
|
||
// 计算长度
|
||
if(1 == m_nNum)
|
||
{
|
||
dLeftDist = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
dbLen = dSrcLen + dLeftDist - dArcShortRadius;
|
||
}
|
||
else
|
||
{
|
||
if(m_bIsHorz)
|
||
dbLen = dSrcLen - m_dCentRadius - dArcShortRadius;
|
||
else
|
||
dbLen = m_dbCenDist - 2 * m_dCentRadius;
|
||
}
|
||
|
||
// 计算起点坐标
|
||
acutPolar(virPt, m_dbAssisAng-_PI, m_bIsHorz ? dArcShortRadius : m_dCentRadius, pt);
|
||
if(1 == m_nEntryType || 3 == m_nEntryType || 5 == m_nEntryType || 7 == m_nEntryType)
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_bIsHorz ? dArcShortRadius : m_dCentRadius, pt);
|
||
else
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_bIsHorz ? dArcShortRadius : m_dCentRadius, pt);
|
||
}
|
||
else
|
||
{
|
||
// 计算长度
|
||
if(m_bIsHorz)
|
||
dbLen = dSrcLen - dArcShortRadius - dArcLongRadius;
|
||
else
|
||
dbLen = dSrcLen - 2 * dArcLongRadius;
|
||
|
||
// 计算起点坐标
|
||
acutPolar(virPt, m_dbAssisAng-_PI, m_bIsHorz ? dArcShortRadius : dArcLongRadius, pt);
|
||
if(1 == m_nEntryType || 3 == m_nEntryType || 5 == m_nEntryType || 7 == m_nEntryType)
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_bIsHorz ? dArcShortRadius : dArcLongRadius, pt);
|
||
else
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_bIsHorz ? dArcShortRadius : dArcLongRadius, pt);
|
||
}
|
||
ReviseLen(dbLen);
|
||
|
||
CPipeLine *line = NULL;
|
||
TransToActualPt(pt, actPt);
|
||
line = new CPipeLine(actPt, m_dbPGAng, dbLen, m_dbAssisAng-_PI, m_dbNormAng);
|
||
|
||
/*
|
||
switch(m_nEntryType)
|
||
{
|
||
case 1:
|
||
case 3:
|
||
case 5:
|
||
case 7:
|
||
{
|
||
if (i == nSize-1) // 最后一根
|
||
{
|
||
if (m_nNum == 1) // 只有一圈
|
||
{
|
||
if ((1 == m_nEntryType) || (5 == m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- m_iLeftDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- m_iLeftDist;
|
||
}
|
||
}
|
||
else if (i == 0) // m_Num = 2时,Line4只有一条
|
||
{
|
||
if ((1==m_nEntryType) || (5==m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- 2*m_iLeftDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- 2*m_iLeftDist;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (nDist1 > nDist2)
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = fabs(m_dbCenDist - 2*m_dbArcRadius);
|
||
}
|
||
}
|
||
}
|
||
else if (i == 0) // 第一根线
|
||
{
|
||
if ((1 == m_nEntryType) || (5 == m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*(m_dDistToWall + m_dbArcRadius
|
||
+ m_iLeftDist);
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*(m_dDistToWall + m_dbArcRadius
|
||
+ m_iLeftDist);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
|
||
acutPolar(virPt, m_dbAssisAng-_PI, m_dbArcRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_dbArcRadius, pt);
|
||
TransToActualPt(pt, actPt);
|
||
line = new CPipeLine(actPt, m_dbPGAng, dbLen, m_dbAssisAng-_PI, m_dbNormAng);
|
||
}
|
||
break;
|
||
case 2:
|
||
case 4:
|
||
case 6:
|
||
case 8:
|
||
{
|
||
if (i == nSize-1) // 最后一根
|
||
{
|
||
if (m_nNum == 1) // 只有一圈
|
||
{
|
||
if ((4 == m_nEntryType) || (8 == m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- m_iLeftDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- m_iLeftDist;
|
||
}
|
||
}
|
||
else if (i == 0) // m_Num = 2时,Line4只有一条
|
||
{
|
||
if ((4 == m_nEntryType) || (8 == m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- 2*m_iLeftDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*m_dDistToWall - 2*m_dbArcRadius
|
||
- 2*m_iLeftDist;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (nDist1 > nDist2)
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
else
|
||
{
|
||
dbLen = fabs(m_dbCenDist - 2*m_dbArcRadius);
|
||
}
|
||
}
|
||
}
|
||
else if (i == 0) // 第一根线
|
||
{
|
||
if ((4 == m_nEntryType) || (8 == m_nEntryType))
|
||
{
|
||
dbLen = m_dbLongDist - 2*m_dDistToWall - 2*m_iLeftDist
|
||
-2*m_dbArcRadius;
|
||
}
|
||
else
|
||
{
|
||
dbLen = m_dbShortDist - 2*m_dDistToWall - 2*m_iLeftDist
|
||
-2*m_dbArcRadius;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
dbLen = dbLen - m_iLeftDist - m_iRightDist;
|
||
}
|
||
acutPolar(virPt, m_dbAssisAng-_PI, m_dbArcRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_dbArcRadius, pt);
|
||
TransToActualPt(pt, actPt);
|
||
line = new CPipeLine(actPt, m_dbPGAng, dbLen, m_dbAssisAng-_PI,
|
||
m_dbNormAng);
|
||
}
|
||
break;
|
||
default:
|
||
return;
|
||
}*/
|
||
m_LineArr4.Add(line);
|
||
|
||
//dSrcLen -= (m_iLeftDist + m_iRightDist);
|
||
dLeftDist = ((iLeftNum>0 && iLeftNum--)?m_dBorderLeftDist:m_iLeftDist);
|
||
dRightDist = ((iRightNum>0 && iRightNum--)?m_dBorderRightDist:m_iRightDist);
|
||
dSrcLen -= (dLeftDist + dRightDist);// cq
|
||
}
|
||
|
||
if( m_iRightNum==0 )
|
||
m_iDrawInterR = 1;
|
||
else if( iRightNum > 0 )
|
||
m_iDrawInterR = 0;
|
||
else
|
||
m_iDrawInterR = 2;
|
||
}
|
||
|
||
// 中间线
|
||
void CPipeStyle1::CreateCenterLine()
|
||
{
|
||
double nDistLR(0), // 左右长度
|
||
nDistTB(0); // 上下长度
|
||
// 根据出口方向,得左右、上下长度,并自动减去“距墙距离”
|
||
GetLengthofLRandTBSide(nDistLR, nDistTB);
|
||
|
||
//BOOL bFlag(FALSE);
|
||
//double nDist1 = nDistLR - (m_nNum-1)*(m_iLeftDist + m_iRightDist),
|
||
// nDist2 = nDistTB - (m_nNum-1)*(m_iTopDist + m_iBottomDist);
|
||
//if (nDist1 < nDist2)
|
||
//{
|
||
// bFlag = TRUE;
|
||
//}
|
||
|
||
int nSize = 0;
|
||
double dbLen = 0; // 直线长
|
||
double nRotate = m_dbPGAng; // 旋转角度,方向
|
||
ads_point pt, lastPt, virPt, actPt; // 前一组直线的终点,虚拟点,实际点
|
||
|
||
// modify begin
|
||
// if(m_bIsHorz)
|
||
// dbLen = nDistLR - (m_nNum - 1) * m_iLeftDist - (m_nNum - 2) * m_iRightDist - 2 * m_dCentRadius;
|
||
// else
|
||
// dbLen = nDistTB - (m_nNum - 1) * m_iTopDist - (m_nNum - 2) * m_iBottomDist - 2 * m_dCentRadius;
|
||
double dDistTemp1, dDistTemp2;
|
||
if(m_bIsHorz){
|
||
if( m_iLeftNum > m_nNum-2 ){
|
||
dDistTemp1 = (m_nNum-1) * m_dBorderLeftDist;
|
||
}else{
|
||
dDistTemp1 = m_iLeftNum*m_dBorderLeftDist + (m_nNum-1-m_iLeftNum)*m_iLeftDist;
|
||
}
|
||
if( m_iRightNum > m_nNum-3 ){
|
||
dDistTemp2 = (m_nNum-2) * m_dBorderRightDist;
|
||
}else{
|
||
dDistTemp2 = m_iRightNum*m_dBorderRightDist + (m_nNum-2-m_iRightNum)*m_iRightDist;
|
||
}
|
||
|
||
dbLen = nDistLR - dDistTemp1 - dDistTemp2 - 2*m_dCentRadius;
|
||
}else{
|
||
if( m_iTopNum > m_nNum-2 ){
|
||
dDistTemp1 = (m_nNum-1) * m_dBorderUpDist;
|
||
}else{
|
||
dDistTemp1 = m_iTopNum*m_dBorderUpDist + (m_nNum-1-m_iTopNum)*m_iTopDist;
|
||
}
|
||
if( m_iBottomNum > m_nNum-3 ){
|
||
dDistTemp2 = (m_nNum-2) * m_dBorderDownDist;
|
||
}else{
|
||
dDistTemp2 = m_iBottomNum*m_dBorderDownDist + (m_nNum-2-m_iBottomNum)*m_iBottomDist;
|
||
}
|
||
|
||
dbLen = nDistTB - dDistTemp1 - dDistTemp2 - 2*m_dCentRadius;
|
||
}
|
||
// modify end by cq 2015-4-7 15:03:33
|
||
ReviseLen(dbLen);
|
||
|
||
double dLastRadius = GetFilletRadius(m_nNum - 2, FALSE);
|
||
switch(m_nEntryType)
|
||
{
|
||
case 1:
|
||
case 4:
|
||
case 5:
|
||
case 8:
|
||
{
|
||
//nDist1 = m_dbLongDist - 2*m_dDistToWall - (m_nNum-1)*m_iLeftDist
|
||
// -(m_nNum-1)*m_iRightDist;
|
||
//nDist2 = m_dbShortDist - 2*m_dDistToWall - (m_nNum-1)*m_iTopDist
|
||
// -(m_nNum-1)*m_iBottomDist;
|
||
// if (nDist2 > nDist1)
|
||
if(!m_bIsHorz)
|
||
{
|
||
nRotate += PI/2*3;
|
||
nSize = (int)m_LineArr2.GetSize();
|
||
m_LineArr2[nSize-1]->GetEndPt(lastPt); // 取2边的最后一条线
|
||
}
|
||
else
|
||
{
|
||
nSize = (int)m_LineArr1.GetSize();
|
||
m_LineArr1[nSize-1]->GetEndPt(lastPt); // 取1边的最后一条线
|
||
}
|
||
|
||
TransToVirtualPt(lastPt, virPt);
|
||
// dbLen = nDist1 - m_iLeftDist - 2*m_dbArcRadius;
|
||
// if (nDist2 > nDist1)
|
||
//{
|
||
// dbLen = nDist2 - m_iTopDist - 2*m_dbArcRadius;
|
||
//}
|
||
//acutPolar(virPt, m_dbAssisAng, m_dbArcRadius, pt);
|
||
acutPolar(virPt, m_dbAssisAng, m_dCentRadius, pt);
|
||
|
||
if ((1 == m_nEntryType) || (5 == m_nEntryType))
|
||
{
|
||
/*if (nDist1 > nDist2)
|
||
{
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_dbArcRadius, pt);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI*3, m_dbArcRadius, pt);
|
||
}*/
|
||
acutPolar(pt, m_dbAssisAng + 0.5 * _PI * (m_bIsHorz ? 1 : 3), m_dCentRadius , pt);
|
||
}
|
||
else if (4 == m_nEntryType)
|
||
{
|
||
acutPolar(pt, m_dbAssisAng - 0.5 * _PI * (m_bIsHorz ? 3 : 1), -m_dCentRadius, pt);
|
||
}
|
||
else if (8 == m_nEntryType)
|
||
{
|
||
acutPolar(pt, m_dbAssisAng + 0.5 * _PI * (m_bIsHorz ? 3 : 1), m_dCentRadius, pt);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_dCentRadius, pt);
|
||
}
|
||
TransToActualPt(pt, actPt);
|
||
|
||
double dAng = _PI;
|
||
if(m_bIsHorz)
|
||
{
|
||
if(1 == m_nEntryType || 4 == m_nEntryType)
|
||
dAng = 0;
|
||
}
|
||
else
|
||
{
|
||
if(1 == m_nEntryType || 8 == m_nEntryType)
|
||
dAng = 0;
|
||
}
|
||
m_pCenLine = new CPipeLine(actPt, nRotate, dbLen, dAng, m_dbNormAng);
|
||
|
||
//if ((1 == m_nEntryType) || (4 == m_nEntryType))
|
||
//{
|
||
// m_pCenLine = new CPipeLine(actPt, nRotate, dbLen, 0, m_dbNormAng);
|
||
//}
|
||
//else
|
||
//{
|
||
// m_pCenLine = new CPipeLine(actPt, nRotate, dbLen, _PI, m_dbNormAng);
|
||
//}
|
||
}
|
||
break;
|
||
case 2:
|
||
case 6:
|
||
{
|
||
// if (!bFlag)
|
||
if(m_bIsHorz)
|
||
{
|
||
nRotate += PI/2;
|
||
nSize = (int)m_LineArr3.GetSize();
|
||
m_LineArr3[nSize-1]->GetEndPt(lastPt); // 取3边的最后一条线
|
||
}
|
||
else
|
||
{
|
||
nSize = (int)m_LineArr2.GetSize();
|
||
m_LineArr2[nSize-1]->GetEndPt(lastPt); // 取2边的最后一条线
|
||
}
|
||
TransToVirtualPt(lastPt, virPt);
|
||
|
||
// if (bFlag)
|
||
if(!m_bIsHorz)
|
||
{
|
||
//dbLen = nDistTB - m_nNum*m_iTopDist - (m_nNum-1)*m_iBottomDist
|
||
// - 2*m_dbArcRadius;
|
||
acutPolar(virPt, m_dbAssisAng, m_dCentRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng+0.5*_PI, m_dCentRadius, pt);
|
||
}
|
||
else
|
||
{
|
||
//dbLen = nDistLR - (m_nNum-1)*m_iLeftDist - (m_nNum-1)*m_iRightDist
|
||
// - 2*m_dbArcRadius + m_iLeftDist;
|
||
acutPolar(virPt, m_dbAssisAng+PI/2, m_dCentRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng+PI, m_dCentRadius, pt);
|
||
}
|
||
|
||
TransToActualPt(pt, actPt);
|
||
if (m_nEntryType == 2)
|
||
{
|
||
m_pCenLine = new CPipeLine(actPt, nRotate, dbLen, _PI, m_dbNormAng);
|
||
}
|
||
else
|
||
{
|
||
m_pCenLine = new CPipeLine(actPt, nRotate, dbLen, 0, m_dbNormAng);
|
||
}
|
||
break;
|
||
}
|
||
case 3:
|
||
case 7:
|
||
{
|
||
if (m_bIsHorz)
|
||
{
|
||
nRotate -= PI/2;
|
||
nSize = (int)m_LineArr3.GetSize();
|
||
m_LineArr3[nSize-1]->GetEndPt(lastPt); // 取3边的最后一条线
|
||
}
|
||
else
|
||
{
|
||
nSize = (int)m_LineArr2.GetSize();
|
||
m_LineArr2[nSize-1]->GetEndPt(lastPt); // 取2边的最后一条线
|
||
}
|
||
TransToVirtualPt(lastPt, virPt);
|
||
|
||
if (!m_bIsHorz)
|
||
{
|
||
//dbLen = nDistTB - m_nNum*m_iTopDist - (m_nNum-1)*m_iBottomDist
|
||
// - 2*m_dbArcRadius;
|
||
acutPolar(virPt, m_dbAssisAng, m_dCentRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng-0.5*_PI, m_dCentRadius, pt);
|
||
}
|
||
else
|
||
{
|
||
//dbLen = nDistLR - m_nNum*m_iLeftDist - (m_nNum-1)*m_iRightDist
|
||
// - 2*m_dbArcRadius;
|
||
acutPolar(virPt, m_dbAssisAng-PI/2, m_dCentRadius, pt);
|
||
acutPolar(pt, m_dbAssisAng-PI, m_dCentRadius, pt);
|
||
}
|
||
|
||
TransToActualPt(pt, actPt);
|
||
if (3 == m_nEntryType)
|
||
{
|
||
m_pCenLine = new CPipeLine(actPt, nRotate, dbLen, _PI, m_dbNormAng);
|
||
}
|
||
else
|
||
{
|
||
m_pCenLine = new CPipeLine(actPt, nRotate, dbLen, 0, m_dbNormAng);
|
||
}
|
||
}
|
||
break;
|
||
default:
|
||
return;
|
||
}
|
||
}
|
||
|
||
bool CPipeStyle1::DrawPGLine()
|
||
{
|
||
// 1、对输入数据的合理性进行检查
|
||
if (abs(m_nDist) <= 0)
|
||
{
|
||
return false;
|
||
}
|
||
if (m_nEntryType < 1 || m_nEntryType > 8)
|
||
{
|
||
return false;
|
||
}
|
||
// 2、构造一个虚拟的外包“矩形”
|
||
GetCenterPt(); // 得到中心点m_CenterPt
|
||
GetDiagAng(); // 得到对角线锐角m_dbDiagAng
|
||
// 得到矩形边长m_dbDiagDist、m_dbShortDist、m_dbLongDist
|
||
GetLengthofSide();
|
||
// 虚拟矩形的四个顶点m_ptLB、m_ptLT、m_ptRT、m_ptRB
|
||
GetVirtaulRect();
|
||
|
||
NormalizeRect(); // 3、把虚拟矩形放倒
|
||
|
||
double nDistLR(0), // 左右长度
|
||
nDistTB(0); // 上下长度
|
||
GetLengthofLRandTBSide(nDistLR, nDistTB); // 4、得到左右、上下长度
|
||
|
||
// 5、计算盘管总共几排,初算m_nNum
|
||
double nBigLR = max(m_iLeftDist, m_iRightDist), // 得到左右、上下中较大的间距
|
||
nBigTB = max(m_iTopDist, m_iBottomDist);
|
||
double nBig = max(nBigLR, nBigTB); // 得到所有间距中最大值
|
||
|
||
// int nNum1 = (int)(nDistLR / (m_iLeftDist + m_iRightDist) * 2),
|
||
// nNum2 = (int)(nDistTB / (m_iTopDist + m_iBottomDist) * 2),
|
||
// nNum = min(nNum1, nNum2); // 较小值(大致能分几个区域)
|
||
double dLeftDist = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
double dRightDist = (m_iRightNum>0?m_dBorderRightDist:m_iRightDist);
|
||
double dTopDist = (m_iTopNum>0?m_dBorderUpDist:m_iTopDist);
|
||
double dBottomDist = (m_iBottomNum>0?m_dBorderDownDist:m_iBottomDist);
|
||
int nNum1 = (int)(nDistLR / (dLeftDist + dRightDist) * 2),
|
||
nNum2 = (int)(nDistTB / (dTopDist + dBottomDist) * 2),
|
||
nNum = min(nNum1, nNum2); // 较小值(大致能分几个区域)
|
||
|
||
// change by hh 2010-11-29
|
||
CalcLeftLines();
|
||
|
||
if (nNum < 3) // 7、初始化LINEARR数组
|
||
{
|
||
if (!DrawSingle()) // 画一圈
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!DrawMulti())
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
XPoint CPipeStyle1::GetEntryPt(int nNum)
|
||
{
|
||
int iOld = m_nEntryType;
|
||
GetCenterPt(); // 得到中心点
|
||
GetDiagAng(); // 得到对角线锐角
|
||
GetLengthofSide(); // 得到长短边
|
||
GetVirtaulRect(); // 得到虚拟矩形
|
||
|
||
XPoint ptOldLB = m_ptLB,
|
||
ptOldLT = m_ptLT,
|
||
ptOldRT = m_ptRT,
|
||
ptOldRB = m_ptRB;
|
||
TransToActualPt(ptOldLB, ptOldLB);
|
||
TransToActualPt(ptOldLT, ptOldLT);
|
||
TransToActualPt(ptOldRT, ptOldRT);
|
||
TransToActualPt(ptOldRB, ptOldRB);
|
||
|
||
NormalizeRect(); // 把虚拟矩形放倒
|
||
|
||
XPoint ptActLB, ptActLT, ptActRT, ptActRB;
|
||
TransToActualPt(m_ptLB, ptActLB);
|
||
TransToActualPt(m_ptLT, ptActLT);
|
||
TransToActualPt(m_ptRT, ptActRT);
|
||
TransToActualPt(m_ptRB, ptActRB);
|
||
|
||
BOOL bReserve(FALSE);
|
||
if (iOld != m_nEntryType)
|
||
{
|
||
bReserve = TRUE;
|
||
}
|
||
|
||
ads_point StartPtIn; // 入口起点
|
||
switch(nNum) // 判断入口
|
||
{
|
||
case 1:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldLB, m_dbPGAng, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActLB, m_dbPGAng, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
case 2:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldLB, m_dbPGAng+0.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActLB, m_dbPGAng+0.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
case 3:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldLT, m_dbPGAng+1.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActLT, m_dbPGAng+1.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
case 4:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldLT, m_dbPGAng, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActLT, m_dbPGAng, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
case 5:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldRT, m_dbPGAng+_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActRT, m_dbPGAng+_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
case 6:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldRT, m_dbPGAng+1.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActRT, m_dbPGAng+1.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
case 7:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldRB, m_dbPGAng+0.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActRB, m_dbPGAng+0.5*_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
case 8:
|
||
if (bReserve)
|
||
{
|
||
acutPolar(ptOldRB, m_dbPGAng+_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
else
|
||
{
|
||
acutPolar(ptActRB, m_dbPGAng+_PI, m_dDistToWall, StartPtIn);
|
||
}
|
||
break;
|
||
default:
|
||
return XPoint();
|
||
}
|
||
|
||
XPoint ptRet = StartPtIn;
|
||
return ptRet;
|
||
}
|
||
|
||
void CPipeStyle1::GetCrossPts(XPoint &ptSupply, XPoint &ptReturn)
|
||
{
|
||
GetCenterPt();
|
||
GetDiagAng();
|
||
GetLengthofSide();
|
||
GetVirtaulRect();
|
||
NormalizeRect();
|
||
CreateLeftLineArr(1);
|
||
ptSupply = m_ptDrawSupply;
|
||
ptReturn = m_ptDrawReturn;
|
||
}
|
||
|
||
//////////////////////////////////////////////////////////////////////
|
||
// 处理弧线
|
||
//////////////////////////////////////////////////////////////////////
|
||
bool CPipeStyle1::CreateArcArr()
|
||
{
|
||
ads_point StartPt, EndPt; // 圆弧起点,圆弧终点
|
||
AcDbObjectId ArcID; // 圆弧实体ID
|
||
ads_point CenPt; // 圆弧中心点
|
||
|
||
int size = (int)m_LineArr2.GetSize();
|
||
int i = 0; // sg modify
|
||
double dRadius = 0;
|
||
for (i = 0; i < size; i++) // 1、2边加角圆弧
|
||
{
|
||
m_LineArr1[i]->GetEndPt(EndPt);
|
||
m_LineArr2[i]->GetStartPt(StartPt);
|
||
dRadius = GetFilletRadius(i);
|
||
GetArcCenterPt(EndPt, 0, CenPt, dRadius);
|
||
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
size = (int)m_LineArr3.GetSize();
|
||
for (i = 0; i < size; i++) // 2、3边加角圆弧
|
||
{
|
||
m_LineArr2[i]->GetEndPt(EndPt);
|
||
m_LineArr3[i]->GetStartPt(StartPt);
|
||
dRadius = GetFilletRadius(i);
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, dRadius);
|
||
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else // 反向画弧
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
size = (int)m_LineArr4.GetSize();
|
||
for (i = 0; i < size; i++) // 3、4边加角圆弧
|
||
{
|
||
m_LineArr3[i]->GetEndPt(EndPt);
|
||
m_LineArr4[i]->GetStartPt(StartPt);
|
||
dRadius = GetFilletRadius(i);
|
||
GetArcCenterPt(EndPt, -_PI, CenPt, dRadius);
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
for (i = 0; i < size; i++) // 4、1边加角圆弧
|
||
{
|
||
dRadius = GetFilletRadius(i);
|
||
if (m_nNum == 1)
|
||
{
|
||
m_LineArr4[0]->GetEndPt(StartPt);
|
||
if (m_LineArr1.GetSize() < 2) // 只有一圈时不画
|
||
{
|
||
break;
|
||
}
|
||
|
||
m_LineArr1[1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, 0, CenPt, dRadius);
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
|
||
if ((i == size-1) && ((2 == m_nEntryType) || (3 == m_nEntryType) ||
|
||
(6 == m_nEntryType) || (7 == m_nEntryType))) // 最后一根
|
||
{
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
m_LineArr4[i]->GetEndPt(EndPt);
|
||
if (m_LineArr1.GetSize() < (i+3)) // 1组中没有实体了
|
||
{
|
||
break;
|
||
}
|
||
m_LineArr1[i+2]->GetStartPt(StartPt);
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, dRadius);
|
||
}
|
||
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
double nDistLR(0), // 左右长度
|
||
nDistTB(0); // 上下长度
|
||
// 根据出口方向,得左右、上下长度,并自动减去“距墙距离”
|
||
GetLengthofLRandTBSide(nDistLR, nDistTB);
|
||
|
||
double nDist1 = nDistLR - (m_nNum-1)*(m_iLeftDist + m_iRightDist),
|
||
nDist2 = nDistTB - (m_nNum-1)*(m_iTopDist + m_iBottomDist);
|
||
|
||
// 中心线两侧圆弧
|
||
if (m_pCenLine != NULL)
|
||
{
|
||
for (int j = 0; j < 2; j++)
|
||
{
|
||
if (j == 0) // 先取中心线的起点
|
||
{
|
||
m_pCenLine->GetStartPt(StartPt);
|
||
}
|
||
else
|
||
{
|
||
m_pCenLine->GetEndPt(StartPt);
|
||
}
|
||
|
||
if ((1 == m_nEntryType) || (4 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (8 == m_nEntryType))
|
||
{
|
||
if (nDist1 > nDist2)
|
||
{
|
||
// 如果是第一根,且入口是1、4、5、8,则连接1边最后一根直线的终点
|
||
if (j == 0)
|
||
{
|
||
m_LineArr1[m_LineArr1.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, 0, CenPt, m_dCentRadius);
|
||
}
|
||
else // 否则连接3边最后一根直线的终点
|
||
{
|
||
m_LineArr3[m_LineArr3.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, _PI, CenPt, m_dCentRadius);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果是第一根,且入口是2、3、6、7,则连接2边最后一根直线的终点
|
||
if (j == 0)
|
||
{
|
||
m_LineArr2[m_LineArr2.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
else
|
||
{// 否则连接4边最后一根直线的终点
|
||
m_LineArr4[m_LineArr4.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果是第一根,且入口是2、3、6、7,则连接2边最后一根直线的终点
|
||
if (j == 0)
|
||
{
|
||
m_LineArr2[m_LineArr2.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
else // 否则连接4边最后一根直线的终点
|
||
{
|
||
m_LineArr4[m_LineArr4.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
}
|
||
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, m_dCentRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
bool CPipeStyle1::CreateArcArr(XExplodeDraw &dc, AcDbObjectId idRetLayer/* = AcDbObjectId::kNull*/)
|
||
{
|
||
ads_point StartPt, EndPt; // 圆弧起点,圆弧终点
|
||
AcDbObjectId ArcID; // 圆弧实体ID
|
||
ads_point CenPt; // 圆弧中心点
|
||
|
||
AcDbObjectId idOrigLayer = dc.GetLayerId();
|
||
int i(0), nSize(0); // sg modify
|
||
double dRadius = 0;
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType)) // 绘制正向的弧
|
||
{
|
||
// add begin 绘制"左边"附加的圆弧
|
||
double dLeftDist = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
if( !m_bEntrType && 4 == m_LineArrAp.GetSize() )
|
||
{
|
||
dc.SetLayer(idRetLayer);
|
||
m_LineArr1[1]->GetStartPt(EndPt);
|
||
m_LineArrAp[0]->GetEndPt(StartPt);
|
||
dRadius = m_dbArcRadius;
|
||
if( dRadius*2 - dLeftDist > -1e-6 )
|
||
{
|
||
dRadius = dLeftDist/3;
|
||
}
|
||
GetArcCenterPt(EndPt, _PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
m_LineArrAp[0]->GetStartPt(EndPt);
|
||
m_LineArrAp[1]->GetStartPt(StartPt);
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
|
||
dRadius = m_dbArcRadius;
|
||
if( dRadius*2 - m_dDistToWall > -1e-6 )
|
||
{
|
||
dRadius = m_dDistToWall/2;
|
||
}
|
||
m_LineArrAp[2]->GetStartPt(EndPt);
|
||
m_LineArrAp[1]->GetEndPt(StartPt);
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
dc.SetLayer(idOrigLayer);
|
||
m_LineArr1[0]->GetStartPt(EndPt);
|
||
m_LineArrAp[3]->GetStartPt(StartPt);
|
||
GetArcCenterPt(EndPt, PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
// add end by cq 2015-4-8 09:27:40
|
||
nSize = (int)m_LineArr2.GetSize();
|
||
for (i = 0; i < nSize; i++) // 1、2边加角圆弧
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
dRadius = GetFilletRadius(i, m_bIsHorz ? FALSE : TRUE);
|
||
|
||
m_LineArr1[i]->GetEndPt(EndPt);
|
||
m_LineArr2[i]->GetStartPt(StartPt);
|
||
if(i == nSize - 1 && !m_bIsHorz)
|
||
{
|
||
GetArcCenterPt(EndPt, 0, CenPt, m_dCentRadius); // 获取弧心
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, m_dCentRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetArcCenterPt(EndPt, 0, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
nSize = (int)m_LineArr3.GetSize();
|
||
for (i = 0; i < nSize; i++) // 2、3边加角圆弧
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
dRadius = GetFilletRadius(i);
|
||
|
||
m_LineArr2[i]->GetEndPt(EndPt);
|
||
m_LineArr3[i]->GetStartPt(StartPt);
|
||
if(nSize - 1 == i && m_bIsHorz)
|
||
{
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, m_dCentRadius);
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, dRadius);
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
nSize = (int)m_LineArr4.GetSize();
|
||
for (i = 0; i < nSize; i++) // 3、4边加角圆弧
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
if(m_bIsHorz)
|
||
dRadius = GetFilletRadius(i);
|
||
else
|
||
dRadius = GetFilletRadius(i + 2, FALSE);
|
||
|
||
|
||
m_LineArr3[i]->GetEndPt(EndPt);
|
||
m_LineArr4[i]->GetStartPt(StartPt);
|
||
if(i == nSize - 1 && !m_bIsHorz)
|
||
{
|
||
GetArcCenterPt(EndPt, -_PI, CenPt, m_dCentRadius);
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetArcCenterPt(EndPt, -_PI, CenPt, dRadius);
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
}
|
||
else // 绘制反向的弧
|
||
{
|
||
// add begin 绘制"左边"附加的圆弧
|
||
double dLeftDist = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
if( !m_bEntrType && 4 == m_LineArrAp.GetSize() )
|
||
{
|
||
dc.SetLayer(idRetLayer);
|
||
m_LineArr1[1]->GetStartPt(EndPt);
|
||
m_LineArrAp[0]->GetEndPt(StartPt);
|
||
dRadius = m_dbArcRadius;
|
||
if( dRadius*2 - dLeftDist > -1e-6 )
|
||
{
|
||
dRadius = dLeftDist/3;
|
||
}
|
||
GetArcCenterPt(EndPt, -_PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
//dc.SetLayer(idOrigLayer);
|
||
m_LineArrAp[0]->GetStartPt(EndPt);
|
||
m_LineArrAp[1]->GetStartPt(StartPt);
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
|
||
dRadius = m_dbArcRadius;
|
||
if( dRadius*2 - m_dDistToWall > -1e-6 )
|
||
{
|
||
dRadius = m_dDistToWall/2;
|
||
}
|
||
m_LineArrAp[2]->GetStartPt(EndPt);
|
||
m_LineArrAp[1]->GetEndPt(StartPt);
|
||
GetArcCenterPt(EndPt, 1.5*_PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
dc.SetLayer(idOrigLayer);
|
||
m_LineArr1[0]->GetStartPt(EndPt);
|
||
m_LineArrAp[3]->GetStartPt(StartPt);
|
||
GetArcCenterPt(EndPt, -_PI, CenPt, dRadius); // 获取弧心
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius)) // 绘制弧
|
||
{
|
||
return false;
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
// add end by cq 2015-4-8 09:27:40
|
||
nSize = (int)m_LineArr2.GetSize();
|
||
for (i = 0; i < nSize; i++) // 1、2边加角圆弧
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
dRadius = GetFilletRadius(i, m_bIsHorz ? FALSE : TRUE);
|
||
|
||
m_LineArr1[i]->GetEndPt(EndPt);
|
||
m_LineArr2[i]->GetStartPt(StartPt);
|
||
if(nSize - 1 == i && !m_bIsHorz)
|
||
{
|
||
GetArcCenterPt(EndPt, 0, CenPt, m_dCentRadius);
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetArcCenterPt(EndPt, 0, CenPt, dRadius);
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
nSize = (int)m_LineArr3.GetSize();
|
||
for (i = 0; i < nSize; i++) // 2、3边加角圆弧
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
dRadius = GetFilletRadius(i);
|
||
|
||
m_LineArr2[i]->GetEndPt(EndPt);
|
||
m_LineArr3[i]->GetStartPt(StartPt);
|
||
if(nSize - 1 == i && m_bIsHorz)
|
||
{
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, m_dCentRadius);
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, dRadius);
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
nSize = (int)m_LineArr4.GetSize();
|
||
for (i = 0; i < nSize; i++) // 3、4边加角圆弧
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
if(m_bIsHorz)
|
||
dRadius = GetFilletRadius(i);
|
||
else
|
||
dRadius = GetFilletRadius(i + 2, FALSE);
|
||
|
||
m_LineArr3[i]->GetEndPt(EndPt);
|
||
m_LineArr4[i]->GetStartPt(StartPt);
|
||
if(nSize - 1 == i && !m_bIsHorz)
|
||
{
|
||
GetArcCenterPt(EndPt, -_PI, CenPt, m_dCentRadius);
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetArcCenterPt(EndPt, -_PI, CenPt, dRadius);
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
}
|
||
|
||
|
||
nSize = (int)m_LineArr4.GetSize();
|
||
for (i = 0; i < nSize; i++) // 4、1边加角圆弧
|
||
{
|
||
// mcl add 2010.11.10 回水图层设置
|
||
if (i%2 == 1 && idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
else
|
||
dc.SetLayer(idOrigLayer);
|
||
if(m_bIsHorz)
|
||
dRadius = GetFilletRadius(i + 2, FALSE);
|
||
else
|
||
dRadius = GetFilletRadius(i + 2, FALSE);
|
||
|
||
if (m_nNum == 1) // 只画一圈
|
||
{
|
||
m_LineArr4[0]->GetEndPt(StartPt);
|
||
if (m_LineArr1.GetSize() < 2) // 只有一圈时不画
|
||
{
|
||
break;
|
||
}
|
||
m_LineArr1[1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, 0, CenPt, dRadius);
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
|
||
if ((i == nSize) && ((2 == m_nEntryType) || (3 == m_nEntryType) ||
|
||
(6 == m_nEntryType) || (7 == m_nEntryType))) // 最后一根
|
||
{
|
||
break;
|
||
}
|
||
else
|
||
{
|
||
m_LineArr4[i]->GetEndPt(EndPt);
|
||
if (m_LineArr1.GetSize() < (i+3)) // 1组中没有实体了
|
||
{
|
||
break;
|
||
}
|
||
m_LineArr1[i+2]->GetStartPt(StartPt);
|
||
if(nSize - 1 == i && m_bIsHorz)
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, m_dCentRadius);
|
||
else
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, dRadius);
|
||
}
|
||
|
||
if(nSize - 1 == i && m_bIsHorz)
|
||
{
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, m_dCentRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, dRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, dRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
|
||
/*double nDist1(0), nDist2(0);
|
||
if ((1 == m_nEntryType) || (4 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (8 == m_nEntryType))
|
||
{
|
||
nDist1 = m_dbLongDist - m_dDistToWall*2 - (m_nNum-1)*(m_iLeftDist+m_iRightDist);
|
||
nDist2 = m_dbShortDist - m_dDistToWall*2 - (m_nNum-1)*(m_iTopDist+m_iBottomDist);
|
||
}
|
||
else
|
||
{
|
||
nDist1 = m_dbShortDist - m_dDistToWall*2 - (m_nNum-1)*(m_iLeftDist+m_iRightDist);
|
||
nDist2 = m_dbLongDist - m_dDistToWall*2 - (m_nNum-1)*(m_iTopDist+m_iBottomDist);
|
||
}*/
|
||
|
||
if (idRetLayer.isValid())
|
||
dc.SetLayer(idRetLayer);
|
||
|
||
// change by hh 2010-11-30
|
||
if (m_pCenLine != NULL) // 中心线两侧圆弧
|
||
{
|
||
for (int j = 0; j < 2; j++)
|
||
{
|
||
if (j == 0) // 先取中心线的起点
|
||
{
|
||
m_pCenLine->GetStartPt(StartPt);
|
||
}
|
||
else
|
||
{
|
||
m_pCenLine->GetEndPt(StartPt);
|
||
}
|
||
|
||
if ((1 == m_nEntryType) || (4 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (8 == m_nEntryType))
|
||
{
|
||
// change by hh 2010-11-30
|
||
// if (nDist1 > nDist2)
|
||
if(m_bIsHorz)
|
||
{
|
||
// 如果是第一根,且入口是1、4、5、8,则连接1边最后一根直线的终点
|
||
if (j == 0)
|
||
{
|
||
m_LineArr1[m_LineArr1.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, 0, CenPt, m_dCentRadius);
|
||
}
|
||
else // 否则连接3边最后一根直线的终点
|
||
{
|
||
m_LineArr3[m_LineArr3.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, _PI, CenPt, m_dCentRadius);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果是第一根,且入口是2、3、6、7,则连接2边最后一根直线的终点
|
||
if (j == 0)
|
||
{
|
||
m_LineArr2[m_LineArr2.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
else // 否则连接4边最后一根直线的终点
|
||
{
|
||
m_LineArr4[m_LineArr4.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
//if (nDist1 < nDist2)
|
||
if(!m_bIsHorz)
|
||
{
|
||
// 如果是第一根,且入口是2、3、6、7,则连接2边最后一根直线的终点
|
||
if (j == 0)
|
||
{
|
||
m_LineArr2[m_LineArr2.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -0.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
else // 否则连接4边最后一根直线的终点
|
||
{
|
||
m_LineArr4[m_LineArr4.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, -1.5*_PI, CenPt, m_dCentRadius);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果是第一根,且入口是1、4、5、8,则连接1边最后一根直线的终点
|
||
if (j == 0)
|
||
{
|
||
m_LineArr3[m_LineArr3.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, _PI, CenPt, m_dCentRadius);
|
||
}
|
||
else // 否则连接3边最后一根直线的终点
|
||
{
|
||
m_LineArr1[m_LineArr1.GetSize()-1]->GetEndPt(EndPt);
|
||
GetArcCenterPt(EndPt, 0, CenPt, m_dCentRadius);
|
||
}
|
||
}
|
||
}
|
||
|
||
if ((1 == m_nEntryType) || (3 == m_nEntryType) || (5 == m_nEntryType)
|
||
|| (7 == m_nEntryType))
|
||
{
|
||
if (!CreateArc(StartPt, EndPt, CenPt, ArcID, dc, m_dCentRadius))
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!CreateArc(EndPt, StartPt, CenPt, ArcID, dc, m_dCentRadius)) // 反向画弧
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
m_ArcArr.Add(ArcID);
|
||
}
|
||
}
|
||
dc.SetLayer(idOrigLayer);
|
||
|
||
// add begin
|
||
|
||
// add end by cq 绘制1边附加圆弧
|
||
return true;
|
||
}
|
||
|
||
/*----------------------------------------------------------------------------*
|
||
* 函数名称: CPipeStyle1::CreateArc()
|
||
* 功能描述: 创建圆弧
|
||
* 参 数: [in] StartPt:圆弧起点
|
||
[in] EndPt:圆弧终点
|
||
[in] CenPt:圆弧圆心
|
||
[out] ObjID:圆弧实体ID
|
||
* 返 回 值: 创建是否成功,true:成功,false:失败
|
||
* 历 史:
|
||
* 备 注: 自定义实体用
|
||
-----------------------------------------------------------------------------*/
|
||
bool CPipeStyle1::CreateArc(ads_point StartPt, ads_point EndPt, ads_point CenPt,
|
||
AcDbObjectId& ObjID, double dRadius)
|
||
{
|
||
double StartAng = acutAngle(CenPt, StartPt),
|
||
EndAng = acutAngle(CenPt, EndPt);
|
||
|
||
XArc pArc(CenPt, dRadius, StartAng, EndAng);
|
||
pArc.Make();
|
||
return true;
|
||
}
|
||
|
||
// 自定义实体
|
||
bool CPipeStyle1::CreateArc(ads_point StartPt, ads_point EndPt, ads_point CenPt,
|
||
AcDbObjectId& ObjID, XExplodeDraw &dc, double dRadius)
|
||
{
|
||
if (fabs(dRadius) < 1.0E-5) // sg add
|
||
{
|
||
return true; // 曲率半径为0时不绘制
|
||
}
|
||
|
||
double StartAng = acutAngle(CenPt, StartPt),
|
||
EndAng = acutAngle(CenPt, EndPt);
|
||
|
||
XArc pArc(CenPt, dRadius, StartAng, EndAng);
|
||
// dc.DrawArc(pArc, 0); // sg modify
|
||
|
||
XCurveSegment seg;
|
||
seg = pArc;
|
||
// if (m_bWeight)
|
||
// if (g_bPipeWeight)
|
||
if (g_bFloorPipeWeight)
|
||
{
|
||
double dWeight = DocGetPScale() * m_dLineWeight;
|
||
DrawWeight(dc, dWeight, seg, m_nColorInd, 1.0);
|
||
}
|
||
else
|
||
{
|
||
dc << seg;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
void CPipeStyle1::GetArcCenterPt(ads_point EndPt, double dbAng, ads_point& actCenPt, double dRadius)
|
||
{
|
||
actCenPt[X] = actCenPt[Y] = actCenPt[Z] = 0.0; // 返回的圆心
|
||
ads_point virPt, CenPt; // 虚拟点,虚拟中心点
|
||
TransToVirtualPt(EndPt, virPt);
|
||
|
||
switch(m_nEntryType)
|
||
{
|
||
case 1:
|
||
acutPolar(virPt, dbAng, dRadius, CenPt);
|
||
break;
|
||
case 2:
|
||
acutPolar(virPt, 0.5*_PI-dbAng, dRadius, CenPt);
|
||
break;
|
||
case 3:
|
||
acutPolar(virPt, dbAng+1.5*_PI, dRadius, CenPt);
|
||
break;
|
||
case 4:
|
||
acutPolar(virPt, 0-dbAng, dRadius, CenPt);
|
||
break;
|
||
case 5:
|
||
acutPolar(virPt, dbAng+_PI, dRadius, CenPt);
|
||
break;
|
||
case 6:
|
||
acutPolar(virPt, 1.5*_PI-dbAng, dRadius, CenPt);
|
||
break;
|
||
case 7:
|
||
acutPolar(virPt, dbAng+0.5*_PI, dRadius, CenPt);
|
||
break;
|
||
case 8:
|
||
acutPolar(virPt, _PI-dbAng, dRadius, CenPt);
|
||
break;
|
||
default :
|
||
return;
|
||
}
|
||
TransToActualPt(CenPt, actCenPt);
|
||
}
|
||
|
||
void CPipeStyle1::ReAllocateDist()
|
||
{
|
||
if( (m_ptPickEntry.x == 0 && m_ptPickEntry.y == 0) )
|
||
{
|
||
m_iLeftDist = m_iLeftDistT;
|
||
m_iRightDist = m_iRightDistT;
|
||
m_iTopDist = m_iTopDistT;
|
||
m_iBottomDist = m_iBottomDistT;
|
||
m_dBorderLeftDist = m_dBorderLeftDistT;
|
||
m_dBorderRightDist = m_dBorderRightDistT;
|
||
m_dBorderUpDist = m_dBorderUpDistT;
|
||
m_dBorderDownDist = m_dBorderDownDistT;
|
||
m_dBorderLeftWidth = m_dBorderLeftWidthT;
|
||
m_dBorderRightWidth = m_dBorderRightWidthT;
|
||
m_dBorderUpWidth = m_dBorderUpWidthT;
|
||
m_dBorderDownWidth = m_dBorderDownWidthT;
|
||
m_iLeftNum = int(floor(m_dBorderLeftWidth*1000/m_dBorderLeftDist));
|
||
m_iRightNum = int(floor(m_dBorderRightWidth*1000/m_dBorderRightDist));
|
||
m_iTopNum = int(floor(m_dBorderUpWidth*1000/m_dBorderUpDist));
|
||
m_iBottomNum = int(floor(m_dBorderDownWidth*1000/m_dBorderDownDist));
|
||
m_bEntrType = TRUE;
|
||
return ;
|
||
}
|
||
|
||
AcGePoint2d ptStart = asPnt2d(m_rectStartPt);
|
||
AcGePoint2d ptEnd = asPnt2d(m_rectEndPt);
|
||
AcGePoint2d ptPick = m_ptPickEntry.AsAcGePoint2d();
|
||
AcGeVector2d ptVec(1.0, -1.0);
|
||
double dDist = m_dDistToWall * sqrt(2.0);
|
||
ptStart += ptVec.normalize()*dDist;
|
||
ptEnd -= ptVec.normalize()*dDist;
|
||
double dTemp, dPrec = 1e-6;
|
||
ptEnd.rotateBy(-m_dbPGAng, ptStart);
|
||
ptPick.rotateBy(-m_dbPGAng, ptStart);
|
||
if( ptStart.x - ptEnd.x > dPrec )
|
||
{
|
||
if( ptStart.y - ptEnd.y > dPrec )
|
||
{
|
||
dTemp = ptStart.x;
|
||
ptStart.x = ptEnd.x;
|
||
ptEnd.x = dTemp;
|
||
}
|
||
else
|
||
{
|
||
std::swap(ptStart, ptEnd);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if( ptStart.y - ptEnd.y < dPrec )
|
||
{
|
||
dTemp = ptStart.y;
|
||
ptStart.y = ptEnd.y;
|
||
ptEnd.y = dTemp;
|
||
}
|
||
}
|
||
int nEntryType = m_nEntryType;
|
||
m_bEntrType = FALSE;
|
||
if( ptPick.x - ptEnd.x > -dPrec )
|
||
{
|
||
if( ptPick.y - ptEnd.y < dPrec )
|
||
{
|
||
if( fabs(ptPick.x-ptEnd.x) - fabs(ptEnd.y-ptPick.y) > dPrec )
|
||
{
|
||
nEntryType = 7;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
else
|
||
{
|
||
nEntryType = 8;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
}
|
||
else if( ptPick.y - ptStart.y > -dPrec )
|
||
{
|
||
if( fabs(ptPick.x-ptEnd.x) - fabs(ptPick.y-ptStart.y) > dPrec )
|
||
{
|
||
nEntryType = 6;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
else
|
||
{
|
||
nEntryType = 5;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
}
|
||
}
|
||
else if( ptPick.x - ptStart.x < dPrec )
|
||
{
|
||
if( ptPick.y - ptEnd.y < dPrec )
|
||
{
|
||
if( fabs(ptStart.x-ptPick.x) - fabs(ptEnd.y-ptPick.y) > dPrec )
|
||
{
|
||
nEntryType = 2;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
else
|
||
{
|
||
nEntryType = 1;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
}
|
||
else if( ptPick.y - ptStart.y > -dPrec )
|
||
{
|
||
if( fabs(ptStart.x-ptPick.x) - fabs(ptPick.y-ptStart.y) > dPrec )
|
||
{
|
||
nEntryType = 3;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
else
|
||
{
|
||
nEntryType = 4;
|
||
m_bEntrType = TRUE;
|
||
}
|
||
}
|
||
}
|
||
if( m_bEntrType )
|
||
{
|
||
m_nEntryType = nEntryType;
|
||
}
|
||
switch(m_nEntryType)
|
||
{
|
||
case 1:
|
||
m_dBorderLeftDist = m_dBorderLeftDistT;
|
||
m_dBorderRightDist = m_dBorderRightDistT;
|
||
m_dBorderUpDist = m_dBorderUpDistT;
|
||
m_dBorderDownDist = m_dBorderDownDistT;
|
||
m_dBorderLeftWidth = m_dBorderLeftWidthT;
|
||
m_dBorderRightWidth = m_dBorderRightWidthT;
|
||
m_dBorderUpWidth = m_dBorderUpWidthT;
|
||
m_dBorderDownWidth = m_dBorderDownWidthT;
|
||
m_iLeftDist = m_iLeftDistT;
|
||
m_iRightDist = m_iRightDistT;
|
||
m_iTopDist = m_iTopDistT;
|
||
m_iBottomDist = m_iBottomDistT;
|
||
break;
|
||
case 2:
|
||
m_dBorderLeftDist = m_dBorderDownDistT;
|
||
m_dBorderRightDist = m_dBorderUpDistT;
|
||
m_dBorderUpDist = m_dBorderRightDistT;
|
||
m_dBorderDownDist = m_dBorderLeftDistT;
|
||
m_dBorderLeftWidth = m_dBorderDownWidthT;
|
||
m_dBorderRightWidth = m_dBorderUpWidthT;
|
||
m_dBorderUpWidth = m_dBorderRightWidthT;
|
||
m_dBorderDownWidth = m_dBorderLeftWidthT;
|
||
m_iLeftDist = m_iBottomDistT;
|
||
m_iRightDist = m_iTopDistT;
|
||
m_iTopDist = m_iRightDistT;
|
||
m_iBottomDist = m_iLeftDistT;
|
||
break;
|
||
case 3:
|
||
m_dBorderLeftDist = m_dBorderUpDistT;
|
||
m_dBorderRightDist = m_dBorderDownDistT;
|
||
m_dBorderUpDist = m_dBorderRightDistT;
|
||
m_dBorderDownDist = m_dBorderLeftDistT;
|
||
m_dBorderLeftWidth = m_dBorderUpWidthT;
|
||
m_dBorderRightWidth = m_dBorderDownWidthT;
|
||
m_dBorderUpWidth = m_dBorderRightWidthT;
|
||
m_dBorderDownWidth = m_dBorderLeftWidthT;
|
||
m_iLeftDist = m_iTopDistT;
|
||
m_iRightDist = m_iBottomDistT;
|
||
m_iTopDist = m_iRightDistT;
|
||
m_iBottomDist = m_iLeftDistT;
|
||
break;
|
||
case 4:
|
||
m_dBorderLeftDist = m_dBorderLeftDistT;
|
||
m_dBorderRightDist = m_dBorderRightDistT;
|
||
m_dBorderUpDist = m_dBorderDownDistT;
|
||
m_dBorderDownDist = m_dBorderUpDistT;
|
||
m_dBorderLeftWidth = m_dBorderLeftWidthT;
|
||
m_dBorderRightWidth = m_dBorderRightWidthT;
|
||
m_dBorderUpWidth = m_dBorderDownWidthT;
|
||
m_dBorderDownWidth = m_dBorderUpWidthT;
|
||
m_iLeftDist = m_iLeftDistT;
|
||
m_iRightDist = m_iRightDistT;
|
||
m_iTopDist = m_iBottomDistT;
|
||
m_iBottomDist = m_iTopDistT;
|
||
break;
|
||
case 5:
|
||
m_dBorderLeftDist = m_dBorderRightDistT;
|
||
m_dBorderRightDist = m_dBorderLeftDistT;
|
||
m_dBorderUpDist = m_dBorderDownDistT;
|
||
m_dBorderDownDist = m_dBorderUpDistT;
|
||
m_dBorderLeftWidth = m_dBorderRightWidthT;
|
||
m_dBorderRightWidth = m_dBorderLeftWidthT;
|
||
m_dBorderUpWidth = m_dBorderDownWidthT;
|
||
m_dBorderDownWidth = m_dBorderUpWidthT;
|
||
m_iLeftDist = m_iRightDistT;
|
||
m_iRightDist = m_iLeftDistT;
|
||
m_iTopDist = m_iBottomDistT;
|
||
m_iBottomDist = m_iTopDistT;
|
||
break;
|
||
case 6:
|
||
m_dBorderLeftDist = m_dBorderUpDistT;
|
||
m_dBorderRightDist = m_dBorderDownDistT;
|
||
m_dBorderUpDist = m_dBorderLeftDistT;
|
||
m_dBorderDownDist = m_dBorderRightDistT;
|
||
m_dBorderLeftWidth = m_dBorderUpWidthT;
|
||
m_dBorderRightWidth = m_dBorderDownWidthT;
|
||
m_dBorderUpWidth = m_dBorderLeftWidthT;
|
||
m_dBorderDownWidth = m_dBorderRightWidthT;
|
||
m_iLeftDist = m_iTopDistT;
|
||
m_iRightDist = m_iBottomDistT;
|
||
m_iTopDist = m_iLeftDistT;
|
||
m_iBottomDist = m_iRightDistT;
|
||
break;
|
||
case 7:
|
||
m_dBorderLeftDist = m_dBorderDownDistT;
|
||
m_dBorderRightDist = m_dBorderUpDistT;
|
||
m_dBorderUpDist = m_dBorderLeftDistT;
|
||
m_dBorderDownDist = m_dBorderRightDistT;
|
||
m_dBorderLeftWidth = m_dBorderDownWidthT;
|
||
m_dBorderRightWidth = m_dBorderUpWidthT;
|
||
m_dBorderUpWidth = m_dBorderLeftWidthT;
|
||
m_dBorderDownWidth = m_dBorderRightWidthT;
|
||
m_iLeftDist = m_iBottomDistT;
|
||
m_iRightDist = m_iTopDistT;
|
||
m_iTopDist = m_iLeftDistT;
|
||
m_iBottomDist = m_iRightDistT;
|
||
break;
|
||
case 8:
|
||
m_dBorderLeftDist = m_dBorderRightDistT;
|
||
m_dBorderRightDist = m_dBorderLeftDistT;
|
||
m_dBorderUpDist = m_dBorderUpDistT;
|
||
m_dBorderDownDist = m_dBorderDownDistT;
|
||
m_dBorderLeftWidth = m_dBorderRightWidthT;
|
||
m_dBorderRightWidth = m_dBorderLeftWidthT;
|
||
m_dBorderUpWidth = m_dBorderUpWidthT;
|
||
m_dBorderDownWidth = m_dBorderDownWidthT;
|
||
m_iLeftDist = m_iRightDistT;
|
||
m_iRightDist = m_iLeftDistT;
|
||
m_iTopDist = m_iTopDistT;
|
||
m_iBottomDist = m_iBottomDistT;
|
||
break;
|
||
}
|
||
|
||
// 计算个方向的边界区圈数
|
||
m_iLeftNum = int(floor(m_dBorderLeftWidth*1000/m_dBorderLeftDist));
|
||
m_iRightNum = int(floor(m_dBorderRightWidth*1000/m_dBorderRightDist));
|
||
m_iTopNum = int(floor(m_dBorderUpWidth*1000/m_dBorderUpDist));
|
||
m_iBottomNum = int(floor(m_dBorderDownWidth*1000/m_dBorderDownDist));
|
||
if( !m_bEntrType )
|
||
{// 处理边界情况
|
||
double dPrve = -1e-6, dDistTemp;
|
||
switch(m_nEntryType)
|
||
{
|
||
case 1:
|
||
dDistTemp = (m_iTopNum>0?m_dBorderUpDist:m_iTopDist);
|
||
if( ptPick.y - ptStart.y + dDistTemp > dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 3;
|
||
m_dBorderLeftDist = m_dBorderUpDistT;
|
||
m_dBorderRightDist = m_dBorderDownDistT;
|
||
m_dBorderUpDist = m_dBorderRightDistT;
|
||
m_dBorderDownDist = m_dBorderLeftDistT;
|
||
m_dBorderLeftWidth = m_dBorderUpWidthT;
|
||
m_dBorderRightWidth = m_dBorderDownWidthT;
|
||
m_dBorderUpWidth = m_dBorderRightWidthT;
|
||
m_dBorderDownWidth = m_dBorderLeftWidthT;
|
||
m_iLeftDist = m_iTopDistT;
|
||
m_iRightDist = m_iBottomDistT;
|
||
m_iTopDist = m_iRightDistT;
|
||
m_iBottomDist = m_iLeftDistT;
|
||
}
|
||
else if( ptPick.y - ptEnd.y < dPrec )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
}
|
||
break;
|
||
case 2:
|
||
dDistTemp = (m_iRightNum>0?m_dBorderRightDist:m_iRightDist);
|
||
if( ptPick.x - ptEnd.x + dDistTemp > dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 8;
|
||
m_dBorderLeftDist = m_dBorderRightDistT;
|
||
m_dBorderRightDist = m_dBorderLeftDistT;
|
||
m_dBorderUpDist = m_dBorderUpDistT;
|
||
m_dBorderDownDist = m_dBorderDownDistT;
|
||
m_dBorderLeftWidth = m_dBorderRightWidthT;
|
||
m_dBorderRightWidth = m_dBorderLeftWidthT;
|
||
m_dBorderUpWidth = m_dBorderUpWidthT;
|
||
m_dBorderDownWidth = m_dBorderDownWidthT;
|
||
m_iLeftDist = m_iRightDistT;
|
||
m_iRightDist = m_iLeftDistT;
|
||
m_iTopDist = m_iTopDistT;
|
||
m_iBottomDist = m_iBottomDistT;
|
||
}
|
||
break;
|
||
case 3:
|
||
dDistTemp = (m_iRightNum>0?m_dBorderRightDist:m_iRightDist);
|
||
if( ptPick.x - ptEnd.x + dDistTemp > dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 5;
|
||
m_dBorderLeftDist = m_dBorderRightDistT;
|
||
m_dBorderRightDist = m_dBorderLeftDistT;
|
||
m_dBorderUpDist = m_dBorderDownDistT;
|
||
m_dBorderDownDist = m_dBorderUpDistT;
|
||
m_dBorderLeftWidth = m_dBorderRightWidthT;
|
||
m_dBorderRightWidth = m_dBorderLeftWidthT;
|
||
m_dBorderUpWidth = m_dBorderDownWidthT;
|
||
m_dBorderDownWidth = m_dBorderUpWidthT;
|
||
m_iLeftDist = m_iRightDistT;
|
||
m_iRightDist = m_iLeftDistT;
|
||
m_iTopDist = m_iBottomDistT;
|
||
m_iBottomDist = m_iTopDistT;
|
||
}
|
||
break;
|
||
case 4:
|
||
dDistTemp = (m_iBottomNum>0?m_dBorderDownDist:m_iBottomDist);
|
||
if( ptPick.y - ptEnd.y - dDistTemp < dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 2;
|
||
m_dBorderLeftDist = m_dBorderDownDistT;
|
||
m_dBorderRightDist = m_dBorderUpDistT;
|
||
m_dBorderUpDist = m_dBorderRightDistT;
|
||
m_dBorderDownDist = m_dBorderLeftDistT;
|
||
m_dBorderLeftWidth = m_dBorderDownWidthT;
|
||
m_dBorderRightWidth = m_dBorderUpWidthT;
|
||
m_dBorderUpWidth = m_dBorderRightWidthT;
|
||
m_dBorderDownWidth = m_dBorderLeftWidthT;
|
||
m_iLeftDist = m_iBottomDistT;
|
||
m_iRightDist = m_iTopDistT;
|
||
m_iTopDist = m_iRightDistT;
|
||
m_iBottomDist = m_iLeftDistT;
|
||
}
|
||
break;
|
||
case 5:
|
||
dDistTemp = (m_iBottomNum>0?m_dBorderDownDist:m_iBottomDist);
|
||
if( ptPick.y - ptEnd.y - dDistTemp < dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 7;
|
||
m_dBorderLeftDist = m_dBorderDownDistT;
|
||
m_dBorderRightDist = m_dBorderUpDistT;
|
||
m_dBorderUpDist = m_dBorderLeftDistT;
|
||
m_dBorderDownDist = m_dBorderRightDistT;
|
||
m_dBorderLeftWidth = m_dBorderDownWidthT;
|
||
m_dBorderRightWidth = m_dBorderUpWidthT;
|
||
m_dBorderUpWidth = m_dBorderLeftWidthT;
|
||
m_dBorderDownWidth = m_dBorderRightWidthT;
|
||
m_iLeftDist = m_iBottomDistT;
|
||
m_iRightDist = m_iTopDistT;
|
||
m_iTopDist = m_iLeftDistT;
|
||
m_iBottomDist = m_iRightDistT;
|
||
}
|
||
break;
|
||
case 6:
|
||
dDistTemp = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
if( ptPick.x - ptStart.x - dDistTemp < dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 4;
|
||
m_dBorderLeftDist = m_dBorderLeftDistT;
|
||
m_dBorderRightDist = m_dBorderRightDistT;
|
||
m_dBorderUpDist = m_dBorderDownDistT;
|
||
m_dBorderDownDist = m_dBorderUpDistT;
|
||
m_dBorderLeftWidth = m_dBorderLeftWidthT;
|
||
m_dBorderRightWidth = m_dBorderRightWidthT;
|
||
m_dBorderUpWidth = m_dBorderDownWidthT;
|
||
m_dBorderDownWidth = m_dBorderUpWidthT;
|
||
m_iLeftDist = m_iLeftDistT;
|
||
m_iRightDist = m_iRightDistT;
|
||
m_iTopDist = m_iBottomDistT;
|
||
m_iBottomDist = m_iTopDistT;
|
||
}
|
||
break;
|
||
case 7:
|
||
dDistTemp = (m_iLeftNum>0?m_dBorderLeftDist:m_iLeftDist);
|
||
if( ptPick.x - ptStart.x - dDistTemp < dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 1;
|
||
m_dBorderLeftDist = m_dBorderLeftDistT;
|
||
m_dBorderRightDist = m_dBorderRightDistT;
|
||
m_dBorderUpDist = m_dBorderUpDistT;
|
||
m_dBorderDownDist = m_dBorderDownDistT;
|
||
m_dBorderLeftWidth = m_dBorderLeftWidthT;
|
||
m_dBorderRightWidth = m_dBorderRightWidthT;
|
||
m_dBorderUpWidth = m_dBorderUpWidthT;
|
||
m_dBorderDownWidth = m_dBorderDownWidthT;
|
||
m_iLeftDist = m_iLeftDistT;
|
||
m_iRightDist = m_iRightDistT;
|
||
m_iTopDist = m_iTopDistT;
|
||
m_iBottomDist = m_iBottomDistT;
|
||
}
|
||
break;
|
||
case 8:
|
||
dDistTemp = (m_iBottomNum>0?m_dBorderDownDist:m_iBottomDist);
|
||
if( ptPick.y - ptStart.y + dDistTemp > dPrve )
|
||
{
|
||
m_bEntrType = TRUE;
|
||
m_nEntryType = 6;
|
||
m_dBorderLeftDist = m_dBorderUpDistT;
|
||
m_dBorderRightDist = m_dBorderDownDistT;
|
||
m_dBorderUpDist = m_dBorderLeftDistT;
|
||
m_dBorderDownDist = m_dBorderRightDistT;
|
||
m_dBorderLeftWidth = m_dBorderUpWidthT;
|
||
m_dBorderRightWidth = m_dBorderDownWidthT;
|
||
m_dBorderUpWidth = m_dBorderLeftWidthT;
|
||
m_dBorderDownWidth = m_dBorderRightWidthT;
|
||
m_iLeftDist = m_iTopDistT;
|
||
m_iRightDist = m_iBottomDistT;
|
||
m_iTopDist = m_iLeftDistT;
|
||
m_iBottomDist = m_iRightDistT;
|
||
}
|
||
break;
|
||
}
|
||
m_iLeftNum = int(floor(m_dBorderLeftWidth*1000/m_dBorderLeftDist));
|
||
m_iRightNum = int(floor(m_dBorderRightWidth*1000/m_dBorderRightDist));
|
||
m_iTopNum = int(floor(m_dBorderUpWidth*1000/m_dBorderUpDist));
|
||
m_iBottomNum = int(floor(m_dBorderDownWidth*1000/m_dBorderDownDist));
|
||
}
|
||
}
|
||
|
||
BOOL CPipeStyle1::GetRealSameDist(double &dSameDist)
|
||
{
|
||
double dCmpDist;
|
||
if( m_iDrawInterL == 0 ) // 只有外区
|
||
dCmpDist = m_dBorderLeftDist;
|
||
else if( m_iDrawInterL == 1 )
|
||
dCmpDist = m_iLeftDist;
|
||
else
|
||
{
|
||
if( fabs(m_dBorderLeftDist-m_iLeftDist) > g_fZero )
|
||
return FALSE;
|
||
dCmpDist = m_iLeftDist;
|
||
}
|
||
|
||
double dDistTemp;
|
||
if( m_iDrawInterR == 0 )
|
||
dDistTemp = m_dBorderRightDist;
|
||
else if( m_iDrawInterR == 1 )
|
||
dDistTemp = m_iRightDist;
|
||
else
|
||
{
|
||
if( fabs(m_dBorderRightDist-m_iRightDist) > g_fZero )
|
||
return FALSE;
|
||
dDistTemp = m_iRightDist;
|
||
}
|
||
|
||
if( fabs(dDistTemp-dCmpDist) > g_fZero )
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
if( m_iDrawInterT == 0 )
|
||
dDistTemp = m_dBorderUpDist;
|
||
else if( m_iDrawInterT == 1 )
|
||
dDistTemp = m_iTopDist;
|
||
else
|
||
{
|
||
if( fabs(m_dBorderUpDist-m_iTopDist) > g_fZero )
|
||
{
|
||
return FALSE;
|
||
}
|
||
dDistTemp = m_iTopDist;
|
||
}
|
||
|
||
if( fabs(dDistTemp-dCmpDist) > g_fZero )
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
if( m_iDrawInterB == 0 )
|
||
dDistTemp = m_dBorderDownDist;
|
||
else if( m_iDrawInterB == 1 )
|
||
dDistTemp = m_iBottomDist;
|
||
else
|
||
{
|
||
if( fabs(m_dBorderDownDist-m_iBottomDist) > g_fZero )
|
||
{
|
||
return FALSE;
|
||
}
|
||
dDistTemp = m_iBottomDist;
|
||
}
|
||
|
||
if( fabs(dDistTemp-dCmpDist) > g_fZero )
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
dSameDist = dCmpDist;
|
||
return TRUE;
|
||
} |