6881 lines
184 KiB
C++
6881 lines
184 KiB
C++
#include "stdafx.h"
|
||
#include "ImpHvacCross.h"
|
||
#include "AecDbObjXDataMap.h"
|
||
#include "AuxTools.h"
|
||
#include "math.h"
|
||
#include "AecDbEntityBase.h"
|
||
|
||
static const Adesk::UInt16 kColorByLayer = 256;
|
||
extern double MayAsMUnit(double dVal);
|
||
|
||
double g_dCmdOff = 100;
|
||
|
||
ImpHvacCross::ImpHvacCross()
|
||
{
|
||
m_pXDataMap = NULL;
|
||
m_pOwnerEnt = NULL;
|
||
}
|
||
|
||
ImpHvacCross::~ImpHvacCross()
|
||
{
|
||
}
|
||
|
||
AcGeVector3d ImpHvacCross::normal() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
AcGeVector3d vtStart, vtBr1;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
|
||
return vtStart.crossProduct(vtBr1);
|
||
}
|
||
|
||
double ImpHvacCross::GetEdgeLineWidth() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
double dWidth(0.0);
|
||
m_pXDataMap->GetAt(HVAC_EdgeWidth, dWidth);
|
||
|
||
return dWidth;
|
||
}
|
||
|
||
double ImpHvacCross::GetCentLineWidth() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
double dWidth(0.0);
|
||
m_pXDataMap->GetAt(HVAC_CentWidth, dWidth);
|
||
|
||
return dWidth;
|
||
}
|
||
|
||
double ImpHvacCross::GetEndLineWidth() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
double dWidth(0.0);
|
||
m_pXDataMap->GetAt(HVAC_EndWidth, dWidth);
|
||
|
||
return dWidth;
|
||
}
|
||
|
||
BOOL ImpHvacCross::SetSingleDashWidth(double& dSta,double& dEnd,double& dBr1,double& dBr2) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
if (!IsSingleLine())
|
||
{
|
||
return FALSE;
|
||
}
|
||
double dSingleWidth(0.0);
|
||
m_pXDataMap->GetAt(KEY_HIDEWIDTH, dSingleWidth);
|
||
if (dSingleWidth > 0)
|
||
{
|
||
dSta = dEnd = dBr1 = dBr2 = dSingleWidth;
|
||
return TRUE;
|
||
}
|
||
return FALSE;
|
||
}
|
||
|
||
void ImpHvacCross::list() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
// 管件类型
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t\t\t\t 暖通:四通"));
|
||
|
||
// 截面类型
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType, (int&)eSectType);
|
||
switch (eSectType)
|
||
{
|
||
case eRect: acutPrintf(_T("\n\t\t\t\t\t\t\t\t\t\t\t 截面:矩形")); break;
|
||
case eCircle:acutPrintf(_T("\n\t\t\t\t\t\t\t\t\t\t\t 截面:圆形")); break;
|
||
case eOblate:acutPrintf(_T("\n\t\t\t\t\t\t\t\t\t\t\t 截面:扁圆形")); break;
|
||
}
|
||
|
||
double dRadRatio = 0.0;
|
||
m_pXDataMap->GetAt(HCRS_RadRatio, dRadRatio);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t\t曲率值:%.2f"), dRadRatio);
|
||
|
||
// 圆型截面显示直径
|
||
if (eCircle == eSectType)
|
||
{
|
||
double dStartDiameter = 0.0, dEndDiameter = 0.0;
|
||
m_pXDataMap->GetAt(HCRS_StartDiameter, dStartDiameter);
|
||
m_pXDataMap->GetAt(HCRS_EndDiameter, dEndDiameter);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t始端直径:%.2f 末端直径:%.2f"), dStartDiameter, dEndDiameter);
|
||
double dBranch1Diameter = 0.0, dBranch2Diameter = 0.0;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Diameter, dBranch1Diameter);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Diameter, dBranch2Diameter);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t支管1直径:%.2f 支管2直径:%.2f"), dBranch1Diameter, dBranch2Diameter);
|
||
}
|
||
// 非圆型截面显示宽度和厚度
|
||
else
|
||
{
|
||
double dStartWidth = 0.0, dEndWidth = 0.0, dThick = 0.0;
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dStartWidth);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEndWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t始端宽度:%.2f 末端宽度:%.2f 厚度:%.2f"), dStartWidth, dEndWidth, dThick);
|
||
double dBranchWidth = 0.0, dBranchThick = 0.0;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBranchWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBranchThick);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t支管1宽度:%.2f 支管1厚度:%.2f"), dBranchWidth, dBranchThick);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBranchWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBranchThick);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t支管2宽度:%.2f 支管2厚度:%.2f"), dBranchWidth, dBranchThick);
|
||
}
|
||
|
||
// 起点
|
||
AcGePoint3d pt;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, pt);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t自 点,X=%.4f\t Y=%.4f\t Z=%.4f"), pt.x, pt.y, pt.z);
|
||
|
||
// 终点
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, pt);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t到 点,X=%.4f\t Y=%.4f\t Z=%.4f"), pt.x, pt.y, pt.z);
|
||
|
||
// 支管1
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, pt);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t支管1,X=%.4f\t Y=%.4f\t Z=%.4f"), pt.x, pt.y, pt.z);
|
||
|
||
// 支管2
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, pt);
|
||
acutPrintf(_T("\n\t\t\t\t\t\t\t\t支管2,X=%.4f\t Y=%.4f\t Z=%.4f"), pt.x, pt.y, pt.z);
|
||
}
|
||
|
||
BOOL ImpHvacCross::IsHorzAlignment() const
|
||
{
|
||
// 获得法向量
|
||
AcGeVector3d vtStart, vtBr1;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
|
||
AcGeVector3d vtNormal = AcGeVector3d::kZAxis;
|
||
vtNormal = vtStart.crossProduct(vtBr1);
|
||
|
||
// 获得UCS坐标Z向量
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
AcGeTol tolTmp;
|
||
tolTmp.setEqualVector(1);
|
||
tolTmp.setEqualPoint(1);
|
||
return vtNormal.isParallelTo(vtZAxis, tolTmp);
|
||
}
|
||
|
||
BOOL ImpHvacCross::IsVertAlignment() const
|
||
{
|
||
// 获得法向量
|
||
AcGeVector3d vtStart, vtBr1;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
|
||
AcGeVector3d vtNormal = AcGeVector3d::kZAxis;
|
||
vtNormal = vtStart.crossProduct(vtBr1);
|
||
|
||
// 获得UCS坐标Z向量
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
|
||
return vtNormal.isPerpendicularTo(vtZAxis);
|
||
}
|
||
|
||
BOOL ImpHvacCross::IsStartVertAlignment() const
|
||
{
|
||
// 获得法向量
|
||
AcGeVector3d vtStart, vtBr1;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
|
||
// 获得UCS坐标Z向量
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
|
||
return vtStart.isPerpendicularTo(vtZAxis);
|
||
}
|
||
|
||
BOOL ImpHvacCross::IsBr1VertAlignment() const
|
||
{
|
||
// 获得法向量
|
||
AcGeVector3d vtStart, vtBr1;
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
// 获得UCS坐标Z向量
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
|
||
return vtStart.isParallelTo(vtZAxis);
|
||
}
|
||
|
||
BOOL ImpHvacCross::IsSingleLine() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
BOOL bSingleLine = FALSE;
|
||
m_pXDataMap->GetAt(HVAC_IsSingleLine, (int&)bSingleLine);
|
||
|
||
return bSingleLine;
|
||
}
|
||
|
||
BOOL ImpHvacCross::HasBaseLine() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
BOOL bHasBaseLIne = FALSE;
|
||
m_pXDataMap->GetAt(HVAC_HasBaseLine, bHasBaseLIne);
|
||
|
||
return bHasBaseLIne;
|
||
}
|
||
|
||
AcGeVector3d ImpHvacCross::GetSectNormal() const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
// 获取四通各点位置
|
||
double dOffset = 0.0;
|
||
AcGeVector3d vtStart, vtBr1;
|
||
AcGeVector3d vtNormal = AcGeVector3d::kZAxis;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
AcGeVector3d vtTmp = vtStart.crossProduct(vtBr1);
|
||
vtTmp.normalize();
|
||
return vtTmp;
|
||
}
|
||
|
||
int ImpHvacCross::AbleConnect(AcGeLine3d line1, AcGeLine3d line2,double dTick1, double dThick2) const
|
||
{
|
||
double dMaxDis = fabs(dTick1 - dThick2) / 2.0;
|
||
AcGePoint3d ptInLine1, ptInLine2;
|
||
|
||
line1.projIntersectWith(line2, normal(), ptInLine1, ptInLine2);
|
||
double dDis = ptInLine1.distanceTo(ptInLine2);
|
||
if (dDis > dMaxDis)
|
||
return 0; // 不能生成四通
|
||
else if (dDis > 0.0)
|
||
return 1; // 中心线不等高,但可以生成四通
|
||
else if (dDis == 0.0)
|
||
return 2; // 中心线等高
|
||
else
|
||
return -1; // 失败
|
||
}
|
||
|
||
BOOL ImpHvacCross::IsValidConst() const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return FALSE;
|
||
|
||
AcGePoint3d ptStart, ptEnd, ptBr1, ptBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
|
||
AcGeVector3d vtNornal = normal();
|
||
AcGeVector3d vtStart, vtEnd, vtBr1, vtBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
|
||
double dSThick = 0, dEThick = 0, dBThick1 = 0, dBThick2 = 0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dSThick);
|
||
m_pXDataMap->GetAt(HCRS_EndThick, dEThick);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBThick1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBThick2);
|
||
|
||
AecHvac::HvacCrossType eTeeType(AecHvac::eOrthoCross);
|
||
AecHvac::HvacSectType eSectType(AecHvac::eRectangular);
|
||
m_pXDataMap->GetAt(HCRS_Type, (int &)eTeeType);
|
||
m_pXDataMap->GetAt(HVAC_SectType, (int &)eSectType);
|
||
BOOL bIsIntubCross = (eTeeType == AecHvac::eInsertCross || eTeeType == AecHvac::eInsertIntubCross
|
||
|| eTeeType == AecHvac::eArcuateIntubCross);
|
||
|
||
// 构造与四通接口方向一致的四条线
|
||
AcGePoint3d ptStartStart = ptStart - vtStart * 500;
|
||
AcGePoint3d ptStartEnd = ptStart + vtStart * 500;
|
||
AcGePoint3d ptEndStart = ptEnd - vtEnd * 500;
|
||
AcGePoint3d ptEndEnd = ptEnd + vtEnd * 500;
|
||
AcGePoint3d ptBr1Start = ptBr1 - vtBr1 * 500;
|
||
AcGePoint3d ptBr1End = ptBr1 + vtBr1 * 500;
|
||
AcGePoint3d ptBr2Start = ptBr2 - vtBr2 * 500;
|
||
AcGePoint3d ptBr2End = ptBr2 + vtBr2 * 500;
|
||
AcGeLine3d lineStart(ptStartStart, ptStartEnd);
|
||
AcGeLine3d lineEnd(ptEndStart, ptEndEnd);
|
||
AcGeLine3d lineBr1(ptBr1Start, ptBr1End);
|
||
AcGeLine3d lineBr2(ptBr2Start, ptBr2End);
|
||
|
||
AcGePlane planSta(ptStart, normal());
|
||
AcGePlane planEnd(ptEnd, normal());
|
||
AcGePoint3d ptInt;
|
||
|
||
if (!bIsIntubCross && (1e-6 < fabs(dSThick + dEThick - dBThick1 - dBThick2)
|
||
|| 1e-6 < fabs(dSThick + dBThick1 - dEThick - dBThick2)))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
if (!lineBr1.intersectWith(lineStart, ptInt))
|
||
{
|
||
if (eSectType == eRect && bIsIntubCross &&
|
||
1 == AbleConnect(lineStart, lineBr1, dSThick, dBThick1))
|
||
{
|
||
ptBr1Start = ptBr1Start.orthoProject(planSta);
|
||
ptBr1End = ptBr1End.orthoProject(planSta);
|
||
lineBr1.set(ptBr1Start, ptBr1End);
|
||
if (!lineStart.intersectWith(lineBr1, ptInt))
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
if (!lineBr1.intersectWith(lineEnd, ptInt))
|
||
{
|
||
if (eSectType == eRect && bIsIntubCross)
|
||
{
|
||
AcGePoint3d ptStartThirdCom = ptBr1Start;
|
||
AcGePoint3d ptEndThirdCom = ptBr1End;
|
||
ptStartThirdCom = ptStartThirdCom.orthoProject(planEnd);
|
||
ptEndThirdCom = ptEndThirdCom.orthoProject(planEnd);
|
||
AcGeLine3d lineThirdCom;
|
||
lineThirdCom.set(ptStartThirdCom, ptEndThirdCom);
|
||
if (!lineEnd.intersectWith(lineThirdCom, ptInt))
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
if (!lineBr2.intersectWith(lineStart, ptInt))
|
||
{
|
||
if (eSectType == eRect && bIsIntubCross
|
||
&& 1 == AbleConnect(lineStart, lineBr2, dSThick, dBThick2))
|
||
{
|
||
ptBr2Start = ptBr2Start.orthoProject(planSta);
|
||
ptBr2End = ptBr2End.orthoProject(planSta);
|
||
lineBr2.set(ptBr2Start, ptBr2End);
|
||
if (!lineStart.intersectWith(lineBr2, ptInt))
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
|
||
if (!lineBr2.intersectWith(lineEnd, ptInt))
|
||
{
|
||
if (eSectType == eRect && bIsIntubCross)
|
||
{
|
||
AcGePoint3d ptStartFourthCom = ptBr2Start;
|
||
AcGePoint3d ptEndFourthCom = ptBr2End;
|
||
ptStartFourthCom = ptStartFourthCom.orthoProject(planEnd);
|
||
ptEndFourthCom = ptEndFourthCom.orthoProject(planEnd);
|
||
AcGeLine3d lineThirdCom;
|
||
lineThirdCom.set(ptStartFourthCom, ptEndFourthCom);
|
||
if (!lineEnd.intersectWith(lineThirdCom, ptInt))
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
Acad::ErrorStatus ImpHvacCross::Draw3d(AcGiDraw &mode) const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return Acad::eNotImplementedYet;
|
||
|
||
int nColorIndexOld = mode.GetColor();
|
||
|
||
// 四通类型
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType, (int&)eSectType);
|
||
|
||
if (!IsValidConst() && eRect == eSectType)
|
||
{
|
||
DrawSpecial3d(mode);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
switch(eCrossType)
|
||
{
|
||
// 普通
|
||
case AecHvac::eOrthoCross:
|
||
DrawOrthoCross3d(mode);
|
||
break;
|
||
// 承插
|
||
case AecHvac::eInsertCross:
|
||
case AecHvac::eInsertIntubCross:
|
||
DrawInsertCross3d(mode);
|
||
break;
|
||
// 斜接
|
||
case AecHvac::eInclineCross:
|
||
DrawInclineCross3d(mode);
|
||
break;
|
||
// 圆角
|
||
case AecHvac::eArcuateCross:
|
||
case AecHvac::eArcuateIntubCross:
|
||
DrawArcuateCross3d(mode);
|
||
break;
|
||
// 直角
|
||
case AecHvac::eLinearCross:
|
||
DrawLinearCross3d(mode);
|
||
break;
|
||
// 交叉
|
||
case AecHvac::eInterCross:
|
||
DrawInterCross3d(mode);
|
||
break;
|
||
}
|
||
mode.SetColor(nColorIndexOld);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
BOOL ImpHvacCross::DrawMesh(AcGiDraw &mode,const Adesk::UInt32 rows,const Adesk::UInt32 columns,const AcGePoint3d* pVertexList) const
|
||
{
|
||
AcGePoint3dArray vertexArray;
|
||
AcArray<Adesk::Int32> faceArray;
|
||
|
||
int nV0 = 0,nV1 = 0,nV2 = 0;
|
||
int nV3= 0;
|
||
int nFaceIndex = 0;
|
||
AcGePoint3d ptFace[4];
|
||
|
||
for (int i = 0;i < rows - 1;i++)
|
||
{
|
||
for (int j = 0;j < columns - 1;j++)
|
||
{
|
||
nV0 = i * columns + j;
|
||
nV1 = nV0 + 1;
|
||
|
||
//第二行,第一个
|
||
nV2 = (i + 1) * columns + j;
|
||
|
||
nV3 = nV2 + 1;
|
||
|
||
//三角:nV0-nV1-nV2
|
||
faceArray.append(3);
|
||
faceArray.append(nV0);//v0
|
||
faceArray.append(nV1);//v1
|
||
faceArray.append(nV2);//v2
|
||
|
||
ptFace[0] = pVertexList[nV0];
|
||
ptFace[1] = pVertexList[nV1];
|
||
ptFace[2] = pVertexList[nV2];
|
||
ptFace[3] = ptFace[0];
|
||
//mode.DrawFace(ptFace);
|
||
|
||
//三角:nV2-nV1-nV3
|
||
faceArray.append(3);
|
||
faceArray.append(nV2);//v2
|
||
faceArray.append(nV1);//v1
|
||
faceArray.append(nV3);//v3
|
||
|
||
ptFace[0] = pVertexList[nV2];
|
||
ptFace[1] = pVertexList[nV1];
|
||
ptFace[2] = pVertexList[nV3];
|
||
ptFace[3] = ptFace[0];
|
||
//mode.DrawFace(ptFace);
|
||
}
|
||
}
|
||
|
||
if (!faceArray.isEmpty())
|
||
{
|
||
int nIndex = 0;
|
||
for (int i = 0;i < rows;i++)
|
||
{
|
||
for (int j = 0;j < columns;j++)
|
||
{
|
||
nIndex = i * columns + j;
|
||
vertexArray.append(pVertexList[nIndex]);
|
||
}
|
||
}
|
||
|
||
AcDbSubDMesh* pSubMesh = new AcDbSubDMesh;
|
||
if ( Acad::eOk == pSubMesh->setSubDMesh(vertexArray,faceArray,0) )
|
||
{
|
||
mode.DrawEntity(pSubMesh);
|
||
m_ar3DDrableBufPtrs_.append(pSubMesh);
|
||
|
||
//有时候失败?
|
||
/*Acad::ErrorStatus es;
|
||
AcDb3dSolid* pSolid = new AcDb3dSolid;
|
||
if ( Acad::eOk == (es = pSubMesh->convertToSolid(false,false,pSolid) ) )
|
||
{
|
||
mode.DrawEntity(pSolid);
|
||
}
|
||
delete pSubMesh;
|
||
*/
|
||
return TRUE;
|
||
}
|
||
delete pSubMesh;
|
||
}
|
||
|
||
mode.DrawMeshS(rows,columns,pVertexList,false);
|
||
return FALSE;
|
||
}
|
||
|
||
BOOL ImpHvacCross::DrawShell(AcGiDraw &mode,const Adesk::UInt32 nbVertex,const AcGePoint3d* pVertexList,const Adesk::UInt32 faceListSize,const Adesk::Int32* pFaceList) const
|
||
{
|
||
AcGePoint3dArray vertexArray;
|
||
AcArray<Adesk::Int32> faceArray;
|
||
|
||
for(int i = 0;i < nbVertex;i++)
|
||
{
|
||
vertexArray.append(pVertexList[i]);
|
||
}
|
||
for (int j = 0;j < faceListSize;j++)
|
||
{
|
||
faceArray.append(pFaceList[j]);
|
||
}
|
||
|
||
AcDbSubDMesh* pSubMesh = new AcDbSubDMesh;
|
||
if ( Acad::eOk == pSubMesh->setSubDMesh(vertexArray,faceArray,0) )
|
||
{
|
||
mode.DrawEntity(pSubMesh);
|
||
m_ar3DDrableBufPtrs_.append(pSubMesh);
|
||
|
||
//有时候失败?
|
||
/*Acad::ErrorStatus es;
|
||
AcDb3dSolid* pSolid = new AcDb3dSolid;
|
||
if ( Acad::eOk == (es = pSubMesh->convertToSolid(false,false,pSolid) ) )
|
||
{
|
||
mode.DrawEntity(pSolid);
|
||
}
|
||
delete pSubMesh;
|
||
*/
|
||
return TRUE;
|
||
}
|
||
delete pSubMesh;
|
||
|
||
mode.DrawShell(nbVertex,pVertexList,faceListSize,pFaceList);
|
||
return FALSE;
|
||
}
|
||
|
||
void ImpHvacCross::Move3DBuffer(AcDbVoidPtrArray& ar3DBuffer) const
|
||
{
|
||
if (!m_ar3DDrableBufPtrs_.isEmpty())
|
||
{
|
||
ar3DBuffer.append(m_ar3DDrableBufPtrs_);
|
||
m_ar3DDrableBufPtrs_.removeAll();
|
||
}
|
||
}
|
||
|
||
bool ImpHvacCross::Has3DBuffer() const
|
||
{
|
||
return !m_ar3DDrableBufPtrs_.isEmpty();
|
||
}
|
||
|
||
Acad::ErrorStatus ImpHvacCross::Draw2d(AcGiDraw &mode) const
|
||
{
|
||
if (m_pXDataMap == NULL)
|
||
{
|
||
return Acad::eNotImplementedYet;
|
||
}
|
||
|
||
AecComplexCurve cplCurve;
|
||
MakeCurves(cplCurve);
|
||
|
||
AecComplexCurveDraw edage;
|
||
edage.SetEdage(cplCurve);
|
||
|
||
BOOL bWeight = FALSE;
|
||
|
||
AcDbObjectId idReal = m_idDoubleLayer;
|
||
AcDbObjectId idDash = m_idDashLayer;
|
||
AcDbObjectId idCent = m_idCenterLayer;
|
||
|
||
edage.Draw2d(mode,idReal,idDash,idCent,NULL,bWeight,FALSE);
|
||
|
||
AecComplexCurve cplCen;
|
||
GetCurvesInSide(cplCen);
|
||
|
||
edage.SetEdage(cplCen);
|
||
edage.Draw2d(mode,idReal,idDash,idCent,NULL,bWeight,FALSE);
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
BOOL ImpHvacCross::MakeCurves(AecComplexCurve& cplCurve) const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return FALSE;
|
||
|
||
// 四通类型
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
|
||
int nIsSingleLine = 0;
|
||
m_pXDataMap->GetAt(HVAC_IsSingleLine, nIsSingleLine);
|
||
int nType = 0;
|
||
//单线形式直接return
|
||
if (1 == nIsSingleLine)
|
||
{
|
||
return FALSE;
|
||
}
|
||
switch(eCrossType)
|
||
{
|
||
// 普通
|
||
case AecHvac::eOrthoCross:
|
||
MakeOrthoCross2dCurves(cplCurve,nType);
|
||
break;
|
||
// 承插
|
||
case AecHvac::eInsertCross:
|
||
MakeInsertCross2dCurves(cplCurve,nType);
|
||
break;
|
||
// 承插(插管式)
|
||
case AecHvac::eInsertIntubCross:
|
||
MakeInsertCross2dCurves(cplCurve,nType, TRUE);
|
||
break;
|
||
// 斜接
|
||
case AecHvac::eInclineCross:
|
||
MakeInclineCross2dCurves(cplCurve,nType);
|
||
break;
|
||
// 圆角
|
||
case AecHvac::eArcuateCross:
|
||
MakeArcuateCross2dCurves(cplCurve,nType);
|
||
break;
|
||
// 圆角(插管)
|
||
case AecHvac::eArcuateIntubCross:
|
||
MakeArcuateCross2dCurves(cplCurve,nType, TRUE);
|
||
break;
|
||
// 直角
|
||
case AecHvac::eLinearCross:
|
||
MakeLinearCross2dCurves(cplCurve,nType);
|
||
break;
|
||
// 交叉
|
||
case AecHvac::eInterCross:
|
||
MakeInterCross2dCurves(cplCurve,nType);
|
||
break;
|
||
}
|
||
return cplCurve.length() > 0;
|
||
}
|
||
|
||
BOOL ImpHvacCross::GetCurvesInSide(AecComplexCurve& compCurve) const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return FALSE;
|
||
|
||
// 四通类型
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
int nType = 1;
|
||
switch(eCrossType)
|
||
{
|
||
// 普通
|
||
case AecHvac::eOrthoCross:
|
||
MakeOrthoCross2dCurves(compCurve,nType);
|
||
break;
|
||
// 承插
|
||
case AecHvac::eInsertCross:
|
||
case AecHvac::eInsertIntubCross:
|
||
MakeInsertCross2dCurves(compCurve,nType);
|
||
break;
|
||
// 斜接
|
||
case AecHvac::eInclineCross:
|
||
MakeInclineCross2dCurves(compCurve,nType);
|
||
break;
|
||
// 圆角
|
||
case AecHvac::eArcuateCross:
|
||
case AecHvac::eArcuateIntubCross:
|
||
MakeArcuateCross2dCurves(compCurve,nType);
|
||
break;
|
||
// 直角
|
||
case AecHvac::eLinearCross:
|
||
MakeLinearCross2dCurves(compCurve,nType);
|
||
break;
|
||
// 交叉
|
||
case AecHvac::eInterCross:
|
||
MakeInterCross2dCurves(compCurve,nType);
|
||
break;
|
||
}
|
||
return compCurve.length() > 0;
|
||
}
|
||
|
||
AecEqui::Position ImpHvacCross::ExplainGripIndex(int nIndex) const
|
||
{
|
||
AecEqui::Position ePos = AecEqui::eStart;
|
||
switch(nIndex)
|
||
{
|
||
case 0:
|
||
ePos = AecEqui::eStart;
|
||
break;
|
||
case 1:
|
||
ePos = AecEqui::eEnd;
|
||
break;
|
||
case 2:
|
||
ePos = AecEqui::eBr1;
|
||
break;
|
||
case 3:
|
||
ePos = AecEqui::eBr2;
|
||
break;
|
||
case 4:
|
||
ePos = AecEqui::eCommand0;
|
||
break;
|
||
case 5:
|
||
ePos = AecEqui::eCommand1;
|
||
break;
|
||
case 6:
|
||
ePos = AecEqui::eCommand2;
|
||
break;
|
||
case 7:
|
||
ePos = AecEqui::eCommand3;
|
||
}
|
||
return ePos;
|
||
}
|
||
|
||
Acad::ErrorStatus ImpHvacCross::transformBy(const AcGeMatrix3d& xform)
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return Acad::eNotApplicable;
|
||
|
||
// 获取四通各点位置
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
|
||
// 变换位置
|
||
ptStart.transformBy(xform);
|
||
ptEnd.transformBy(xform);
|
||
ptBr1.transformBy(xform);
|
||
ptBr2.transformBy(xform);
|
||
|
||
vtStart.transformBy(xform);
|
||
vtEnd.transformBy(xform);
|
||
vtBr1.transformBy(xform);
|
||
vtBr2.transformBy(xform);
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
|
||
// 设置尺寸
|
||
double dScale = xform.scale();
|
||
double dStaWidth(0.0), dEndWidth(0.), dThick(0.0), dBran1Width(0.0),
|
||
dBran2Width(0.0), dBran1Thick(0.0), dBran2Thick(0.0);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dStaWidth);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEndWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBran1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBran2Width);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBran1Thick);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBran1Thick);
|
||
|
||
dStaWidth *= dScale;
|
||
dEndWidth *= dScale;
|
||
dBran1Width *= dScale;
|
||
dBran2Width *= dScale;
|
||
dThick *= dScale;
|
||
dBran1Thick *= dScale;
|
||
dBran2Thick *= dScale;
|
||
|
||
m_pXDataMap->SetAt(HCRS_StartWidth, dStaWidth);
|
||
m_pXDataMap->SetAt(HCRS_EndWidth, dEndWidth);
|
||
m_pXDataMap->SetAt(HCRS_Branch1Width, dBran1Width);
|
||
m_pXDataMap->SetAt(HCRS_Branch2Width, dBran2Width);
|
||
m_pXDataMap->SetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->SetAt(HCRS_Branch1Thick, dBran1Thick);
|
||
m_pXDataMap->SetAt(HCRS_Branch2Thick, dBran1Thick);
|
||
|
||
// 更新点
|
||
m_pXDataMap->SetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->SetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->SetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->SetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->SetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->SetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->SetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->SetAt(HCRS_BranchDir2, vtBr2);
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus ImpHvacCross::getStretchPoints(AcGePoint3dArray& stretchPoints) const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return Acad::eNotApplicable;
|
||
|
||
// 取得位置点
|
||
AcGePoint3d ptStart, ptEnd, ptBr1, ptBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
|
||
stretchPoints.append(ptStart);
|
||
stretchPoints.append(ptEnd);
|
||
stretchPoints.append(ptBr1);
|
||
stretchPoints.append(ptBr2);
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus ImpHvacCross::getGripPoints(AcGePoint3dArray& gripPoints,
|
||
AcDbIntArray& osnapModes,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return Acad::eNotApplicable;
|
||
|
||
// 获取四通各点位置
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
|
||
//夹点
|
||
gripPoints.append(ptStart);
|
||
gripPoints.append(ptEnd);
|
||
gripPoints.append(ptBr1);
|
||
gripPoints.append(ptBr2);
|
||
|
||
|
||
//增加4个命令夹点
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
|
||
gripPoints.append(ptStart + vtStart * g_dCmdOff); //cmd0
|
||
gripPoints.append(ptEnd + vtEnd * g_dCmdOff); //cmd1
|
||
gripPoints.append(ptBr1 + vtBr1 * g_dCmdOff); //cmd2
|
||
gripPoints.append(ptBr2 + vtBr2 * g_dCmdOff); //cmd3
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus ImpHvacCross::getOsnapPoints(AcDb::OsnapMode osnapMode,
|
||
INT_PTR gsSelectionMark,
|
||
const AcGePoint3d& pickPoint,
|
||
const AcGePoint3d& lastPoint,
|
||
const AcGeMatrix3d& viewXform,
|
||
AcGePoint3dArray& snapPoints,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return Acad::eNotApplicable;
|
||
|
||
// 获取四通各点位置
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
|
||
// 根据捕捉模式处理
|
||
switch(osnapMode)
|
||
{
|
||
case AcDb::kOsModeEnd:
|
||
snapPoints.append(ptStart);
|
||
snapPoints.append(ptEnd);
|
||
snapPoints.append(ptBr1);
|
||
snapPoints.append(ptBr2);
|
||
break;
|
||
case AcDb::kOsModeMid:
|
||
break;
|
||
case AcDb::kOsModeCen:
|
||
break;
|
||
case AcDb::kOsModePerp:
|
||
break;
|
||
case AcDb::kOsModeNear:
|
||
break;
|
||
}
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
|
||
// 7━━━━━6
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// 0━━━━┛ ┃ ┗━━━━5
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ━━━━━━━━━━━━━━━━
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// 1━━━━┓ ┃ ┏━━━━4
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// 2━━━━━3
|
||
BOOL ImpHvacCross::DrawSpecial3d(AcGiDraw &mode) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
AcGePoint3dArray arptUp, arptDown;
|
||
if (!GetInterfaceKeyPt(arptUp, arptDown))
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
// 上面
|
||
AcGePoint3d ptArUpPoly[4] = {arptUp[0], arptUp[1], arptUp[5], arptUp[4]};
|
||
// 下面
|
||
AcGePoint3d ptArDownPoly[4] = {arptDown[0], arptDown[1], arptDown[5], arptDown[4]};
|
||
// 支管1左侧
|
||
AcGePoint3d ptArBranLeft1[4] = {arptUp[1], arptDown[1], arptUp[2], arptDown[2]};
|
||
// 支管1右侧
|
||
AcGePoint3d ptArBranRight1[4] = {arptUp[3], arptDown[3], arptUp[4], arptDown[4]};
|
||
// 支管1上
|
||
AcGePoint3d ptArBranUp1[4] = {arptUp[1], arptUp[2], arptUp[4], arptUp[3]};
|
||
// 支管1下
|
||
AcGePoint3d ptArBranDown1[4] = {arptDown[1], arptDown[2], arptDown[4], arptDown[3]};
|
||
// 支管2左侧
|
||
AcGePoint3d ptArBranLeft2[4] = {arptUp[5], arptDown[5], arptUp[6], arptDown[6]};
|
||
// 支管2右侧
|
||
AcGePoint3d ptArBranRight2[4] = {arptUp[7], arptDown[7], arptUp[0], arptDown[0]};
|
||
// 支管2上
|
||
AcGePoint3d ptArBranUp2[4] = {arptUp[5], arptUp[6], arptUp[0], arptUp[7]};
|
||
// 支管2下
|
||
AcGePoint3d ptArBranDown2[4] = {arptDown[5], arptDown[6], arptDown[0], arptDown[7]};
|
||
|
||
DrawMesh(mode,2, 2, ptArUpPoly);
|
||
DrawMesh(mode,2, 2, ptArDownPoly);
|
||
DrawMesh(mode,2, 2, ptArBranLeft1);
|
||
DrawMesh(mode,2, 2, ptArBranRight1);
|
||
DrawMesh(mode,2, 2, ptArBranUp1);
|
||
DrawMesh(mode,2, 2, ptArBranDown1);
|
||
DrawMesh(mode,2, 2, ptArBranLeft2);
|
||
DrawMesh(mode,2, 2, ptArBranRight2);
|
||
DrawMesh(mode,2, 2, ptArBranUp2);
|
||
DrawMesh(mode,2, 2, ptArBranDown2);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
//3维模型
|
||
void ImpHvacCross::DrawOrthoCross3d(AcGiDraw &mode) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
//方截面
|
||
if (eSectType == eRect)
|
||
{
|
||
double dThick = 200.0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
AcGePoint3dArray arPts,arPtsU,arPtsD,arptSides;
|
||
GetCrossPts(arPts,FALSE,TRUE);
|
||
AcGeMatrix3d mat;
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
//从第8个点开始把所有点向下偏移半个厚度
|
||
for (int i = 8; i < arPts.length(); i++)
|
||
{
|
||
arPtsU.append(arPts[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat.setToTranslation(vtNor);
|
||
//从第8个点开始把所有点向上偏移半个厚度
|
||
for (i = 8; i < arPts.length(); i++)
|
||
{
|
||
arPtsD.append(arPts[i].transformBy(mat));
|
||
}
|
||
//开始面
|
||
arptSides.append(arPtsU[0]);
|
||
arptSides.append(arPtsU[11]);
|
||
arptSides.append(arPtsD[11]);
|
||
arptSides.append(arPtsD[0]);
|
||
arptSides.append(arPtsU[0]);
|
||
//交点面S
|
||
arptSides.append(arPtsU[1]);
|
||
arptSides.append(arPtsU[10]);
|
||
arptSides.append(arPtsD[10]);
|
||
arptSides.append(arPtsD[1]);
|
||
arptSides.append(arPtsU[1]);
|
||
//交点面E
|
||
arptSides.append(arPtsU[4]);
|
||
arptSides.append(arPtsU[7]);
|
||
arptSides.append(arPtsD[7]);
|
||
arptSides.append(arPtsD[4]);
|
||
arptSides.append(arPtsU[4]);
|
||
//末点面
|
||
arptSides.append(arPtsU[5]);
|
||
arptSides.append(arPtsU[6]);
|
||
arptSides.append(arPtsD[6]);
|
||
arptSides.append(arPtsD[5]);
|
||
arptSides.append(arPtsU[5]);
|
||
DrawMesh(mode,4, 5, arptSides.asArrayPtr());
|
||
|
||
arptSides.setLogicalLength(0);
|
||
//Br1面
|
||
arptSides.append(arPtsU[2]);
|
||
arptSides.append(arPtsU[3]);
|
||
arptSides.append(arPtsD[3]);
|
||
arptSides.append(arPtsD[2]);
|
||
arptSides.append(arPtsU[2]);
|
||
//交点面Br1
|
||
arptSides.append(arPtsU[1]);
|
||
arptSides.append(arPtsU[4]);
|
||
arptSides.append(arPtsD[4]);
|
||
arptSides.append(arPtsD[1]);
|
||
arptSides.append(arPtsU[1]);
|
||
DrawMesh(mode,2, 5, arptSides.asArrayPtr());
|
||
|
||
arptSides.setLogicalLength(0);
|
||
//Br2面
|
||
arptSides.append(arPtsU[8]);
|
||
arptSides.append(arPtsU[9]);
|
||
arptSides.append(arPtsD[9]);
|
||
arptSides.append(arPtsD[8]);
|
||
arptSides.append(arPtsU[8]);
|
||
//交点面Br2
|
||
arptSides.append(arPtsU[7]);
|
||
arptSides.append(arPtsU[10]);
|
||
arptSides.append(arPtsD[10]);
|
||
arptSides.append(arPtsD[7]);
|
||
arptSides.append(arPtsU[7]);
|
||
DrawMesh(mode,2, 5, arptSides.asArrayPtr());
|
||
}
|
||
//圆截面
|
||
else if (eSectType == eCircle)
|
||
{
|
||
AcGePoint3dArray arPts,arPtsU,arPtsD,arptSides;
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dThick = 200.0, dBr1Width = 300.0, dBr2Width = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
|
||
double dMinDiffAng = TAuxTools::GetMinDiffAngle();
|
||
//按照90°弯头分成nSect1个圆截面,每个圆截面分成nSect个点
|
||
int nSect = int(PI * 2 / dMinDiffAng);
|
||
AcGeVector3d vtNor;
|
||
vtNor = vtStart.crossProduct(vtBr1);
|
||
vtNor.normalize();
|
||
//Start到End点
|
||
AcGePoint3d pt, ptInter;
|
||
pt = ptStart + vtNor * dSWidth * 0.5;
|
||
for (int i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtStart,ptStart));
|
||
}
|
||
pt = ptEnd + vtNor * dEWidth * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtStart,ptEnd));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
|
||
//Br1
|
||
arptSides.setLogicalLength(0);
|
||
pt = ptBr1 + vtNor * dBr1Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr1,ptBr1));
|
||
}
|
||
GetIntersectWith(ptStart, ptBr1, vtStart, vtBr1, ptInter);
|
||
pt = ptInter + vtNor * dBr1Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr1,ptInter));
|
||
}
|
||
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
//Br2
|
||
arptSides.setLogicalLength(0);
|
||
pt = ptBr2 + vtNor * dBr2Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr2,ptBr2));
|
||
}
|
||
GetIntersectWith(ptStart, ptBr2, vtStart, vtBr2, ptInter);
|
||
pt = ptInter + vtNor * dBr2Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr2,ptInter));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
}
|
||
}
|
||
|
||
// 承插
|
||
void ImpHvacCross::DrawInsertCross3d(AcGiDraw &mode) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
|
||
AcGeVector3d vtStart = AcGeVector3d::kIdentity;
|
||
AcGeVector3d vtBr1 = AcGeVector3d::kIdentity;
|
||
AcGeVector3d vtBr2 = AcGeVector3d::kIdentity;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
|
||
AcGeVector3d vtEnd = AcGeVector3d::kIdentity;
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
|
||
// 矩形口
|
||
if (eSectType == eRect)
|
||
{
|
||
double dThick = 200.0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
|
||
double dThickSub = 200.0;
|
||
if (!m_pXDataMap->GetAt(KEY_EndThick, dThickSub))
|
||
{
|
||
dThickSub = dThick;
|
||
}
|
||
|
||
double dBrThick1 = 0.0;
|
||
double dBrThick2 = 0.0;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBrThick1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBrThick2);
|
||
AcGePoint3d ptSta, ptBran1, ptBran2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptSta);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBran1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBran2);
|
||
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
AcGePlane planSta(ptSta, vtNor);
|
||
|
||
AcGePoint3d ptEnd;
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
AcGePlane planEnd(ptEnd, vtNor);
|
||
|
||
AcGePlane planBr1(ptBran1, vtNor);
|
||
AcGePlane planBr2(ptBran2, vtNor);
|
||
|
||
AcGePoint3dArray arPts,arPtsU,arPtsD,arptSides;
|
||
|
||
GetCrossPts(arPts,FALSE,TRUE);
|
||
|
||
// ?÷ì?μ?
|
||
AcGePoint3dArray arPtsMajor, arPtsBr;
|
||
arPtsMajor.append(arPts[8]);
|
||
AcGePoint3d ptTmp = AcGePoint3d::kOrigin;
|
||
ptTmp = arPts[8] - vtStart * 50.0;
|
||
arPtsMajor.append(ptTmp);
|
||
ptTmp = arPts[12];
|
||
ptTmp = ptTmp.orthoProject(planSta);
|
||
arPtsMajor.append(ptTmp);
|
||
arPtsMajor.append(arPts[13]);
|
||
arPtsMajor.append(arPts[14]);
|
||
ptTmp = arPts[15];
|
||
ptTmp = ptTmp.orthoProject(planSta);
|
||
arPtsMajor.append(ptTmp);
|
||
ptTmp = arPts[19] - vtStart * 50.0;
|
||
arPtsMajor.append(ptTmp);
|
||
arPtsMajor.append(arPts[19]);
|
||
|
||
// ·??§μ?
|
||
arPtsBr.append(arPts[11]);
|
||
ptTmp = arPts[11] - vtBr1 * 50.0;
|
||
arPtsBr.append(ptTmp);
|
||
arPtsBr.append(arPts[12]);
|
||
ptTmp = arPts[8] - vtStart * 50.0;
|
||
ptTmp = ptTmp.orthoProject(planBr1);
|
||
arPtsBr.append(ptTmp);
|
||
ptTmp = arPts[10] - vtBr1 * 50.0;
|
||
arPtsBr.append(ptTmp);
|
||
arPtsBr.append(arPts[10]);
|
||
|
||
arPtsBr.append(arPts[17]);
|
||
ptTmp = arPts[17] - vtBr2 * 50.0;
|
||
arPtsBr.append(ptTmp);
|
||
ptTmp = arPts[19] - vtStart * 50.0;
|
||
ptTmp = ptTmp.orthoProject(planBr2);
|
||
arPtsBr.append(ptTmp);
|
||
arPtsBr.append(arPts[15]);
|
||
ptTmp = arPts[16] - vtBr2 * 50.0;
|
||
arPtsBr.append(ptTmp);
|
||
arPtsBr.append(arPts[16]);
|
||
|
||
AcGeMatrix3d mat;
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
|
||
AcGeMatrix3d matSub;
|
||
vtNor.normalize();
|
||
vtNor *= dThickSub * 0.5;
|
||
matSub.setToTranslation(vtNor);
|
||
|
||
int i = 0;
|
||
AcGePoint3dArray arPtsMajorU, arPtsMajorD;
|
||
for (i = 0; i < arPtsMajor.length(); i++)
|
||
{
|
||
if (2 == i || 5 == i || 3 == i || 4 == i)
|
||
{
|
||
arPtsMajor[i] = arPtsMajor[i].orthoProject(planEnd);
|
||
arPtsMajorU.append(arPtsMajor[i].transformBy(matSub));
|
||
}
|
||
else
|
||
{
|
||
arPtsMajorU.append(arPtsMajor[i].transformBy(mat));
|
||
}
|
||
|
||
}
|
||
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat.setToTranslation(vtNor);
|
||
|
||
vtNor.normalize();
|
||
vtNor *= dThickSub;
|
||
matSub.setToTranslation(vtNor);
|
||
|
||
for (i = 0; i < arPtsMajor.length(); i++)
|
||
{
|
||
if (2 == i || 5 == i || 3 == i || 4 == i)
|
||
{
|
||
arPtsMajorD.append(arPtsMajor[i].transformBy(matSub));
|
||
}
|
||
else
|
||
{
|
||
arPtsMajorD.append(arPtsMajor[i].transformBy(mat));
|
||
}
|
||
}
|
||
|
||
arptSides.append(arPtsMajorU[0]);
|
||
arptSides.append(arPtsMajorU[7]);
|
||
arptSides.append(arPtsMajorD[7]);
|
||
arptSides.append(arPtsMajorD[0]);
|
||
arptSides.append(arPtsMajorU[0]);
|
||
|
||
arptSides.append(arPtsMajorU[1]);
|
||
arptSides.append(arPtsMajorU[6]);
|
||
arptSides.append(arPtsMajorD[6]);
|
||
arptSides.append(arPtsMajorD[1]);
|
||
arptSides.append(arPtsMajorU[1]);
|
||
|
||
arptSides.append(arPtsMajorU[2]);
|
||
arptSides.append(arPtsMajorU[5]);
|
||
arptSides.append(arPtsMajorD[5]);
|
||
arptSides.append(arPtsMajorD[2]);
|
||
arptSides.append(arPtsMajorU[2]);
|
||
|
||
arptSides.append(arPtsMajorU[3]);
|
||
arptSides.append(arPtsMajorU[4]);
|
||
arptSides.append(arPtsMajorD[4]);
|
||
arptSides.append(arPtsMajorD[3]);
|
||
arptSides.append(arPtsMajorU[3]);
|
||
|
||
DrawMesh(mode,4, 5, arptSides.asArrayPtr());
|
||
arptSides.setLogicalLength(0);
|
||
|
||
AcGePoint3dArray arPtBrU, arPtBrD;
|
||
vtNor.normalize();
|
||
vtNor *= dBrThick1 * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
for (i = 0; i < 6; i++)
|
||
{
|
||
arPtBrU.append(arPtsBr[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= -dBrThick1;
|
||
mat.setToTranslation(vtNor);
|
||
for (i = 0; i < 6; i++)
|
||
{
|
||
arPtBrD.append(arPtsBr[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= dBrThick2 * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
for (i = 6; i < 12; i++)
|
||
{
|
||
arPtBrU.append(arPtsBr[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= -dBrThick2;
|
||
mat.setToTranslation(vtNor);
|
||
for (i = 6; i < 12; i++)
|
||
{
|
||
arPtBrD.append(arPtsBr[i].transformBy(mat));
|
||
}
|
||
|
||
arptSides.append(arPtBrU[0]);
|
||
arptSides.append(arPtBrU[5]);
|
||
arptSides.append(arPtBrD[5]);
|
||
arptSides.append(arPtBrD[0]);
|
||
arptSides.append(arPtBrU[0]);
|
||
|
||
arptSides.append(arPtBrU[1]);
|
||
arptSides.append(arPtBrU[4]);
|
||
arptSides.append(arPtBrD[4]);
|
||
arptSides.append(arPtBrD[1]);
|
||
arptSides.append(arPtBrU[1]);
|
||
|
||
arptSides.append(arPtBrU[2]);
|
||
arptSides.append(arPtBrU[3]);
|
||
arptSides.append(arPtBrD[3]);
|
||
arptSides.append(arPtBrD[2]);
|
||
arptSides.append(arPtBrU[2]);
|
||
DrawMesh(mode,3, 5, arptSides.asArrayPtr());
|
||
|
||
arptSides.setLogicalLength(0);
|
||
|
||
arptSides.append(arPtBrU[6]);
|
||
arptSides.append(arPtBrU[11]);
|
||
arptSides.append(arPtBrD[11]);
|
||
arptSides.append(arPtBrD[6]);
|
||
arptSides.append(arPtBrU[6]);
|
||
|
||
arptSides.append(arPtBrU[7]);
|
||
arptSides.append(arPtBrU[10]);
|
||
arptSides.append(arPtBrD[10]);
|
||
arptSides.append(arPtBrD[7]);
|
||
arptSides.append(arPtBrU[7]);
|
||
|
||
arptSides.append(arPtBrU[8]);
|
||
arptSides.append(arPtBrU[9]);
|
||
arptSides.append(arPtBrD[9]);
|
||
arptSides.append(arPtBrD[8]);
|
||
arptSides.append(arPtBrU[8]);
|
||
|
||
DrawMesh(mode,3, 5, arptSides.asArrayPtr());
|
||
}
|
||
if (eSectType == eCircle)
|
||
{
|
||
DrawOrthoCross3d(mode);
|
||
}
|
||
}
|
||
|
||
// 斜接
|
||
void ImpHvacCross::DrawInclineCross3d(AcGiDraw &mode) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType, (int&)eSectType);
|
||
if (eSectType == eRect)
|
||
{
|
||
// 矩形口三维画法与圆角类型类似,
|
||
// 稍作修改后直接调用圆角类型的三维绘制函数
|
||
DrawArcuateCross3d(mode);
|
||
}
|
||
else if (eSectType == eCircle)
|
||
{
|
||
AcGePoint3dArray arPts;
|
||
if (!GetInclineCirPts(arPts))
|
||
return;
|
||
|
||
AcGePoint3dArray arPtsU,arPtsD,arptSides;
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dThick = 200.0, dBr1Width = 300.0, dBr2Width = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
|
||
double dMinDiffAng = TAuxTools::GetMinDiffAngle();
|
||
//按照90°弯头分成nSect1个圆截面,每个圆截面分成nSect个点
|
||
int nSect = int(PI * 2 / dMinDiffAng);
|
||
AcGeVector3d vtNor;
|
||
vtNor = vtStart.crossProduct(vtBr1);
|
||
vtNor.normalize();
|
||
// 主管
|
||
AcGeVector3d vtM = arPts[12] - arPts[15];
|
||
vtM.normalize();
|
||
AcGePoint3d pt = arPts[12] + vtNor * dSWidth * 0.5;
|
||
for (int i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtM,arPts[12]));
|
||
}
|
||
pt = arPts[15] + vtNor * dEWidth * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtM,arPts[15]));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
|
||
// 主管直边
|
||
arptSides.setLogicalLength(0);
|
||
pt = arPts[0] + vtNor * dSWidth * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtStart,arPts[0]));
|
||
}
|
||
pt = arPts[12] + vtNor * dSWidth * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtStart,arPts[12]));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
|
||
arptSides.setLogicalLength(0);
|
||
pt = arPts[3] + vtNor * dEWidth * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtEnd,arPts[3]));
|
||
}
|
||
pt = arPts[15] + vtNor * dEWidth * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtEnd,arPts[15]));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
|
||
|
||
|
||
// 支管2
|
||
arptSides.setLogicalLength(0);
|
||
pt = arPts[21] + vtNor * dBr2Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr2,arPts[21]));
|
||
}
|
||
AcGeVector3d vtD = arPts[25] - arPts[23];
|
||
vtD.normalize();
|
||
AcGePoint3d ptTmp = arPts[23] + vtD * arPts[14].distanceTo(arPts[22]);
|
||
AcGeVector3d vtTmp = arPts[14] - ptTmp;
|
||
vtTmp.normalize();
|
||
ptTmp = ptTmp + vtTmp * arPts[14].distanceTo(ptTmp) / 2.0;
|
||
|
||
pt = ptTmp + vtNor * arPts[14].distanceTo(ptTmp);
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng, vtBr2, ptTmp));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1, arptSides.asArrayPtr());
|
||
|
||
// 支管2直边
|
||
arptSides.setLogicalLength(0);
|
||
pt = arPts[9] + vtNor * dBr2Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr2,arPts[9]));
|
||
}
|
||
pt = arPts[21] + vtNor * dBr2Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr2,arPts[21]));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1, arptSides.asArrayPtr());
|
||
|
||
// 支管1
|
||
arptSides.setLogicalLength(0);
|
||
pt = arPts[18] + vtNor * dBr1Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr1,arPts[18]));
|
||
}
|
||
vtD = arPts[24] - arPts[19];
|
||
vtD.normalize();
|
||
ptTmp = arPts[19] + vtD * arPts[13].distanceTo(arPts[20]);
|
||
vtTmp = arPts[13] - ptTmp;
|
||
vtTmp.normalize();
|
||
ptTmp = ptTmp + vtTmp * arPts[13].distanceTo(ptTmp) / 2.0;
|
||
pt = ptTmp + vtNor * arPts[13].distanceTo(ptTmp);
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng, vtBr1, ptTmp));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
|
||
// 支管1直边
|
||
arptSides.setLogicalLength(0);
|
||
pt = arPts[6] + vtNor * dBr1Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr1,arPts[6]));
|
||
}
|
||
pt = arPts[18] + vtNor * dBr1Width * 0.5;
|
||
for (i = 0; i <= nSect; i++)
|
||
{
|
||
arptSides.append(pt.rotateBy(dMinDiffAng,vtBr1,arPts[18]));
|
||
}
|
||
DrawMesh(mode,2, nSect + 1 , arptSides.asArrayPtr());
|
||
}
|
||
}
|
||
|
||
// 圆角
|
||
void ImpHvacCross::DrawArcuateCross3d(AcGiDraw &mode) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
double dThick = 200.0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
|
||
double dThickSub = 200.0;
|
||
if (!m_pXDataMap->GetAt(KEY_EndThick, dThickSub))
|
||
{
|
||
dThickSub = dThick;
|
||
}
|
||
|
||
double dBran1Thick = 200.0, dBran2Thick = 200.0;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBran1Thick);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBran2Thick);
|
||
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
AcGePoint3dArray arPts, arPts1, arPts2, arPts3, arPts4, arPtsU, arPtsD, arptSides;
|
||
GetArcuateCrossPts(arPts);
|
||
|
||
AecHvac::HvacCrossType eType = AecHvac::eArcuateCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eType);
|
||
double dMinDiffAng = TAuxTools::GetMinDiffAngle();
|
||
|
||
if (eType == AecHvac::eArcuateIntubCross) // 插管圆角
|
||
{
|
||
AcGePoint3d ptSta, ptBr1, ptBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptSta);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
|
||
AcGePlane planSta(ptSta, vtNor);
|
||
|
||
AcGePoint3d ptEnd;
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
AcGePlane planEnd(ptEnd, vtNor);
|
||
|
||
AcGePlane planBr1(ptBr1, vtNor);
|
||
AcGePlane planBr2(ptBr2, vtNor);
|
||
|
||
arPts1.append(arPts[3]);
|
||
AcGeCircArc3d circArc(arPts[3], arPts[28], arPts[11]);
|
||
AcGeVector3d vts, vte;
|
||
vts = circArc.center() - arPts[3];
|
||
vte = circArc.center() - arPts[11];
|
||
double dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle;
|
||
}
|
||
|
||
int nSect = int(dAngle / dMinDiffAng);
|
||
AcGePoint3d pt;
|
||
pt = arPts[3];
|
||
int i = 0;
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts1.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
arPts1.append(arPts[11]);
|
||
arPts1.append(arPts[8]);
|
||
|
||
arPts2.append(arPts[7]);
|
||
arPts2.append(arPts[9]);
|
||
circArc.set(arPts[9], arPts[30], arPts[29]);
|
||
vts = circArc.center() - arPts[9];
|
||
vte = circArc.center() - arPts[29];
|
||
dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle ;
|
||
}
|
||
nSect = int(dAngle / dMinDiffAng);
|
||
pt = arPts[9];
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts2.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
arPts2.append(arPts[29]);
|
||
|
||
arptSides.append(arPts1);
|
||
arptSides.append(arPts2);
|
||
|
||
int nSize = arptSides.length();
|
||
|
||
AcGeMatrix3d mat1,mat2;
|
||
AcArray<Adesk::Int32> arlFaceList;
|
||
arlFaceList.append(nSize);
|
||
vtNor.normalize();
|
||
vtNor *= dBran1Thick * 0.5;
|
||
mat1.setToTranslation(vtNor);
|
||
vtNor.normalize();
|
||
vtNor *= -dBran1Thick;
|
||
mat2.setToTranslation(vtNor);
|
||
//所有点向上偏移半个厚度
|
||
for (i = 0; i < nSize; i++)
|
||
{
|
||
arPtsU.append(arptSides[i].transformBy(mat1));
|
||
arPtsD.append(arptSides[i].transformBy(mat2));
|
||
arlFaceList.append(i);
|
||
}
|
||
DrawShell(mode,nSize, arPtsU.asArrayPtr(), nSize + 1, arlFaceList.asArrayPtr());
|
||
DrawShell(mode,nSize, arPtsD.asArrayPtr(), nSize + 1, arlFaceList.asArrayPtr());
|
||
|
||
//侧面的面
|
||
for (int j = 0; j < 2; j++)
|
||
{
|
||
arptSides.setLogicalLength(0);
|
||
arPtsU.setLogicalLength(0);
|
||
arPtsD.setLogicalLength(0);
|
||
AcGePoint3dArray arPtsKK;
|
||
switch(j)
|
||
{
|
||
case 0:
|
||
arPtsKK.append(arPts1);
|
||
break;
|
||
case 1:
|
||
arPtsKK.append(arPts2);
|
||
break;
|
||
case 2:
|
||
arPtsKK.append(arPts3);
|
||
break;
|
||
case 3:
|
||
arPtsKK.append(arPts4);
|
||
break;
|
||
}
|
||
for (i = 0; i < arPtsKK.length(); i++)
|
||
{
|
||
arPtsU.append(arPtsKK[i].transformBy(mat1));
|
||
arPtsD.append(arPtsKK[i].transformBy(mat2));
|
||
}
|
||
arptSides.append(arPtsU);
|
||
arptSides.append(arPtsD);
|
||
DrawMesh(mode,2, arPtsU.length(), arptSides.asArrayPtr());
|
||
}
|
||
|
||
//右下角的各个点
|
||
arPts3.append(arPts[32]);
|
||
circArc.set(arPts[32], arPts[33], arPts[23]);
|
||
vts = circArc.center() - arPts[32];
|
||
vte = circArc.center() - arPts[23];
|
||
dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle ;
|
||
}
|
||
nSect = int(dAngle / dMinDiffAng);
|
||
pt = arPts[32];
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts3.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
arPts3.append(arPts[23]);
|
||
arPts3.append(arPts[20]);
|
||
|
||
//左下下角的各个点
|
||
arPts4.append(arPts[19]);
|
||
arPts4.append(arPts[21]);
|
||
if (eType == AecHvac::eArcuateCross || eType == AecHvac::eArcuateIntubCross)
|
||
{
|
||
circArc.set(arPts[21], arPts[31], arPts[5]);
|
||
vts = circArc.center() - arPts[21];
|
||
vte = circArc.center() - arPts[5];
|
||
dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle ;
|
||
}
|
||
nSect = int(dAngle / dMinDiffAng);
|
||
pt = arPts[21];
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts4.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
}
|
||
arPts4.append(arPts[5]);
|
||
|
||
arptSides.setLogicalLength(0);
|
||
arptSides.append(arPts3);
|
||
arptSides.append(arPts4);
|
||
|
||
nSize = arptSides.length();
|
||
|
||
arlFaceList.setLogicalLength(0);
|
||
arlFaceList.append(nSize);
|
||
vtNor.normalize();
|
||
vtNor *= dBran2Thick * 0.5;
|
||
mat1.setToTranslation(vtNor);
|
||
vtNor.normalize();
|
||
vtNor *= -dBran2Thick;
|
||
mat2.setToTranslation(vtNor);
|
||
arPtsU.setLogicalLength(0);
|
||
arPtsD.setLogicalLength(0);
|
||
|
||
//所有点向上偏移半个厚度
|
||
for (i = 0; i < nSize; i++)
|
||
{
|
||
arPtsU.append(arptSides[i].transformBy(mat1));
|
||
arPtsD.append(arptSides[i].transformBy(mat2));
|
||
arlFaceList.append(i);
|
||
}
|
||
DrawShell(mode,nSize, arPtsU.asArrayPtr(), nSize + 1, arlFaceList.asArrayPtr());
|
||
DrawShell(mode,nSize, arPtsD.asArrayPtr(), nSize + 1, arlFaceList.asArrayPtr());
|
||
|
||
//侧面的面
|
||
for (j = 2; j < 4; j++)
|
||
{
|
||
arptSides.setLogicalLength(0);
|
||
arPtsU.setLogicalLength(0);
|
||
arPtsD.setLogicalLength(0);
|
||
AcGePoint3dArray arPtsKK;
|
||
switch(j)
|
||
{
|
||
case 0:
|
||
arPtsKK.append(arPts1);
|
||
break;
|
||
case 1:
|
||
arPtsKK.append(arPts2);
|
||
break;
|
||
case 2:
|
||
arPtsKK.append(arPts3);
|
||
break;
|
||
case 3:
|
||
arPtsKK.append(arPts4);
|
||
break;
|
||
}
|
||
for (i = 0; i < arPtsKK.length(); i++)
|
||
{
|
||
arPtsU.append(arPtsKK[i].transformBy(mat1));
|
||
arPtsD.append(arPtsKK[i].transformBy(mat2));
|
||
}
|
||
arptSides.append(arPtsU);
|
||
arptSides.append(arPtsD);
|
||
DrawMesh(mode,2, arPtsU.length(), arptSides.asArrayPtr());
|
||
}
|
||
|
||
arptSides.setLogicalLength(0);
|
||
arptSides.append(arPts[1]);
|
||
AcGePoint3d ptProj = arPts[3];
|
||
ptProj = ptProj.orthoProject(planSta);
|
||
arptSides.append(ptProj);
|
||
ptProj = arPts[29];
|
||
|
||
ptProj = ptProj.orthoProject(planEnd);
|
||
arptSides.append(ptProj);
|
||
ptProj = arPts[14];
|
||
ptProj = ptProj.orthoProject(planEnd);
|
||
arptSides.append(ptProj);
|
||
ptProj = arPts[13];
|
||
ptProj = ptProj.orthoProject(planEnd);
|
||
arptSides.append(ptProj);
|
||
ptProj = arPts[32];
|
||
ptProj = ptProj.orthoProject(planEnd);
|
||
arptSides.append(ptProj);
|
||
|
||
ptProj = arPts[5];
|
||
ptProj = ptProj.orthoProject(planSta);
|
||
arptSides.append(ptProj);
|
||
arptSides.append(arPts[2]);
|
||
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat1.setToTranslation(vtNor);
|
||
|
||
vtNor.normalize();
|
||
vtNor *= dThickSub * 0.5;
|
||
AcGeMatrix3d mat3;
|
||
mat3.setToTranslation(vtNor);
|
||
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat2.setToTranslation(vtNor);
|
||
|
||
vtNor.normalize();
|
||
vtNor *= dThickSub;
|
||
AcGeMatrix3d mat4;
|
||
mat4.setToTranslation(vtNor);
|
||
|
||
arPtsU.setLogicalLength(0);
|
||
arPtsD.setLogicalLength(0);
|
||
|
||
for (i = 0; i < arptSides.length(); i++)
|
||
{
|
||
if (2 == i || 3 == i || 4 == i || 5 == i)//尾管端四个点
|
||
{
|
||
arPtsU.append(arptSides[i].transformBy(mat3));
|
||
arPtsD.append(arptSides[i].transformBy(mat4));
|
||
}
|
||
else//主管端四个点
|
||
{
|
||
arPtsU.append(arptSides[i].transformBy(mat1));
|
||
arPtsD.append(arptSides[i].transformBy(mat2));
|
||
}
|
||
}
|
||
|
||
arptSides.setLogicalLength(0);
|
||
arptSides.append(arPtsU[0]);
|
||
arptSides.append(arPtsU[7]);
|
||
arptSides.append(arPtsD[7]);
|
||
arptSides.append(arPtsD[0]);
|
||
arptSides.append(arPtsU[0]);
|
||
|
||
arptSides.append(arPtsU[1]);
|
||
arptSides.append(arPtsU[6]);
|
||
arptSides.append(arPtsD[6]);
|
||
arptSides.append(arPtsD[1]);
|
||
arptSides.append(arPtsU[1]);
|
||
|
||
arptSides.append(arPtsU[2]);
|
||
arptSides.append(arPtsU[5]);
|
||
arptSides.append(arPtsD[5]);
|
||
arptSides.append(arPtsD[2]);
|
||
arptSides.append(arPtsU[2]);
|
||
|
||
arptSides.append(arPtsU[3]);
|
||
arptSides.append(arPtsU[4]);
|
||
arptSides.append(arPtsD[4]);
|
||
arptSides.append(arPtsD[3]);
|
||
arptSides.append(arPtsU[3]);
|
||
|
||
DrawMesh(mode,4, 5, arptSides.asArrayPtr());
|
||
}
|
||
else // 普通圆角
|
||
{
|
||
//左上角的各个点
|
||
arPts1.append(arPts[1]);
|
||
arPts1.append(arPts[3]);
|
||
|
||
AcGeCircArc3d circArc(arPts[3], arPts[28], arPts[11]);
|
||
AcGeVector3d vts, vte;
|
||
vts = circArc.center() - arPts[3];
|
||
vte = circArc.center() - arPts[11];
|
||
double dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle;
|
||
}
|
||
|
||
int nSect = int(dAngle / dMinDiffAng);
|
||
AcGePoint3d pt;
|
||
pt = arPts[3];
|
||
int i = 0;
|
||
if (eType == AecHvac::eArcuateCross || eType == AecHvac::eArcuateIntubCross)
|
||
{
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts1.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
}
|
||
arPts1.append(arPts[11]);
|
||
arPts1.append(arPts[8]);
|
||
|
||
//右上角的各个点
|
||
arPts2.append(arPts[7]);
|
||
arPts2.append(arPts[9]);
|
||
circArc.set(arPts[9], arPts[30], arPts[29]);
|
||
vts = circArc.center() - arPts[9];
|
||
vte = circArc.center() - arPts[29];
|
||
dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle ;
|
||
}
|
||
nSect = int(dAngle / dMinDiffAng);
|
||
pt = arPts[9];
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts2.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
arPts2.append(arPts[29]);
|
||
arPts2.append(arPts[17]);
|
||
arPts2.append(arPts[14]);
|
||
|
||
//右下角的各个点
|
||
arPts3.append(arPts[13]);
|
||
arPts3.append(arPts[15]);
|
||
arPts3.append(arPts[32]);
|
||
circArc.set(arPts[32], arPts[33], arPts[23]);
|
||
vts = circArc.center() - arPts[32];
|
||
vte = circArc.center() - arPts[23];
|
||
dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle ;
|
||
}
|
||
nSect = int(dAngle / dMinDiffAng);
|
||
pt = arPts[32];
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts3.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
arPts3.append(arPts[23]);
|
||
arPts3.append(arPts[20]);
|
||
|
||
//左下下角的各个点
|
||
arPts4.append(arPts[19]);
|
||
arPts4.append(arPts[21]);
|
||
if (eType == AecHvac::eArcuateCross || eType == AecHvac::eArcuateIntubCross)
|
||
{
|
||
circArc.set(arPts[21], arPts[31], arPts[5]);
|
||
vts = circArc.center() - arPts[21];
|
||
vte = circArc.center() - arPts[5];
|
||
dAngle = vts.angleTo(vte,circArc.normal());
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle ;
|
||
}
|
||
nSect = int(dAngle / dMinDiffAng);
|
||
pt = arPts[21];
|
||
for (i = 0; i < nSect; i++)
|
||
{
|
||
arPts4.append(pt.rotateBy(dMinDiffAng, circArc.normal(), circArc.center()));
|
||
}
|
||
}
|
||
|
||
arPts4.append(arPts[5]);
|
||
arPts4.append(arPts[2]);
|
||
arptSides.append(arPts1);
|
||
arptSides.append(arPts2);
|
||
arptSides.append(arPts3);
|
||
arptSides.append(arPts4);
|
||
|
||
int nSize = arptSides.length();
|
||
|
||
AcGeMatrix3d mat1,mat2;
|
||
AcArray<Adesk::Int32> arlFaceList;
|
||
arlFaceList.append(nSize);
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat1.setToTranslation(vtNor);
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat2.setToTranslation(vtNor);
|
||
//所有点向上偏移半个厚度
|
||
for (i = 0; i < nSize; i++)
|
||
{
|
||
arPtsU.append(arptSides[i].transformBy(mat1));
|
||
arPtsD.append(arptSides[i].transformBy(mat2));
|
||
arlFaceList.append(i);
|
||
}
|
||
DrawShell(mode,nSize, arPtsU.asArrayPtr(), nSize + 1, arlFaceList.asArrayPtr());
|
||
DrawShell(mode,nSize, arPtsD.asArrayPtr(), nSize + 1, arlFaceList.asArrayPtr());
|
||
//侧面的面
|
||
for (int j = 0; j < 4; j++)
|
||
{
|
||
arptSides.setLogicalLength(0);
|
||
arPtsU.setLogicalLength(0);
|
||
arPtsD.setLogicalLength(0);
|
||
arPts.setLogicalLength(0);
|
||
switch(j)
|
||
{
|
||
case 0:
|
||
arPts.append(arPts1);
|
||
break;
|
||
case 1:
|
||
arPts.append(arPts2);
|
||
break;
|
||
case 2:
|
||
arPts.append(arPts3);
|
||
break;
|
||
case 3:
|
||
arPts.append(arPts4);
|
||
break;
|
||
}
|
||
for (i = 0; i < arPts.length(); i++)
|
||
{
|
||
arPtsU.append(arPts[i].transformBy(mat1));
|
||
arPtsD.append(arPts[i].transformBy(mat2));
|
||
}
|
||
arptSides.append(arPtsU);
|
||
arptSides.append(arPtsD);
|
||
DrawMesh(mode,2, arPtsU.length(), arptSides.asArrayPtr());
|
||
}
|
||
}
|
||
}
|
||
|
||
// 直角
|
||
void ImpHvacCross::DrawLinearCross3d(AcGiDraw &mode) const
|
||
{
|
||
DrawInterCross3d(mode);
|
||
}
|
||
|
||
// 交叉
|
||
void ImpHvacCross::DrawInterCross3d(AcGiDraw &mode) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
double dThick = 200.0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
AcGePoint3dArray arPts,arPtsU,arPtsD,arptSides;
|
||
GetIntersectCrossPts(arPts);
|
||
AcGeMatrix3d mat;
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
//去掉四个中心线点,把所有点向上偏移半个厚度
|
||
for (int i = 0; i < arPts.length() - 4; i++)
|
||
{
|
||
arPtsU.append(arPts[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat.setToTranslation(vtNor);
|
||
//去掉四个中心线点,把所有点向下偏移半个厚度
|
||
for (i = 0; i < arPts.length() - 4; i++)
|
||
{
|
||
arPtsD.append(arPts[i].transformBy(mat));
|
||
}
|
||
//开始面
|
||
arptSides.append(arPtsU[1]);
|
||
arptSides.append(arPtsU[2]);
|
||
arptSides.append(arPtsD[2]);
|
||
arptSides.append(arPtsD[1]);
|
||
arptSides.append(arPtsU[1]);
|
||
//开始直边段
|
||
arptSides.append(arPtsU[3]);
|
||
arptSides.append(arPtsU[5]);
|
||
arptSides.append(arPtsD[5]);
|
||
arptSides.append(arPtsD[3]);
|
||
arptSides.append(arPtsU[3]);
|
||
//
|
||
arptSides.append(arPtsU[11]);
|
||
arptSides.append(arPtsU[21]);
|
||
arptSides.append(arPtsD[21]);
|
||
arptSides.append(arPtsD[11]);
|
||
arptSides.append(arPtsU[11]);
|
||
|
||
// 如果是直角四通,修改9,15点为交点
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
if(eCrossType == AecHvac::eLinearCross)
|
||
{
|
||
arptSides.append(arPtsU[9]);
|
||
arptSides.append(arPtsU[23]);
|
||
arptSides.append(arPtsD[23]);
|
||
arptSides.append(arPtsD[9]);
|
||
arptSides.append(arPtsU[9]);
|
||
//末点面
|
||
arptSides.append(arPtsU[14]);
|
||
arptSides.append(arPtsU[13]);
|
||
arptSides.append(arPtsD[13]);
|
||
arptSides.append(arPtsD[14]);
|
||
arptSides.append(arPtsU[14]);
|
||
DrawMesh(mode,5, 5, arptSides.asArrayPtr());
|
||
}
|
||
else if (eCrossType == AecHvac::eInterCross)
|
||
{
|
||
//
|
||
arptSides.append(arPtsU[9]);
|
||
arptSides.append(arPtsU[23]);
|
||
arptSides.append(arPtsD[23]);
|
||
arptSides.append(arPtsD[9]);
|
||
arptSides.append(arPtsU[9]);
|
||
//末点直边段
|
||
arptSides.append(arPtsU[17]);
|
||
arptSides.append(arPtsU[15]);
|
||
arptSides.append(arPtsD[15]);
|
||
arptSides.append(arPtsD[17]);
|
||
arptSides.append(arPtsU[17]);
|
||
//末点面
|
||
arptSides.append(arPtsU[14]);
|
||
arptSides.append(arPtsU[13]);
|
||
arptSides.append(arPtsD[13]);
|
||
arptSides.append(arPtsD[14]);
|
||
arptSides.append(arPtsU[14]);
|
||
DrawMesh(mode,6, 5, arptSides.asArrayPtr());
|
||
}
|
||
|
||
//支管BR1
|
||
arptSides.setLogicalLength(0);
|
||
arptSides.append(arPtsU[20]);
|
||
arptSides.append(arPtsU[19]);
|
||
arptSides.append(arPtsD[19]);
|
||
arptSides.append(arPtsD[20]);
|
||
arptSides.append(arPtsU[20]);
|
||
|
||
arptSides.append(arPtsU[23]);
|
||
arptSides.append(arPtsU[21]);
|
||
arptSides.append(arPtsD[21]);
|
||
arptSides.append(arPtsD[23]);
|
||
arptSides.append(arPtsU[23]);
|
||
DrawMesh(mode,2, 5, arptSides.asArrayPtr());
|
||
|
||
//支管BR2
|
||
arptSides.setLogicalLength(0);
|
||
arptSides.append(arPtsU[7]);
|
||
arptSides.append(arPtsU[8]);
|
||
arptSides.append(arPtsD[8]);
|
||
arptSides.append(arPtsD[7]);
|
||
arptSides.append(arPtsU[7]);
|
||
//末点面
|
||
arptSides.append(arPtsU[9]);
|
||
arptSides.append(arPtsU[11]);
|
||
arptSides.append(arPtsD[11]);
|
||
arptSides.append(arPtsD[9]);
|
||
arptSides.append(arPtsU[9]);
|
||
DrawMesh(mode,2, 5, arptSides.asArrayPtr());
|
||
}
|
||
|
||
//二维曲线
|
||
BOOL ImpHvacCross::MakeOrthoCross2dCurves(AecComplexCurve& cplCurve, int &nType) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
AcGePoint3dArray arPts;
|
||
GetCrossPts(arPts,FALSE,TRUE);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
|
||
AecEqui::AecCurveElement el;
|
||
memset(&el,0,sizeof(AecEqui::AecCurveElement));
|
||
AcDbObjectId idBaseLayer(NULL), idSideLayer(NULL);
|
||
m_pXDataMap->GetAt(HVAC_EndLayer, idSideLayer);
|
||
|
||
double dEdgeWidth = GetEdgeLineWidth();
|
||
double dCenWidth = GetCentLineWidth();
|
||
double dEndLineWidth = GetEndLineWidth();
|
||
//水平放置
|
||
if (IsHorzAlignment())
|
||
{
|
||
//方口
|
||
if (arPts.length() == 20)
|
||
{
|
||
//外轮廓
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[8];
|
||
el.ptGe[1] = arPts[9];
|
||
el.ptGe[2] = arPts[9];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[9];
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[10];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[12];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[13];
|
||
el.ptGe[2] = arPts[13];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[14];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[15];
|
||
el.ptGe[1] = arPts[16];
|
||
el.ptGe[2] = arPts[16];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[17];
|
||
el.ptGe[1] = arPts[18];
|
||
el.ptGe[2] = arPts[18];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[18];
|
||
el.ptGe[1] = arPts[19];
|
||
el.ptGe[2] = arPts[19];
|
||
cplCurve.append(el);
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
el.ptGe[0] = arPts[10];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[14];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[16];
|
||
el.ptGe[1] = arPts[17];
|
||
el.ptGe[2] = arPts[17];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[19];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[8];
|
||
cplCurve.append(el);
|
||
}
|
||
//中心线
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.gsMark = -1;
|
||
el.idSubLay = idBaseLayer;
|
||
if (IsSingleLine())
|
||
el.dWidth = dEdgeWidth;
|
||
else
|
||
el.dWidth = dCenWidth;
|
||
|
||
AcGePoint3d ptCen = arPts[7];
|
||
if (arPts[0].distanceTo(arPts[1]) < arPts[0].distanceTo(arPts[7]))
|
||
{
|
||
ptCen = arPts[1];
|
||
}
|
||
AcGePoint3d ptPlusEdgeS = GetPlusEdgeStartPt();
|
||
AcGePoint3d ptPlusEdgeE = GetPlusEdgeEndPt();
|
||
AcGePoint3d ptPlusEdgeB1 = GetPlusEdgeBra1Pt();
|
||
AcGePoint3d ptPlusEdgeB2 = GetPlusEdgeBra2Pt();
|
||
el.ptGe[0] = arPts[0];
|
||
el.ptGe[1] = ptPlusEdgeS;
|
||
el.ptGe[2] = ptPlusEdgeS;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[2];
|
||
el.ptGe[1] = ptPlusEdgeE;
|
||
el.ptGe[2] = ptPlusEdgeE;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = ptPlusEdgeB1;
|
||
el.ptGe[2] = ptPlusEdgeB1;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[6];
|
||
el.ptGe[1] = ptPlusEdgeB2;
|
||
el.ptGe[2] = ptPlusEdgeB2;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = ptPlusEdgeS;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = ptPlusEdgeE;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = ptPlusEdgeB1;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = ptPlusEdgeB2;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
//圆口
|
||
if (arPts.length() == 34)
|
||
{
|
||
//外轮廓
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
//直边段
|
||
for (int i = 0; i <= 18; i+=6)
|
||
{
|
||
el.ptGe[0] = arPts[i + 1];
|
||
el.ptGe[1] = arPts[i + 3];
|
||
el.ptGe[2] = arPts[i + 3];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[i + 2];
|
||
el.ptGe[1] = arPts[i + 5];
|
||
el.ptGe[2] = arPts[i + 5];
|
||
cplCurve.append(el);
|
||
}
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[24];
|
||
el.ptGe[2] = arPts[24];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[24];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[9];
|
||
el.ptGe[1] = arPts[25];
|
||
el.ptGe[2] = arPts[25];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[25];
|
||
el.ptGe[1] = arPts[17];
|
||
el.ptGe[2] = arPts[17];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[15];
|
||
el.ptGe[1] = arPts[26];
|
||
el.ptGe[2] = arPts[26];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[26];
|
||
el.ptGe[1] = arPts[23];
|
||
el.ptGe[2] = arPts[23];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[21];
|
||
el.ptGe[1] = arPts[27];
|
||
el.ptGe[2] = arPts[27];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[27];
|
||
el.ptGe[1] = arPts[5];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
|
||
//上下弧
|
||
el.ptGe[0] = arPts[24];
|
||
el.ptGe[1] = arPts[32];
|
||
el.ptGe[2] = arPts[25];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[27];
|
||
el.ptGe[1] = arPts[33];
|
||
el.ptGe[2] = arPts[26];
|
||
cplCurve.append(el);
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
for (i = 0; i <= 18; i+=6)
|
||
{
|
||
el.ptGe[0] = arPts[i + 1];
|
||
el.ptGe[1] = arPts[i + 2];
|
||
el.ptGe[2] = arPts[i + 2];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
|
||
//中心线
|
||
el.gsMark = -1;
|
||
el.idSubLay = idBaseLayer;
|
||
if (IsSingleLine())
|
||
el.dWidth = dEdgeWidth;
|
||
else
|
||
el.dWidth = dCenWidth;
|
||
//直边段
|
||
for (int i = 0; i <= 18; i+=6)
|
||
{
|
||
el.ptGe[0] = arPts[i];
|
||
el.ptGe[1] = arPts[i + 4];
|
||
el.ptGe[2] = arPts[i + 4];
|
||
cplCurve.append(el);
|
||
}
|
||
AcGePoint3d ptCen = arPts[31];
|
||
if (arPts[0].distanceTo(arPts[28]) < arPts[0].distanceTo(arPts[31]))
|
||
{
|
||
ptCen = arPts[28];
|
||
}
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[10];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[16];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[22];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
//垂直放置(立管)
|
||
else if (IsVertAlignment())
|
||
{
|
||
//方口
|
||
if (eSectType == eRect)
|
||
{
|
||
double dThick = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
AcGePoint3d pt, ptTemp;
|
||
AcGePoint3dArray arPtsV;
|
||
//开始矢量和Z轴垂直(前视)
|
||
if (IsStartVertAlignment())
|
||
{
|
||
pt = arPts[8];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[10];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[11];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[13];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
}
|
||
//br1矢量和Z轴垂直(左视)
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
pt = arPts[10];
|
||
pt.z = arPts[0].z;
|
||
ptTemp = arPts[11];
|
||
ptTemp.z = arPts[0].z;
|
||
if (arPts[0].distanceTo(pt) < arPts[0].distanceTo(ptTemp))
|
||
{
|
||
pt = ptTemp;
|
||
}
|
||
arPtsV.append(pt);
|
||
pt = arPts[8];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[19];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[17];
|
||
pt.z = arPts[0].z;
|
||
ptTemp = arPts[16];
|
||
ptTemp.z = arPts[0].z;
|
||
if (arPts[0].distanceTo(pt) < arPts[0].distanceTo(ptTemp))
|
||
{
|
||
pt = ptTemp;
|
||
}
|
||
arPtsV.append(pt);
|
||
}
|
||
else
|
||
return FALSE;
|
||
|
||
AcGeMatrix3d mat;
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
arPtsV.append(arPtsV[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat.setToTranslation(vtNor);
|
||
for (i = 0; i < 4; i++)
|
||
{
|
||
arPtsV.append(arPtsV[i].transformBy(mat));
|
||
}
|
||
//外轮廓
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.idSubLay = NULL;
|
||
el.ptGe[0] = arPtsV[4];
|
||
el.ptGe[1] = arPtsV[7];
|
||
el.ptGe[2] = arPtsV[7];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPtsV[8];
|
||
el.ptGe[1] = arPtsV[11];
|
||
el.ptGe[2] = arPtsV[11];
|
||
cplCurve.append(el);
|
||
|
||
el.dWidth = dEndLineWidth;
|
||
el.idSubLay = idSideLayer;
|
||
el.ptGe[0] = arPtsV[4];
|
||
el.ptGe[1] = arPtsV[8];
|
||
el.ptGe[2] = arPtsV[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[7];
|
||
el.ptGe[1] = arPtsV[11];
|
||
el.ptGe[2] = arPtsV[11];
|
||
cplCurve.append(el);
|
||
}
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.dWidth = dCenWidth;
|
||
el.idSubLay = idBaseLayer;
|
||
el.ptGe[0] = arPtsV[5];
|
||
el.ptGe[1] = arPtsV[9];
|
||
el.ptGe[2] = arPtsV[9];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[6];
|
||
el.ptGe[1] = arPtsV[10];
|
||
el.ptGe[2] = arPtsV[10];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
//圆口
|
||
else if (eSectType == eCircle)
|
||
{
|
||
AcGeVector3d vtStar, vtBr1, vtNor;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStar);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
double dAngle = vtStar.angleTo(vtBr1);
|
||
//支管垂直
|
||
if (fabs(dAngle - PI / 2) < 1e-3)
|
||
{
|
||
arPts.setLogicalLength(0);
|
||
GetCrossPtsVerCir(arPts);
|
||
//BR管径大,有交点
|
||
if (arPts.length() == 15)
|
||
{
|
||
//外轮廓
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[4];
|
||
el.ptGe[2] = arPts[4];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[5];
|
||
el.ptGe[1] = arPts[13];
|
||
el.ptGe[2] = arPts[13];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[14];
|
||
el.ptGe[1] = arPts[6];
|
||
el.ptGe[2] = arPts[6];
|
||
cplCurve.append(el);
|
||
|
||
el.dWidth = dEndLineWidth;
|
||
el.idSubLay = idSideLayer;
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = arPts[5];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[6];
|
||
el.ptGe[2] = arPts[6];
|
||
cplCurve.append(el);
|
||
}
|
||
//内部线
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.dWidth = dCenWidth;
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[7];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[9];
|
||
el.ptGe[2] = arPts[13];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
//Br管径小,没有交点
|
||
else if (arPts.length() == 11)
|
||
{
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[4];
|
||
el.ptGe[2] = arPts[4];
|
||
cplCurve.append(el);
|
||
|
||
|
||
el.ptGe[0] = arPts[5];
|
||
el.ptGe[1] = arPts[6];
|
||
el.ptGe[2] = arPts[6];
|
||
cplCurve.append(el);
|
||
|
||
el.dWidth = dEndLineWidth;
|
||
el.idSubLay = idSideLayer;
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = arPts[5];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[6];
|
||
el.ptGe[1] = arPts[3];
|
||
el.ptGe[2] = arPts[3];
|
||
cplCurve.append(el);
|
||
}
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.dWidth = dCenWidth;
|
||
el.ptGe[0] = arPts[7];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[9];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[7];
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[9];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
//非支管90°
|
||
else
|
||
{
|
||
double dSWidth, dEWidth, dBr1Width, dBr2Width;
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
vtNor = GetSectNormal();
|
||
vtNor.normal();
|
||
dSWidth *= 0.5;
|
||
dEWidth *= 0.5;
|
||
dBr1Width *=0.5;
|
||
dBr2Width *=0.5;
|
||
AcGePoint3d pts, pte, ptm, ptlineStaU, ptlineStaD, ptlineEndU, ptlineEndD;
|
||
//开始矢量和Z轴垂直(前视)
|
||
el.dWidth = dEdgeWidth;
|
||
if (IsStartVertAlignment())
|
||
{
|
||
//主管4点
|
||
pts = arPts[0];
|
||
pte = arPts[12];
|
||
pte.z = pts.z;
|
||
el.ptGe[0] = pts + vtNor * dSWidth;
|
||
el.ptGe[1] = pte + vtNor * dEWidth;
|
||
el.ptGe[2] = pte + vtNor * dEWidth;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pte + vtNor * dEWidth;
|
||
el.ptGe[1] = pte - vtNor * dEWidth;
|
||
el.ptGe[2] = pte - vtNor * dEWidth;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pte - vtNor * dEWidth;
|
||
el.ptGe[1] = pts - vtNor * dSWidth;
|
||
el.ptGe[2] = pts - vtNor * dSWidth;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pts + vtNor * dSWidth;
|
||
el.ptGe[1] = pts - vtNor * dSWidth;
|
||
el.ptGe[2] = pts - vtNor * dSWidth;
|
||
cplCurve.append(el);
|
||
//Br1投影椭圆1
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
AcDbPolyline pPolyLine, pPolyLine1, pPolyLine2;
|
||
AcGePoint3dArray arPtsEll;
|
||
pte = arPts[6];
|
||
pte.z = pts.z;
|
||
int iRes = TAuxTools::GetEllipseFromCircle(pte, dBr1Width * 2, vtBr1, vtZAxis, pPolyLine,vtStar);
|
||
if (iRes == 2)
|
||
{
|
||
arPtsEll.setLogicalLength(0);
|
||
|
||
TAuxTools::GetArcPoint(pPolyLine, arPtsEll);//Lixl add 2011-11-23
|
||
for(int i = 0; i < arPtsEll.length()-1; i++)
|
||
{
|
||
el.ptGe[0] = arPtsEll[i];
|
||
el.ptGe[1] = arPtsEll[i+1];
|
||
el.ptGe[2] = arPtsEll[i+1];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
//椭圆2
|
||
iRes = TAuxTools::GetEllipseFromCircle(pte, dBr1Width * 2, vtBr1, vtZAxis, pPolyLine1, -vtStar);
|
||
if (iRes == 2)
|
||
{
|
||
arPtsEll.setLogicalLength(0);
|
||
|
||
TAuxTools::GetArcPoint(pPolyLine1, arPtsEll);//Lixl add 2011-11-23
|
||
for(int i = 0; i < arPtsEll.length()-1; i++)
|
||
{
|
||
el.ptGe[0] = arPtsEll[i];
|
||
el.ptGe[1] = arPtsEll[i+1];
|
||
el.ptGe[2] = arPtsEll[i+1];
|
||
cplCurve.append(el);
|
||
}
|
||
ptlineStaU = arPtsEll.first();
|
||
ptlineStaD = arPtsEll.last();
|
||
}
|
||
//椭圆3
|
||
pte = arPts[28];
|
||
pte.z = pts.z;
|
||
iRes = TAuxTools::GetEllipseFromCircle(pte, dBr1Width * 2, vtBr1, vtZAxis, pPolyLine2, vtStar);
|
||
if (iRes == 2)
|
||
{
|
||
arPtsEll.setLogicalLength(0);
|
||
|
||
TAuxTools::GetArcPoint(pPolyLine2, arPtsEll);//Lixl add 2011-11-23
|
||
for(int i = 0; i < arPtsEll.length()-1; i++)
|
||
{
|
||
el.ptGe[0] = arPtsEll[i];
|
||
el.ptGe[1] = arPtsEll[i+1];
|
||
el.ptGe[2] = arPtsEll[i+1];
|
||
cplCurve.append(el);
|
||
}
|
||
ptlineEndU = arPtsEll.last();
|
||
ptlineEndD = arPtsEll.first();
|
||
}
|
||
//椭圆的两根直线
|
||
el.ptGe[0] = ptlineStaU;
|
||
el.ptGe[1] = ptlineEndU;
|
||
el.ptGe[2] = ptlineEndU;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = ptlineStaD;
|
||
el.ptGe[1] = ptlineEndD;
|
||
el.ptGe[2] = ptlineEndD;
|
||
cplCurve.append(el);
|
||
|
||
}
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
AcGeVector3d vtTemp = vtNor;
|
||
vtTemp.rotateBy(PI / 2, vtStar);
|
||
vtTemp.normalize();
|
||
|
||
//主管4点
|
||
pts = arPts[0];
|
||
el.ptGe[0] = pts + vtNor * dSWidth;
|
||
el.ptGe[1] = pts + vtTemp * dSWidth;
|
||
el.ptGe[2] = pts - vtNor * dSWidth;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pts + vtNor * dSWidth;
|
||
el.ptGe[1] = pts - vtTemp * dSWidth;
|
||
el.ptGe[2] = pts - vtNor * dSWidth;
|
||
cplCurve.append(el);
|
||
//Br1投影椭圆1
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
AcDbPolyline pPolyLine, pPolyLine1, pPolyLine2;
|
||
AcGeVector3d vtBr1toBr2;
|
||
AcGePoint3dArray arPtsEll;
|
||
pte = arPts[6];
|
||
pte.z = pts.z;
|
||
ptm = arPts[18];
|
||
ptm.z = pts.z;
|
||
vtBr1toBr2 = pte - ptm;
|
||
|
||
int iRes = TAuxTools::GetEllipseFromCircle(pte, dBr1Width * 2, vtBr1, vtZAxis, pPolyLine, vtBr1toBr2);
|
||
if (iRes == 2)
|
||
{
|
||
arPtsEll.setLogicalLength(0);
|
||
|
||
TAuxTools::GetArcPoint(pPolyLine, arPtsEll);
|
||
for(int i = 0; i < arPtsEll.length()-1; i++)
|
||
{
|
||
el.ptGe[0] = arPtsEll[i];
|
||
el.ptGe[1] = arPtsEll[i+1];
|
||
el.ptGe[2] = arPtsEll[i+1];
|
||
cplCurve.append(el);
|
||
}
|
||
ptlineEndU = arPtsEll.first();
|
||
ptlineEndD = arPtsEll.last();
|
||
|
||
}
|
||
//椭圆2
|
||
iRes = TAuxTools::GetEllipseFromCircle(ptm, dBr2Width * 2, vtBr1, vtZAxis, pPolyLine2, -vtBr1toBr2);
|
||
if (iRes == 2)
|
||
{
|
||
arPtsEll.setLogicalLength(0);
|
||
|
||
TAuxTools::GetArcPoint(pPolyLine2, arPtsEll);
|
||
for(int i = 0; i < arPtsEll.length()-1; i++)
|
||
{
|
||
el.ptGe[0] = arPtsEll[i];
|
||
el.ptGe[1] = arPtsEll[i+1];
|
||
el.ptGe[2] = arPtsEll[i+1];
|
||
cplCurve.append(el);
|
||
}
|
||
ptlineEndU = arPtsEll.last();
|
||
ptlineEndD = arPtsEll.first();
|
||
}
|
||
AcGePoint3d ptIntersect1, ptIntersect2, ptIntersect3, ptIntersect4;
|
||
AcGeCircArc3d cirarc(arPts[0], vtStar, dSWidth);
|
||
AcGeLine3d pline1(ptlineStaU, ptlineStaU + vtBr1toBr2 * 100);
|
||
AcGeLine3d pline2(ptlineStaD, ptlineStaD + vtBr1toBr2 * 100);
|
||
AcGeLine3d pline3(ptlineEndU, ptlineEndU + vtBr1toBr2 * 100);
|
||
AcGeLine3d pline4(ptlineEndD, ptlineEndD + vtBr1toBr2 * 100);
|
||
int nNum = 0, nNum2 = 0;
|
||
cirarc.intersectWith((AcGeLinearEnt3d&)pline1, nNum, ptIntersect1, ptIntersect2);
|
||
if (2 == nNum)
|
||
{
|
||
if (ptlineStaU.distanceTo(ptIntersect1) > ptlineStaU.distanceTo(ptIntersect2))
|
||
{
|
||
ptIntersect1 = ptIntersect2;
|
||
}
|
||
}
|
||
el.ptGe[0] = ptlineStaU;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
cirarc.intersectWith((AcGeLinearEnt3d&)pline2, nNum, ptIntersect1, ptIntersect2);
|
||
if (2 == nNum)
|
||
{
|
||
if (ptlineStaD.distanceTo(ptIntersect1) > ptlineStaD.distanceTo(ptIntersect2))
|
||
{
|
||
ptIntersect1 = ptIntersect2;
|
||
}
|
||
}
|
||
el.ptGe[0] = ptlineStaD;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
|
||
cirarc.intersectWith((AcGeLinearEnt3d&)pline3, nNum, ptIntersect1, ptIntersect2);
|
||
if (2 == nNum)
|
||
{
|
||
if (ptlineEndU.distanceTo(ptIntersect1) > ptlineEndU.distanceTo(ptIntersect2))
|
||
{
|
||
ptIntersect1 = ptIntersect2;
|
||
}
|
||
}
|
||
el.ptGe[0] = ptlineEndU;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
|
||
cirarc.intersectWith((AcGeLinearEnt3d&)pline4, nNum, ptIntersect1, ptIntersect2);
|
||
if (2 == nNum)
|
||
{
|
||
if (ptlineEndD.distanceTo(ptIntersect1) > ptlineEndD.distanceTo(ptIntersect2))
|
||
{
|
||
ptIntersect1 = ptIntersect2;
|
||
}
|
||
}
|
||
el.ptGe[0] = ptlineEndD;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
return cplCurve.length() > 0;
|
||
}
|
||
|
||
// 承插
|
||
BOOL ImpHvacCross::MakeInsertCross2dCurves( AecComplexCurve& cplCurve, int &nType, BOOL bIntub /*= FALSE*/ ) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
AcGePoint3dArray arPts;
|
||
GetCrossPts(arPts,FALSE,TRUE);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
|
||
AecEqui::AecCurveElement el;
|
||
memset(&el,0,sizeof(AecEqui::AecCurveElement));
|
||
AcDbObjectId idBaseLayer(NULL), idSideLayer(NULL);
|
||
m_pXDataMap->GetAt(HVAC_EndLayer, idSideLayer);
|
||
AcGeVector3d vtStart = AcGeVector3d::kIdentity;
|
||
AcGeVector3d vtBr1 = AcGeVector3d::kIdentity;
|
||
AcGeVector3d vtBr2 = AcGeVector3d::kIdentity;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
double dThick = 0.0;
|
||
double dBrThick1 = 0.0;
|
||
double dBrThick2 = 0.0;
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBrThick1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBrThick2);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
vtStart.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
double dEdgeWidth = GetEdgeLineWidth();
|
||
double dCenWidth = GetCentLineWidth();
|
||
double dEndLineWidth = GetEndLineWidth();
|
||
if (eSectType == eRect)
|
||
{
|
||
if (IsHorzAlignment())
|
||
{
|
||
// 俯视矩形口
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
AcGePoint3d ptTmp1 = AcGePoint3d::kOrigin;
|
||
AcGePoint3d ptTmp2 = AcGePoint3d::kOrigin;
|
||
ptTmp1 = arPts[8] - vtStart * dPlusEdge;
|
||
ptTmp2 = arPts[10] - vtBr1 * dPlusEdge;
|
||
|
||
el.ptGe[0] = arPts[8];
|
||
el.ptGe[1] = ptTmp1;
|
||
el.ptGe[2] = ptTmp1;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = ptTmp2;
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[10];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = arPts[12];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[12];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[13];
|
||
el.ptGe[2] = arPts[13];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[14];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[15];
|
||
el.ptGe[1] = arPts[16];
|
||
el.ptGe[2] = arPts[16];
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPts[17] - vtBr2 * dPlusEdge;
|
||
ptTmp2 = arPts[19] - vtStart * dPlusEdge;
|
||
|
||
el.ptGe[0] = arPts[17];
|
||
el.ptGe[1] = ptTmp1;
|
||
el.ptGe[2] = ptTmp1;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = ptTmp2;
|
||
el.ptGe[1] = arPts[19];
|
||
el.ptGe[2] = arPts[19];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[15];
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
el.ptGe[0] = arPts[10];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[16];
|
||
el.ptGe[1] = arPts[17];
|
||
el.ptGe[2] = arPts[17];
|
||
cplCurve.append(el);
|
||
|
||
if (!bIntub)
|
||
{
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[14];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[19];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[8];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.gsMark = -1;
|
||
el.idSubLay = idBaseLayer;
|
||
if (IsSingleLine())
|
||
el.dWidth = dEdgeWidth;
|
||
else
|
||
el.dWidth = dCenWidth;
|
||
|
||
AcGePoint3d ptCen = arPts[7];
|
||
if (arPts[0].distanceTo(arPts[1]) < arPts[0].distanceTo(arPts[7]))
|
||
{
|
||
ptCen = arPts[1];
|
||
}
|
||
AcGePoint3d ptPlusEdgeS = GetPlusEdgeStartPt();
|
||
AcGePoint3d ptPlusEdgeE = GetPlusEdgeEndPt();
|
||
AcGePoint3d ptPlusEdgeB1 = GetPlusEdgeBra1Pt();
|
||
AcGePoint3d ptPlusEdgeB2 = GetPlusEdgeBra2Pt();
|
||
el.ptGe[0] = arPts[0];
|
||
el.ptGe[1] = ptPlusEdgeS;
|
||
el.ptGe[2] = ptPlusEdgeS;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[2];
|
||
el.ptGe[1] = ptPlusEdgeE;
|
||
el.ptGe[2] = ptPlusEdgeE;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = ptPlusEdgeB1;
|
||
el.ptGe[2] = ptPlusEdgeB1;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[6];
|
||
el.ptGe[1] = ptPlusEdgeB2;
|
||
el.ptGe[2] = ptPlusEdgeB2;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = ptPlusEdgeS;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = ptPlusEdgeE;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = ptPlusEdgeB1;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = ptPlusEdgeB2;
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
else if (IsVertAlignment())
|
||
{
|
||
AcGePoint3d ptTmp = AcGePoint3d::kOrigin;
|
||
AcGePoint3dArray arPtsV;
|
||
if (IsStartVertAlignment())
|
||
{
|
||
ptTmp = arPts[13];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[11];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[10];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[8];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
vtNor.normalize();
|
||
AcGePoint3d ptTmp1 = AcGePoint3d::kOrigin;
|
||
AcGePoint3d ptTmp2 = AcGePoint3d::kOrigin;
|
||
|
||
ptTmp1 = arPtsV[0] + vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[0] - vtNor * dThick / 2.0;
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[1] + vtNor * dBrThick1 / 2.0;
|
||
ptTmp2 = arPtsV[1] - vtNor * dBrThick1 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[2] + vtNor * dBrThick1 / 2.0;
|
||
ptTmp2 = arPtsV[2] - vtNor * dBrThick1 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[3] + vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[3] - vtNor * dThick / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[0] + vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[3] + vtNor * dThick / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[0] - vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[3] - vtNor * dThick / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[1] + vtNor * dBrThick1 / 2.0;
|
||
ptTmp2 = arPtsV[2] + vtNor * dBrThick1 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[1] - vtNor * dBrThick1 / 2.0;
|
||
ptTmp2 = arPtsV[2] - vtNor * dBrThick1 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
}
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
ptTmp = arPts[10];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[8];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[19];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[17];
|
||
ptTmp.z = arPts[4].z;
|
||
arPtsV.append(ptTmp);
|
||
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
vtNor.normalize();
|
||
AcGePoint3d ptTmp1 = AcGePoint3d::kOrigin;
|
||
AcGePoint3d ptTmp2 = AcGePoint3d::kOrigin;
|
||
|
||
|
||
ptTmp1 = arPtsV[0] + vtNor * dBrThick1 / 2.0;
|
||
ptTmp2 = arPtsV[0] - vtNor * dBrThick2 / 2.0;
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[1] + vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[1] - vtNor * dThick / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[2] + vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[2] - vtNor * dThick / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[3] + vtNor * dBrThick2 / 2.0;
|
||
ptTmp2 = arPtsV[3] - vtNor * dBrThick2 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[0] + vtNor * dBrThick1 / 2.0;
|
||
ptTmp2 = arPtsV[1] + vtNor * dBrThick1 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[0] - vtNor * dBrThick1 / 2.0;
|
||
ptTmp2 = arPtsV[1] - vtNor * dBrThick1 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[1] + vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[2] + vtNor * dThick / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[1] - vtNor * dThick / 2.0;
|
||
ptTmp2 = arPtsV[2] - vtNor * dThick / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[2] + vtNor * dBrThick2 / 2.0;
|
||
ptTmp2 = arPtsV[3] + vtNor * dBrThick2 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
|
||
ptTmp1 = arPtsV[2] - vtNor * dBrThick2 / 2.0;
|
||
ptTmp2 = arPtsV[3] - vtNor * dBrThick2 / 2.0;
|
||
|
||
el.ptGe[0] = ptTmp1;
|
||
el.ptGe[1] = ptTmp2;
|
||
el.ptGe[2] = ptTmp2;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
// 圆形口
|
||
if (eSectType == eCircle)
|
||
{
|
||
arPts.setLogicalLength(0);
|
||
if (!GetInsertCirPts(arPts))
|
||
return FALSE;
|
||
|
||
if (IsHorzAlignment())
|
||
{
|
||
// 俯视
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[1];
|
||
el.ptGe[1] = arPts[13];
|
||
el.ptGe[2] = arPts[13];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[18];
|
||
el.ptGe[2] = arPts[18];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[18];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[7];
|
||
el.ptGe[1] = arPts[19];
|
||
el.ptGe[2] = arPts[19];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[19];
|
||
el.ptGe[1] = arPts[17];
|
||
el.ptGe[2] = arPts[17];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[17];
|
||
el.ptGe[1] = arPts[5];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = arPts[16];
|
||
el.ptGe[2] = arPts[16];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[16];
|
||
el.ptGe[1] = arPts[21];
|
||
el.ptGe[2] = arPts[21];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[21];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[10];
|
||
el.ptGe[1] = arPts[20];
|
||
el.ptGe[2] = arPts[20];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[20];
|
||
el.ptGe[1] = arPts[14];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[14];
|
||
el.ptGe[1] = arPts[2];
|
||
el.ptGe[2] = arPts[2];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[18];
|
||
el.ptGe[1] = arPts[22];
|
||
el.ptGe[2] = arPts[19];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[20];
|
||
el.ptGe[1] = arPts[23];
|
||
el.ptGe[2] = arPts[21];
|
||
cplCurve.append(el);
|
||
|
||
el.dWidth = dEndLineWidth;
|
||
el.idSubLay = idSideLayer;
|
||
|
||
el.ptGe[0] = arPts[5];
|
||
el.ptGe[1] = arPts[4];
|
||
el.ptGe[2] = arPts[4];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[8];
|
||
el.ptGe[1] = arPts[7];
|
||
el.ptGe[2] = arPts[7];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[2];
|
||
el.ptGe[1] = arPts[1];
|
||
el.ptGe[2] = arPts[1];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[10];
|
||
cplCurve.append(el);
|
||
}
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.gsMark = -1;
|
||
el.idSubLay = idBaseLayer;
|
||
if (IsSingleLine())
|
||
el.dWidth = dEdgeWidth;
|
||
else
|
||
el.dWidth = dCenWidth;
|
||
el.ptGe[0] = arPts[0];
|
||
el.ptGe[1] = arPts[12];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[6];
|
||
el.ptGe[1] = arPts[12];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[9];
|
||
el.ptGe[1] = arPts[12];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
else if (IsVertAlignment())
|
||
{
|
||
MakeOrthoCross2dCurves(cplCurve, nType);
|
||
}
|
||
}
|
||
return cplCurve.length() > 0;
|
||
}
|
||
|
||
// 斜接
|
||
BOOL ImpHvacCross::MakeInclineCross2dCurves(AecComplexCurve& cplCurve, int &nType) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
AcDbObjectId idBaseLayer(NULL), idSideLayer(NULL);
|
||
m_pXDataMap->GetAt(HVAC_EndLayer, idSideLayer);
|
||
idBaseLayer = layerId();
|
||
|
||
double dEdgeWidth = GetEdgeLineWidth();
|
||
double dCenWidth = GetCentLineWidth();
|
||
double dEndLineWidth = GetEndLineWidth();
|
||
|
||
if (eSectType == eRect)
|
||
{
|
||
MakeArcuateCross2dCurves(cplCurve, nType);
|
||
}
|
||
else if (eSectType == eCircle)
|
||
{
|
||
AcGePoint3dArray arPts;
|
||
if(!GetInclineCirPts(arPts))
|
||
return FALSE;
|
||
|
||
AecEqui::AecCurveElement el;
|
||
memset(&el,0,sizeof(AecEqui::AecCurveElement));
|
||
|
||
if (IsHorzAlignment())
|
||
{
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[1];
|
||
el.ptGe[1] = arPts[13];
|
||
el.ptGe[2] = arPts[13];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[20];
|
||
el.ptGe[2] = arPts[20];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[20];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[7];
|
||
el.ptGe[1] = arPts[19];
|
||
el.ptGe[2] = arPts[19];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[19];
|
||
el.ptGe[1] = arPts[24];
|
||
el.ptGe[2] = arPts[24];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[24];
|
||
el.ptGe[1] = arPts[17];
|
||
el.ptGe[2] = arPts[17];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[17];
|
||
el.ptGe[1] = arPts[5];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = arPts[16];
|
||
el.ptGe[2] = arPts[16];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[16];
|
||
el.ptGe[1] = arPts[25];
|
||
el.ptGe[2] = arPts[25];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[25];
|
||
el.ptGe[1] = arPts[23];
|
||
el.ptGe[2] = arPts[23];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[23];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[10];
|
||
el.ptGe[1] = arPts[22];
|
||
el.ptGe[2] = arPts[22];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[22];
|
||
el.ptGe[1] = arPts[14];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[14];
|
||
el.ptGe[1] = arPts[2];
|
||
el.ptGe[2] = arPts[2];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[0];
|
||
el.ptGe[1] = arPts[12];
|
||
el.ptGe[2] = arPts[12];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[24];
|
||
el.ptGe[2] = arPts[24];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[25];
|
||
el.ptGe[2] = arPts[25];
|
||
cplCurve.append(el);
|
||
|
||
el.dWidth = dEndLineWidth;
|
||
el.idSubLay = idSideLayer;
|
||
el.ptGe[0] = arPts[8];
|
||
el.ptGe[1] = arPts[7];
|
||
el.ptGe[2] = arPts[7];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[2];
|
||
el.ptGe[1] = arPts[1];
|
||
el.ptGe[2] = arPts[1];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[5];
|
||
el.ptGe[1] = arPts[4];
|
||
el.ptGe[2] = arPts[4];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[10];
|
||
cplCurve.append(el);
|
||
|
||
}
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.gsMark = -1;
|
||
if (IsSingleLine())
|
||
el.dWidth = dEdgeWidth;
|
||
else
|
||
el.dWidth = dCenWidth;
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[0];
|
||
el.ptGe[2] = arPts[0];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[6];
|
||
el.ptGe[1] = arPts[18];
|
||
el.ptGe[2] = arPts[18];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[9];
|
||
el.ptGe[1] = arPts[21];
|
||
el.ptGe[2] = arPts[21];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[18];
|
||
el.ptGe[2] = arPts[18];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[21];
|
||
el.ptGe[2] = arPts[21];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
else if (IsVertAlignment())
|
||
{
|
||
if (IsBr1VertAlignment()) // 侧视
|
||
{
|
||
AcGePoint3d ptTmp = AcGePoint3d::kOrigin;
|
||
AcGePoint3dArray arPtsV;
|
||
ptTmp = arPts[8];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[6];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[1];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[0];
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[2];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[9];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[10];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[18];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[21];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
|
||
double dBr1Width = 0.0;
|
||
double dBr2Width = 0.0;
|
||
double dSWidth = 0.0;
|
||
AcGeVector3d vtBr1 = AcGeVector3d::kIdentity;
|
||
AcGeVector3d vtBr2 = AcGeVector3d::kIdentity;
|
||
m_pXDataMap->GetAt(HCRS_StartDiameter, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Diameter, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Diameter, dBr2Width);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
|
||
AcDbPolyline pPolyLine;
|
||
int iRes = TAuxTools::GetEllipseFromCircle(arPtsV[1], dBr1Width, vtBr1, vtZAxis, pPolyLine, arPtsV[0] - arPtsV[6]);
|
||
el.dWidth = dEdgeWidth;
|
||
|
||
if (iRes == 2 || iRes == 0)
|
||
{
|
||
AcGePoint3dArray arPtsEll;
|
||
|
||
TAuxTools::GetArcPoint(pPolyLine, arPtsEll);
|
||
for(int i = 0; i < arPtsEll.length()-1; i++)
|
||
{
|
||
el.ptGe[0] = arPtsEll[i];
|
||
el.ptGe[1] = arPtsEll[i+1];
|
||
el.ptGe[2] = arPtsEll[i+1];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = arPtsV[1] - vtNor * dBr1Width / 2.0;
|
||
el.ptGe[1] = arPtsV[1] + vtNor * dBr1Width / 2.0;
|
||
el.ptGe[2] = arPtsV[1] + vtNor * dBr1Width / 2.0;
|
||
cplCurve.append(el);
|
||
}
|
||
|
||
el.ptGe[0] = arPtsV[1] - vtNor * dBr1Width / 2.0;
|
||
el.ptGe[1] = arPtsV[7] - vtNor * dBr1Width / 2.0;
|
||
el.ptGe[2] = arPtsV[7] - vtNor * dBr1Width / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[1] + vtNor * dBr1Width / 2.0;
|
||
el.ptGe[1] = arPtsV[7] + vtNor * dBr1Width / 2.0;
|
||
el.ptGe[2] = arPtsV[7] + vtNor * dBr1Width / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[3] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[2];
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[3] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[4];
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
AcDbPolyline pPolyLine1;
|
||
iRes = TAuxTools::GetEllipseFromCircle(arPtsV[5], dBr2Width, vtBr2, vtZAxis, pPolyLine1, arPtsV[6] - arPtsV[0]);
|
||
if (iRes == 2 || iRes == 0)
|
||
{
|
||
AcGePoint3dArray arPtsEll;
|
||
|
||
TAuxTools::GetArcPoint(pPolyLine1, arPtsEll);
|
||
for(int i = 0; i < arPtsEll.length()-1; i++)
|
||
{
|
||
el.ptGe[0] = arPtsEll[i];
|
||
el.ptGe[1] = arPtsEll[i+1];
|
||
el.ptGe[2] = arPtsEll[i+1];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = arPtsV[5] - vtNor * dBr2Width / 2.0;
|
||
el.ptGe[1] = arPtsV[5] + vtNor * dBr2Width / 2.0;
|
||
el.ptGe[2] = arPtsV[5] + vtNor * dBr2Width / 2.0;
|
||
cplCurve.append(el);
|
||
}
|
||
|
||
el.ptGe[0] = arPtsV[5] - vtNor * dBr2Width / 2.0;
|
||
el.ptGe[1] = arPtsV[8] - vtNor * dBr2Width / 2.0;
|
||
el.ptGe[2] = arPtsV[8] - vtNor * dBr2Width / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[5] + vtNor * dBr2Width / 2.0;
|
||
el.ptGe[1] = arPtsV[8] + vtNor * dBr2Width / 2.0;
|
||
el.ptGe[2] = arPtsV[8] + vtNor * dBr2Width / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
if (dBr1Width < dSWidth)
|
||
{
|
||
AcGePoint3d ptIntersect1,ptIntersect2;
|
||
//求出直线于圆弧的交点
|
||
AcGeCircArc3d circArc(arPtsV[3] - vtNor * dSWidth / 2.0, arPtsV[2], arPtsV[3] + vtNor * dSWidth / 2.0);
|
||
//定义求交直线
|
||
AcGeLine3d *pLine = new AcGeLine3d(arPtsV[7] - vtNor * dBr1Width / 2.0, arPtsV[3] - vtNor * dSWidth / 2.0);
|
||
int nNum=0;//交点数
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
AcGePoint3d ptTmp = arPtsV[7] - vtNor * dBr1Width / 2.0;
|
||
|
||
if (ptTmp.distanceTo(ptIntersect1) < ptTmp.distanceTo(ptIntersect2))
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect2;
|
||
el.ptGe[2] = ptIntersect2;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
pLine = new AcGeLine3d(arPtsV[7] + vtNor * dBr1Width / 2.0, arPtsV[3] + vtNor * dSWidth / 2.0);
|
||
nNum = 0;
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
AcGePoint3d ptTmp = arPtsV[7] + vtNor * dBr1Width / 2.0;
|
||
|
||
if (ptTmp.distanceTo(ptIntersect1) < ptTmp.distanceTo(ptIntersect2))
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect2;
|
||
el.ptGe[2] = ptIntersect2;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = arPtsV[7] - vtNor * dBr1Width / 2.0;
|
||
el.ptGe[1] = arPtsV[3] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[3] - vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[7] + vtNor * dBr1Width / 2.0;
|
||
el.ptGe[1] = arPtsV[3] + vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
}
|
||
|
||
if (dBr2Width < dSWidth)
|
||
{
|
||
AcGePoint3d ptIntersect1,ptIntersect2;
|
||
//求出直线于圆弧的交点
|
||
AcGeCircArc3d circArc(arPtsV[3] - vtNor * dSWidth / 2.0, arPtsV[4], arPtsV[3] + vtNor * dSWidth / 2.0);
|
||
//定义求交直线
|
||
AcGeLine3d *pLine = new AcGeLine3d(arPtsV[8] - vtNor * dBr2Width / 2.0, arPtsV[3] - vtNor * dSWidth / 2.0);
|
||
int nNum=0;//交点数
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
AcGePoint3d ptTmp = arPtsV[8] - vtNor * dBr2Width / 2.0;
|
||
|
||
if (ptTmp.distanceTo(ptIntersect1) < ptTmp.distanceTo(ptIntersect2))
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect2;
|
||
el.ptGe[2] = ptIntersect2;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
pLine = new AcGeLine3d(arPtsV[8] + vtNor * dBr2Width / 2.0, arPtsV[3] + vtNor * dSWidth / 2.0);
|
||
nNum = 0;
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
AcGePoint3d ptTmp = arPtsV[8] + vtNor * dBr2Width / 2.0;
|
||
|
||
if (ptTmp.distanceTo(ptIntersect1) < ptTmp.distanceTo(ptIntersect2))
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect1;
|
||
el.ptGe[2] = ptIntersect1;
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = ptTmp;
|
||
el.ptGe[1] = ptIntersect2;
|
||
el.ptGe[2] = ptIntersect2;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = arPtsV[8] - vtNor * dBr2Width / 2.0;
|
||
el.ptGe[1] = arPtsV[3] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[3] - vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[8] + vtNor * dBr2Width / 2.0;
|
||
el.ptGe[1] = arPtsV[3] + vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
|
||
if (IsStartVertAlignment()) // 主视
|
||
{
|
||
AcGePoint3d ptTmp = AcGePoint3d::kOrigin;
|
||
AcGePoint3dArray arPtsV;
|
||
ptTmp = arPts[1];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[5];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[8];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[6];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[7];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[13];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
ptTmp = arPts[17];
|
||
ptTmp.z = arPts[0].z;
|
||
arPtsV.append(ptTmp);
|
||
|
||
double dSWidth = 0.0;
|
||
double dEWidth = 0.0;
|
||
double dBr1Width = 0.0;
|
||
AcGeVector3d vtBr1 = AcGeVector3d::kIdentity;
|
||
m_pXDataMap->GetAt(HCRS_StartDiameter, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_EndDiameter, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Diameter, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
vtNor.normalize();
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPtsV[0] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[0] + vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[0] + vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[1] - vtNor * dEWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[1] + vtNor * dEWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[1] + vtNor * dEWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[0] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[5] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[5] - vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[6] - vtNor * dEWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[5] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[5] - vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[1] - vtNor * dEWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[6] - vtNor * dEWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[6] - vtNor * dEWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[0] + vtNor * dSWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[5] + vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[5] + vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[6] + vtNor * dEWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[5] + vtNor * dSWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[5] + vtNor * dSWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[6] + vtNor * dEWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[1] + vtNor * dEWidth / 2.0;
|
||
el.ptGe[2] = arPtsV[1] + vtNor * dEWidth / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[5] - vtNor * dSWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[3] - vtNor * dBr1Width / 2.0;
|
||
el.ptGe[2] = arPtsV[3] - vtNor * dBr1Width / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[5] + vtNor * dSWidth / 2.0;
|
||
el.ptGe[1] = arPtsV[3] + vtNor * dBr1Width / 2.0;
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dBr1Width / 2.0;
|
||
cplCurve.append(el);
|
||
|
||
AcGeVector3d vtTmp1, vtTmp2;
|
||
vtTmp1 = GetSectNormal();
|
||
vtTmp2 = arPtsV[1] - arPtsV[0];
|
||
AcGeVector3d vtTmp = AcGeVector3d::kZAxis;//vtTmp1.crossProduct(vtTmp2)
|
||
AcDbDatabase* pDb = acdbCurDwg();
|
||
AcGeVector3d vtZAxis(pDb->ucsxdir().crossProduct(pDb->ucsydir()));
|
||
AcDbPolyline pPolyLine;
|
||
int iRes = TAuxTools::GetEllipseFromCircle(arPtsV[3], dBr1Width, vtBr1, vtZAxis, pPolyLine, vtTmp2);
|
||
|
||
if (iRes == 2 || iRes == 0)
|
||
{
|
||
AcGePoint3dArray arEllpts;
|
||
TAuxTools::GetArcPoint(pPolyLine, arEllpts);// Lixl add 2011-11-23
|
||
|
||
el.ptGe[0] = arPtsV[3] - vtNor * dBr1Width * 0.5;
|
||
el.ptGe[1] = arEllpts[3];
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dBr1Width * 0.5;
|
||
cplCurve.append(el);
|
||
|
||
AcDbPolyline pPolyLine1;
|
||
TAuxTools::GetEllipseFromCircle(arPtsV[3], dBr1Width, vtBr1, vtZAxis, pPolyLine1, -vtTmp2);
|
||
AcGePoint3dArray arEllpts1;
|
||
TAuxTools::GetArcPoint(pPolyLine1, arEllpts1);// Lixl add 2011-11-23
|
||
el.ptGe[0] = arPtsV[3] - vtNor * dBr1Width * 0.5;
|
||
el.ptGe[1] = arEllpts1[3];
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dBr1Width * 0.5;
|
||
cplCurve.append(el);
|
||
}
|
||
if (iRes == 1)
|
||
{
|
||
el.ptGe[0] = arPtsV[3] - vtNor * dBr1Width / 2.0;
|
||
el.ptGe[1] = arPtsV[3] + vtNor * dBr1Width / 2.0;
|
||
el.ptGe[2] = arPtsV[3] + vtNor * dBr1Width / 2.0;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return cplCurve.length() > 0;
|
||
}
|
||
|
||
// 圆角
|
||
BOOL ImpHvacCross::MakeArcuateCross2dCurves( AecComplexCurve& cplCurve, int &nType, BOOL bIntub /*= FALSE*/ ) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
AcGePoint3dArray arPts;
|
||
GetArcuateCrossPts(arPts);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
|
||
AecHvac::HvacCrossType eType = AecHvac::eArcuateCross;
|
||
AecEqui::AecCurveElement el;
|
||
memset(&el,0,sizeof(AecEqui::AecCurveElement));
|
||
AcDbObjectId idBaseLayer(NULL), idSideLayer(NULL);
|
||
//m_pXDataMap->GetAt(HVAC_BaseLayer, idBaseLayer);
|
||
m_pXDataMap->GetAt(HVAC_EndLayer, idSideLayer);
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eType);
|
||
|
||
double dEdgeWidth = GetEdgeLineWidth();
|
||
double dCenWidth = GetCentLineWidth();
|
||
double dEndLineWidth = GetEndLineWidth();
|
||
//水平放置
|
||
if (IsHorzAlignment())
|
||
{
|
||
if (arPts.length() == 34)
|
||
{
|
||
//外轮廓
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[1];
|
||
el.ptGe[1] = arPts[3];
|
||
el.ptGe[2] = arPts[3];
|
||
cplCurve.append(el);
|
||
|
||
if (eType == AecHvac::eArcuateCross || eType == AecHvac::eArcuateIntubCross)
|
||
{
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[28];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
}
|
||
else if (eType == AecHvac::eInclineCross)
|
||
{
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
}
|
||
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[7];
|
||
el.ptGe[1] = arPts[9];
|
||
el.ptGe[2] = arPts[9];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[9];
|
||
el.ptGe[1] = arPts[30];
|
||
el.ptGe[2] = arPts[29];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[29];
|
||
el.ptGe[1] = arPts[17];
|
||
el.ptGe[2] = arPts[17];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[17];
|
||
el.ptGe[1] = arPts[14];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
|
||
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[15];
|
||
el.ptGe[1] = arPts[32];
|
||
el.ptGe[2] = arPts[32];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[32];
|
||
el.ptGe[1] = arPts[33];
|
||
el.ptGe[2] = arPts[23];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[23];
|
||
el.ptGe[1] = arPts[20];
|
||
el.ptGe[2] = arPts[20];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[19];
|
||
el.ptGe[1] = arPts[21];
|
||
el.ptGe[2] = arPts[21];
|
||
cplCurve.append(el);
|
||
|
||
if (eType == AecHvac::eArcuateCross || eType == AecHvac::eArcuateIntubCross)
|
||
{
|
||
el.ptGe[0] = arPts[21];
|
||
el.ptGe[1] = arPts[31];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
}
|
||
else if (eType == AecHvac::eInclineCross)
|
||
{
|
||
el.ptGe[0] = arPts[21];
|
||
el.ptGe[1] = arPts[5];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
}
|
||
|
||
el.ptGe[0] = arPts[5];
|
||
el.ptGe[1] = arPts[2];
|
||
el.ptGe[2] = arPts[2];
|
||
cplCurve.append(el);
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
el.ptGe[0] = arPts[8];
|
||
el.ptGe[1] = arPts[7];
|
||
el.ptGe[2] = arPts[7];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[20];
|
||
el.ptGe[1] = arPts[19];
|
||
el.ptGe[2] = arPts[19];
|
||
cplCurve.append(el);
|
||
|
||
// 插管式,添加管壁线及不绘制两端线
|
||
if (bIntub)
|
||
{
|
||
el.idSubLay.setNull();
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[29];
|
||
el.ptGe[2] = arPts[29];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[5];
|
||
el.ptGe[1] = arPts[32];
|
||
el.ptGe[2] = arPts[32];
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = arPts[2];
|
||
el.ptGe[1] = arPts[1];
|
||
el.ptGe[2] = arPts[1];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[14];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
//中心线
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
el.gsMark = -1;
|
||
el.idSubLay = idBaseLayer;
|
||
if (IsSingleLine())
|
||
el.dWidth = dEdgeWidth;
|
||
else
|
||
el.dWidth = dCenWidth;
|
||
AcGePoint3d ptCen,ptInter1,ptInter2;
|
||
GetIntersectWith(arPts[0],arPts[4],arPts[6],arPts[10],ptInter1);
|
||
GetIntersectWith(arPts[0],arPts[4],arPts[18],arPts[22],ptInter2);
|
||
ptCen = ptInter2;
|
||
if (arPts[0].distanceTo(ptInter1) < arPts[0].distanceTo(ptInter2))
|
||
{
|
||
ptCen = ptInter1;
|
||
}
|
||
el.ptGe[0] = arPts[0];
|
||
el.ptGe[1] = arPts[4];
|
||
el.ptGe[2] = arPts[4];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[6];
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[10];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[10];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[16];
|
||
el.ptGe[2] = arPts[16];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[16];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[18];
|
||
el.ptGe[1] = arPts[22];
|
||
el.ptGe[2] = arPts[22];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[22];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
//垂直放置(立管)
|
||
else if (IsVertAlignment())
|
||
{
|
||
double dThick = 300.0;
|
||
double dBran1Thick = 300.0, dBran2Thick = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBran1Thick);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBran2Thick);
|
||
|
||
AcGePoint3d pt;
|
||
AcGePoint3dArray arPtsV;
|
||
//开始矢量和Z轴垂直(前视)
|
||
if (IsStartVertAlignment())
|
||
{
|
||
//标高与开始点相同
|
||
pt = arPts[1];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[8];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[7];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[14];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
}
|
||
//br1矢量和Z轴垂直(左视)
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
//标高与Br1点相同
|
||
pt = arPts[8];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[1];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[2];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[19];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[3];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[5];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
}
|
||
else
|
||
return FALSE;
|
||
|
||
if (eType == AecHvac::eArcuateIntubCross) // 圆角(插管)
|
||
{
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
{
|
||
if (IsStartVertAlignment())
|
||
{
|
||
AcGePoint3d pt1, pt2, pt3, pt4;
|
||
pt1 = arPtsV[0] + vtNor * dThick * 0.5;
|
||
pt2 = arPtsV[0] - vtNor * dThick * 0.5;
|
||
pt3 = arPtsV[3] + vtNor * dThick * 0.5;
|
||
pt4 = arPtsV[3] - vtNor * dThick * 0.5;
|
||
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = pt1;
|
||
el.ptGe[1] = pt3;
|
||
el.ptGe[2] = pt3;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt2;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
el.ptGe[0] = pt2;
|
||
el.ptGe[1] = pt1;
|
||
el.ptGe[2] = pt1;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt3;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
}
|
||
|
||
pt1 = arPtsV[1] + vtNor * dBran1Thick * 0.5;
|
||
pt2 = arPtsV[1] - vtNor * dBran1Thick * 0.5;
|
||
pt3 = arPtsV[2] + vtNor * dBran1Thick * 0.5;
|
||
pt4 = arPtsV[2] - vtNor * dBran1Thick * 0.5;
|
||
//if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
//{
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dCenWidth;
|
||
el.ptGe[0] = pt3;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt1;
|
||
el.ptGe[1] = pt2;
|
||
el.ptGe[2] = pt2;
|
||
cplCurve.append(el);
|
||
|
||
if (dBran1Thick < dThick)
|
||
{
|
||
el.ptGe[0] = pt3;
|
||
el.ptGe[1] = pt1;
|
||
el.ptGe[2] = pt1;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt2;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
}
|
||
//}
|
||
|
||
}
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
AcGePoint3d pt1, pt2, pt3, pt4;
|
||
pt1 = arPtsV[0] + vtNor * dBran1Thick * 0.5;
|
||
pt2 = arPtsV[0] - vtNor * dBran1Thick * 0.5;
|
||
pt3 = arPtsV[4] + vtNor * dBran1Thick * 0.5;
|
||
pt4 = arPtsV[4] - vtNor * dBran1Thick * 0.5;
|
||
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = pt1;
|
||
el.ptGe[1] = pt3;
|
||
el.ptGe[2] = pt3;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt2;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
|
||
pt1 = arPtsV[1] + vtNor * dThick * 0.5;
|
||
pt2 = arPtsV[1] - vtNor * dThick * 0.5;
|
||
pt3 = arPtsV[2] + vtNor * dThick * 0.5;
|
||
pt4 = arPtsV[2] - vtNor * dThick * 0.5;
|
||
el.ptGe[0] = pt1;
|
||
el.ptGe[1] = pt3;
|
||
el.ptGe[2] = pt3;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt2;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt1;
|
||
el.ptGe[1] = pt2;
|
||
el.ptGe[2] = pt2;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt4;
|
||
el.ptGe[1] = pt3;
|
||
el.ptGe[2] = pt3;
|
||
cplCurve.append(el);
|
||
|
||
pt1 = arPtsV[3] + vtNor * dBran2Thick * 0.5;
|
||
pt2 = arPtsV[3] - vtNor * dBran2Thick * 0.5;
|
||
pt3 = arPtsV[5] + vtNor * dBran2Thick * 0.5;
|
||
pt4 = arPtsV[5] - vtNor * dBran2Thick * 0.5;
|
||
el.ptGe[0] = pt1;
|
||
el.ptGe[1] = pt3;
|
||
el.ptGe[2] = pt3;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt2;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
|
||
pt1 = arPtsV[0] + vtNor * dBran1Thick * 0.5;
|
||
pt2 = arPtsV[0] - vtNor * dBran1Thick * 0.5;
|
||
pt3 = arPtsV[3] + vtNor * dBran2Thick * 0.5;
|
||
pt4 = arPtsV[3] - vtNor * dBran2Thick * 0.5;
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
el.ptGe[0] = pt1;
|
||
el.ptGe[1] = pt2;
|
||
el.ptGe[2] = pt2;
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = pt3;
|
||
el.ptGe[1] = pt4;
|
||
el.ptGe[2] = pt4;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AcGeMatrix3d mat;
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
arPtsV.append(arPtsV[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat.setToTranslation(vtNor);
|
||
for (i = 0; i < 4; i++)
|
||
{
|
||
arPtsV.append(arPtsV[i].transformBy(mat));
|
||
}
|
||
//外轮廓
|
||
if (IsStartVertAlignment())
|
||
{
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPtsV[4];
|
||
el.ptGe[1] = arPtsV[7];
|
||
el.ptGe[2] = arPtsV[7];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPtsV[8];
|
||
el.ptGe[1] = arPtsV[11];
|
||
el.ptGe[2] = arPtsV[11];
|
||
cplCurve.append(el);
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
|
||
el.ptGe[0] = arPtsV[4];
|
||
el.ptGe[1] = arPtsV[8];
|
||
el.ptGe[2] = arPtsV[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[7];
|
||
el.ptGe[1] = arPtsV[11];
|
||
el.ptGe[2] = arPtsV[11];
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dCenWidth;
|
||
el.ptGe[0] = arPtsV[5];
|
||
el.ptGe[1] = arPtsV[9];
|
||
el.ptGe[2] = arPtsV[9];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[6];
|
||
el.ptGe[1] = arPtsV[10];
|
||
el.ptGe[2] = arPtsV[10];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[5];
|
||
el.ptGe[1] = arPtsV[6];
|
||
el.ptGe[2] = arPtsV[6];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[9];
|
||
el.ptGe[1] = arPtsV[10];
|
||
el.ptGe[2] = arPtsV[10];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
el.ptGe[0] = arPtsV[6];
|
||
el.ptGe[1] = arPtsV[10];
|
||
el.ptGe[2] = arPtsV[10];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[9];
|
||
el.ptGe[1] = arPtsV[13];
|
||
el.ptGe[2] = arPtsV[13];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPtsV[7];
|
||
el.ptGe[1] = arPtsV[11];
|
||
el.ptGe[2] = arPtsV[11];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[8];
|
||
el.ptGe[1] = arPtsV[12];
|
||
el.ptGe[2] = arPtsV[12];
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.ptGe[0] = arPtsV[6];
|
||
el.ptGe[1] = arPtsV[9];
|
||
el.ptGe[2] = arPtsV[9];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[13];
|
||
el.ptGe[1] = arPtsV[10];
|
||
el.ptGe[2] = arPtsV[10];
|
||
cplCurve.append(el);
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dCenWidth;
|
||
|
||
el.ptGe[0] = arPtsV[7];
|
||
el.ptGe[1] = arPtsV[8];
|
||
el.ptGe[2] = arPtsV[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[11];
|
||
el.ptGe[1] = arPtsV[12];
|
||
el.ptGe[2] = arPtsV[12];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return cplCurve.length() > 0;
|
||
}
|
||
|
||
// 直角
|
||
BOOL ImpHvacCross::MakeLinearCross2dCurves(AecComplexCurve& cplCurve, int &nType) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
MakeInterCross2dCurves(cplCurve, nType);
|
||
return FALSE;
|
||
}
|
||
|
||
// 交叉
|
||
BOOL ImpHvacCross::MakeInterCross2dCurves(AecComplexCurve& cplCurve, int &nType) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
AcGePoint3dArray arPts;
|
||
GetIntersectCrossPts(arPts);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
|
||
AecEqui::AecCurveElement el;
|
||
memset(&el,0,sizeof(AecEqui::AecCurveElement));
|
||
AcDbObjectId idBaseLayer(NULL), idSideLayer(NULL);
|
||
m_pXDataMap->GetAt(HVAC_EndLayer, idSideLayer);
|
||
|
||
double dEdgeWidth = GetEdgeLineWidth();
|
||
double dCenWidth = GetCentLineWidth();
|
||
double dEndLineWidth = GetEndLineWidth();
|
||
//水平放置
|
||
if (IsHorzAlignment())
|
||
{
|
||
//方口
|
||
if (arPts.length() == 29)
|
||
{
|
||
//外轮廓
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPts[1];
|
||
el.ptGe[1] = arPts[3];
|
||
el.ptGe[2] = arPts[3];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[3];
|
||
el.ptGe[1] = arPts[11];
|
||
el.ptGe[2] = arPts[11];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[11];
|
||
el.ptGe[1] = arPts[8];
|
||
el.ptGe[2] = arPts[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[7];
|
||
el.ptGe[1] = arPts[9];
|
||
el.ptGe[2] = arPts[9];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[9];
|
||
el.ptGe[1] = arPts[17];
|
||
el.ptGe[2] = arPts[17];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[17];
|
||
el.ptGe[1] = arPts[14];
|
||
el.ptGe[2] = arPts[14];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[13];
|
||
el.ptGe[1] = arPts[15];
|
||
el.ptGe[2] = arPts[15];
|
||
cplCurve.append(el);
|
||
el.ptGe[0] = arPts[15];
|
||
el.ptGe[1] = arPts[23];
|
||
el.ptGe[2] = arPts[23];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[23];
|
||
el.ptGe[1] = arPts[20];
|
||
el.ptGe[2] = arPts[20];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[21];
|
||
el.ptGe[1] = arPts[5];
|
||
el.ptGe[2] = arPts[5];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[5];
|
||
el.ptGe[1] = arPts[2];
|
||
el.ptGe[2] = arPts[2];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[19];
|
||
el.ptGe[1] = arPts[21];
|
||
el.ptGe[2] = arPts[21];
|
||
cplCurve.append(el);
|
||
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
el.ptGe[0] = arPts[8];
|
||
el.ptGe[1] = arPts[7];
|
||
el.ptGe[2] = arPts[7];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[14];
|
||
el.ptGe[1] = arPts[13];
|
||
el.ptGe[2] = arPts[13];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[20];
|
||
el.ptGe[1] = arPts[19];
|
||
el.ptGe[2] = arPts[19];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[2];
|
||
el.ptGe[1] = arPts[1];
|
||
el.ptGe[2] = arPts[1];
|
||
cplCurve.append(el);
|
||
}
|
||
//中心线
|
||
if (1 == nType && (HasBaseLine() || IsSingleLine()))
|
||
{
|
||
AcGePoint3d ptCen = arPts[24];
|
||
if (arPts[0].distanceTo(arPts[27]) < arPts[0].distanceTo(arPts[24]))
|
||
{
|
||
ptCen = arPts[27];
|
||
}
|
||
el.gsMark = -1;
|
||
el.idSubLay = idBaseLayer;
|
||
if (IsSingleLine())
|
||
el.dWidth = dEdgeWidth;
|
||
else
|
||
el.dWidth = dCenWidth;
|
||
el.ptGe[0] = arPts[0];
|
||
el.ptGe[1] = arPts[4];
|
||
el.ptGe[2] = arPts[4];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[4];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[6];
|
||
el.ptGe[1] = arPts[10];
|
||
el.ptGe[2] = arPts[10];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[10];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[12];
|
||
el.ptGe[1] = arPts[16];
|
||
el.ptGe[2] = arPts[16];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[16];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[18];
|
||
el.ptGe[1] = arPts[22];
|
||
el.ptGe[2] = arPts[22];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPts[22];
|
||
el.ptGe[1] = ptCen;
|
||
el.ptGe[2] = ptCen;
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
}
|
||
//垂直放置(立管)
|
||
else if (IsVertAlignment())
|
||
{
|
||
double dThick = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
AcGePoint3d pt;
|
||
AcGePoint3dArray arPtsV;
|
||
//开始矢量和Z轴垂直(前视)
|
||
if (IsStartVertAlignment())
|
||
{
|
||
//标高与开始点相同
|
||
pt = arPts[1];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[8];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[7];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[14];
|
||
pt.z = arPts[0].z;
|
||
arPtsV.append(pt);
|
||
}
|
||
//br1矢量和Z轴垂直(左视)
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
//标高与Br1点相同
|
||
pt = arPts[8];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[1];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[2];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
pt = arPts[19];
|
||
pt.z = arPts[6].z;
|
||
arPtsV.append(pt);
|
||
}
|
||
else
|
||
return FALSE;
|
||
|
||
AcGeMatrix3d mat;
|
||
AcGeVector3d vtNor = GetSectNormal();
|
||
vtNor.normalize();
|
||
vtNor *= dThick * 0.5;
|
||
mat.setToTranslation(vtNor);
|
||
for (int i = 0; i < 4; i++)
|
||
{
|
||
arPtsV.append(arPtsV[i].transformBy(mat));
|
||
}
|
||
vtNor.normalize();
|
||
vtNor *= -dThick;
|
||
mat.setToTranslation(vtNor);
|
||
for (i = 0; i < 4; i++)
|
||
{
|
||
arPtsV.append(arPtsV[i].transformBy(mat));
|
||
}
|
||
//外轮廓
|
||
if (0 == nType)
|
||
{
|
||
el.dWidth = dEdgeWidth;
|
||
el.ptGe[0] = arPtsV[4];
|
||
el.ptGe[1] = arPtsV[7];
|
||
el.ptGe[2] = arPtsV[7];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[8];
|
||
el.ptGe[1] = arPtsV[11];
|
||
el.ptGe[2] = arPtsV[11];
|
||
cplCurve.append(el);
|
||
el.idSubLay = idSideLayer;
|
||
el.dWidth = dEndLineWidth;
|
||
|
||
el.ptGe[0] = arPtsV[4];
|
||
el.ptGe[1] = arPtsV[8];
|
||
el.ptGe[2] = arPtsV[8];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[7];
|
||
el.ptGe[1] = arPtsV[11];
|
||
el.ptGe[2] = arPtsV[11];
|
||
cplCurve.append(el);
|
||
}
|
||
else
|
||
{
|
||
el.dWidth = dCenWidth;
|
||
el.idSubLay = idSideLayer;
|
||
el.ptGe[0] = arPtsV[5];
|
||
el.ptGe[1] = arPtsV[9];
|
||
el.ptGe[2] = arPtsV[9];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[6];
|
||
el.ptGe[1] = arPtsV[10];
|
||
el.ptGe[2] = arPtsV[10];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[5];
|
||
el.ptGe[1] = arPtsV[6];
|
||
el.ptGe[2] = arPtsV[6];
|
||
cplCurve.append(el);
|
||
|
||
el.ptGe[0] = arPtsV[9];
|
||
el.ptGe[1] = arPtsV[10];
|
||
el.ptGe[2] = arPtsV[10];
|
||
cplCurve.append(el);
|
||
}
|
||
}
|
||
return cplCurve.length() > 0;
|
||
}
|
||
|
||
//斜接俯视顶点
|
||
// 8 6 7
|
||
// ╱╲
|
||
// ╱ ╱
|
||
// 1 ╱ ╱12
|
||
// │ └──┐5
|
||
// 0│ │3
|
||
// │ ┌──┘4
|
||
// 2 ╲ ╲13
|
||
// ╲ ╲
|
||
// ╲╱
|
||
// 10 9 11
|
||
//
|
||
|
||
BOOL ImpHvacCross::GetInclineCirPts(AcGePoint3dArray& arPts, BOOL nDefault) const
|
||
{
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
|
||
double dSWidth = MayAsMUnit(300.0), dEWidth = MayAsMUnit(300.0), dThick = MayAsMUnit(200.0);
|
||
double dBr1Width = MayAsMUnit(300.0), dBr2Width = MayAsMUnit(300.0), dPlusEdge = MayAsMUnit(50.0);
|
||
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartDiameter, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_EndDiameter, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Diameter, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Diameter, dBr2Width);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis;
|
||
vtNor = GetSectNormal();
|
||
dSWidth *= 0.5;
|
||
dEWidth *= 0.5;
|
||
dBr1Width *= 0.5;
|
||
dBr2Width *= 0.5;
|
||
AcGePoint3d ptTemp1,ptTemp2,ptInter;
|
||
AcGeVector3d vtStartv, vtEndv, vtBr1v, vtBr2v;
|
||
vtStartv = vtStart;
|
||
vtEndv = vtEnd;
|
||
vtBr1v = vtBr1;
|
||
vtBr2v = vtBr2;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
vtEndv.rotateBy(PI * 0.5,vtNor);
|
||
vtBr1v.rotateBy(PI * 0.5,vtNor);
|
||
vtBr2v.rotateBy(PI * 0.5,vtNor);
|
||
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
vtStartv.normalize();
|
||
vtEndv.normalize();
|
||
vtBr1v.normalize();
|
||
vtBr2v.normalize();
|
||
|
||
// 0-23点
|
||
arPts.append(ptStart);
|
||
arPts.append(ptStart + vtStartv * dSWidth);
|
||
arPts.append(ptStart - vtStartv * dSWidth);
|
||
arPts.append(ptEnd);
|
||
arPts.append(ptEnd + vtEndv * dEWidth);
|
||
arPts.append(ptEnd - vtEndv * dEWidth);
|
||
arPts.append(ptBr1);
|
||
arPts.append(ptBr1 + vtBr1v * dBr1Width);
|
||
arPts.append(ptBr1 - vtBr1v * dBr1Width);
|
||
arPts.append(ptBr2);
|
||
arPts.append(ptBr2 + vtBr2v * dBr2Width);
|
||
arPts.append(ptBr2 - vtBr2v * dBr2Width);
|
||
arPts.append(arPts[0] - vtStart * dPlusEdge);
|
||
arPts.append(arPts[1] - vtStart * dPlusEdge);
|
||
arPts.append(arPts[2] - vtStart * dPlusEdge);
|
||
arPts.append(arPts[3] - vtEnd * dPlusEdge);
|
||
arPts.append(arPts[4] - vtEnd * dPlusEdge);
|
||
arPts.append(arPts[5] - vtEnd * dPlusEdge);
|
||
arPts.append(arPts[6] - vtBr1 * dPlusEdge);
|
||
arPts.append(arPts[7] - vtBr1 * dPlusEdge);
|
||
arPts.append(arPts[8] - vtBr1 * dPlusEdge);
|
||
arPts.append(arPts[9] - vtBr2 * dPlusEdge);
|
||
arPts.append(arPts[10] - vtBr2 * dPlusEdge);
|
||
arPts.append(arPts[11] - vtBr2 * dPlusEdge);
|
||
|
||
// 24-25 关键点
|
||
AcGePoint3d ptTmp = AcGePoint3d::kOrigin;
|
||
AcGePoint3d ptInt = AcGePoint3d::kOrigin;
|
||
if (GetIntersectWith(arPts[13], arPts[20], arPts[12], arPts[18], ptTmp))
|
||
{
|
||
if (GetIntersectWith(ptTmp, arPts[19], arPts[17], arPts[13], ptInt))
|
||
{
|
||
arPts.append(ptInt);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AcGeVector3d vt1 = AcGeVector3d::kIdentity;
|
||
AcGeVector3d vt2 = AcGeVector3d::kIdentity;
|
||
vt1 = arPts[12] - arPts[18];
|
||
vt1.normalize();
|
||
vt2 = arPts[13] - arPts[17];
|
||
vt2.normalize();
|
||
if (GetIntersectWith(arPts[19], arPts[17], vt1, vt2, ptInt))
|
||
{
|
||
arPts.append(ptInt);
|
||
}
|
||
}
|
||
|
||
if (GetIntersectWith(arPts[14], arPts[22], arPts[12], arPts[21], ptTmp))
|
||
{
|
||
if (GetIntersectWith(ptTmp, arPts[23], arPts[16], arPts[14], ptInt))
|
||
{
|
||
arPts.append(ptInt);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
AcGeVector3d vt1 = AcGeVector3d::kIdentity;
|
||
AcGeVector3d vt2 = AcGeVector3d::kIdentity;
|
||
vt1 = arPts[12] - arPts[21];
|
||
vt1.normalize();
|
||
vt2 = arPts[14] - arPts[16];
|
||
vt2.normalize();
|
||
if (GetIntersectWith(arPts[23], arPts[16], vt1, vt2, ptInt))
|
||
{
|
||
arPts.append(ptInt);
|
||
}
|
||
}
|
||
return arPts.length() == 26;
|
||
}
|
||
|
||
BOOL ImpHvacCross::GetInsertCirPts(AcGePoint3dArray& arPts) const
|
||
{
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dBr1Width = 300.0, dBr2Width = 300.0, dPlus = 25.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlus);
|
||
|
||
AcGePoint3d ptInter;
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis;
|
||
vtNor = GetSectNormal();
|
||
AcGeVector3d vtStartv, vtEndv, vtBr1v, vtBr2v;
|
||
vtStartv = vtStart;
|
||
vtEndv = vtEnd;
|
||
vtBr1v = vtBr1;
|
||
vtBr2v = vtBr2;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
vtEndv.rotateBy(PI * 0.5,vtNor);
|
||
vtBr1v.rotateBy(PI * 0.5,vtNor);
|
||
vtBr2v.rotateBy(PI * 0.5,vtNor);
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
vtStartv.normalize();
|
||
vtEndv.normalize();
|
||
vtBr1v.normalize();
|
||
vtBr2v.normalize();
|
||
|
||
// 0 - 17
|
||
arPts.append(ptStart);
|
||
arPts.append(ptStart + vtStartv * dSWidth * 0.5);
|
||
arPts.append(ptStart - vtStartv * dSWidth * 0.5);
|
||
arPts.append(ptEnd);
|
||
arPts.append(ptEnd + vtEndv * dEWidth * 0.5);
|
||
arPts.append(ptEnd - vtEndv * dEWidth * 0.5);
|
||
arPts.append(ptBr1);
|
||
arPts.append(ptBr1 + vtBr1v * dBr1Width * 0.5);
|
||
arPts.append(ptBr1 - vtBr1v * dBr1Width * 0.5);
|
||
arPts.append(ptBr2);
|
||
arPts.append(ptBr2 + vtBr2v * dBr2Width * 0.5);
|
||
arPts.append(ptBr2 - vtBr2v * dBr2Width * 0.5);
|
||
arPts.append(arPts[0] + vtEnd * dPlus);
|
||
arPts.append(arPts[1] + vtEnd * dPlus);
|
||
arPts.append(arPts[2] + vtEnd * dPlus);
|
||
arPts.append(arPts[3] + vtStart * dPlus);
|
||
arPts.append(arPts[4] + vtStart * dPlus);
|
||
arPts.append(arPts[5] + vtStart * dPlus);
|
||
|
||
// 18 - 21
|
||
AcGeVector3d vtGeTmp = arPts[13] - arPts[17];
|
||
vtGeTmp.normalize();
|
||
if (GetIntersectWith(arPts[13], arPts[8], vtGeTmp, vtBr1, ptInter))
|
||
{
|
||
arPts.append(ptInter);
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
if (GetIntersectWith(arPts[17], arPts[7], vtGeTmp, vtBr1, ptInter))
|
||
{
|
||
arPts.append(ptInter);
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
vtGeTmp = arPts[14] - arPts[16];
|
||
vtGeTmp.normalize();
|
||
if (GetIntersectWith(arPts[14], arPts[10], vtGeTmp, vtBr2, ptInter))
|
||
{
|
||
arPts.append(ptInter);
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
if (GetIntersectWith(arPts[16], arPts[11], vtGeTmp, vtBr2, ptInter))
|
||
{
|
||
arPts.append(ptInter);
|
||
}
|
||
else
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
// 22 - 23
|
||
AcGePoint3d ptArc;
|
||
double dDis1 = arPts[8].distanceTo(arPts[18]);
|
||
double dDis2 = arPts[7].distanceTo(arPts[19]);
|
||
ptArc = arPts[6] - vtBr1 * ((dDis1 + dDis2) * 0.5 + dBr1Width * 0.3);
|
||
arPts.append(ptArc);
|
||
dDis1 = arPts[10].distanceTo(arPts[20]);
|
||
dDis2 = arPts[11].distanceTo(arPts[21]);
|
||
ptArc = arPts[9] - vtBr2 * ((dDis1 + dDis2) * 0.5 + dBr2Width * 0.3);
|
||
arPts.append(ptArc);
|
||
|
||
return arPts.length() == 24;
|
||
}
|
||
|
||
// 4 6
|
||
// 方口 10┏━━-━━┓11 圆口有50直边 8 ┏━━-━━┓7
|
||
// ┃ ┆ ┃ ┃ ┆ ┃
|
||
// 9┃ ┆ ┃ 24┃11 10 9 ┃
|
||
// 8 ┏━━━-━┛ ┆ ┃12 1 ┏━━━-━┛ 32 ┃25
|
||
// ┃ 7 ┆ ┗━━━━┓13 ┃ 3 31 ┆ ┗━━━━┓14
|
||
// 0 ┃--------------┆1 ┃ 0 ┃--4-----------┆ 28 17 ┃
|
||
// ┃ 3┆-----------------┃2 ┃ 30 ┆-------------16--┃12
|
||
// ┃ ┆ 5 ┃ ┃ 5 33 29 15 ┃
|
||
// 19 ┗━━━┓ ┆ ┏━━━━━━┛14 2 ┗━━━┓ ┆ ┏━━━━━━┛13
|
||
// 18┃ ┆ ┃15 27┃21 22 23┃26
|
||
// ┃ ┆ ┃ ┃ ┆ ┃
|
||
// 17┗━━━━┛16 19┗━━━━┛20
|
||
// 6 18
|
||
|
||
BOOL ImpHvacCross::GetCrossPts(AcGePoint3dArray& arPts, BOOL bDefault, BOOL bIs3D) const
|
||
{
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dThick = 200.0, dBr1Width = 300.0, dBr2Width = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
double dRadRatio = 1.0;
|
||
m_pXDataMap->GetAt(HCRS_RadRatio, dRadRatio);
|
||
if (!bIs3D)
|
||
{
|
||
//单线遮挡宽度
|
||
SetSingleDashWidth(dSWidth,dEWidth,dBr1Width,dBr2Width);
|
||
}
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis;
|
||
vtNor = GetSectNormal();
|
||
dSWidth *= 0.5;
|
||
dEWidth *= 0.5;
|
||
dBr1Width *= 0.5;
|
||
dBr2Width *= 0.5;
|
||
AcGePoint3d ptTemp1,ptTemp2,ptInter;
|
||
AcGeVector3d vtStartv, vtEndv, vtBr1v, vtBr2v;
|
||
vtStartv = vtStart;
|
||
vtEndv = vtEnd;
|
||
vtBr1v = vtBr1;
|
||
vtBr2v = vtBr2;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
vtEndv.rotateBy(PI * 0.5,vtNor);
|
||
vtBr1v.rotateBy(PI * 0.5,vtNor);
|
||
vtBr2v.rotateBy(PI * 0.5,vtNor);
|
||
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
vtStartv.normalize();
|
||
vtEndv.normalize();
|
||
vtBr1v.normalize();
|
||
vtBr2v.normalize();
|
||
AecHvac::HvacCrossType eType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eType);
|
||
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
if (eSectType == eRect)
|
||
{
|
||
AcGePlane planSta(ptStart, vtNor);
|
||
AcGePlane planBr1(ptBr1, vtNor);
|
||
AcGePlane planBr2(ptBr2, vtNor);
|
||
|
||
AcGePlane planEnd(ptEnd, vtNor);
|
||
|
||
// 投影至主矢量平面
|
||
if (eType == AecHvac::eInsertCross || eType == AecHvac::eInsertIntubCross)
|
||
{
|
||
ptBr1 = ptBr1.orthoProject(planSta);
|
||
ptBr2 = ptBr2.orthoProject(planSta);
|
||
}
|
||
|
||
//0-7
|
||
arPts.append(ptStart);
|
||
GetIntersectWith(ptStart, ptBr1, vtStart, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptEnd);
|
||
GetIntersectWith(ptEnd, ptBr2, vtEnd, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptBr1);
|
||
GetIntersectWith(ptEnd, ptBr1, vtEnd, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptBr2);
|
||
GetIntersectWith(ptStart, ptBr2, vtStart, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
|
||
//8-10
|
||
ptTemp1 = ptStart + vtStartv * dSWidth;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptBr1 - vtBr1v * dBr1Width;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtStart,vtBr1,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
//11-13
|
||
ptTemp1 = ptBr1 + vtBr1v * dBr1Width;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptEnd - vtEndv * dEWidth;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtBr1,vtEnd,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
//14-16
|
||
ptTemp1 = ptEnd + vtEndv * dEWidth;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptBr2 - vtBr2v * dBr2Width;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtEnd,vtBr2,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
//17-19
|
||
ptTemp1 = ptBr2 + vtBr2v * dBr2Width;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptStart - vtStartv * dSWidth;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtBr2,vtStart,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
|
||
BOOL bIsOK = TRUE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[8],arPts[9],vtStart))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[19],arPts[18],vtStart))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[13],arPts[12],vtEnd))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[14],arPts[15],vtEnd))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[10],arPts[9],vtBr1))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[11],arPts[12],vtBr1))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[16],arPts[15],vtBr2))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[17],arPts[18],vtBr2))
|
||
bIsOK = FALSE;
|
||
|
||
//重新计算标准点
|
||
if (bDefault)
|
||
{
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
double dPlusEnd = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
AcGePoint3d pt;
|
||
double dLength = max(dBr1Width,dBr2Width);
|
||
if (eType == AecHvac::eOrthoCross)
|
||
{
|
||
dLength = dLength * 2 * dRadRatio;
|
||
arPts[0] = GetFinalPt(arPts[0],arPts[1],arPts[7],arPts[9],arPts[18],vtStart,dLength);
|
||
arPts[2] = GetFinalPt(arPts[2],arPts[3],arPts[5],arPts[15],arPts[12],vtEnd,dLength);
|
||
double dMax = max(dSWidth, dEWidth);
|
||
arPts[4] = arPts[1] + vtBr1 * (dMax + dBr1Width);
|
||
arPts[6] = arPts[7] + vtBr2 * (dMax + dBr2Width);
|
||
}
|
||
//承差
|
||
else
|
||
{
|
||
double dPlusSta = MayAsMUnit(100.0);
|
||
double dPlusBr = MayAsMUnit(150.0);
|
||
|
||
dLength = dLength * 2 * dRadRatio;
|
||
arPts[0] = GetFinalPt(arPts[0],arPts[1],arPts[7],arPts[9],arPts[18],vtStart,dLength);
|
||
arPts[2] = GetFinalPtEnd(arPts[2],arPts[3],arPts[5],arPts[15],arPts[12],vtEnd);
|
||
|
||
AcGePoint3d ptTest = arPts[2];
|
||
arPts[2] = arPts[2].orthoProject(planEnd);
|
||
ptTest = arPts[2];
|
||
|
||
AcGePoint3d ptCor1 = arPts[9],ptCor2 = arPts[18],ptCor3 = arPts[12],ptCor4 = arPts[15];
|
||
|
||
AcGePoint3d ptDis = arPts[4] + vtBr1 * 10000;
|
||
double dis1 = ptDis.distanceTo(ptCor1);
|
||
double dis2 = ptDis.distanceTo(ptCor3);
|
||
if (dis1 < dis2)
|
||
{
|
||
arPts[4] = (ptCor1 + vtBr1 * (dPlusBr + dPlusEdge)) + vtBr1v * dBr1Width;
|
||
}
|
||
else
|
||
{
|
||
arPts[4] = (ptCor3 + vtBr1 * (dPlusBr + dPlusEdge)) - vtBr1v * dBr1Width;
|
||
}
|
||
|
||
ptDis = arPts[6] + vtBr2 * 10000;
|
||
dis1 = ptDis.distanceTo(ptCor2);
|
||
dis2 = ptDis.distanceTo(ptCor4);
|
||
if (dis1 < dis2)
|
||
{
|
||
arPts[6] = (ptCor2 + vtBr2 * (dPlusBr + dPlusEdge)) - vtBr2v * dBr2Width;
|
||
}
|
||
else
|
||
{
|
||
arPts[6] = (ptCor4 + vtBr2 * (dPlusBr + dPlusEdge)) + vtBr2v * dBr2Width;
|
||
}
|
||
}
|
||
}
|
||
|
||
// 投影回支管平面
|
||
if (eType == AecHvac::eInsertCross || eType == AecHvac::eInsertIntubCross)
|
||
{
|
||
AcGePoint3d ptProj = AcGePoint3d::kOrigin;
|
||
ptProj = arPts[4];
|
||
arPts.setAt(4, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[10];
|
||
arPts.setAt(10, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[11];
|
||
arPts.setAt(11, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[9];
|
||
arPts.setAt(9, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[12];
|
||
arPts.setAt(12, ptProj.orthoProject(planBr1));
|
||
|
||
ptProj = arPts[6];
|
||
arPts.setAt(6, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[16];
|
||
arPts.setAt(16, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[17];
|
||
arPts.setAt(17, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[15];
|
||
arPts.setAt(15, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[18];
|
||
arPts.setAt(18, ptProj.orthoProject(planBr2));
|
||
}
|
||
return bIsOK;
|
||
}
|
||
if(eSectType == eCircle)
|
||
{
|
||
//求直边段的各个点
|
||
GetPlusEdgePts(arPts, ptStart, vtStart, vtNor, dSWidth);
|
||
GetPlusEdgePts(arPts, ptBr1, vtBr1, vtNor, dBr1Width);
|
||
GetPlusEdgePts(arPts, ptEnd, vtEnd, vtNor, dEWidth);
|
||
GetPlusEdgePts(arPts, ptBr2, vtBr2, vtNor, dBr2Width);
|
||
|
||
//求交点24,25,26,27
|
||
GetIntersectWith(arPts[3], arPts[17], arPts[11], arPts[8], ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(arPts[3], arPts[17], arPts[7], arPts[9], ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(arPts[5], arPts[15], arPts[20], arPts[23], ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(arPts[5], arPts[15], arPts[19], arPts[21], ptInter);
|
||
arPts.append(ptInter);
|
||
//中心点28,29,30,31
|
||
GetIntersectWith(ptStart, ptBr1, vtStart, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(ptEnd, ptBr1, vtEnd, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(ptEnd, ptBr2, vtEnd, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(ptStart, ptBr2, vtStart, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
//计算上下两条圆弧的点32,33
|
||
AcGePoint3d ptArc;
|
||
double dDis1 = arPts[11].distanceTo(arPts[24]);
|
||
double dDis2 = arPts[9].distanceTo(arPts[25]);
|
||
ptArc = arPts[10] - vtBr1 * ((dDis1 + dDis2) * 0.5 + dBr1Width * 0.3);
|
||
arPts.append(ptArc);
|
||
dDis1 = arPts[21].distanceTo(arPts[27]);
|
||
dDis2 = arPts[23].distanceTo(arPts[26]);
|
||
ptArc = arPts[22] - vtBr2 * ((dDis1 + dDis2) * 0.5 + dBr2Width * 0.3);
|
||
arPts.append(ptArc);
|
||
|
||
BOOL bIsOK = TRUE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[1],arPts[24],vtStart))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[2],arPts[27],vtStart))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[13],arPts[/*12*/26],vtEnd))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[14],arPts[25],vtEnd))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[8],arPts[24],vtBr1))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[7],arPts[25],vtBr1))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[20],arPts[26],vtBr2))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[19],arPts[27],vtBr2))
|
||
bIsOK = FALSE;
|
||
//重新计算标准点
|
||
if (bDefault)
|
||
{
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
double dPlusEnd = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
AcGePoint3d pt;
|
||
double dLength = max(dBr1Width,dBr2Width);
|
||
|
||
dLength = dLength * 2 * dRadRatio;
|
||
arPts[0] = GetFinalPt(arPts[0],arPts[28],arPts[31],arPts[24],arPts[27],vtStart,dLength);
|
||
arPts[2] = GetFinalPt(arPts[12],arPts[29],arPts[30],arPts[25],arPts[26],vtEnd,dLength);
|
||
arPts[4] = GetFinalPt(arPts[6],arPts[28],arPts[29],arPts[24],arPts[25],vtBr1,dLength);
|
||
arPts[6] = GetFinalPt(arPts[18],arPts[31],arPts[30],arPts[27],arPts[26],vtBr2,dLength);
|
||
}
|
||
return bIsOK;
|
||
}
|
||
return FALSE;
|
||
}
|
||
|
||
// 4 6
|
||
// 方口 10┏━━-━━┓11 圆口有50直边 8 ┏━━-━━┓7
|
||
// ┃ ┆ ┃ ┃ ┆ ┃
|
||
// 9┃ ┆ ┃ 24┃11 10 9 ┃
|
||
// 8 ┏━━━-━┛ ┆ ┃12 1 ┏━━━-━┛ 29 ┃25
|
||
// ┃ 7 ┆ ┗━━━━┓13 ┃ 3 ┆ ┗━━━━┓14
|
||
// 0 ┃--------------┆1 ┃ 0 ┃--4--------- 28 17 ┃
|
||
// ┃ 3┆-----------------┃2 ┃ ------------16--┃12
|
||
// ┃ ┆ 5 ┃ ┃ 5 30 15 ┃
|
||
// 19 ┗━━━┓ ┆ ┏━━━━━━┛14 2 ┗━━━┓ ┆ ┏━━━━━━┛13
|
||
// 18┃ ┆ ┃15 27┃21 22 23┃26
|
||
// ┃ ┆ ┃ ┃ ┆ ┃
|
||
// 17┗━━━━┛16 19┗━━━━┛20
|
||
// 临时 6 18
|
||
|
||
BOOL ImpHvacCross::GetCrossPtsCirRedu(AcGePoint3dArray& arPts) const
|
||
{
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dThick = 200.0, dBr1Width = 300.0, dBr2Width = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis;
|
||
vtNor = GetSectNormal();
|
||
dSWidth *= 0.5;
|
||
dEWidth *= 0.5;
|
||
dBr1Width *= 0.5;
|
||
dBr2Width *= 0.5;
|
||
AcGePoint3d ptTemp1,ptTemp2,ptInter;
|
||
AcGeVector3d vtStartv, vtEndv, vtBr1v, vtBr2v;
|
||
vtStartv = vtStart;
|
||
vtEndv = vtEnd;
|
||
vtBr1v = vtBr1;
|
||
vtBr2v = vtBr2;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
vtEndv.rotateBy(PI * 0.5,vtNor);
|
||
vtBr1v.rotateBy(PI * 0.5,vtNor);
|
||
vtBr2v.rotateBy(PI * 0.5,vtNor);
|
||
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
vtStartv.normalize();
|
||
vtEndv.normalize();
|
||
vtBr1v.normalize();
|
||
vtBr2v.normalize();
|
||
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType,(int&)eSectType);
|
||
if (eSectType == eRect)
|
||
{
|
||
//0-7
|
||
arPts.append(ptStart);
|
||
GetIntersectWith(ptStart, ptBr1, vtStart, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptEnd);
|
||
GetIntersectWith(ptEnd, ptBr2, vtEnd, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptBr1);
|
||
GetIntersectWith(ptEnd, ptBr1, vtEnd, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptBr2);
|
||
GetIntersectWith(ptStart, ptBr2, vtStart, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
|
||
//8-10
|
||
ptTemp1 = ptStart + vtStartv * dSWidth;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptBr1 - vtBr1v * dBr1Width;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtStart,vtBr1,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
//11-13
|
||
ptTemp1 = ptBr1 + vtBr1v * dBr1Width;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptEnd - vtEndv * dEWidth;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtBr1,vtEnd,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
//14-16
|
||
ptTemp1 = ptEnd + vtEndv * dEWidth;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptBr2 - vtBr2v * dBr2Width;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtEnd,vtBr2,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
//17-19
|
||
ptTemp1 = ptBr2 + vtBr2v * dBr2Width;
|
||
arPts.append(ptTemp1);
|
||
ptTemp2 = ptStart - vtStartv * dSWidth;
|
||
GetIntersectWith(ptTemp1,ptTemp2,vtBr2,vtStart,ptInter);
|
||
arPts.append(ptInter);
|
||
arPts.append(ptTemp2);
|
||
}
|
||
else if(eSectType == eCircle)
|
||
{
|
||
//求直边段的各个点
|
||
GetPlusEdgePts(arPts, ptStart, vtStart, vtNor, dSWidth);
|
||
GetPlusEdgePts(arPts, ptBr1, vtBr1, vtNor, dBr1Width);
|
||
GetPlusEdgePts(arPts, ptEnd, vtEnd, vtNor, dEWidth);
|
||
GetPlusEdgePts(arPts, ptBr2, vtBr2, vtNor, dBr2Width);
|
||
|
||
//求交点24,25,26,27
|
||
GetIntersectWith(arPts[3], arPts[17], arPts[11], arPts[21], ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(arPts[3], arPts[17], arPts[9], arPts[23], ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(arPts[5], arPts[15], arPts[9], arPts[23], ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(arPts[5], arPts[15], arPts[11], arPts[21], ptInter);
|
||
arPts.append(ptInter);
|
||
//中心点28
|
||
GetIntersectWith(arPts[4], arPts[16], arPts[10], arPts[22], ptInter);
|
||
arPts.append(ptInter);
|
||
//计算上下两条圆弧的点29,30
|
||
AcGePoint3d ptArc;
|
||
AcGeVector3d vtBr1ToBr2 = arPts[10] - arPts[22];
|
||
vtBr1ToBr2.normalize();
|
||
double dDis1 = arPts[11].distanceTo(arPts[24]);
|
||
double dDis2 = arPts[9].distanceTo(arPts[25]);
|
||
ptArc = arPts[10] - vtBr1ToBr2 * ((dDis1 + dDis2) * 0.5 + dBr1Width * 0.3);
|
||
arPts.append(ptArc);
|
||
dDis1 = arPts[21].distanceTo(arPts[27]);
|
||
dDis2 = arPts[23].distanceTo(arPts[26]);
|
||
ptArc = arPts[22] + vtBr1ToBr2 * ((dDis1 + dDis2) * 0.5 + dBr2Width * 0.3);
|
||
arPts.append(ptArc);
|
||
}
|
||
return arPts.length() > 0;
|
||
}
|
||
|
||
//
|
||
// 8
|
||
// 11╭───╮12
|
||
// 3┌──-│ │-──┐4
|
||
// 0│ 7 │ 2 │9 │1
|
||
// 6└──-│ │-──┘5
|
||
// 14╰───╯13
|
||
// 10
|
||
//
|
||
|
||
BOOL ImpHvacCross::GetCrossPtsVerCir(AcGePoint3dArray& arPts) const
|
||
{
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dThick = 200.0, dBr1Width = 300.0, dBr2Width = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis;
|
||
vtNor = GetSectNormal();
|
||
dSWidth *= 0.5;
|
||
dEWidth *= 0.5;
|
||
dBr1Width *= 0.5;
|
||
dBr2Width *= 0.5;
|
||
|
||
//开始矢量和Z轴垂直(前视)
|
||
if (IsStartVertAlignment())
|
||
{
|
||
ptEnd.z = ptStart.z;
|
||
ptBr1.z = ptStart.z;
|
||
//0-6
|
||
arPts.append(ptStart);
|
||
arPts.append(ptEnd);
|
||
arPts.append(ptBr1);
|
||
arPts.append(ptStart - vtNor * dSWidth);
|
||
arPts.append(ptEnd - vtNor * dEWidth);
|
||
arPts.append(ptEnd + vtNor * dEWidth);
|
||
arPts.append(ptStart + vtNor * dSWidth);
|
||
|
||
//7-10
|
||
arPts.append(ptBr1 + vtStart * dBr1Width);
|
||
arPts.append(ptBr1 - vtNor * dBr1Width);
|
||
arPts.append(ptBr1 - vtStart * dBr1Width);
|
||
arPts.append(ptBr1 + vtNor * dBr1Width);
|
||
AcGePoint3d ptIntersect1,ptIntersect2;
|
||
//求出直线于圆弧的交点
|
||
AcGeCircArc3d circArc(ptBr1, vtBr1, dBr1Width);
|
||
//定义求交直线
|
||
AcGeLine3d *pLine = new AcGeLine3d(arPts[3], arPts[4]);
|
||
int nNum=0;//交点数
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
if (arPts[3].distanceTo(ptIntersect1) < arPts[3].distanceTo(ptIntersect2))
|
||
{
|
||
arPts.append(ptIntersect1);
|
||
arPts.append(ptIntersect2);
|
||
}
|
||
else
|
||
{
|
||
arPts.append(ptIntersect2);
|
||
arPts.append(ptIntersect1);
|
||
}
|
||
}
|
||
//定义求交直线
|
||
pLine = new AcGeLine3d(arPts[5], arPts[6]);
|
||
nNum=0;//交点数
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
if (arPts[5].distanceTo(ptIntersect1) < arPts[5].distanceTo(ptIntersect2))
|
||
{
|
||
arPts.append(ptIntersect1);
|
||
arPts.append(ptIntersect2);
|
||
}
|
||
else
|
||
{
|
||
arPts.append(ptIntersect2);
|
||
arPts.append(ptIntersect1);
|
||
}
|
||
}
|
||
}
|
||
//br1矢量和Z轴垂直(左视)
|
||
else if (IsBr1VertAlignment())
|
||
{
|
||
ptStart.z = ptBr1.z;
|
||
ptBr2.z = ptBr1.z;
|
||
//0-6
|
||
arPts.append(ptBr1);
|
||
arPts.append(ptBr2);
|
||
arPts.append(ptStart);
|
||
arPts.append(ptBr1 - vtNor * dBr1Width);
|
||
arPts.append(ptBr2 - vtNor * dBr2Width);
|
||
arPts.append(ptBr2 + vtNor * dBr2Width);
|
||
arPts.append(ptBr1 + vtNor * dBr1Width);
|
||
|
||
//7-10
|
||
arPts.append(ptStart + vtBr1 * dSWidth);
|
||
arPts.append(ptStart - vtNor * dSWidth);
|
||
arPts.append(ptStart - vtBr1 * dSWidth);
|
||
arPts.append(ptStart + vtNor * dSWidth);
|
||
AcGePoint3d ptIntersect1,ptIntersect2;
|
||
//求出直线于圆弧的交点
|
||
AcGeCircArc3d circArc(ptStart, vtStart, dSWidth);
|
||
//定义求交直线
|
||
AcGeLine3d *pLine = new AcGeLine3d(arPts[3], arPts[4]);
|
||
AcGePoint3d pt3 = arPts[3], pt4 = arPts[4];
|
||
|
||
int nNum=0;//交点数
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
if (arPts[3].distanceTo(ptIntersect1) < arPts[3].distanceTo(ptIntersect2))
|
||
{
|
||
arPts.append(ptIntersect1);
|
||
arPts.append(ptIntersect2);
|
||
}
|
||
else
|
||
{
|
||
arPts.append(ptIntersect2);
|
||
arPts.append(ptIntersect1);
|
||
}
|
||
}
|
||
//定义求交直线
|
||
pLine = new AcGeLine3d(arPts[5], arPts[6]);
|
||
nNum=0;//交点数
|
||
circArc.intersectWith(*pLine, nNum, ptIntersect1, ptIntersect2);
|
||
delete pLine;
|
||
if (2 == nNum)
|
||
{
|
||
if (arPts[5].distanceTo(ptIntersect1) < arPts[5].distanceTo(ptIntersect2))
|
||
{
|
||
arPts.append(ptIntersect1);
|
||
arPts.append(ptIntersect2);
|
||
}
|
||
else
|
||
{
|
||
arPts.append(ptIntersect2);
|
||
arPts.append(ptIntersect1);
|
||
}
|
||
}
|
||
}
|
||
return arPts.length() > 0;
|
||
}
|
||
|
||
// 6
|
||
// 方口 50直边 8 ┏━━-━━┓7
|
||
// ┃ ┆ ┃
|
||
// C1╱11 10 9 ╲C3
|
||
// 1 ┏━━━╱ ┆ ╲
|
||
// ┃ 3 27 ┆ -━━┓14
|
||
// 0 ┃--4-----------┆ 24 17 ┃
|
||
// ┃ ┆-------------16--┃12
|
||
// ┃ 5 26┆ 25 15 ┃
|
||
// 2 ┗━-╲ ┆ ╱-━━━━┛13
|
||
// C2 ╲ 21 22 23 ╱ C4
|
||
// ┃ ┆ ┃
|
||
// 19┗━━━━┛20
|
||
// 18
|
||
|
||
BOOL ImpHvacCross::GetIntersectCrossPts(AcGePoint3dArray& arPts, BOOL bDefault) const
|
||
{
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dThick = 200.0, dBr1Width = 300.0, dBr2Width = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
double dRadRatio = 1.5;
|
||
m_pXDataMap->GetAt(HCRS_RadRatio, dRadRatio);
|
||
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis;
|
||
vtNor = GetSectNormal();
|
||
dSWidth *= 0.5;
|
||
dEWidth *= 0.5;
|
||
dBr1Width *= 0.5;
|
||
dBr2Width *= 0.5;
|
||
AcGePoint3d ptTemp1,ptTemp2,ptInter;
|
||
//求直边段的各个点
|
||
GetPlusEdgePts(arPts, ptStart, vtStart, vtNor, dSWidth);
|
||
GetPlusEdgePts(arPts, ptBr1, vtBr1, vtNor, dBr1Width);
|
||
GetPlusEdgePts(arPts, ptEnd, vtEnd, vtNor, dEWidth);
|
||
GetPlusEdgePts(arPts, ptBr2, vtBr2, vtNor, dBr2Width);
|
||
//24-27
|
||
GetIntersectWith(ptStart, ptBr1, vtStart, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(ptEnd, ptBr1, vtEnd, vtBr1, ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(ptEnd, ptBr2, vtEnd, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(ptStart, ptBr2, vtStart, vtBr2, ptInter);
|
||
arPts.append(ptInter);
|
||
//交点28
|
||
if(TAuxTools::isCodirectionalPt(arPts[27], arPts[25], vtStart))
|
||
{
|
||
arPts.append(arPts[27]);
|
||
}
|
||
else
|
||
{
|
||
arPts.append(arPts[25]);
|
||
}
|
||
|
||
//重新计算带有变径或偏心的个点
|
||
AcGeVector3d vtStartv, vtEndv, vtBr1v, vtBr2v;
|
||
vtStartv = vtStart;
|
||
vtEndv = vtEnd;
|
||
vtBr1v = vtBr1;
|
||
vtBr2v = vtBr2;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
vtEndv.rotateBy(PI * 0.5,vtNor);
|
||
vtBr1v.rotateBy(PI * 0.5,vtNor);
|
||
vtBr2v.rotateBy(PI * 0.5,vtNor);
|
||
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
vtStartv.normalize();
|
||
vtEndv.normalize();
|
||
vtBr1v.normalize();
|
||
vtBr2v.normalize();
|
||
|
||
AcGePoint3d pt;
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
double dPlusSta = MayAsMUnit(100.0);
|
||
double dPlusEnd = MayAsMUnit(50.0);
|
||
double dPlusBr = MayAsMUnit(150.0);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
|
||
double dLength = max(dBr1Width,dBr2Width);
|
||
dLength = dPlusEdge + dPlusSta;
|
||
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
|
||
if(eCrossType == AecHvac::eLinearCross)
|
||
{
|
||
GetIntersectWith(arPts[7], arPts[9], arPts[14], arPts[17], ptInter);
|
||
arPts[9] = ptInter;
|
||
|
||
GetIntersectWith(arPts[13], arPts[15], arPts[20], arPts[23], ptInter);
|
||
arPts[23] = ptInter;
|
||
}
|
||
else
|
||
{
|
||
}
|
||
|
||
AcGePoint3d ptCor1,ptCor2,ptCor3,ptCor4;
|
||
BOOL bIsOK = TRUE;
|
||
GetIntersectWith(arPts[1], arPts[3], arPts[8], arPts[11], ptCor1);
|
||
if (!TAuxTools::isCodirectionalPt(arPts[1],ptCor1,vtStart))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[8],ptCor1,vtBr1))
|
||
bIsOK = FALSE;
|
||
GetIntersectWith(arPts[2], arPts[5], arPts[19], arPts[21], ptCor2);
|
||
if (!TAuxTools::isCodirectionalPt(arPts[2],ptCor2,vtStart))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[19],ptCor2,vtBr2))
|
||
bIsOK = FALSE;
|
||
GetIntersectWith(arPts[14], arPts[17], arPts[7], arPts[9], ptCor3);
|
||
if (!TAuxTools::isCodirectionalPt(arPts[14],ptCor3,vtEnd))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[7],ptCor3,vtBr1))
|
||
bIsOK = FALSE;
|
||
GetIntersectWith(arPts[13], arPts[15], arPts[20], arPts[23], ptCor4);
|
||
if (!TAuxTools::isCodirectionalPt(arPts[13],ptCor4,vtEnd))
|
||
bIsOK = FALSE;
|
||
if (!TAuxTools::isCodirectionalPt(arPts[20],ptCor4,vtBr2))
|
||
bIsOK = FALSE;
|
||
|
||
//重新计算标准点
|
||
if (bDefault)
|
||
{
|
||
dLength = max(dSWidth, dEWidth) * 2 * dRadRatio;
|
||
arPts[0] = GetInterFinalPt(arPts[0],arPts[24],arPts[27],ptCor1,ptCor2,vtStart,dLength);
|
||
arPts[2] = GetFinalPtEnd(arPts[12],arPts[25],arPts[26],ptCor3,ptCor4,vtEnd);
|
||
|
||
AcGePoint3d ptDis = arPts[6] + vtBr1 * 10000;
|
||
double dis1 = ptDis.distanceTo(ptCor1);
|
||
double dis2 = ptDis.distanceTo(ptCor3);
|
||
if (dis1 < dis2)
|
||
{
|
||
arPts[4] = (ptCor1 + vtBr1 * (dPlusBr + dPlusEdge)) + vtBr1v * dBr1Width;
|
||
}
|
||
else
|
||
{
|
||
arPts[4] = (ptCor3 + vtBr1 * (dPlusBr + dPlusEdge)) - vtBr1v * dBr1Width;
|
||
}
|
||
|
||
ptDis = arPts[18] + vtBr2 * 10000;
|
||
dis1 = ptDis.distanceTo(ptCor2);
|
||
dis2 = ptDis.distanceTo(ptCor4);
|
||
if (dis1 < dis2)
|
||
{
|
||
arPts[6] = (ptCor2 + vtBr2 * (dPlusBr + dPlusEdge)) - vtBr2v * dBr2Width;
|
||
}
|
||
else
|
||
{
|
||
arPts[6] = (ptCor4 + vtBr2 * (dPlusBr + dPlusEdge)) + vtBr2v * dBr2Width;
|
||
}
|
||
|
||
if(eCrossType == AecHvac::eInterCross)
|
||
{
|
||
arPts[2] = GetInterFinalPt(arPts[12],arPts[25],arPts[26],ptCor3,ptCor4,vtEnd,dLength);
|
||
}
|
||
}
|
||
return bIsOK;
|
||
}
|
||
|
||
|
||
// 6
|
||
// 方口有50直边 8 ┏━━-━━┓7
|
||
// C1 ┃ ┆ ┃
|
||
// 28┃11 10 9 ┃30 C4
|
||
// 1 ┏━━━-━┛ ┆ ┃29
|
||
// ┃ 3 ┆ ┗━━━━┓14
|
||
// 0 ┃--4-----------┆ 17 ┃
|
||
// ┃ ┆-------------16--┃12
|
||
// ┃ 5 ┆ 15 ┃
|
||
// 2 ┗━━━┓ ┆ ┏━━━━━━┛13
|
||
// C2 31┃ ┆ ┃32 C3
|
||
// ┃21 22 23┃33
|
||
// 19┗━━━━┛20
|
||
// 18
|
||
|
||
BOOL ImpHvacCross::GetArcuateCrossPts(AcGePoint3dArray& arPts, BOOL bDefault) const
|
||
{
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
double dSWidth = 300.0, dEWidth = 300.0, dThick = 200.0, dBr1Width = 300.0, dBr2Width = 300.0;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dSWidth);
|
||
m_pXDataMap->GetAt(HCRS_Thick, dThick);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
AecHvac::HvacCrossType eCrosstype = AecHvac::eArcuateCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrosstype);
|
||
|
||
AcGeVector3d vtTT = GetSectNormal();
|
||
AcGePlane planSta(ptStart, vtTT);
|
||
AcGePlane planBr1(ptBr1, vtTT);
|
||
AcGePlane planBr2(ptBr2, vtTT);
|
||
|
||
AcGePlane planEnd;
|
||
|
||
if (eCrosstype == AecHvac::eArcuateIntubCross)
|
||
{
|
||
planEnd.set(ptEnd, vtTT);
|
||
ptEnd = ptEnd.orthoProject(planSta);
|
||
ptBr1 = ptBr1.orthoProject(planSta);
|
||
ptBr2 = ptBr2.orthoProject(planSta);
|
||
}
|
||
|
||
if(vtStart.isCodirectionalTo(vtEnd) || vtStart.isCodirectionalTo(vtBr1) || vtStart.isCodirectionalTo(vtBr2) )
|
||
return FALSE;
|
||
if(vtEnd.isCodirectionalTo(vtBr1) || vtEnd.isCodirectionalTo(vtBr2) )
|
||
return FALSE;
|
||
if(vtBr1.isCodirectionalTo(vtBr2) )
|
||
return FALSE;
|
||
|
||
double dRadRatio = 1.5;
|
||
double dRadRatioBr1 = 1.5;
|
||
double dRadRatioBr2 = 1.5;
|
||
m_pXDataMap->GetAt(HCRS_RadRatio, dRadRatio);
|
||
|
||
dRadRatioBr1 = min(dSWidth, dBr1Width) * (dRadRatio - 0.5);
|
||
dRadRatioBr2 = min(dSWidth, dBr2Width) * (dRadRatio - 0.5);
|
||
|
||
BOOL bIsOK = TRUE;
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis;
|
||
vtNor = GetSectNormal();
|
||
dSWidth *= 0.5;
|
||
dEWidth *= 0.5;
|
||
dBr1Width *= 0.5;
|
||
dBr2Width *= 0.5;
|
||
AcGePoint3d ptInter;
|
||
AcGeVector3d vtStartv, vtEndv, vtBr1v, vtBr2v;
|
||
vtStartv = vtStart;
|
||
vtEndv = vtEnd;
|
||
vtBr1v = vtBr1;
|
||
vtBr2v = vtBr2;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
vtEndv.rotateBy(PI * 0.5,vtNor);
|
||
vtBr1v.rotateBy(PI * 0.5,vtNor);
|
||
vtBr2v.rotateBy(PI * 0.5,vtNor);
|
||
|
||
vtStart.normalize();
|
||
vtEnd.normalize();
|
||
vtBr1.normalize();
|
||
vtBr2.normalize();
|
||
vtStartv.normalize();
|
||
vtEndv.normalize();
|
||
vtBr1v.normalize();
|
||
vtBr2v.normalize();
|
||
|
||
//求直边段的各个点
|
||
GetPlusEdgePts(arPts, ptStart, vtStart, vtNor, dSWidth);
|
||
GetPlusEdgePts(arPts, ptBr1, vtBr1, vtNor, dBr1Width);
|
||
GetPlusEdgePts(arPts, ptEnd, vtEnd, vtNor, dEWidth);
|
||
GetPlusEdgePts(arPts, ptBr2, vtBr2, vtNor, dBr2Width);
|
||
|
||
//求交点24,25
|
||
GetIntersectWith(arPts[1], arPts[3], arPts[8], arPts[11], ptInter);
|
||
arPts.append(ptInter);
|
||
GetIntersectWith(arPts[2], arPts[5], arPts[19], arPts[21], ptInter);
|
||
arPts.append(ptInter);
|
||
|
||
double dAngle = vtStart.angleTo(vtBr1, vtNor);
|
||
if (dAngle > PI)
|
||
{
|
||
dAngle = 2 * PI - dAngle ;
|
||
}
|
||
dAngle *= 0.5;
|
||
double dAngle1 = vtStart.angleTo(vtBr2, vtNor);
|
||
if (dAngle1 > PI)
|
||
{
|
||
dAngle1 = 2 * PI - dAngle1 ;
|
||
}
|
||
dAngle1 *= 0.5;
|
||
//求圆心26,27
|
||
ptInter = arPts[24] + vtStart * dRadRatioBr1 / tan(dAngle);
|
||
ptInter = ptInter + vtStartv * dRadRatioBr1;
|
||
arPts.append(ptInter);
|
||
ptInter = arPts[25] + vtStart * dRadRatioBr2 / tan(dAngle1);
|
||
ptInter = ptInter - vtStartv * dRadRatioBr2;
|
||
arPts.append(ptInter);
|
||
//偏心重新算点
|
||
//上弧
|
||
ptInter = arPts[26] - vtStartv * dRadRatioBr1;
|
||
int nPos = TAuxTools::PositionOnLine(arPts[1], arPts[3], ptInter);
|
||
if (nPos == 1)
|
||
{
|
||
bIsOK = FALSE;
|
||
}
|
||
else if (nPos == 2)
|
||
{
|
||
arPts[3] = ptInter;
|
||
}
|
||
if(!bDefault)
|
||
{
|
||
arPts[11] = arPts[26] + vtBr1v * dRadRatioBr1;
|
||
arPts[9] = arPts[26] + vtBr1v * (dRadRatioBr1 + 2 * dBr1Width);
|
||
}
|
||
//下弧
|
||
ptInter = arPts[27] + vtStartv * dRadRatioBr2;
|
||
nPos = TAuxTools::PositionOnLine(arPts[2], arPts[5], ptInter);
|
||
if (nPos == 1)
|
||
{
|
||
bIsOK = FALSE;
|
||
}
|
||
else if (nPos == 2)
|
||
{
|
||
arPts[5] = ptInter;
|
||
}
|
||
if(!bDefault)
|
||
{
|
||
arPts[21] = arPts[27] - vtBr2v * dRadRatioBr2;
|
||
arPts[23] = arPts[27] - vtBr2v * (dRadRatioBr2 + 2 * dBr2Width);
|
||
}
|
||
//计算上圆弧的点
|
||
AcGeVector3d vtCor = arPts[24] - arPts[26];
|
||
vtCor.normalize();
|
||
ptInter = arPts[26] + vtCor * dRadRatioBr1;
|
||
//28
|
||
arPts.append(ptInter);
|
||
AcDbCircle circArc(arPts[26],vtNor,dRadRatioBr1 + 2 * dBr1Width);
|
||
//定义求交直线
|
||
AcGePoint3dArray arInterpts;
|
||
AcDbLine line(arPts[14], arPts[17]);
|
||
circArc.intersectWith(&line, AcDb::kExtendBoth, arInterpts);
|
||
if (arInterpts.length() == 2)
|
||
{
|
||
//29
|
||
if (arPts[17].distanceTo(arInterpts[0]) > arPts[17].distanceTo(arInterpts[1]))
|
||
{
|
||
arPts.append(arInterpts[1]);
|
||
}
|
||
else
|
||
{
|
||
arPts.append(arInterpts[0]);
|
||
}
|
||
AcGeVector3d vtS, vtE;
|
||
vtS = arPts[9] - arPts[26];
|
||
vtE = arPts[29] - arPts[26];
|
||
vtCor = vtS + vtE;
|
||
vtCor.normalize();
|
||
//30
|
||
arPts.append(arPts[26] + vtCor * circArc.radius());
|
||
}
|
||
else
|
||
{
|
||
GetIntersectWith(arPts[9], arPts[7], arPts[14], arPts[17], ptInter);
|
||
arPts[9] = ptInter;
|
||
arPts.append(ptInter);
|
||
arPts.append(ptInter);
|
||
}
|
||
AcGePoint3d pt;
|
||
//判断是否越界
|
||
pt = arPts[9] + vtEnd * 100;
|
||
GetIntersectWith(arPts[9], pt, arPts[12], arPts[13], ptInter);
|
||
if (!TAuxTools::isCodirectionalPt(arPts[14],ptInter,vtEndv))
|
||
{
|
||
GetIntersectWith(arPts[9], arPts[7], arPts[14], arPts[17], ptInter);
|
||
arPts[9] = ptInter;
|
||
arPts[29] = ptInter;
|
||
arPts[30] = ptInter;
|
||
}
|
||
|
||
//计算下圆弧的点
|
||
vtCor = arPts[25] - arPts[27];
|
||
vtCor.normalize();
|
||
ptInter = arPts[27] + vtCor * dRadRatioBr2;
|
||
//31
|
||
arPts.append(ptInter);
|
||
AcDbCircle circArc1(arPts[27],vtNor,dRadRatioBr2 + 2 * dBr2Width);
|
||
//定义求交直线
|
||
arInterpts.setLogicalLength(0);
|
||
AcDbLine line1(arPts[13], arPts[15]);
|
||
circArc1.intersectWith(&line1, AcDb::kExtendBoth, arInterpts);
|
||
if (arInterpts.length() == 2)
|
||
{
|
||
//32
|
||
if (arPts[15].distanceTo(arInterpts[0]) > arPts[15].distanceTo(arInterpts[1]))
|
||
{
|
||
arPts.append(arInterpts[1]);
|
||
}
|
||
else
|
||
{
|
||
arPts.append(arInterpts[0]);
|
||
}
|
||
AcGeVector3d vtS, vtE;
|
||
vtS = arPts[23] - arPts[27];
|
||
vtE = arPts[32] - arPts[27];
|
||
vtCor = vtS + vtE;
|
||
vtCor.normalize();
|
||
//33
|
||
arPts.append(arPts[27] + vtCor * circArc1.radius());
|
||
}
|
||
else
|
||
{
|
||
GetIntersectWith(arPts[13], arPts[15], arPts[20], arPts[23], ptInter);
|
||
arPts[23] = ptInter;
|
||
arPts.append(ptInter);
|
||
arPts.append(ptInter);
|
||
}
|
||
//判断是否越界
|
||
pt = arPts[23] + vtEnd * 100;
|
||
GetIntersectWith(arPts[23], pt, arPts[12], arPts[13], ptInter);
|
||
if (!TAuxTools::isCodirectionalPt(ptInter,arPts[13],vtEndv))
|
||
{
|
||
GetIntersectWith(arPts[13], arPts[15], arPts[20], arPts[23], ptInter);
|
||
arPts[23] = ptInter;
|
||
arPts[32] = ptInter;
|
||
arPts[33] = ptInter;
|
||
}
|
||
|
||
//重新计算标准点
|
||
if (bDefault)
|
||
{
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
double dPlusEnd = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
double dLength;
|
||
|
||
//计算角点
|
||
AcGePoint3d ptCor1,ptCor2,ptCor3,ptCor4;
|
||
GetIntersectWith(arPts[1], arPts[3], arPts[8], arPts[11], ptCor1);
|
||
GetIntersectWith(arPts[2], arPts[5], arPts[19], arPts[21], ptCor2);
|
||
GetIntersectWith(arPts[13], arPts[15], arPts[20], arPts[23], ptCor3);
|
||
GetIntersectWith(arPts[7], arPts[9], arPts[14], arPts[17], ptCor4);
|
||
double dminSbr1 = dBr1Width;
|
||
if (dBr1Width > dSWidth)
|
||
{
|
||
dminSbr1 = dSWidth;
|
||
}
|
||
double dminSbr2 = dBr2Width;
|
||
if (dBr2Width > dSWidth)
|
||
{
|
||
dminSbr2 = dSWidth;
|
||
}
|
||
double dminEbr1 = dBr1Width;
|
||
if (dBr1Width > dEWidth)
|
||
{
|
||
dminEbr1 = dEWidth;
|
||
}
|
||
double dminEbr2 = dBr2Width;
|
||
if (dBr2Width > dEWidth)
|
||
{
|
||
dminEbr2 = dEWidth;
|
||
}
|
||
//start
|
||
AcGePoint3d ptDis = ptStart + vtStart * 10000;
|
||
double dis1 = ptDis.distanceTo(ptCor1);
|
||
double dis2 = ptDis.distanceTo(ptCor2);
|
||
if (dis1 < dis2)
|
||
{
|
||
dAngle = vtStart.angleTo(vtBr1);
|
||
dAngle *= 0.5;
|
||
dLength = (dRadRatio - 0.5) * dminSbr1 * 2 / tan(dAngle) + dPlusEdge;
|
||
|
||
arPts[0] = ptCor1 + vtStart * dLength;
|
||
arPts[0] = arPts[0] - vtStartv * dSWidth;
|
||
}
|
||
else
|
||
{
|
||
dAngle = vtStart.angleTo(vtBr2);
|
||
dAngle *= 0.5;
|
||
dLength = (dRadRatio - 0.5) * dminSbr2 * 2 / tan(dAngle) + dPlusEdge;
|
||
|
||
arPts[0] = ptCor2 + vtStart * dLength;
|
||
arPts[0] = arPts[0] + vtStartv * dSWidth;
|
||
}
|
||
//end
|
||
ptDis = arPts[12] + vtEnd * 10000;
|
||
dis1 = ptDis.distanceTo(ptCor4);
|
||
dis2 = ptDis.distanceTo(ptCor3);
|
||
if (dis1 < dis2)
|
||
{
|
||
dAngle = vtEnd.angleTo(vtBr1);
|
||
dAngle *= 0.5;
|
||
dLength = dPlusEnd + dPlusEdge;
|
||
|
||
arPts[2] = ptCor4 + vtEnd * dLength;
|
||
arPts[2] = arPts[2] + vtEndv * dEWidth;
|
||
}
|
||
else
|
||
{
|
||
dAngle = vtEnd.angleTo(vtBr2);
|
||
dAngle *= 0.5;
|
||
dLength = dPlusEnd + dPlusEdge;
|
||
|
||
arPts[2] = ptCor3 + vtEnd * dLength;
|
||
arPts[2] = arPts[2] - vtEndv * dEWidth;
|
||
}
|
||
|
||
if (eCrosstype == AecHvac::eArcuateIntubCross)
|
||
{
|
||
arPts[2] = arPts[2].orthoProject(planEnd);
|
||
}
|
||
|
||
//br1
|
||
ptDis = arPts[6] + vtBr1 * 10000;
|
||
dis1 = ptDis.distanceTo(ptCor1);
|
||
dis2 = ptDis.distanceTo(ptCor4);
|
||
if (dis1 < dis2)
|
||
{
|
||
dAngle = vtBr1.angleTo(vtStart);
|
||
dAngle *= 0.5;
|
||
dLength = (dRadRatio - 0.5) * dminSbr1 * 2 / tan(dAngle) + dPlusEdge;
|
||
|
||
arPts[4] = ptCor1 + vtBr1 * dLength;
|
||
arPts[4] = arPts[4] + vtBr1v * dBr1Width;
|
||
arPts[4] = arPts[4].orthoProject(planBr1);
|
||
}
|
||
else
|
||
{
|
||
dAngle = vtBr1.angleTo(vtEnd);
|
||
dAngle *= 0.5;
|
||
dLength = (dRadRatio - 0.5) * dminEbr1 * 2 / tan(dAngle) + dPlusEdge;
|
||
|
||
arPts[4] = ptCor4 + vtBr1 * dLength;
|
||
arPts[4] = arPts[4] - vtBr1v * dBr1Width;
|
||
arPts[4] = arPts[4].orthoProject(planBr1);
|
||
}
|
||
//br2
|
||
ptDis = arPts[18] + vtBr2 * 10000;
|
||
dis1 = ptDis.distanceTo(ptCor2);
|
||
dis2 = ptDis.distanceTo(ptCor3);
|
||
if (dis1 < dis2)
|
||
{
|
||
dAngle = vtBr2.angleTo(vtStart);
|
||
dAngle *= 0.5;
|
||
dLength = (dRadRatio - 0.5) * dminSbr2 * 2 / tan(dAngle) + dPlusEdge;
|
||
|
||
arPts[6] = ptCor2 + vtBr2 * dLength;
|
||
arPts[6] = arPts[6] - vtBr2v * dBr2Width;
|
||
arPts[6] = arPts[6].orthoProject(planBr2);
|
||
}
|
||
else
|
||
{
|
||
dAngle = vtBr2.angleTo(vtEnd);
|
||
dAngle *= 0.5;
|
||
dLength = (dRadRatio - 0.5) * dminEbr2 * 2 / tan(dAngle) + dPlusEdge;
|
||
|
||
arPts[6] = ptCor3 + vtBr2 * dLength;
|
||
arPts[6] = arPts[6] + vtBr2v * dBr2Width;
|
||
arPts[6] = arPts[6].orthoProject(planBr2);
|
||
}
|
||
}
|
||
|
||
if (!bDefault && eCrosstype == AecHvac::eArcuateIntubCross)
|
||
{
|
||
AcGePoint3d ptProj = AcGePoint3d::kOrigin;
|
||
ptProj = arPts[3];
|
||
arPts.setAt(3, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[28];
|
||
arPts.setAt(28, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[11];
|
||
arPts.setAt(11, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[8];
|
||
arPts.setAt(8, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[6];
|
||
arPts.setAt(6, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[7];
|
||
arPts.setAt(7, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[9];
|
||
arPts.setAt(9, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[30];
|
||
arPts.setAt(30, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[29];
|
||
arPts.setAt(29, ptProj.orthoProject(planBr1));
|
||
ptProj = arPts[10];
|
||
arPts.setAt(10, ptProj.orthoProject(planBr1));
|
||
|
||
ptProj = arPts[5];
|
||
arPts.setAt(5, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[31];
|
||
arPts.setAt(31, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[21];
|
||
arPts.setAt(21, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[19];
|
||
arPts.setAt(19, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[18];
|
||
arPts.setAt(18, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[20];
|
||
arPts.setAt(20, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[22];
|
||
arPts.setAt(22, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[23];
|
||
arPts.setAt(23, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[33];
|
||
arPts.setAt(33, ptProj.orthoProject(planBr2));
|
||
ptProj = arPts[32];
|
||
arPts.setAt(32, ptProj.orthoProject(planBr2));
|
||
}
|
||
|
||
return arPts.length() > 0;
|
||
}
|
||
|
||
BOOL ImpHvacCross::GetIntersectWith(AcGePoint3d &pt1,AcGePoint3d &pt2,AcGeVector3d &vt1,AcGeVector3d &vt2,AcGePoint3d &ptIntersect) const
|
||
{
|
||
AcGePoint3d ptTmp1 = pt1;
|
||
AcGePoint3d ptTmp2 = pt1 + vt1 * 1000;
|
||
AcGePoint3d ptTmp3 = pt2;
|
||
AcGePoint3d ptTmp4 = pt2 + vt2 * 1000;
|
||
ptTmp1.z = ptTmp2.z = ptTmp3.z = ptTmp4.z = 0;
|
||
AcDbLine line1(ptTmp1,ptTmp2),line2(ptTmp3,ptTmp4);
|
||
AcGePoint3dArray arrPtInsec;
|
||
BOOL bRes = FALSE;
|
||
if(Acad::eOk == line1.intersectWith(&line2, AcDb::kExtendBoth, arrPtInsec))
|
||
{
|
||
if(arrPtInsec.length() > 0)
|
||
{
|
||
ptIntersect = arrPtInsec[0];
|
||
bRes = TRUE;
|
||
}
|
||
}
|
||
ptIntersect.z = pt1.z;
|
||
return bRes;
|
||
}
|
||
|
||
BOOL ImpHvacCross::GetIntersectWith(AcGePoint3d &pt1,AcGePoint3d &pt2,AcGePoint3d &pt3,AcGePoint3d &pt4,AcGePoint3d &ptIntersect) const
|
||
{
|
||
AcGePoint3d ptTmp1 = pt1;
|
||
AcGePoint3d ptTmp2 = pt2;
|
||
AcGePoint3d ptTmp3 = pt3;
|
||
AcGePoint3d ptTmp4 = pt4;
|
||
ptTmp1.z = ptTmp2.z = ptTmp3.z = ptTmp4.z = 0;
|
||
AcDbLine line1(ptTmp1,ptTmp2),line2(ptTmp3,ptTmp4);
|
||
AcGePoint3dArray arrPtInsec;
|
||
BOOL bRes = FALSE;
|
||
if(Acad::eOk == line1.intersectWith(&line2, AcDb::kExtendBoth, arrPtInsec))
|
||
{
|
||
if(arrPtInsec.length() > 0)
|
||
{
|
||
ptIntersect = arrPtInsec[0];
|
||
bRes = TRUE;
|
||
}
|
||
}
|
||
ptIntersect.z = pt1.z;
|
||
return bRes;
|
||
}
|
||
|
||
void ImpHvacCross::GetPlusEdgePts(AcGePoint3dArray &arPts, AcGePoint3d &ptStart, AcGeVector3d &vtStart, AcGeVector3d &vtNor, double dSWidth) const
|
||
{
|
||
double dPlusEdge = MayAsMUnit(50);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
if (dPlusEdge < 1.e-3)
|
||
{
|
||
dPlusEdge = 0.01;
|
||
}
|
||
AcGeVector3d vtStartv = vtStart;
|
||
vtStartv.rotateBy(PI * 0.5, vtNor);
|
||
vtStart.normalize();
|
||
vtStartv.normalize();
|
||
arPts.append(ptStart);
|
||
AcGePoint3d ptpt,ptpt1;
|
||
ptpt = ptStart + vtStartv * dSWidth;
|
||
|
||
arPts.append(ptpt);
|
||
ptpt1 = ptStart - vtStartv * dSWidth;
|
||
arPts.append(ptpt1);
|
||
int nSize = arPts.length();
|
||
arPts.append(arPts[nSize - 2] - vtStart * dPlusEdge);
|
||
arPts.append(arPts[nSize - 3] - vtStart * dPlusEdge);
|
||
arPts.append(arPts[nSize - 1] - vtStart * dPlusEdge);
|
||
}
|
||
|
||
void ImpHvacCross::GetArcPoint(AcDbPolyline &polyLine, AcGePoint3dArray &ptArcArr) const
|
||
{
|
||
if (polyLine.numVerts() != 4)
|
||
return;
|
||
|
||
double dPara1(0.0), dPara2(0.0);
|
||
double dPar1, dPar2;
|
||
AcGePoint3d pt0, pt1, pt2, pt3, ptMid;
|
||
|
||
polyLine.getPointAt(0, pt0);
|
||
polyLine.getPointAt(1, pt1);
|
||
polyLine.getPointAt(2, pt2);
|
||
polyLine.getPointAt(3, pt3);
|
||
|
||
polyLine.getParamAtPoint(pt0, dPar1);
|
||
polyLine.getParamAtPoint(pt1, dPar2);
|
||
polyLine.getPointAtParam((dPar1 + dPar2)*0.5, ptMid);
|
||
ptArcArr.append(pt0);
|
||
ptArcArr.append(ptMid);
|
||
ptArcArr.append(pt1);
|
||
|
||
polyLine.getParamAtPoint(pt1, dPar1);
|
||
polyLine.getParamAtPoint(pt2, dPar2);
|
||
polyLine.getPointAtParam((dPar1 + dPar2)*0.5, ptMid);
|
||
ptArcArr.append(ptMid);
|
||
ptArcArr.append(pt2);
|
||
|
||
polyLine.getParamAtPoint(pt2, dPar1);
|
||
polyLine.getParamAtPoint(pt3, dPar2);
|
||
polyLine.getPointAtParam((dPar1 + dPar2)*0.5, ptMid);
|
||
ptArcArr.append(ptMid);
|
||
ptArcArr.append(pt3);
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetCenterPt() const
|
||
{
|
||
AcGeVector3d vtStart;
|
||
AcGePoint3d ptStart;
|
||
double dBr1Width = MayAsMUnit(300.0), dBr2Width = MayAsMUnit(300.0), dPlusEdge = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBr1Width);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBr2Width);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
double dRadRatio = 1.0;
|
||
m_pXDataMap->GetAt(HCRS_RadRatio, dRadRatio);
|
||
|
||
dRadRatio *= max(dBr1Width,dBr2Width);
|
||
vtStart.normalize();
|
||
AecHvac::HvacCrossType eType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eType);
|
||
if (eType == AecHvac::eOrthoCross || eType == AecHvac::eArcuateCross || eType == AecHvac::eArcuateIntubCross)
|
||
{
|
||
return ptStart - vtStart * (dRadRatio + dPlusEdge);
|
||
}
|
||
double dPlusSta = 100.0;
|
||
|
||
return ptStart - vtStart * (dPlusSta + dPlusEdge + max(dBr1Width,dBr2Width) * 0.5);
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetPlusEdgeStartPt() const
|
||
{
|
||
AcGeVector3d vt;
|
||
AcGePoint3d pt;
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, pt);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vt);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
vt.normalize();
|
||
return pt - vt * dPlusEdge;
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetPlusEdgeEndPt() const
|
||
{
|
||
AcGeVector3d vt;
|
||
AcGePoint3d pt;
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, pt);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vt);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
vt.normalize();
|
||
return pt - vt * dPlusEdge;
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetPlusEdgeBra1Pt() const
|
||
{
|
||
AcGeVector3d vt;
|
||
AcGePoint3d pt;
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, pt);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vt);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
vt.normalize();
|
||
return pt - vt * dPlusEdge;
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetPlusEdgeBra2Pt() const
|
||
{
|
||
AcGeVector3d vt;
|
||
AcGePoint3d pt;
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, pt);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vt);
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
vt.normalize();
|
||
return pt - vt * dPlusEdge;
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetFinalPt(AcGePoint3d ptStart,AcGePoint3d ptInter1,AcGePoint3d ptInter2,AcGePoint3d ptCor1,
|
||
AcGePoint3d ptCor2,AcGeVector3d vtStart,double dLength) const
|
||
{
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis,vtStartv;
|
||
vtNor = GetSectNormal();
|
||
vtStartv = vtStart;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
double dPlusEnd = MayAsMUnit(50.0);
|
||
AcGePoint3d ptInter,ptRet;
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
double ddisPar = dPlusEnd + dPlusEdge;
|
||
AcGePoint3d ptDis = ptStart + vtStart * 10000;
|
||
double dis1 = ptDis.distanceTo(ptCor1);
|
||
double dis2 = ptDis.distanceTo(ptCor2);
|
||
double dWidthBr1, dWidthBr2;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dWidthBr1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dWidthBr2);
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eInsertCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType, (int&)eSectType);
|
||
// 不用该分支了
|
||
if (dis1 < dis2)
|
||
{
|
||
GetIntersectWith(ptCor1, ptInter1, vtStartv, vtStart, ptInter);
|
||
if ((ptInter.distanceTo(ptInter1) + ddisPar) < dLength)
|
||
{
|
||
if (!(eCrossType == AecHvac::eInsertCross || eCrossType == AecHvac::eInsertIntubCross))
|
||
ptRet = ptInter1 + vtStart * dLength;
|
||
else
|
||
{
|
||
if(eCircle == eSectType)
|
||
ptRet = ptInter + vtStart * 50;
|
||
else
|
||
ptRet = ptInter1 + vtStart * (100.0 + dPlusEdge + dWidthBr1 * 0.5);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!(eCrossType == AecHvac::eInsertCross || eCrossType == AecHvac::eInsertIntubCross))
|
||
ptRet = ptInter + vtStart * ddisPar;
|
||
else
|
||
ptRet = ptInter + vtStart * (100.0 + dPlusEdge);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetIntersectWith(ptCor2, ptInter2, vtStartv, vtStart,ptInter);
|
||
if ((ptInter.distanceTo(ptInter2) + ddisPar) < dLength)
|
||
{
|
||
if (!(eCrossType == AecHvac::eInsertCross || eCrossType == AecHvac::eInsertIntubCross))
|
||
ptRet = ptInter2 + vtStart * dLength;
|
||
else
|
||
{
|
||
if(eCircle == eSectType)
|
||
ptRet = ptInter + vtStart * 50;
|
||
else
|
||
ptRet = ptInter2 + vtStart * (100.0 + dPlusEdge + dWidthBr2 * 0.5);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!(eCrossType == AecHvac::eInsertCross || eCrossType == AecHvac::eInsertIntubCross))
|
||
ptRet = ptInter + vtStart * ddisPar;
|
||
else
|
||
ptRet = ptInter + vtStart * (100.0 + dPlusEdge);
|
||
}
|
||
}
|
||
return ptRet;
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetInterBrPt(AcGePoint3d ptStart,AcGePoint3d ptInter1,AcGePoint3d ptInter2,AcGePoint3d ptCor1,
|
||
AcGePoint3d ptCor2,AcGeVector3d vtStart,double dLength) const
|
||
{
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis,vtStartv;
|
||
vtNor = GetSectNormal();
|
||
vtStartv = vtStart;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
double dPlusEnd = MayAsMUnit(50.0);
|
||
double dPlusBr = MayAsMUnit(150.0);
|
||
AcGePoint3d ptInter,ptRet;
|
||
|
||
double ddisPar = dPlusEnd + dPlusEdge;
|
||
AcGePoint3d ptDis = ptStart + vtStart * 10000;
|
||
double dis1 = ptDis.distanceTo(ptCor1);
|
||
double dis2 = ptDis.distanceTo(ptCor2);
|
||
double dWidthBr1, dWidthBr2;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dWidthBr1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dWidthBr2);
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eInsertCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
if (dis1 < dis2)
|
||
{
|
||
ptRet = (ptCor1 + vtStart * dPlusBr) + vtStartv * (dLength + dPlusEdge);
|
||
}
|
||
else
|
||
{
|
||
ptRet = (ptCor2 + vtStart * dPlusBr) - vtStartv * (dLength + dPlusEdge);
|
||
}
|
||
return ptRet;
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetInterFinalPt(AcGePoint3d ptStart,AcGePoint3d ptInter1,AcGePoint3d ptInter2,AcGePoint3d ptCor1,
|
||
AcGePoint3d ptCor2,AcGeVector3d vtStart,double dLength) const
|
||
{
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis,vtStartv;
|
||
vtNor = GetSectNormal();
|
||
vtStartv = vtStart;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
double dPlusEnd = MayAsMUnit(50.0);
|
||
AcGePoint3d ptInter,ptRet;
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
double ddisPar = dPlusEnd + dPlusEdge;
|
||
AcGePoint3d ptDis = ptStart + vtStart * 10000;
|
||
double dis1 = ptDis.distanceTo(ptCor1);
|
||
double dis2 = ptDis.distanceTo(ptCor2);
|
||
double dWidthBr1, dWidthBr2;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dWidthBr1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dWidthBr2);
|
||
AecHvac::HvacCrossType eCrossType = AecHvac::eInsertCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eCrossType);
|
||
if (dis1 < dis2)
|
||
{
|
||
GetIntersectWith(ptCor1, ptInter1, vtStartv, vtStart, ptInter);
|
||
if ((ptInter.distanceTo(ptInter1) + ddisPar) < dLength)
|
||
{
|
||
ptRet = ptInter1 + vtStart * (100.0 + dPlusEdge + dWidthBr1 * 0.5);
|
||
}
|
||
else
|
||
{
|
||
ptRet = ptInter + vtStart * (100.0 + dPlusEdge);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GetIntersectWith(ptCor2, ptInter2, vtStartv, vtStart,ptInter);
|
||
if ((ptInter.distanceTo(ptInter2) + ddisPar) < dLength)
|
||
{
|
||
|
||
ptRet = ptInter2 + vtStart * (100.0 + dPlusEdge + dWidthBr2 * 0.5);
|
||
}
|
||
else
|
||
{
|
||
|
||
ptRet = ptInter + vtStart * (100.0 + dPlusEdge);
|
||
}
|
||
}
|
||
return ptRet;
|
||
}
|
||
|
||
AcGePoint3d ImpHvacCross::GetFinalPtEnd(AcGePoint3d ptStart,AcGePoint3d ptInter1,AcGePoint3d ptInter2,AcGePoint3d ptCor1,
|
||
AcGePoint3d ptCor2,AcGeVector3d vtStart, double dPlusEnd) const
|
||
{
|
||
AcGeVector3d vtNor = AcGeVector3d::kZAxis,vtStartv;
|
||
vtNor = GetSectNormal();
|
||
vtStartv = vtStart;
|
||
vtStartv.rotateBy(PI * 0.5,vtNor);
|
||
double dPlusEdge = MayAsMUnit(50.0);
|
||
AcGePoint3d ptInter,ptRet;
|
||
m_pXDataMap->GetAt(HVAC_PlusEdge, dPlusEdge);
|
||
double ddisPar = dPlusEnd + dPlusEdge;
|
||
AcGePoint3d ptDis = ptStart + vtStart * 10000;
|
||
double dis1 = ptDis.distanceTo(ptCor1);
|
||
double dis2 = ptDis.distanceTo(ptCor2);
|
||
if (dis1 < dis2)
|
||
{
|
||
GetIntersectWith(ptCor1, ptInter1, vtStartv, vtStart, ptInter);
|
||
ptRet = ptInter + vtStart * ddisPar;
|
||
}
|
||
else
|
||
{
|
||
GetIntersectWith(ptCor2, ptInter2, vtStartv, vtStart,ptInter);
|
||
ptRet = ptInter + vtStart * ddisPar;
|
||
}
|
||
return ptRet;
|
||
}
|
||
|
||
BOOL ImpHvacCross::GetInterfaceKeyPt(AcGePoint3dArray &ptUpArr, AcGePoint3dArray &ptDownArr) const
|
||
{
|
||
// 7━━━━━6
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// 0━━━━┛ ┃ ┗━━━━5
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ━━━━━━━━━━━━━━━━
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// 1━━━━┓ ┃ ┏━━━━4
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// ┃ ┃ ┃
|
||
// 2━━━━━3
|
||
|
||
if (NULL == m_pXDataMap)
|
||
{
|
||
return FALSE;
|
||
}
|
||
ESection eSectTeye = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType, (int&)eSectTeye);
|
||
|
||
AcGePoint3d ptStart, ptEnd, ptBran1, ptBran2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBran1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBran2);
|
||
|
||
AcGeVector3d vtNormal = normal();
|
||
AcGeVector3d vtStart, vtEnd, vtBran1, vtBran2;
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBran1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBran2);
|
||
AcGeVector3d vtStartSide = vtStart;
|
||
vtStartSide.rotateBy(PI * 0.5, vtNormal);
|
||
AcGeVector3d vtEndSide = vtEnd;
|
||
vtEndSide.rotateBy(PI * 0.5, vtNormal);
|
||
AcGeVector3d vtBranSide1 = vtBran1;
|
||
vtBranSide1.rotateBy(PI * 0.5, vtNormal);
|
||
AcGeVector3d vtBranSide2 = vtBran2;
|
||
vtBranSide2.rotateBy(PI * 0.5, vtNormal);
|
||
|
||
double dStrWidth = 0, dEndWidth = 0, dBranWidth1 = 0, dBranWidth2 = 0;
|
||
m_pXDataMap->GetAt(HCRS_StartWidth, dStrWidth);
|
||
m_pXDataMap->GetAt(HCRS_EndWidth, dEndWidth);
|
||
m_pXDataMap->GetAt(HCRS_Branch1Width, dBranWidth1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Width, dBranWidth2);
|
||
double dHalfStrWidth = dStrWidth * 0.5;
|
||
double dHalfEndWidth = dEndWidth * 0.5;
|
||
double dHalfBranWidth1 = dBranWidth1 * 0.5;
|
||
double dHalfBranWidth2 = dBranWidth2 * 0.5;
|
||
|
||
double dStrThick = 0, dEndThick = 0, dBranThick1 = 0, dBranThick2 = 0;
|
||
if(eRect != eSectTeye)
|
||
{
|
||
dStrThick = dStrWidth;
|
||
dEndThick = dEndWidth;
|
||
dBranThick1 = dBranWidth1;
|
||
dBranThick2 = dBranWidth2;
|
||
}
|
||
else
|
||
{
|
||
m_pXDataMap->GetAt(HCRS_Thick, dStrThick);
|
||
if(!m_pXDataMap->GetAt(HCRS_EndThick, dEndThick))
|
||
dEndThick = dStrThick;
|
||
m_pXDataMap->GetAt(HCRS_Branch1Thick, dBranThick1);
|
||
m_pXDataMap->GetAt(HCRS_Branch2Thick, dBranThick2);
|
||
}
|
||
|
||
double dHalfStrThick = dStrThick * 0.5;
|
||
double dHalfEndThick = dEndThick * 0.5;
|
||
double dHalfBranThick1 = dBranThick1 * 0.5;
|
||
double dHalfBranThick2 = dBranThick2 * 0.5;
|
||
|
||
AcGePoint3d ptUp, ptDown;
|
||
// pt0
|
||
ptUp = ptStart - vtStartSide * dHalfStrWidth;
|
||
ptUp = ptUp + vtNormal * dHalfStrThick;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dStrThick;
|
||
ptDownArr.append(ptDown);
|
||
|
||
// pt1
|
||
ptUp = ptStart + vtStartSide * dHalfStrWidth;
|
||
ptUp = ptUp + vtNormal * dHalfStrThick;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dStrThick;
|
||
ptDownArr.append(ptDown);
|
||
|
||
// pt2
|
||
ptUp = ptBran1 - vtBranSide1 * dHalfBranWidth1;
|
||
ptUp = ptUp + vtNormal * dHalfBranThick1;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dBranThick1;
|
||
ptDownArr.append(ptDown);
|
||
|
||
// pt3
|
||
ptUp = ptBran1 + vtBranSide1 * dHalfBranWidth1;
|
||
ptUp = ptUp + vtNormal * dHalfBranThick1;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dBranThick1;
|
||
ptDownArr.append(ptDown);
|
||
|
||
// pt4
|
||
ptUp = ptEnd - vtEndSide * dHalfEndWidth;
|
||
ptUp = ptUp + vtNormal * dHalfEndThick;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dEndThick;
|
||
ptDownArr.append(ptDown);
|
||
|
||
// pt5
|
||
ptUp = ptEnd + vtEndSide * dHalfEndWidth;
|
||
ptUp = ptUp + vtNormal * dHalfEndThick;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dEndThick;
|
||
ptDownArr.append(ptDown);
|
||
|
||
// pt6
|
||
ptUp = ptBran2 - vtBranSide2 * dHalfBranWidth2;
|
||
ptUp = ptUp + vtNormal * dHalfBranThick2;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dBranThick2;
|
||
ptDownArr.append(ptDown);
|
||
|
||
// pt7
|
||
ptUp = ptBran2 + vtBranSide2 * dHalfBranWidth2;
|
||
ptUp = ptUp + vtNormal * dHalfBranThick2;
|
||
ptUpArr.append(ptUp);
|
||
ptDown = ptUp - vtNormal * dBranThick2;
|
||
ptDownArr.append(ptDown);
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
double ImpHvacCross::InsertLength(double dEndWidth, double dBr1Width, double dBr2Width,
|
||
double dFlange, double dAngle, AecHvac::HvacCrossType eType) const
|
||
{
|
||
double dWidth = dBr1Width > dBr2Width ? dBr1Width : dBr2Width;
|
||
if (AecHvac::eInsertCross == eType)
|
||
{
|
||
// 承插标准长度算法
|
||
if ((int)dAngle == 30)
|
||
{
|
||
return dEndWidth + dWidth + 1.866 * (dFlange * 2.0 + 20);
|
||
}
|
||
if ((int)dAngle == 45)
|
||
{
|
||
return (dEndWidth + dWidth) * 0.65 + 1.21 * (dFlange * 2.0 + 20);
|
||
}
|
||
}
|
||
|
||
if (AecHvac::eInclineCross == eType)
|
||
{
|
||
// 斜接标准长度算法
|
||
double dTmp = (dWidth * cos(dAngle * PI / 180) + dEndWidth) * 0.5 * 1.4 / sin(dAngle * PI / 180);
|
||
|
||
int iTmp = (int)dTmp;
|
||
int iDivNum = iTmp / 50;
|
||
int iNum = iTmp % 50;
|
||
if (iNum != 0)
|
||
{
|
||
iDivNum++;
|
||
}
|
||
|
||
iTmp = iDivNum * 50;
|
||
dTmp = (double)iTmp;
|
||
dTmp += dFlange;
|
||
|
||
return dTmp;
|
||
}
|
||
return dWidth;
|
||
}
|
||
|
||
BOOL ImpHvacCross::GetInterfaceSizeData(int nIndex, AecInterface& inf) const
|
||
{
|
||
ASSERT(NULL != m_pXDataMap);
|
||
|
||
// 获取对象类型
|
||
AecHvac::HvacCrossType eType = AecHvac::eOrthoCross;
|
||
m_pXDataMap->GetAt(HCRS_Type, (int&)eType);
|
||
|
||
// 获取截面类型
|
||
ESection eSectType = eRect;
|
||
m_pXDataMap->GetAt(HVAC_SectType, (int&)eSectType);
|
||
|
||
// 获取接口截面、宽度、厚度数据key值
|
||
LPCTSTR pszWidthKey, pszThickKey;
|
||
switch (nIndex)
|
||
{
|
||
case 0:
|
||
pszWidthKey = ((eCircle == eSectType) ? HCRS_StartDiameter : HCRS_StartWidth);
|
||
pszThickKey = HCRS_Thick;
|
||
break;
|
||
case 1:
|
||
pszWidthKey = ((eCircle == eSectType) ? HCRS_EndDiameter : HCRS_EndWidth);
|
||
pszThickKey = HCRS_Thick;
|
||
break;
|
||
case 2:
|
||
pszWidthKey = ((eCircle == eSectType) ? HCRS_Branch1Diameter : HCRS_Branch1Width);
|
||
pszThickKey = ((AecHvac::eInsertCross == eType || AecHvac::eInsertIntubCross == eType) ? HCRS_Branch1Thick : HCRS_Thick);
|
||
break;
|
||
case 3:
|
||
pszWidthKey = ((eCircle == eSectType) ? HCRS_Branch2Diameter : HCRS_Branch2Width);
|
||
pszThickKey = ((AecHvac::eInsertCross == eType || AecHvac::eInsertIntubCross == eType) ? HCRS_Branch2Thick : HCRS_Thick);
|
||
break;
|
||
default:
|
||
return FALSE;
|
||
}
|
||
|
||
// 获取尺寸
|
||
double dWidth = 0.0, dThick = 0.0;
|
||
m_pXDataMap->GetAt(pszWidthKey, dWidth);
|
||
m_pXDataMap->GetAt(pszThickKey, dThick);
|
||
|
||
// 设置接口数据
|
||
inf.nSectType = eSectType;
|
||
inf.dSize1 = dWidth;
|
||
inf.dSize2 = dThick;
|
||
|
||
return TRUE;
|
||
}
|
||
|
||
bool ImpHvacCross::GetInterface(AcArray<AecInterface>& arInfs) const
|
||
{
|
||
if (NULL == m_pXDataMap)
|
||
return FALSE;
|
||
|
||
// 获取四通各点位置
|
||
AcGePoint3d ptStart,ptEnd,ptBr1,ptBr2;
|
||
AcGeVector3d vtStart,vtEnd,vtBr1,vtBr2;
|
||
m_pXDataMap->GetAt(HCRS_StartPoint, ptStart);
|
||
m_pXDataMap->GetAt(HCRS_StartDir, vtStart);
|
||
m_pXDataMap->GetAt(HCRS_EndPoint, ptEnd);
|
||
m_pXDataMap->GetAt(HCRS_EndDir, vtEnd);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint1, ptBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir1, vtBr1);
|
||
m_pXDataMap->GetAt(HCRS_BranchPoint2, ptBr2);
|
||
m_pXDataMap->GetAt(HCRS_BranchDir2, vtBr2);
|
||
|
||
AecInterface inf;
|
||
inf.idOwner = m_pOwnerEnt->objectId();
|
||
for (int nIndex = 0;nIndex <= 3;nIndex++)
|
||
{
|
||
switch(nIndex)
|
||
{
|
||
case 0:
|
||
{
|
||
// 没有管件连接
|
||
inf.vtDir = vtStart;
|
||
inf.ptPos = ptStart;
|
||
GetInterfaceSizeData(nIndex, inf);
|
||
break;
|
||
}
|
||
case 1:
|
||
{
|
||
// 没有管件连接
|
||
inf.vtDir = vtEnd;
|
||
inf.ptPos = ptEnd;
|
||
GetInterfaceSizeData(nIndex, inf);
|
||
break;
|
||
}
|
||
case 2:
|
||
{
|
||
// 没有管件连接
|
||
inf.vtDir = vtBr1;
|
||
inf.ptPos = ptBr1;
|
||
GetInterfaceSizeData(nIndex, inf);
|
||
break;
|
||
}
|
||
case 3:
|
||
{
|
||
// 没有管件连接
|
||
inf.vtDir = vtBr2;
|
||
inf.ptPos = ptBr2;
|
||
GetInterfaceSizeData(nIndex, inf);
|
||
break;
|
||
}
|
||
}
|
||
arInfs.append(inf);
|
||
}
|
||
return true;
|
||
} |