Files
envi-code/SourceCode/Code2026/tg_shs/shs_pipewire/DbWaterTank.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

1818 lines
63 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// DbWaterTank.cpp: implementation of the TDbWaterTank class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "DbWaterTank.h"
#define PSCALE 100 // 管线加粗
extern Acad::ErrorStatus DrawPolyMesh(XPoint ptS, XPoint ptE, double nRadius, XExplodeDraw &dc);
void GetPointList(XCurveSegment seg, int iNum, XPointList &lstPt, int mode)
{
if(mode == 0){
if(seg.Is(CURVE_LINE)){
XLine line = seg.GetLine();
double angLine = ads_angle(line.GetStartPoint(), line.GetEndPoint());
double distLine = line.GetLength() / iNum / 2;
int n = 0;
while(n < iNum){
XPoint ptTemp;
ads_polar(line.GetStartPoint(), angLine, (2*n+1)*distLine, ptTemp);
lstPt.NewAppend(ptTemp);
n++;
}
}
else if(seg.Is(CURVE_ARC)){
XArc arc = seg.GetArc();
double al = arc.GetEndAngle() - arc.GetStarAngle();
if(al < 0)
al += 2 * PI;
double distArc = al / iNum / 2;
int n = 0;
while(n < iNum){
XPoint ptTemp;
ads_polar(arc.GetCenterPt(), (arc.GetStarAngle() + distArc*(1+ 2*n)), arc.GetRadius(), ptTemp);
lstPt.NewAppend(ptTemp);
n++;
}
}
else if(seg.Is(CURVE_CIRCLE)){
XCircle cir = seg.GetCircle();
double al = 2 * PI;
double start = -(PI/2);
double distCir = al / iNum / 2;
int n = 0;
while(n < iNum){
XPoint ptTemp;
ads_polar(cir.GetCenterPt(), (start + distCir*(1+ 2*n)), cir.GetRadius(), ptTemp);
lstPt.NewAppend(ptTemp);
n++;
}
}
}
else if(mode == 1){
if(iNum < 2)
return;
if(seg.Is(CURVE_LINE)){
XLine line = seg.GetLine();
double angLine = ads_angle(line.GetStartPoint(), line.GetEndPoint());
double distLine = line.GetLength() / (iNum - 1);
int n = 0;
while(n < iNum){
XPoint ptTemp;
ads_polar(line.GetStartPoint(), angLine, n*distLine, ptTemp);
lstPt.NewAppend(ptTemp);
n++;
}
}
else if(seg.Is(CURVE_ARC)){
XArc arc = seg.GetArc();
double al = arc.GetEndAngle() - arc.GetStarAngle();
if(al < 0)
al += 2 * PI;
double distArc = al / (iNum - 1);
int n = 0;
while(n < iNum){
XPoint ptTemp;
ads_polar(arc.GetCenterPt(), (arc.GetStarAngle() + distArc*n), arc.GetRadius(), ptTemp);
lstPt.NewAppend(ptTemp);
n++;
}
}
}
}
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
ACRX_DXF_DEFINE_MEMBERS(ATSWaterTank, ATSEntity, AcDb::kDHL_CURRENT,
AcDb::kMReleaseCurrent, 1, ATS_WATERTANK,
"ATS_WATERTANK图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
IMPLEMENT_TENTBASE(TDbWaterTank);
const Adesk::UInt8 TDbWaterTank::g_nVersion = 2;
TDbWaterTank::TDbWaterTank()
{
m_bNeedHole = TRUE;
m_bNeedSleeper = TRUE;
m_iShape = 1;
m_iShowType = 0;
m_iSleeperNum = 3;
m_iSleeperPos = 0;
m_nHighLine = 0;
m_nLowLine = 0;
m_nHoleWidth = 0.25;
m_nSleeperWidth = 0.1;
m_nHeight = 3;
m_nLength = 3;
m_nWidth = 3;
m_nSpare = 0.2;
m_nRotation = 0;
m_nOverfallEle = 0;
m_nRushEle = 0;
m_nWaterInEle = 0;
m_bHoleIsRect = FALSE;
}
void TDbWaterTank::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
{
assertWriteEnabled();
TDbWaterTank *pSect = TDbWaterTank::cast(pSrc);
if(pSect) {
m_nHeight = pSect->m_nHeight;
m_nLength = pSect->m_nLength;
m_nWidth = pSect->m_nWidth;
}
TDbEntity::CopyPropertiesFrom(pSrc, gMatchFlag);
}
Acad::ErrorStatus TDbWaterTank::subGetClassID(CLSID* pClsid) const
{
return Acad::eOk;
}
// 取得所有的夹点
Acad::ErrorStatus
TDbWaterTank::subGetGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
assertReadEnabled();
gripPoints.append(m_ptLocation);
if(m_iShowType == 0){
gripPoints.append(m_ptHoleInsert);
if(!!m_ptOverfallStart && !!m_ptOverfallEnd){
gripPoints.append(m_ptOverfallStart);
gripPoints.append(m_ptOverfallEnd);
}
}
return Acad::eOk;
}
// 功能: 夹点操作
Acad::ErrorStatus
TDbWaterTank::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset)
{
assertWriteEnabled();
bool bMoveHole = false; // cet 2011.10.10 add
AcGeMatrix3d mat;
AcGeVector3d vtOffset=offset;
//vtOffset.z=0; zxl modify 2012.12.03 支持z轴移动
mat.setToTranslation(vtOffset);
int idx=0;
for (int i = 0; i < indices.length(); i++) {
idx = indices[i];
if(idx == 0){
m_ptLocation.TransformBy(mat);
SetElev(m_ptLocation.z / 1000, false);
// cet 2011.10.10 modify ucs下无进出管时,无需坐标变换,否则会绘制出进出管
// m_ptHoleInsert.TransformBy(mat);
// m_ptOverfallStart.TransformBy(mat);
// m_ptOverfallEnd.TransformBy(mat);
// m_ptWaterIn1.TransformBy(mat);
// m_ptWaterIn2.TransformBy(mat);
if (!bMoveHole)
{
bMoveHole = true;
m_ptHoleInsert.TransformBy(mat);
}
if (!!m_ptOverfallStart)
{
m_ptOverfallStart.TransformBy(mat);
}
if (!!m_ptOverfallEnd)
{
m_ptOverfallEnd.TransformBy(mat);
}
if (!!m_ptWaterIn1)
{
m_ptWaterIn1.TransformBy(mat);
}
if (!!m_ptWaterIn2)
{
m_ptWaterIn2.TransformBy(mat);
}
m_ptWaterInFrom.TransformBy(mat);
}
else if(idx == 1){
//m_ptHoleInsert.TransformBy(mat); cet 2011.10.10 modify
if (!bMoveHole)
{
bMoveHole = true;
m_ptHoleInsert.TransformBy(mat);
}
}
else if(idx == 2){
m_ptOverfallStart.TransformBy(mat);
}
else if(idx == 3){
m_ptOverfallEnd.TransformBy(mat);
}
}
Acad::ErrorStatus es=Acad::eOk;
return es;
}
Acad::ErrorStatus
TDbWaterTank::GetGripText(int idx, CString &cs) const
{
Acad::ErrorStatus es=Acad::eOk;
switch(idx) {
case 0:
cs=_T("移动水箱");
break;
case 1:
cs=_T("移动人孔");
break;
case 2:
cs=_T("溢流管起点");
break;
case 3:
cs=_T("溢流管终点");
break;
default:
es=Acad::eInvalidInput;
}
return es;
}
// 从DWG读入数据:
Acad::ErrorStatus TDbWaterTank::dwgInFields(AcDbDwgFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler);
if(es != Acad::eOk) return es;
Adesk::UInt8 nVer;
pFiler->readItem(&nVer);
if(nVer>g_nVersion) {// Version is too new
return Acad::eMakeMeProxy;
}
pFiler->readItem((AcGePoint3d *)&m_ptLocation);
pFiler->readItem((AcGePoint3d *)&m_ptHoleInsert);
pFiler->readItem((AcGePoint3d *)&m_ptOverfallStart);
pFiler->readItem((AcGePoint3d *)&m_ptOverfallEnd);
pFiler->readItem((AcGePoint3d *)&m_ptWaterIn1);
pFiler->readItem((AcGePoint3d *)&m_ptWaterIn2);
pFiler->readItem((AcGePoint3d *)&m_ptWaterInFrom);
//pFiler->readItem(&m_bNeedHole);
//pFiler->readItem(&m_bNeedSleeper);
FilerRead(pFiler, m_bNeedHole);
FilerRead(pFiler, m_bNeedSleeper);
pFiler->readItem(&m_iShape);
pFiler->readItem(&m_iShowType);
pFiler->readItem(&m_iSleeperNum);
pFiler->readItem(&m_iSleeperPos);
pFiler->readItem(&m_nHighLine);
pFiler->readItem(&m_nLowLine);
pFiler->readItem(&m_nHoleWidth);
pFiler->readItem(&m_nSleeperWidth);
pFiler->readItem(&m_nHeight);
pFiler->readItem(&m_nLength);
pFiler->readItem(&m_nWidth);
pFiler->readItem(&m_nRotation);
pFiler->readItem(&m_nOverfallEle);
pFiler->readItem(&m_nRushEle);
pFiler->readItem(&m_nWaterInEle);
pFiler->readItem(&m_nSpare);
pFiler->readItem(&m_idDashLayer);
pFiler->readItem(&m_idBlock3d);
if(nVer > 1){
//pFiler->readItem(&m_bHoleIsRect);
FilerRead(pFiler, m_bHoleIsRect);
pFiler->readItem(&m_iSpare);
pFiler->readItem((AcGePoint3d *)&m_ptSpare);
ReadString(pFiler,m_sSpare);
}
return pFiler->filerStatus();
}
Acad::ErrorStatus TDbWaterTank::dwgOutFields(AcDbDwgFiler* pFiler) const
{
assertReadEnabled();
Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler);
if(es != Acad::eOk) return es;
// pFiler->writeItem(g_nVersion);
if(g_nSaveTArchVer==7)
pFiler->writeItem((Adesk::UInt8)1);
else
pFiler->writeItem(g_nVersion);
pFiler->writeItem((const AcGePoint3d &)m_ptLocation);
pFiler->writeItem((const AcGePoint3d &)m_ptHoleInsert);
pFiler->writeItem((const AcGePoint3d &)m_ptOverfallStart);
pFiler->writeItem((const AcGePoint3d &)m_ptOverfallEnd);
pFiler->writeItem((const AcGePoint3d &)m_ptWaterIn1);
pFiler->writeItem((const AcGePoint3d &)m_ptWaterIn2);
pFiler->writeItem((const AcGePoint3d &)m_ptWaterInFrom);
//pFiler->writeItem(m_bNeedHole);
//pFiler->writeItem(m_bNeedSleeper);
FilerWrite(pFiler, m_bNeedHole);
FilerWrite(pFiler, m_bNeedSleeper);
pFiler->writeItem(m_iShape);
pFiler->writeItem(m_iShowType);
pFiler->writeItem(m_iSleeperNum);
pFiler->writeItem(m_iSleeperPos);
pFiler->writeItem(m_nHighLine);
pFiler->writeItem(m_nLowLine);
pFiler->writeItem(m_nHoleWidth);
pFiler->writeItem(m_nSleeperWidth);
pFiler->writeItem(m_nHeight);
pFiler->writeItem(m_nLength);
pFiler->writeItem(m_nWidth);
pFiler->writeItem(m_nRotation);
pFiler->writeItem(m_nOverfallEle);
pFiler->writeItem(m_nRushEle);
pFiler->writeItem(m_nWaterInEle);
pFiler->writeItem(m_nSpare);
pFiler->writeItem(m_idDashLayer);
pFiler->writeItem(m_idBlock3d);
if(g_nSaveTArchVer>7){
//pFiler->writeItem(m_bHoleIsRect);
FilerWrite(pFiler, m_bHoleIsRect);
pFiler->writeItem(m_iSpare);
pFiler->writeItem((const AcGePoint3d &)m_ptSpare);
pFiler->writeItem((const TCHAR *)m_sSpare);
}
return pFiler->filerStatus();
}
Acad::ErrorStatus TDbWaterTank::dxfInFields(AcDbDxfFiler* pFiler)
{
assertWriteEnabled();
Acad::ErrorStatus es=Acad::eOk;
es=TDbEntity::dxfInFields(pFiler);
return es;
}
Acad::ErrorStatus TDbWaterTank::dxfOutFields(AcDbDxfFiler* pFiler) const
{
Acad::ErrorStatus es=Acad::eOk;
es=TDbEntity::dxfOutFields(pFiler);
return es;
}
// Active when being rotated, scaled, moved, etc.
Acad::ErrorStatus
TDbWaterTank::subTransformBy(const AcGeMatrix3d& xform)
{
assertWriteEnabled();
m_ptLocation.TransformBy(xform);
SetElev(m_ptLocation.z / 1000, false); // zxl 2012.12.03 add
m_ptHoleInsert.TransformBy(xform);
double nLength = m_nLength * 1000;
double nWidth = m_nWidth * 1000;
TDbRect rect1;
rect1.SetSizeX(nLength);
rect1.SetSizeY(nWidth);
rect1.SetCenter(m_ptLocation);
rect1.SetRotation(m_nRotation);
XPoint ptLowLeft=rect1.GetLowLeft();
XPoint ptLowRight=rect1.GetLowRight();
((AcGePoint3d &)ptLowLeft).transformBy(xform);
((AcGePoint3d &)ptLowRight).transformBy(xform);
if(!!m_ptOverfallStart)
m_ptOverfallStart.TransformBy(xform);
if(!!m_ptOverfallEnd)
m_ptOverfallEnd.TransformBy(xform);
if(!!m_ptWaterIn1)
m_ptWaterIn1.TransformBy(xform);
if(!!m_ptWaterIn2)
m_ptWaterIn2.TransformBy(xform);
if(!!m_ptWaterInFrom)
m_ptWaterInFrom.TransformBy(xform);
m_nRotation=ads_angle(ptLowLeft, ptLowRight);
Acad::ErrorStatus es=Acad::eOk;
return es;
}
Acad::ErrorStatus TDbWaterTank::DrawCircleSect0(XExplodeDraw &dc) const
{
double nLength = m_nLength * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
double nHeight = m_nHeight * 1000;
double nWidth = m_nWidth * 1000;
double nSleeperWidth = m_nSleeperWidth * 1000;
TDbRect rect1;
rect1.SetSizeX(nLength);
rect1.SetSizeY(nHeight);
rect1.SetCenter(m_ptLocation);
rect1.SetRotation(m_nRotation);
XLine line3(rect1.GetUpLeft(), rect1.GetLowLeft());
dc << line3;
XLine line4(rect1.GetUpRight(), rect1.GetLowRight());
dc << line4;
XLine line1(rect1.GetUpLeft(), rect1.GetUpRight());
XPoint ptTmp;
ptTmp = line1.MidPoint();
ads_polar(ptTmp, m_nRotation+PI/2, 3*PSCALE, ptTmp);
XArc arc(rect1.GetUpLeft(),ptTmp,rect1.GetUpRight());
dc << arc;
XLine line2(rect1.GetLowLeft(), rect1.GetLowRight());
ptTmp = line2.MidPoint();
ads_polar(ptTmp, m_nRotation-PI/2, 3*PSCALE, ptTmp);
XArc arc2(rect1.GetLowLeft(),ptTmp,rect1.GetLowRight());
dc << arc2;
ads_polar(ptTmp, m_nRotation-PI/2, nWidth/2, ptTmp);
TDbRect rect3;
rect3.SetCenter(ptTmp);
rect3.SetRotation(m_nRotation);
rect3.SetSizeX(nSleeperWidth);
rect3.SetSizeY(nWidth);
rect3.ExplodeOrDraw2d(dc);
ads_polar(rect1.GetLowLeft(), m_nRotation-PI/2, (nWidth+3*PSCALE)/2, ptTmp);
ads_polar(ptTmp, m_nRotation, nSleeperWidth/2, ptTmp);
TDbRect rect4;
rect4.SetCenter(ptTmp);
rect4.SetRotation(m_nRotation);
rect4.SetSizeX(nSleeperWidth);
rect4.SetSizeY(nWidth+3*PSCALE);
rect4.ExplodeOrDraw2d(dc);
ads_polar(rect1.GetLowRight(), m_nRotation-PI/2, (nWidth+3*PSCALE)/2, ptTmp);
ads_polar(ptTmp, m_nRotation-PI, nSleeperWidth/2, ptTmp);
TDbRect rect5;
rect5.SetCenter(ptTmp);
rect5.SetRotation(m_nRotation);
rect5.SetSizeX(nSleeperWidth);
rect5.SetSizeY(nWidth+3*PSCALE);
rect5.ExplodeOrDraw2d(dc);
return Acad::eOk;
}
//绘制水位线
Acad::ErrorStatus TDbWaterTank::DrawWaterLevel(XPoint pt1, XPoint pt2, double nScale, XExplodeDraw &dc) const
{
XLine line9(pt1, pt2, 1);
double nAng = line9.Direction();
dc << line9;
XPoint ptMid, p3, p4;
ptMid = line9.MidPoint();
ads_polar(ptMid, nAng-PI/2, nScale/2, ptMid);
ads_polar(ptMid, nAng, nScale*2, p3);
ads_polar(ptMid, nAng, -nScale*2, p4);
dc << XLine(p3, p4);
ads_polar(ptMid, nAng-PI/2, nScale/2, ptMid);
ads_polar(ptMid, nAng, nScale, p3);
ads_polar(ptMid, nAng, -nScale, p4);
dc << XLine(p3, p4);
ads_polar(ptMid, nAng-PI/2, nScale/2, ptMid);
ads_polar(ptMid, nAng, nScale/2, p3);
ads_polar(ptMid, nAng, -nScale/2, p4);
dc << XLine(p3, p4);
return Acad::eOk;
}
void TDbWaterTank::DrawPLine(XPoint ptStart, XPoint ptEnd, XExplodeDraw &dc) const
{
XLine pLine(ptStart, ptEnd, 1);
XCurveSegment seg;
seg = pLine;
XPoly2D poly;
seg.AsPoly2D(poly);
AcDbPolyline pline;
PolyConvert(poly, pline);
XAcGiViewDraw &viewDraw = (XAcGiViewDraw &)dc;
int nNum = pline.numVerts();
if (nNum > 0) {
for (int k=0;k<nNum; k++) {
pline.setWidthsAt(k,0.35*PSCALE,0.35*PSCALE);
}
viewDraw.Polyline(pline);
}
}
Acad::ErrorStatus TDbWaterTank::DrawLeftSect(XExplodeDraw &dc) const
{
double nHeight = m_nHeight * 1000;
double nLength = m_nLength * 1000;
double nWidth = m_nWidth * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
//double nSleeperWidth = m_nSleeperWidth * 1000;
TDbRect rect1;
rect1.SetSizeX(nWidth);
rect1.SetSizeY(nHeight);
rect1.SetCenter(m_ptLocation);
rect1.SetRotation(m_nRotation);
rect1.ExplodeOrDraw2d(dc);
XPoint ptTmp1, ptTmp2, ptTmp3, ptTmp4, ptTmp5, ptTmp6;
if(!!m_ptWaterIn1 && !!m_ptWaterIn2 && m_nWaterInEle > 0){
XLine line1(m_ptWaterIn1, m_ptWaterInFrom, 1);
TDbRect rect10;
rect10.SetSizeX(nLength);
rect10.SetSizeY(nWidth);
rect10.SetCenter(m_ptLocation);
rect10.SetRotation(m_nRotation);
XLine line11(rect10.GetUpLeft(), rect10.GetUpRight(), 1);
XLine line22(rect10.GetLowLeft(), rect10.GetLowRight(), 1);
XLine line33(rect10.GetUpLeft(), rect10.GetLowLeft(), 1);
XLine line44(rect10.GetUpRight(), rect10.GetLowRight(), 1);
int ret1 = line1.Intersection(&line11, ptTmp1);
int ret2 = line1.Intersection(&line22, ptTmp1);
int ret3 = line1.Intersection(&line33, ptTmp1);
int ret4 = line1.Intersection(&line44, ptTmp1);
double nAngle(0);
if(ret1 == 1)
nAngle = PI;
double nValveLen = PSCALE*2;
if(ret3 == 1 || ret4 == 1){
ptTmp1 = m_ptWaterIn1;
ptTmp1.Project(&line44, ptTmp2);
double nDist = ads_distance(rect10.GetUpRight(), ptTmp2);
ads_polar(rect1.GetLowLeft(), m_nRotation, nDist, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, m_nWaterInEle*1000, ptTmp2);
dc << XCircle(ptTmp2, PSCALE/2);
ptTmp1 = m_ptWaterIn2;
ptTmp1.Project(&line44, ptTmp2);
nDist = ads_distance(rect10.GetUpRight(), ptTmp2);
ads_polar(rect1.GetLowLeft(), m_nRotation, nDist, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, m_nWaterInEle*1000, ptTmp2);
dc << XCircle(ptTmp2, PSCALE/2);
}
else if(ret1 == 1 || ret2 == 1){
ptTmp1 = m_ptWaterIn1;
ptTmp1.Project(&line44, ptTmp2);
double nDist = ads_distance(rect10.GetUpRight(), ptTmp2);
ads_polar(rect1.GetLowLeft(), m_nRotation, nDist, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, m_nWaterInEle*1000, ptTmp2);
ads_polar(ptTmp2, m_nRotation+nAngle, line1.GetLength(), ptTmp6);
ads_polar(ptTmp6, m_nRotation+nAngle, -nValveLen, ptTmp5);
ads_polar(ptTmp6, m_nRotation+nAngle, -nValveLen/2*3, ptTmp3);
DrawPLine(ptTmp2, ptTmp3, dc);
ads_polar(ptTmp6, m_nRotation+nAngle, -nValveLen/2, ptTmp3);
DrawPLine(ptTmp3, ptTmp6, dc);
TDbRect rect2;
rect2.SetSizeX(nValveLen);
rect2.SetSizeY(nValveLen/2);
rect2.SetCenter(ptTmp5);
rect2.SetRotation(m_nRotation+nAngle);
dc << XLine(rect2.GetLowLeft(), rect2.GetUpLeft());
dc << XLine(rect2.GetLowRight(), rect2.GetUpRight());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpRight());
dc << XLine(rect2.GetUpLeft(), rect2.GetLowRight());
ads_polar(ptTmp2, m_nRotation+nAngle, -PSCALE/2, ptTmp2);
TDbRect rect3;
rect3.SetSizeX(nValveLen/2);
rect3.SetSizeY(nValveLen/2);
rect3.SetCenter(ptTmp2);
rect3.SetRotation(m_nRotation);
rect3.ExplodeOrDraw2d(dc);
ads_polar(ptTmp2, m_nRotation+PI/2, PSCALE/2, ptTmp6);
ads_polar(ptTmp6, m_nRotation+PI/2, PSCALE/2, ptTmp5);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp5, m_nRotation+nAngle, -PSCALE/2*3, ptTmp6);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp6, m_nRotation-PI/2, PSCALE, ptTmp5);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp5, m_nRotation+nAngle/2+PI/4*5, PSCALE*2, ptTmp6);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp6, m_nRotation+nAngle/2+PI/4*5, PSCALE/4, ptTmp6);
dc << XCircle(ptTmp6, PSCALE/4);
}
}
if(!!m_ptOverfallStart && !!m_ptOverfallEnd && m_nHighLine > 0){
XLine line1(m_ptOverfallStart, m_ptOverfallEnd, 1);
double nAngle(0);
TDbRect rect10;
rect10.SetSizeX(nLength);
rect10.SetSizeY(nWidth);
rect10.SetCenter(m_ptLocation);
rect10.SetRotation(m_nRotation);
XLine line11(rect10.GetUpLeft(), rect10.GetUpRight(), 1);
XLine line22(rect10.GetLowLeft(), rect10.GetLowRight(), 1);
XLine line33(rect10.GetUpLeft(), rect10.GetLowLeft(), 1);
XLine line44(rect10.GetUpRight(), rect10.GetLowRight(), 1);
int ret1 = line1.Intersection(&line11, ptTmp1);
int ret2 = line1.Intersection(&line22, ptTmp1);
int ret3 = line1.Intersection(&line33, ptTmp1);
int ret4 = line1.Intersection(&line44, ptTmp1);
if(ret1 == 1)
nAngle = PI;
TDbRect rect0;
rect0.SetSizeX(nLength);
rect0.SetSizeY(nWidth);
rect0.SetCenter(m_ptLocation);
rect0.SetRotation(m_nRotation);
// cet 2011.11.2 del
// XLine line9(rect0.GetUpRight(), rect0.GetLowRight(), 1);
// ptTmp1 = m_ptOverfallStart;
// ptTmp1.Project(&line9, ptTmp2);
double nDist = ads_distance(rect0.GetUpRight(), ptTmp2);
// cet 2011.11.2 modify
// ads_polar(rect1.GetUpLeft(), 0, nDist, ptTmp2);
// ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp3);
// ptTmp2.y = ptTmp3.y;
AcGeVector3d vtTemp = rect1.GetUpRight() - rect1.GetLowRight();
ads_polar(rect1.GetUpLeft(), m_nRotation, nDist, ptTmp2);
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp3);
XLine lineTemp(ptTmp3, ptTmp3 + vtTemp, 0);
ptTmp2.Project(&lineTemp, ptTmp2);
if(ret1 == 1 || ret2 == 1){
double nValveLen = PSCALE*2;
ptTmp6 = ptTmp2;
//绘制溢流口
ads_polar(ptTmp2, m_nRotation, -PSCALE/4, ptTmp1);
ads_polar(ptTmp2, m_nRotation, PSCALE/4, ptTmp3);
dc << XLine(ptTmp1, ptTmp3);
ads_polar(ptTmp2, m_nRotation+PI/2, PSCALE/2, ptTmp2);
ads_polar(ptTmp2, m_nRotation, -PSCALE/2, ptTmp4);
ads_polar(ptTmp2, m_nRotation, PSCALE/2, ptTmp5);
dc << XLine(ptTmp4, ptTmp5);
dc << XLine(ptTmp1, ptTmp4);
dc << XLine(ptTmp3, ptTmp5);
//绘制溢流管
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nOverfallEle*1000, ptTmp3);
//cet 2011.11.2 modify
//ptTmp2.y = ptTmp3.y;
vtTemp = rect1.GetUpLeft() - rect1.GetUpRight();
lineTemp.SetPoints(ptTmp3, ptTmp3 + vtTemp);
ptTmp2.Project(&lineTemp, ptTmp2);
DrawPLine(ptTmp2, ptTmp6, dc);
ads_polar(ptTmp2, m_nRotation+nAngle, line1.GetLength(), ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nRushEle*1000, ptTmp3);
ptTmp2 = ptTmp6;
//cet 2011.11.2 modify
//ptTmp2.y = ptTmp3.y;
lineTemp.SetPoints(ptTmp3, ptTmp3 + vtTemp);
ptTmp2.Project(&lineTemp, ptTmp2);
DrawPLine(ptTmp2, ptTmp6, dc);
ads_polar(ptTmp2, m_nRotation+nAngle+PI, PSCALE, ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
ads_polar(ptTmp2, m_nRotation+nAngle, line1.GetLength(), ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
ads_polar(ptTmp2, m_nRotation+nAngle+PI, PSCALE*2, ptTmp2);
TDbRect rect2;
rect2.SetSizeX(nValveLen);
rect2.SetSizeY(nValveLen/2);
rect2.SetCenter(ptTmp2);
rect2.SetRotation(m_nRotation);
dc << XLine(rect2.GetLowLeft(), rect2.GetUpLeft());
dc << XLine(rect2.GetLowRight(), rect2.GetUpRight());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpRight());
dc << XLine(rect2.GetUpLeft(), rect2.GetLowRight());
ads_polar(ptTmp2, m_nRotation+nAngle+PI, PSCALE, ptTmp2);
ads_polar(ptTmp2, m_nRotation+nAngle+PI, line1.GetLength()-PSCALE*3, ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
}
else if(ret3 == 1 || ret4 == 1){
//绘制溢流口
ptTmp6 = ptTmp2;
ads_polar(ptTmp2, m_nRotation, -PSCALE/4, ptTmp1);
ads_polar(ptTmp2, m_nRotation, PSCALE/4, ptTmp3);
dc << XLine(ptTmp1, ptTmp3);
ads_polar(ptTmp2, m_nRotation+PI/2, PSCALE/2, ptTmp2);
ads_polar(ptTmp2, m_nRotation, -PSCALE/2, ptTmp4);
ads_polar(ptTmp2, m_nRotation, PSCALE/2, ptTmp5);
dc << XLine(ptTmp4, ptTmp5);
dc << XLine(ptTmp1, ptTmp4);
dc << XLine(ptTmp3, ptTmp5);
//绘制溢流管
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nOverfallEle*1000, ptTmp3);
//cet 2011.11.2 modify
//ptTmp3.x = ptTmp6.x;
vtTemp = rect1.GetUpLeft() - rect1.GetUpRight();
lineTemp.SetPoints(ptTmp6, ptTmp6 + vtTemp);
ptTmp3.Project(&lineTemp, ptTmp3);
ads_polar(ptTmp3, m_nRotation+PI/2, PSCALE/2, ptTmp4);
DrawPLine(ptTmp6, ptTmp4, dc);
dc << XCircle(ptTmp3, PSCALE/2);
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nRushEle*1000, ptTmp4);
//cet 2011.11.2 modify
//ptTmp4.x = ptTmp6.x;
ptTmp4.Project(&lineTemp, ptTmp4);
dc << XCircle(ptTmp4, PSCALE/2);
DrawPLine(ptTmp3, ptTmp4, dc);
}
}
if(m_nHighLine > 0.001 ){
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp2);
ads_polar(rect1.GetLowRight(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp3);
DrawWaterLevel(ptTmp2, ptTmp3, PSCALE, dc);
}
if(m_nLowLine > 0.001 ){
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp2);
ads_polar(rect1.GetLowRight(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp3);
DrawWaterLevel(ptTmp2, ptTmp3, PSCALE, dc);
}
if(m_bNeedHole){
TDbRect rect0;
rect0.SetSizeX(nLength);
rect0.SetSizeY(nWidth);
rect0.SetCenter(m_ptLocation);
rect0.SetRotation(m_nRotation);
XLine line9(rect0.GetUpRight(), rect0.GetLowRight(), 1);
ptTmp1 = m_ptHoleInsert;
ptTmp1.Project(&line9, ptTmp2);
double nDist = ads_distance(rect0.GetUpRight(), ptTmp2);
ads_polar(rect1.GetUpLeft(), m_nRotation, nDist, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, PSCALE/2, ptTmp2);
TDbRect rect4;
rect4.SetCenter(ptTmp2);
rect4.SetSizeX(nHoleWidth);
rect4.SetSizeY(PSCALE);
rect4.SetRotation(m_nRotation);
rect4.ExplodeOrDraw2d(dc);
}
if(m_bNeedSleeper){
double dSleeperWidth = m_nSpare * 1000; //modified by cet 2009.11.11
double dSleeperHeight = m_nSleeperWidth * 1000;
if(m_iSleeperPos == 1){
XLine line2(rect1.GetLowLeft(), rect1.GetLowRight());
ptTmp1 = line2.MidPoint();
ads_polar(ptTmp1, PI/2, -dSleeperHeight/2, ptTmp1);
TDbRect rect3;
rect3.SetCenter(ptTmp1);
// cet 2011.6.14 modify 枕木长改为用户设置
//rect3.SetSizeX(nWidth + 2*PSCALE);
double dSleeperLen = GetSleeperLen();
rect3.SetSizeX(dSleeperLen * 1000);
rect3.SetSizeY(dSleeperHeight);
rect3.SetRotation(m_nRotation);
rect3.ExplodeOrDraw2d(dc);
}
else if(m_iSleeperPos == 0){
XCurveSegment seg;
XLine line5(rect1.GetLowLeft(), rect1.GetLowRight(), 1);
seg = line5;
XPointList lstPt;
GetPointList(seg, m_iSleeperNum, lstPt, 1);
for(int i=0;i<lstPt.Length();i++){
XPoint pt = *lstPt[i];
ads_polar(pt, PI/2+m_nRotation, -dSleeperHeight/2, pt);
TDbRect rect3;
rect3.SetCenter(pt);
rect3.SetRotation(m_nRotation);
rect3.SetSizeX(dSleeperWidth);
rect3.SetSizeY(dSleeperHeight);
rect3.ExplodeOrDraw2d(dc);
}
}
}
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::DrawMainSect(XExplodeDraw &dc) const
{
double nHeight = m_nHeight * 1000;
double nLength = m_nLength * 1000;
double nWidth = m_nWidth * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
TDbRect rect1;
rect1.SetSizeX(nLength);
rect1.SetSizeY(nHeight);
rect1.SetCenter(m_ptLocation);
rect1.SetRotation(m_nRotation);
rect1.ExplodeOrDraw2d(dc);
XPoint ptTmp1, ptTmp2, ptTmp3, ptTmp4, ptTmp5, ptTmp6;
if(!!m_ptWaterIn1 && !!m_ptWaterIn2 && m_nWaterInEle > 0){
XLine line1(m_ptWaterIn1, m_ptWaterInFrom, 1);
TDbRect rect10;
rect10.SetSizeX(nLength);
rect10.SetSizeY(nWidth);
rect10.SetCenter(m_ptLocation);
rect10.SetRotation(m_nRotation);
XLine line11(rect10.GetUpLeft(), rect10.GetUpRight(), 1);
XLine line22(rect10.GetLowLeft(), rect10.GetLowRight(), 1);
XLine line33(rect10.GetUpLeft(), rect10.GetLowLeft(), 1);
XLine line44(rect10.GetUpRight(), rect10.GetLowRight(), 1);
int ret1 = line1.Intersection(&line11, ptTmp1);
int ret2 = line1.Intersection(&line22, ptTmp1);
int ret3 = line1.Intersection(&line33, ptTmp1);
int ret4 = line1.Intersection(&line44, ptTmp1);
double nAngle(0);
if(ret3 == 1)
nAngle = PI;
double nValveLen = PSCALE*2;
if(ret3 == 1 || ret4 == 1){
ptTmp1 = m_ptWaterIn1;
ptTmp1.Project(&line22, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, m_nWaterInEle*1000, ptTmp2);
ads_polar(ptTmp2, m_nRotation+nAngle, line1.GetLength(), ptTmp6);
ads_polar(ptTmp6, m_nRotation+nAngle, -nValveLen, ptTmp5);
ads_polar(ptTmp6, m_nRotation+nAngle, -nValveLen/2*3, ptTmp3);
DrawPLine(ptTmp2, ptTmp3, dc);
ads_polar(ptTmp6, m_nRotation+nAngle, -nValveLen/2, ptTmp3);
DrawPLine(ptTmp3, ptTmp6, dc);
TDbRect rect2;
rect2.SetSizeX(nValveLen);
rect2.SetSizeY(nValveLen/2);
rect2.SetCenter(ptTmp5);
rect2.SetRotation(m_nRotation+nAngle);
//绘制阀门
dc << XLine(rect2.GetLowLeft(), rect2.GetUpLeft());
dc << XLine(rect2.GetLowRight(), rect2.GetUpRight());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpRight());
dc << XLine(rect2.GetUpLeft(), rect2.GetLowRight());
ads_polar(ptTmp2, m_nRotation+nAngle, -PSCALE/2, ptTmp2);
TDbRect rect3;
rect3.SetSizeX(nValveLen/2);
rect3.SetSizeY(nValveLen/2);
rect3.SetCenter(ptTmp2);
rect3.SetRotation(m_nRotation);
rect3.ExplodeOrDraw2d(dc);
ads_polar(ptTmp2, m_nRotation+PI/2, PSCALE/2, ptTmp6);
ads_polar(ptTmp6, m_nRotation+PI/2, PSCALE/2, ptTmp5);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp5, m_nRotation+nAngle, -PSCALE/2*3, ptTmp6);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp6, m_nRotation-PI/2, PSCALE, ptTmp5);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp5, m_nRotation+nAngle/2+PI/4*5, PSCALE*2, ptTmp6);
dc << XLine(ptTmp5, ptTmp6);
ads_polar(ptTmp6, m_nRotation+nAngle/2+PI/4*5, PSCALE/4, ptTmp6);
dc << XCircle(ptTmp6, PSCALE/4);
}
else if(ret1 == 1 || ret2 == 1){
ptTmp1 = m_ptWaterIn1;
ptTmp1.Project(&line22, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, m_nWaterInEle*1000, ptTmp2);
dc << XCircle(ptTmp2, PSCALE/2);
ptTmp1 = m_ptWaterIn2;
ptTmp1.Project(&line22, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, m_nWaterInEle*1000, ptTmp2);
dc << XCircle(ptTmp2, PSCALE/2);
}
}
if(!!m_ptOverfallStart && !!m_ptOverfallEnd && m_nHighLine > 0){
XLine line1(m_ptOverfallStart, m_ptOverfallEnd, 1);
TDbRect rect10;
rect10.SetSizeX(nLength);
rect10.SetSizeY(nWidth);
rect10.SetCenter(m_ptLocation);
rect10.SetRotation(m_nRotation);
XLine line11(rect10.GetUpLeft(), rect10.GetUpRight(), 1);
XLine line22(rect10.GetLowLeft(), rect10.GetLowRight(), 1);
XLine line33(rect10.GetUpLeft(), rect10.GetLowLeft(), 1);
XLine line44(rect10.GetUpRight(), rect10.GetLowRight(), 1);
int ret1 = line1.Intersection(&line11, ptTmp1);
int ret2 = line1.Intersection(&line22, ptTmp1);
int ret3 = line1.Intersection(&line33, ptTmp1);
int ret4 = line1.Intersection(&line44, ptTmp1);
// cet 2011.11.2 modify 点ptTmp2求解错误
// XLine line9(rect1.GetUpLeft(), rect1.GetUpRight(), 1);
// ptTmp1 = m_ptOverfallStart;
// ptTmp1.Project(&line9, ptTmp2);
// ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp3);
// ptTmp2.y = ptTmp3.y;
AcGeVector3d vtTemp = rect1.GetUpRight() - rect1.GetUpLeft();
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp3);
XLine lineTemp(ptTmp3, ptTmp3 + vtTemp, 0);
m_ptOverfallStart.Project(&lineTemp, ptTmp2);
if(ret1 == 1 || ret2 == 1){
//绘制溢流口
ptTmp6 = ptTmp2;
ads_polar(ptTmp2, m_nRotation, -PSCALE/4, ptTmp1);
ads_polar(ptTmp2, m_nRotation, PSCALE/4, ptTmp3);
dc << XLine(ptTmp1, ptTmp3);
ads_polar(ptTmp2, m_nRotation+PI/2, PSCALE/2, ptTmp2);
ads_polar(ptTmp2, m_nRotation, -PSCALE/2, ptTmp4);
ads_polar(ptTmp2, m_nRotation, PSCALE/2, ptTmp5);
dc << XLine(ptTmp4, ptTmp5);
dc << XLine(ptTmp1, ptTmp4);
dc << XLine(ptTmp3, ptTmp5);
//绘制溢流管
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nOverfallEle*1000, ptTmp3);
//cet 2011.11.2 modify
//ptTmp3.x = ptTmp6.x;
vtTemp = rect1.GetUpLeft() - rect1.GetLowLeft();
lineTemp.SetPoints(ptTmp6, ptTmp6 + vtTemp);
ptTmp3.Project(&lineTemp, ptTmp3);
ads_polar(ptTmp3, m_nRotation+PI/2, PSCALE/2, ptTmp4);
DrawPLine(ptTmp6, ptTmp4, dc);
dc << XCircle(ptTmp3, PSCALE/2);
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nRushEle*1000, ptTmp4);
//cet 2011.11.2 modify
//ptTmp4.x = ptTmp6.x;
ptTmp4.Project(&lineTemp, ptTmp4);
dc << XCircle(ptTmp4, PSCALE/2);
DrawPLine(ptTmp3, ptTmp4, dc);
}
else if(ret3 == 1 || ret4 == 1){
double nValveLen = PSCALE*2;
ptTmp6 = ptTmp2;
//绘制溢流口
ads_polar(ptTmp2, m_nRotation, -PSCALE/4, ptTmp1);
ads_polar(ptTmp2, m_nRotation, PSCALE/4, ptTmp3);
dc << XLine(ptTmp1, ptTmp3);
ads_polar(ptTmp2, m_nRotation+PI/2, PSCALE/2, ptTmp2);
ads_polar(ptTmp2, m_nRotation, -PSCALE/2, ptTmp4);
ads_polar(ptTmp2, m_nRotation, PSCALE/2, ptTmp5);
dc << XLine(ptTmp4, ptTmp5);
dc << XLine(ptTmp1, ptTmp4);
dc << XLine(ptTmp3, ptTmp5);
//绘制溢流管
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nOverfallEle*1000, ptTmp3);
//cet 2011.11.2 modify
//ptTmp2.y = ptTmp3.y;
lineTemp.SetPoints(ptTmp3, ptTmp3 + vtTemp);
ptTmp2.Project(&lineTemp, ptTmp2);
DrawPLine(ptTmp2, ptTmp6, dc);
//ads_polar(ptTmp2, m_nRotation+line1.Direction(), line1.GetLength(), ptTmp6); cet 2011.11.2 modify
ads_polar(ptTmp2, line1.Direction(), line1.GetLength(), ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nRushEle*1000, ptTmp3);
ptTmp2 = ptTmp6;
//cet 2011.11.2 modify
//ptTmp2.y = ptTmp3.y;
lineTemp.SetPoints(ptTmp3, ptTmp3 + vtTemp);
ptTmp2.Project(&lineTemp, ptTmp2);
DrawPLine(ptTmp2, ptTmp6, dc);
//cet 2011.11.2 modify
//ads_polar(ptTmp2, m_nRotation+line1.Direction()+PI, PSCALE, ptTmp6);
ads_polar(ptTmp2, line1.Direction()+PI, PSCALE, ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
//cet 2011.11.2 modify
//ads_polar(ptTmp2, m_nRotation+line1.Direction(), line1.GetLength(), ptTmp6);
ads_polar(ptTmp2, line1.Direction(), line1.GetLength(), ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
//cet 2011.11.2 modify
//ads_polar(ptTmp2, m_nRotation+line1.Direction()+PI, PSCALE*2, ptTmp2);
ads_polar(ptTmp2, line1.Direction()+PI, PSCALE*2, ptTmp2);
TDbRect rect2;
rect2.SetSizeX(nValveLen);
rect2.SetSizeY(nValveLen/2);
rect2.SetCenter(ptTmp2);
rect2.SetRotation(m_nRotation);
dc << XLine(rect2.GetLowLeft(), rect2.GetUpLeft());
dc << XLine(rect2.GetLowRight(), rect2.GetUpRight());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpRight());
dc << XLine(rect2.GetUpLeft(), rect2.GetLowRight());
//cet 2011.11.2 modify
//ads_polar(ptTmp2, m_nRotation+line1.Direction()+PI, PSCALE, ptTmp2);
//ads_polar(ptTmp2, m_nRotation+line1.Direction()+PI, line1.GetLength()-PSCALE*3, ptTmp6);
ads_polar(ptTmp2, line1.Direction()+PI, PSCALE, ptTmp2);
ads_polar(ptTmp2, line1.Direction()+PI, line1.GetLength()-PSCALE*3, ptTmp6);
DrawPLine(ptTmp2, ptTmp6, dc);
}
}
if(m_nHighLine > 0.001 ){
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp2);
ads_polar(rect1.GetLowRight(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp3);
DrawWaterLevel(ptTmp2, ptTmp3, PSCALE, dc);
}
if(m_nLowLine > 0.001 ){
ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp2);
ads_polar(rect1.GetLowRight(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp3);
DrawWaterLevel(ptTmp2, ptTmp3, PSCALE, dc);
}
if(m_bNeedHole){
XLine line9(rect1.GetUpLeft(), rect1.GetUpRight(), 1);
ptTmp1 = m_ptHoleInsert;
ptTmp1.Project(&line9, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, PSCALE/2, ptTmp2);
TDbRect rect4;
rect4.SetCenter(ptTmp2);
rect4.SetSizeX(nHoleWidth);
rect4.SetSizeY(PSCALE);
rect4.SetRotation(m_nRotation);
rect4.ExplodeOrDraw2d(dc);
}
if(m_bNeedSleeper){
double dSleeperWidth = m_nSpare * 1000; //modified by cet 2009.11.11
double dSleeperHeight = m_nSleeperWidth * 1000;
if(m_iSleeperPos == 0){
XLine line2(rect1.GetLowLeft(), rect1.GetLowRight());
ptTmp1 = line2.MidPoint();
// cet 2011.10.10 modify 点计算方法错误
// ptTmp1 = Wcs2Ucs(ptTmp1); // cet 2011.9.15 add
// ads_polar(ptTmp1, PI/2, -dSleeperHeight/2, ptTmp1);
// ptTmp1 = Ucs2Wcs(ptTmp1); // cet 2011.9.15 add
AcGeVector3d vt = rect1.GetLowRight() - rect1.GetLowLeft();
vt.normalize();
vt.rotateBy(-PI/2, AcGeVector3d::kZAxis);
ptTmp1 += vt * dSleeperHeight / 2;
TDbRect rect3;
rect3.SetCenter(ptTmp1);
// cet 2011.6.14 modify 枕木长改为用户设置
//rect3.SetSizeX(nLength + 2*PSCALE);
double dSleeperLen = GetSleeperLen();
rect3.SetSizeX(dSleeperLen * 1000);
rect3.SetSizeY(dSleeperHeight);
rect3.SetRotation(m_nRotation);
rect3.ExplodeOrDraw2d(dc);
}
else if(m_iSleeperPos == 1){
XCurveSegment seg;
XLine line5(rect1.GetLowLeft(), rect1.GetLowRight(), 1);
seg = line5;
XPointList lstPt;
GetPointList(seg, m_iSleeperNum, lstPt, 1);
for(int i=0;i<lstPt.Length();i++){
XPoint pt = *lstPt[i];
ads_polar(pt, PI/2+m_nRotation, -dSleeperHeight/2, pt);
TDbRect rect3;
rect3.SetCenter(pt);
rect3.SetRotation(m_nRotation);
rect3.SetSizeX(dSleeperWidth);
rect3.SetSizeY(dSleeperHeight);
rect3.ExplodeOrDraw2d(dc);
}
}
}
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::DrawSysTank(XExplodeDraw &dc) const
{
// double nHeight = m_nHeight * 1000;
// double nLength = m_nLength * 1000;
// double nWidth = m_nWidth * 1000;
// XPoint ptSysLoc = m_ptLocation;
// XPoint ptTmp;
// ads_polar(m_ptLocation, PI/4, -nWidth/2, ptSysLoc);
// ads_polar(ptSysLoc, PI/2, nHeight/2, ptSysLoc);
//
//
// TDbRect rect1;
// rect1.SetSizeX(nLength);
// rect1.SetSizeY(nHeight);
// rect1.SetCenter(ptSysLoc);
// rect1.SetRotation(m_nRotation);
// rect1.ExplodeOrDraw2d(dc);
//
// ads_polar(ptSysLoc, PI/4, nWidth, ptTmp);//*sqrt(2.0)
// TDbRect rect2;
// rect2.SetSizeX(nLength);
// rect2.SetSizeY(nHeight);
// rect2.SetCenter(ptTmp);
// rect2.SetRotation(m_nRotation);
// rect2.ExplodeOrDraw2d(dc);
//
// dc << XLine(rect1.GetLowLeft(), rect2.GetLowLeft());
// dc << XLine(rect1.GetUpLeft(), rect2.GetUpLeft());
// dc << XLine(rect1.GetLowRight(), rect2.GetLowRight());
// dc << XLine(rect1.GetUpRight(), rect2.GetUpRight());
// XPoint ptTmp2, ptTmp3, ptTmp4, ptTmp5;
// if(m_nHighLine > 0.001 ){
// ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp2);
// ads_polar(rect1.GetLowRight(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp3);
// DrawWaterLevel(ptTmp2, ptTmp3, PSCALE, dc);
//
// ads_polar(rect2.GetLowLeft(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp4);
// ads_polar(rect2.GetLowRight(), PI/2+m_nRotation, m_nHighLine*1000, ptTmp5);
// dc << XLine(ptTmp4, ptTmp5);
// dc << XLine(ptTmp2, ptTmp4);
// dc << XLine(ptTmp3, ptTmp5);
// }
// if(m_nLowLine > 0.001 ){
// ads_polar(rect1.GetLowLeft(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp2);
// ads_polar(rect1.GetLowRight(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp3);
// DrawWaterLevel(ptTmp2, ptTmp3, PSCALE, dc);
// ads_polar(rect2.GetLowLeft(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp4);
// ads_polar(rect2.GetLowRight(), PI/2+m_nRotation, m_nLowLine*1000, ptTmp5);
// dc << XLine(ptTmp4, ptTmp5);
// dc << XLine(ptTmp2, ptTmp4);
// dc << XLine(ptTmp3, ptTmp5);
// }
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::DrawPlan(XExplodeDraw &dc) const
{
double nHeight = m_nHeight * 1000;
double nLength = m_nLength * 1000;
double nWidth = m_nWidth * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
TDbRect rect1;
rect1.SetSizeX(nLength);
rect1.SetSizeY(nWidth);
rect1.SetCenter(m_ptLocation);
rect1.SetRotation(m_nRotation);
rect1.ExplodeOrDraw2d(dc);
double nValveLen = PSCALE*2;
if(!!m_ptWaterIn1 && !!m_ptWaterIn2 && !!m_ptWaterInFrom){
dc << XCircle(m_ptWaterIn1, PSCALE/2);
dc << XCircle(m_ptWaterIn2, PSCALE/2);
XPoint ptTmp1, ptTmp2, ptTmp3, ptTmp4;
XLine line4(m_ptWaterIn1, m_ptWaterInFrom);
ads_polar(m_ptWaterIn1, line4.Direction(), PSCALE/2, ptTmp1);
ads_polar(m_ptWaterInFrom, line4.Direction(), -nValveLen, ptTmp2);
ads_polar(m_ptWaterInFrom, line4.Direction(), -nValveLen/2*3, ptTmp3);
DrawPLine(ptTmp1, ptTmp3, dc);
ads_polar(m_ptWaterInFrom, line4.Direction(), -nValveLen/2, ptTmp3);
DrawPLine(ptTmp3, m_ptWaterInFrom, dc);
TDbRect rect2;
rect2.SetSizeX(nValveLen);
rect2.SetSizeY(nValveLen/2);
rect2.SetCenter(ptTmp2);
rect2.SetRotation(line4.Direction());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpLeft());
dc << XLine(rect2.GetLowRight(), rect2.GetUpRight());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpRight());
dc << XLine(rect2.GetUpLeft(), rect2.GetLowRight());
ads_polar(m_ptWaterIn2, line4.Direction(), line4.GetLength(), ptTmp4);
XLine line5(m_ptWaterIn2, ptTmp4);
ads_polar(m_ptWaterIn2, line4.Direction(), PSCALE/2, ptTmp1);
ads_polar(ptTmp4, line4.Direction(), -nValveLen, ptTmp2);
ads_polar(ptTmp4, line4.Direction(), -nValveLen/2*3, ptTmp3);
DrawPLine(ptTmp1, ptTmp3, dc);
ads_polar(ptTmp4, line4.Direction(), -nValveLen/2, ptTmp3);
DrawPLine(ptTmp3, ptTmp4, dc);
TDbRect rect3;
rect3.SetSizeX(nValveLen);
rect3.SetSizeY(nValveLen/2);
rect3.SetCenter(ptTmp2);
rect3.SetRotation(line4.Direction());
dc << XLine(rect3.GetLowLeft(), rect3.GetUpLeft());
dc << XLine(rect3.GetLowRight(), rect3.GetUpRight());
dc << XLine(rect3.GetLowLeft(), rect3.GetUpRight());
dc << XLine(rect3.GetUpLeft(), rect3.GetLowRight());
}
if(!!m_ptOverfallStart && !!m_ptOverfallEnd){
dc << XCircle(m_ptOverfallStart, PSCALE/2);
dc << XCircle(m_ptOverfallEnd, PSCALE/2);
XPoint ptTmp1, ptTmp2, ptTmp3;
XLine line4(m_ptOverfallStart, m_ptOverfallEnd);
ads_polar(m_ptOverfallStart, line4.Direction(), PSCALE/2, ptTmp1);
ads_polar(m_ptOverfallEnd, line4.Direction(), -nValveLen, ptTmp2);
ads_polar(m_ptOverfallEnd, line4.Direction(), -nValveLen/2*3, ptTmp3);
DrawPLine(ptTmp1, ptTmp3, dc);
ads_polar(m_ptOverfallEnd, line4.Direction(), -nValveLen/2, ptTmp3);
DrawPLine(ptTmp3, m_ptOverfallEnd, dc);
TDbRect rect2;
rect2.SetSizeX(nValveLen);
rect2.SetSizeY(nValveLen/2);
rect2.SetCenter(ptTmp2);
rect2.SetRotation(line4.Direction());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpLeft());
dc << XLine(rect2.GetLowRight(), rect2.GetUpRight());
dc << XLine(rect2.GetLowLeft(), rect2.GetUpRight());
dc << XLine(rect2.GetUpLeft(), rect2.GetLowRight());
}
if(m_bNeedHole){
if (!m_bHoleIsRect)
{
XPoint ptTmp1, ptTmp2, ptInt;
TDbRect rect2;
rect2.SetSizeX(nHoleWidth);
rect2.SetSizeY(nHoleWidth);
rect2.SetCenter(m_ptHoleInsert);
rect2.SetRotation(m_nRotation);
rect2.ExplodeOrDraw2d(dc);
XLine line1(m_ptHoleInsert, rect2.GetUpLeft());
ptInt = line1.MidPoint();
XLine line3(rect2.GetLowLeft(), ptInt, 1);
dc << line3;
XLine line4(rect2.GetUpRight(), ptInt, 1);
dc << line4;
}
else
{
//圆形人孔
XCircle circle(m_ptHoleInsert,m_nHoleWidth/2*1000);
dc << circle;
}
}
if(m_bNeedSleeper){
// double nSleeperWidth = m_nSleeperWidth * 1000;
double dSleeperWidth = m_nSpare * 1000; //modified by cet 2009.11.11
AcDbObjectId idLayerOld=dc.GetLayerId();
dc.SetLayer(m_idDashLayer);
XPoint ptTmp1, ptTmp2;
XCurveSegment seg;
if(m_iSleeperPos == 0){
XLine line1(rect1.GetUpLeft(), rect1.GetUpRight(), 1);
ptTmp1 = line1.MidPoint();
XLine line2(rect1.GetLowLeft(), rect1.GetLowRight(), 1);
ptTmp2 = line2.MidPoint();
XLine line3(ptTmp1, ptTmp2);
seg = line3;
}
else{
XLine line1(rect1.GetUpLeft(), rect1.GetLowLeft(), 1);
ptTmp1 = line1.MidPoint();
XLine line2(rect1.GetUpRight(), rect1.GetLowRight(), 1);
ptTmp2 = line2.MidPoint();
XLine line3(ptTmp1, ptTmp2);
seg = line3;
}
XPointList lstPt;
GetPointList(seg, m_iSleeperNum, lstPt, 1);
for(int i=0;i<lstPt.Length();i++){
XPoint pt = *lstPt[i];
TDbRect rect3;
rect3.SetCenter(pt);
if(m_iSleeperPos == 0){
rect3.SetRotation(m_nRotation);
// cet 2011.6.14 modify 枕木长改为用户设置
//rect3.SetSizeX(nLength + PSCALE);
double dSleeperLen = GetSleeperLen();
rect3.SetSizeX(dSleeperLen * 1000);
}
else{
rect3.SetRotation(m_nRotation + PI/2);
// cet 2011.6.14 modify 枕木长改为用户设置
//rect3.SetSizeX(nWidth + PSCALE);
double dSleeperLen = GetSleeperLen();
rect3.SetSizeX(dSleeperLen * 1000);
}
rect3.SetSizeY(dSleeperWidth);
//rect3.ExplodeOrDraw2d(dc); sr 2011-9-30 TDbRect 改为AcDbPolyline , 因为关闭图层依然打印出来
AcDbPolyline pline;
rect3.GetPolyline(pline);
XAcGiViewDraw &viewDraw = (XAcGiViewDraw &)dc;
viewDraw.Polyline(pline);
}
dc.SetLayer(idLayerOld);
}
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::DrawCirclePlan2(XExplodeDraw &dc) const
{
assertReadEnabled();
double nLength = m_nLength * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
double nHeight = m_nHeight * 1000;
double nWidth = m_nWidth * 1000;
double nSleeperWidth = m_nSleeperWidth * 1000;
TDbRect rect1;
rect1.SetSizeX(nHeight);
rect1.SetSizeY(nLength);
rect1.SetCenter(m_ptLocation);
rect1.SetRotation(m_nRotation);
rect1.ExplodeOrDraw2d(dc);
if(m_bNeedHole){
XCircle cir2(m_ptHoleInsert, nHoleWidth/2);
dc << cir2;
}
AcDbObjectId idLayerOld=dc.GetLayerId();
dc.SetLayer(m_idDashLayer);
XPoint ptTmp1, ptTmp2;
XCurveSegment seg;
XLine line1(rect1.GetUpLeft(), rect1.GetLowLeft(), 1);
ptTmp1 = line1.MidPoint();
XLine line2(rect1.GetUpRight(), rect1.GetLowRight(), 1);
ptTmp2 = line2.MidPoint();
XLine line3(ptTmp1, ptTmp2);
seg = line3;
XPointList lstPt;
GetPointList(seg, 2, lstPt, 0);
for(int i=0;i<lstPt.Length();i++){
XPoint pt = *lstPt[i];
TDbRect rect3;
rect3.SetCenter(pt);
rect3.SetRotation(m_nRotation);
rect3.SetSizeX(nHoleWidth/2);
rect3.SetSizeY(nLength*0.8);
rect3.ExplodeOrDraw2d(dc);
}
dc.SetLayer(idLayerOld);
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::DrawCircleLeftSect2(XExplodeDraw &dc) const
{
assertReadEnabled();
double nLength = m_nLength * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
double nHeight = m_nHeight * 1000;
double nWidth = m_nWidth * 1000;
double nSleeperWidth = m_nSleeperWidth * 1000;
XCircle cir(m_ptLocation, nLength/2);
dc << cir;
XPoint ptTmp1, ptTmp2, ptTmp3;
if(m_bNeedHole){
ads_polar(m_ptLocation, m_nRotation+PI/2, nLength/2+PSCALE/2, ptTmp1);
TDbRect rect4;
rect4.SetCenter(ptTmp1);
rect4.SetSizeX(nHoleWidth);
rect4.SetSizeY(PSCALE);
rect4.SetRotation(m_nRotation);
rect4.ExplodeOrDraw2d(dc);
}
ads_polar(m_ptLocation, m_nRotation+PI+PI/4, nLength/2, ptTmp1);
ads_polar(ptTmp1, m_nRotation+PI/2, -nWidth, ptTmp2);
dc << XLine(ptTmp1, ptTmp2);
ads_polar(m_ptLocation, m_nRotation+PI*7/4, nLength/2, ptTmp1);
ads_polar(ptTmp1, m_nRotation+PI/2, -nWidth, ptTmp3);
dc << XLine(ptTmp1, ptTmp3);
dc << XLine(ptTmp3, ptTmp2);
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::DrawCircleMainSect2(XExplodeDraw &dc) const
{
assertReadEnabled();
double nLength = m_nLength * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
double nHeight = m_nHeight * 1000;
double nWidth = m_nWidth * 1000;
double nSleeperWidth = m_nSleeperWidth * 1000;
TDbRect rect1;
XCurveSegment seg;
XPoint ptTmp1, ptTmp2;
rect1.SetSizeX(nHeight);
rect1.SetSizeY(nLength);
rect1.SetCenter(m_ptLocation);
rect1.SetRotation(m_nRotation);
XLine line33(rect1.GetUpLeft(), rect1.GetUpRight());
dc << line33;
XLine line44(rect1.GetLowLeft(), rect1.GetLowRight());
dc << line44;
XLine line11(rect1.GetUpLeft(), rect1.GetLowLeft());
XPoint ptTmp;
ptTmp = line11.MidPoint();
ads_polar(ptTmp, m_nRotation-PI, 3*PSCALE, ptTmp);
XArc arc(rect1.GetUpLeft(),ptTmp,rect1.GetLowLeft());
dc << arc;
XLine line22(rect1.GetUpRight(), rect1.GetLowRight());
ptTmp = line22.MidPoint();
ads_polar(ptTmp, m_nRotation, 3*PSCALE, ptTmp);
XArc arc2(rect1.GetUpRight(),ptTmp,rect1.GetLowRight());
dc << arc2;
if(m_bNeedHole){
XLine line9(rect1.GetUpLeft(), rect1.GetUpRight(), 1);
ptTmp1 = m_ptHoleInsert;
ptTmp1.Project(&line9, ptTmp2);
ads_polar(ptTmp2, PI/2+m_nRotation, PSCALE/2, ptTmp2);
TDbRect rect4;
rect4.SetCenter(ptTmp2);
rect4.SetSizeX(nHoleWidth);
rect4.SetSizeY(PSCALE);
rect4.SetRotation(m_nRotation);
rect4.ExplodeOrDraw2d(dc);
}
XLine line2(rect1.GetLowLeft(), rect1.GetLowRight(), 1);
seg = line2;
XPointList lstPt;
GetPointList(seg, 2, lstPt, 0);
for(int i=0;i<lstPt.Length();i++){
XPoint pt = *lstPt[i];
TDbRect rect3;
rect3.SetCenter(pt);
rect3.SetRotation(m_nRotation);
rect3.SetSizeX(nHoleWidth/2);
rect3.SetSizeY(nWidth);
rect3.ExplodeOrDraw2d(dc);
}
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::ExplodeOrDraw2d(XExplodeDraw &dc) const
{
// cet 2016.10.17 add 图层关闭时,实体不显示,不进行绘制(打印时,也不会绘制)
AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead);
if (player.openStatus() == Acad::eOk && player->isOff())
{
return Acad::eOk;
}
assertReadEnabled();
if(m_iShape == 1){ //方水箱
if(m_iShowType == 0)
DrawPlan(dc);
else if(m_iShowType == 1)
DrawMainSect(dc);
else if(m_iShowType == 2)
DrawLeftSect(dc);
// else if(m_iShowType == 3)
// DrawSysTank(dc); 2006 12 21 取消系统水箱,改为平面图生成系统图实现
}
else if(m_iShape == 0){//圆水箱 立式
if(m_iShowType == 0){
double nLength = m_nLength * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
XCircle cir(m_ptLocation, nLength/2);
dc << cir;
if(m_bNeedHole){
XCircle cir2(m_ptHoleInsert, nHoleWidth/2);
dc << cir2;
}
}
else
DrawCircleSect0(dc);
}
else if(m_iShape == 2){//圆水箱 卧式
if(m_iShowType == 0)
DrawCirclePlan2(dc);
else if(m_iShowType == 1)
DrawCircleMainSect2(dc);
else if(m_iShowType == 2)
DrawCircleLeftSect2(dc);
}
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::Draw3dBox(XExplodeDraw &dc) const
{
assertReadEnabled();
double nHeight = m_nHeight * 1000;
double nLength = m_nLength * 1000;
double nWidth = m_nWidth * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
double nSleeperWidth = m_nSleeperWidth * 1000;
double dSleeperWidth = m_nSpare * 1000; //modified by cet 2009.11.11
double dSleeperHeight = m_nSleeperWidth * 1000;
XPoint ptLoc = m_ptLocation;
if(m_bNeedSleeper)
//ptLoc.z = dSleeperHeight; // zxl 2012.11.29 modify
ptLoc.z += dSleeperHeight;
TDbRect rect1;
rect1.SetSizeX(nLength);
rect1.SetSizeY(nWidth);
rect1.SetCenter(ptLoc);
rect1.SetRotation(m_nRotation);
XPoint ptLowLeft=rect1.GetLowLeft();
XPoint ptLowRight=rect1.GetLowRight();
XPoint ptUpRight=rect1.GetUpRight();
XPoint ptUpLeft=rect1.GetUpLeft();
XPoly2D poly2d(1);
poly2d.AppendNode(ptLowLeft);
poly2d.AppendNode(ptLowRight);
poly2d.AppendNode(ptUpRight);
poly2d.AppendNode(ptUpLeft);
XVector3D vt = XVector3D(0,0,1);
vt.Normalize();
vt *= nHeight;
dc.DrawBody(poly2d, vt);
if(m_bNeedHole){
if (!m_bHoleIsRect)
{
XPoint ptHole = m_ptHoleInsert;
ptHole.z += nHeight + nSleeperWidth;
TDbRect rect2;
rect2.SetSizeX(nHoleWidth);
rect2.SetSizeY(nHoleWidth);
rect2.SetCenter(ptHole);
rect2.SetRotation(m_nRotation);
ptLowLeft=rect2.GetLowLeft();
ptLowRight=rect2.GetLowRight();
ptUpRight=rect2.GetUpRight();
ptUpLeft=rect2.GetUpLeft();
XPoly2D poly2d2(1);
poly2d2.AppendNode(ptLowLeft);
poly2d2.AppendNode(ptLowRight);
poly2d2.AppendNode(ptUpRight);
poly2d2.AppendNode(ptUpLeft);
XVector3D vt2 = XVector3D(0,0,1);
vt2.Normalize();
vt2 *= 1* PSCALE;
dc.DrawBody(poly2d2, vt2);
}
else
{
XPoint pt1 = m_ptHoleInsert;
pt1.z += nHeight + nSleeperWidth;
XPoint pt2 = pt1;
pt2 += AcGeVector3d::kZAxis*PSCALE;
DrawPolyMesh(pt1,pt2,m_nHoleWidth*1000/2,dc);
}
}
if(m_bNeedSleeper){
XPoint ptTmp1, ptTmp2;
XCurveSegment seg;
if(m_iSleeperPos == 0){
XLine line1(rect1.GetUpLeft(), rect1.GetUpRight(), 1);
ptTmp1 = line1.MidPoint();
XLine line2(rect1.GetLowLeft(), rect1.GetLowRight(), 1);
ptTmp2 = line2.MidPoint();
XLine line3(ptTmp1, ptTmp2);
seg = line3;
}
else{
XLine line1(rect1.GetUpLeft(), rect1.GetLowLeft(), 1);
ptTmp1 = line1.MidPoint();
XLine line2(rect1.GetUpRight(), rect1.GetLowRight(), 1);
ptTmp2 = line2.MidPoint();
XLine line3(ptTmp1, ptTmp2);
seg = line3;
}
XPointList lstPt;
GetPointList(seg, m_iSleeperNum, lstPt, 1);
for(int i=0;i<lstPt.Length();i++){
XPoint pt = *lstPt[i];
TDbRect rect3;
pt.z -= dSleeperHeight;
rect3.SetCenter(pt);
if(m_iSleeperPos == 0){
rect3.SetRotation(m_nRotation);
// cet 2011.6.14 modify 枕木长改为用户设置
//rect3.SetSizeX(nLength + PSCALE);
double dSleeperLen = GetSleeperLen();
rect3.SetSizeX(dSleeperLen * 1000);
}
else{
rect3.SetRotation(m_nRotation + PI/2);
// cet 2011.6.14 modify 枕木长改为用户设置
//rect3.SetSizeX(nWidth + PSCALE);
double dSleeperLen = GetSleeperLen();
rect3.SetSizeX(dSleeperLen * 1000);
}
rect3.SetSizeY(dSleeperWidth);
ptLowLeft=rect3.GetLowLeft();
ptLowRight=rect3.GetLowRight();
ptUpRight=rect3.GetUpRight();
ptUpLeft=rect3.GetUpLeft();
XPoly2D poly2d3(1);
poly2d3.AppendNode(ptLowLeft);
poly2d3.AppendNode(ptLowRight);
poly2d3.AppendNode(ptUpRight);
poly2d3.AppendNode(ptUpLeft);
XVector3D vt3 = XVector3D(0,0,1);
vt3.Normalize();
vt3 *= dSleeperHeight;
dc.DrawBody(poly2d3, vt3);
}
}
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::Draw3dCover(XExplodeDraw &dc, XVector3D vt, XPoint pt) const
{
double nLength = m_nLength * 1000;
OPENOBJ_BEGIN(m_idBlock3d, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
if(pBlock) {
AcGeMatrix3d mat;
AcGeVector3d v1 = vt;
AcGeVector3d vtNormal(0,0,1);
double nAng = v1.angleTo(vtNormal);
AcGeScale3d scale(nLength/2,nLength/2,fabs(nLength/2));
AcDbBlockReference insert(pt, m_idBlock3d);
insert.setScaleFactors(scale);
if(nAng > 0 && nAng < PI)
mat.setToRotation(nAng, vtNormal.crossProduct(v1), insert.position());
else if(fabs(nAng - PI) < 0.00001){
AcGePlane plan(insert.position(), vtNormal);
mat.setToMirroring(plan);
}
insert.transformBy(mat);
if(_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0) {
AcGeMatrix3d mat=insert.blockTransform();
AcGiGeometry *geom=((XAcGiViewDraw &)dc).GetCommonDraw()->rawGeometry();
geom->pushModelTransform(mat);
geom->draw(pBlock);
geom->popModelTransform();
} else if(_tcscmp(dc.Desc(), XExplodeStream::Descriptor())==0) {
((XExplodeStream &)dc).Append((AcDbEntity *)insert.clone());
}
}
OPENOBJ_END();
return Acad::eOk;
}
Acad::ErrorStatus TDbWaterTank::ExplodeOrDraw3d(XExplodeDraw &dc) const
{
double nHeight = m_nHeight * 1000;
double nLength = m_nLength * 1000;
double nWidth = m_nWidth * 1000;
double nHoleWidth = m_nHoleWidth * 1000;
double nSleeperWidth = m_nSleeperWidth * 1000;
if(m_iShape == 1){
Draw3dBox(dc);
}
if(m_iShape == 0){ //圆 立式
XPoint pt1, pt2;
pt1 = pt2 = m_ptLocation;
pt1.z += nWidth;
pt2.z += (nWidth+nHeight);
DrawPolyMesh(pt1, pt2, nLength/2, dc);
XVector3D vt(pt2.x - m_ptLocation.x, pt2.y - m_ptLocation.y, pt2.z - m_ptLocation.z);
Draw3dCover(dc, vt, pt2);
XVector3D vt2(m_ptLocation.x - pt2.x, m_ptLocation.y - pt2.y, m_ptLocation.z - pt2.z);
Draw3dCover(dc, vt2, pt1);
ads_polar(m_ptLocation, m_nRotation, nLength/2-nSleeperWidth, pt1);
//pt1.z = 0;//zxl del 2012.12.03
pt2 = pt1;
// pt2.z = nWidth;
pt2.z += nWidth;//zxl modify 2012.12.03
DrawPolyMesh(pt1, pt2, nSleeperWidth, dc);
ads_polar(m_ptLocation, m_nRotation+PI*2/3, nLength/2-nSleeperWidth, pt1);
//pt1.z = 0;//zxl del 2012.12.03
pt2 = pt1;
// pt2.z = nWidth;
pt2.z += nWidth;//zxl modify 2012.12.03
DrawPolyMesh(pt1, pt2, nSleeperWidth, dc);
ads_polar(m_ptLocation, m_nRotation+PI*4/3, nLength/2-nSleeperWidth, pt1);
//pt1.z = 0;//zxl del 2012.12.03
pt2 = pt1;
// pt2.z = nWidth;
pt2.z += nWidth;//zxl modify 2012.12.03
DrawPolyMesh(pt1, pt2, nSleeperWidth, dc);
}
else if(m_iShape == 2){ //圆卧式
XPoint pt1, pt2, ptCen;
ptCen = m_ptLocation;
ptCen.z += nWidth+nLength/2;
ads_polar(ptCen, m_nRotation, nHeight/2, pt1);
ads_polar(ptCen, m_nRotation, -nHeight/2, pt2);
DrawPolyMesh(pt1, pt2, nLength/2, dc);
XVector3D vt(pt2.x - ptCen.x, pt2.y - ptCen.y, pt2.z - ptCen.z);
Draw3dCover(dc, vt, pt2);
XVector3D vt2(ptCen.x - pt2.x, ptCen.y - pt2.y, ptCen.z - pt2.z);
Draw3dCover(dc, vt2, pt1);
ads_polar(m_ptLocation, m_nRotation, nHeight/4, pt1);
ads_polar(m_ptLocation, m_nRotation, -nHeight/4, pt2);
TDbRect rect1;
rect1.SetSizeX(nHoleWidth/2);
rect1.SetSizeY(nLength*0.8);
rect1.SetCenter(pt1);
rect1.SetRotation(m_nRotation);
XPoint ptLowLeft=rect1.GetLowLeft();
XPoint ptLowRight=rect1.GetLowRight();
XPoint ptUpRight=rect1.GetUpRight();
XPoint ptUpLeft=rect1.GetUpLeft();
XPoly2D poly2d(1);
poly2d.AppendNode(ptLowLeft);
poly2d.AppendNode(ptLowRight);
poly2d.AppendNode(ptUpRight);
poly2d.AppendNode(ptUpLeft);
XVector3D vt3 = XVector3D(0,0,1);
vt3.Normalize();
vt3 *= nWidth*2;
dc.DrawBody(poly2d, vt3);
TDbRect rect2;
rect2.SetSizeX(nHoleWidth/2);
rect2.SetSizeY(nLength*0.8);
rect2.SetCenter(pt2);
rect2.SetRotation(m_nRotation);
ptLowLeft=rect2.GetLowLeft();
ptLowRight=rect2.GetLowRight();
ptUpRight=rect2.GetUpRight();
ptUpLeft=rect2.GetUpLeft();
XPoly2D poly2d2(1);
poly2d2.AppendNode(ptLowLeft);
poly2d2.AppendNode(ptLowRight);
poly2d2.AppendNode(ptUpRight);
poly2d2.AppendNode(ptUpLeft);
XVector3D vt4 = XVector3D(0,0,1);
vt4.Normalize();
vt4 *= nWidth*2;
dc.DrawBody(poly2d2, vt4);
}
return Acad::eOk;
}
//取动态属性显示数据
void TDbWaterTank::GetTips(DList<TObjInfoUnit> &info) const
{
info.Append(new TObjInfoUnit(_T("对象类型"), _T("水箱")));
}
double TDbWaterTank::GetOldSleeperLen() const
{
double dSleeperLen = 0.0;
if(m_iSleeperPos == 0)
{
dSleeperLen = m_nLength+ PSCALE * 0.001;
}
else
{
dSleeperLen = m_nWidth + PSCALE * 0.001;
}
return dSleeperLen;
}
void InitDbWaterTank(BOOL bTrue)
{
if(bTrue) {
TDbWaterTank::rxInit();
TDbWaterTank::InitMatchProtocol(TRUE);
// static TArchMatchProp *pMatchProp=NULL;
// pMatchProp = new TArchMatchProp;
// TDbWaterTank::desc()->addX(AcDbMatchProperties::desc(), pMatchProp);
// AcRxObject* pRxobj = TDbWaterTank::desc()->getX(TArchMatchProp::desc());
} else {
TDbWaterTank::InitMatchProtocol(FALSE);
deleteAcRxClass(TDbWaterTank::desc());
}
}