1767 lines
52 KiB
C++
1767 lines
52 KiB
C++
#include "stdafx.h"
|
|
#include "DbEquipment.h"
|
|
#include "DbPipe.h"
|
|
#include "PipePrototype.h"
|
|
#include "DbDimension.h"
|
|
#include <sstream>
|
|
|
|
extern double g_dPointToOriginLimitDist;
|
|
void Matrix3D2String( const AcGeMatrix3d &mat, CString &str )
|
|
{
|
|
#if ADS <= 15
|
|
std::ostringstream stream;
|
|
#else
|
|
std::wostringstream stream;
|
|
#endif
|
|
for (int ln = 0; ln < 4; ++ln)
|
|
{
|
|
for (int col = 0; col < 4; ++col)
|
|
{
|
|
stream << mat.entry[ln][col];
|
|
#if ADS <= 15
|
|
stream << " ";
|
|
#else
|
|
stream << L" ";
|
|
#endif
|
|
}
|
|
}
|
|
str = stream.str().c_str();
|
|
}
|
|
|
|
// cet2017.3.2 add 设备类型名
|
|
CString GetEquipmentName(const TDbEquipment *pEquip)
|
|
{
|
|
CString sName = _T("普通设备");
|
|
if (pEquip == NULL)
|
|
{
|
|
return sName;
|
|
}
|
|
if (pEquip->IsSprinkler())
|
|
{
|
|
sName = _T("喷头");
|
|
}
|
|
else if (pEquip->IsHydrant())
|
|
{
|
|
sName = _T("消火栓");
|
|
}
|
|
int nEquipType = pEquip->GetEquipmentType();
|
|
switch (nEquipType)
|
|
{
|
|
case 0:
|
|
{
|
|
sName = _T("消火栓");
|
|
break;
|
|
}
|
|
case 1:
|
|
{
|
|
sName = _T("喷头");
|
|
break;
|
|
}
|
|
case 2:
|
|
{
|
|
sName = _T("井");
|
|
break;
|
|
}
|
|
case 3:
|
|
{
|
|
sName = _T("水泵");
|
|
break;
|
|
}
|
|
case 4:
|
|
{
|
|
sName = _T("雨水口");
|
|
break;
|
|
}
|
|
case 5:
|
|
{
|
|
sName = _T("大小接头");
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return sName;
|
|
}
|
|
|
|
extern CString ReadXdata(Entity ent, const TCHAR*szName);
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSEquipment, ATSPipeNode, AcDb::kDHL_CURRENT,
|
|
AcDb::kMReleaseCurrent, 1, ATS_EQUIPMENT,
|
|
"ATS_EQUIPMENT图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
|
IMPLEMENT_TENTBASE(TDbEquipment);
|
|
|
|
const Adesk::UInt8 TDbEquipment::g_nVersion = 3;
|
|
|
|
TDbEquipment::TDbEquipment():
|
|
m_vtDirection(1,0,0),m_dScale(1.0),m_dDang(0.5),
|
|
m_bHidePipe(TRUE),m_nMirror(0),m_dPipeLength(0)
|
|
{
|
|
m_visibility=TPipeSys::kVisible;
|
|
m_dYScale = 0;
|
|
m_dZScale = 0;
|
|
m_bAutoScale = TRUE;
|
|
}
|
|
|
|
void TDbEquipment::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbPipeNode::CopyPropertiesFrom(pSrc, gMatchFlag);
|
|
TDbEquipment *pEqu = TDbEquipment::cast(pSrc);
|
|
if(pEqu) {
|
|
//m_idBlock2d = pEqu->m_idBlock2d;
|
|
//m_idBlock3d = pEqu->m_idBlock3d;
|
|
//m_sSysBlock = pEqu->m_sSysBlock;
|
|
//m_dScale = pEqu->m_dScale;
|
|
m_bHidePipe = pEqu->m_bHidePipe;
|
|
//m_nMirror = pEqu->m_nMirror;
|
|
//m_dPipeLength = pEqu->m_dPipeLength;
|
|
//m_dDang = pEqu->m_dDang;
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::subGetClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::subGetOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& ptPick,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
|
|
if( osnapMode == AcDb::kOsModeIns ||
|
|
osnapMode == AcDb::kOsModeCen ||
|
|
osnapMode == AcDb::kOsModeNode) {
|
|
snapPoints.append(m_ptInsert);
|
|
snapPoints.append(m_ptLocation);
|
|
}
|
|
es=TDbPipeNode::subGetOsnapPoints(osnapMode,gsSelectionMark,
|
|
ptPick,lastPoint,viewXform,snapPoints,geomIds);
|
|
|
|
return es;
|
|
}
|
|
|
|
// 从DWG读入数据:
|
|
Acad::ErrorStatus TDbEquipment::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
Acad::ErrorStatus es = TDbPipeNode::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(&m_idBlock2d);
|
|
pFiler->readItem(&m_idBlock3d);
|
|
ReadString(pFiler, m_sSysBlock);
|
|
pFiler->readItem((AcGePoint3d *)&m_ptLocation);
|
|
pFiler->readItem((AcGePoint3d *)&m_ptInsert);
|
|
pFiler->readItem((AcGeVector3d *)&m_vtDirection);
|
|
pFiler->readItem(&m_dScale);
|
|
//pFiler->readItem(&m_bHidePipe);
|
|
FilerRead(pFiler, m_bHidePipe);
|
|
pFiler->readItem(&m_nMirror);
|
|
pFiler->readItem(&m_dPipeLength);
|
|
pFiler->readItem(&m_dDang);
|
|
if(nVer > 1){
|
|
pFiler->readItem(&m_dCircleRadius);
|
|
pFiler->readItem(&m_dYScale);
|
|
pFiler->readItem(&m_dZScale);
|
|
pFiler->readItem(&m_dSpare);
|
|
if(nVer > 2){
|
|
//pFiler->readItem(&m_bAutoScale);
|
|
FilerRead(pFiler, m_bAutoScale);
|
|
}
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es = TDbPipeNode::dwgOutFields(pFiler);
|
|
if(es != Acad::eOk) return es;
|
|
|
|
if(g_nSaveTArchVer==6)
|
|
pFiler->writeItem((Adesk::UInt8)1);
|
|
else if(g_nSaveTArchVer==7)
|
|
pFiler->writeItem((Adesk::UInt8)2);
|
|
else
|
|
pFiler->writeItem(g_nVersion);
|
|
pFiler->writeItem(m_idBlock2d);
|
|
pFiler->writeItem(m_idBlock3d);
|
|
pFiler->writeItem((const TCHAR *)m_sSysBlock);
|
|
pFiler->writeItem((const AcGePoint3d &)m_ptLocation);
|
|
pFiler->writeItem((const AcGePoint3d &)m_ptInsert);
|
|
pFiler->writeItem((const AcGeVector3d &)m_vtDirection);
|
|
pFiler->writeItem(m_dScale);
|
|
//pFiler->writeItem(m_bHidePipe);
|
|
FilerWrite(pFiler, m_bHidePipe);
|
|
pFiler->writeItem(m_nMirror);
|
|
pFiler->writeItem(m_dPipeLength);
|
|
pFiler->writeItem(m_dDang);
|
|
if(g_nSaveTArchVer>6){
|
|
pFiler->writeItem(m_dCircleRadius);
|
|
pFiler->writeItem(m_dYScale);
|
|
pFiler->writeItem(m_dZScale);
|
|
pFiler->writeItem(m_dSpare);
|
|
if (g_nSaveTArchVer > 7)
|
|
//pFiler->writeItem(m_bAutoScale);
|
|
FilerWrite(pFiler, m_bAutoScale);
|
|
}
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
es=TDbPipeNode::dxfInFields(pFiler);
|
|
if(es!=Acad::eOk) return es;
|
|
|
|
if (!pFiler->atSubclassData(_T("TDbEquipment"))) {
|
|
return Acad::eBadDxfSequence;
|
|
}
|
|
|
|
resbuf rb;
|
|
while((es==Acad::eOk) && ((es=pFiler->readResBuf(&rb))==Acad::eOk)) {
|
|
switch (rb.restype) {
|
|
case AcDb::kDxfXCoord:
|
|
m_ptLocation =rb.resval.rpoint;
|
|
break;
|
|
case AcDb::kDxfXReal:
|
|
m_dScale=rb.resval.rreal;
|
|
break;
|
|
case AcDb::kDxfBlockName:
|
|
break;
|
|
default:
|
|
pFiler->pushBackItem();
|
|
es = Acad::eEndOfFile;
|
|
break;
|
|
}
|
|
}
|
|
if(es!=Acad::eEndOfFile)
|
|
return Acad::eInvalidResBuf;
|
|
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
es=TDbPipeNode::dxfOutFields(pFiler);
|
|
assert(es==Acad::eOk);
|
|
es=pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbEquipment"));
|
|
assert(es==Acad::eOk);
|
|
|
|
pFiler->writePoint3d(AcDb::kDxfXCoord,m_ptLocation);
|
|
pFiler->writeDouble(AcDb::kDxfXReal,m_dScale);
|
|
CString sBlkName,sDesName;
|
|
GetBlkNameById(m_idBlock2d,sBlkName,sDesName);
|
|
pFiler->writeString(AcDb::kDxfBlockName,(const TCHAR*)sBlkName);
|
|
// cet 2017.3.2 add 添加设备类型名,用于识别设备
|
|
CString sName = GetEquipmentName(this);
|
|
pFiler->writeString(AcDb::kDxfXTextString,(const TCHAR*)sName);
|
|
return es;
|
|
}
|
|
|
|
// 图块插入比例
|
|
AcGeScale3d TDbEquipment::GetInsertScale() const
|
|
{
|
|
assertReadEnabled();
|
|
double dScale(1), dScaleY(1), dScaleZ(1);
|
|
if(m_bAutoScale)
|
|
{
|
|
dScale = m_dScale*GetPScale()/100;
|
|
dScaleY= m_dYScale*GetPScale()/100;
|
|
dScaleZ= m_dZScale*GetPScale()/100;
|
|
}
|
|
else
|
|
{
|
|
dScale = m_dScale;
|
|
dScaleY= m_dYScale;
|
|
dScaleZ= m_dZScale;
|
|
}
|
|
|
|
if(fabs(dScaleY) < 0.001)
|
|
dScaleY = dScale;
|
|
if(fabs(dScaleZ) < 0.001)
|
|
dScaleZ = dScale;
|
|
AcGeScale3d scale(dScale,dScaleY,fabs(dScaleZ));
|
|
if(IsMirrorByY())
|
|
scale.sx *= -1;
|
|
if(IsMirrorByX())
|
|
scale.sy *= -1;
|
|
return scale;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::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;
|
|
}
|
|
return _ExplodeOrDraw2d(dc);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::_ExplodeOrDraw2d(XExplodeDraw &dc,BOOL bZEqual0) const
|
|
{
|
|
if(!m_idBlock2d.isValid())
|
|
return Acad::eInvalidInput;
|
|
|
|
if(fabs(m_vtDirection.x)<1.0E-6 && fabs(m_vtDirection.y)<1.0E-6)
|
|
return Acad::eOk; //垂直设备
|
|
|
|
OPENOBJ_BEGIN(m_idBlock2d, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
if(pBlock) {
|
|
XPoint ptInsert=m_ptInsert;
|
|
if(bZEqual0) ptInsert.z=0;
|
|
double dAngle = ads_angle(XPoint(),m_vtDirection);
|
|
|
|
// BOOL bNewMethod=(g_nAcadVer>15.0001 && g_bMakeBlock);
|
|
// sg add 091105,强制打印时,不使用新方法
|
|
// if (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0 && dc.IsPlotGeneration())
|
|
// bNewMethod = FALSE;
|
|
|
|
//2011-9-30 沈睿dc.DrawBlock(*pBlock,ptInsert,GetInsertScale(),dAngle,TRUE); 采用旧方法,从8.0版本开始,TRUE参数对于打印不起作用。关闭图层,仍然打印
|
|
//dc.DrawBlock(*pBlock,ptInsert,GetInsertScale(),dAngle,bNewMethod);
|
|
|
|
|
|
dc.DrawBlock(*pBlock,ptInsert,GetInsertScale(),dAngle,TRUE);
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::ExplodeOrDraw3d(XExplodeDraw &dc) const
|
|
{
|
|
if(!m_idBlock3d.isValid())
|
|
return _ExplodeOrDraw2d(dc,FALSE);
|
|
|
|
OPENOBJ_BEGIN(m_idBlock3d, AcDb::kForRead, AcDbBlockTableRecord, pBlock);
|
|
if(pBlock) {
|
|
XVector3D vtNormal(0,0,1);
|
|
if(fabs(m_vtDirection.z)>1.0E-6) { //非水平面,计算法向
|
|
vtNormal = XVector3D(1,0,0)*m_vtDirection;
|
|
vtNormal.Normalize();
|
|
}
|
|
//XPoint ptLoc=Wcs2Ecs(m_ptLocation, vtNormal); cet 2011.12.29 modify
|
|
XPoint ptInsert = m_ptInsert;
|
|
ptInsert.z = m_ptLocation.z;
|
|
XPoint ptLoc=Wcs2Ecs(ptInsert, vtNormal);
|
|
if (IsUpLinkHydrant()) // 上接消火栓补充一段管线
|
|
{
|
|
ExplodeOrDrawPipe3d(dc);
|
|
}
|
|
|
|
double nRotEcs = ads_angle(XPoint(),m_vtDirection); //计算ECS下的转角
|
|
|
|
|
|
AcDbBlockReference insert(ptLoc, m_idBlock3d);
|
|
insert.setRotation(nRotEcs);
|
|
insert.setScaleFactors(GetInsertScale());
|
|
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());
|
|
}
|
|
} else {
|
|
return Acad::eInvalidInput;
|
|
}
|
|
OPENOBJ_END();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::ExplodeOrDrawPipe3d(XExplodeDraw &dc) const
|
|
{
|
|
// 获得连接管的id
|
|
int nNum = GetInterfaceNum();
|
|
TPipeInterface face;
|
|
AcDbObjectId idPipe;
|
|
for(int i = 0; i < nNum; i++)
|
|
{
|
|
GetInterface(i, face);
|
|
idPipe = face.m_idPipe;
|
|
break;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipe, pPipe);
|
|
if (pPipe != NULL)
|
|
{
|
|
// 获得管道起点终点
|
|
XVector3D vtNormal(0,0,1);
|
|
if(fabs(m_vtDirection.z)>1.0E-6) //非水平面,计算法向
|
|
{
|
|
vtNormal = XVector3D(1,0,0)*m_vtDirection;
|
|
vtNormal.Normalize();
|
|
}
|
|
XPoint ptInsert = m_ptInsert;
|
|
ptInsert.z = m_ptLocation.z;
|
|
XPoint pt1 = Wcs2Ecs(ptInsert, vtNormal);
|
|
XLine line(pPipe->StartPoint(), pPipe->EndPoint());
|
|
XPoint pt2 = Wcs2Ecs(m_ptLocation, vtNormal);
|
|
m_ptLocation.Project(&line, pt2);
|
|
|
|
TDbPipe *pNewPipe = (TDbPipe *)pPipe->clone();
|
|
pNewPipe->SetStartPoint(pt1);
|
|
pNewPipe->SetEndPoint(pt2);
|
|
pNewPipe->SetNode(0, AcDbObjectId::kNull);
|
|
pNewPipe->SetNode(1, AcDbObjectId::kNull);
|
|
Adesk::UInt16 color = dc.GetColor();
|
|
dc.SetColor(1);
|
|
pNewPipe->ExplodeOrDraw3d(dc);
|
|
dc.SetColor(color);
|
|
}
|
|
OPENOBJ_END();
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TDbEquipment::GetTips(DList<TObjInfoUnit> &info) const
|
|
{
|
|
info.Append(new TObjInfoUnit(_T("对象类型"), _T("设备")));
|
|
CString sBlkName,sDesName;
|
|
if(GetBlkNameById(m_idBlock2d,sBlkName,sDesName) && !sDesName.IsEmpty()) {
|
|
info.Append(new TObjInfoUnit(_T("对象名称"), (const TCHAR*)sDesName));
|
|
}
|
|
// if(sDesName.Find(_T("井")) > -1){ //检查井
|
|
// info.Append(new TObjInfoUnit(_T("井编号"), m_sSysBlock));
|
|
// info.Append(new TObjInfoUnit(_T("地面标高"), XString(_T("%.3f"), m_dDang)));
|
|
// info.Append(new TObjInfoUnit(_T("井底标高"), XString("%.3f", m_dPipeLength)));
|
|
// int num = GetInterfaceNum();
|
|
// for(int i=0;i<num;i++){
|
|
// TPipeInterface iFace;
|
|
// GetInterface(i, iFace);
|
|
// CString csPipeName, csLabel;
|
|
// csLabel = GetISysLabel(i);
|
|
// if(csLabel == "")
|
|
// continue;
|
|
// OPENOBJ_BEGIN(iFace.m_idPipe,AcDb::kForRead,TDbPipePrototype,pPipe);
|
|
// if(pPipe) {
|
|
// csPipeName = pPipe->GetSysLabel();
|
|
// }
|
|
// OPENOBJ_END();
|
|
// csPipeName.Format("%s底标高", csPipeName);
|
|
// info.Append(new TObjInfoUnit((const char*)csPipeName, csLabel));
|
|
// }
|
|
// }
|
|
// else
|
|
info.Append(new TObjInfoUnit(_T("当量值"), Dist2Str(m_dDang)));
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::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; // cet 2016.8.3 add
|
|
default: es=Acad::eInvalidInput;
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
gripPoints.append((AcGePoint3d)m_ptInsert);
|
|
gripPoints.append((AcGePoint3d)m_ptLocation);
|
|
// cet 2016.8.3 add 增加消火栓右侧夹点,用于实现调整消火栓开启方向
|
|
if (m_idBlock2d.isValid() && IsHydrant())
|
|
{
|
|
double dWidth = GetInsertScale().sx;
|
|
double dHeight = GetInsertScale().sy;
|
|
double dAngle = ads_angle(XPoint(),m_vtDirection);
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis * dWidth * 0.5 + AcGeVector3d::kYAxis * dHeight * 0.55;
|
|
AcGePoint3d pt = m_ptLocation + vtX.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
gripPoints.append(pt);
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
|
{
|
|
assertReadEnabled();
|
|
stretchPoints.append((AcGePoint3d)m_ptInsert);
|
|
stretchPoints.append((AcGePoint3d)m_ptLocation);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::subMoveGripPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
// cet 2016.8.3 add 消火栓夹点,实现调整方向
|
|
if (indices.length() == 1 && indices[0] == 2)
|
|
{
|
|
// 移动前所在象限
|
|
double dWidth = GetInsertScale().sx;
|
|
double dHeight = GetInsertScale().sy;
|
|
double dAngleBeforeMove = AcGeVector3d::kXAxis.angleTo(AcGeVector3d::kXAxis * dWidth * 0.5 + AcGeVector3d::kYAxis * dHeight * 0.55, AcGeVector3d::kZAxis);
|
|
int nDirBeforMove = -1;
|
|
if(fabs(dAngleBeforeMove - PI * 2) < 0.001)
|
|
{
|
|
dAngleBeforeMove = 0.0;
|
|
}
|
|
if (dAngleBeforeMove > 0.0 + 0.001 && dAngleBeforeMove + 0.001 < PI * 0.5) // (0, 90)
|
|
{
|
|
nDirBeforMove = 0;
|
|
}
|
|
else if (dAngleBeforeMove > PI * 0.5 + 0.001 && dAngleBeforeMove + 0.001 < PI) // (90, 180)
|
|
{
|
|
nDirBeforMove = 1;
|
|
}
|
|
else if (dAngleBeforeMove > PI + 0.001 && dAngleBeforeMove + 0.001 < PI * 1.5) // (180, 270)
|
|
{
|
|
nDirBeforMove = 2;
|
|
}
|
|
else if (dAngleBeforeMove > PI * 1.5 + 0.001 && dAngleBeforeMove + 0.001 < PI * 2) // (270, 360)
|
|
{
|
|
nDirBeforMove = 3;
|
|
}
|
|
// 移动后点所在象限
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis * dWidth * 0.5 + AcGeVector3d::kYAxis * dHeight * 0.55;
|
|
double dAngle = ads_angle(XPoint(),m_vtDirection);
|
|
vtX.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
AcGeVector3d ptMove = m_ptLocation + vtX + offset;
|
|
AcGeVector3d vtTemp = ptMove - m_ptLocation.AsAcGePoint3d();
|
|
vtTemp.z = 0.0;
|
|
vtX = AcGeVector3d::kXAxis;
|
|
vtX.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
|
double dAngleAfterMove = vtX.angleTo(vtTemp, AcGeVector3d::kZAxis);
|
|
if(fabs(dAngleAfterMove - PI * 2) < 0.001)
|
|
{
|
|
dAngleAfterMove = 0.0;
|
|
}
|
|
int nDirAfterMove = -1;
|
|
if (dAngleAfterMove > 0.0 + 0.001 && dAngleAfterMove + 0.001 < PI * 0.5) // (0, 90)
|
|
{
|
|
nDirAfterMove = 0;
|
|
}
|
|
else if (dAngleAfterMove > PI * 0.5 + 0.001 && dAngleAfterMove + 0.001 < PI) // (90, 180)
|
|
{
|
|
nDirAfterMove = 1;
|
|
}
|
|
else if (dAngleAfterMove > PI + 0.001 && dAngleAfterMove + 0.001 < PI * 1.5) // (180, 270)
|
|
{
|
|
nDirAfterMove = 2;
|
|
}
|
|
else if (dAngleAfterMove > PI * 1.5 + 0.001 && dAngleAfterMove + 0.001 < PI * 2) // (270, 360)
|
|
{
|
|
nDirAfterMove = 3;
|
|
}
|
|
// 根据象限变化调整方向
|
|
if (nDirAfterMove == nDirBeforMove || nDirBeforMove == - 1 || nDirAfterMove == -1)
|
|
{
|
|
return es;
|
|
}
|
|
if (nDirBeforMove == 0 && nDirAfterMove == 3 ||
|
|
nDirBeforMove == 1 && nDirAfterMove == 2 ||
|
|
nDirBeforMove == 2 && nDirAfterMove == 1 ||
|
|
nDirBeforMove == 3 && nDirAfterMove == 0 ) // x轴镜像
|
|
{
|
|
MirrorByX(IsMirrorByX() ? FALSE : TRUE);
|
|
}
|
|
else if (nDirBeforMove == 0 && nDirAfterMove == 1 ||
|
|
nDirBeforMove == 1 && nDirAfterMove == 0 ||
|
|
nDirBeforMove == 2 && nDirAfterMove == 3 ||
|
|
nDirBeforMove == 3 && nDirAfterMove == 2) // y轴镜像
|
|
{
|
|
MirrorByY(IsMirrorByY() ? FALSE : TRUE);
|
|
}
|
|
else
|
|
{
|
|
MirrorByY(IsMirrorByY() ? FALSE : TRUE);
|
|
MirrorByX(IsMirrorByX() ? FALSE : TRUE);
|
|
}
|
|
return es;
|
|
}
|
|
es=MoveGSPointsAt(indices,offset);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::subMoveStretchPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
assertWriteEnabled();
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
es=MoveGSPointsAt(indices,offset);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::MoveGSPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
XPoint vtOffset;
|
|
(AcGeVector3d &)vtOffset=offset;
|
|
vtOffset.z=0;
|
|
m_ptInsert += vtOffset;
|
|
m_ptLocation += vtOffset;
|
|
|
|
return es;
|
|
|
|
// SR 2010-6-17 修改 拉伸不考虑z坐标
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
// Acad::ErrorStatus es=Acad::eOk;
|
|
// AcGeMatrix3d mat;
|
|
// mat.setToTranslation(offset);
|
|
//
|
|
// if(m_ptLocation==m_ptInsert) {
|
|
// m_ptInsert.TransformBy(mat);
|
|
// m_ptLocation.TransformBy(mat);
|
|
// }
|
|
// else {
|
|
// for (int i=0; i<indices.length();i++) {
|
|
// int idx = indices[i];
|
|
// switch(idx) {
|
|
// case 0:
|
|
// m_ptInsert.TransformBy(mat);
|
|
// m_ptLocation.TransformBy(mat);//sr add 2004/7/27
|
|
// break;
|
|
// case 1:
|
|
// m_ptInsert.TransformBy(mat);
|
|
// m_ptLocation.TransformBy(mat);
|
|
// break;
|
|
// default:
|
|
// es=Acad::eInvalidInput;
|
|
// }
|
|
// }
|
|
// }
|
|
// return es;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus
|
|
TDbEquipment::subTransformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
TDbPipeNode::subTransformBy(xform);
|
|
m_ptInsert.TransformBy(xform);
|
|
m_ptLocation.TransformBy(xform);
|
|
|
|
/* cet 2012.7.5 modify 原方法镜像错误
|
|
if(IsMirrorMatrix(xform))
|
|
{//设备镜像 sr modify 2007/3/9
|
|
// TCHAR *layer;
|
|
// layer = this->layer();
|
|
// if(_tcsicmp(layer, LAY_EQUIP_HYDRANT) == 0) // 2009-7-30 SR 取消消火栓限制,其他附件也可以左右翻转了(忘记当初为什么要做这样的限制了)
|
|
MirrorByY(!IsMirrorByY()); //消火栓镜像稍微麻烦点
|
|
// delete []layer;
|
|
((AcGeVector3d &)m_vtDirection).transformBy(xform);
|
|
double dAng = ads_angle(XPoint(),m_vtDirection);
|
|
dAng = dAng - PI;
|
|
SetAngle(fabs(dAng));
|
|
return Acad::eOk;
|
|
}
|
|
|
|
((AcGeVector3d &)m_vtDirection).transformBy(xform);
|
|
*/
|
|
|
|
((AcGeVector3d &)m_vtDirection).transformBy(xform);
|
|
if (IsMirrorMatrix(xform))
|
|
{
|
|
MirrorByX(!IsMirrorByX());
|
|
}
|
|
|
|
double dScale = xform.scale();
|
|
if (fabs(dScale-1)>1.0E-5 && fabs(dScale)>1.0E-5) { // cet 2010.8.27 modify 将1.0E-3 改为 1.0E-5
|
|
m_dScale *= dScale;
|
|
m_dYScale *= dScale; // 2009-8-3 增加Y,Z 不然用SC变比例,没有变Y,Z方向的比例
|
|
m_dZScale *= dScale;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TDbEquipment::MirrorByX(BOOL bFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bFlag)
|
|
m_nMirror |= MIRROR_XAXIS;
|
|
else
|
|
m_nMirror &= ~MIRROR_XAXIS;
|
|
}
|
|
|
|
void TDbEquipment::MirrorByY(BOOL bFlag)
|
|
{
|
|
assertWriteEnabled();
|
|
if(bFlag)
|
|
m_nMirror |= MIRROR_YAXIS;
|
|
else
|
|
m_nMirror &= ~MIRROR_YAXIS;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbEquipment::GetExtents(XPoint &ptLow, XPoint &ptUp) const
|
|
{
|
|
Acad::ErrorStatus es=Acad::eOk;
|
|
es = TDbPipeNode::GetExtents(ptLow,ptUp);
|
|
if(es==Acad::eOk) {
|
|
if(ptLow==XPoint()&&ptUp==XPoint()) {
|
|
ptLow = m_ptLocation;
|
|
ptUp = m_ptLocation;
|
|
} else {
|
|
ptLow = Min(ptLow,m_ptLocation);
|
|
ptUp = Max(ptUp,m_ptLocation);
|
|
}
|
|
}
|
|
return es;
|
|
}
|
|
|
|
// 判断节点是否可以连接管段. nPos: 0--start; 1--end
|
|
BOOL TDbEquipment::CanLinkSide(const AcDbObjectId &idPipe, int nPos) const
|
|
{
|
|
BOOL bRet=FALSE;
|
|
// cet 2016.6.7 modify 自定义实体中不再直接使用图层宏
|
|
// // zxl 2014.01.09 add 雨水口特殊处理
|
|
// CString sLayer = layer();
|
|
// if (sLayer.Compare(LAY_TWT_GULLY) == 0)
|
|
if (GetEquipmentType() == 4)
|
|
{
|
|
double dMeter = 1.0;
|
|
if(DocGetMeterUnitDraw())
|
|
dMeter = 1000.0;
|
|
double nRadius = GetScale() * GetPScale();
|
|
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipePrototype, pPipe);
|
|
if(pPipe) {
|
|
XPoint ptRef=nPos? pPipe->EndPoint() : pPipe->StartPoint();
|
|
XPoint ptLoc=GetLocation();
|
|
ptLoc.z =0;//
|
|
ptRef.z = 0;//
|
|
if(ptRef.Distance(ptLoc)<PS_SNAP / dMeter)
|
|
bRet = TRUE;
|
|
double nDist = ptRef.Distance(ptLoc);
|
|
if(fabs(nDist - nRadius/2) < PS_SNAP / dMeter)
|
|
bRet = TRUE;
|
|
}
|
|
OPENOBJ_END();
|
|
return bRet;
|
|
}
|
|
|
|
OPENOBJ_BEGIN(idPipe, AcDb::kForRead, TDbPipePrototype, pPipe);
|
|
if(pPipe) {
|
|
const XPoint &ptRef=nPos? pPipe->EndPoint() : pPipe->StartPoint();
|
|
XPoint ptLoc=GetLocation();
|
|
if(ptRef.Distance(ptLoc)<PS_SNAP)
|
|
bRet=TRUE;
|
|
}
|
|
OPENOBJ_END();
|
|
return bRet;
|
|
}
|
|
|
|
//XRectAngle.Intersection 函数有缺陷,无法求交坐标过大的情况
|
|
int IntersectionRect2Line(XRectAngle &rect, XLine &line, XPoint &ptInter)
|
|
{
|
|
AcGeLineSeg2d ln1(line.StartPoint().AsAcGePoint2d(), line.EndPoint().AsAcGePoint2d());
|
|
XPoint lowRight(rect.upRight.x,rect.lowLeft.y, rect.upRight.z),
|
|
upLeft(rect.lowLeft.x, rect.upRight.y, rect.upRight.z);
|
|
XLine line1(rect.lowLeft, lowRight, LS_FINITE),
|
|
line2(lowRight, rect.upRight, LS_FINITE),
|
|
line3(rect.upRight, upLeft, LS_FINITE),
|
|
line4(upLeft, rect.lowLeft, LS_FINITE);
|
|
int intersNum=0;
|
|
XPoint intPt;
|
|
XLine *ptr[4] = { &line1, &line2, &line3, &line4 };
|
|
for(int i=0; i<4; i++) {
|
|
XPoint p1 = ptr[i]->StartPoint();
|
|
XPoint p2 = ptr[i]->EndPoint();
|
|
AcGeLineSeg2d ln2(p1.AsAcGePoint2d(), p2.AsAcGePoint2d());
|
|
if(ln1.intersectWith(ln2, ptInter))
|
|
return 1;
|
|
}
|
|
return intersNum;
|
|
}
|
|
|
|
double TDbEquipment::GetWidth(const TDbPipePrototype* pPipe) const
|
|
{
|
|
//待考虑三维图块...
|
|
double dWidth=0;
|
|
// cet 2014.5.6 del 管线被设备遮挡的长度,通过炸开二维图块与管线求交获得
|
|
// CString csNumber = GetNumber();
|
|
//
|
|
// if(csNumber.Find(_T("CIRCLE")) >= 0 && IsHidePipe()){//如果是圆设备,返回圆半径×比例
|
|
// csNumber = csNumber.Right(csNumber.GetLength() - 7);
|
|
// dWidth = _tstof(csNumber)*GetScale();
|
|
// return dWidth*GetPScale()/100;
|
|
// }
|
|
if(m_idBlock2d.isValid()) {// 二维图块
|
|
AcDbExtents extents;
|
|
AcDbBlockReference insert(AcGePoint3d(0,0,0), m_idBlock2d);
|
|
double dScaleX(0), dScaleY(0);
|
|
|
|
if(m_bAutoScale)
|
|
{
|
|
dScaleX = m_dScale*GetPScale()/100;
|
|
dScaleY = m_dYScale*GetPScale()/100;
|
|
}
|
|
else
|
|
{
|
|
dScaleX = m_dScale;
|
|
dScaleY = m_dYScale;
|
|
}
|
|
|
|
|
|
if(fabs(dScaleY) < 0.001)
|
|
dScaleY = dScaleX;
|
|
|
|
if(IsMirrorByY())
|
|
dScaleX = -dScaleX;
|
|
if(IsMirrorByX())
|
|
dScaleY = -dScaleY;
|
|
insert.setScaleFactors(AcGeScale3d(dScaleX, dScaleY, fabs(dScaleX)));
|
|
// cet 2014.5.6 modify 使用外包框算法,结果有时不准备, 改为炸开实体求交 (未考虑图块嵌套情况)
|
|
// if(insert.geomExtentsBestFit(extents)==Acad::eOk) {
|
|
// XPoint ptMax = extents.maxPoint();
|
|
// XPoint ptMin = extents.minPoint();
|
|
//
|
|
// dWidth = (ptMax.x-ptMin.x)/2;// 第一次求得的宽度值
|
|
//
|
|
// if(pPipe!=NULL && pPipe->Is(CURVE_LINE)) { // 仅考虑直线管段
|
|
// XPoint ptPosition = insert.position();
|
|
// XPoint ptPlus = m_ptInsert-ptPosition;
|
|
//
|
|
// XPoint ptLocation=m_ptLocation;
|
|
// XRectAngle rect(ptMin+ptPlus,ptMax+ptPlus);
|
|
// XLine line=(XLine)*pPipe;
|
|
//
|
|
// double dAngle=CT_std_angle(ads_angle(XPoint(),m_vtDirection));
|
|
// if(fabs(dAngle)>1.0E-6) {
|
|
// ads_matrix mat;
|
|
// m_ptInsert.GetRotationMatrix(-dAngle,mat);
|
|
// line.TransformBy(mat);
|
|
// ptLocation.TransformBy(mat);
|
|
// }
|
|
// rect.SetElevation(0);
|
|
// line.SetElevation(0);
|
|
// ptLocation.z=0;
|
|
//
|
|
// int nFlag = ptLocation▭
|
|
// if(nFlag != PR_INSIDE) {
|
|
// dWidth = 0;
|
|
// } else {
|
|
// XPoint ptIntersect;
|
|
// if(IntersectionRect2Line(rect,line,ptIntersect)){
|
|
// dWidth=ptLocation.Distance(ptIntersect);
|
|
// }
|
|
// // if(rect.Intersection(line,ptIntersect)){//sr remove it 2007-5-9 XRectAngle.Intersection 函数有缺陷,无法求交坐标过大的情况
|
|
// // dWidth=ptLocation.Distance(ptIntersect);
|
|
// // }
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
insert.setPosition(m_ptInsert);
|
|
double dAngle = ads_angle(XPoint(),m_vtDirection);
|
|
insert.setRotation(dAngle);
|
|
TGGeCurveSegment curve = pPipe->GetCurve();
|
|
curve.SetElevation(0.0);
|
|
AcDbCurve *pPipeCurve = curve.AsAcDbCurve();
|
|
// cet 2017.3.8 add 距离原点过远时,移动到原点附近计算,防止计算出错
|
|
AcGeMatrix3d mat = AcGeMatrix3d::kIdentity;
|
|
if (m_ptInsert.Distance(XPoint()) > g_dPointToOriginLimitDist)
|
|
{
|
|
XPoint ptTemp = m_ptInsert;
|
|
ptTemp.z = 0.0;
|
|
mat.setToTranslation(-ptTemp.AsAcGeVector3d());
|
|
insert.transformBy(mat);
|
|
pPipeCurve->transformBy(mat);
|
|
}
|
|
AcDbVoidPtrArray arrEnt;
|
|
AcGePoint3dArray arrIntPt, arrPoint;
|
|
AcGePoint3d pt1, pt2;
|
|
if (insert.explode(arrEnt) == Acad::eOk)
|
|
{
|
|
for (int j = 0; j < arrEnt.length(); ++j)
|
|
{
|
|
AcDbEntity *pEnt = (AcDbEntity*)(arrEnt[j]);
|
|
if (pEnt == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
AcDbCurve *pCurve = AcDbCurve::cast(pEnt);
|
|
if (pCurve == NULL)
|
|
{
|
|
continue;
|
|
}
|
|
Acad::ErrorStatus st = pPipeCurve->intersectWith(pCurve, AcDb::kOnBothOperands, AcGePlane::kXYPlane, arrIntPt);
|
|
for (int i = 0; i < arrIntPt.length(); ++i)
|
|
{
|
|
arrPoint.append(arrIntPt[i]);
|
|
}
|
|
arrIntPt.setLogicalLength(0);
|
|
}
|
|
ReleaseEntSet(arrEnt);
|
|
}
|
|
delete pPipeCurve;
|
|
pPipeCurve = NULL;
|
|
|
|
// 设备插入点在管线一端,找到与设备重合的管线端点,求出距该点最用的交点距离
|
|
XPoint ptS = pPipe->GetStartPoint();
|
|
XPoint ptE = pPipe->GetEndPoint();
|
|
AcGePoint3d pt = ptS;
|
|
if (ptS.Distance2d(m_ptInsert) > ptE.Distance2d(m_ptInsert))
|
|
{
|
|
pt = ptE;
|
|
}
|
|
pt.transformBy(mat); // cet 2017.3.8 add 考虑距离原点过远情况,移动到原点附近计算
|
|
pt.z = 0.0;
|
|
for (int k = 0; k < arrPoint.length(); ++k)
|
|
{
|
|
double dDist = pt.distanceTo(arrPoint[k]);
|
|
if (k == 0 || dWidth < dDist)
|
|
{
|
|
dWidth = dDist;
|
|
}
|
|
}
|
|
}
|
|
return dWidth;
|
|
}
|
|
|
|
// 对st类型的接口进行重新连接
|
|
void TDbEquipment::UpdateLinkage(const XPoint &ptAt,
|
|
TPipeSys::SysType st,
|
|
const DList<AcDbObjectId> &idPipes)
|
|
{
|
|
assertWriteEnabled();
|
|
m_ptLocation = ptAt;
|
|
// cet 2016.6.7 modify 自定义实体中不再直接使用图层宏
|
|
// // zxl 2014.01.09 add 雨水口特殊处理
|
|
// CString sLayer = layer();
|
|
// if (sLayer.Compare(LAY_TWT_GULLY) == 0)
|
|
if (GetEquipmentType() == 4)
|
|
{
|
|
DList<TPipeInterface> lstInterface;//先保留一份出来,目的是得到各管底标高
|
|
for(int j=0; j<m_lstInterface.Length(); j++) {
|
|
TPipeInterface& iFace=*m_lstInterface[j];
|
|
lstInterface.Append(new TPipeInterface(iFace));
|
|
}
|
|
|
|
double dMeter = 1.0;
|
|
if(DocGetMeterUnitDraw())
|
|
dMeter = 1000.0;
|
|
|
|
RemoveInterface(st);
|
|
double nRadius = GetScale() * GetPScale();
|
|
for(int i=0; i<idPipes.Length(); i++) {
|
|
const AcDbObjectId &id=idPipes[i];
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe) {
|
|
TPipeInterface iFace;
|
|
iFace.m_sysType = st;
|
|
iFace.m_faceType = TPipeInterface::kNodeLocation;
|
|
for(j=0; j<lstInterface.Length(); j++) {
|
|
TPipeInterface& iFace2=*lstInterface[j];
|
|
if(iFace2.m_idPipe == id){
|
|
iFace.m_sSysLabel = iFace2.m_sSysLabel;
|
|
break;
|
|
}
|
|
}
|
|
iFace.m_idPipe = id;
|
|
XPoint ptS, ptE;
|
|
ptS = pPipe->StartPoint();
|
|
ptE = pPipe->EndPoint();
|
|
ptS.z = 0;
|
|
ptE.z = 0;
|
|
XPoint ptLoc = m_ptLocation;
|
|
ptLoc.z = 0;
|
|
double nDist1 = ptLoc.Distance(ptS);
|
|
double nDist2 = ptLoc.Distance(ptE);
|
|
if(nDist1<PS_SNAP / dMeter || fabs(nDist1 - nRadius/2) < PS_SNAP / dMeter) {
|
|
if(fabs(nDist1 - nRadius/2) < PS_SNAP / dMeter){
|
|
if(pPipe->upgradeOpen()==Acad::eOk){
|
|
pPipe->SetStartPoint(m_ptLocation);
|
|
pPipe->downgradeOpen();
|
|
}
|
|
}
|
|
iFace.m_ptLocation = pPipe->StartPoint();
|
|
AcGeVector3d vt;
|
|
pPipe->getFirstDeriv(pPipe->StartPoint(), vt);
|
|
iFace.m_vtLocation = vt;
|
|
AddInterface(iFace);
|
|
} else if(nDist2<PS_SNAP / dMeter || fabs(nDist2 - nRadius/2) < PS_SNAP / dMeter) {
|
|
if(fabs(nDist2 - nRadius/2) < PS_SNAP / dMeter){
|
|
if(pPipe->upgradeOpen()==Acad::eOk){
|
|
pPipe->SetEndPoint(m_ptLocation);
|
|
pPipe->downgradeOpen();
|
|
}
|
|
}
|
|
iFace.m_ptLocation = pPipe->EndPoint();
|
|
AcGeVector3d vt;
|
|
pPipe->getFirstDeriv(pPipe->EndPoint(), vt);
|
|
iFace.m_vtLocation = XVector3D(-vt[0], -vt[1], -vt[2]);
|
|
AddInterface(iFace);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
return;
|
|
}
|
|
TDbPipeNode::UpdateLinkage(ptAt,st,idPipes);
|
|
|
|
/*RemoveInterface(st);
|
|
for(int i=0; i<idPipes.Length(); i++) {
|
|
const AcDbObjectId &id=idPipes[i];
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe) {
|
|
TPipeInterface iFace;
|
|
iFace.m_sysType = st;
|
|
iFace.m_faceType = TPipeInterface::kNodeLocation;
|
|
iFace.m_sSysLabel = pPipe->GetSysLabel();
|
|
iFace.m_idPipe = id;
|
|
if(m_ptLocation.Distance(pPipe->StartPoint())<PS_SNAP) {
|
|
iFace.m_ptLocation = pPipe->StartPoint();
|
|
AcGeVector3d vt;
|
|
pPipe->getFirstDeriv(pPipe->StartPoint(), vt);
|
|
iFace.m_vtLocation = vt;
|
|
AddInterface(iFace);
|
|
} else if(m_ptLocation.Distance(pPipe->EndPoint())<PS_SNAP) {
|
|
iFace.m_ptLocation = pPipe->EndPoint();
|
|
AcGeVector3d vt;
|
|
pPipe->getFirstDeriv(pPipe->EndPoint(), vt);
|
|
iFace.m_vtLocation = XVector3D(-vt[0], -vt[1], -vt[2]);
|
|
AddInterface(iFace);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}*/
|
|
}
|
|
|
|
// 2008-2-27 沈睿 add 支持系统图块与不相关但位置贴近的管线,进行裁剪
|
|
Acad::ErrorStatus TDbEquipment::GetClipBoundary(XPoly2D& poly)const
|
|
{
|
|
if(m_idBlock2d.isValid() && IsHidePipe()) {// 二维图块
|
|
AcDbExtents extents;
|
|
// AcDbBlockReference insert(m_ptLocation, m_idBlock2d);
|
|
// double dScaleX(0), dScaleY(0);
|
|
// dScaleX = m_dScale*GetPScale()/100;
|
|
// dScaleY = m_dYScale*GetPScale()/100;
|
|
// if(fabs(dScaleY) < 0.001)
|
|
// dScaleY = dScaleX;
|
|
//
|
|
// if(IsMirrorByY())
|
|
// dScaleX = -dScaleX;
|
|
// if(IsMirrorByX())
|
|
// dScaleY = -dScaleY;
|
|
// insert.setScaleFactors(AcGeScale3d(dScaleX, dScaleY, fabs(dScaleX)));
|
|
|
|
// if(insert.geomExtentsBestFit(extents)==Acad::eOk) {
|
|
if(getGeomExtents(extents)==Acad::eOk) {
|
|
XPoint ptMax = extents.maxPoint();
|
|
XPoint ptMin = extents.minPoint();
|
|
ptMax.z = 0;
|
|
ptMin.z = 0;
|
|
XRectAngle rect(ptMin,ptMax);
|
|
rect.AsPoly2D(poly);
|
|
poly.SetFlag(1);
|
|
//poly.Make();
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
|
|
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
bool TDbEquipment::GetSection(const AcDbFace &face, const AcGeVector3d& vtPlaneSecDir,
|
|
std::vector<TObjSectionRecord> §ionRecords,
|
|
AcDbVoidPtrArray& arFillPtrs) const
|
|
{
|
|
if (IsSprinkler()) // 喷头
|
|
{
|
|
// 连接管
|
|
TGGeSectionPlane section_pln(face, vtPlaneSecDir);
|
|
AcGeVector3d vtPipe = AcGeVector3d::kZAxis;
|
|
AcDbObjectId id = objectId(), idLayer = layerId();
|
|
AcGePoint3d ptS = m_ptLocation, ptE = ptS + vtPipe * m_dPipeLength;
|
|
if (GetInterfaceNum() > 0)
|
|
{
|
|
TPipeInterface iter;
|
|
GetInterface(0, iter);
|
|
AcDbObjectId nextPipeId = iter.m_idPipe;
|
|
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe != NULL)
|
|
{
|
|
id = pPipe->objectId();
|
|
idLayer = pPipe->layerId();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
AcGeLineSeg3d line(ptS, ptE);
|
|
AcGeLineSeg3d seg;
|
|
AcGePoint3d pt;
|
|
int nRet = SectionUtility::Projection_line2plane(section_pln, line, seg, pt);
|
|
|
|
TGGePoly2D poly2d;
|
|
poly2d.AppendNode(asDblArray(seg.startPoint()));
|
|
poly2d.AppendNode(asDblArray(seg.endPoint()));
|
|
TObjSectionRecord record(id, idLayer, TObjSectionRecord::eTCH_EEQUIPMENT, 0, poly2d);
|
|
sectionRecords.push_back(record);
|
|
|
|
// 求线与投影面的最短距离
|
|
AcGePlane plane = section_pln.AsAcGePlane();
|
|
pt = ptE;
|
|
pt = pt.project(plane, vtPlaneSecDir);
|
|
double dDist = pt.distanceTo(m_ptLocation);
|
|
|
|
XPoint pt1, pt2;
|
|
AcGePoint3d ptMin, ptMax;
|
|
GetExtents(pt1, pt2);
|
|
ptMin = pt1;
|
|
ptMax = pt2;
|
|
ptMin = ptMin.orthoProject(plane);
|
|
ptMax = ptMax.orthoProject(plane);
|
|
|
|
XString xsBlk;
|
|
XString xsTKName, xsRocord;
|
|
SplitSlbName(_T("TwtSys(00000283)"), xsTKName, xsRocord);
|
|
LoadDwbBlock(xsTKName, xsRocord, xsBlk);
|
|
AcDbObjectId idBlock;
|
|
AcDbBlockTable *pBlkTbl = NULL;
|
|
acdbHostApplicationServices()->workingDatabase()->getBlockTable(pBlkTbl, AcDb::kForRead);
|
|
if (pBlkTbl != NULL)
|
|
{
|
|
pBlkTbl->getAt(xsBlk, idBlock);
|
|
pBlkTbl->close();
|
|
}
|
|
|
|
if (idBlock.isValid())
|
|
{
|
|
BlockRefInfo info(idBlock, AcGeScale3d(m_dScale), pt, dDist * (-1), ptMax, ptMin);
|
|
TSectionFill *pFill = new TSectionFill(info, layerId());
|
|
arFillPtrs.append(pFill);
|
|
}
|
|
}
|
|
else if (IsHydrant()) // 消火栓
|
|
{
|
|
bool bUpLink = FALSE; // 消火栓样式上接
|
|
CString strBlkName,strDes;
|
|
GetBlkNameById(m_idBlock3d, strBlkName, strDes);
|
|
if (strBlkName.CompareNoCase(_T("$TwtSys$00000441")) == 0) // 上接
|
|
{
|
|
bUpLink = TRUE;
|
|
}
|
|
else if (strBlkName.CompareNoCase(_T("$TwtSys$00000442")) == 0) // 下接
|
|
{
|
|
bUpLink = FALSE;
|
|
}
|
|
|
|
double dHeight = 1000; // 消火栓高度先假设为此值
|
|
double dWidth = m_dYScale, dLen = m_dScale;
|
|
AcGeVector3d vt = m_vtDirection.AsAcGeVector3d(); // 消火栓方向
|
|
AcGeVector3d vtZ = AcGeVector3d::kZAxis;
|
|
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
|
AcGeVector3d vtY = AcGeVector3d::kYAxis;
|
|
TGGeSectionPlane section_pln(face, vtPlaneSecDir);
|
|
if (vt.isParallelTo(vtPlaneSecDir)) // 与剖切方向平行
|
|
{
|
|
AcGePoint3d pt1 = m_ptLocation - vtX * dLen / 2 + vtY * dWidth / 2 ;
|
|
if (bUpLink)
|
|
{
|
|
pt1 += vtZ * 200;
|
|
}
|
|
else
|
|
{
|
|
pt1 -= vtZ * 200;
|
|
}
|
|
AcGePoint3d pt2 = pt1 - vtY * dWidth;
|
|
AcGePoint3d pt3 = pt1 + vtZ * dHeight;
|
|
AcGePoint3d pt4 = pt2 + vtZ * dHeight;
|
|
|
|
TGGePoly2D poly2d;
|
|
TGGeSectionPlane plane1(pt1, pt2, pt4, pt3, vt);
|
|
double dDist = SectionUtility::Projection_plane2plane(section_pln, plane1, poly2d);
|
|
|
|
TObjSectionRecord record(objectId(), layerId(), TObjSectionRecord::eTCH_EEQUIPMENT, dDist, poly2d);
|
|
sectionRecords.push_back(record);
|
|
}
|
|
else // 其他情况均按与剖切方向垂直处理
|
|
{
|
|
AcGePoint3d pt1 = m_ptLocation - vtX * dLen / 2 + vtY * dWidth / 2;
|
|
if (bUpLink)
|
|
{
|
|
pt1 += vtZ * 200;
|
|
}
|
|
else
|
|
{
|
|
pt1 -= vtZ * 200;
|
|
}
|
|
AcGePoint3d pt2 = pt1 + vtX * dLen;
|
|
AcGePoint3d pt3 = pt1 + vtZ * dHeight;
|
|
AcGePoint3d pt4 = pt2 + vtZ * dHeight;
|
|
|
|
TGGePoly2D poly2d;
|
|
TGGeSectionPlane plane1(pt1, pt2, pt4, pt3, vt);
|
|
double dDist = SectionUtility::Projection_plane2plane(section_pln, plane1, poly2d);
|
|
|
|
TObjSectionRecord record(objectId(), layerId(), TObjSectionRecord::eTCH_EEQUIPMENT, dDist, poly2d);
|
|
sectionRecords.push_back(record);
|
|
}
|
|
|
|
// 消火栓上接时需多画一段线
|
|
if (bUpLink)
|
|
{
|
|
AcDbObjectId id = objectId(), idLayer = layerId();
|
|
AcGePoint3d ptS = m_ptLocation, ptE = ptS + vtZ * 200; // 图块插入点距消火栓底部距离
|
|
if (GetInterfaceNum() > 0)
|
|
{
|
|
TPipeInterface iter;
|
|
GetInterface(0, iter);
|
|
AcDbObjectId nextPipeId = iter.m_idPipe;
|
|
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe != NULL)
|
|
{
|
|
id = pPipe->objectId();
|
|
idLayer = pPipe->layerId();
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
AcGeLineSeg3d line(ptS, ptE);
|
|
AcGeLineSeg3d seg;
|
|
AcGePoint3d pt;
|
|
SectionUtility::Projection_line2plane(section_pln, line, seg, pt);
|
|
|
|
TGGePoly2D poly2d;
|
|
poly2d.AppendNode(asDblArray(seg.startPoint()));
|
|
poly2d.AppendNode(asDblArray(seg.endPoint()));
|
|
TObjSectionRecord record(id, idLayer, TObjSectionRecord::eTCH_EEQUIPMENT, 0, poly2d);
|
|
sectionRecords.push_back(record);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
BOOL TDbEquipment::IsSprinkler() const
|
|
{
|
|
// cet 2014.12.2 add 根据设备类型判断是否为喷头
|
|
if (GetEquipmentType() == 1)
|
|
{
|
|
return TRUE;
|
|
}
|
|
XString xsTmp1 = _T("$twtsys$00000125");
|
|
XString xsTmp2 = _T("$twtsys$00000128");
|
|
XString xsTmp3 = _T("$twtsys$00000129");
|
|
XString xsTmp4 = _T("$twtsys$00000131");
|
|
// XString xsTmp5 = _T("$twtsys$00000283"); //系统喷头
|
|
// XString xsTmp6 = _T("$twtsys$00000126"); //系统喷头
|
|
// XString xsTmp7 = _T("$twtsys$00000130"); //系统喷头
|
|
AcDbObjectId idBlk = GetBlock2d();
|
|
const TCHAR *szBlkName = NULL;
|
|
OPENOBJ_BEGIN(idBlk, AcDb::kForRead, AcDbBlockTableRecord, pRecord);
|
|
if(pRecord){
|
|
pRecord->getName(szBlkName);
|
|
}
|
|
OPENOBJ_END();
|
|
// cet 2012.6.26 modify 将块名改为小写
|
|
CString sBlkName = szBlkName;
|
|
sBlkName.MakeLower();
|
|
if(_tcsicmp(sBlkName, xsTmp2) == 0 || _tcsicmp(sBlkName, xsTmp1) == 0 ||
|
|
_tcsicmp(sBlkName, xsTmp4) == 0 || _tcsicmp(sBlkName, xsTmp3) == 0) //是喷头
|
|
return TRUE;
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbEquipment::IsHydrant() const
|
|
{
|
|
// cet 2014.12.2 add 根据设备类型判断是否为消火栓
|
|
if (GetEquipmentType() == 0)
|
|
{
|
|
return TRUE;
|
|
}
|
|
XString xsTmp1 = _T("$twtsys$00000434");
|
|
XString xsTmp2 = _T("$twtsys$00000435");
|
|
XString xsTmp3 = _T("$twtsys$00000485");
|
|
XString xsTmp4 = _T("$twtsys$00000487");
|
|
XString xsTmp5 = _T("$twtsys$00000508");
|
|
XString xsTmp6 = _T("$twtsys$00000509");
|
|
const TCHAR *szBlkName = NULL;
|
|
AcDbObjectId idBlk = GetBlock2d();
|
|
OPENOBJ_BEGIN(idBlk, AcDb::kForRead, AcDbBlockTableRecord, pRecord);
|
|
if(pRecord){
|
|
pRecord->getName(szBlkName);
|
|
}
|
|
OPENOBJ_END();
|
|
// cet 2012.6.26 modify 将块名改为小写
|
|
CString sBlkName = szBlkName;
|
|
sBlkName.MakeLower();
|
|
if(_tcsicmp(sBlkName, xsTmp2) == 0 || _tcsicmp(sBlkName, xsTmp1) == 0 ||
|
|
_tcsicmp(sBlkName, xsTmp3) == 0 || _tcsicmp(sBlkName, xsTmp4) == 0 ||
|
|
_tcsicmp(sBlkName, xsTmp5) == 0 || _tcsicmp(sBlkName, xsTmp6) == 0 )
|
|
return TRUE;
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbEquipment::IsUpLinkHydrant() const
|
|
{
|
|
XString xsTmp1 = _T("$twtsys$00000441");
|
|
const TCHAR *szBlkName = NULL;
|
|
AcDbObjectId idBlk = GetBlock3d();
|
|
OPENOBJ_BEGIN(idBlk, AcDb::kForRead, AcDbBlockTableRecord, pRecord);
|
|
if(pRecord){
|
|
pRecord->getName(szBlkName);
|
|
}
|
|
OPENOBJ_END();
|
|
// cet 2012.6.26 modify 将块名改为小写
|
|
CString sBlkName = szBlkName;
|
|
sBlkName.MakeLower();
|
|
if(_tcsicmp(sBlkName, xsTmp1) == 0)
|
|
return TRUE;
|
|
else
|
|
return FALSE;
|
|
}
|
|
|
|
void InitDbEquipment(BOOL bTrue)
|
|
{
|
|
if(bTrue) {
|
|
TDbEquipment::rxInit();
|
|
TDbEquipment::InitMatchProtocol(TRUE);
|
|
} else {
|
|
TDbEquipment::InitMatchProtocol(FALSE);
|
|
deleteAcRxClass(TDbEquipment::desc());
|
|
}
|
|
}
|
|
|
|
CString TDbEquipment::GetXml(const AcGeMatrix3d& mat) const
|
|
{
|
|
// cet 2013.5.14 add 三维图块id不存在时,不进行导出
|
|
if (m_idBlock3d.isNull())
|
|
{
|
|
return CString();
|
|
}
|
|
|
|
if (GetInterfaceNum() > 0)
|
|
{
|
|
TPipeSys::ModelType modelType = TPipeSys::kModel; // cet 2015.3.31 modify 设置默认值(有时关联管线无法正确获得,导致该值未知,产生崩溃)
|
|
TPipeInterface iter;
|
|
GetInterface(0, iter);
|
|
AcDbObjectId nextPipeId = iter.m_idPipe;
|
|
OPENOBJ_BEGIN(nextPipeId, AcDb::kForRead, TDbPipe, pPipe);
|
|
if(pPipe != NULL)
|
|
{
|
|
modelType = pPipe->GetModelType();
|
|
}
|
|
OPENOBJ_END();
|
|
|
|
if (modelType == TPipeSys::kSystem) // 管段的模型类型为系统图
|
|
{
|
|
return CString();
|
|
}
|
|
}
|
|
|
|
TXmlTree xmlTree;
|
|
CString csText;
|
|
AcGePoint3d pt;
|
|
CString csX, csY, csZ;
|
|
int nPreci = 3; // 精度
|
|
|
|
// 获得设备转换矩阵
|
|
XVector3D vtNormal(0,0,1);
|
|
if(fabs(m_vtDirection.z) > 1.0E-6) //非水平面,计算法向
|
|
{
|
|
vtNormal = XVector3D(1,0,0)*m_vtDirection;
|
|
vtNormal.Normalize();
|
|
}
|
|
XPoint ptLoc=Wcs2Ecs(m_ptLocation, vtNormal);
|
|
double nRotEcs = ads_angle(XPoint(),m_vtDirection); //计算ECS下的转角
|
|
AcDbBlockReference block(ptLoc, m_idBlock3d);
|
|
block.setRotation(nRotEcs);
|
|
block.setScaleFactors(GetInsertScale());
|
|
AcGeMatrix3d mat1 = block.blockTransform();
|
|
mat1 = mat * mat1;
|
|
CString sMat;
|
|
Matrix3D2String(mat1, sMat);
|
|
|
|
if (IsHydrant()) // 消火栓
|
|
{
|
|
POSITION posRoot = xmlTree.Insert(_T("TCH_EQUIPMENTTWT"), NULL, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posRoot, _T("name"), _T("消火栓"));
|
|
xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称"));
|
|
}
|
|
|
|
POSITION posItemStyle = xmlTree.Insert(_T("Style"),posRoot, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posItemStyle, _T("name"), _T("样式"));
|
|
xmlTree.SetAttribute(posItemStyle, _T("comment"), _T("消火栓接管样式"));
|
|
|
|
if (fabs(m_dPipeLength) < 0.001)
|
|
{
|
|
csText = _T("平接");
|
|
}
|
|
else
|
|
{
|
|
csText = _T("上接");
|
|
}
|
|
xmlTree.SetItemText(posItemStyle, csText);
|
|
}
|
|
|
|
POSITION posItemCenterPt = xmlTree.Insert(_T("Center_point"), posRoot, posItemStyle);
|
|
{
|
|
xmlTree.SetAttribute(posItemCenterPt, _T("name"), _T("中心点"));
|
|
xmlTree.SetAttribute(posItemCenterPt, _T("comment"), _T("插入点位置"));
|
|
XPoint ptLoc = m_ptInsert;
|
|
ptLoc.z = m_ptLocation.z;
|
|
ptLoc.TransformBy(mat);
|
|
csX = DoubleToString(ptLoc.x, nPreci);
|
|
csY = DoubleToString(ptLoc.y, nPreci);
|
|
csZ = DoubleToString(ptLoc.z, nPreci);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemCenterPt, csText);
|
|
}
|
|
|
|
POSITION posItemVector = xmlTree.Insert(_T("Vector"), posRoot, posItemCenterPt);
|
|
{
|
|
xmlTree.SetAttribute(posItemVector, _T("name"), _T("向量"));
|
|
xmlTree.SetAttribute(posItemVector, _T("comment"), _T("向量"));
|
|
XVector3D vtDir = m_vtDirection;
|
|
vtDir.TransformBy(mat);
|
|
csX = DoubleToString(vtDir.x, nPreci);
|
|
csY = DoubleToString(vtDir.y, nPreci);
|
|
csZ = DoubleToString(vtDir.z, nPreci);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemVector, csText);
|
|
}
|
|
|
|
// zxl 2013.11.14 add
|
|
POSITION posItemLength = xmlTree.Insert(_T("Length"), posRoot, posItemVector);
|
|
{
|
|
xmlTree.SetAttribute(posItemLength, _T("name"), _T("长度"));
|
|
xmlTree.SetAttribute(posItemLength, _T("comment"), _T("长度"));
|
|
csText = DoubleToString(m_dScale, nPreci);
|
|
xmlTree.SetItemText(posItemLength, csText);
|
|
}
|
|
|
|
POSITION posItemWidth = xmlTree.Insert(_T("Width"), posRoot, posItemLength);
|
|
{
|
|
xmlTree.SetAttribute(posItemWidth, _T("name"), _T("宽度"));
|
|
xmlTree.SetAttribute(posItemWidth, _T("comment"), _T("宽度"));
|
|
csText = DoubleToString(m_dYScale, nPreci);
|
|
xmlTree.SetItemText(posItemWidth, csText);
|
|
}
|
|
|
|
POSITION posItemHeight = xmlTree.Insert(_T("Height"), posRoot, posItemWidth);
|
|
{
|
|
xmlTree.SetAttribute(posItemHeight, _T("name"), _T("高度"));
|
|
xmlTree.SetAttribute(posItemHeight, _T("comment"), _T("高度"));
|
|
csText = DoubleToString(m_dScale, nPreci);
|
|
xmlTree.SetItemText(posItemHeight, csText);
|
|
}
|
|
|
|
|
|
// POSITION posItemBlk = xmlTree.Insert(_T("Block"), posRoot, posItemVector);
|
|
POSITION posItemBlk = xmlTree.Insert(_T("Block"), posRoot, posItemHeight);
|
|
{
|
|
xmlTree.SetAttribute(posItemBlk, _T("name"), _T("对应图块"));
|
|
}
|
|
|
|
POSITION posItemBlk2d = xmlTree.Insert(_T("Block_2D"), posItemBlk, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posItemBlk2d, _T("name"), _T("2D块图块名"));
|
|
xmlTree.SetAttribute(posItemBlk2d, _T("comment"), _T("平面图块"));
|
|
CString csBlkName, csDesName;
|
|
GetBlkNameById(m_idBlock2d, csBlkName, csDesName);
|
|
xmlTree.SetItemText(posItemBlk2d, csBlkName);
|
|
}
|
|
|
|
POSITION posItemBlk3d = xmlTree.Insert(_T("Block_3D"), posItemBlk, posItemBlk2d);
|
|
{
|
|
xmlTree.SetAttribute(posItemBlk3d, _T("name"), _T("3D块图块名"));
|
|
xmlTree.SetAttribute(posItemBlk3d, _T("comment"), _T("三维图块"));
|
|
CString csBlkName, csDesName;
|
|
GetBlkNameById(m_idBlock3d, csBlkName, csDesName);
|
|
xmlTree.SetItemText(posItemBlk3d, csBlkName);
|
|
}
|
|
|
|
|
|
POSITION posItemScale = xmlTree.Insert(_T("Ratio"), posRoot, posItemBlk3d);
|
|
{
|
|
xmlTree.SetAttribute(posItemScale, _T("name"), _T("图块比例"));
|
|
xmlTree.SetAttribute(posItemScale, _T("comment"), _T("图块x,y,z方向比例"));
|
|
AcGeScale3d scale = GetInsertScale();
|
|
csX = DoubleToString(scale[X], nPreci);
|
|
csY = DoubleToString(scale[Y], nPreci);
|
|
csZ = DoubleToString(scale[Z], nPreci);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemScale, csText);
|
|
}
|
|
|
|
POSITION posItemDn = xmlTree.Insert(_T("Protect_Radius"), posRoot, posItemScale);
|
|
{
|
|
xmlTree.SetAttribute(posItemDn, _T("name"), _T("保护半径"));
|
|
xmlTree.SetAttribute(posItemDn, _T("comment"), _T("消火栓保护半径"));
|
|
|
|
ads_name ent;
|
|
acdbGetAdsName(ent, objectId());
|
|
double dRadius = _tstof(ReadXdata(ent, _T("HYDRANT_RADIUS")));
|
|
csText = DoubleToString(dRadius, nPreci);
|
|
xmlTree.SetItemText(posItemDn, csText);
|
|
}
|
|
|
|
POSITION posItemId = xmlTree.Insert(_T("Object_ID"), posRoot, posItemDn);
|
|
{
|
|
xmlTree.SetAttribute(posItemId, _T("name"), _T("ID"));
|
|
xmlTree.SetAttribute(posItemId, _T("comment"), _T("消火栓ID"));
|
|
csText.Format(_T("%ld"), objectId().asOldId());
|
|
xmlTree.SetItemText(posItemId, csText);
|
|
}
|
|
|
|
POSITION posItemMat= xmlTree.Insert(_T("Matrix3d"), posRoot, posItemId);
|
|
{
|
|
xmlTree.SetAttribute(posItemMat, _T("name"), _T("矩阵"));
|
|
xmlTree.SetAttribute(posItemMat, _T("comment"), _T("图块转换矩阵"));
|
|
xmlTree.SetItemText(posItemMat, sMat);
|
|
}
|
|
}
|
|
else if (IsSprinkler()) // 喷头
|
|
{
|
|
POSITION posRoot = xmlTree.Insert(_T("TCH_EQUIPMENTTWT"), NULL, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posRoot, _T("name"), _T("喷头"));
|
|
xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称"));
|
|
}
|
|
|
|
POSITION posItemType = xmlTree.Insert(_T("Style"),posRoot, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posItemType, _T("name"), _T("样式"));
|
|
xmlTree.SetAttribute(posItemType, _T("comment"), _T("喷头样式"));
|
|
|
|
XString xsTmp, xsTmp2, xsTmp3, xsTmp4, xsTmp5, xsTmp6, xsTmp7;
|
|
CString csBlkName, csDesName;
|
|
GetBlkNameById(m_idBlock2d, csBlkName, csDesName);
|
|
CString csDwb = csDesName + _T("$TwtSys$");
|
|
xsTmp = _T("$TwtSys$00000125");
|
|
xsTmp2 = _T("$TwtSys$00000128");
|
|
xsTmp3 = _T("$TwtSys$00000129");
|
|
xsTmp4 = _T("$TwtSys$00000131");
|
|
xsTmp5 = _T("$TwtSys$00000283");
|
|
xsTmp6 = _T("$TwtSys$00000126");
|
|
xsTmp7 = _T("$TwtSys$00000130");
|
|
|
|
if(_tcsicmp(csBlkName, xsTmp) == 0)
|
|
{
|
|
if(_tcsicmp(_T("TWTSYS(00000283)"), GetSysBlock()) == 0)
|
|
{
|
|
csText = _T("闭式");
|
|
}
|
|
else if(_tcsicmp(_T("TWTSYS(00000126)"), GetSysBlock()) == 0)
|
|
{
|
|
csText = _T("开式");
|
|
}
|
|
}
|
|
else if(_tcsicmp(csBlkName, xsTmp2) == 0 || _tcsicmp(csBlkName, xsTmp5) == 0)
|
|
{
|
|
csText = _T("闭式");
|
|
}
|
|
else if(_tcsicmp(csBlkName, xsTmp3) == 0 || _tcsicmp(csBlkName, xsTmp7) == 0)
|
|
{
|
|
csText = _T("侧墙"); //侧墙
|
|
}
|
|
else if(_tcsicmp(csBlkName, xsTmp4) == 0)
|
|
{
|
|
csText = _T("侧喷"); //侧喷
|
|
}
|
|
else if (_tcsicmp(csBlkName, xsTmp6) == 0)
|
|
{
|
|
csText = _T("开式");
|
|
}
|
|
|
|
xmlTree.SetItemText(posItemType, csText);
|
|
}
|
|
|
|
POSITION posItemCenterPt = xmlTree.Insert(_T("Center_point"), posRoot, posItemType);
|
|
{
|
|
xmlTree.SetAttribute(posItemCenterPt, _T("name"), _T("中心点"));
|
|
xmlTree.SetAttribute(posItemCenterPt, _T("comment"), _T("插入点位置"));
|
|
XPoint ptLoc = m_ptLocation;
|
|
ptLoc.TransformBy(mat);
|
|
csX = DoubleToString(ptLoc.x, nPreci);
|
|
csY = DoubleToString(ptLoc.y, nPreci);
|
|
csZ = DoubleToString(ptLoc.z, nPreci);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemCenterPt, csText);
|
|
}
|
|
|
|
POSITION posItemVector = xmlTree.Insert(_T("Vector"), posRoot, posItemCenterPt);
|
|
{
|
|
xmlTree.SetAttribute(posItemVector, _T("name"), _T("向量"));
|
|
xmlTree.SetAttribute(posItemVector, _T("comment"), _T("向量"));
|
|
XVector3D vtDir = m_vtDirection;
|
|
vtDir.TransformBy(mat);
|
|
csX = DoubleToString(vtDir.x, nPreci);
|
|
csY = DoubleToString(vtDir.y, nPreci);
|
|
csZ = DoubleToString(vtDir.z, nPreci);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemVector, csText);
|
|
}
|
|
|
|
POSITION posItemPipeLen = xmlTree.Insert(_T("Length"), posRoot, posItemVector);
|
|
{
|
|
xmlTree.SetAttribute(posItemPipeLen, _T("name"), _T("接管长度"));
|
|
xmlTree.SetAttribute(posItemPipeLen, _T("comment"), _T("喷头与管线连接所需长度"));
|
|
csText = DoubleToString(m_dPipeLength, nPreci);
|
|
xmlTree.SetItemText(posItemPipeLen, csText);
|
|
}
|
|
|
|
POSITION posItemBlk = xmlTree.Insert(_T("Block"), posRoot, posItemPipeLen);
|
|
{
|
|
xmlTree.SetAttribute(posItemBlk, _T("name"), _T("对应图块"));
|
|
}
|
|
|
|
POSITION posItemBlk2d = xmlTree.Insert(_T("Block_2D"), posItemBlk, NULL);
|
|
{
|
|
xmlTree.SetAttribute(posItemBlk2d, _T("name"), _T("2D块图块名"));
|
|
xmlTree.SetAttribute(posItemBlk2d, _T("comment"), _T("平面图块"));
|
|
CString csBlkName, csDesName;
|
|
GetBlkNameById(m_idBlock2d, csBlkName, csDesName);
|
|
xmlTree.SetItemText(posItemBlk2d, csBlkName);
|
|
}
|
|
|
|
POSITION posItemBlk3d = xmlTree.Insert(_T("Block_3D"), posItemBlk, posItemBlk2d);
|
|
{
|
|
xmlTree.SetAttribute(posItemBlk3d, _T("name"), _T("3D块图块名"));
|
|
xmlTree.SetAttribute(posItemBlk3d, _T("comment"), _T("三维图块"));
|
|
CString csBlkName, csDesName;
|
|
GetBlkNameById(m_idBlock3d, csBlkName, csDesName);
|
|
xmlTree.SetItemText(posItemBlk3d, csBlkName);
|
|
}
|
|
|
|
|
|
POSITION posItemScale = xmlTree.Insert(_T("Scale"), posRoot, posItemBlk3d);
|
|
{
|
|
xmlTree.SetAttribute(posItemScale, _T("name"), _T("图块比例"));
|
|
xmlTree.SetAttribute(posItemScale, _T("comment"), _T("图块x,y,z方向比例"));
|
|
AcGeScale3d scale = GetInsertScale();
|
|
csX = DoubleToString(scale[X], nPreci);
|
|
csY = DoubleToString(scale[Y], nPreci);
|
|
csZ = DoubleToString(scale[Z], nPreci);
|
|
csText.Format(_T("%s,%s,%s"), csX, csY, csZ);
|
|
xmlTree.SetItemText(posItemScale, csText);
|
|
}
|
|
|
|
POSITION posItemK = xmlTree.Insert(_T("Ratio"), posRoot, posItemScale);
|
|
{
|
|
xmlTree.SetAttribute(posItemK, _T("name"), _T("特性系数"));
|
|
xmlTree.SetAttribute(posItemK, _T("comment"), _T("喷淋计算特性系数K"));
|
|
|
|
ads_name ent;
|
|
acdbGetAdsName(ent, objectId());
|
|
int nK = _ttoi(ReadXdata(ent, _T("SPRINKLER_K")));
|
|
csText.Format(_T("%d"), nK);
|
|
xmlTree.SetItemText(posItemK, csText);
|
|
}
|
|
|
|
POSITION posItemDn = xmlTree.Insert(_T("Protect_Radius"), posRoot, posItemK);
|
|
{
|
|
xmlTree.SetAttribute(posItemDn, _T("name"), _T("保护半径"));
|
|
xmlTree.SetAttribute(posItemDn, _T("comment"), _T("喷头保护半径"));
|
|
|
|
ads_name ent;
|
|
acdbGetAdsName(ent, objectId());
|
|
double dRadius = _tstof(ReadXdata(ent, _T("HYDRANT_RADIUS")));
|
|
csText = DoubleToString(dRadius, nPreci);
|
|
xmlTree.SetItemText(posItemDn, csText);
|
|
}
|
|
|
|
POSITION posItemId = xmlTree.Insert(_T("Object_ID"), posRoot, posItemDn);
|
|
{
|
|
xmlTree.SetAttribute(posItemId, _T("name"), _T("ID"));
|
|
xmlTree.SetAttribute(posItemId, _T("comment"), _T("喷头ID"));
|
|
csText.Format(_T("%ld"), objectId().asOldId());
|
|
xmlTree.SetItemText(posItemId, csText);
|
|
}
|
|
|
|
POSITION posItemMat= xmlTree.Insert(_T("Matrix3d"), posRoot, posItemId);
|
|
{
|
|
xmlTree.SetAttribute(posItemMat, _T("name"), _T("矩阵"));
|
|
xmlTree.SetAttribute(posItemMat, _T("comment"), _T("图块转换矩阵"));
|
|
xmlTree.SetItemText(posItemMat, sMat);
|
|
}
|
|
}
|
|
|
|
CString csXml = xmlTree.GetXml();
|
|
int nIndex = -1;
|
|
nIndex = csXml.Find(_T("</TCH_EQUIPMENTTWT>"));
|
|
if (nIndex != -1)
|
|
{
|
|
CString sTemp = TDbPipeNode::GetXml(mat);
|
|
csXml.Insert(nIndex, sTemp);
|
|
}
|
|
return csXml;
|
|
}
|
|
|
|
void TDbEquipment::SetEquipmentType( int nType )
|
|
{
|
|
assertWriteEnabled();
|
|
TEntityFields &fd = Fields();
|
|
fd.SFD(_T("EquipmentType"), static_cast<Adesk::Int8>(nType));
|
|
}
|
|
|
|
void TDbEquipment::SetEquipmentType(EquipType nType)
|
|
{
|
|
SetEquipmentType(static_cast<int>(nType));
|
|
}
|
|
|
|
int TDbEquipment::GetEquipmentType() const
|
|
{
|
|
const TEntityFields &fd = GetFields();
|
|
Adesk::Int8 nType = -1;
|
|
fd.GFD(_T("EquipmentType"), nType);
|
|
return static_cast<int>(nType);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|