#include "stdafx.h" #include "TDbColumn.h" #include "slab_xdata_key.h" ///////////////////////////////////////////////////////////// // 屋顶对象类 ///////////////////////////////////////////////////////////// // ver:1-TArch5; 2-TArch6 const Adesk::UInt8 TDbSlab::g_nVersion = 2; ACRX_DXF_DEFINE_MEMBERS(ATSSlab, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, ATS_SLAB, "ATS_SLAB图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com"); IMPLEMENT_TENTBASE(TDbSlab); TDbSlab::TDbSlab() :m_polyOutline(1), m_nInvisibleEdge(0), m_vtNormal(0,0,1) { m_nThickness=0; } TDbSlab::~TDbSlab() { } BOOL TDbSlab::IsValid() const { BOOL bRet=TDbEntity::IsValid(); if(!bRet) return bRet; bRet=(m_polyOutline.Length()>1 && m_polyOutline.IsClosed()); return bRet; } Acad::ErrorStatus TDbSlab::subGetClassID(CLSID* pClsid) const { return Acad::eOk; } // 提供对格式刷的支持 void TDbSlab::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag) { assertWriteEnabled(); TDbEntity::CopyPropertiesFrom(pSrcEntity, gMatchFlag); TDbSlab *pSrc=TDbSlab::cast(pSrcEntity); if(pSrc) { m_nThickness=pSrc->m_nThickness; //<0, 则基准面在顶部 } } Acad::ErrorStatus TDbSlab::DownGradeSave(int nDrawMode, AcDbVoidPtrArray &entSet, BOOL *bErase) { if(g_nSaveTArchVer==5) { Acad::ErrorStatus es=Acad::eOk; if(m_vtNormal.AsAcGeVector3d()!=AcGeVector3d(0,0,1)) { assertWriteEnabled(); _SetNormal(m_vtNormal); } } return TDbEntity::DownGradeSave(nDrawMode,entSet,bErase); } Acad::ErrorStatus TDbSlab::GetPathPoly(XPoly2D&poly,AcGeVector3d&normal)const { assertReadEnabled(); poly=m_polyOutline; normal=m_vtNormal.AsAcGeVector3d(); return Acad::eOk; } Acad::ErrorStatus TDbSlab::SetPathPoly(const XPoly2D&poly,const AcGeVector3d&normal) { assertWriteEnabled(); m_polyOutline=poly; if(m_polyOutline.PathArea()>0) m_polyOutline.Reverse(); m_vtNormal=normal; return Acad::eOk; } // 从DWG读入数据: Acad::ErrorStatus TDbSlab::dwgInFields (AcDbDwgFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = TDbEntity::dwgInFields(pFiler); if(es != Acad::eOk) return es; Adesk::UInt8 nVer; pFiler->readItem(&nVer); if(nVer>g_nVersion) {// Version is too new return Acad::eMakeMeProxy; } pFiler->readItem(&m_nThickness); pFiler->readItem(&m_nInvisibleEdge); double nElev=0.0; pFiler->readItem(&nElev); m_polyOutline.Reset(); ReadPoly2D(pFiler, m_polyOutline); m_polyOutline.SetElevation(nElev); m_lstHoles.Reset(); Adesk::UInt16 nHole=0; pFiler->readItem(&nHole); for(Adesk::UInt16 i=0; iSetElevation(nElev); m_lstHoles.Append(pHole); } if(nVer>1) { pFiler->readItem((AcGeVector3d *)&m_vtNormal); } else { m_vtNormal = _GetNormal(); } // pFiler->readItem(&m_idLayerHatch2d); return pFiler->filerStatus(); } Acad::ErrorStatus TDbSlab::dwgOutFields(AcDbDwgFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = TDbEntity::dwgOutFields(pFiler); if(es != Acad::eOk) return es; if(g_nSaveTArchVer==5) pFiler->writeItem((Adesk::UInt8)1); else pFiler->writeItem(g_nVersion); pFiler->writeItem(m_nThickness); pFiler->writeItem(m_nInvisibleEdge); double nElev=0.0; if(!!m_polyOutline) nElev=m_polyOutline[0].z; pFiler->writeItem(nElev); WritePoly2D(pFiler, m_polyOutline); Adesk::UInt16 num=m_lstHoles.Length(); pFiler->writeItem(num); for(Adesk::UInt16 i=0; iwriteItem((const AcGeVector3d &)m_vtNormal); //pFiler->writeItem(m_idLayerHatch2d); return pFiler->filerStatus(); } Acad::ErrorStatus TDbSlab::dxfInFields (AcDbDxfFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler); if(es!=Acad::eOk) return es; if (!pFiler->atSubclassData(_T("TDbSlab"))) { return Acad::eBadDxfSequence; } int fieldsFlags=0; resbuf rb; int n1; double r1=0.0, r2=0.0; 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 149: r2=rb.resval.rreal; fieldsFlags |= 0x02; break; case AcDb::kDxfInt32: n1=rb.resval.rlong; fieldsFlags |= 0x04; break; case AcDb::kDxfXCoord: pts.Append(new XPoint(rb.resval.rpoint)); break; case AcDb::kDxfAngle: bulges.Append(new double(rb.resval.rreal)); break; case 210: m_vtNormal=rb.resval.rpoint; 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(pts.Length()<2 || pts.Length()!=bulges.Length()) { pFiler->setError(_T("\nError DXF group code: 10, 50")); return Acad::eMissingDxfField; } m_nThickness=r2; if(fieldsFlags&0x04) m_nInvisibleEdge=n1; m_polyOutline.Reset(); for(int i=0; ifilerStatus(); } Acad::ErrorStatus TDbSlab::dxfOutFields(AcDbDxfFiler* pFiler) const { assertReadEnabled(); Acad::ErrorStatus es; es = TDbEntity::dxfOutFields(pFiler); assert(es == Acad::eOk); es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbSlab")); assert(es == Acad::eOk); pFiler->writeDouble(148, GetElevation()); pFiler->writeDouble(149, m_nThickness); pFiler->writeInt32(AcDb::kDxfInt32, m_nInvisibleEdge); for(int i=0; iwritePoint2d(AcDb::kDxfXCoord, m_polyOutline[i]); pFiler->writeDouble(AcDb::kDxfAngle, m_polyOutline.GetBulge(i)); } pFiler->writeVector3d(210, m_vtNormal); return pFiler->filerStatus(); } // ----------------------------------------------------------------------- // Overriden functions for edit // to do: // 允许通过夹点改变边界 Acad::ErrorStatus TDbSlab::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { int nEdgeNum=GetEdgeNum(); XVector3D vtNormal=GetNormal(); for(int i=0; i0) { m_polyOutline.Reverse(); int nEdgeNum=GetEdgeNum(); DList lstEdgeFlag; for(int n=0; n0) rHole.Reverse(); } SetNormal(vtNormal); /* ads_matrix mat; memcpy(mat, &xform, sizeof(ads_matrix)); BOOL bMirror=IsMirrorMatrix(mat); double nElev=0.0; for(int i=0; iTransformBy(mat); //以第一个顶点的z坐标为基准 if(i==0) { nElev = pt->z; } else { pt->z = nElev; } } if(bMirror && m_polyOutline.PathArea()>0) { m_polyOutline.Reverse(); int nEdgeNum=GetEdgeNum(); DList lstEdgeFlag; for(int n=0; nTransformBy(mat); //以第一个顶点的z坐标为基准 pt->z = nElev; } if(bMirror && rHole.PathArea()>0) rHole.Reverse(); } */ return Acad::eOk; } void TDbSlab::UnionScale(double nScale) { assertWriteEnabled(); double nOldElev=GetElevation(); TDbEntity::UnionScale(nScale); SetElevation(nOldElev*nScale); m_nThickness*=nScale; } // 功能: 夹点操作 Acad::ErrorStatus TDbSlab::subMoveGripPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset) { assertWriteEnabled(); XPoly2D polyBack(m_polyOutline); //XPoint vtOffset=*(XPoint *)&offset; XVector3D vtNormal=GetNormal(); XPoint vtOffset=Wcs2Ecs(*(XPoint *)&offset, vtNormal); //vtOffset.z=0; int nTotalEdge=GetEdgeNum(); for (int i = 0; i < indices.length(); i++) { int idx = indices[i]; ASSERT(idx<2*nTotalEdge); if(idx=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 && nPrev15 void TDbSlab::CreateGrip() { TDbEntity::CreateGrip(); ::CreateGrip(this,m_polyOutline,0); } Acad::ErrorStatus TDbSlab::EntityToDim(long iGrip,long iDim,const AcDbEntity*pEnt) { TEntityBase *pCurve=TDbSlab::cast(pEnt); if(pCurve==NULL) pCurve=this; XPoly2D polyPath; AcGeVector3d normal; pCurve->GetPathPoly(polyPath,normal); return ::EntityToDim(this,polyPath,iGrip,iDim,0); } Acad::ErrorStatus TDbSlab::DimToEntity(long iGrip,long iDim,double newValue,const AcGeVector3d& offset) { assertWriteEnabled(); TDbSlab curve; curve.CopyPropertiesFrom(this,0); Acad::ErrorStatus es=::DimToEntity(this,m_polyOutline,iGrip,iDim,newValue,offset,0); if(es==Acad::eOk&&!IsValid()) { CopyPropertiesFrom(&curve,0); return Acad::eInvalidInput; } return es; } #endif // 功能: 夹点操作 // 状态: 有待完成修改相关墙体门窗的操作 Acad::ErrorStatus TDbSlab::subMoveStretchPointsAt( const AcDbIntArray& indices, const AcGeVector3d& offset) { int nCount=indices.length(); return subMoveGripPointsAt(indices, offset); } Acad::ErrorStatus TDbSlab::GetExtents2d(XPoint &ptLow, XPoint &ptUp) const { AcGeVector3d vtStd(0,0,1); AcGeVector3d vtNorm; vtNorm=(AcGeVector3d &)GetNormal(); Acad::ErrorStatus es=Acad::eOk; if(vtNorm==vtStd) { XPoly2D poly(m_polyOutline); poly.SetElevation(0.0); poly.GetExtend(ptLow, ptUp); ptLow.z=ptUp.z=0.0; } else { es=TDbEntity::GetExtents2d(ptLow, ptUp); } return es; } Acad::ErrorStatus TDbSlab::GetExtents(XPoint &ptLow, XPoint &ptUp) const { AcGeVector3d vtStd(0,0,1); AcGeVector3d vtNorm; vtNorm=(AcGeVector3d &)GetNormal(); Acad::ErrorStatus es=Acad::eOk; if(vtNorm==vtStd) { XPoly2D poly(m_polyOutline); poly.SetElevation(0.0); poly.GetExtend(ptLow, ptUp); double nThick=GetThickness(); double nElev=GetElevation(); double nElev1=nElev+nThick; ptLow.z=min(nElev, nElev1); ptUp.z=max(nElev, nElev1); } else { es=TDbEntity::GetExtents(ptLow, ptUp); } return es; } Acad::ErrorStatus TDbSlab::ExplodeOrDraw3d(XExplodeDraw &dc) const { assertReadEnabled(); //TPushProperty vProp(this, dc); XVector3D vtNormal=GetNormal(); if(((AcGeVector3d &)vtNormal)!=AcGeVector3d(0,0,1)) { XPoly2D polyOutline(1); m_polyOutline.Disperse1(polyOutline, _AS_SYS_UNIT(g_nCirDeviation)); for(int i=0; i lstHoles; for(i=0; i_DIST_SNAP) dc.DrawBody(polyOutline, lstHoles, vt); else dc.DrawShell(polyOutline, lstHoles); /* dc.DrawShell(polyOutline, lstHoles); if(fabs(m_nThickness)>_DIST_SNAP) { XPoly2D polyUp(polyOutline); for(i=0; i lstHoleUp; for(int n=0; nLength(); j++) { *(*pHole)[j] += vt; } lstHoleUp.Append(pHole); } dc.DrawShell(polyUp, lstHoleUp); dc.DrawMesh(polyOutline, vt); for(i=0; i_DIST_SNAP) dc.DrawBody(m_polyOutline, m_lstHoles, vt); else dc.DrawShell(m_polyOutline, m_lstHoles); /* dc.DrawShell(m_polyOutline, m_lstHoles); if(fabs(m_nThickness)>_DIST_SNAP) { XPoly2D polyUp(m_polyOutline); double nElev = GetElevation()+m_nThickness; polyUp.SetElevation(nElev); DList lstHoleUp; for(int n=0; nSetElevation(nElev); lstHoleUp.Append(pHole); } dc.DrawShell(polyUp, lstHoleUp); dc.DrawMesh(m_polyOutline, vt); for(int i=0; iGetMe()->isKindOf(TDbColumn::desc())) return true; return false; } Acad::ErrorStatus TDbSlab::ExplodeOrDraw2d(XExplodeDraw &dc) const { //TPushProperty vProp(this, dc); XVector3D vt=GetNormal(); if(((AcGeVector3d &)vt)!=AcGeVector3d(0,0,1)) return ExplodeOrDraw3d(dc);//解决平板出现无二维的情况,按三维绘制,add by whl on 041108 int nVisEdge=0; if (_tcscmp(dc.Desc(), TGGiWorldViewportDraw::Descriptor()) == 0 && !ownerId()) { XPoly2D poly1(m_polyOutline); poly1.SetElevation(0.0); for(int i=0; iClipCurveByTrace(dcSrc.m_lstCurves); } } else { XPoly2D polyOutline(m_polyOutline); polyOutline.SetElevation(0.0); AcDbObjectId idOwner=ownerId(); AcDbObjectIdArray railArray; if(!!polyOutline && !!idOwner && TDbHandRail::GetRailsByCP(polyOutline, idOwner, railArray)) { int nCount=railArray.length(); for(int cnt=0; cntClipCurveByTrace(dcSrc.m_lstCurves); OPENOBJ_END(); } } } dcSrc.CopyTo(dc); if (!g_bOsnapExpl) { //板新增填充功能 int nisFill = 0; m_XDataMap.GetAt(bKEY_SLAB_FILL, nisFill); if (nisFill > 0) { double dscale(100.0); int ncolor(256); CString sPatname = _T("ANSI31"); m_XDataMap.GetAt(sKEY_PAT_PATPICNAME, sPatname); m_XDataMap.GetAt(dKEY_PAT_DENSITY, dscale); m_XDataMap.GetAt(dwKEY_PAT_COLOR, ncolor); AcGeDoubleArray bulges; AcGePoint2dArray vertices; int nVert = poly.Length(); AcDbHatch pHatch; pHatch.setAssociative(Adesk::kFalse); pHatch.setPatternScale(dscale); pHatch.setHatchStyle(AcDbHatch::kNormal); pHatch.setPattern(AcDbHatch::kPreDefined, sPatname); bulges.setPhysicalLength(0).setLogicalLength(nVert+1); vertices.setPhysicalLength(0).setLogicalLength(nVert+1); for (i = 0; i < nVert; i++) { vertices[i] = *poly[i]; bulges[i] = tan(poly.GetBulge(i)/4); } vertices[i] = vertices[0]; bulges[i] = bulges[0]; Acad::ErrorStatus es = pHatch.appendLoop(AcDbHatch::kSelfIntersecting, vertices, bulges); for(i = 0; i < m_lstHoles.Length(); i++) { poly = m_lstHoles[i]; nVert = poly.Length(); bulges.setPhysicalLength(0).setLogicalLength(nVert+1); vertices.setPhysicalLength(0).setLogicalLength(nVert+1); for (int j = 0; j < nVert; j++) { vertices[j] = *poly[j]; bulges[j] = tan(poly.GetBulge(j)/4); } vertices[j] = vertices[0]; bulges[j] = bulges[0]; es = pHatch.insertLoopAt(i+1,AcDbHatch::kSelfIntersecting , vertices, bulges); } pHatch.evaluateHatch(); AcDbObjectId idlay; m_XDataMap.GetAt(idKEY_PAT_LAYER, idlay); if (idlay.isValid()) { pHatch.setLayer(idlay); pHatch.setColorIndex(ncolor); } dc.DrawEntity(pHatch); } } return Acad::eOk; } const TCHAR *TDbSlab::GetDefaultLayer() const { return LAY_SLAB; } /* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */ void TDbSlab::GetTips(DList &lstInfo) const { lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("平板"))); lstInfo.Append(new TObjInfoUnit(_T("平板厚度"), Dist2Str(GetThickness()))); lstInfo.Append(new TObjInfoUnit(_T("底标高"), Dist2Str(GetElevation()))); if(!m_lstHoles) { lstInfo.Append(new TObjInfoUnit(_T("周长"), Dist2Str(GetPerimeter0()))); lstInfo.Append(new TObjInfoUnit(_T("底面积"), XString(_T("%.2f"), _AS_SQMETER(GetBottomArea0())))); lstInfo.Append(new TObjInfoUnit(_T("侧面积"), XString(_T("%.2f"), _AS_SQMETER(GetSideArea0())))); lstInfo.Append(new TObjInfoUnit(_T("体积"), XString(_T("%.3f"), _AS_CUMETER(GetVolume0())))); } else { lstInfo.Append(new TObjInfoUnit(_T("周长(不含洞)"), Dist2Str(GetPerimeter0()))); lstInfo.Append(new TObjInfoUnit(_T("周长(含洞)"), Dist2Str(GetPerimeter()))); lstInfo.Append(new TObjInfoUnit(_T("底面积(不扣洞)"), XString(_T("%.2f"), _AS_SQMETER(GetBottomArea0())))); lstInfo.Append(new TObjInfoUnit(_T("底面积(扣洞)"), XString(_T("%.2f"), _AS_SQMETER(GetBottomArea())))); lstInfo.Append(new TObjInfoUnit(_T("侧面积(不含洞)"), XString(_T("%.2f"), _AS_SQMETER(GetSideArea0())))); lstInfo.Append(new TObjInfoUnit(_T("侧面积(含洞)"), XString(_T("%.2f"), _AS_SQMETER(GetSideArea())))); lstInfo.Append(new TObjInfoUnit(_T("体积(不扣洞)"), XString(_T("%.3f"), _AS_CUMETER(GetVolume0())))); lstInfo.Append(new TObjInfoUnit(_T("体积(扣洞)"), XString(_T("%.3f"), _AS_CUMETER(GetVolume())))); } } void TDbSlab::AddTempRail(TDbHandRail *pRail) { m_tempRailArray.append(pRail); } int TDbSlab::GetEdgeNum() const { return m_polyOutline.TotalSegments(); } BOOL TDbSlab::GetVisibilityAt(int idx) const { ASSERT(idxSetElevation(GetElevation()); m_lstHoles.Append(pHole); return TRUE; } BOOL TDbSlab::RemoveHole(int idx) { assertWriteEnabled(); if(idxSetElevation(nElev); } XVector3D TDbSlab::GetNormal() const { return m_vtNormal; } // Upgrade from TArch5 to TArch6 only XVector3D TDbSlab::_GetNormal() const { int nFlag=0; resbuf *xd=xData(TCHXD); BOOL bRet=FALSE; XVector3D vt(0,0,1); if(xd) { resbuf *rb=xd->rbnext; if(rb->restype==1010) { vt = rb->resval.rpoint; vt /= vt.Length(); // normalize } ads_relrb(xd); } return vt; } void TDbSlab::_SetNormal(XVector3D vt) { assertWriteEnabled(); if(!XSymbolTable(_T("APPID"), TCHXD) && database()==acdbCurDwg()) ads_regapp(TCHXD); vt /= vt.Length(); int nFlag=0; resbuf *xd=ads_buildlist(1001, TCHXD, 1010, &vt, NULL); setXData(xd); ads_relrb(xd); } void TDbSlab::SetNormal(XVector3D vt) { assertWriteEnabled(); vt.Normalize(); m_vtNormal=vt; } // 扣除洞口 double TDbSlab::GetPerimeter() const { double nHoleVal=0.0; for(int i=0; i & TDbSlab::GetHoles() const { return m_lstHoles; } // 高16--洞序号, 低16--边号 BOOL TDbSlab::HitTestOnHole(const XPoint &ptTest,Adesk::UInt32 *bHitFlag) const { XPoint pt=ptTest; pt.z = GetElevation(); for(int i=0; i0? -nTol/2.0 : nTol/2.0; XCurveSegment segRail=seg1.Offset(OFFSET_RIGHT, nOffDist, LS_INFINITE); XPoint pt1, pt2, ptMid; seg0.StartPoint().Project(&ar1, pt1); seg0.EndPoint().Project(&ar1, pt2); seg0.MidPoint().Project(&ar1, ptMid); segHit=XArc(pt1, ptMid, pt2); segHit.SetLineFlag(LS_FINITE); return (nIntNum? 3:4); } } } return (nIntNum? 1 : 2); } // cet 2012.11.12 add支持导出XML CString TDbSlab::GetXml(const AcGeMatrix3d& mat) const { TXmlTree xmlTree; POSITION posRoot = xmlTree.Insert(_T("ATS_SLAB"), NULL, NULL); { xmlTree.SetAttribute(posRoot, _T("name"), _T("平板")); xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称")); } CString strText; POSITION posItemThick = xmlTree.Insert(_T("Flr_thick"), posRoot, NULL); { xmlTree.SetAttribute(posItemThick, _T("name"), _T("板厚")); xmlTree.SetAttribute(posItemThick, _T("comment"), _T("板厚")); strText.Format(_T("%f"), m_nThickness); xmlTree.SetItemText(posItemThick, strText); } POSITION posItemNormal = xmlTree.Insert(_T("VtNormal"), posRoot, posItemThick); { xmlTree.SetAttribute(posItemNormal, _T("name"), _T("方向")); XVector3D vtNormal=GetNormal(); vtNormal.TransformBy(mat); strText.Format(_T("%f,%f,%f"), vtNormal.x, vtNormal.y, vtNormal.z); xmlTree.SetItemText(posItemNormal, strText); } POSITION posItemOutLine = xmlTree.Insert(_T("Baseline"), posRoot, posItemNormal); { xmlTree.SetAttribute(posItemOutLine, _T("name"), _T("截面参数")); POSITION posItem = NULL; TADSGePoint3d ptNode; int iLen = m_polyOutline.Length(); for (int i = 0; i < iLen; i++) { ptNode = m_polyOutline[i]; // 对点进行坐标变换 ptNode.TransformBy(mat); strText.Format(_T("Point_%d"), i + 1); posItem = xmlTree.Insert(strText, posItemOutLine, 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, posItemOutLine, 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 (GetVisibilityAt(i)) nSign = 1; else nSign = 0; strText.Format(_T("Show_%d"), i + 1); posItem = xmlTree.Insert(strText, posItemOutLine, posItem); { strText.Format(_T("点%d是否显示"), i + 1); xmlTree.SetAttribute(posItem, _T("name"), strText); strText.Format(_T("%d"), nSign); xmlTree.SetItemText(posItem, strText); } } } POSITION posItemHole = posItemOutLine; int nHoles = m_lstHoles.Length(); if(nHoles > 0) { posItemHole = xmlTree.Insert(_T("Holes"), posRoot, posItemOutLine); xmlTree.SetAttribute(posItemHole, _T("name"), _T("板洞参数")); XPoly2D poly; CString sHoleNum; POSITION posItemHoleNum = NULL; for(int i = 0; i < nHoles; i++) { sHoleNum.Format(_T("第%d个洞"), i + 1); posItemHoleNum = xmlTree.Insert(sHoleNum, posItemHole, posItemHoleNum); poly = m_lstHoles[i]; int nTotal = poly.Length(); POSITION posItem = NULL; TADSGePoint3d ptNode; for (int i = 0; i < nTotal; i++) { ptNode = *poly[i]; // 对点进行坐标变换 ptNode.TransformBy(mat); strText.Format(_T("Point_%d"), i + 1); posItem = xmlTree.Insert(strText, posItemHoleNum, 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, posItemHoleNum, 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); } } } } POSITION posItemId = xmlTree.Insert(_T("Object_ID"), posRoot, posItemHole); { xmlTree.SetAttribute(posItemId, _T("name"), _T("ID")); xmlTree.SetAttribute(posItemId, _T("comment"), _T("平板ID")); strText.Format(_T("%ld"), objectId().asOldId()); xmlTree.SetItemText(posItemId, strText); } CString strBase = TDbEntity::GetXml(mat); CString strXml = xmlTree.GetXml(); int nIndex = strXml.Find(_T("GetSpecialtyData(); if ( pMapClone != NULL) { m_XDataMap.BeginCloneXlation(pMapClone,idMap); } } } return es; } Acad::ErrorStatus TDbSlab::subWblockClone( AcRxObject* pOwnerObject, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary) const { assertReadEnabled(); Acad::ErrorStatus es = TDbEntity::subWblockClone(pOwnerObject, pClonedObject, idMap, isPrimary); if (pClonedObject != NULL) { TDbEntity* pBase = TDbEntity::cast(pClonedObject); if (pBase != NULL) { TDbXDataMap* pMapClone = pBase->GetSpecialtyData(); if ( pMapClone != NULL) { m_XDataMap.BeginCloneXlation(pMapClone,idMap); } } } return es; } int EditSlab0(AcDbObjectId id); void InitDbSlab(BOOL bTrue) { AecObjectEditMethod pOldEdit=NULL; if(bTrue) { TDbSlab::rxInit(); pOldEdit=TDbSlab::SetEditMethod(EditSlab0); acrxBuildClassHierarchy(); TDbSlab::InitMatchProtocol(TRUE); } else { TDbSlab::InitMatchProtocol(FALSE); TDbSlab::SetEditMethod(pOldEdit); deleteAcRxClass(TDbSlab::desc()); } } // Command:编辑平板 int EditSlab0(AcDbObjectId id) { OPENOBJ_BEGIN(id, AcDb::kForRead, TDbSlab, pStep); if(!pStep) return RTERROR; //判断是不是上海城建叠合板实体 CString strCmdName(_T("")); TDbXDataMap map; map.Read(pStep, _T("TGZZCL")); map.GetAt(_T("cmdName"), strCmdName); if (strCmdName == _T("TGZZCLBD")) { struct resbuf rbUr; rbUr.restype = RTSTR; rbUr.resval.rstring = _tcsdup(_T("EditObj")); rbUr.rbnext = NULL; acedSetVar(_T("USERS3"), &rbUr); acedPostCommand(strCmdName); acedPostCommand(_T("\n")); return RTNORM; } else { while(1) { const TCHAR *szPrompt1=_T("\n选择 [加洞(A)/减洞(D)/加边界(P)/减边界(M)/边可见性(E)/板厚(H)/标高(T)/参数列表(L)]<退出>:"); XString sKeyword; int nRet=0; INITGET_BEG(0, _T("A D P M E H T L")); nRet=ads_getkword(szPrompt1, sKeyword); INITGET_END(); if(nRet!=RTNORM) break; if(sKeyword[0]==_T('H')) { double nRailHeight=pStep->GetThickness(); nRet=GetReal(_T("\n板厚"), nRailHeight); if(nRet==RTCAN) break; if(nRet==RTNORM) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->assertWriteEnabled(); pStep->SetThickness(nRailHeight); pStep->downgradeOpen(); } } else if(sKeyword[0]==_T('T')) { double nElev=pStep->GetElevation(); nRet=GetReal(_T("\n标高"), nElev); 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('A')) { RBList mask=GetClosedCurveMask(); PickSet ss(SS_FREE); const TCHAR *szPrompt[2]={_T("选择封闭的多段线或圆:"), _T("移除已选的多段线或圆")}; int nRet=ss.Get(_T(":$"), szPrompt, NULL,mask); if(nRet==RTCAN) return nRet; else if(nRet==RTNORM) { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->assertWriteEnabled(); XVector3D vtNorm=pStep->GetNormal(); long len=ss.Length(); for(long i=0L; iAddHole(polyHole); } pStep->downgradeOpen(); int bDelObj; VERIFY(xg_getvar(_T("DELOBJ"), &bDelObj)==RTNORM); if(bDelObj) { ss.Delete(); } } } else if(sKeyword[0]==_T('D')) { XPushVar tVar(_T("OSMODE"), OS_NEA); XPoint ptEdge; int nRet=ads_getpoint(NULL, _T("\n请要移除的洞:"), ptEdge); if(nRet==RTCAN) return nRet; else if(nRet==RTNORM) { Adesk::UInt32 nTestCode=0; if(!pStep->HitTestOnHole(Ucs2Ecs(ptEdge, pStep->GetNormal()), &nTestCode)) { adsout << _T("\n请正确点取!"); } else { nTestCode >>= 16; if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->assertWriteEnabled(); pStep->RemoveHole(nTestCode); pStep->downgradeOpen(); } } } else if(sKeyword[0]==_T('E')) { XPushVar tVar(_T("OSMODE"), OS_NEA); XPoint ptEdge; int nRet=RTNORM; INITGET_BEG(0, _T("Y N")); nRet=ads_getpoint(NULL, _T("\n点取不可见的边或 [全可见(Y)/全不可见(N)]<退出>:"), ptEdge); INITGET_END(); if(nRet==RTCAN) return nRet; else if(nRet==RTNORM) { Adesk::UInt16 nTestCode=pStep->HitTestOnOutline(ptEdge); if(nTestCode<0) { adsout << _T("\n请正确点取!"); } else { if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->assertWriteEnabled(); BOOL bVis=pStep->GetVisibilityAt(nTestCode); pStep->SetVisibilityAt(nTestCode, !bVis); pStep->downgradeOpen(); } } else if(nRet==RTKWORD) { XString sInput; ads_getinput(sInput); if(pStep->upgradeOpen()!=Acad::eOk) return RTERROR; pStep->assertWriteEnabled(); int nEdgeNum=pStep->GetEdgeNum(); for(int n=0; nSetVisibilityAt(n, sInput[0]==_T('Y')); pStep->downgradeOpen(); } } else if(sKeyword[0]==_T('P') || sKeyword[0]==_T('M')) { const TCHAR *szPrompts[2]={ _T("\n选择一封闭的多段线(或圆)并入当前的边界:"), _T("\n选择一封闭的多段线(或圆)以便从当前边界中减去:") }; int nSel=(sKeyword[0]==_T('P')? 0 : 1); Entity ent; RBList mask=GetClosedCurveMask(); if(SelectEntity(szPrompts[nSel], ent, mask)==RTNORM) { XVector3D vtNorm=pStep->GetNormal(); XVector3D vt(0,0,1); ent.GetData(210,&vt); XPoly2D poly2d(ent); if(vt.AsAcGeVector3d()==vtNorm.AsAcGeVector3d() && !!poly2d) { XPoly2D polySrc(1); DList lstDest; polySrc=pStep->GetOutline(); polySrc.SetElevation(0.0); poly2d.SetElevation(0.0); if(PolyBoolOper(polySrc, poly2d, lstDest, nSel? AcDb::kBoolSubtract: AcDb::kBoolUnite) && lstDest.Length()==1) { if(pStep->upgradeOpen()==Acad::eOk) { lstDest[0]->Compress(); if(lstDest[0]->PathArea()>0.0) lstDest[0]->Reverse(); double nElev=pStep->GetElevation(); pStep->SetOutline(*lstDest[0]); pStep->SetElevation(nElev); pStep->SetVisibilityAll(TRUE); pStep->downgradeOpen(); ent.Delete(); } } } } } } } OPENOBJ_END(); return RTNORM; }