#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 lstEdgeFlag; for(int n=0; nerrorsFixed(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;ireadItem(&idWall); m_lstWallId.Append(new AcDbSoftPointerId(idWall)); } pFiler->readItem(&m_idHouse); m_lstWinId.Reset(); num = 0; pFiler->readItem(&num); for(i=0;ireadItem(&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;iwriteItem(m_lstWallId[i]); pFiler->writeItem(m_idHouse); num=m_lstWinId.Length(); pFiler->writeItem(num); for(i=0;iwriteItem(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 pts; DList 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; ifilerStatus(); } 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; iwritePoint2d(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; iTransformBy(mat); //以第一个顶点的z坐标为基准 if(i==0) { nElev = pt->z; } else { pt->z = nElev; } } if(IsMirrorMatrix(mat)) { for(int m=0; m0) { m_polyOutline.Reverse(); int nEdgeNum=GetEdgeNum(); DList lstEdgeFlag; for(int n=0; n=0 && nPrev=0 && nNext1.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=0 && nPrev0) { m_polyOutline.Reverse(); int nEdgeNum=GetEdgeNum(); DList lstEdgeFlag; for(int n=0; n15 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 lstEdgeFlag; for(int n=0; n0) TchPrivate::Exchange(polyIn, polyOut); DList 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_DIST_SNAP) { seg1.SetElevation(nOutElev); dc.DrawCurve(seg1, vt.z); } } for(int ii=0; ii()); //栏板顶面 rPoly.SetElevation(GetElevation()-GetGirderThickness()); if(HasGirder()) dc.DrawShell(rPoly, DList()); //封梁底 //dc.DrawMesh(rPoly, vt); //封梁侧面 } TMasterProperties prop; dc.BackUpProperties(prop); dc.SetColorLayer(colorIndex(), m_idLayerGround3d); dc.DrawShell(polyIn, DList()); //阳台地面 polyIn.SetElevation(GetElevation()-GetSlabThickness()); dc.DrawShell(HasGirder()? polyIn : polyOut, DList()); //阳台底面 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 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 lstCurves; // bool bFirst = true; // TGGePoly2D poly1,poly2; // for(int i=0; i 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<subEntityTraits().setFillType(nFillType); // dcCommon->subEntityTraits().setTrueColor(cmColor); // } // } // } // if (bBalconyClipInsu) // { // dc << lstCurves; // } int nEdge=GetEdgeNum(); for(int i=0; i &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=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(idxgetName(pLayerName); strText = pLayerName; pLayer->close(); } xmlTree.SetItemText(posItem4, strText); } CString strBase = TEntityBase::GetXml(mat); CString strXml = xmlTree.GetXml(); int nIndex = strXml.Find(_T("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 (16at(_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 lstCurves; bool bFirst = true; TGGePoly2D poly1,poly2; double dLength = _AS_SYS_UNIT(10); for(int i=0; i 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 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(); } }