1039 lines
25 KiB
C++
1039 lines
25 KiB
C++
//------------------------------------------------------------------------+
|
||
// Copyright (C), 1998-2011, Beijing Tangent Software Co. Ltd.
|
||
// = FileName : TDbStruSlabHole类
|
||
// = Version : ver1.0
|
||
// = Author : cet
|
||
// = CreateDate : 2011-06-15
|
||
// = Description: 结构板洞类实现
|
||
// = Maintainers:
|
||
//
|
||
//------------------------------------------------------------------------+
|
||
|
||
#include "stdafx.h"
|
||
#ifdef TASD
|
||
#include "TDbStruSlabHole.h"
|
||
#include "TAsdKeyDefine.h"
|
||
#include "TDbStruFloorSlab.h"
|
||
#include "TBaseWallIntegrateTool.h"
|
||
#include "TConfigInfo.h"
|
||
|
||
extern bool g_bShowZX; // 是否显示折线
|
||
extern bool g_bHatch; // 是否填充
|
||
extern CString g_sHatchType; // 填充样式
|
||
|
||
ACRX_DXF_DEFINE_MEMBERS(TDbStruSlabHole, TDbStruHole, AcDb::kDHL_CURRENT,
|
||
AcDb::kMReleaseCurrent, 1, ATS_STRUSLABHOLE,
|
||
"ATS_STRUSLABHOLE图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
||
IMPLEMENT_TENTBASE(TDbStruSlabHole);
|
||
|
||
TDbStruSlabHole::TDbStruSlabHole()
|
||
{
|
||
|
||
}
|
||
|
||
TDbStruSlabHole::~TDbStruSlabHole()
|
||
{
|
||
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subGetOsnapPoints( AcDb::OsnapMode osnapMode, INT_PTR gsSelectionMark, const AcGePoint3d& pickPoint, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcGePoint3dArray& snapPoints, AcDbIntArray& geomIds ) const
|
||
{
|
||
assertReadEnabled();
|
||
TDbStruEntityBase::subGetOsnapPoints(osnapMode, gsSelectionMark, pickPoint, lastPoint, viewXform, snapPoints, geomIds);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subTransformBy( const AcGeMatrix3d& xform )
|
||
{
|
||
assertWriteEnabled();
|
||
AcGePoint3d ptLoc;
|
||
GetAt(KEY_POS, ptLoc);
|
||
ptLoc.transformBy(xform);
|
||
SetAt(KEY_POS, ptLoc);
|
||
m_polySection.TransformBy(xform);
|
||
AcGePoint3dArray ptArr;
|
||
GetAt(KEY_ZXPTS, ptArr);
|
||
for (int i = 0; i < ptArr.length(); i++)
|
||
{
|
||
ptArr[i].transformBy(xform);
|
||
}
|
||
SetAt(KEY_ZXPTS, ptArr);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subGetTransformedCopy( const AcGeMatrix3d& xform, AcDbEntity*& pEnt ) const
|
||
{
|
||
assertReadEnabled();
|
||
pEnt = new TDbStruSlabHole;
|
||
pEnt->copyFrom(this);
|
||
pEnt->transformBy(xform);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::copyFrom( const AcRxObject* pSrc )
|
||
{
|
||
assertWriteEnabled();
|
||
if (pSrc != NULL)
|
||
{
|
||
TDbStruEntityBase::copyFrom(pSrc);
|
||
|
||
TDbStruSlabHole* pHole = TDbStruSlabHole::cast(pSrc);
|
||
if (pHole != NULL)
|
||
{
|
||
//setDatabaseDefaults(pHole->database());
|
||
m_polySection.Reset();
|
||
m_polySection = pHole->GetOutlinePoly();
|
||
GetSpecialtyData()->Empty();
|
||
*GetSpecialtyData() = *pHole->GetSpecialtyData();
|
||
}
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subGetGripPoints( AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds ) const
|
||
{
|
||
assertReadEnabled();
|
||
AcGePoint3d ptLoc;
|
||
GetAt(KEY_POS, ptLoc);
|
||
gripPoints.append(ptLoc);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subGetStretchPoints( AcGePoint3dArray& stretchPoints ) const
|
||
{
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset )
|
||
{
|
||
assertWriteEnabled();
|
||
if (indices.length() == 1 && indices[0] == 0)
|
||
{
|
||
AcGeVector3d vtOffset = offset;
|
||
vtOffset.z = 0.0;
|
||
AcGeMatrix3d mat = AcGeMatrix3d::kIdentity;
|
||
mat.setToTranslation(vtOffset);
|
||
subTransformBy(mat);
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subMoveStretchPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset )
|
||
{
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subGetClassID( CLSID* pClsid ) const
|
||
{
|
||
#if (ADS >= 17)
|
||
assertReadEnabled();
|
||
#endif
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subWblockClone( AcRxObject* pOwner, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary ) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es = TDbStruEntityBase::subWblockClone(pOwner, pClonedObject, idMap, isPrimary);
|
||
if (es != Acad::eOk)
|
||
return es;
|
||
|
||
TDbStruSlabHole *pHole = TDbStruSlabHole::cast(pClonedObject);
|
||
if (pHole != NULL)
|
||
{
|
||
pHole->GetSpecialtyData()->Empty();
|
||
*pHole->GetSpecialtyData() = *GetSpecialtyDataReadOnly();
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::subDeepClone( AcDbObject* pOwner, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary ) const
|
||
{
|
||
assertReadEnabled();
|
||
return TDbStruEntityBase::subDeepClone(pOwner, pClonedObject, idMap, isPrimary);
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::GetGripText( int i, CString &cs ) const
|
||
{
|
||
assertReadEnabled();
|
||
if (i == 0)
|
||
{
|
||
cs = _T("移动");
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::ExplodeOrDraw3d( TGGiExplodeDrawBase &dc ) const
|
||
{
|
||
assertReadEnabled();
|
||
AcGeVector3d vtDir = AcGeVector3d::kZAxis;
|
||
GetAt(KEY_NORMAL, vtDir);
|
||
double dThick = 0.0;
|
||
GetAt(KEY_THICK, dThick);
|
||
AcGePoint3d ptPos = AcGePoint3d::kOrigin;
|
||
|
||
if (GetAt(KEY_POS, ptPos))
|
||
{
|
||
// 侧面儿
|
||
vtDir *= dThick * (-1);
|
||
TGGePoly2D plBot(m_polySection);
|
||
if (plBot.HasArcSegment())
|
||
plBot.Disperse(plBot);
|
||
dc.DrawMesh(plBot, vtDir);
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::ExplodeOrDraw2d( TGGiExplodeDrawBase &dc ) const
|
||
{
|
||
assertReadEnabled();
|
||
AcDbObjectId idLineType = AcDbObjectId::kNull, idOldLineType = AcDbObjectId::kNull;
|
||
GetAt(KEY_LTID, idLineType);
|
||
idOldLineType = dc.GetLineTypeId();
|
||
if (idLineType.isValid())
|
||
{
|
||
dc.SetLineType(idLineType);
|
||
}
|
||
|
||
// // 填充
|
||
if (DocGetSlabHoleShowZX())
|
||
{
|
||
DrawZX(dc);
|
||
}
|
||
|
||
TGGePoly2D plBot(m_polySection);
|
||
plBot.SetElevation(0);
|
||
dc << plBot;
|
||
|
||
// add by wjx on 120106 绘制板洞的折现部分(从左下到右上)
|
||
XPoint ptLow, ptUp;
|
||
int iType;
|
||
TGGePoly2D poly; // 折线部分
|
||
GetAt(KEY_SECTYP, iType);
|
||
if(iType == ST_CIRCLE) // 圆洞
|
||
{
|
||
XPoint ptLow, ptUp;
|
||
plBot.GetExtend(ptLow, ptUp);
|
||
TGGeCurveSegment seg(ptLow, ptUp, 0);
|
||
seg.SetElevation(0.0);
|
||
|
||
TGGeCurveSegment segTemp;
|
||
plBot.Nth(0, segTemp);
|
||
double dBugle = -2.5; // 折线弧度
|
||
|
||
int n = seg.Intersection(segTemp, ptLow, ptUp);
|
||
if(n > 0)
|
||
{
|
||
poly.AppendNode(ptLow, dBugle);
|
||
|
||
if(n == 2)
|
||
{
|
||
poly.AppendNode(ptUp);
|
||
}
|
||
else
|
||
{
|
||
plBot.Nth(1, segTemp);
|
||
n = seg.Intersection(segTemp, ptLow, ptUp);
|
||
if(n > 0)
|
||
{
|
||
poly.AppendNode(ptLow);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// else if(iType == ST_RECT)
|
||
// {
|
||
// plBot.GetExtend(ptLow, ptUp);
|
||
//
|
||
// double dWidth = ptUp.x-ptLow.x;
|
||
// double dHeight = ptUp.y - ptLow.y;
|
||
// XPoint ptMid(ptLow.x+dHeight*0.2, ptLow.y+dHeight*0.8, 0);
|
||
//
|
||
// poly.AppendNode(ptLow);
|
||
// poly.AppendNode(ptMid);
|
||
// poly.AppendNode(ptUp);
|
||
//
|
||
// ads_matrix mat;
|
||
// double dRot;
|
||
// GetAt(KEY_ANG, dRot);
|
||
// AcGePoint3d ptLoc;
|
||
// GetAt(KEY_POS, ptLoc);
|
||
// XPoint(ptLoc).GetRotationMatrix(dRot, mat);
|
||
// poly.TransformBy(AsAcGeMatrix3d(mat));
|
||
// }
|
||
else
|
||
{
|
||
// 找到左下角点和右上角点
|
||
GetLRPoint(plBot, ptLow, ptUp);
|
||
int nFlag;
|
||
GetAt(KEY_STAIR, nFlag);
|
||
if(nFlag == 1) // 楼梯间洞
|
||
{
|
||
poly.AppendNode(ptLow);
|
||
poly.AppendNode(ptUp);
|
||
}
|
||
else
|
||
{
|
||
double dWidth = ptUp.x-ptLow.x;
|
||
double dHeight = ptUp.y - ptLow.y;
|
||
|
||
if(iType == ST_RECT)
|
||
{
|
||
GetAt(KEY_B, dWidth);
|
||
GetAt(KEY_H, dHeight);
|
||
}
|
||
|
||
XPoint ptMid;
|
||
plBot.Center(ptMid);
|
||
|
||
ptMid.x -= dWidth*0.2;
|
||
ptMid.y += dHeight*0.2;
|
||
|
||
poly.AppendNode(ptLow);
|
||
poly.AppendNode(ptMid);
|
||
poly.AppendNode(ptUp);
|
||
}
|
||
}
|
||
dc << poly;
|
||
|
||
dc.SetLineType(idOldLineType);
|
||
|
||
// 板洞尺寸
|
||
if (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0)
|
||
{
|
||
AcGiCommonDraw *dcCommon = ((XAcGiViewDraw &)dc).GetCommonDraw();
|
||
if (!dcCommon->context()->isPlotGeneration())
|
||
{
|
||
if(DocGetShowBH() && DocGetSlabHoleShowBH())
|
||
{
|
||
DrawBH(dc);
|
||
}
|
||
}
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// add by wjxon 120106
|
||
// 找到板洞左下角点和右上角的点
|
||
void TDbStruSlabHole::GetLRPoint(TGGePoly2D poly, XPoint &ptL, XPoint &ptR)const
|
||
{
|
||
int nCount = poly.Length();
|
||
if(nCount < 0)
|
||
{
|
||
return;
|
||
}
|
||
|
||
ptL = ptR = poly.GetPointListAt(0)->AsAcGeVector3d();
|
||
|
||
XPoint ptTemp;
|
||
for(int i = 1; i < nCount; i++)
|
||
{
|
||
ptTemp = poly.GetPointListAt(i)->AsAcGeVector3d();
|
||
|
||
if(ptL.x - ptTemp.x > _DIST_SNAP)
|
||
{
|
||
ptL = ptTemp;
|
||
}
|
||
else if(fabs(ptL.x - ptTemp.x) < _DIST_SNAP)
|
||
{
|
||
if(ptL.y - ptTemp.y > _DIST_SNAP)
|
||
{
|
||
ptL = ptTemp;
|
||
}
|
||
}
|
||
}
|
||
|
||
for(int i = 1; i < nCount; i++)
|
||
{
|
||
ptTemp = poly.GetPointListAt(i)->AsAcGeVector3d();
|
||
|
||
if(ptTemp.x - ptR.x > _DIST_SNAP)
|
||
{
|
||
ptR = ptTemp;
|
||
}
|
||
else if(fabs(ptR.x - ptTemp.x) < _DIST_SNAP)
|
||
{
|
||
if(ptTemp.y - ptR.y > _DIST_SNAP)
|
||
{
|
||
ptR = ptTemp;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::GetExtents2d( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const
|
||
{
|
||
assertReadEnabled();
|
||
m_polySection.GetExtend(ptLow, ptUp);
|
||
ptLow.z = 0.0;
|
||
ptUp.z = 0.0;
|
||
return Acad::eOk;
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::GetExtents( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const
|
||
{
|
||
assertReadEnabled();
|
||
m_polySection.GetExtend(ptLow, ptUp);
|
||
|
||
AcGePoint3d ptPos;
|
||
GetAt(KEY_POS, ptPos);
|
||
|
||
double dThick = 0.0;
|
||
GetAt(KEY_THICK, dThick);
|
||
ptUp.z = ptPos.z;
|
||
ptLow.z = ptPos.z-dThick;
|
||
return Acad::eOk;
|
||
}
|
||
|
||
bool TDbStruSlabHole::UnifyElevation( double dElevation )
|
||
{
|
||
return true;
|
||
}
|
||
|
||
void TDbStruSlabHole::GetTips( TDPtrList<TObjInfoUnit> & ) const
|
||
{
|
||
|
||
}
|
||
|
||
const TCHAR * TDbStruSlabHole::GetDefaultLayer() const
|
||
{
|
||
return LAY_S_OPNG_PLAN_LINE;
|
||
}
|
||
|
||
BOOL TDbStruSlabHole::IsValid() const
|
||
{
|
||
assertReadEnabled();
|
||
double dThick = 0.0;
|
||
GetAt(KEY_THICK, dThick);
|
||
if (!m_polySection.IsClosed() || m_polySection.Length() == 0 || dThick < _DIST_SNAP)
|
||
{
|
||
return FALSE;
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
void TDbStruSlabHole::CopyPropertiesFrom( AcDbEntity *pSrcEntity, unsigned gMatchFlag )
|
||
{
|
||
assertWriteEnabled();
|
||
TDbStruEntityBase::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
||
TDbStruSlabHole *pHole = TDbStruSlabHole::cast(pSrcEntity);
|
||
if (pHole != NULL)
|
||
{
|
||
CopyData(pHole);
|
||
}
|
||
}
|
||
|
||
bool TDbStruSlabHole::GetStandardFaceBody( AcDbVoidPtrArray& arFacePtrs ) const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
bool TDbStruSlabHole::GetSafeProtectedSpace( AcDbVoidPtrArray& arFacePtrs ) const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
bool TDbStruSlabHole::GetSection( const AcDbFace &face, const AcGeVector3d& vtPlaneSecDir, std::vector<TObjSectionRecord> §ionRecords, AcDbVoidPtrArray& arFillPtrs ) const
|
||
{
|
||
return false;
|
||
}
|
||
|
||
CString TDbStruSlabHole::GetXml(const AcGeMatrix3d& mat) const
|
||
{
|
||
TXmlTree xmlTree;
|
||
POSITION posRoot = xmlTree.Insert(_T("ATS_STRUSLABHOLE"), NULL, NULL);
|
||
{
|
||
xmlTree.SetAttribute(posRoot, _T("name"), _T("板洞"));
|
||
xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称"));
|
||
}
|
||
|
||
CString strText;
|
||
POSITION posItem1 = xmlTree.Insert(_T("Object_ID"), posRoot, NULL);
|
||
{
|
||
xmlTree.SetAttribute(posItem1, _T("name"), _T("对象编号"));
|
||
xmlTree.SetAttribute(posItem1, _T("comment"), _T("当前对象的句柄"));
|
||
strText.Format(_T("%ld"), objectId());
|
||
xmlTree.SetItemText(posItem1, strText);
|
||
}
|
||
|
||
POSITION posItem = NULL;
|
||
POSITION posItem2 = xmlTree.Insert(_T("Link_Slab"), posRoot, posItem1);
|
||
{
|
||
xmlTree.SetAttribute(posItem2, _T("name"), _T("连接楼板"));
|
||
|
||
posItem = xmlTree.Insert(_T("Link_ID"), posItem2, NULL);
|
||
{
|
||
AcDbObjectId idSlab;
|
||
GetAt(KEY_ASSOC, idSlab);
|
||
xmlTree.SetAttribute(posItem, _T("name"), _T("楼板句柄"));
|
||
strText.Format(_T("%ld"), idSlab);
|
||
xmlTree.SetItemText(posItem, strText);
|
||
}
|
||
}
|
||
|
||
POSITION posItem3 = xmlTree.Insert(_T("Position"), posRoot, posItem2);
|
||
{
|
||
xmlTree.SetAttribute(posItem3, _T("name"), _T("位置"));
|
||
xmlTree.SetAttribute(posItem3, _T("comment"), _T("洞口位置"));
|
||
AcGePoint3d ptPos;
|
||
GetAt(KEY_POS, ptPos);
|
||
|
||
TADSGePoint3d ptTransformBy = ptPos;
|
||
ptTransformBy.TransformBy(mat);
|
||
strText.Format(_T("%f,%f,%f"), ptTransformBy.x, ptTransformBy.y, ptTransformBy.z);
|
||
xmlTree.SetItemText(posItem3, strText);
|
||
}
|
||
|
||
POSITION posItem4 = xmlTree.Insert(_T("Thick"), posRoot, posItem3);
|
||
{
|
||
xmlTree.SetAttribute(posItem4, _T("name"), _T("洞厚"));
|
||
xmlTree.SetAttribute(posItem4, _T("comment"), _T("洞口厚度随板"));
|
||
double dThick=0;
|
||
GetAt(KEY_THICK, dThick);
|
||
strText.Format(_T("%f"), dThick);
|
||
xmlTree.SetItemText(posItem4, strText);
|
||
}
|
||
POSITION posItem5 = xmlTree.Insert(_T("Normal"), posRoot, posItem4);
|
||
{
|
||
xmlTree.SetAttribute(posItem5, _T("name"), _T("洞口法向"));
|
||
xmlTree.SetAttribute(posItem5, _T("comment"), _T("洞口法向"));
|
||
AcGeVector3d vtNorm;
|
||
GetAt(KEY_NORMAL, vtNorm);
|
||
|
||
TADSGePoint3d ptTransformBy = vtNorm;
|
||
ptTransformBy.TransformBy(mat);
|
||
strText.Format(_T("%f,%f,%f"), ptTransformBy.x, ptTransformBy.y, ptTransformBy.z);
|
||
xmlTree.SetItemText(posItem5, strText);
|
||
}
|
||
POSITION posItem7 = xmlTree.Insert(_T("Baseline"), posRoot, posItem5);
|
||
{
|
||
xmlTree.SetAttribute(posItem7, _T("name"), _T("基线参数"));
|
||
xmlTree.SetAttribute(posItem7, _T("comment"), _T("用于用于洞口形状"));
|
||
|
||
posItem = NULL;
|
||
CString strTab,strKeyVal;
|
||
TADSGePoint3d pt;
|
||
for (int i = 0; i < m_polySection.Length(); i++)
|
||
{
|
||
pt = m_polySection[i];
|
||
pt.TransformBy(mat);
|
||
|
||
strTab.Format(_T("Point_%d"), i + 1);
|
||
posItem = xmlTree.Insert(strTab, posItem7, posItem);
|
||
{
|
||
strKeyVal.Format(_T("第%d点"), i + 1);
|
||
xmlTree.SetAttribute(posItem, _T("name"), strKeyVal);
|
||
strText.Format(_T("%f,%f,%f"), pt.x, pt.y, pt.z);
|
||
xmlTree.SetItemText(posItem, strText);
|
||
}
|
||
|
||
strTab.Format(_T("Ang_%d"), i + 1);
|
||
posItem = xmlTree.Insert(strTab, posItem7, posItem);
|
||
{
|
||
strKeyVal.Format(_T("圆心角%d"), i + 1);
|
||
xmlTree.SetAttribute(posItem, _T("name"), strKeyVal);
|
||
strText.Format(_T("%f"), m_polySection.GetBulge(i));
|
||
xmlTree.SetItemText(posItem, strText);
|
||
}
|
||
}
|
||
}
|
||
|
||
CString strBase = TEntityBase::GetXml(mat);
|
||
CString strXml = xmlTree.GetXml();
|
||
int nIndex = strXml.Find(_T("<Object_ID"));
|
||
strXml.Insert(nIndex, strBase);
|
||
|
||
return strXml;
|
||
}
|
||
|
||
void TDbStruSlabHole::PostAssocMsg( TAssocMsg assocMsg ) const
|
||
{
|
||
|
||
}
|
||
|
||
void TDbStruSlabHole::ReceiveAssocMsg( TAssocMsg assocMsg )
|
||
{
|
||
|
||
}
|
||
|
||
void TDbStruSlabHole::MakeAssocRelation( AcDbObject& ids )
|
||
{
|
||
assertWriteEnabled();
|
||
AcDbObjectId idAssoc = ids.objectId();
|
||
SetAt(KEY_ASSOC, idAssoc);
|
||
}
|
||
|
||
void TDbStruSlabHole::MakeAssocRelation(AcDbObjectIdArray& ids )
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
if (ids.length() < 1)
|
||
{
|
||
return;
|
||
}
|
||
|
||
TPickEntSet ss(SS_FREE);
|
||
ads_name eName;
|
||
for (int i = 0; i < ids.length(); i++)
|
||
{
|
||
if (acdbGetAdsName(eName, ids[i]) == Acad::eOk)
|
||
{
|
||
ss += ids[i];
|
||
}
|
||
}
|
||
|
||
TGGePoly2D poly; //板洞平面线
|
||
GetOutline(poly);
|
||
poly.SetElevation(0);
|
||
|
||
double dGap(0);
|
||
TEntitySet ent;
|
||
for (long j = 0; j < ss.Length(); j++)
|
||
{
|
||
ent = ss[j];
|
||
if (ent.Is(_T("ATS_STRU_FLOORSLAB")))//板
|
||
{
|
||
OPENOBJ_BEGIN(ent, AcDb::kForRead, TDbStruFloorSlab, pEnt);
|
||
if (!pEnt)
|
||
{
|
||
continue;
|
||
}
|
||
|
||
TGGePoly2D polyDest; //板平面线
|
||
pEnt->GetOutline(polyDest);
|
||
polyDest.SetElevation(0);
|
||
|
||
bool bRet = TBaseWallIntegrateTool::GetMinGap(poly, polyDest, dGap);
|
||
if(bRet && dGap < _DIST_SNAP)
|
||
{
|
||
SetAt(KEY_ASSOC, pEnt->objectId());
|
||
}
|
||
else
|
||
{
|
||
continue;
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
}
|
||
|
||
void TDbStruSlabHole::RemoveAssocRelation( AcDbObjectId& id )
|
||
{
|
||
assertWriteEnabled();
|
||
AcDbObjectId idAssoc;
|
||
GetAt(KEY_ASSOC, idAssoc);
|
||
if (id == idAssoc)
|
||
{
|
||
SetAt(KEY_ASSOC, AcDbObjectId::kNull);
|
||
}
|
||
}
|
||
|
||
void TDbStruSlabHole::GetAssocRelation( AcDbObjectId& idAssoc ) const
|
||
{
|
||
assertReadEnabled();
|
||
GetAt(KEY_ASSOC, idAssoc);
|
||
}
|
||
|
||
// 获取关联关系,nType:关联类型;ar:关联对象句柄数组
|
||
void TDbStruSlabHole::GetAssocRelation(int nType, AcDbObjectIdArray& ar)const
|
||
{
|
||
assertReadEnabled();
|
||
ar.setLogicalLength(0);
|
||
|
||
switch (nType)
|
||
{
|
||
case ASSOC_SLAB:
|
||
case ASSOC_ALL:
|
||
{
|
||
AcDbObjectId idAssoc;
|
||
GetAt(KEY_ASSOC, idAssoc);
|
||
ar.append(idAssoc);
|
||
}
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
TADSGePoint3d TDbStruSlabHole::GetParameters() const
|
||
{
|
||
assertReadEnabled();
|
||
TADSGePoint3d ptLow, ptUp;
|
||
GetExtents2d(ptLow, ptUp);
|
||
TADSGePoint3d pt;
|
||
pt.x = fabs(ptLow.x - ptUp.x);
|
||
pt.y = fabs(ptLow.y - ptUp.y);
|
||
pt.z = 0.0;
|
||
return pt;
|
||
}
|
||
|
||
void TDbStruSlabHole::GetOutline( TGGePoly2D &poly ) const
|
||
{
|
||
assertReadEnabled();
|
||
poly = m_polySection;
|
||
}
|
||
|
||
const TGGePoly2D& TDbStruSlabHole::GetOutlinePoly() const
|
||
{
|
||
return m_polySection;
|
||
}
|
||
|
||
void TDbStruSlabHole::SetOutlinePoly( const TGGePoly2D &poly )
|
||
{
|
||
m_polySection = poly;
|
||
if (m_polySection.PathArea() > 0) // 顺时针时调整为逆时针
|
||
{
|
||
m_polySection.Reverse();
|
||
}
|
||
}
|
||
|
||
double TDbStruSlabHole::GetBottomElev() const
|
||
{
|
||
assertReadEnabled();
|
||
AcGePoint3d ptLoc;
|
||
GetAt(KEY_POS, ptLoc);
|
||
return ptLoc.z;
|
||
}
|
||
|
||
void TDbStruSlabHole::SetBottomElev( double dElev )
|
||
{
|
||
assertWriteEnabled();
|
||
AcGePoint3d ptLoc;
|
||
GetAt(KEY_POS, ptLoc);
|
||
ptLoc.z = dElev;
|
||
SetAt(KEY_POS, ptLoc);
|
||
}
|
||
|
||
void TDbStruSlabHole::CopyData(TDbStruSlabHole *pHole)
|
||
{
|
||
if (pHole == NULL)
|
||
{
|
||
return;
|
||
}
|
||
|
||
AcGeVector3d vtNorm;
|
||
GetAt(KEY_NORMAL, vtNorm);
|
||
double dThick = 0.0;
|
||
GetAt(KEY_THICK, dThick);
|
||
AcDbObjectId idAssoc;
|
||
GetAt(KEY_ASSOC, idAssoc);
|
||
AcGePoint3dArray ptArr;
|
||
GetAt(KEY_ZXPTS, ptArr);
|
||
AcGePoint3d ptLoc;
|
||
GetAt(KEY_POS, ptLoc);
|
||
int nType = -1;
|
||
GetAt(KEY_SECTYP, nType);
|
||
double dWidth = 0.0, dHeight = 0.0;
|
||
GetAt(KEY_SUMB, dWidth);
|
||
GetAt(KEY_SUMH, dHeight);
|
||
switch(nType)
|
||
{
|
||
case ST_RECT:
|
||
{
|
||
double dB = 0.0, dH = 0.0;
|
||
GetAt(KEY_B, dB);
|
||
GetAt(KEY_H, dH);
|
||
GetSpecialtyData()->Empty();
|
||
*GetSpecialtyData() = *pHole->GetSpecialtyData();
|
||
SetAt(KEY_B, dB);
|
||
SetAt(KEY_H, dH);
|
||
break;
|
||
}
|
||
case ST_CIRCLE:
|
||
{
|
||
double dB = 0.0;
|
||
GetAt(KEY_B, dB);
|
||
GetSpecialtyData()->Empty();
|
||
*GetSpecialtyData() = *pHole->GetSpecialtyData();
|
||
SetAt(KEY_B, dB);
|
||
break;
|
||
}
|
||
}
|
||
|
||
SetAt(KEY_NORMAL, vtNorm);
|
||
SetAt(KEY_THICK, dThick);
|
||
SetAt(KEY_ASSOC, idAssoc);
|
||
SetAt(KEY_ZXPTS, ptArr);
|
||
SetAt(KEY_POS, ptLoc);
|
||
SetAt(KEY_SECTYP, nType);
|
||
SetAt(KEY_SUMB, dWidth);
|
||
SetAt(KEY_SUMH, dHeight);
|
||
}
|
||
|
||
Acad::ErrorStatus TDbStruSlabHole::DrawZX(TGGiExplodeDrawBase &dc) const
|
||
{
|
||
int nShape = -1;
|
||
GetAt(KEY_SSHAPE, nShape);
|
||
TGGePoly2D poly, polyHatch;
|
||
switch(nShape)
|
||
{
|
||
case ST_RECT:
|
||
{
|
||
double dWidth = 0.0, dHeight = 0.0;
|
||
GetAt(KEY_B, dWidth);
|
||
GetAt(KEY_H, dHeight);
|
||
AcGePoint3d ptLoc;
|
||
GetAt(KEY_POS, ptLoc);
|
||
ptLoc.z = 0.0;
|
||
double dAngle = 0.0;
|
||
GetAt(KEY_AXANG, dAngle);
|
||
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
||
vtX.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
||
AcGeVector3d vtY = vtX;
|
||
vtY.rotateBy(PI / 2, AcGeVector3d::kZAxis);
|
||
TADSGePoint3d ptTemp;
|
||
ptTemp = ptLoc - vtX * dWidth * 0.5 - vtY * dHeight * 0.5;
|
||
poly.AppendNode(ptTemp);
|
||
ptTemp = ptLoc - vtX * dWidth * 0.25 + vtY * dHeight * 0.25;
|
||
poly.AppendNode(ptTemp);
|
||
ptTemp = ptLoc + vtX * dWidth * 0.5 + vtY * dHeight * 0.5;
|
||
poly.AppendNode(ptTemp);
|
||
|
||
if (DocGetIsSolidFill())
|
||
{
|
||
ptTemp = ptLoc + vtX * dWidth * 0.5 + vtY * dHeight * 0.5;
|
||
polyHatch.AppendNode(ptTemp);
|
||
ptTemp = ptLoc - vtX * dWidth * 0.5 + vtY * dHeight * 0.5;
|
||
polyHatch.AppendNode(ptTemp);
|
||
ptTemp = ptLoc - vtX * dWidth * 0.5 - vtY * dHeight * 0.5;
|
||
polyHatch.AppendNode(ptTemp);
|
||
ptTemp = ptLoc - vtX * dWidth * 0.25 + vtY * dHeight * 0.25;
|
||
polyHatch.AppendNode(ptTemp);
|
||
polyHatch.SetClosed();
|
||
}
|
||
break;
|
||
}
|
||
case ST_CIRCLE:
|
||
{
|
||
double dDiameter = 0.0;
|
||
GetAt(KEY_B, dDiameter);;
|
||
AcGePoint3d ptLoc;
|
||
GetAt(KEY_POS, ptLoc);
|
||
ptLoc.z = 0.0;
|
||
double dAngle = 0.0;
|
||
GetAt(KEY_AXANG, dAngle);
|
||
AcGeVector3d vtX = AcGeVector3d::kXAxis;
|
||
vtX.rotateBy(dAngle, AcGeVector3d::kZAxis);
|
||
AcGeVector3d vtY = vtX;
|
||
vtY.rotateBy(PI / 2, AcGeVector3d::kZAxis);
|
||
TADSGePoint3d pt1, pt2, pt3;
|
||
pt1 = ptLoc - vtX * dDiameter * 0.5;
|
||
pt2 = ptLoc - vtX * dDiameter * 0.25 + vtY * dDiameter * 0.25;
|
||
pt3 = ptLoc + vtX * dDiameter * 0.5;
|
||
TGGeArc arc(pt1, pt2, pt3);
|
||
arc.GetStartPoint(pt1);
|
||
arc.GetEndPoint(pt2);
|
||
poly.AppendNode(pt1, arc.Bulge());
|
||
poly.AppendNode(pt2);
|
||
if (DocGetIsSolidFill())
|
||
{
|
||
pt1 = ptLoc + vtX * dDiameter * 0.5;
|
||
polyHatch.AppendNode(pt1, PI);
|
||
pt1 = ptLoc - vtX * dDiameter * 0.5;
|
||
polyHatch.AppendNode(pt1, arc.Bulge() * (-1));
|
||
pt1 = ptLoc + vtX * dDiameter * 0.5;
|
||
polyHatch.AppendNode(pt1);
|
||
polyHatch.SetClosed();
|
||
TGGePoly2D polyDest;
|
||
polyHatch.Disperse(polyDest);
|
||
polyHatch.Reset();
|
||
polyHatch = polyDest;
|
||
}
|
||
break;
|
||
}
|
||
case ST_POLY:
|
||
{
|
||
break;
|
||
}
|
||
default:
|
||
{
|
||
return Acad::eOk;
|
||
}
|
||
}
|
||
|
||
// 填充
|
||
if (DocGetIsSolidFill() && DocGetSlabHoleHatch())
|
||
{
|
||
CString sHatchType = DocGetSlabHoleHPatte();
|
||
if (_tcsicmp(sHatchType, _T("SOLID")) == 0)
|
||
{
|
||
dc << TGGeSolid(polyHatch);
|
||
}
|
||
else
|
||
{
|
||
dc << TGGeHatch(polyHatch, sHatchType, GetPScale());
|
||
}
|
||
}
|
||
|
||
// 绘线
|
||
dc << poly;
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// 显示板洞尺寸
|
||
void TDbStruSlabHole::DrawBH(TGGiExplodeDrawBase &dc) const
|
||
{
|
||
TDbText text;
|
||
|
||
// 得到文字样式ID
|
||
AcDbObjectId idSlabHoleStyl = DocGetSlabHoleBHStyle();
|
||
if(idSlabHoleStyl.isNull())
|
||
{
|
||
idSlabHoleStyl = InitTextStyle(TS_STANDARD);
|
||
}
|
||
text.SetStyleId(idSlabHoleStyl); // 设置文字样式
|
||
|
||
text.SetHeight(DocGetSlabHoleBHHigh()); // 设置文字高度
|
||
|
||
text.setColorIndex(DocGetSlabHoleBHColor());// 设置文字颜色
|
||
|
||
text.SetAlignment(XExplodeDraw::kTopCenter);// 设置文字对齐方式
|
||
|
||
// TADSGePoint3d ptLow, ptUp;
|
||
// GetExtents2d(ptLow, ptUp); // 获得轮廓的最高点和最底点
|
||
|
||
// 求外围轮廓的宽和高
|
||
double dHeight(0), dWidth(0);
|
||
// dHeight = fabs(ptUp.y - ptLow.y); // 得到板洞的高度
|
||
// dWidth = fabs(ptUp.x - ptLow.x); // 得到板洞的宽度
|
||
|
||
|
||
CString strHeight, strWidth;
|
||
|
||
// modify by wjx on 120105 修改尺寸文字位置和内容
|
||
CString strText;
|
||
//strText.Format(_T("%s×%s"), strWidth, strHeight);
|
||
//text.SetText(strText); // 设置文字显示内容
|
||
|
||
TGGePoly2D poly = GetOutlinePoly(); // 得到楼板的轮廓线
|
||
XPoint ptInsert;
|
||
double dDis = 0.0;
|
||
|
||
int nShape;
|
||
GetAt(KEY_SECTYP, nShape); // 得到板洞类型
|
||
|
||
if(nShape == ST_CIRCLE) // 圆形板洞
|
||
{
|
||
GetAt(KEY_B, dWidth);
|
||
strWidth = Dist2Str(dWidth);
|
||
|
||
//dHoleWidth = dHeight;
|
||
//ptInsert.y -= (dHoleWidth/2 + DocGetSlabHoleBHDist() * GetPScale());
|
||
strText.Format(_T("洞Φ%s"), strWidth);
|
||
AcGePoint3d ptIns;
|
||
GetAt(KEY_POS, ptIns); // 得到板洞的插入位置
|
||
ptInsert = XPoint(ptIns);
|
||
}
|
||
else // 矩形板洞和任意形板洞
|
||
{
|
||
//TGGePoly2D poly = GetOutlinePoly(); // 得到楼板的轮廓线
|
||
//XCurveSegment seg;
|
||
//poly.Nth(0, seg);
|
||
|
||
//XPoint ptStart = seg.GetStartPoint();
|
||
//XPoint ptEnd = seg.GetEndPoint();
|
||
|
||
//double angle = ads_angle(ptStart, ptEnd);// 得到柱子的旋转角度
|
||
|
||
//if(angle - PI > g_angleZero) // 180-360度时的处理
|
||
//{
|
||
// angle -= PI;
|
||
//}
|
||
|
||
//if(angle - PI/2 <= g_angleZero) // 0-90度时得到文字需要移动的距离
|
||
//{
|
||
// dHoleWidth = dHeight;
|
||
//}
|
||
//else // 90-180
|
||
//{
|
||
// dHoleWidth = dWidth;
|
||
//}
|
||
|
||
//// 将文字的旋转角度设置成0-90度之间的角度
|
||
//while(angle - PI/2 > g_angleZero)
|
||
//{
|
||
// angle -= (PI/2);
|
||
//}
|
||
|
||
//text.SetRotation(angle); // 设置文字的旋转角度
|
||
|
||
//dDis = dHoleWidth/2 + DocGetSlabHoleBHDist() * GetPScale();
|
||
//ptInsert = XPoint(ptInsert, angle+PI/2, -dDis);// 得到插入点(在垂直方向移动dDis距离后的点)
|
||
if (nShape == ST_RECT)
|
||
{
|
||
GetAt(KEY_B, dWidth);
|
||
GetAt(KEY_H, dHeight);
|
||
}
|
||
else
|
||
{
|
||
TADSGePoint3d ptLow, ptUp;
|
||
GetExtents2d(ptLow, ptUp); // 获得轮廓的最高点和最底点
|
||
|
||
// 求外围轮廓的宽和高
|
||
dHeight = fabs(ptUp.y - ptLow.y); // 得到板洞的高度
|
||
dWidth = fabs(ptUp.x - ptLow.x); // 得到板洞的宽度
|
||
}
|
||
strWidth = Dist2Str(dWidth);
|
||
strHeight = Dist2Str(dHeight);
|
||
|
||
poly.Center(ptInsert);
|
||
strText.Format(_T("洞%s×%s"), strWidth, strHeight);
|
||
}
|
||
text.SetText(strText); // 设置文字显示内容
|
||
text.SetAlignment(XExplodeDraw::kCenter);// 设置文字对齐方式
|
||
|
||
// 设置斜线部分的起始点和终止点
|
||
int nColor = dc.GetColor();
|
||
int nLineColor = 3;
|
||
dc.SetColor(nLineColor);
|
||
|
||
double dLineLen = 200;
|
||
TADSGePoint3d ptEnd(ptInsert.x + dWidth/2 + dLineLen, ptInsert.y + dHeight/2 + dLineLen, ptInsert.z);
|
||
TADSGePoint3d ptStart(ptInsert);
|
||
|
||
TGGeCurveSegment seg(ptStart, ptEnd, 0);
|
||
|
||
TGGeLine line(seg);
|
||
dc.DrawLine(line);
|
||
|
||
double dTextWidth = dLineLen, dTextHeight = 0;
|
||
text.GetExtents(&dTextWidth, &dTextHeight); // 得到文字的宽和高
|
||
|
||
ptInsert = AcGePoint3d(ptEnd.x + dTextWidth/2, ptEnd.y, 0); // 计算文字的插入点
|
||
text.SetLocation(ptInsert); // 设置文字的插入位置
|
||
|
||
ptStart = TADSGePoint3d(ptEnd);
|
||
ptEnd.x += dTextWidth * 1.2; // *1.2是因为文字下方的线要比文字的宽度长一些
|
||
|
||
seg = TGGeCurveSegment(ptStart, ptEnd, 0);
|
||
|
||
line = TGGeLine(seg);
|
||
dc.DrawLine(line);
|
||
|
||
dc.SetColor(nColor);
|
||
|
||
text.ExplodeOrDraw2d(dc);
|
||
}
|
||
int TDbStruSlabHole::GetFirstVersion()const
|
||
{
|
||
return 10;
|
||
}
|
||
bool TDbStruSlabHole::IsModelEntity() const
|
||
{
|
||
return true;
|
||
}
|
||
void InitStruSlabHole(bool bTrue)
|
||
{
|
||
if (bTrue)
|
||
{
|
||
TDbStruSlabHole::rxInit();
|
||
acrxBuildClassHierarchy();
|
||
TDbStruSlabHole::InitMatchProtocol(TRUE);
|
||
}
|
||
else
|
||
{
|
||
TDbStruSlabHole::InitMatchProtocol(FALSE);
|
||
deleteAcRxClass(TDbStruSlabHole::desc());
|
||
}
|
||
}
|
||
#endif |