2152 lines
57 KiB
C++
2152 lines
57 KiB
C++
#include "stdafx.h"
|
||
#include "TDbColumn.h"
|
||
#include "TDbWallPatch.h"
|
||
|
||
#include "imgdef.h" // AcDbRasterImageDef and reactors,
|
||
#include "imgent.h"
|
||
|
||
/////////////////////////////////////////////////////////////
|
||
// 阳台对象类
|
||
/////////////////////////////////////////////////////////////
|
||
extern BOOL g_bBalconyClipInsu;
|
||
// ver:1-TArch5;2-TArch6; 3-TArch7,4-TArch8
|
||
const Adesk::UInt8 TDbBalcony::g_nVersion = 4;
|
||
|
||
ACRX_DXF_DEFINE_MEMBERS(ATSBalcony, ATSPolyPathEnt, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
||
1, ATS_BALCONY, "ATS_BALCONY图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com");
|
||
|
||
IMPLEMENT_TENTBASE(TDbBalcony);
|
||
|
||
TDbBalcony::TDbBalcony()
|
||
:m_polyOutline(1), m_nRailEdge(0)
|
||
{
|
||
m_nRailWidth=m_nRailHeight=0;
|
||
m_nSlabThickness = m_nGirderThickness = 0;
|
||
|
||
m_nFlag=0;
|
||
m_uFrame=_AS_SYS_UNIT(40);
|
||
m_vFrame=_AS_SYS_UNIT(40);
|
||
m_nWinHeight=_AS_SYS_UNIT(1500);
|
||
|
||
//add by xlc on 110218 阳台遮挡保温
|
||
if (g_bBalconyClipInsu)
|
||
{
|
||
SetBalconyClipInsu(TRUE);
|
||
}
|
||
|
||
}
|
||
|
||
|
||
TDbBalcony::~TDbBalcony()
|
||
{
|
||
}
|
||
|
||
BOOL TDbBalcony::IsValid() const
|
||
{
|
||
BOOL bRet=TDbPolyPathEnt::IsValid();
|
||
if(!bRet)
|
||
return bRet;
|
||
bRet=(m_polyOutline.Length()>1 && m_polyOutline.IsClosed() &&
|
||
m_nRailHeight>-1.0E-6 &&
|
||
fabs(m_nRailWidth)>1E-6 &&
|
||
m_nSlabThickness>1E-6 &&
|
||
m_nGirderThickness>1E-6);
|
||
if(bRet) {
|
||
XPoly2D polyIn(1);
|
||
polyIn=m_polyOutline;
|
||
XPoly2D polyOut(1);
|
||
if(!Offset(polyIn, polyOut))
|
||
return FALSE;
|
||
}
|
||
return bRet;
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbBalcony::audit(AcDbAuditInfo* pAuditInfo)
|
||
{
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
// sg add 090806,解决高版本下修复02图纸,对象丢失的问题
|
||
es = TDbPolyPathEnt::audit(pAuditInfo);
|
||
if (es != Acad::eOk)
|
||
return es;
|
||
|
||
if (m_polyOutline.PathArea() >= 0.0)
|
||
{
|
||
pAuditInfo->errorsFound(1);
|
||
if (pAuditInfo->fixErrors() == Adesk::kTrue) {
|
||
pAuditInfo->printError(_T("柱子"), _T("轮廓"), _T("必须为逆时针"), _T(""));
|
||
|
||
m_polyOutline.Reverse();
|
||
int nEdgeNum=GetEdgeNum();
|
||
DList<int> lstEdgeFlag;
|
||
for(int n=0; n<nEdgeNum; n++)
|
||
lstEdgeFlag.Append(new int(HasRailAt(n)));
|
||
lstEdgeFlag.Reverse();
|
||
for(n=0; n<nEdgeNum; n++)
|
||
SetRailAt(n, *lstEdgeFlag[n]);
|
||
|
||
pAuditInfo->errorsFixed(1);
|
||
es = Acad::eFixedAllErrors;
|
||
} else
|
||
es = Acad::eLeftErrorsUnfixed;
|
||
}
|
||
return es;
|
||
}
|
||
|
||
|
||
|
||
// 提供对格式刷的支持
|
||
void TDbBalcony::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag)
|
||
{
|
||
assertWriteEnabled();
|
||
TDbPolyPathEnt::CopyPropertiesFrom(pSrcEntity, gMatchFlag);
|
||
TDbBalcony *pSrc=TDbBalcony::cast(pSrcEntity);
|
||
if(pSrc) {
|
||
m_nRailHeight=pSrc->m_nRailHeight;
|
||
m_nRailWidth=pSrc->m_nRailWidth; //扶手高和扶手宽, 扶手宽<0, 则为内轮廓
|
||
m_nSlabThickness=pSrc->m_nSlabThickness;
|
||
m_nGirderThickness=pSrc->m_nGirderThickness;
|
||
m_nFlag=pSrc->m_nFlag;
|
||
if(database()==NULL||
|
||
pSrcEntity->database()==NULL||
|
||
database()==pSrcEntity->database())//add by whl on 060317
|
||
{
|
||
m_idLayerGround3d=pSrc->m_idLayerGround3d;
|
||
m_idLayerGlass3d=pSrc->m_idLayerGlass3d;
|
||
m_idLayerFrame3d=pSrc->m_idLayerFrame3d;
|
||
}
|
||
m_uFrame=pSrc->m_uFrame;
|
||
m_vFrame=pSrc->m_vFrame;
|
||
m_nWinHeight=pSrc->m_nWinHeight;
|
||
}
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbBalcony::subGetClassID(CLSID* pClsid) const
|
||
{
|
||
return Acad::eOk;
|
||
|
||
}
|
||
|
||
// 从DWG读入数据:
|
||
Acad::ErrorStatus TDbBalcony::dwgInFields (AcDbDwgFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
Acad::ErrorStatus es = TDbPolyPathEnt::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_nRailEdge);
|
||
|
||
double nElev=0.0;
|
||
pFiler->readItem(&nElev);
|
||
ReadPoly2D(pFiler, m_polyOutline);
|
||
m_polyOutline.SetElevation(nElev);
|
||
|
||
pFiler->readItem(&m_nRailWidth);
|
||
pFiler->readItem(&m_nRailHeight);
|
||
|
||
pFiler->readItem(&m_nSlabThickness);
|
||
pFiler->readItem(&m_nGirderThickness);
|
||
|
||
if(nVer>1)
|
||
{
|
||
pFiler->readItem(&m_idLayerGround3d);
|
||
}
|
||
else
|
||
{ // TArch5 update
|
||
if(database()==acdbCurDwg())
|
||
{
|
||
m_idLayerGround3d = InitLayer(LAY_GROUND, FALSE);
|
||
}
|
||
else
|
||
{
|
||
m_idLayerGround3d = GetLayerIdFromString(LAY_GROUND, database());
|
||
}
|
||
}
|
||
|
||
if(nVer>2)
|
||
{
|
||
pFiler->readItem(&m_nFlag);
|
||
pFiler->readItem(&m_idLayerGlass3d);
|
||
pFiler->readItem(&m_idLayerFrame3d);
|
||
pFiler->readItem(&m_uFrame);
|
||
pFiler->readItem(&m_vFrame);
|
||
pFiler->readItem(&m_nWinHeight);
|
||
|
||
int num;
|
||
pFiler->readItem(&num);//无用数据,永远为0
|
||
}
|
||
|
||
if(nVer>3)//TArch8
|
||
{
|
||
//modify by xlc on 100419 添加num变量的初始化
|
||
Adesk::Int32 num = 0;
|
||
|
||
m_lstWallId.Reset();
|
||
pFiler->readItem(&num);
|
||
for(long i=0;i<num;i++)
|
||
{
|
||
AcDbSoftPointerId idWall;
|
||
pFiler->readItem(&idWall);
|
||
m_lstWallId.Append(new AcDbSoftPointerId(idWall));
|
||
}
|
||
|
||
pFiler->readItem(&m_idHouse);
|
||
|
||
m_lstWinId.Reset();
|
||
|
||
num = 0;
|
||
pFiler->readItem(&num);
|
||
for(i=0;i<num;i++)
|
||
{
|
||
AcDbSoftPointerId idWin;
|
||
pFiler->readItem(&idWin);
|
||
m_lstWinId.Append(new AcDbSoftPointerId(idWin));
|
||
}
|
||
}
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbBalcony::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es = TDbPolyPathEnt::dwgOutFields(pFiler);
|
||
if(es != Acad::eOk) return es;
|
||
|
||
if(g_nSaveTArchVer==5)
|
||
pFiler->writeItem((Adesk::UInt8)1);
|
||
else if(g_nSaveTArchVer==6)
|
||
pFiler->writeItem((Adesk::UInt8)2);
|
||
else if(g_nSaveTArchVer==7)
|
||
pFiler->writeItem((Adesk::UInt8)3);
|
||
else
|
||
pFiler->writeItem(g_nVersion);
|
||
|
||
pFiler->writeItem(m_nRailEdge);
|
||
|
||
double nElev=0.0;
|
||
if(!!m_polyOutline)
|
||
nElev=m_polyOutline[0].z;
|
||
pFiler->writeItem(nElev);
|
||
WritePoly2D(pFiler, m_polyOutline);
|
||
|
||
pFiler->writeItem(m_nRailWidth);
|
||
pFiler->writeItem(m_nRailHeight);
|
||
|
||
pFiler->writeItem(m_nSlabThickness);
|
||
pFiler->writeItem(m_nGirderThickness);
|
||
|
||
if(g_nSaveTArchVer>5)
|
||
pFiler->writeItem(m_idLayerGround3d);
|
||
|
||
if(g_nSaveTArchVer>6)
|
||
{
|
||
pFiler->writeItem(m_nFlag);
|
||
pFiler->writeItem(m_idLayerGlass3d);
|
||
pFiler->writeItem(m_idLayerFrame3d);
|
||
pFiler->writeItem(m_uFrame);
|
||
pFiler->writeItem(m_vFrame);
|
||
pFiler->writeItem(m_nWinHeight);
|
||
|
||
int num=0;
|
||
pFiler->writeItem(num);//无用数据
|
||
}
|
||
|
||
if(g_nSaveTArchVer>7)
|
||
{
|
||
Adesk::Int32 num;
|
||
|
||
num=m_lstWallId.Length();
|
||
pFiler->writeItem(num);
|
||
for(long i=0;i<num;i++)
|
||
pFiler->writeItem(m_lstWallId[i]);
|
||
|
||
pFiler->writeItem(m_idHouse);
|
||
|
||
num=m_lstWinId.Length();
|
||
pFiler->writeItem(num);
|
||
for(i=0;i<num;i++)
|
||
pFiler->writeItem(m_lstWinId[i]);
|
||
}
|
||
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbBalcony::dxfInFields (AcDbDxfFiler* pFiler)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
Acad::ErrorStatus es = TDbPolyPathEnt::dxfInFields(pFiler);
|
||
if(es!=Acad::eOk)
|
||
return es;
|
||
|
||
if (!pFiler->atSubclassData(_T("TDbBalcony"))) {
|
||
return Acad::eBadDxfSequence;
|
||
}
|
||
|
||
int fieldsFlags=0;
|
||
resbuf rb;
|
||
Adesk::UInt32 nFlag;
|
||
double r1, r2, r3, r4, r5;
|
||
DList<XPoint> pts;
|
||
DList<double> bulges;
|
||
while ((es == Acad::eOk)
|
||
&& ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) {
|
||
switch (rb.restype) {
|
||
case 148:
|
||
r1=rb.resval.rreal;
|
||
fieldsFlags |= 0x01;
|
||
break;
|
||
case AcDb::kDxfReal:
|
||
r2 = rb.resval.rreal;
|
||
fieldsFlags |= 0x02;
|
||
break;
|
||
case AcDb::kDxfReal+1:
|
||
r3=rb.resval.rreal;
|
||
fieldsFlags |= 0x04;
|
||
break;
|
||
case AcDb::kDxfReal+2:
|
||
r4=rb.resval.rreal;
|
||
fieldsFlags |= 0x08;
|
||
break;
|
||
case AcDb::kDxfReal+3:
|
||
r5=rb.resval.rreal;
|
||
fieldsFlags |= 0x10;
|
||
break;
|
||
case AcDb::kDxfInt32:
|
||
nFlag=rb.resval.rlong;
|
||
fieldsFlags |= 0x20;
|
||
break;
|
||
case AcDb::kDxfXCoord:
|
||
pts.Append(new XPoint(rb.resval.rpoint));
|
||
fieldsFlags |= 0x40;
|
||
break;
|
||
case AcDb::kDxfAngle:
|
||
bulges.Append(new double(rb.resval.rreal));
|
||
fieldsFlags |= 0x80;
|
||
break;
|
||
case 412:
|
||
m_idLayerGround3d=GetLayerIdFromString(rb.resval.rstring, database());
|
||
free(rb.resval.rstring);
|
||
break;
|
||
//fall through intentional
|
||
default:
|
||
// An unrecognized group. Push it back so that
|
||
// the subclass can read it again.
|
||
pFiler->pushBackItem();
|
||
es = Acad::eEndOfFile;
|
||
break;
|
||
}
|
||
}
|
||
|
||
// At this point the es variable must contain eEndOfFile
|
||
// - either from readResBuf() or from pushback. If not,
|
||
// it indicates that an error happened and we should
|
||
// return immediately.
|
||
//
|
||
if (es != Acad::eEndOfFile)
|
||
return Acad::eInvalidResBuf;
|
||
|
||
if (!(fieldsFlags&0x02)) {
|
||
pFiler->setError(Acad::eMissingDxfField,
|
||
_T("\nMissing DXF group code: 40"));
|
||
return Acad::eMissingDxfField;
|
||
}
|
||
if (!(fieldsFlags&0x04)) {
|
||
pFiler->setError(Acad::eMissingDxfField,
|
||
_T("\nMissing DXF group code: 41"));
|
||
return Acad::eMissingDxfField;
|
||
}
|
||
if (!(fieldsFlags&0x08)) {
|
||
pFiler->setError(Acad::eMissingDxfField,
|
||
_T("\nMissing DXF group code: 42"));
|
||
return Acad::eMissingDxfField;
|
||
}
|
||
if (!(fieldsFlags&0x10)) {
|
||
pFiler->setError(Acad::eMissingDxfField,
|
||
_T("\nMissing DXF group code: 43"));
|
||
return Acad::eMissingDxfField;
|
||
}
|
||
if(pts.Length()<2 || pts.Length()!=bulges.Length()) {
|
||
pFiler->setError(_T("\nError DXF group code: 10, 50"));
|
||
return Acad::eMissingDxfField;
|
||
}
|
||
|
||
double nElev=(fieldsFlags&0x01)? r1 : 0.0;
|
||
SetRailHeight(r2);
|
||
SetRailWidth(r3);
|
||
SetSlabThickness(r4);
|
||
SetGirderThickness(r5);
|
||
if(fieldsFlags&0x20)
|
||
m_nRailEdge=nFlag;
|
||
m_polyOutline.Reset();
|
||
for(int i=0; i<pts.Length(); i++) {
|
||
m_polyOutline.AppendNode(*pts[i], *bulges[i]);
|
||
}
|
||
m_polyOutline.SetElevation(nElev);
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
Acad::ErrorStatus TDbBalcony::dxfOutFields(AcDbDxfFiler* pFiler) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es;
|
||
|
||
es = TDbPolyPathEnt::dxfOutFields(pFiler);
|
||
assert(es == Acad::eOk);
|
||
|
||
es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbBalcony"));
|
||
assert(es == Acad::eOk);
|
||
pFiler->writeDouble(148, GetElevation());
|
||
pFiler->writeDouble(AcDb::kDxfReal, GetRailHeight());
|
||
pFiler->writeDouble(AcDb::kDxfReal+1, GetRailWidth());
|
||
pFiler->writeDouble(AcDb::kDxfReal+2, GetSlabThickness());
|
||
pFiler->writeDouble(AcDb::kDxfReal+3, GetGirderThickness());
|
||
pFiler->writeInt32(AcDb::kDxfInt32, m_nRailEdge);
|
||
for(int i=0; i<m_polyOutline.Length(); i++) {
|
||
pFiler->writePoint2d(AcDb::kDxfXCoord, m_polyOutline[i]);
|
||
pFiler->writeDouble(AcDb::kDxfAngle, m_polyOutline.GetBulge(i));
|
||
}
|
||
|
||
pFiler->writeString(412, (const TCHAR *)LayerId2String(m_idLayerGround3d));
|
||
return pFiler->filerStatus();
|
||
}
|
||
|
||
|
||
// -----------------------------------------------------------------------
|
||
// Overriden functions for edit
|
||
// to do:
|
||
// 允许通过夹点改变边界
|
||
Acad::ErrorStatus TDbBalcony::subGetGripPoints(AcGePoint3dArray& gripPoints,
|
||
AcDbIntArray& osnapModes,
|
||
AcDbIntArray& geomIds) const
|
||
{
|
||
assertReadEnabled();
|
||
int nEdgeNum=GetEdgeNum();
|
||
for(int i=0; i<nEdgeNum; i++) {
|
||
gripPoints.append(m_polyOutline[i]);
|
||
}
|
||
//边上的夹点
|
||
for(i=0; i<nEdgeNum; i++) {
|
||
XCurveSegment edge;
|
||
m_polyOutline.Nth(i, edge);
|
||
XPoint ptMid=edge.MidPoint();
|
||
gripPoints.append(ptMid);
|
||
}
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// stretch points is diffrent from grep points, with no midpoint included
|
||
Acad::ErrorStatus TDbBalcony::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const
|
||
{
|
||
assertReadEnabled();
|
||
for(int i=0; i<m_polyOutline.Length(); i++) {
|
||
stretchPoints.append(m_polyOutline[i]);
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
|
||
|
||
|
||
// Active when being rotated, scaled, moved, etc.
|
||
Acad::ErrorStatus
|
||
TDbBalcony::subTransformBy(const AcGeMatrix3d& xform)
|
||
{
|
||
assertWriteEnabled();
|
||
TDbEntity::subTransformBy(xform);
|
||
ads_matrix mat;
|
||
memcpy(mat, &xform, sizeof(ads_matrix));
|
||
double nElev=0.0;
|
||
for(int i=0; i<m_polyOutline.Length(); i++) {
|
||
XPoint *pt=m_polyOutline[i];
|
||
pt->TransformBy(mat);
|
||
//以第一个顶点的z坐标为基准
|
||
if(i==0) {
|
||
nElev = pt->z;
|
||
} else {
|
||
pt->z = nElev;
|
||
}
|
||
}
|
||
if(IsMirrorMatrix(mat)) {
|
||
for(int m=0; m<m_polyOutline.Length(); m++)
|
||
m_polyOutline.SetBulge(m, -m_polyOutline.GetBulge(m));
|
||
}
|
||
if(m_polyOutline.PathArea()>0) {
|
||
m_polyOutline.Reverse();
|
||
int nEdgeNum=GetEdgeNum();
|
||
DList<int> lstEdgeFlag;
|
||
for(int n=0; n<nEdgeNum; n++)
|
||
lstEdgeFlag.Append(new int(HasRailAt(n)));
|
||
lstEdgeFlag.Reverse();
|
||
for(n=0; n<nEdgeNum; n++)
|
||
SetRailAt(n, *lstEdgeFlag[n]);
|
||
}
|
||
return Acad::eOk;
|
||
}
|
||
void TDbBalcony::UnionScale(double nScale)
|
||
{
|
||
assertWriteEnabled();
|
||
double nOldElev=GetElevation();
|
||
TDbEntity::UnionScale(nScale);
|
||
SetElevation(nOldElev*nScale);
|
||
m_nRailHeight*=nScale;
|
||
m_nRailWidth*=nScale;
|
||
m_nSlabThickness*=nScale;
|
||
m_nGirderThickness*=nScale;
|
||
m_uFrame*=nScale;
|
||
m_vFrame*=nScale;
|
||
m_nWinHeight*=nScale;
|
||
}
|
||
// 功能: 夹点操作
|
||
Acad::ErrorStatus TDbBalcony::subMoveGripPointsAt(
|
||
const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
XPoly2D polyBack(m_polyOutline);
|
||
|
||
XPoint vtOffset=*(XPoint *)&offset;
|
||
vtOffset.z=0;
|
||
int nTotalEdge=GetEdgeNum();
|
||
for (int i = 0; i < indices.length(); i++)
|
||
{
|
||
int idx = indices[i];
|
||
ASSERT(idx<2*nTotalEdge);
|
||
if (idx<nTotalEdge)
|
||
{
|
||
*m_polyOutline[idx] += vtOffset;
|
||
}
|
||
else
|
||
{
|
||
int nEdgeIndex=idx-nTotalEdge;
|
||
ASSERT(nEdgeIndex<nTotalEdge);
|
||
|
||
XDirectionCurve cv;
|
||
m_polyOutline.Nth(nEdgeIndex, cv);
|
||
ASSERT(!!cv);
|
||
if(cv.Is(CURVE_LINE)) { // Move
|
||
XLine ln=cv.GetLine();
|
||
ln.StartPoint() += vtOffset;
|
||
ln.EndPoint() += vtOffset;
|
||
ln.SetLineFlag(LS_INFINITE);
|
||
XDirectionCurve prevSeg, nextSeg;
|
||
int nPrev=nEdgeIndex-1, nNext=nEdgeIndex+1;
|
||
nPrev=DePeriod(nTotalEdge, nPrev);
|
||
nNext=DePeriod(nTotalEdge, nNext);
|
||
|
||
XPoint ptStart, ptEnd;
|
||
BOOL bUpdateIt=TRUE;
|
||
//更新起点
|
||
if(nPrev>=0 && nPrev<nTotalEdge) {
|
||
m_polyOutline.Nth(nPrev, prevSeg);
|
||
prevSeg.SetLineFlag(LS_INFINITE);
|
||
XPoint ptInt[2];
|
||
int nIntNum=prevSeg.Intersection(ln, ptInt[0], ptInt[1]);
|
||
if(nIntNum==1) ptStart=ptInt[0];
|
||
else if(nIntNum==2) {
|
||
ptStart=XLine(ptInt[0], ptInt[1]).NearPoint(ln.StartPoint());
|
||
} else bUpdateIt=FALSE;
|
||
} else {
|
||
ptStart = *m_polyOutline[nEdgeIndex] + vtOffset;
|
||
}
|
||
|
||
// 更新下一点
|
||
if(nNext>=0 && nNext<nTotalEdge) {
|
||
m_polyOutline.Nth(nNext, nextSeg);
|
||
nextSeg.SetLineFlag(LS_INFINITE);
|
||
XPoint ptInt[2];
|
||
int nIntNum=nextSeg.Intersection(ln, ptInt[0], ptInt[1]);
|
||
if(nIntNum==1) ptEnd=ptInt[0];
|
||
else if(nIntNum==2) {
|
||
ptEnd=XLine(ptInt[0], ptInt[1]).NearPoint(ln.EndPoint());
|
||
} else bUpdateIt=FALSE;
|
||
} else {
|
||
ptEnd = *m_polyOutline[nEdgeIndex+1] + vtOffset;
|
||
}
|
||
|
||
if(bUpdateIt) {
|
||
double nPrevBulge=0.0, nNextBulge=0.0;
|
||
if(fabs(prevSeg.GetBulge())>1.0E-5) {
|
||
XArc prevArc=prevSeg.GetArc();
|
||
double nAngBeg=ads_angle(prevArc.GetCenterPt(), prevSeg.StartPoint());
|
||
double nAngEnd=ads_angle(prevArc.GetCenterPt(), ptStart);
|
||
if(prevSeg.IsMinusArc()) {
|
||
nPrevBulge=-CT_std_angle(nAngBeg-nAngEnd);
|
||
} else {
|
||
nPrevBulge=CT_std_angle(nAngEnd-nAngBeg);
|
||
}
|
||
}
|
||
if(fabs(nextSeg.GetBulge())>1.0E-5) {
|
||
XArc nextArc=nextSeg.GetArc();
|
||
double nAngBeg=ads_angle(nextArc.GetCenterPt(), ptEnd);
|
||
double nAngEnd=ads_angle(nextArc.GetCenterPt(), nextSeg.EndPoint());
|
||
if(nextSeg.IsMinusArc()) {
|
||
nNextBulge=-CT_std_angle(nAngBeg-nAngEnd);
|
||
} else {
|
||
nNextBulge=CT_std_angle(nAngEnd-nAngBeg);
|
||
}
|
||
}
|
||
|
||
*m_polyOutline[nEdgeIndex] = ptStart;
|
||
if(nNext>=0 && nNext<m_polyOutline.Length())
|
||
{
|
||
*m_polyOutline[nNext] = ptEnd;
|
||
m_polyOutline.SetBulge(nNext, nNextBulge);
|
||
}
|
||
if(nPrev>=0 && nPrev<m_polyOutline.Length())
|
||
m_polyOutline.SetBulge(nPrev, nPrevBulge);
|
||
|
||
}
|
||
|
||
} else { // Change Arc Segment--bulge
|
||
XPoint ptMid=cv.MidPoint();
|
||
XPoint ptMidNew= ptMid + vtOffset;
|
||
XArc arNew(cv.StartPoint(), ptMidNew, cv.EndPoint());
|
||
if(!!arNew) { //新的弧有效
|
||
XCurveSegment cvLine(cv.StartPoint(), cv.EndPoint(), 0.0);
|
||
int nSideOld=cvLine.OnWhichSide(ptMid);
|
||
int nSideNew=cvLine.OnWhichSide(ptMidNew);
|
||
double nSignal=cv.GetBulge()/fabs(cv.GetBulge());
|
||
if(nSideOld==nSideNew) {
|
||
m_polyOutline.SetBulge(nEdgeIndex, nSignal*arNew.Bulge());
|
||
} else {
|
||
m_polyOutline.SetBulge(nEdgeIndex, -nSignal*arNew.Bulge());
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
Acad::ErrorStatus es = Acad::eOk;
|
||
if(m_polyOutline.IsSelfIntersect()) {
|
||
m_polyOutline=polyBack;
|
||
es = Acad::eInvalidInput;
|
||
}
|
||
|
||
// sg add 110106,解决阳台对象,拖拽夹点后,出现反向的问题
|
||
if (m_polyOutline.PathArea()>0)
|
||
{
|
||
m_polyOutline.Reverse();
|
||
int nEdgeNum=GetEdgeNum();
|
||
DList<int> lstEdgeFlag;
|
||
for(int n=0; n<nEdgeNum; n++)
|
||
lstEdgeFlag.Append(new int(HasRailAt(n)));
|
||
lstEdgeFlag.Reverse();
|
||
for(n=0; n<nEdgeNum; n++)
|
||
SetRailAt(n, *lstEdgeFlag[n]);
|
||
}
|
||
|
||
return es;
|
||
}
|
||
|
||
// 取得夹点说明
|
||
Acad::ErrorStatus TDbBalcony::GetGripText(int i, CString &cs) const
|
||
{
|
||
assertReadEnabled();
|
||
Acad::ErrorStatus es=Acad::eOk;
|
||
XString sInfo;
|
||
if(i<GetEdgeNum()) {
|
||
sInfo << _T("移动第") << (i+1) << _T("个顶点");
|
||
} else {
|
||
sInfo << _T("移动第") << (i-GetEdgeNum()+1) << _T("条边");
|
||
}
|
||
cs = sInfo;
|
||
return es;
|
||
}
|
||
#if ADS>15
|
||
void TDbBalcony::CreateGrip()
|
||
{
|
||
TDbEntity::CreateGrip();
|
||
TchExport2::CreateGrip(this,m_polyOutline,0);
|
||
}
|
||
Acad::ErrorStatus TDbBalcony::EntityToDim(long iGrip,long iDim,const AcDbEntity*pEnt)
|
||
{
|
||
TEntityBase *pCurve=TDbBalcony::cast(pEnt);
|
||
if(pCurve==NULL)
|
||
pCurve=this;
|
||
XPoly2D polyPath;
|
||
AcGeVector3d normal;
|
||
pCurve->GetPathPoly(polyPath,normal);
|
||
return TchExport2::EntityToDim(this,polyPath,iGrip,iDim,0);
|
||
}
|
||
|
||
Acad::ErrorStatus TDbBalcony::DimToEntity(long iGrip,long iDim,double newValue,const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
|
||
TDbBalcony curve;
|
||
curve.CopyPropertiesFrom(this,0);
|
||
|
||
Acad::ErrorStatus es=TchExport2::DimToEntity(this,m_polyOutline,iGrip,iDim,newValue,offset,0);
|
||
if(es==Acad::eOk&&!IsValid())
|
||
{
|
||
CopyPropertiesFrom(&curve,0);
|
||
return Acad::eInvalidInput;
|
||
}
|
||
|
||
// sg add 110106,解决阳台对象,动态输入修改夹点后,出现反向的问题
|
||
if (m_polyOutline.PathArea()>0)
|
||
{
|
||
m_polyOutline.Reverse();
|
||
int nEdgeNum=GetEdgeNum();
|
||
DList<int> lstEdgeFlag;
|
||
for(int n=0; n<nEdgeNum; n++)
|
||
lstEdgeFlag.Append(new int(HasRailAt(n)));
|
||
lstEdgeFlag.Reverse();
|
||
for(n=0; n<nEdgeNum; n++)
|
||
SetRailAt(n, *lstEdgeFlag[n]);
|
||
}
|
||
|
||
|
||
return es;
|
||
}
|
||
#endif
|
||
// 功能: 夹点操作
|
||
// 状态: 有待完成修改相关墙体门窗的操作
|
||
Acad::ErrorStatus TDbBalcony::subMoveStretchPointsAt(
|
||
const AcDbIntArray& indices,
|
||
const AcGeVector3d& offset)
|
||
{
|
||
assertWriteEnabled();
|
||
int nCount=indices.length();
|
||
return subMoveGripPointsAt(indices, offset);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
Acad::ErrorStatus
|
||
TDbBalcony::ExplodeOrDraw3d(XExplodeDraw &dc) const
|
||
{
|
||
assertReadEnabled();
|
||
//TPushProperty vProp(this, dc);
|
||
|
||
XPoly2D polyIn(1);
|
||
polyIn=m_polyOutline;
|
||
|
||
XPoly2D polyOut(1);
|
||
{
|
||
//// sg add 110920,解决日照环境和建筑环境下,由于容忍度不一样,导致日照软件环境下,求不到交点,阳台不能显示的问题
|
||
if (g_nProductId == kTSUN)
|
||
{
|
||
AcGeTol &tmpTol = AcGeContext::gTol;
|
||
double dOldTol = tmpTol.equalPoint(),
|
||
dNewTol = _distSnap*0.1;
|
||
tmpTol.setEqualPoint(dNewTol);
|
||
|
||
if (!Offset(polyIn, polyOut))
|
||
return Acad::eInvalidInput;
|
||
|
||
tmpTol.setEqualPoint(dOldTol);
|
||
}
|
||
else
|
||
{
|
||
if (!Offset(polyIn, polyOut))
|
||
return Acad::eInvalidInput;
|
||
}
|
||
}
|
||
|
||
double nHIn = GetRailHeight();
|
||
double nHOut = GetRailHeight() + GetGirderThickness();
|
||
if(m_nRailWidth>0)
|
||
TchPrivate::Exchange(polyIn, polyOut);
|
||
|
||
DList<XPoly2D> lstPolys;
|
||
// modify on 2002/2/22 by ZJQ 解决标高不为0的时候,区域运算和搜索的问题。
|
||
polyOut.SetElevation(0.0);
|
||
polyIn.SetElevation(0.0);
|
||
TchSubExport::Subtract(polyOut, polyIn, lstPolys); //阳台拦板
|
||
|
||
double nOutElev=GetElevation()-GetGirderThickness();
|
||
XVector3D vt(0,0,GetGirderThickness()-GetSlabThickness());
|
||
polyOut.SetElevation(nOutElev);
|
||
polyIn.SetElevation(GetElevation());
|
||
int nEdge=GetEdgeNum();
|
||
for(int i=0; i<nEdge; i++) {
|
||
if(!HasRailAt(i))
|
||
continue;
|
||
XCurveSegment seg1, seg2;
|
||
polyIn.Nth(i, seg1);
|
||
polyOut.Nth(i, seg2);
|
||
dc.DrawCurve(seg1, nHIn);
|
||
dc.DrawCurve(seg2, nHOut);
|
||
// 封梁侧面
|
||
if(vt.z>_DIST_SNAP) {
|
||
seg1.SetElevation(nOutElev);
|
||
dc.DrawCurve(seg1, vt.z);
|
||
}
|
||
}
|
||
|
||
|
||
for(int ii=0; ii<lstPolys.Length(); ii++) {
|
||
XPoly2D &rPoly=*lstPolys[ii];
|
||
rPoly.SetElevation(GetElevation()+nHIn);
|
||
dc.DrawShell(rPoly, DList<XPoly2D>()); //栏板顶面
|
||
rPoly.SetElevation(GetElevation()-GetGirderThickness());
|
||
if(HasGirder())
|
||
dc.DrawShell(rPoly, DList<XPoly2D>()); //封梁底
|
||
//dc.DrawMesh(rPoly, vt); //封梁侧面
|
||
}
|
||
|
||
|
||
TMasterProperties prop;
|
||
dc.BackUpProperties(prop);
|
||
dc.SetColorLayer(colorIndex(), m_idLayerGround3d);
|
||
dc.DrawShell(polyIn, DList<XPoly2D>()); //阳台地面
|
||
polyIn.SetElevation(GetElevation()-GetSlabThickness());
|
||
dc.DrawShell(HasGirder()? polyIn : polyOut, DList<XPoly2D>()); //阳台底面
|
||
dc.RestoreProperties(prop);
|
||
return Acad::eOk;
|
||
}
|
||
bool TDbBalcony::IsClipMe(const TEntityBase* pEnt)const
|
||
{
|
||
if(TDbEntity::IsClipMe(pEnt))
|
||
return true;
|
||
|
||
// if(pEnt->GetMe()->isKindOf(TDbColumn::desc())||
|
||
// pEnt->GetMe()->isKindOf(TDbWall::desc())) // 8.0支持墙裁剪阳台
|
||
if(pEnt->GetMe()->isKindOf(TDbColumn::desc()) ||
|
||
pEnt->GetMe()->isKindOf(TDbWall::desc()) || // 8.0支持墙裁剪阳台
|
||
pEnt->GetMe()->isKindOf(TDbWallPatch::desc())) // sg add 090527,墙体造型裁剪阳台
|
||
return true;
|
||
|
||
return false;
|
||
}
|
||
|
||
Acad::ErrorStatus
|
||
TDbBalcony::ExplodeOrDraw2d(XExplodeDraw &dc) const
|
||
{
|
||
//TPushProperty vProp(this, dc);
|
||
assertReadEnabled();
|
||
XPoly2D polyCur(1);
|
||
polyCur=m_polyOutline;
|
||
polyCur.SetElevation(0.0);
|
||
|
||
XPoly2D polyNext(1);
|
||
{
|
||
// sg add 110928,解决日照环境和建筑环境下,由于容忍度不一样,导致日照软件环境下,求不到交点,阳台不能显示的问题
|
||
if (g_nProductId == kTSUN)
|
||
{
|
||
AcGeTol &tmpTol = AcGeContext::gTol;
|
||
double dOldTol = tmpTol.equalPoint(),
|
||
dNewTol = _distSnap*0.1;
|
||
tmpTol.setEqualPoint(dNewTol);
|
||
|
||
if (!Offset(polyCur, polyNext))
|
||
{
|
||
XPoint pt1, pt2;
|
||
int nColorOld=dc.GetColor();
|
||
dc.SetColor(1);
|
||
dc << polyCur;
|
||
polyCur.GetExtend(pt1, pt2);
|
||
XRectAngle box(pt1, pt2);
|
||
dc << XLine(box.GetLowLeft(), box.GetUpRight())
|
||
<< XLine(box.GetUpLeft(), box.GetLowRight());
|
||
dc.SetColor(nColorOld);
|
||
return Acad::eOk;
|
||
}
|
||
|
||
tmpTol.setEqualPoint(dOldTol);
|
||
}
|
||
else
|
||
{
|
||
if (!Offset(polyCur, polyNext))
|
||
{
|
||
XPoint pt1, pt2;
|
||
int nColorOld=dc.GetColor();
|
||
dc.SetColor(1);
|
||
dc << polyCur;
|
||
polyCur.GetExtend(pt1, pt2);
|
||
XRectAngle box(pt1, pt2);
|
||
dc << XLine(box.GetLowLeft(), box.GetUpRight())
|
||
<< XLine(box.GetUpLeft(), box.GetLowRight());
|
||
dc.SetColor(nColorOld);
|
||
return Acad::eOk;
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
//modify by xlc on 110519 调整阳台遮挡保温算法
|
||
// //add by xlc on 110218 阳台遮挡保温
|
||
// bool bBalconyClipInsu = false;
|
||
// TDPtrList<TGGePoly2D> lstTemp;
|
||
// double dLength = _AS_SYS_UNIT(10);
|
||
// if(IsBalconyClipInsu() && (!(g_bGetExtents || g_bOsnapExpl)))
|
||
// {
|
||
// for (long i = 0; i < m_lstClipId.Length(); i++)
|
||
// {
|
||
// const AcDbObjectId &id = m_lstClipId[i];
|
||
// if (id.isNull() || !id.isValid())
|
||
// {
|
||
// continue;
|
||
// }
|
||
//
|
||
// //modify by xlc on 110314 优化阳台遮挡保温算法
|
||
// //OPENOBJ_BEGIN(id, AcDb::kForRead, TDbWall, pWall);
|
||
// //if (pWall)
|
||
// //{
|
||
// // if ((pWall->GetWallFlag() & WF_LEFT_INSULATE) || (pWall->GetWallFlag() & WF_RIGHT_INSULATE))
|
||
// // {
|
||
// // bBalconyClipInsu = true;
|
||
// // break;
|
||
// // }
|
||
// //}
|
||
// //OPENOBJ_END();
|
||
// AcDbEntity *pEnt = NULL;
|
||
// acdbOpenObject(pEnt,id,AcDb::kForRead);
|
||
//
|
||
// if (pEnt != NULL)
|
||
// {
|
||
// bool bAddPoly = false;
|
||
// double dThick = 0;
|
||
// TGGePoly2D polyOut;
|
||
// if (pEnt->isKindOf(TDbWall::desc()))
|
||
// {
|
||
// bAddPoly = true;
|
||
// ((TDbWall*)pEnt)->GetOutlinePoly(0, polyOut);
|
||
//
|
||
// int nWallFlag = ((TDbWall*)pEnt)->GetWallFlag();
|
||
// if ((nWallFlag & WF_LEFT_INSULATE) || (nWallFlag & WF_RIGHT_INSULATE))
|
||
// {
|
||
// bBalconyClipInsu = true;
|
||
// double dThick0 = ((TDbWall*)pEnt)->GetInsulateThick(0);
|
||
// double dThick1 = ((TDbWall*)pEnt)->GetInsulateThick(1);
|
||
// dThick = dThick0;
|
||
// if (dThick > dThick1)
|
||
// {
|
||
// dThick = dThick1;
|
||
// }
|
||
// }
|
||
// }
|
||
// else if (pEnt->isKindOf(TDbColumn::desc()))
|
||
// {
|
||
// bAddPoly = true;
|
||
// polyOut=((TDbColumn*)pEnt)->GetOutlinePoly();
|
||
//
|
||
// bool bHasInsl = ((TDbColumn*)pEnt)->IsInsulateOnColumn();
|
||
// double dInsThk = ((TDbColumn*)pEnt)->GetInsulateThick();
|
||
// if (bHasInsl && dInsThk >= 1.e-3) //这里精度与柱子绘制精度保持一致
|
||
// {
|
||
// dThick = dInsThk;
|
||
// bBalconyClipInsu = true;
|
||
// }
|
||
//
|
||
// }
|
||
// else if(pEnt->isKindOf(TDbWallPatch::desc()))
|
||
// {
|
||
// bAddPoly = true;
|
||
// ((TDbWallPatch*)pEnt)->GetOutlinePoly(polyOut, false);
|
||
// BOOL bHasInsl = ((TDbWallPatch*)pEnt)->HasInsulate();
|
||
// double dInsThk = ((TDbWallPatch*)pEnt)->GetInsulateThick();
|
||
// if (bHasInsl && dInsThk >= 1.E-5) //这里精度与墙体造型绘制精度保持一致
|
||
// {
|
||
// dThick = dInsThk;
|
||
// bBalconyClipInsu = true;
|
||
// }
|
||
// }
|
||
//
|
||
// if (bAddPoly)
|
||
// {
|
||
// if (dThick > dLength)
|
||
// {
|
||
// dThick = dLength;
|
||
// }
|
||
// else
|
||
// {
|
||
// dThick *= 0.5;
|
||
// }
|
||
//
|
||
// GetOffsetPoly2D(polyOut,polyOut,dThick);
|
||
// lstTemp.Append(new TGGePoly2D(polyOut));
|
||
// }
|
||
// pEnt->close();
|
||
// }
|
||
// }
|
||
// }
|
||
//
|
||
// int nEdge=GetEdgeNum();
|
||
// TGGePoly2D poly(1);
|
||
// TDPtrList<TGGeCurveSegment> lstCurves;
|
||
// bool bFirst = true;
|
||
// TGGePoly2D poly1,poly2;
|
||
// for(int i=0; i<nEdge; i++)
|
||
// {
|
||
// if(!HasRailAt(i))
|
||
// continue;
|
||
// XCurveSegment seg1, seg2;
|
||
// polyCur.Nth(i, seg1);
|
||
// polyNext.Nth(i, seg2);
|
||
//
|
||
// //modify by xlc on 110218 阳台遮挡保温
|
||
// //dc<<seg1<<seg2;
|
||
// if(bBalconyClipInsu)
|
||
// {
|
||
// lstCurves.Append(new TGGeCurveSegment(seg1));
|
||
// lstCurves.Append(new TGGeCurveSegment(seg2));
|
||
//
|
||
// //modify by xlc on 110314 优化阳台遮挡保温算法
|
||
// //XPoint ptS = seg1.StartPoint(), ptE =seg1.EndPoint();
|
||
// //if (bFirst)
|
||
// //{
|
||
// // TADSGePointDir2d ptDir;
|
||
// // seg1.Polar(dLength, ptDir);
|
||
// // poly.InsertNodeAt(0, ptDir);
|
||
// //}
|
||
// //poly.InsertNodeAt(0, ptE);
|
||
// //
|
||
// //ptS = seg2.StartPoint(), ptE = seg2.EndPoint();
|
||
// //if (bFirst)
|
||
// //{
|
||
// // TADSGePointDir2d ptDir;
|
||
// // seg2.Polar(dLength, ptDir);
|
||
// // poly.AppendNode(ptDir);
|
||
// //}
|
||
// //else
|
||
// //{
|
||
// // bFirst = false;
|
||
// //}
|
||
// //poly.AppendNode(ptE);
|
||
// if (bFirst)
|
||
// {
|
||
// poly1.AppendNode(*polyCur[i],polyCur.GetBulge(i));
|
||
// }
|
||
// poly1.AppendNode(*polyCur[i+1],polyCur.GetBulge(i+1));
|
||
//
|
||
// if (bFirst)
|
||
// {
|
||
// poly2.AppendNode(*polyNext[i],polyNext.GetBulge(i));
|
||
// bFirst = false;
|
||
// }
|
||
// poly2.AppendNode(*polyNext[i+1],polyNext.GetBulge(i+1));
|
||
// }
|
||
// else
|
||
// {
|
||
// dc<<seg1<<seg2;
|
||
// }
|
||
// }
|
||
//
|
||
// if (0&&bBalconyClipInsu && _tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0)
|
||
// {
|
||
// for (int i = 0; i < poly1.Length(); i++)
|
||
// {
|
||
// poly.AppendNode(*poly1[i],poly1.GetBulge(i));
|
||
// }
|
||
// poly2.Reverse();
|
||
// for (i = 0; i < poly2.Length(); i++)
|
||
// {
|
||
// poly.AppendNode(*poly2[i],poly2.GetBulge(i));
|
||
// }
|
||
// poly.Compress();
|
||
//
|
||
// TDPtrList<TGGePoly2D> lstBal,lstRes;
|
||
// lstBal.Append(new TGGePoly2D(poly));
|
||
// Subtract(lstBal, lstTemp, lstRes);
|
||
//
|
||
// if (lstRes.Length()>0)
|
||
// {
|
||
// poly = *lstRes[0];
|
||
// }
|
||
// else
|
||
// {
|
||
// poly.Reset();
|
||
// }
|
||
//
|
||
// if(poly.Length() > 3)
|
||
// {
|
||
///* if (lstCurves.Length() >= 2)
|
||
// {
|
||
// TGGeCurveSegment &cvSeg = *lstCurves[lstCurves.Length()-2];
|
||
// TADSGePointDir2d ptDir;
|
||
// cvSeg.Polar(cvSeg.GetLength()-dLength, ptDir, 1);
|
||
// poly.RemoveNode(0);
|
||
// poly.InsertNodeAt(0, ptDir);
|
||
//
|
||
// TGGeCurveSegment &cvSeg1 = *lstCurves[lstCurves.Length()-1];
|
||
// cvSeg1.Polar(cvSeg1.GetLength()-dLength, ptDir, 1);
|
||
// poly.RemoveNode(poly.Length()-1);
|
||
// poly.AppendNode(ptDir);
|
||
// }
|
||
//*/
|
||
//
|
||
// COLORREF colorImage;
|
||
// AcColorSettings setAcadColor;
|
||
// acedGetCurrentColors(&setAcadColor);
|
||
//
|
||
// int tilemode;
|
||
// xg_getvar(_T("TILEMODE"), &tilemode);
|
||
// colorImage = tilemode? setAcadColor.dwGfxModelBkColor : setAcadColor.dwGfxLayoutBkColor;
|
||
// AcCmEntityColor color;
|
||
// if (colorImage == RGB(255,255,255))
|
||
// {
|
||
// color.setColorIndex(255);
|
||
// }
|
||
// else
|
||
// {
|
||
// color.setTrueColor();
|
||
// color.setRGB(GetRValue(colorImage),GetGValue(colorImage),GetBValue(colorImage));
|
||
// }
|
||
//
|
||
// AcGiCommonDraw *dcCommon = ((XAcGiViewDraw &)dc).GetCommonDraw();
|
||
// if (!dcCommon->context()->isPlotGeneration())
|
||
// {
|
||
// AcGiFillType nFillType=dcCommon->subEntityTraits().fillType();
|
||
// AcCmEntityColor cmColor=dcCommon->subEntityTraits().trueColor();
|
||
// dcCommon->subEntityTraits().setFillType(kAcGiFillAlways);
|
||
// dcCommon->subEntityTraits().setTrueColor(color);
|
||
// dc<<XSolid(poly);
|
||
// dcCommon->subEntityTraits().setFillType(nFillType);
|
||
// dcCommon->subEntityTraits().setTrueColor(cmColor);
|
||
// }
|
||
// }
|
||
// }
|
||
// if (bBalconyClipInsu)
|
||
// {
|
||
// dc << lstCurves;
|
||
// }
|
||
int nEdge=GetEdgeNum();
|
||
for(int i=0; i<nEdge; i++)
|
||
{
|
||
if(!HasRailAt(i))
|
||
continue;
|
||
TGGeCurveSegment seg1, seg2;
|
||
polyCur.Nth(i, seg1);
|
||
polyNext.Nth(i, seg2);
|
||
dc<<seg1<<seg2;
|
||
}
|
||
|
||
return Acad::eOk;
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
const TCHAR *TDbBalcony::GetDefaultLayer() const
|
||
{
|
||
assertReadEnabled();
|
||
return LAY_BALCONY;
|
||
}
|
||
|
||
|
||
|
||
/* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */
|
||
void TDbBalcony::GetTips(DList<TObjInfoUnit> &lstInfo) const
|
||
{
|
||
assertReadEnabled();
|
||
lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("阳台")));
|
||
lstInfo.Append(new TObjInfoUnit(_T("拦板宽"), Dist2Str(fabs(GetRailWidth()))));
|
||
lstInfo.Append(new TObjInfoUnit(_T("拦板高"), Dist2Str(GetRailHeight())));
|
||
lstInfo.Append(new TObjInfoUnit(_T("地面高差"), Dist2Str(-GetElevation())));
|
||
lstInfo.Append(new TObjInfoUnit(_T("地板厚"), Dist2Str(GetSlabThickness())));
|
||
if(HasGirder())
|
||
lstInfo.Append(new TObjInfoUnit(_T("梁高"), Dist2Str(GetGirderThickness())));
|
||
XString sArea(_T("%.2f"), _AS_SQMETER(GetOutline().Area()));
|
||
lstInfo.Append(new TObjInfoUnit(_T("面积"), sArea));
|
||
}
|
||
|
||
|
||
int
|
||
TDbBalcony::GetEdgeNum() const
|
||
{
|
||
assertReadEnabled();
|
||
return m_polyOutline.TotalSegments();
|
||
}
|
||
|
||
BOOL
|
||
TDbBalcony::HasRailAt(int idx) const
|
||
{
|
||
assertReadEnabled();
|
||
ASSERT(idx<GetEdgeNum());
|
||
int nTestBit=0x01;
|
||
nTestBit <<= idx;
|
||
return ((m_nRailEdge&nTestBit)==0);
|
||
}
|
||
|
||
double
|
||
TDbBalcony::GetOffsetDist(int idx) const
|
||
{
|
||
assertReadEnabled();
|
||
double nDist= HasRailAt(idx)? -m_nRailWidth : 0.0;
|
||
return nDist;
|
||
}
|
||
|
||
|
||
BOOL
|
||
TDbBalcony::Offset(const XPoly2D &src, XPoly2D &dest) const
|
||
{
|
||
assertReadEnabled();
|
||
int nTotalSeg=src.TotalSegments();
|
||
ASSERT(nTotalSeg==GetEdgeNum());
|
||
dest.Reset();
|
||
dest.SetFlag(1);
|
||
|
||
XDirectionCurve finalMidSeg, lastSeg;
|
||
src.Nth(nTotalSeg-1, finalMidSeg);
|
||
lastSeg = finalMidSeg.Offset(GetOffsetDist(nTotalSeg-1), LS_INFINITE);
|
||
if(!lastSeg)
|
||
return FALSE;
|
||
|
||
XPoint nextPt;
|
||
for(int i=0; i<nTotalSeg; i++) {
|
||
XDirectionCurve curMidSeg;
|
||
src.Nth(i, curMidSeg);
|
||
XDirectionCurve curSeg=curMidSeg.Offset(GetOffsetDist(i), LS_INFINITE);
|
||
if(!curSeg)
|
||
return FALSE;
|
||
|
||
XPoint pt1, pt2, curPt;
|
||
if(!i) { // 求当前点
|
||
if(!lastSeg) curPt=curSeg.StartPoint();
|
||
else {
|
||
int ptNum=curSeg.Intersection(lastSeg, pt1, pt2);
|
||
if(ptNum==2) curPt=XLine(pt1,pt2).NearPoint(curSeg.StartPoint());
|
||
else if(ptNum==1) curPt=pt1;
|
||
else {
|
||
return FALSE;
|
||
}
|
||
}
|
||
} else curPt=nextPt; //上次求得的下一点
|
||
|
||
int nextIndex= i>=nTotalSeg-1? 0 : i+1; // 当前段为最后时, 下一段为起始段
|
||
XDirectionCurve nextMidSeg;
|
||
src.Nth(nextIndex, nextMidSeg);
|
||
|
||
XDirectionCurve nextSeg=nextMidSeg.Offset(GetOffsetDist(nextIndex), LS_INFINITE);
|
||
if(!nextSeg)
|
||
return FALSE;
|
||
int ptNum=curSeg.Intersection(nextSeg, pt1, pt2);
|
||
if(ptNum==2) nextPt=XLine(pt1, pt2).NearPoint(curSeg.EndPoint());
|
||
else if(ptNum==1) nextPt=pt1;
|
||
else {
|
||
return FALSE;
|
||
}
|
||
|
||
lastSeg=curSeg;
|
||
if(curSeg.Is(CURVE_ARC)) {
|
||
XArc arc=curSeg.GetArc();
|
||
if(!curSeg.IsMinusArc()) { //逆时针
|
||
arc.SetStarAngle(ads_angle(arc.GetCenterPt(), curPt));
|
||
arc.SetEndAngle(ads_angle(arc.GetCenterPt(), nextPt));
|
||
curSeg.SetBulge(arc.Bulge());
|
||
}
|
||
else
|
||
{
|
||
arc.SetStarAngle(ads_angle(arc.GetCenterPt(), nextPt));
|
||
arc.SetEndAngle(ads_angle(arc.GetCenterPt(), curPt));
|
||
curSeg.SetBulge(-arc.Bulge());
|
||
}
|
||
curSeg.StartPoint()=curPt;
|
||
curSeg.EndPoint()=nextPt;
|
||
}
|
||
|
||
//添一段
|
||
dest.Append(new XPoint(curPt));
|
||
dest.AppendBugle(curSeg.GetBulge());
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
double
|
||
TDbBalcony::GetRailHeight() const
|
||
{
|
||
assertReadEnabled();
|
||
return m_nRailHeight;
|
||
}
|
||
|
||
double
|
||
TDbBalcony::GetRailWidth() const
|
||
{
|
||
assertReadEnabled();
|
||
return m_nRailWidth;
|
||
}
|
||
|
||
double
|
||
TDbBalcony::GetGirderThickness() const
|
||
{
|
||
assertReadEnabled();
|
||
return m_nGirderThickness;
|
||
}
|
||
|
||
BOOL
|
||
TDbBalcony::HasGirder() const
|
||
{
|
||
assertReadEnabled();
|
||
return (GetGirderThickness()-GetSlabThickness()>_DIST_SNAP);
|
||
}
|
||
|
||
double
|
||
TDbBalcony::GetSlabThickness() const
|
||
{
|
||
assertReadEnabled();
|
||
return m_nSlabThickness;
|
||
}
|
||
|
||
|
||
const XPoly2D &
|
||
TDbBalcony::GetOutline() const
|
||
{
|
||
assertReadEnabled();
|
||
return m_polyOutline;
|
||
}
|
||
|
||
|
||
|
||
void
|
||
TDbBalcony::SetRailHeight(double h)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nRailHeight=h;
|
||
}
|
||
|
||
void
|
||
TDbBalcony::SetRailWidth(double w)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nRailWidth = w;
|
||
}
|
||
|
||
void
|
||
TDbBalcony::SetOutline(const XPoly2D &poly)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(poly.PathArea()<0.0 && poly.GetFlag()==1);
|
||
m_polyOutline = poly;
|
||
}
|
||
|
||
void
|
||
TDbBalcony::SetRailAt(int idx, BOOL bHasRail)
|
||
{
|
||
assertWriteEnabled();
|
||
ASSERT(idx<GetEdgeNum());
|
||
int nTestBit=0x01;
|
||
nTestBit <<= idx;
|
||
if(!bHasRail)
|
||
m_nRailEdge |= nTestBit;
|
||
else
|
||
m_nRailEdge &= ~nTestBit;
|
||
}
|
||
|
||
double
|
||
TDbBalcony::GetElevation() const
|
||
{
|
||
assertReadEnabled();
|
||
double nElev=0;
|
||
if(!!m_polyOutline)
|
||
nElev=m_polyOutline[0].z;
|
||
return nElev;
|
||
}
|
||
|
||
void
|
||
TDbBalcony::SetElevation(double nElev)
|
||
{
|
||
assertWriteEnabled();
|
||
m_polyOutline.SetElevation(nElev);
|
||
}
|
||
|
||
|
||
void
|
||
TDbBalcony::SetSlabThickness(double val)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nSlabThickness = val;
|
||
}
|
||
|
||
void
|
||
TDbBalcony::SetGirderThickness(double val)
|
||
{
|
||
assertWriteEnabled();
|
||
m_nGirderThickness = val;
|
||
}
|
||
BOOL TDbBalcony::GetPolyIn(XPoly2D&poly)const
|
||
{
|
||
XPoly2D polyNext(1),polyCur(1);
|
||
polyCur=m_polyOutline;
|
||
if(Offset(polyCur, polyNext))
|
||
{
|
||
poly=polyNext;
|
||
return TRUE;
|
||
}
|
||
return FALSE;
|
||
}
|
||
// From TDbPolyPathEnt
|
||
Acad::ErrorStatus
|
||
TDbBalcony::GetBindPath(XPoly2D &polyPath,AcGeVector3d &normal) const
|
||
{
|
||
assertReadEnabled();
|
||
XPoly2D poly1;
|
||
GetPathPoly(poly1,normal);
|
||
poly1.Offset(-m_nRailWidth/2, polyPath);
|
||
return Acad::eOk;
|
||
}
|
||
Acad::ErrorStatus
|
||
TDbBalcony::GetPathPoly(XPoly2D &polyPath,AcGeVector3d &normal) const
|
||
{
|
||
assertReadEnabled();
|
||
normal=AcGeVector3d::kZAxis;
|
||
polyPath=m_polyOutline;
|
||
return Acad::eOk;
|
||
}
|
||
|
||
// sg add 100722,支持统一标高
|
||
bool TDbBalcony::UnifyElevation(double dElevation)
|
||
{
|
||
TGGePoly2D pathPoly;
|
||
pathPoly = GetOutline();
|
||
|
||
pathPoly.SetElevation(dElevation);
|
||
|
||
SetOutline(pathPoly);
|
||
return true;
|
||
}
|
||
|
||
// sg add 101119,支持导出XML
|
||
CString TDbBalcony::GetXml(const AcGeMatrix3d& mat) const
|
||
{
|
||
TXmlTree xmlTree;
|
||
POSITION posRoot = xmlTree.Insert(_T("ATS_BALCONY"), NULL, NULL);
|
||
{
|
||
xmlTree.SetAttribute(posRoot, _T("name"), _T("阳台"));
|
||
xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称"));
|
||
}
|
||
|
||
CString strText;
|
||
POSITION posItem = NULL;
|
||
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 posItem2 = xmlTree.Insert(_T("Section"), posRoot, posItem1);
|
||
{
|
||
xmlTree.SetAttribute(posItem2, _T("name"), _T("截面参数"));
|
||
POSITION posItemBalHeight = xmlTree.Insert(_T("Bal_height"), posItem2, NULL);
|
||
{
|
||
xmlTree.SetAttribute(posItemBalHeight, _T("name"), _T("栏板高"));
|
||
xmlTree.SetAttribute(posItemBalHeight, _T("comment"), _T("从阳台地面算的栏板高"));
|
||
strText.Format(_T("%f"), GetRailHeight());
|
||
xmlTree.SetItemText(posItemBalHeight, strText);
|
||
}
|
||
|
||
POSITION posItemBalWidth = xmlTree.Insert(_T("Bal_width"), posItem2, posItemBalHeight);
|
||
{
|
||
xmlTree.SetAttribute(posItemBalWidth, _T("name"), _T("栏板宽"));
|
||
xmlTree.SetAttribute(posItemBalWidth, _T("comment"), _T("从阳台外边算的栏板宽"));
|
||
strText.Format(_T("%f"), GetRailWidth());
|
||
xmlTree.SetItemText(posItemBalWidth, strText);
|
||
}
|
||
|
||
POSITION posItemFlrHeight = xmlTree.Insert(_T("Flr_height"), posItem2, posItemBalWidth);
|
||
{
|
||
xmlTree.SetAttribute(posItemFlrHeight, _T("name"), _T("地面标高"));
|
||
xmlTree.SetAttribute(posItemFlrHeight, _T("comment"), _T("阳台地面与楼面的相对标高"));
|
||
strText.Format(_T("%f"), GetElevation());
|
||
xmlTree.SetItemText(posItemFlrHeight, strText);
|
||
}
|
||
|
||
POSITION posItemFlrThick = xmlTree.Insert(_T("Flr_thick"), posItem2, posItemFlrHeight);
|
||
{
|
||
xmlTree.SetAttribute(posItemFlrThick, _T("name"), _T("阳台板厚"));
|
||
xmlTree.SetAttribute(posItemFlrThick, _T("comment"), _T("阳台板厚"));
|
||
strText.Format(_T("%f"), GetSlabThickness());
|
||
xmlTree.SetItemText(posItemFlrThick, strText);
|
||
}
|
||
|
||
POSITION posItemBmHeight = xmlTree.Insert(_T("Bm_height"), posItem2, posItemFlrThick);
|
||
{
|
||
xmlTree.SetAttribute(posItemBmHeight, _T("name"), _T("阳台梁高"));
|
||
xmlTree.SetAttribute(posItemBmHeight, _T("comment"), _T("阳台梁高"));
|
||
strText.Format(_T("%f"), GetGirderThickness());
|
||
xmlTree.SetItemText(posItemBmHeight, strText);
|
||
}
|
||
}
|
||
|
||
POSITION posItem3 = xmlTree.Insert(_T("Baseline"), posRoot, posItem2);
|
||
{
|
||
xmlTree.SetAttribute(posItem3, _T("name"), _T("截面参数"));
|
||
posItem = NULL;
|
||
TADSGePoint3d ptNode;
|
||
int iLen = m_polyOutline.Length();
|
||
for (int i = 0; i < iLen; i++)
|
||
{
|
||
ptNode = m_polyOutline[i];
|
||
// sg add 120117,对点进行坐标变换
|
||
ptNode.TransformBy(mat);
|
||
|
||
strText.Format(_T("Point_%d"), i + 1);
|
||
posItem = xmlTree.Insert(strText, posItem3, posItem);
|
||
{
|
||
strText.Format(_T("第%d点"), i + 1);
|
||
xmlTree.SetAttribute(posItem, _T("name"), strText);
|
||
strText.Format(_T("%f,%f,%f"), ptNode.x, ptNode.y, ptNode.z);
|
||
xmlTree.SetItemText(posItem, strText);
|
||
}
|
||
|
||
strText.Format(_T("Ang_%d"), i + 1);
|
||
posItem = xmlTree.Insert(strText, posItem3, posItem);
|
||
{
|
||
strText.Format(_T("圆心角%d"), i + 1);
|
||
xmlTree.SetAttribute(posItem, _T("name"), strText);
|
||
strText.Format(_T("%f"), m_polyOutline.GetBulge(i));
|
||
xmlTree.SetItemText(posItem, strText);
|
||
}
|
||
|
||
int nSign = -1;
|
||
if (HasRailAt(i))
|
||
nSign = 1;
|
||
else
|
||
nSign = 0;
|
||
strText.Format(_T("Show_%d"), i + 1);
|
||
posItem = xmlTree.Insert(strText, posItem3, posItem);
|
||
{
|
||
strText.Format(_T("点%d是否显示"), i + 1);
|
||
xmlTree.SetAttribute(posItem, _T("name"), strText);
|
||
strText.Format(_T("%d"), nSign);
|
||
xmlTree.SetItemText(posItem, strText);
|
||
}
|
||
}
|
||
}
|
||
|
||
POSITION posItem4 = xmlTree.Insert(_T("Ground_Layer"), posRoot, posItem3);
|
||
{
|
||
xmlTree.SetAttribute(posItem4, _T("name"), _T("地板图层"));
|
||
//xmlTree.SetAttribute(posItem4, _T("comment"), _T("当前对象的句柄"));
|
||
AcDbObjectId idGroundLayer = GetLayerGround3d();
|
||
AcDbLayerTableRecord * pLayer = NULL;
|
||
acdbOpenObject(pLayer, idGroundLayer, AcDb::kForRead);
|
||
if (pLayer != NULL)
|
||
{
|
||
TCHAR *pLayerName = NULL;
|
||
pLayer->getName(pLayerName);
|
||
strText = pLayerName;
|
||
pLayer->close();
|
||
}
|
||
xmlTree.SetItemText(posItem4, strText);
|
||
}
|
||
|
||
CString strBase = TEntityBase::GetXml(mat);
|
||
CString strXml = xmlTree.GetXml();
|
||
int nIndex = strXml.Find(_T("<Object_ID"));
|
||
if (nIndex != -1)
|
||
{
|
||
strXml.Insert(nIndex, strBase);
|
||
}
|
||
|
||
return strXml;
|
||
}
|
||
|
||
// Acad::ErrorStatus
|
||
//TDbBalcony::GetPathPoly(XPoly2D &polyPath,AcGeVector3d &normal) const
|
||
//{
|
||
// assertReadEnabled();
|
||
// normal=AcGeVector3d::kZAxis;
|
||
//
|
||
// polyPath.Reset();
|
||
// polyPath.flag=0;
|
||
// int nEdgeNum=GetEdgeNum();
|
||
// ASSERT(nEdgeNum);
|
||
// for(int n=0; n<nEdgeNum; n++) {
|
||
// if(HasRailAt(n)) {
|
||
// XDirectionCurve cv;
|
||
// m_polyOutline.Nth(n, cv);
|
||
// polyPath.AppendNode(cv.StartPoint(), cv.bulge);
|
||
// } else if(polyPath.Length()) {
|
||
// polyPath.AppendNode(m_polyOutline[n]);
|
||
// break;
|
||
// }
|
||
// }
|
||
// // 0~n段都已经完成
|
||
//
|
||
// if(n==nEdgeNum)
|
||
// polyPath.AppendNode(m_polyOutline[0]);
|
||
// else if(HasRailAt(0) && n<nEdgeNum-1) {
|
||
// for(int i=-1; i>n-nEdgeNum; i--) {
|
||
// if(HasRailAt(DePeriod(nEdgeNum, i))) {
|
||
// XDirectionCurve cv;
|
||
// m_polyOutline.Nth(n, cv);
|
||
// polyPath[0];
|
||
// polyPath.bulges[0];
|
||
// polyPath.Insert(new XPoint(cv.StartPoint()));
|
||
// polyPath.bulges.Insert(new double(cv.bulge));
|
||
// } else {
|
||
// break;
|
||
// }
|
||
// }
|
||
// }
|
||
//
|
||
// return Acad::eOk;
|
||
//}
|
||
|
||
void InitDbBalcony(BOOL bTrue)
|
||
{
|
||
AecObjectEditMethod pOldEdit=NULL;
|
||
if(bTrue) {
|
||
TDbBalcony::rxInit();
|
||
acrxBuildClassHierarchy();
|
||
TDbBalcony::InitMatchProtocol(TRUE);
|
||
pOldEdit=TDbBalcony::SetEditMethod(EditBalcony0);
|
||
} else {
|
||
TDbBalcony::InitMatchProtocol(FALSE);
|
||
TDbBalcony::SetEditMethod(pOldEdit);
|
||
deleteAcRxClass(TDbBalcony::desc());
|
||
}
|
||
}
|
||
|
||
// Command:编辑阳台
|
||
int EditBalcony0(AcDbObjectId id)
|
||
{
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, TDbBalcony, pStep);
|
||
if(!pStep)
|
||
return RTERROR;
|
||
while(1) {
|
||
const TCHAR *szPrompt1=_T("\n选择 [拦板宽(W)/拦板高(H)/阳台地高(T)/梁高(G)/地板厚(S)/参数列表(L)]<退出>:");
|
||
XString sKeyword;
|
||
int nRet=0;
|
||
INITGET_BEG(0, _T("W H T G S L"));
|
||
nRet=ads_getkword(szPrompt1, sKeyword);
|
||
INITGET_END();
|
||
|
||
if(nRet!=RTNORM)
|
||
break;
|
||
if(sKeyword[0]==_T('W')) {
|
||
double nRailWidth=pStep->GetRailWidth();
|
||
nRet=GetReal(_T("\n拦板宽"), nRailWidth);
|
||
if(nRet==RTCAN)
|
||
break;
|
||
if(nRet==RTNORM) {
|
||
if(pStep->upgradeOpen()!=Acad::eOk)
|
||
return RTERROR;
|
||
pStep->assertWriteEnabled();
|
||
pStep->SetRailWidth(nRailWidth);
|
||
pStep->downgradeOpen();
|
||
}
|
||
} else if(sKeyword[0]==_T('H')) {
|
||
double nRailHeight=pStep->GetRailHeight();
|
||
nRet=GetReal(_T("\n拦板高"), nRailHeight);
|
||
if(nRet==RTCAN)
|
||
break;
|
||
if(nRet==RTNORM) {
|
||
if(pStep->upgradeOpen()!=Acad::eOk)
|
||
return RTERROR;
|
||
pStep->assertWriteEnabled();
|
||
pStep->SetRailHeight(nRailHeight);
|
||
pStep->downgradeOpen();
|
||
}
|
||
} else if(sKeyword[0]==_T('T')) {
|
||
double nElev=fabs(pStep->GetElevation());
|
||
nRet=GetReal(_T("\n地面高差"), nElev, RSG_NONEG);
|
||
if(nRet==RTCAN)
|
||
break;
|
||
if(nRet==RTNORM) {
|
||
if(pStep->upgradeOpen()!=Acad::eOk)
|
||
return RTERROR;
|
||
pStep->assertWriteEnabled();
|
||
pStep->SetElevation(-nElev);
|
||
pStep->downgradeOpen();
|
||
}
|
||
} else if(sKeyword[0]==_T('L')) {
|
||
pStep->list();
|
||
} else if(sKeyword[0]==_T('G')) {
|
||
double nVal=pStep->GetGirderThickness();
|
||
nRet=GetReal(_T("\n梁高"), nVal);
|
||
if(nRet==RTCAN)
|
||
break;
|
||
if(nRet==RTNORM) {
|
||
if(pStep->upgradeOpen()!=Acad::eOk)
|
||
return RTERROR;
|
||
pStep->assertWriteEnabled();
|
||
pStep->SetGirderThickness(nVal);
|
||
pStep->downgradeOpen();
|
||
}
|
||
} else if(sKeyword[0]==_T('S')) {
|
||
double nVal=pStep->GetSlabThickness();
|
||
nRet=GetReal(_T("\n阳台板厚"), nVal);
|
||
if(nRet==RTCAN)
|
||
break;
|
||
if(nRet==RTNORM) {
|
||
if(pStep->upgradeOpen()!=Acad::eOk)
|
||
return RTERROR;
|
||
pStep->assertWriteEnabled();
|
||
pStep->SetSlabThickness(nVal);
|
||
pStep->downgradeOpen();
|
||
}
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
|
||
return RTNORM;
|
||
}
|
||
|
||
//add by xlc on 110218 阳台遮挡保温
|
||
bool TDbBalcony::IsBalconyClipInsu() const
|
||
{
|
||
return (m_nFlag & BF_BALCONYCLIPINSU) != 0;
|
||
}
|
||
|
||
void TDbBalcony::SetBalconyClipInsu(BOOL bTrue)
|
||
{
|
||
assertWriteEnabled();
|
||
if(bTrue)
|
||
{
|
||
m_nFlag |= BF_BALCONYCLIPINSU;
|
||
}
|
||
else
|
||
{
|
||
m_nFlag &= ~BF_BALCONYCLIPINSU;
|
||
}
|
||
}
|
||
|
||
AcDbEntity* TDbBalcony::CreateWipeOut() const
|
||
{
|
||
//modify by xlc on 110519 调整阳台遮挡保温算法
|
||
return NULL;
|
||
|
||
bool bBalconyClipInsu = false;
|
||
if(IsBalconyClipInsu())
|
||
{
|
||
for (long i = 0; i < m_lstClipId.Length(); i++)
|
||
{
|
||
const AcDbObjectId &id = m_lstClipId[i];
|
||
if (id.isNull() || !id.isValid())
|
||
{
|
||
continue;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEnt);
|
||
if (pEnt->isKindOf(TDbWall::desc()))
|
||
{
|
||
int nWallFlag = ((TDbWall*)pEnt)->GetWallFlag();
|
||
if ((nWallFlag & WF_LEFT_INSULATE) || (nWallFlag & WF_RIGHT_INSULATE))
|
||
{
|
||
bBalconyClipInsu = true;
|
||
break;
|
||
}
|
||
}
|
||
else if (pEnt->isKindOf(TDbColumn::desc()))
|
||
{
|
||
bool bHasInsl = ((TDbColumn*)pEnt)->IsInsulateOnColumn();
|
||
double dInsThk = ((TDbColumn*)pEnt)->GetInsulateThick();
|
||
if (bHasInsl && dInsThk >= 1.e-3) //这里精度与柱子绘制精度保持一致
|
||
{
|
||
bBalconyClipInsu = true;
|
||
break;
|
||
}
|
||
}
|
||
else if(pEnt->isKindOf(TDbWallPatch::desc()))
|
||
{
|
||
BOOL bHasInsl = ((TDbWallPatch*)pEnt)->HasInsulate();
|
||
double dInsThk = ((TDbWallPatch*)pEnt)->GetInsulateThick();
|
||
if (bHasInsl && dInsThk >= 1.E-5) //这里精度与墙体造型绘制精度保持一致
|
||
{
|
||
bBalconyClipInsu = true;
|
||
break;
|
||
}
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|
||
|
||
if(bBalconyClipInsu)
|
||
{
|
||
AcDbObjectId idImage=InitWipeout();
|
||
OPENOBJ_BEGIN(idImage, AcDb::kForRead, AcDbEntity, pImage);
|
||
if(pImage)
|
||
{
|
||
return (AcDbEntity *)pImage->clone();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
return NULL;
|
||
}
|
||
|
||
|
||
AcDbObjectId TDbBalcony::InitWipeout() const
|
||
{
|
||
#if (ADS<16)
|
||
if(!AT_loaded(_T("wipeout"))) {
|
||
int nRet=acrxLoadModule(_T("wipeout.arx"), Adesk::kFalse, true);
|
||
if(!nRet) {
|
||
adsout << _T("\n请事先安装AutoCAD快捷工具!");
|
||
return FALSE;
|
||
}
|
||
}
|
||
//LH 2013-2-27 修改原因当ADS=19时不执行下面代码
|
||
//#else if (ADS<19)
|
||
#endif
|
||
#if (16<ADS && ADS<19)
|
||
if(!AT_loaded(_T("AcWipeout"))) {
|
||
int nRet=acrxLoadModule(_T("AcWipeout.arx"), Adesk::kFalse, true);
|
||
if(!nRet) {
|
||
adsout << _T("\n无法加载AcWipeout.arx!");
|
||
return FALSE;
|
||
}
|
||
}
|
||
#endif
|
||
//LH 2013-2-28 由于AutoCAD2013版本后去除了AcWipeout.arx文件,所以2013版本需要判断是否加载了acismobj19.dbx
|
||
#if (ADS==19)
|
||
if(!AT_loaded(_T("acismobj19")))
|
||
{
|
||
int nRet=acrxLoadModule(_T("acismobj19.dbx"), Adesk::kFalse, true);
|
||
if(!nRet) {
|
||
adsout << _T("\n无法加载acismobj19.dbx!");
|
||
return FALSE;
|
||
}
|
||
}
|
||
#endif
|
||
#if (ADS==20)
|
||
if(!AT_loaded(_T("acismobj20")))
|
||
{
|
||
int nRet=acrxLoadModule(_T("acismobj20.dbx"), Adesk::kFalse, true);
|
||
if(!nRet) {
|
||
adsout << _T("\n无法加载acismobj20.dbx!");
|
||
return FALSE;
|
||
}
|
||
}
|
||
#endif
|
||
AcRxClass* pClass = AcRxClass::cast(acrxClassDictionary->at(_T("AcDbWipeout")));
|
||
if (pClass == NULL)
|
||
{
|
||
return FALSE;
|
||
}
|
||
|
||
BOOL bFirstNew=FALSE;
|
||
AcDbObjectId idEnt=GetTempEntityId(pClass, _T("_$TMP_BLOCK"), &bFirstNew);
|
||
OPENOBJ_BEGIN(idEnt, AcDb::kForWrite, AcDbRasterImage, pAcDbRasterImage);
|
||
if(pAcDbRasterImage)
|
||
{
|
||
if(bFirstNew)
|
||
{
|
||
pAcDbRasterImage->setDatabaseDefaults();
|
||
}
|
||
SetupImageInfo(pAcDbRasterImage);
|
||
}
|
||
OPENOBJ_END();
|
||
return idEnt;
|
||
}
|
||
|
||
void TDbBalcony::SetupImageInfo(AcDbRasterImage *pAcDbRasterImage) const
|
||
{
|
||
XPoly2D polyCur(1);
|
||
polyCur=m_polyOutline;
|
||
polyCur.SetElevation(0.0);
|
||
|
||
XPoly2D polyNext(1);
|
||
if(!Offset(polyCur, polyNext))
|
||
{
|
||
return;
|
||
}
|
||
|
||
int nEdge=GetEdgeNum();
|
||
TGGePoly2D poly(1);
|
||
TDPtrList<TGGeCurveSegment> lstCurves;
|
||
bool bFirst = true;
|
||
TGGePoly2D poly1,poly2;
|
||
double dLength = _AS_SYS_UNIT(10);
|
||
for(int i=0; i<nEdge; i++)
|
||
{
|
||
if(!HasRailAt(i))
|
||
continue;
|
||
XCurveSegment seg1, seg2;
|
||
polyCur.Nth(i, seg1);
|
||
polyNext.Nth(i, seg2);
|
||
|
||
//modify by xlc on 110314 优化阳台遮挡保温算法
|
||
//lstCurves.Append(new TGGeCurveSegment(seg1));
|
||
//lstCurves.Append(new TGGeCurveSegment(seg2));
|
||
//XPoint ptE =seg1.EndPoint();
|
||
//if (bFirst)
|
||
//{
|
||
// TADSGePointDir2d ptDir;
|
||
// seg1.Polar(dLength, ptDir);
|
||
// poly.InsertNodeAt(0, ptDir);
|
||
//}
|
||
//poly.InsertNodeAt(0, ptE);
|
||
|
||
//ptE =seg2.EndPoint();
|
||
//if (bFirst)
|
||
//{
|
||
// TADSGePointDir2d ptDir;
|
||
// seg2.Polar(dLength, ptDir);
|
||
// poly.AppendNode(ptDir);
|
||
//}
|
||
//else
|
||
//{
|
||
// bFirst = false;
|
||
//}
|
||
//poly.AppendNode(ptE);
|
||
if (bFirst)
|
||
{
|
||
poly1.AppendNode(*polyCur[i],polyCur.GetBulge(i));
|
||
}
|
||
poly1.AppendNode(*polyCur[i+1],polyCur.GetBulge(i+1));
|
||
|
||
if (bFirst)
|
||
{
|
||
poly2.AppendNode(*polyNext[i],polyNext.GetBulge(i));
|
||
bFirst = false;
|
||
}
|
||
poly2.AppendNode(*polyNext[i+1],polyNext.GetBulge(i+1));
|
||
}
|
||
|
||
TDPtrList<TGGePoly2D> lstTemp;
|
||
for (i = 0; i < m_lstClipId.Length(); i++)
|
||
{
|
||
const AcDbObjectId &id = m_lstClipId[i];
|
||
if (id.isNull() || !id.isValid())
|
||
{
|
||
continue;
|
||
}
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
acdbOpenObject(pEnt,id,AcDb::kForRead);
|
||
|
||
if (pEnt != NULL)
|
||
{
|
||
bool bAddPoly = false;
|
||
double dThick = 0;
|
||
TGGePoly2D polyOut;
|
||
if (pEnt->isKindOf(TDbWall::desc()))
|
||
{
|
||
bAddPoly = true;
|
||
((TDbWall*)pEnt)->GetOutlinePoly(0, polyOut);
|
||
|
||
int nWallFlag = ((TDbWall*)pEnt)->GetWallFlag();
|
||
if ((nWallFlag & WF_LEFT_INSULATE) || (nWallFlag & WF_RIGHT_INSULATE))
|
||
{
|
||
double dThick0 = ((TDbWall*)pEnt)->GetInsulateThick(0);
|
||
double dThick1 = ((TDbWall*)pEnt)->GetInsulateThick(1);
|
||
dThick = dThick0;
|
||
if (dThick > dThick1)
|
||
{
|
||
dThick = dThick1;
|
||
}
|
||
}
|
||
}
|
||
else if (pEnt->isKindOf(TDbColumn::desc()))
|
||
{
|
||
bAddPoly = true;
|
||
polyOut=((TDbColumn*)pEnt)->GetOutlinePoly();
|
||
|
||
bool bHasInsl = ((TDbColumn*)pEnt)->IsInsulateOnColumn();
|
||
double dInsThk = ((TDbColumn*)pEnt)->GetInsulateThick();
|
||
if (bHasInsl && dInsThk >= 1.e-3) //这里精度与柱子绘制精度保持一致
|
||
{
|
||
dThick = dInsThk;
|
||
}
|
||
|
||
}
|
||
else if(pEnt->isKindOf(TDbWallPatch::desc()))
|
||
{
|
||
bAddPoly = true;
|
||
((TDbWallPatch*)pEnt)->GetOutlinePoly(polyOut, false);
|
||
BOOL bHasInsl = ((TDbWallPatch*)pEnt)->HasInsulate();
|
||
double dInsThk = ((TDbWallPatch*)pEnt)->GetInsulateThick();
|
||
if (bHasInsl && dInsThk >= 1.E-5) //这里精度与墙体造型绘制精度保持一致
|
||
{
|
||
dThick = dInsThk;
|
||
}
|
||
}
|
||
|
||
if (bAddPoly)
|
||
{
|
||
if (dThick > dLength)
|
||
{
|
||
dThick = dLength;
|
||
}
|
||
else
|
||
{
|
||
dThick *= 0.5;
|
||
}
|
||
|
||
GetOffsetPoly2D(polyOut,polyOut,dThick);
|
||
lstTemp.Append(new TGGePoly2D(polyOut));
|
||
}
|
||
pEnt->close();
|
||
}
|
||
}
|
||
|
||
for (i = 0; i < poly1.Length(); i++)
|
||
{
|
||
poly.AppendNode(*poly1[i],poly1.GetBulge(i));
|
||
}
|
||
poly2.Reverse();
|
||
for (i = 0; i < poly2.Length(); i++)
|
||
{
|
||
poly.AppendNode(*poly2[i],poly2.GetBulge(i));
|
||
}
|
||
poly.Compress();
|
||
|
||
TDPtrList<TGGePoly2D> lstBal,lstRes;
|
||
lstBal.Append(new TGGePoly2D(poly));
|
||
Subtract(lstBal, lstTemp, lstRes);
|
||
|
||
if (lstRes.Length()>0)
|
||
{
|
||
poly = *lstRes[0];
|
||
}
|
||
else
|
||
{
|
||
poly.Reset();
|
||
}
|
||
|
||
if(poly.Length() > 3)
|
||
{
|
||
//if (lstCurves.Length() >= 2)
|
||
{
|
||
//modify by xlc on 110314 优化阳台遮挡保温算法
|
||
//TGGeCurveSegment &cvSeg = *lstCurves[lstCurves.Length()-2];
|
||
//TADSGePointDir2d ptDir;
|
||
//cvSeg.Polar(cvSeg.GetLength()-dLength, ptDir, 1);
|
||
//poly.RemoveNode(0);
|
||
//poly.InsertNodeAt(0, ptDir);
|
||
|
||
//TGGeCurveSegment &cvSeg1 = *lstCurves[lstCurves.Length()-1];
|
||
//cvSeg1.Polar(cvSeg1.GetLength()-dLength, ptDir, 1);
|
||
//poly.RemoveNode(poly.Length()-1);
|
||
//poly.AppendNode(ptDir);
|
||
|
||
pAcDbRasterImage->setClipBoundaryToWholeImage();
|
||
|
||
AcGeMatrix3d matPixelToModel, matModelToPixel;
|
||
pAcDbRasterImage->getPixelToModelTransform(matPixelToModel);
|
||
matModelToPixel = matPixelToModel.invert();
|
||
|
||
AcGePoint2dArray ptArray;
|
||
AcGePoint3d pt;
|
||
for(i = 0; i < poly.Length(); i++)
|
||
{
|
||
pt = poly[i]->AsAcGePoint3d();
|
||
pt = pt.transformBy(matModelToPixel);
|
||
ptArray.append(AcGePoint2d(pt.x,pt.y));
|
||
}
|
||
pt = poly[0]->AsAcGePoint3d();
|
||
pt = pt.transformBy(matModelToPixel);
|
||
ptArray.append(AcGePoint2d(pt.x,pt.y));
|
||
|
||
pAcDbRasterImage->setClipBoundary( AcDbRasterImage::kPoly, ptArray);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
bool TDbBalcony::OnExplodeOrDraw(TGGiDrawStreamBase& dc)const
|
||
{
|
||
for (long i = 0; i < m_lstClipId.Length(); i++)
|
||
{
|
||
const AcDbObjectId &id = m_lstClipId[i];
|
||
if (id.isNull() || !id.isValid())
|
||
{
|
||
continue;
|
||
}
|
||
|
||
AcDbEntity *pEnt = NULL;
|
||
acdbOpenObject(pEnt,id,AcDb::kForRead);
|
||
|
||
if (pEnt != NULL)
|
||
{
|
||
TEntityBase* pEntBase = TEntityBase::Cast(pEnt);
|
||
if (pEntBase != NULL)
|
||
{
|
||
TGGePoly2D poly;
|
||
|
||
bool bBalconyClipInsu = false;
|
||
if (IsBalconyClipInsu())
|
||
{
|
||
if (pEnt->isKindOf(TDbWall::desc()))
|
||
{
|
||
int nWallFlag = ((TDbWall*)pEnt)->GetWallFlag();
|
||
if ((nWallFlag & WF_LEFT_INSULATE) || (nWallFlag & WF_RIGHT_INSULATE))
|
||
{
|
||
bBalconyClipInsu = true;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (bBalconyClipInsu)
|
||
{
|
||
((TDbWall*)pEnt)->GetOutlinePoly(0, poly);
|
||
poly.SetElevation(0);
|
||
dc.PushClip(poly,TGGiClipBoundary::kClipIn);
|
||
}
|
||
else if (pEntBase->GetClipBoundary(poly) == Acad::eOk)
|
||
{
|
||
poly.SetElevation(0);
|
||
|
||
if (pEnt->isKindOf(TDbSymbCut::desc()))
|
||
{
|
||
TDbSymbCut* pCut = TDbSymbCut::cast(pEnt);
|
||
dc.PushClip(poly,pCut->GetClipType());
|
||
}
|
||
|
||
else if (pEnt->isKindOf(TDbColumn::desc()))
|
||
{
|
||
bool bHasInsl = ((TDbColumn*)pEnt)->IsInsulateOnColumn();
|
||
double dInsThk = ((TDbColumn*)pEnt)->GetInsulateThick();
|
||
if (!IsBalconyClipInsu() && bHasInsl && dInsThk >= 1.e-3) //这里精度与柱子绘制精度保持一致
|
||
{
|
||
poly = ((TDbColumn*)pEnt)->GetOutlinePoly();
|
||
GetOffsetPoly2D(poly, poly, dInsThk);
|
||
|
||
}
|
||
poly.SetElevation(0);
|
||
dc.PushClip(poly,TGGiClipBoundary::kClipIn);
|
||
}
|
||
else if(pEnt->isKindOf(TDbWallPatch::desc()))
|
||
{
|
||
BOOL bHasInsl = ((TDbWallPatch*)pEnt)->HasInsulate();
|
||
double dInsThk = ((TDbWallPatch*)pEnt)->GetInsulateThick();
|
||
if (!IsBalconyClipInsu() && bHasInsl && dInsThk >= 1.E-5) //这里精度与墙体造型绘制精度保持一致
|
||
{
|
||
((TDbWallPatch*)pEnt)->GetOutlinePoly(poly, TRUE);
|
||
}
|
||
|
||
poly.SetElevation(0);
|
||
dc.PushClip(poly,TGGiClipBoundary::kClipIn);
|
||
}
|
||
|
||
else
|
||
{
|
||
dc.PushClip(poly,TGGiClipBoundary::kClipIn);
|
||
}
|
||
}
|
||
}
|
||
|
||
pEnt->close();
|
||
}
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
// sg add 110614,设置与阳台相关联的墙体、造型、柱子对象更新
|
||
void TDbBalcony::UpdateClipEntity() const
|
||
{
|
||
int nLength = (int)m_lstClipId.Length();
|
||
for (long i = 0; i < nLength; i++)
|
||
{
|
||
const AcDbObjectId &id = m_lstClipId[i];
|
||
if (id.isNull() || !id.isValid())
|
||
{
|
||
continue;
|
||
}
|
||
|
||
OPENOBJ_BEGIN(id, AcDb::kForWrite, AcDbEntity, pEnt);
|
||
if (pEnt != NULL)
|
||
{
|
||
pEnt->recordGraphicsModified();
|
||
}
|
||
OPENOBJ_END();
|
||
}
|
||
}
|