//-----------------------------------------------------------------------------+ // Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd. // = FileName : TDbColumn.h // = Version : ver2.0 // = Author : xlc // = CreateDate : 2002-09-09 // = Description: 柱子类的声明 // = Maintainers: // //-----------------------------------------------------------------------------+ #include "StdAfx.h" #include "TDbColumn.h" #include "TDPtrList.h" #include "DbConfig.h" //#include "TGGeDirectionCurve.h" #include "TGGeCurveSegment.h" #include "TSymbolTableRecord.h" #include "Symdef.h" #include "TPushMemVar.h" #include "TGGiWorldViewportDraw.h" #include "column_xdata_key.h" #include "wall_xdata_key.h" #define TDBCOLUMN_INSULATE _T("TDBCOLUMN_INSULATE") extern int g_nSolidColor; extern AcDbObjectId g_idPubWall; // 3-TArch5;4-TArch6;5-TArch7,6-TArch8 const Adesk::UInt8 TDbColumn::g_nVersion = 6; ACRX_DXF_DEFINE_MEMBERS(ATSColumn, ATSEntity, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, ATS_COLUMN, "ATS_COLUMN,图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com"); IMPLEMENT_TENTBASE(TDbColumn); extern double g_nInsulateThick; BOOL g_bColumnSkipStretch = FALSE; // xlc add 111019,标记当前是否是在拉伸 TDbColumn::TDbColumn() //:TColumnData(),m_nColuFlag(0),m_nInsulateThick(80) :TColumnData(),m_nColuFlag(0),m_nInsulateThick((int)g_nInsulateThick) { } BOOL TDbColumn::IsValid() const { BOOL bRet = TDbEntity::IsValid(); if (!bRet) { return bRet; } //t20加入4,7,9,11等多边形wlw 14.1.9 bRet = (m_nHeight > -_DIST_SNAP && m_nSectionShape >= 0 && m_nSectionShape <= 13 && m_polyOutline.Length() > 1 && m_polyOutline.IsClosed()); return bRet; } // 提供对格式刷的支持 void TDbColumn::CopyPropertiesFrom(AcDbEntity *pSrcEntity, unsigned gMatchFlag) { assertWriteEnabled(); TDbEntity::CopyPropertiesFrom(pSrcEntity, gMatchFlag); TDbColumn *pSrc = TDbColumn::cast(pSrcEntity); if (pSrc) { m_material = pSrc->m_material; m_nColuFlag = pSrc->m_nColuFlag; m_sLabel = pSrc->m_sLabel; m_nInsulateThick = pSrc->m_nInsulateThick; if (database() == NULL|| pSrcEntity->database() == NULL|| database() == pSrcEntity->database()) { m_idLayerHatch2d = pSrc->m_idLayerHatch2d; m_idTextStyle = pSrc->m_idTextStyle; m_idLayerText = pSrc->m_idLayerText; m_idLayerInsulate = pSrc->m_idLayerInsulate; } m_nTextHeight = pSrc->m_nTextHeight; m_nSectionShape = pSrc->m_nSectionShape; m_nHeight = pSrc->m_nHeight; m_polyOutline = pSrc->m_polyOutline; TADSGePoint3d offset = m_ptLocation-pSrc->m_ptLocation; for (long i = 0; i < m_polyOutline.Length(); i++) { *m_polyOutline[i] += offset; } } } Acad::ErrorStatus TDbColumn::GetPathPoly(TGGePoly2D &polyPath,AcGeVector3d &normal) const { assertReadEnabled(); polyPath = m_polyOutline; normal = AcGeVector3d::kZAxis; return Acad::eOk; } Acad::ErrorStatus TDbColumn::SetPathPoly(const TGGePoly2D &polyPath,const AcGeVector3d &normal) { assertWriteEnabled(); m_polyOutline = polyPath; if (m_polyOutline.PathArea() > 0) { m_polyOutline.Reverse(); } double elev = GetElevation(); m_polyOutline.Center(m_ptLocation); m_ptLocation.z = elev; SetSectionShape(TColumnData::kPoly); return Acad::eOk; } Acad::ErrorStatus TDbColumn::subGetClassID(CLSID* pClsid) const { return Acad::eOk; } void TDbColumn::ResetLinkage() { m_lstWallIds.Reset(); } Acad::ErrorStatus TDbColumn::audit(AcDbAuditInfo* pAuditInfo) { // 调用父类,否则在高版ACAD中修复打开,对象丢失 Acad::ErrorStatus es = TDbEntity::audit(pAuditInfo); if (Acad::eOk == es && m_polyOutline.PathArea() >= 0.0) { pAuditInfo->errorsFound(1); if (pAuditInfo->fixErrors() == Adesk::kTrue) { pAuditInfo->printError(_T("柱子"), _T("轮廓"), _T("必须为逆时针"), _T("")); m_polyOutline.Reverse(); pAuditInfo->errorsFixed(1); return Acad::eFixedAllErrors; } else { return Acad::eLeftErrorsUnfixed; } } else { return Acad::eOk; } } // 从DWG读入数据: // ver3--改变材料类型 Acad::ErrorStatus TDbColumn::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(&(AcGePoint3d &)m_ptLocation); //含Z坐标,作为窗台高度 m_polyOutline.Reset(); ReadPoly2D(pFiler, m_polyOutline); pFiler->readItem(&m_nHeight); m_lstWallIds.Reset(); Adesk::UInt8 nUsage = 0; pFiler->readItem(&nUsage); m_nSectionShape = (TSectionShape)nUsage; Adesk::UInt8 nPatchCount = 0; // max 255 pFiler->readItem(&nPatchCount); for (Adesk::UInt8 n = 0; n < nPatchCount; n++) { AcDbSoftPointerId id; pFiler->readItem(&id); m_lstWallIds.Append(new AcDbSoftPointerId(id)); } if (nVer > 1) { Adesk::UInt8 mater; pFiler->readItem(&mater); if (nVer < 3) { switch(mater) { case 0: m_material = kConcrete; break; case 1: m_material = kSteel; break; case 2: m_material = kBrick; break; } } else { m_material = (TColumnMaterial)mater; } } if (nVer > 3) { //TArch6 pFiler->readItem(&m_nColuFlag); pFiler->readItem(&m_idLayerHatch2d); if (IsLabelEnabled()) { ReadString(pFiler, m_sLabel); pFiler->readItem(&(AcGePoint2d &)m_ptLabel); pFiler->readItem(&m_idTextStyle); pFiler->readItem(&m_idLayerText); pFiler->readItem(&m_nTextHeight); } } else { m_nColuFlag = _GetColumnFlag(); if (database() == acdbCurDwg()) { m_idLayerHatch2d = InitLayer(LAY_HATCH, FALSE); } else { m_idLayerHatch2d = GetLayerIdFromString(LAY_HATCH, database()); } } m_lstNeighbourId.Reset(); if (nVer > 4)//TArch7 { Adesk::UInt8 nCount = 0; // max 255 pFiler->readItem(&nCount); for (Adesk::UInt8 n = 0; n < nCount; n++) { AcDbSoftPointerId id; pFiler->readItem(&id); m_lstNeighbourId.Append(new AcDbSoftPointerId(id)); } } if (nVer > 5)//TArch8 { pFiler->readItem(&m_nInsulateThick);//保温层厚 pFiler->readItem(&m_idLayerInsulate);//保温图层 } return pFiler->filerStatus(); } // 写出数据到dwg: Acad::ErrorStatus TDbColumn::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)3); } else if (g_nSaveTArchVer == 6) { pFiler->writeItem((Adesk::UInt8)4); } else if (g_nSaveTArchVer == 7) { pFiler->writeItem((Adesk::UInt8)5); } else { pFiler->writeItem(g_nVersion); } pFiler->writeItem((AcGePoint3d &)m_ptLocation); //含Z坐标,作为窗台高度 WritePoly2D(pFiler, m_polyOutline); pFiler->writeItem(m_nHeight); pFiler->writeItem((Adesk::UInt8)m_nSectionShape); Adesk::UInt8 nPatchCount = (Adesk::UInt8)m_lstWallIds.Length(); // max 255 pFiler->writeItem(nPatchCount); for (Adesk::UInt8 n = 0; n < nPatchCount; n++) { const AcDbSoftPointerId &id = m_lstWallIds[(int)n]; pFiler->writeItem(id); } pFiler->writeItem((Adesk::UInt8 )m_material); if (g_nSaveTArchVer > 5) { pFiler->writeItem(m_nColuFlag); pFiler->writeItem(m_idLayerHatch2d); if (IsLabelEnabled()) { pFiler->writeItem((const TCHAR *)m_sLabel); pFiler->writeItem((const AcGePoint2d &)m_ptLabel); pFiler->writeItem(m_idTextStyle); pFiler->writeItem(m_idLayerText); pFiler->writeItem(m_nTextHeight); } } if (g_nSaveTArchVer > 6) { Adesk::UInt8 nCount = (Adesk::UInt8)m_lstNeighbourId.Length(); pFiler->writeItem(nCount); for (long i = 0; iwriteItem(id); } } if (g_nSaveTArchVer > 7)//TArch8 { pFiler->writeItem(m_nInsulateThick);//保温层厚 pFiler->writeItem(m_idLayerInsulate);//保温图层 } return es; } Acad::ErrorStatus TDbColumn::dxfInFields (AcDbDxfFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = TDbEntity::dxfInFields(pFiler); if (es != Acad::eOk) { return es; } if (!pFiler->atSubclassData(_T("TDbColumn"))) { return Acad::eBadDxfSequence; } int fieldsFlags = 0; resbuf rb; Adesk::UInt32 n1, n2, n3; double r1; TDPtrList pts; TADSGePoint3d pt; TDPtrList bulges; while ((es == Acad::eOk) && ((es = pFiler->readResBuf(&rb)) == Acad::eOk)) { switch (rb.restype) { case AcDb::kDxfXCoord + 1: pt = rb.resval.rpoint; fieldsFlags |= 0x01; break; case 149: r1 = rb.resval.rreal; fieldsFlags |= 0x02; break; case AcDb::kDxfInt16: n1 = rb.resval.rint; fieldsFlags |= 0x04; break; case AcDb::kDxfInt16+1: n2 = rb.resval.rint; fieldsFlags |= 0x08; break; case AcDb::kDxfInt16+2: n3 = rb.resval.rint; fieldsFlags |= 0x10; break; case AcDb::kDxfXCoord: pts.Append(new TADSGePoint3d(rb.resval.rpoint)); break; case AcDb::kDxfAngle: bulges.Append(new double(rb.resval.rreal)); break; case 411: m_idLayerHatch2d = LayerString2Id(rb.resval.rstring, database()); free(rb.resval.rstring); default: pFiler->pushBackItem(); es = Acad::eEndOfFile; break; } } if (es != Acad::eEndOfFile) { return Acad::eInvalidResBuf; } if (!(fieldsFlags & 0x01)) { pFiler->setError(Acad::eMissingDxfField,_T("\nMissing DXF group code: 11")); return Acad::eMissingDxfField; } if (pts.Length() < 2 || pts.Length() != bulges.Length()) { pFiler->setError(_T("\nError DXF group code: 10, 50")); return Acad::eMissingDxfField; } m_ptLocation = pt; if (fieldsFlags & 0x02) { m_nHeight = r1; } else { m_nHeight = DocGetLHeight(); } if (fieldsFlags & 0x04) { m_nSectionShape = (TSectionShape)n1; } if (fieldsFlags & 0x08) { m_material = (TColumnMaterial)n2; } if (fieldsFlags & 0x10) { SetFortifyColumn(n3); } m_polyOutline.Reset(); for (int i = 0; i < pts.Length(); i++) { m_polyOutline.AppendNode(*pts[i], *bulges[i]); } m_polyOutline.SetElevation(m_ptLocation.z); return pFiler->filerStatus(); } Acad::ErrorStatus TDbColumn::dxfOutFields(AcDbDxfFiler* pFiler) const { Acad::ErrorStatus es = TDbEntity::dxfOutFields(pFiler); assert(es == Acad::eOk); es = pFiler->writeItem(AcDb::kDxfSubclass,_T("TDbColumn")); assert(es == Acad::eOk); pFiler->writePoint3d(AcDb::kDxfXCoord + 1, m_ptLocation); pFiler->writeDouble(149, m_nHeight); pFiler->writeInt16(AcDb::kDxfInt16, m_nSectionShape); pFiler->writeInt16(AcDb::kDxfInt16 + 1, m_material); pFiler->writeInt16(AcDb::kDxfInt16 + 2, IsFortifyColumn()); for (int i = 0; iwritePoint2d(AcDb::kDxfXCoord, m_polyOutline[i]); pFiler->writeDouble(AcDb::kDxfAngle, m_polyOutline.GetBulge(i)); } pFiler->writeString(411, (const TCHAR *)LayerId2String(m_idLayerHatch2d)); return pFiler->filerStatus(); } Acad::ErrorStatus TDbColumn::subGetOsnapPoints( AcDb::OsnapMode osnapMode, INT_PTR gsSelectionMark, const AcGePoint3d& ptPick, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcGePoint3dArray& snapPoints, AcDbIntArray& geomIds) const { assertReadEnabled(); if (osnapMode == AcDb::kOsModeIns) { //插入点捕捉 snapPoints.append(m_ptLocation); return Acad::eOk; } return TDbEntity::subGetOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds); } // 对于自定义柱子,应当允许通过夹点改变边界 Acad::ErrorStatus TDbColumn::subGetGripPoints(AcGePoint3dArray& gripPoints, AcDbIntArray& osnapModes, AcDbIntArray& geomIds) const { gripPoints.append(m_ptLocation.AsAcGePoint3d()); for (int i = 0; i < m_polyOutline.Length(); i++) { gripPoints.append(m_polyOutline[i]); } if (GetSectionShape() <= kCircle) { //边上的夹点 for (i = 0; i < m_polyOutline.Length(); i++) { TGGeCurveSegment edge; m_polyOutline.Nth(i, edge); TADSGePoint3d ptMid = edge.MidPoint(); gripPoints.append(ptMid); } } return Acad::eOk; } Acad::ErrorStatus TDbColumn::subGetStretchPoints(AcGePoint3dArray & stretchPoints) const { stretchPoints.append(m_ptLocation.AsAcGePoint3d()); return Acad::eOk; } // 在全局旋转之后,仍然要保持旋转角度同墙体一致 Acad::ErrorStatus TDbColumn::subTransformBy(const AcGeMatrix3d& xform) { assertWriteEnabled(); TDbEntity::subTransformBy(xform); ads_matrix mat; memcpy(mat, &xform, sizeof(ads_matrix)); m_ptLocation.TransformBy(mat); m_polyOutline.TransformBy(xform); m_polyOutline.SetElevation(m_ptLocation.z); if (IsMirrorMatrix(mat) && m_polyOutline.PathArea() > 0) { m_polyOutline.Reverse(); } //modify by xlc on 100701 解决move柱子后墙体缺口问题 if (!objectId()) { UpdateAssocWallGraphics(); } //add wlw 100913 保温线方向需要处理 bool bHasInsulate = false; AcGeVector3dArray arDirs; arDirs.setLogicalLength(0); ReadInsulateFromXData(bHasInsulate, arDirs); int nlen = arDirs.length(); if (nlen > 0) { for (int i = 0; i < nlen; i++) { arDirs[i].transformBy(xform); } WriteInsulateToXData(bHasInsulate,arDirs); } return Acad::eOk; } // 功能: 夹点操作 // 状态: 有待完成修改相关墙体的操作 Acad::ErrorStatus TDbColumn::subMoveGripPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { assertWriteEnabled(); int nTotalEdge = m_polyOutline.TotalSegments(); TGGePoly2D polyBack(m_polyOutline); TADSGePoint3d vtOffset = *(TADSGePoint3d *) & offset; vtOffset.z = 0; ads_matrix mat; for (int i = 0; i < indices.length(); i++) { int idx = indices[i]; if (idx == 0) { if (!GetCtrlToggle() && GetSectionShape() != kCircle) { GetLocation().GetRotationMatrix(vtOffset.AsAcGeVector2d().angle(),mat); } else { TADSGePoint3d().GetMoveMatrix(vtOffset, mat); m_ptLocation += vtOffset; //add by xlc on 100701 解决移动柱子后墙体有缺口问题 UpdateAssocWallGraphics(); } m_polyOutline.TransUCS(mat); m_polyOutline.SetElevation(GetElevation()); continue; } idx--; if (idxkRect)//圆或等边柱 { double dr = ptDest.Distance2d(GetLocation()); double dr0 = m_polyOutline[idx]->Distance2d(GetLocation()); m_ptLocation.GetScaleMatrix(dr / dr0, mat); m_polyOutline.TransUCS(mat); TADSGePoint3d vt0 = *m_polyOutline[idx] - GetLocation(), vt1 = ptDest - GetLocation(); m_ptLocation.GetRotationMatrix(vt1.AsAcGeVector2d().angle() - vt0.AsAcGeVector2d().angle(),mat); m_polyOutline.TransUCS(mat); m_polyOutline.SetElevation(GetElevation()); } else//矩形柱 { if (GetSectionShape() == kRect) { TADSGePoint3d pa = GetParameters(),vt = vtOffset; vt.Rotate(-pa.z); TADSGePoint3d vtX(vt.x,0),vtY(0,vt.y); vtX.Rotate(pa.z); vtY.Rotate(pa.z); if (idx == 0 || idx == 2) { *m_polyOutline[(idx + 1) % 4] += vtY; *m_polyOutline[(idx + 3) % 4] += vtX; } else { *m_polyOutline[(idx + 1) % 4] += vtX; *m_polyOutline[(idx + 3) % 4] += vtY; } } *m_polyOutline[idx] += vtOffset; } continue; } idx -= m_polyOutline.Length(); if (idx < m_polyOutline.Length())//移动边夹点 { if (GetSectionShape() == kCircle)//圆 { TGGeCurveSegment edge; m_polyOutline.Nth(idx,edge); TADSGePoint3d ptDest = edge.MidPoint() + vtOffset; double dr = ptDest.Distance2d(GetLocation()); double dr0 = m_polyOutline[idx]->Distance2d(GetLocation()); m_ptLocation.GetScaleMatrix(dr / dr0, mat); m_polyOutline.TransUCS(mat); m_polyOutline.SetElevation(GetElevation()); } else { TGGeDirectionCurve cv; m_polyOutline.Nth(idx, cv); ASSERT(!!cv); if (cv.Is(CURVE_LINE)) { // Move TGGeLine ln = cv.GetLine(); ln.SetStartPoint(ln.GetStartPoint() + vtOffset); ln.SetEndPoint(ln.GetEndPoint() + vtOffset); ln.SetLineFlag(LS_INFINITE); TGGeDirectionCurve prevSeg, nextSeg; int nPrev = idx - 1, nNext = idx + 1; nPrev = DePeriod(nTotalEdge, nPrev); nNext = DePeriod(nTotalEdge, nNext); TADSGePoint3d ptStart, ptEnd; BOOL bUpdateIt = TRUE; //更新起点 if (nPrev >= 0 && nPrev < nTotalEdge) { m_polyOutline.Nth(nPrev, prevSeg); prevSeg.SetLineFlag(LS_INFINITE); TADSGePoint3d ptInt[2]; int nIntNum = prevSeg.Intersection(ln, ptInt[0], ptInt[1]); if (nIntNum == 1) { ptStart = ptInt[0]; } else if (nIntNum == 2) { ptStart = TGGeLine(ptInt[0], ptInt[1]).NearPoint(ln.GetStartPoint()); } else { bUpdateIt = FALSE; } } else { ptStart = *m_polyOutline[idx] + vtOffset; } // 更新下一点 if (nNext >= 0 && nNext < nTotalEdge) { m_polyOutline.Nth(nNext, nextSeg); nextSeg.SetLineFlag(LS_INFINITE); TADSGePoint3d ptInt[2]; int nIntNum = nextSeg.Intersection(ln, ptInt[0], ptInt[1]); if (nIntNum == 1) { ptEnd = ptInt[0]; } else if (nIntNum == 2) { ptEnd = TGGeLine(ptInt[0], ptInt[1]).NearPoint(ln.GetEndPoint()); } else { bUpdateIt = FALSE; } } else { ptEnd = *m_polyOutline[idx + 1] + vtOffset; } if (bUpdateIt) { double dPrevBulge = 0.0, dNextBulge = 0.0; double dAngBeg = 0.0, dAngEnd = 0.0; if (fabs(prevSeg.GetBulge()) > 1.0E-5) { TGGeArc prevArc = prevSeg.GetArc(); dAngBeg = ads_angle(prevArc.GetCenterPt(), prevSeg.GetStartPoint()); dAngEnd = ads_angle(prevArc.GetCenterPt(), ptStart); if (prevSeg.IsMinusArc()) { dPrevBulge = -AngleRangeTo2PI(dAngBeg - dAngEnd); } else { dPrevBulge = AngleRangeTo2PI(dAngEnd - dAngBeg); } } if (fabs(nextSeg.GetBulge()) > 1.0E-5) { TGGeArc nextArc = nextSeg.GetArc(); dAngBeg = ads_angle(nextArc.GetCenterPt(), ptEnd); dAngEnd = ads_angle(nextArc.GetCenterPt(), nextSeg.GetEndPoint()); if (nextSeg.IsMinusArc()) { dNextBulge = -AngleRangeTo2PI(dAngBeg - dAngEnd); } else { dNextBulge = AngleRangeTo2PI(dAngEnd - dAngBeg); } } *m_polyOutline[idx] = ptStart; if (nNext >= 0 && nNext < m_polyOutline.Length()) { *m_polyOutline[nNext] = ptEnd; m_polyOutline.SetBulge(nNext, dNextBulge); } if (nPrev >=0 && nPrev < m_polyOutline.Length()) { m_polyOutline.SetBulge(nPrev, dPrevBulge); } } } else { // Change Arc Segment--bulge TADSGePoint3d ptMid = cv.MidPoint(); TADSGePoint3d ptMidNew = ptMid + vtOffset; TGGeArc arNew(cv.GetStartPoint(), ptMidNew, cv.GetEndPoint()); if (!!arNew) { //新的弧有效 TGGeCurveSegment cvLine(cv.GetStartPoint(), cv.GetEndPoint(), 0.0); int nSideOld = cvLine.OnWhichSide(ptMid); int nSideNew = cvLine.OnWhichSide(ptMidNew); double dSignal = cv.GetBulge() / fabs(cv.GetBulge()); if (nSideOld == nSideNew) { m_polyOutline.SetBulge(idx, dSignal * arNew.Bulge()); } else { m_polyOutline.SetBulge(idx, -dSignal * arNew.Bulge()); } } } } } } if (GetSectionShape() != kPoly) { double delev = GetElevation(); m_polyOutline.Center(m_ptLocation); m_ptLocation.z = delev; } Acad::ErrorStatus es = Acad::eOk; if (m_polyOutline.Area() < 1E-6 || m_polyOutline.IsSelfIntersect()) { m_polyOutline = polyBack; es = Acad::eInvalidInput; } return es; } bool TDbColumn::IsModelEntity() const { return true; } bool TDbColumn::IsMeClip() const { return true; } int TDbColumn::GetCtrlToggleIndex() const { return 0; } AcDbEntity* TDbColumn::GetMyEntity() const { return (AcDbEntity*)this; } int TDbColumn::GetMaterialIndex() const { return GetMaterial(); } TWallBase::Usage TDbColumn::GetUsage() const { return kColumn; } int TDbColumn::GetPriority() const { if (!IsShortColumn()) { return GetMaterial(); } else { return -1000000 + (int)GetHeight(); } } Adesk::UInt16 TDbColumn::GetColumnFlag() const { return m_nColuFlag; } void TDbColumn::SetColumnFlag(Adesk::UInt16 nFlag) { assertWriteEnabled(); m_nColuFlag = nFlag; } AcDbObjectId TDbColumn::GetLayerHatch2d() const { return m_idLayerHatch2d; } void TDbColumn::SetLayerHatch2d(AcDbObjectId id) { assertWriteEnabled(); m_idLayerHatch2d = id; } BOOL TDbColumn::IsLabelEnabled() const { return ((m_nColuFlag & CF_LABEL) != 0); } void TDbColumn::EnableLabel(BOOL bTrue) { assertWriteEnabled(); if (bTrue) { m_nColuFlag |= CF_LABEL; } else { m_nColuFlag &= ~CF_LABEL; } } void TDbColumn::SetLabelPos(TADSGePoint3d pt) { assertWriteEnabled(); m_ptLabel = pt; } const TCHAR * TDbColumn::GetLabel() const { return (const TCHAR *)m_sLabel; } void TDbColumn::SetLabel(const TCHAR *sz) { assertWriteEnabled(); if (sz) { m_sLabel = sz; } } AcDbObjectId TDbColumn::GetTextStyle() const { return m_idTextStyle; } void TDbColumn::SetTextStyle(AcDbObjectId id) { assertWriteEnabled(); m_idTextStyle = id; } AcDbObjectId TDbColumn::GetLayerText() const { return m_idLayerText; } void TDbColumn::SetLayerText(AcDbObjectId id) { assertWriteEnabled(); m_idLayerText = id; } double TDbColumn::GetTextHeight(BOOL bAsPaperUnit) const { double dh = m_nTextHeight; if (!bAsPaperUnit) { dh *= GetPScale(); } return dh; } void TDbColumn::SetTextHeight(double dHeight, BOOL bAsPaperUnit) { assertWriteEnabled(); if (bAsPaperUnit) { m_nTextHeight = dHeight; } else { m_nTextHeight = dHeight / GetPScale(); } } // 取得夹点说明 Acad::ErrorStatus TDbColumn::GetGripText(int i, CString &cs) const { Acad::ErrorStatus es = Acad::eOk; if (i == 0) { if (GetSectionShape() == kCircle) { cs = _T("移动柱子"); } else { cs = !GetCtrlToggle()?_T("中心旋转(Ctrl-移动)"):_T("移动柱子(Ctrl-中心旋转)"); } } else if (i < m_polyOutline.Length() + 1) { cs = _T("移动顶点"); } else if (GetSectionShape() <= kCircle && i < 2 * m_polyOutline.Length() + 1) { if (GetSectionShape() < kCircle) { cs = _T("移动边"); } else { cs = _T("改变半径"); } } else { es = Acad::eInvalidInput; } return es; } #if ADS > 15 void TDbColumn::CreateGrip() { TDbEntity::CreateGrip(); if (GetSectionShape() == kPoly) { TchExport2::CreateGrip(this,m_polyOutline,1); } } Acad::ErrorStatus TDbColumn::EntityToDim(long iGrip,long iDim,const AcDbEntity*pEnt) { if (GetSectionShape() != kPoly) { return Acad::eNotImplementedYet; } TEntityBase *pCurve = TDbColumn::cast(pEnt); if (pCurve == NULL) { pCurve = this; } TGGePoly2D polyPath; AcGeVector3d normal; pCurve->GetPathPoly(polyPath,normal); return TchExport2::EntityToDim(this,polyPath,iGrip,iDim,1); } Acad::ErrorStatus TDbColumn::DimToEntity(long iGrip,long iDim,double newValue,const AcGeVector3d& offset) { assertWriteEnabled(); if (GetSectionShape() != kPoly) { return Acad::eNotImplementedYet; } TDbColumn curve; curve.CopyPropertiesFrom(this,0); Acad::ErrorStatus es = TchExport2::DimToEntity(this,m_polyOutline,iGrip,iDim,newValue,offset,1); if (es == Acad::eOk && !IsValid()) { CopyPropertiesFrom(&curve,0); return Acad::eInvalidInput; } return es; } #endif // 功能: 夹点操作 // 状态: 有待完成修改相关墙体门窗的操作 Acad::ErrorStatus TDbColumn::subMoveStretchPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { TPushMemVar vTemp(GetCtrlToggle(),TRUE); //add by xlc 111019 忽略stretch命令更新墙 TPushMemVar vTempStretch(g_bColumnSkipStretch, TRUE); return subMoveGripPointsAt(indices, offset); } Acad::ErrorStatus TDbColumn::subOpen(AcDb::OpenMode mode) { Acad::ErrorStatus es = TDbEntity::subOpen(mode); return es; } void TDbColumn::GetThinCurves(TDPtrList &lstResult, TDPtrList &lstResultIn) const { TDPtrList lstCurves, lstCurves1, *pSource = NULL, *pDest = NULL; TDPtrList lstCurvesIn, lstCurves1In, *pSourceIn = NULL, *pDestIn = NULL; double nThick = DocGetIsLineWeight() ? GetLineWeight(FALSE) : 0.0; TGGePoly2D polyOut(1), polyIn(1); GetOutline(polyOut); ASSERT(polyOut.Length() != 0); polyOut.SetElevation(0.0); polyOut.QuickOffset(-nThick, polyIn); ExplodePoly2D(polyOut, lstCurves); BOOL bThickMode = (IsBoldLine() && nThick > _DIST_SNAP); if (bThickMode) { ExplodePoly2D(polyIn, lstCurvesIn); } if (!lstCurves) { return; } pSource = &lstCurves; pSourceIn = &lstCurvesIn; pDest = &lstCurves1; pDestIn = &lstCurves1In; AcDbObjectId idOwner = ownerId(); if (!!idOwner) { for (int i = 0; iGetStartColumnId() == objectId() || pWall->GetEndColumnId() == objectId()) && int(pWall->GetStyle()) == int(m_material)) { //同材料 //add by xlc on 100719 标准柱与矮墙连接时与矮墙不融合(加粗状态) if ((!IsShortColumn() && !IsFortifyColumn()) && pWall->GetUsageFlag() == TWallData::kParapet) { continue; } //add by xlc on 101231 矮柱与一般墙或隔断不融合(加粗状态) if (IsShortColumn() && (pWall->GetUsageFlag() == TWallData::kNormal || pWall->GetUsageFlag() == TWallData::kApartment)) { continue; } TGGePoly2D polyWall(1); pWall->GetOutlinePoly(0.0, polyWall); polyWall.SetElevation(GetElevation()); pDest->Reset(); TDPtrList lstTemp, lstEdge; PolyClip(*pSource, polyWall, lstTemp, *pDest, lstEdge); if (!pDest->Length()) {//裁剩下空 return; } Exchange(pSource, pDest); if (bThickMode) { TGGeCurveSegment cvLeftIn, cvRightIn; //粗线内侧 pWall->GetThickLineSideCurve(cvLeftIn, cvRightIn); TGGePoly2D polyClip(1); polyClip.AppendNode(cvLeftIn.GetStartPoint()); //add by xlc on 100629 解决同材质,墙基线在墙外与柱子相交时柱子不加粗的问题 if (!(pWall->GetWidth(0) < _DIST_SNAP || pWall->GetWidth(1) < _DIST_SNAP)) { polyClip.AppendNode(pWall->GetStartPoint()); } polyClip.AppendNode(cvRightIn.GetStartPoint(), cvRightIn.GetBulge()); polyClip.AppendNode(cvRightIn.GetEndPoint()); //add by xlc on 100629 解决同材质,墙基线在墙外与柱子相交时柱子不加粗的问题 if (!(pWall->GetWidth(0) < _DIST_SNAP || pWall->GetWidth(1) < _DIST_SNAP)) { polyClip.AppendNode(pWall->GetEndPoint()); } polyClip.AppendNode(cvLeftIn.GetEndPoint(), -cvLeftIn.GetBulge()); polyClip.SetElevation(GetElevation()); pDestIn->Reset(); PolyClip(*pSourceIn, polyClip, lstTemp, *pDestIn, lstEdge); Exchange(pSourceIn, pDestIn); pDestIn->Reset(); } } } OPENOBJ_END(); } for (int n = 0; n < pSource->Length(); n++) { TGGeCurveSegment *pSeg = (*pSource)[n]; lstResult.Append(new TGGeCurveSegment(*pSeg)); } if (bThickMode) { for (n = 0; n < pSourceIn->Length(); n++) { lstResultIn.Append(new TGGeCurveSegment(*(*pSourceIn)[n])); } } } // 显示或者炸碎二维 Acad::ErrorStatus TDbColumn::ExplodeOrDraw2d(TGGiExplodeDrawBase &dc) const { double nScale = GetPScale(); BOOL bDrawDetail = (nScale - g_nDetailScale < -1.0E-3); BOOL bIsHatch = FALSE; m_XDataMap.GetAt(bKEY_COLUMN_FILLING_OP, bIsHatch); if (!ownerId() && _tcscmp(dc.Desc(), TGGiWorldViewportDraw::Descriptor()) == 0) //临时绘制 { TGGePoly2D polyOutline(1); GetOutline(polyOutline); dc << polyOutline; return Acad::eOk; } else if (dc.IsExportTch4() && m_material == kConcrete && !bDrawDetail &&//导出TArch3 m_lstClipId.Length() == 0 && !bIsHatch)//有切割和有独立填充时按绘制走 wlw mod 14.05.28 { TADSGePoint3d ptCen = GetLocation(); TADSGePoint3d ptPara = GetParameters(); AcDbObjectId idBlock; if (m_nSectionShape == kRect) { if (IsSolidFill() && m_material == kConcrete && !IsShortColumn()) { if (!bDrawDetail) { idBlock = InitBlock(_T("_FZH"), database()); } } else { idBlock = InitBlock(_T("_FZHK"), database()); } } else if (m_nSectionShape == kCircle) { if (IsSolidFill() && m_material == kConcrete && !IsShortColumn()) { if (!bDrawDetail) { idBlock = InitBlock(_T("_YZH"), database()); } } else { idBlock = InitBlock(_T("_YZHK"), database()); } } else { //... } if (idBlock.isValid()) { AcDbBlockReference *pColu = new AcDbBlockReference(ptCen, idBlock); pColu->setPropertiesFrom(this); AcGeScale3d scale(ptPara.x, ptPara.y, ptPara.y); pColu->setScaleFactors(scale); pColu->setRotation(ptPara.z); ((TGGiExplodeDraw &)dc).Append(pColu, FALSE); TDPtrList lstSegs, lstSegsIn; GetThinCurves(lstSegs, lstSegsIn); if (lstSegsIn.Length() == lstSegs.Length() && !IsShortColumn()) { AcDbObjectId idOld = dc.GetLayerId(); dc.SetLayer(g_idPubWall); for (int n = 0; n < lstSegs.Length(); n++) { TGGeCurveSegment *seg1 = lstSegs[n]; TGGeCurveSegment *seg2 = lstSegsIn[n]; dc << TGGeSolidCurve(*seg1, *seg2); } dc.SetLayer(idOld); } //绘制-保温层 wlw add 100913 DrawInsulateLine(dc); return Acad::eOk; } } double nThick = DocGetIsLineWeight() ? GetLineWeight(FALSE) : 0.0; BOOL bShortColumn = IsShortColumn(); //是否矮柱 BOOL bFortifyColumn = IsFortifyColumn(); //是否构造柱 //得到所有邻接墙的外轮廓 TDPtrList lstWallOut; for (int i = 0; i GetStartColumnId() == objectId() || pWall->GetEndColumnId() == objectId()) // && int(pWall->GetStyle()) == int(m_material)) if (pWall && (pWall->GetStartColumnId() == objectId() || pWall->GetEndColumnId() == objectId())) { //矮柱与矮墙,顶标高一致时融合 if (bShortColumn && pWall->GetUsageFlag() == TWallData::kParapet) { double dTopElevColu = GetElevation() + GetHeight(); double dTopElevWall = pWall->GetElevation() + pWall->GetHeight(); if (fabs(dTopElevWall - dTopElevColu) > _DIST_SNAP) { continue; } //add by xlc on 110401 矮墙矮柱融合与材料无关 TGGePoly2D polyOut(1); pWall->GetOutlinePoly(0, polyOut); //一定是逆时针 lstWallOut.Append(new TGGePoly2D(polyOut)); continue; } if (int(pWall->GetStyle()) == int(m_material)) { //add by xlc on 100719 矮墙与标准柱不融合,矮墙与矮柱顶标高不同时不融合 //标准柱与矮墙不融合 if ((!bFortifyColumn && !bShortColumn) //标准柱 && pWall->GetUsageFlag() == TWallData::kParapet) { continue; } //add by xlc on 101231 矮柱与一般墙或隔断不融合 if (bShortColumn && (pWall->GetUsageFlag() == TWallData::kNormal || pWall->GetUsageFlag() == TWallData::kApartment)) { continue; } TGGePoly2D polyOut(1); pWall->GetOutlinePoly(0, polyOut); //一定是逆时针 lstWallOut.Append(new TGGePoly2D(polyOut)); } } OPENOBJ_END(); } //计算大融合体外轮廓 TDPtrList lstMyPoly,lstUnion; TGGePoly2D *pNewPoly = new TGGePoly2D(m_polyOutline); // add by xlc on 100812 柱子有共线点时会影响布尔运算,解决此时出现柱子无法加粗的问题 pNewPoly->Compress(); pNewPoly->SetElevation(0); lstMyPoly.Append(pNewPoly); Union(lstMyPoly,lstWallOut,lstUnion); TGGePoly2D polyUnion(m_polyOutline); // add by xlc on 100812 柱子有共线点时会影响布尔运算,解决此时出现柱子无法加粗的问题 polyUnion.Compress(); if (lstUnion.Length() == 1) { polyUnion = *lstUnion[0]; } if (!g_bOsnapExpl && !IsShortColumn()) { //绘制填充 const TCHAR *pszHatch = GetHatchPattern(); if (pszHatch != NULL) { //绘制内部填充 AcDbObjectId idOldLay = dc.GetLayerId(); int nColorOld = dc.GetColor(); dc.SetColorLayer(GetHatchColor(),m_idLayerHatch2d); if (_tcsicmp(pszHatch, _T("SOLID")) == 0) { dc << TGGeSolid(m_polyOutline); } else { double dscale = GetPScale(); /* BOOL bIsWallHatch = FALSE; m_XDataMap.GetAt(bKEY_COLUMN_FILLING_OP, bIsWallHatch); if (bIsWallHatch) { m_XDataMap.GetAt(dKEY_COLUMN_FILLING_DENSITY, dscale); } */ dc << TGGeHatch(m_polyOutline, pszHatch, dscale); } dc.SetLayer(idOldLay); dc.SetColor(nColorOld); } //绘制加粗边界 if (nThick > _DIST_SNAP) { bool bFree = true; if (lstWallOut.Length() > 0) { TGGePoly2D polyUnionHatch = polyUnion; TGGePoly2D polyTemp(1); double nOffset = -nThick; if (polyUnionHatch.QuickOffset(nOffset, polyTemp) == RTNORM) { polyUnionHatch = polyTemp; } TDPtrList lstResultPolies; // modify by xlc on 100812 柱子有共线点时会影响布尔运算,解决此时出现柱子无法加粗的问题 //if (TchSubExport::Subtract(m_polyOutline,polyUnionHatch,lstResultPolies) == RTNORM && lstResultPolies.Length() > 0) TGGePoly2D polyComp(m_polyOutline); polyComp.Compress(); if (TchSubExport::Subtract(polyComp,polyUnionHatch,lstResultPolies) == RTNORM && lstResultPolies.Length() > 0) { // modify by xlc on 100413 //解决墙基线在外部且柱子仅于基线相交时,墙柱加粗时柱子填充的问题 if (!(lstResultPolies.Length() == 1 && fabs(polyUnionHatch.PathArea()) < fabs(lstResultPolies[0]->PathArea()) )) { bFree = false; for (int i = 0; i < lstResultPolies.Length(); i++) { dc << TGGeSolid(*lstResultPolies[i]); } } } } if (bFree)//独立柱。 { TDPtrList lstSegs, lstSegsIn; GetThinCurves(lstSegs, lstSegsIn); if (lstSegsIn.Length()>0 && lstSegs.Length() == lstSegsIn.Length()) { for (int n = 0; n < lstSegs.Length(); n++) { dc << TGGeSolidCurve(*lstSegs[n], *lstSegsIn[n]); } } } } } //绘制边界细线 TDPtrList lstSegs0,lstSegs,temp; ExplodePoly2D(m_polyOutline,lstSegs0); PolyClip(lstSegs0,polyUnion,temp,lstSegs); for (int n = 0; n < lstSegs.Length(); n++) { dc << *lstSegs[n]; } // modify by xlc on 110519 解决阳台遮挡保温层的问题 //绘制-保温层 //DrawInsulateLine(dc); if (IsInsulateOnColumn()) { long iClipCount = 0; //阳台裁剪边界数 for (long i = 0; i < m_lstClippedId.Length(); i++) { const AcDbObjectId &id = m_lstClippedId[i]; if (id.isNull() || !id.isValid()) { continue; } OPENOBJ_BEGIN(id, AcDb::kForRead, TDbBalcony, pBalcony); if (pBalcony) { if(pBalcony->IsBalconyClipInsu()) { TGGePoly2D polyBal = pBalcony->GetOutline(),polyIn; if( pBalcony->GetPolyIn(polyIn)) { polyIn.SetFlag(0); polyIn.Reverse(); for (int j = 0; j < polyIn.Length(); j++) { polyBal.AppendNode(*polyIn[j], polyIn.GetBulge(j)); } dc.PushClip(polyBal); iClipCount++; } } } OPENOBJ_END(); } DrawInsulateLine(dc); while (iClipCount > 0) { dc.PopClip(); iClipCount--; } } #ifdef TASD StruExplodeOrDraw2d(dc); #endif return Acad::eOk; } Acad::ErrorStatus TDbColumn::ExplodeOrDraw3d(TGGiExplodeDrawBase &dc) const { int nColFlag = GetColumnFlag(); if (IsFortifyColumn()) { return Acad::eOk; } if (m_nHeight<_DIST_SNAP) {//高度为0的不绘制 return Acad::eOk; } double nElev = GetElevation(); TGGePoly2D polyOut(m_polyOutline); polyOut.SetElevation(nElev); double nHeight = m_nHeight; if (!DocGetLevelLine() && g_bExplodeMesh && (!(nColFlag&CF_BOTTOM) || !(nColFlag&CF_TOP))) { BOOL bVisBot = (nColFlag&CF_BOTTOM) != 0; BOOL bVisTop = (nColFlag&CF_TOP) != 0; TGGePoly2D polyBot; polyOut.Disperse1(polyBot, _AS_SYS_UNIT(g_nCirDeviation)); int nColumn = polyBot.Length() + 1; int nRow = 2; TADSGePoint3d *ptArray = new TADSGePoint3d[nColumn*nRow]; for (int m = 0; m < nRow; m++) { for (int n = 0; n < nColumn; n++) { int nBase = m * nColumn; int idx = n; if (n == nColumn - 1) { idx = 0; } ptArray[nBase + n] = *polyBot[idx]; if (m) { ptArray[nBase + n].z += nHeight; } } } AcGiEdgeData edgeData; Adesk::UInt8 *edgeVis = new Adesk::UInt8[(nColumn - 1) * nRow + nColumn * (nRow - 1)]; for (m = 0; m < (nColumn - 1) * nRow; m++) { if (m < nColumn - 1) { edgeVis[m] = bVisBot; } else { edgeVis[m] = bVisTop; } } for (int n = 0; n < nColumn; n++) { int idx = n; if (n == nColumn - 1) { idx = 0; } edgeVis[m + n] = 1; } edgeData.setVisibility(edgeVis); dc.DrawMesh(nRow, nColumn, (AcGePoint3d *)ptArray, &edgeData); delete [] ptArray; delete [] edgeVis; if (bVisBot) { dc.DrawShell(polyBot); } if (bVisTop) { polyBot.SetElevation(nElev + nHeight); dc.DrawShell(polyBot); } } else { //wlw add 100715 保温层3d显示 GetColSurFacePoly2D(polyOut,TRUE); polyOut.SetElevation(nElev); dc.DrawBody(polyOut, TVector3D(0,0,nHeight)); } #ifdef TASD StruExplodeOrDraw3d(dc); #endif return Acad::eOk; } Acad::ErrorStatus TDbColumn::AddLinkWallId(const AcDbObjectId &id) { if (!id || m_lstWallIds.FindNode(&id, CompareObjectId)) { return Acad::eInvalidInput; } m_lstWallIds.Append(new AcDbSoftPointerId(id)); return Acad::eOk; } void TDbColumn::RemoveLinkWallId(const AcDbObjectId &idWall) { assertWriteEnabled(); m_lstWallIds.FindAndDel(&idWall,CompareObjectId); } void TDbColumn::PreErase() const { for (long i = 0; i < m_lstWallIds.Length(); i++) { TDbWall*pWall = NULL; acdbOpenObject(pWall,m_lstWallIds[i],AcDb::kForWrite); if (pWall != NULL) { pWall->assertWriteEnabled(); pWall->RemoveColumn(objectId()); pWall->close(); } } } const TCHAR * TDbColumn::GetMaterialText() const { const TCHAR *pszMater = NULL; if (IsFortifyColumn()) { pszMater = _T("构造柱"); } else { switch(m_material) { case kBrick: pszMater = _T("砖"); break; case kRocket: pszMater = _T("石材"); break; case kConcrete: pszMater = _T("钢筋混凝土"); break; case kSteel: pszMater = _T("金属"); break; default: pszMater = _T("未知"); break; } } return pszMater; } const TCHAR *TDbColumn::GetDefaultLayer() const { const TCHAR *pLay = NULL; pLay = LAY_COLU; switch(m_material) { case kSteel: pLay = LAY_COLU_STEEL; break; case kRocket: pLay = LAY_COLU_ROCKET; break; case kBrick: pLay = LAY_COLU_BRICK; break; case kConcrete: pLay = LAY_COLU_CONCRETE; break; } return pLay; } // 需要查询全局字典 const TCHAR *TDbColumn::GetHatchPattern() const { static TCHAR szHatch[256] = _T(""); szHatch[0] = 0; //S wlw add 131201 增加独有图案设置,FALSE时才取全局设置 BOOL bIsHatch = FALSE; CString sPattern; m_XDataMap.GetAt(bKEY_COLUMN_FILLING_OP, bIsHatch); m_XDataMap.GetAt(sKEY_COLUMN_FILLING_MATERIAL, sPattern); if (bIsHatch) { _tcscpy(szHatch, sPattern); return szHatch; } if (!IsSolidFill()) return NULL; //E double dScale = GetPScale(); BOOL bDrawDetail = (dScale - g_nDetailScale < -1.0E-3); TDbConfig *p = GetDwgGlobal(AcDb::kForRead,g_pCurrentDb); TAcDbObjectPtr temp(p); if (p) { switch(m_material) { case kSteel: _tcscpy(szHatch, p->GetHatchSteel(bDrawDetail)); break; case kRocket: _tcscpy(szHatch, p->GetHatchRocket(bDrawDetail)); break; case kBrick: _tcscpy(szHatch, p->GetHatchBrick(bDrawDetail)); break; case kConcrete: _tcscpy(szHatch, p->GetHatchConcrete(bDrawDetail)); break; } } else { if (!bDrawDetail) { if (m_material == kConcrete) { _tcscpy(szHatch, _T("SOLID")); } } else { if (m_material == kConcrete) { _tcscpy(szHatch, _T("钢筋混凝土")); } } } if (!szHatch[0]) { return NULL; } return szHatch; } Adesk::UInt16 TDbColumn::GetHatchColor() const { //S wlw add 131201 增加独有图案设置,FALSE时才取全局设置 BOOL bIsWallHatch = FALSE; Adesk::UInt16 nColor(256); m_XDataMap.GetAt(bKEY_COLUMN_FILLING_OP, bIsWallHatch); m_XDataMap.GetAt(iKEY_COLUMN_FILLING_COLOR, (int&)nColor); if (bIsWallHatch) { return nColor; } //E TDbConfig *p = GetDwgGlobal(AcDb::kForRead,g_pCurrentDb); TAcDbObjectPtr temp(p); if (p) { switch(m_material) { case kSteel: return p->GetSteelColor(); case kRocket: return p->GetRocketColor(); case kBrick: return p->GetBrickColor(); case kConcrete: return p->GetConcreteColor(); } } return 256; } //取线粗,不管加粗开关是否开启 double TDbColumn::GetLineWeight(BOOL bAsPaperUnit) const { double nWeight = 0.4; double dScale = GetPScale(); BOOL bDrawDetail = (dScale - g_nDetailScale < -1.0E-3); TDbConfig *p = GetDwgGlobal(AcDb::kForRead,g_pCurrentDb); TAcDbObjectPtr temp(p); if (p) { switch(m_material) { case kSteel: nWeight = p->GetBoldSteel(bDrawDetail); break; case kRocket: nWeight = p->GetBoldRocket(bDrawDetail); break; case kBrick: nWeight = p->GetBoldBrick(bDrawDetail); break; case kConcrete: nWeight = p->GetBoldConcrete(bDrawDetail); break; } } if (!bAsPaperUnit) { nWeight *= GetPScale(); } return nWeight; } void TDbColumn::GetAxisColuInfo(TADSGePointDir2d &ptLoc, TVector3D &vtOffset) const { ASSERT(IsValid()); (TADSGePoint3d &)ptLoc = m_ptLocation; double nDir = GetRotation(); ptLoc.nDirection = nDir; vtOffset.x = 0; vtOffset.y = 0; vtOffset.z = 0; TADSGePoint3d ptLow, ptUp; m_polyOutline.GetExtend(ptLow, ptUp); TADSGePointDir2d ptTemp; if (GetAxisInter(ptLow, ptUp, ptTemp)) { vtOffset = ((TADSGePoint3d &)ptTemp) - m_ptLocation; vtOffset.z = 0; ptLoc.nDirection = AngleRangeTo2PI(nDir - ptTemp.nDirection); } } Acad::ErrorStatus TDbColumn::subWblockClone(AcRxObject* pOwner, AcDbObject*& pClonedObject, AcDbIdMapping& idMap, Adesk::Boolean isPrimary) const { Acad::ErrorStatus es = TDbEntity::subWblockClone(pOwner, pClonedObject, idMap, isPrimary); return es; } /* * * * * * * * * * 取 动 态 属 性 显 示 数 据 的 函 数 * * * * * * * * * */ void TDbColumn::GetTips(TDPtrList &lstInfo) const { lstInfo.Append(new TObjInfoUnit(_T("对象类型"), _T("柱子"))); lstInfo.Append(new TObjInfoUnit(_T("截面形状"), GetSectionShapeText())); // sg modify 100412,根据8.5需求,如果是矮柱,不显示材料类型,只显示类型 if (IsShortColumn()) { lstInfo.Append(new TObjInfoUnit(_T("类型"), _T("矮柱"))); } else { lstInfo.Append(new TObjInfoUnit(_T("材料类型"), GetMaterialText())); } TADSGePoint3d ptPara = GetParameters(); double dRot = ptPara.z; double dx = ptPara.x; double dy = ptPara.y; lstInfo.Append(new TObjInfoUnit(_T("转角"), TchExport::Angle2Str(dRot*180.0/PI))); lstInfo.Append(new TObjInfoUnit(_T("截面宽"), TchExport::Dist2Str(dx))); lstInfo.Append(new TObjInfoUnit(_T("截面高"), TchExport::Dist2Str(dy))); lstInfo.Append(new TObjInfoUnit(_T("高度"), TchExport::Dist2Str(m_nHeight))); lstInfo.Append(new TObjInfoUnit(_T("周长"), TchExport::Dist2Str(m_polyOutline.Distance2d()))); lstInfo.Append(new TObjInfoUnit(_T("侧面积"), TCString(_T("%.2f"), _AS_SQMETER(m_polyOutline.Distance2d()*m_nHeight)))); lstInfo.Append(new TObjInfoUnit(_T("截面积"), TCString(_T("%.2f"), _AS_SQMETER(GetSectionArea())))); lstInfo.Append(new TObjInfoUnit(_T("体积"), TCString(_T("%.3f"), _AS_CUMETER(GetVolume())))); lstInfo.Append(new TObjInfoUnit(_T("底标高"), TchExport::Dist2Str(GetElevation()))); } Adesk::UInt16 TDbColumn::_GetColumnFlag() const { int nFlag = 0; resbuf *xd = xData(TCHXD); BOOL bRet = FALSE; if (xd) { resbuf *rb = xd->rbnext; if (rb->restype == 1070) { nFlag = (Adesk::UInt16)rb->resval.rint; } ads_relrb(xd); } return nFlag; } BOOL TDbColumn::IsFortifyColumn() const { int nFlag = GetColumnFlag(); return ((nFlag&CF_FORTIFY) != 0); } BOOL TDbColumn::IsShortColumn() const { int nFlag = GetColumnFlag(); return ((nFlag&CF_SHORT) != 0); } void TDbColumn::SetFortifyColumn(BOOL bTrue) { assertWriteEnabled(); if (bTrue) { m_nColuFlag |= CF_FORTIFY; m_nColuFlag &= ~CF_SHORT;//与矮柱特性互斥 } else { m_nColuFlag &= ~CF_FORTIFY; } if (bTrue) { m_lstWallIds.Reset(); } } void TDbColumn::SetShortColumn(BOOL bTrue) { assertWriteEnabled(); if (bTrue) { m_nColuFlag |= CF_SHORT; m_nColuFlag &= ~CF_FORTIFY;//与构造柱特性互斥 } else { m_nColuFlag &= ~CF_SHORT; } if (bTrue) { m_lstWallIds.Reset(); } } void TDbColumn::_SetColumnFlag(Adesk::UInt16 nFlag) { assertWriteEnabled(); if (!TAcDbSymbolTable(_T("APPID"), TCHXD) && database() == acdbCurDwg()) { ads_regapp(TCHXD); } TRBList xd = ads_buildlist(1001, TCHXD, 1070, (int)nFlag, NULL); setXData(xd); } void TDbColumn::UpdateAssocWallGraphics() const { int nCount = m_lstWallIds.Length(); for (int n = 0; n < nCount; n++) { OPENOBJ_BEGIN(m_lstWallIds[n], AcDb::kForRead, TDbWall, pWall); if (pWall) { pWall->upgradeOpen(); //modify by xlc on 100701 解决move柱子后墙体缺口问题 #if (ADS == 16) // 注:其实这个问题是CAD2004问题特有的,一起拉伸墙体和柱子会崩溃 if(g_bColumnSkipStretch) { pWall->recordGraphicsModified(); } else { pWall->draw(); } #else pWall->draw(); #endif pWall->downgradeOpen(); } OPENOBJ_END(); } } TADSGePoint3d TDbColumn::GetLabelPos(BOOL bIsDefault) const { TADSGePoint3d pt = m_ptLabel; if (bIsDefault) { TADSGePoint3d pt1, pt2; GetExtents2d(pt1, pt2); double dTextSize = GetTextHeight(FALSE); ads_polar(pt2, ads_angle(pt1, pt2), dTextSize, pt); } pt.z = 0; return pt; } //柱子保温wlw bool TDbColumn::IsInsulateOnColumn() const { resbuf *pXData = NULL; bool bHasInsulate = false; pXData = this->xData(TDBCOLUMN_INSULATE); if (pXData != NULL) { resbuf* pRb = pXData; pRb = pRb->rbnext; if (NULL != pRb && pRb->restype == AcDb::kDxfXdInteger16) { bHasInsulate = pRb->resval.rint; } } return bHasInsulate; } void TDbColumn::SetInsulateOnColumn(bool bAdd) { bool bHasInsulate; AcGeVector3dArray arDir; ReadInsulateFromXData(bHasInsulate, arDir); WriteInsulateToXData(bAdd, arDir); return; } void TDbColumn::SetInsulateThick(double dThick) { m_nInsulateThick = dThick; } double TDbColumn::GetInsulateThick() const { return m_nInsulateThick; } void TDbColumn::SetInsulateLayerId(AcDbObjectId id) { m_idLayerInsulate = id; } AcDbObjectId TDbColumn::GetInsulateLayerId() const { return m_idLayerInsulate; } bool TDbColumn::AppendInsulateDir(AcGeVector3d vtDir) { if (!IsInsulateOnColumn()) { SetInsulateOnColumn(); } bool bHasInsulate; AcGeVector3dArray arDirs; vtDir.normalize(); ReadInsulateFromXData(bHasInsulate, arDirs); if (HasSurFaceWithVector(vtDir) && arDirs.length() > 0) { return true; } arDirs.append(vtDir); return WriteInsulateToXData(bHasInsulate, arDirs); } bool TDbColumn::RemoveInsulateDir(AcGeVector3d vtDir) { bool bHasInsulate; AcGeVector3d vtTemp; AcGeVector3dArray arDirs; TDPtrList lstSegsSurFace; //先判断该向量是否有保温 if (GetSurFaceWithVector(vtDir, lstSegsSurFace)) { //如果有才进行对比,找与其夹角最小的向量,将其移除 ReadInsulateFromXData(bHasInsulate, arDirs); for (int i = 0; i < arDirs.length(); i++) { if (HasSurFaceWithVector(arDirs[i], lstSegsSurFace)) { arDirs.removeAt(i); } } return WriteInsulateToXData(bHasInsulate, arDirs); } return false; } bool TDbColumn::ReadInsulateFromXData(bool& bHasInsulate, AcGeVector3dArray& arDir) const { assertReadEnabled(); bHasInsulate = false; arDir.setLogicalLength(0); AcGeVector3d vtTemp; resbuf *pXData = NULL; pXData = this->xData(TDBCOLUMN_INSULATE); if (pXData != NULL) { resbuf* pRb = pXData; pRb = pRb->rbnext; if (NULL != pRb && pRb->restype == AcDb::kDxfXdInteger16) { bHasInsulate = pRb->resval.rint; } if (m_lstWallIds.Length() > 1) { while (pRb != NULL) { pRb = pRb->rbnext; if (NULL != pRb && pRb->restype == AcDb::kDxfXdWorldXDir) { vtTemp.x = pRb->resval.rpoint[0]; vtTemp.y = pRb->resval.rpoint[1]; vtTemp.z = pRb->resval.rpoint[2]; arDir.append(vtTemp); } } } acutRelRb(pXData); return true; } return false; } bool TDbColumn::WriteInsulateToXData(bool bHasInsulate, const AcGeVector3dArray& arDir) { assertWriteEnabled(); AcGeVector3d vtTemp; resbuf *pXData = NULL; TGRegApp(TDBCOLUMN_INSULATE, database()); pXData = this->xData(TDBCOLUMN_INSULATE); if (pXData == NULL) { pXData = ads_buildlist(1001, TDBCOLUMN_INSULATE, NULL); } resbuf* pRb = NULL; resbuf* pRbTemp = NULL; pRbTemp = acutNewRb(AcDb::kDxfXdInteger16); pRbTemp->resval.rint = bHasInsulate; pXData->rbnext = pRbTemp; pRb = pRbTemp; //如果带保温,则将保温Dir数组存入xdata if (bHasInsulate) { for (int i = 0; i < arDir.length(); i++) { pRbTemp = acutNewRb(AcDb::kDxfXdWorldXDir); pRbTemp->resval.rpoint[0] = arDir[i].x; pRbTemp->resval.rpoint[1] = arDir[i].y; pRbTemp->resval.rpoint[2] = arDir[i].z; pRb->rbnext = pRbTemp; pRbTemp->rbnext = NULL; pRb = pRbTemp; } } Acad::ErrorStatus es = this->setXData(pXData); acutRelRb(pXData); if (es == Acad::eOk) { return true; } return false; } void TDbColumn::GetColSurFacePoly2D(TGGePoly2D& polySurFace,BOOL bPerfect) const { //bPerfect控制是否完美,柱子3D显示将弥补墙的缺角 //分两步走,1先得到带保温柱子与带保温墙的union后1个TGGePoly2D poly1 //2再算出柱子四周都带保温与墙的Intersect后1个TGGePoly2D poly2 // 最终2个TGGePoly2D再union得到完美的柱子保温线。 polySurFace = m_polyOutline; bool bHasIns = false; AcGeVector3dArray arDirs; arDirs.setLogicalLength(0); ReadInsulateFromXData(bHasIns, arDirs); if (bHasIns) {//有保温 TGGePoly2D polySur,poly1(m_polyOutline),poly2(m_polyOutline); int nDirLen = arDirs.length(), j = 0; TDPtrList lstSegsSurFinal; TDPtrList lstSurFinal; GetOffsetPoly2D(m_polyOutline,polySurFace,m_nInsulateThick); if (m_lstWallIds.Length() < 1 || nDirLen < 1) {//如果没墙或没有保温向量 return; } //1 for (j = 0; j < nDirLen; j++) { lstSegsSurFinal.Reset(); lstSurFinal.Reset(); polySur.Reset(); GetSurFaceWithVector(arDirs[j], lstSegsSurFinal); if (SearchPathFromCurve(lstSegsSurFinal, polySur)) { //与柱子基点构造成一个可以与m_polyOutline相交的区域 polySur.AppendNode(m_ptLocation); polySur.SetFlag(1); Union(poly1, polySur, lstSurFinal); if (lstSurFinal.Length() > 0) { poly1 = *lstSurFinal[0]; } } } if (!bPerfect) {//如果不求完美可以退出了 polySurFace = poly1; return; } //2 TDPtrList lstWallOutSurFace; TGGePoly2D polyWallOut(1); for (j = 0; j GetStartColumnId() == objectId() || pWall->GetEndColumnId() == objectId())) { pWall->GetOutlinePoly(0, polyWallOut,TRUE); lstWallOutSurFace.Append(new TGGePoly2D(polyWallOut)); } OPENOBJ_END(); } TDPtrList lstPoly1,lstPoly2,lstPolyOk; lstPoly1.Append(new TGGePoly2D(polySurFace)); //墙与offset了保温的polySurFace求Intersect Intersect(lstWallOutSurFace,lstPoly1,lstPoly2); if (lstPoly2.Length() > 0) { lstPoly1.Reset(); lstPoly1.Append(new TGGePoly2D(*lstPoly2[0])); lstPoly2.Remove(0); } //将Intersect后的墙段合并一个整体,只能分出一来,再与其他合并 Union(lstPoly1,lstPoly2,lstPolyOk); if (lstPolyOk.Length() > 0) { poly2 = *lstPolyOk[0]; } //最后与poly1 合并成完美的柱子保温线 lstPolyOk.Reset(); Union(poly1, poly2, lstPolyOk); if (lstPolyOk.Length() > 0) { polySurFace.Reset(); polySurFace = *lstPolyOk[0]; } } } void TDbColumn::GetColSurFaceLines(TDPtrList& lstSegsSurFace) const { int i = 0; TGGePoly2D polySurFace; GetOffsetPoly2D(m_polyOutline,polySurFace,m_nInsulateThick); //得到所有邻接墙的外轮廓-计算保温层使用 TDPtrList lstWallOutSurFace; for (i = 0; i GetStartColumnId() == objectId() || pWall->GetEndColumnId() == objectId())) { TGGePoly2D polyOut(1); if (pWall->GetUsageFlag() == TWallData::kVirtual) { //wlw 101112虚墙处理时将宽度设为最小,这样裁剪区域会小一些 TWallData virwalldata(*pWall); if (virwalldata.GetWidth(0) > 0.001) { virwalldata.SetWidth(0,1); } if (virwalldata.GetWidth(1) > 0.001) { virwalldata.SetWidth(1,1); } virwalldata.GetOutlinePoly(0,polyOut); } else { pWall->GetOutlinePoly(0, polyOut,TRUE); //一定是逆时针 } lstWallOutSurFace.Append(new TGGePoly2D(polyOut)); } OPENOBJ_END(); } TDPtrList lstMyPolySurFace,lstUnionSurFace; TGGePoly2D *pNewPolySurFace = new TGGePoly2D(polySurFace); lstMyPolySurFace.Append(pNewPolySurFace); Union(lstMyPolySurFace,lstWallOutSurFace,lstUnionSurFace); TGGePoly2D polyUnionSurFace(m_polyOutline); if (lstUnionSurFace.Length() == 1) { polyUnionSurFace = *lstUnionSurFace[0]; } //经过裁剪处理,得到保温的线 TDPtrList lstSegs,temp; ExplodePoly2D(polySurFace,lstSegs); PolyClip(lstSegs,polyUnionSurFace,temp,lstSegsSurFace); } void TDbColumn::GetColSurFaceFinal(TDPtrList& lstSegsSurFinal) const { int i = 0; int j = 0; bool bHasIns = false; double dgap = 10.0; //增大求交范围 AcGeVector3dArray arDirs; arDirs.setLogicalLength(0); lstSegsSurFinal.Reset(); ReadInsulateFromXData(bHasIns, arDirs); //不带保温 if (!bHasIns) { return; } int nCount = arDirs.length(); //得到所有剪裁好的保温层lines TDPtrList lstSegsSurLines; GetColSurFaceLines(lstSegsSurLines); if (nCount < 1) { lstSegsSurFinal.copyFrom(lstSegsSurLines); return; } TDPtrList lstWallOutSurFace; AcGeVector3d vtDir,vtTemp; ads_point ptInter1,ptInter2; TGGeCurveSegment line,lineTemp; TADSGePoint3d pts,pte,ptTemp; int nType = 0; //得到每个方向Dir上的保温线 for (i = 0; i < arDirs.length(); i++) { vtDir = arDirs[i]; line.SetStartPoint(m_ptLocation); line.SetEndPoint(m_ptLocation + vtDir * 100000); for (j = 0; j < lstSegsSurLines.Length(); j++) { lineTemp = *lstSegsSurLines[j]; //增大求交范围 pts = lineTemp.StartPoint(); pte = lineTemp.EndPoint(); vtTemp = pts - pte; vtTemp.normalize(); lineTemp.SetStartPoint(pts + vtTemp * dgap); lineTemp.SetEndPoint(pte - vtTemp * dgap); if (line.Intersection(lineTemp,ptInter1,ptInter2)) { ptTemp = ptInter1; if ((ptTemp & lineTemp) == PR_EXTEND) { continue; } GetConcatLine(pts, lstSegsSurLines, lstSegsSurFinal); GetConcatLine(pts, lstSegsSurLines, lstSegsSurFinal); //一个方向上只能有一次相交的可能 break; } } } } bool TDbColumn::HasSurFaceWithVector(AcGeVector3d vtDir) const { TDPtrList lstSegsSurFinal; GetColSurFaceFinal(lstSegsSurFinal); ads_point ptInter1,ptInter2; TGGeCurveSegment line,lineTemp; TADSGePoint3d ptTemp; vtDir.normalize(); line.SetStartPoint(m_ptLocation); line.SetEndPoint(m_ptLocation + vtDir * 100000); for (int j = 0; j < lstSegsSurFinal.Length(); j++) { lineTemp = *lstSegsSurFinal[j]; if (line.Intersection(lineTemp,ptInter1,ptInter2)) { ptTemp = ptInter1; lineTemp.SetLineFlag(LS_FINITE); if ((ptTemp & lineTemp) == PR_EXTEND) { continue; } return true; } } return false; } bool TDbColumn::HasSurFaceWithVector(AcGeVector3d vtDir, const TDPtrList& lstSegsSurFinal) const { ads_point ptInter1,ptInter2; TGGeCurveSegment line,lineTemp; TADSGePoint3d ptTemp; vtDir.normalize(); line.SetStartPoint(m_ptLocation); line.SetEndPoint(m_ptLocation + vtDir * 100000); for (int j = 0; j < lstSegsSurFinal.Length(); j++) { lineTemp = lstSegsSurFinal[j]; if (line.Intersection(lineTemp,ptInter1,ptInter2)) { ptTemp = ptInter1; if ((ptTemp & lineTemp) == PR_EXTEND) { continue; } return true; } } return false; } bool TDbColumn::GetSurFaceWithVector(AcGeVector3d vtDir, TDPtrList& lstSegsSurFace) const { TDPtrList lstSegsSurFinal; GetColSurFaceFinal(lstSegsSurFinal); ads_point ptInter1,ptInter2; TGGeCurveSegment line,lineTemp; TADSGePoint3d pts,pte,ptTemp; AcGeVector3d vtTemp; double dgap = 10.0; vtDir.normalize(); line.SetStartPoint(m_ptLocation); line.SetEndPoint(m_ptLocation + vtDir * 100000); for (int j = 0; j < lstSegsSurFinal.Length(); j++) { lineTemp = *lstSegsSurFinal[j]; //增大求交范围 pts = lineTemp.StartPoint(); pte = lineTemp.EndPoint(); vtTemp = pts - pte; vtTemp.normalize(); lineTemp.SetStartPoint(pts + vtTemp * dgap); lineTemp.SetEndPoint(pte - vtTemp * dgap); if (line.Intersection(lineTemp,ptInter1,ptInter2)) { ptTemp = ptInter1; if ((ptTemp & lineTemp) == PR_EXTEND) { continue; } GetConcatLine(pts, lstSegsSurFinal, lstSegsSurFace); GetConcatLine(pts, lstSegsSurFinal, lstSegsSurFace); //一个方向上只能有一次相交的可能 return true; } } return false; } bool TDbColumn::GetIntersectWithCurveSeg(const TGGeCurveSegment& segSrc, TADSGePoint3d& ptInter) { TGGeCurveSegment segTemp; ads_point ptInter1,ptInter2; AcGePoint3dArray arptIns; TADSGePoint3d ptTemp; TGGePoly2D polySurFace(m_polyOutline); if (IsInsulateOnColumn()) { GetOffsetPoly2D(m_polyOutline, polySurFace, m_nInsulateThick); } for (int i = 0; i < polySurFace.Length(); i++) { polySurFace.Nth(i,segTemp); if (segTemp.Intersection(segSrc, ptInter1, ptInter2)) { ptInter = ptInter1; if ((ptInter & segTemp) == PR_EXTEND) { continue; } arptIns.append(ptInter.AsAcGePoint3d()); } } int nLen = arptIns.length(); if (nLen == 1) { ptInter = arptIns[0]; return true; } else if (nLen == 2) { ptInter = arptIns[0]; ptTemp = arptIns[1]; if (ptInter.Distance(segSrc.MidPoint()) > ptTemp.Distance(segSrc.MidPoint())) { ptInter = ptTemp; } return true; } return false; } bool TDbColumn::GetIntersectWithLine(const TGGeLine& line, TADSGePoint3d& ptInter) { TGGeCurveSegment segTemp; ads_point ptInter1,ptInter2; AcGePoint3dArray arptIns; AcGePoint3d ptTemp = line.StartPoint(); TGGePoly2D polySurFace(m_polyOutline); if (IsInsulateOnColumn()) { GetColSurFacePoly2D(polySurFace,FALSE); } for (int i = 0; i < polySurFace.Length(); i++) { polySurFace.Nth(i,segTemp); segTemp.SetLineFlag(LS_FINITE); if (segTemp.Intersection(line, ptInter1, ptInter2)) { ptInter = ptInter1; arptIns.append(ptInter.AsAcGePoint3d()); } } int nLen = arptIns.length(); if (nLen == 0) { return false; } ptInter = arptIns[0]; if (nLen == 1) { return true; } for (i = 0; i < nLen - 1; i++) { if (ptTemp.distanceTo(arptIns[i + 1]) < ptTemp.distanceTo(ptInter)) { ptInter = arptIns[i + 1]; } } return true; } void TDbColumn::GetConcatLine(TADSGePoint3d ptStart, TDPtrList& lstSegsSrc, TDPtrList& lstSegsCon) const { int nCount = lstSegsSrc.Length(); int nPos = -1; TGGeCurveSegment line; bool bFlag = true; while (nCount > 0 && bFlag) { bFlag = false; for (int j = 0; j < nCount; j++) { line = *lstSegsSrc[j]; nPos = ptStart & line; if (nPos == PR_ONPT1 || nPos == PR_ONPT2) { lstSegsCon.Append(new TGGeCurveSegment(line)); if (ptStart.Distance(line.GetEndPoint()) < 1.0) { ptStart = line.GetStartPoint(); } else { ptStart = line.GetEndPoint(); } lstSegsSrc.Remove(j); bFlag = true; } nCount = lstSegsSrc.Length(); } } } //绘制-保温层 void TDbColumn::DrawInsulateLine(TGGiExplodeDrawBase &dc) const { //wlw11.01.12 mod 如果保温厚度0 则不画 if (GetInsulateThick() < 1.e-3) { return; } TDPtrList lstSurFaceFinal; TGGePoly2D polySurFace; GetColSurFaceFinal(lstSurFaceFinal); if (lstSurFaceFinal.Length() < 1) { return; } AcDbObjectId idOldLay = dc.GetLayerId(); int nColorOld = dc.GetColor(); dc.SetColorLayer(colorIndex(), m_idLayerInsulate); for (int n = 0; n < lstSurFaceFinal.Length(); n++) { dc << *lstSurFaceFinal[n]; } BOOL bIsWallHatch = FALSE; CString sPattern; Adesk::UInt16 nColor(256); AcDbObjectId id; if (m_lstWallIds.Length() > 0) { id = m_lstWallIds[0]; } OPENOBJ_BEGIN(id, AcDb::kForRead, TDbWall, pWall) AcDbObjectId idLineBlock; TDbPolyPathArray linepat; BOOL bFullExplode = FALSE; if (_tcscmp(dc.Desc(), TGGiWorldViewportDraw::Descriptor()) == 0) { bFullExplode = TRUE; } if (_tcscmp(dc.Desc(), TGGiExplodeDraw::Descriptor()) == 0) { bFullExplode = ((TGGiExplodeDraw &)dc).m_bFullExplode; } int nSaveFlag = 0; m_XDataMap.GetAt(_T("DownGradeSaveFlag"), nSaveFlag); int n = 0,nSide=0; TGGePoly2D poly2d; TADSGePoint3d ptOnln; TGGeCurveSegment seg; if (pWall) {//wlw add 140220 增加保温花线 pWall->GetSpecialtyDataReadOnly()->GetAt(idKEY_WALL_WARM_HATCH_PATTERN_ID, idLineBlock); pWall->GetSpecialtyDataReadOnly()->GetAt(bKEY_WALL_WARM_HATCH_OP, bIsWallHatch); pWall->GetSpecialtyDataReadOnly()->GetAt(nKEY_WALL_WARM_HATCH_COLOR, (int&)nColor); if (pWall->GetUsageFlag() == TWallData::kParapet) { bIsWallHatch = FALSE; } if (bIsWallHatch && bFullExplode && !g_bOsnapExpl) { linepat.SetUnitId(idLineBlock); for (n = 0; n < lstSurFaceFinal.Length(); n++) { seg = *lstSurFaceFinal[n]; nSide = pWall->OnWhichSide(lstSurFaceFinal[n]->MidPoint()); double ddist = GetInsulateThick(); for (int j = 0; j < m_polyOutline.Length(); j++) { TADSGePoint3d pt = m_polyOutline[j]; lstSurFaceFinal[n]->ProjectToMe(pt,ptOnln); //为了避免墙相交时图案重叠 if (fabs(ddist - ptOnln.Distance2d(pt)) < 1 && ((ptOnln & seg) == PR_INSIDE)) { if (lstSurFaceFinal[n]->StartPoint().Distance2d(ptOnln) < lstSurFaceFinal[n]->EndPoint().Distance2d(ptOnln)) { seg.SetStartPoint(ptOnln); } else { seg.SetEndPoint(ptOnln); } } } poly2d.Reset(); seg.AsPoly2D(poly2d); linepat.SetBaseType(1);//0,左,1,右,2,中 linepat.SetUnitHeight(GetInsulateThick()); linepat.SetPathPoly(poly2d,AcGeVector3d::kZAxis); linepat.SetRatio(1); if (nSaveFlag == 1) { linepat.setLayer(dc.GetLayerId()); linepat.setColorIndex(dc.GetColor()); dc.DrawEntity(linepat); } else { BOOL bWallLinepatClipOld = g_bWallLinepatClip; if (_tcscmp(dc.Desc(), TGGiWorldViewportDraw::Descriptor())==0) { g_bWallLinepatClip = TRUE; } linepat.ExplodeOrDraw2d(dc); g_bWallLinepatClip = bWallLinepatClipOld; } } } } OPENOBJ_END(); dc.SetLayer(idOldLay); dc.SetColor(nColorOld); /* 测试用,保温方向线 bool bhasins = false; AcGeVector3dArray vts; ReadInsulateFromXData(bhasins,vts); for (n = 0; n < vts.length(); n++) { TGGeCurveSegment seg; seg.SetStartPoint(m_ptLocation); AcGePoint3d pttemp = m_ptLocation.AsAcGePoint3d(); pttemp += vts[n] * 500; TADSGePoint3d ptsss = pttemp; seg.SetEndPoint(ptsss); dc << seg; } */ } //nside = 1 加内墙方向柱子保温 = 0加外墙方向柱子保温 void TDbColumn::DrawInsulateInExt(int nSide) { TDPtrList lstSegsSurFinal,lstSegsSurFace; GetColSurFaceLines(lstSegsSurFinal); TADSGePoint3d ptOnline; TGGePoly2D poly(1); TGGeCurveSegment segIns; int nPolySize = 0; while (lstSegsSurFinal.Length() > 0) { lstSegsSurFace.Reset(); poly.Reset(); ptOnline = lstSegsSurFinal[0]->StartPoint(); GetConcatLine(ptOnline, lstSegsSurFinal, lstSegsSurFace); GetConcatLine(ptOnline, lstSegsSurFinal, lstSegsSurFace); if (SearchPathFromCurve(lstSegsSurFace,poly)) { nPolySize = poly.Length(); if (nPolySize > 1) { poly.Nth(0,segIns); if (segIns.StartPoint().Distance2d(*poly[0]) > 0.01) { segIns.StartPoint() = *poly[0]; segIns.EndPoint() = *poly[1]; if (fabs(segIns.m_dBulge) > 0.0) { segIns.m_dBulge *= -1; } } if (!DrawInsulateInExtByPt(nSide,segIns)) { poly.Nth(nPolySize - 2, segIns); if (segIns.StartPoint().Distance2d(*poly[nPolySize - 1]) > 0.01) { segIns.StartPoint() = *poly[nPolySize - 1]; segIns.EndPoint() = *poly[nPolySize - 2]; if (fabs(segIns.m_dBulge) > 0.0) { segIns.m_dBulge *= -1; } } DrawInsulateInExtByPt(nSide,segIns); } } } } } BOOL TDbColumn::DrawInsulateInExtByPt(int nSide, const TGGeCurveSegment& segIns) { TADSGePoint3d ptOnline; int nSideT = 0,nPos = 0; TGGeCurveSegment segwalloff; for (int i = 0; i < m_lstWallIds.Length(); i++) { OPENOBJ_BEGIN(*m_lstWallIds[i],AcDb::kForRead,TDbWall,pWall); if (pWall) { ptOnline = segIns.StartPoint(); nSideT = pWall->OnWhichSide(ptOnline); segwalloff = pWall->Offset(nSideT, (pWall->GetWidth(nSideT + 2)),LS_FINITE); nPos = (ptOnline & segwalloff); if (nPos > PR_OUTSIDE && nPos < PR_EXTEND) { if (pWall->GetExtSide() == -1) {//与该处链接的墙没有设置内外 return FALSE; } ptOnline = segIns.EndPoint(); if (GetSectionShape() == TColumnData::kCircle) { ptOnline = segIns.MidPoint(); } if (nSide) {//内墙保温 if (!pWall->IsExternal1(nSideT)) { AppendInsulateDir(ptOnline - m_ptLocation); } } else {//外墙保温 if (pWall->IsExternal1(nSideT)) { AppendInsulateDir(ptOnline - m_ptLocation); } } } } OPENOBJ_END(); } return TRUE; } bool TDbColumn::GetStandardFaceBody(AcDbVoidPtrArray& arFacePtrs) const { GetSafeProtectedSpace(arFacePtrs); return arFacePtrs.length() > 0; } bool TDbColumn::GetSafeProtectedSpace(AcDbVoidPtrArray& arFacePtrs) const { TGGeCurveSegment seg; TGGePoly2D poly(m_polyOutline); if (IsInsulateOnColumn()) { GetOffsetPoly2D(m_polyOutline,poly,m_nInsulateThick); } TADSGePoint3d ptCen = poly.GetInsidePoint(),pts,pte,ptCenOn; for (int i = 0; i < poly.Length(); i++) { poly.Nth(i, seg); arFacePtrs.append(GetFaceFromSegment(seg, m_nHeight)); pts = seg.StartPoint(); pte = seg.EndPoint(); arFacePtrs.append(new AcDbFace(ptCen,pts,pte,ptCen)); pts[2] = m_nHeight; pte[2] = m_nHeight; ptCenOn[2] = m_nHeight; arFacePtrs.append(new AcDbFace(ptCenOn,pts,pte,ptCenOn)); } return arFacePtrs.length() > 0; } // 注意 GetSection内不应将std::vector参数清空 bool TDbColumn::GetSection(const AcDbFace &face, const AcGeVector3d& vtPlaneSecDir, std::vector §ionRecord, AcDbVoidPtrArray& arFillPtrs) const { TGGeSectionPlane section_pln(face, vtPlaneSecDir); // 构造一个剖面 TSectionShape shape = GetSectionShape(); if (shape == 2) // 圆 { TGGePoly2D poly = GetOutlinePoly();// 现有版本,取出来的只有两个点 if (poly.Length() >= 2) { AcGePoint3d pt1(poly[0]->AsAcGePoint3d()), pt2(poly[1]->AsAcGePoint3d()); double dRadius = pt1.distanceTo(pt2) * .5; AcGePoint3d ptLoc = GetLocation().AsAcGePoint3d(); AcGeVector3d vt1 = vtPlaneSecDir, vt2 = vtPlaneSecDir; vt1.normalize(); vt2.normalize(); vt1.rotateBy(PI * .5, AcGeVector3d::kZAxis); vt2.rotateBy(-PI * .5, AcGeVector3d::kZAxis); vt1 *= dRadius; vt2 *= dRadius; pt1 = ptLoc + vt1; pt2 = ptLoc + vt2; AcGePoint3d pt3(pt2), pt4(pt1); pt3.z = pt4.z = GetElevation(); pt1.z = pt2.z = pt3.z + GetHeight(); TGGePoly2D poly; poly.AppendNode(pt1); poly.AppendNode(pt2); poly.AppendNode(pt3); poly.AppendNode(pt4); poly.SetClosed(); TGGeSectionPlane plane(poly, vtPlaneSecDir); poly.Reset(); double dDis = SectionUtility::Projection_plane2plane(section_pln, plane, poly); sectionRecord.push_back(TObjSectionRecord(objectId(), layerId(), TObjSectionRecord::eTCH_WALL, dDis, poly)); } } else { SectionUtility::FillRecordsByPoly(m_polyOutline, section_pln, sectionRecord, GetElevation(), GetHeight(), *this); } // 添充功能待定 return true; } CString TDbColumn::GetXml(const AcGeMatrix3d& mat) const { TXmlTree xmlTree; POSITION posRoot = xmlTree.Insert(_T("ATS_COLUMN"), NULL, NULL); { xmlTree.SetAttribute(posRoot, _T("name"), _T("柱")); xmlTree.SetAttribute(posRoot, _T("comment"), _T("上华对象名称")); } CString strText; POSITION posItem1 = xmlTree.Insert(_T("Object_ID"), posRoot, NULL); { xmlTree.SetAttribute(posItem1, _T("name"), _T("对象编号")); xmlTree.SetAttribute(posItem1, _T("comment"), _T("当前对象的句柄")); strText.Format(_T("%ld"), objectId()); xmlTree.SetItemText(posItem1, strText); } POSITION posItem = NULL; POSITION posItem2 = xmlTree.Insert(_T("Link_WALL"),posRoot, posItem1); { xmlTree.SetAttribute(posItem2, _T("name"), _T("连接墙体")); for (int i = 0; i < m_lstWallIds.Length(); i++) { posItem = xmlTree.Insert(_T("Link_ID"), posItem2, posItem); xmlTree.SetAttribute(posItem, _T("name"), _T("墙体句柄")); strText.Format(_T("%ld"), m_lstWallIds[i]); xmlTree.SetItemText(posItem, strText); } } POSITION posItem3 = xmlTree.Insert(_T("Property"), posRoot, posItem2); { xmlTree.SetAttribute(posItem3, _T("name"), _T("截面特性")); xmlTree.SetAttribute(posItem3, _T("comment"), _T("截面特性包括矩形到异形柱等8类")); xmlTree.SetItemText(posItem3, GetSectionShape(GetSectionShape())); posItem = xmlTree.Insert(_T("Material"), posItem3, NULL); { xmlTree.SetAttribute(posItem, _T("name"), _T("柱材料")); xmlTree.SetAttribute(posItem, _T("comment"), _T("柱子使用的材料")); CString strMaterial; if (!GetSpecialtyDataReadOnly()->GetAt(sKEY_COLUMN_HATCH_PATTERN, strMaterial)) { strMaterial = GetMaterialText(); if (strMaterial == "钢筋混凝土") strMaterial = "混凝土"; } xmlTree.SetItemText(posItem, strMaterial); } POSITION posItem4 = NULL; //截面参数节点 switch (GetSectionShape()) { case kCircle: { posItem4 = xmlTree.Insert(__T("Circle"), posItem3, posItem); { xmlTree.SetAttribute(posItem4, _T("name"), _T("圆形参数")); xmlTree.SetAttribute(posItem4, _T("comment"), _T("用于圆柱")); } TADSGePoint3d ptPara = GetParameters(); posItem = NULL; posItem = xmlTree.Insert(__T("Center_point"), posItem4, posItem); { // sg modify 120117,对点进行坐标变换 TADSGePoint3d ptTransformBy = GetLocation(); ptTransformBy.TransformBy(mat); xmlTree.SetAttribute(posItem, _T("name"), _T("圆心点")); // strText.Format(_T("%f,%f,%f"), GetLocation().x, GetLocation().y, GetLocation().z); strText.Format(_T("%f,%f,%f"), ptTransformBy.x, ptTransformBy.y, ptTransformBy.z); xmlTree.SetItemText(posItem, strText); } posItem = xmlTree.Insert(__T("Diameter"), posItem4, posItem); { xmlTree.SetAttribute(posItem, _T("name"), _T("直径")); strText.Format(_T("%f"), ptPara.x); xmlTree.SetItemText(posItem, strText); } } break; case kRect: //矩形 case kPoly: //异形柱 { posItem4 = xmlTree.Insert(__T("Baseline"), posItem3, posItem); { xmlTree.SetAttribute(posItem4, _T("name"), _T("基线参数")); xmlTree.SetAttribute(posItem4, _T("comment"), _T("用于矩形柱和异形柱")); } posItem = NULL; CString strTab,strKeyVal; TADSGePoint3d pt; for (int i = 0; i < m_polyOutline.Length(); i++) { pt = m_polyOutline[i]; // sg add 120117,对点进行坐标变换 pt.TransformBy(mat); strTab.Format(_T("Point_%d"), i + 1); posItem = xmlTree.Insert(strTab, posItem4, posItem); { strKeyVal.Format(_T("第%d点"), i + 1); xmlTree.SetAttribute(posItem, _T("name"), strKeyVal); strText.Format(_T("%f,%f,%f"), pt.x, pt.y, pt.z); xmlTree.SetItemText(posItem, strText); } strTab.Format(_T("Ang_%d"), i + 1); posItem = xmlTree.Insert(strTab, posItem4, posItem); { strKeyVal.Format(_T("圆心角%d"), i + 1); xmlTree.SetAttribute(posItem, _T("name"), strKeyVal); strText.Format(_T("%f"), m_polyOutline.GetBulge(i)); xmlTree.SetItemText(posItem, strText); } } } break; case kStd3: case kStd5: case kStd6: case kStd8: case kStd12: //多边形 { posItem4 = xmlTree.Insert(__T("Polygon"), posItem3, posItem); { xmlTree.SetAttribute(posItem4, _T("name"), _T("多边形参数")); xmlTree.SetAttribute(posItem4, _T("comment"), _T("用于三角形到十二边形")); } TADSGePoint3d ptPara = GetParameters(); posItem = NULL; posItem = xmlTree.Insert(__T("Center_point"), posItem4, posItem); { // sg modify 120117,对点进行坐标变换 TADSGePoint3d ptTransformBy = GetLocation(); ptTransformBy.TransformBy(mat); xmlTree.SetAttribute(posItem, _T("name"), _T("圆心点")); // strText.Format(_T("%f,%f,%f"), GetLocation().x, GetLocation().y, GetLocation().z); strText.Format(_T("%f,%f,%f"), ptTransformBy.x, ptTransformBy.y, ptTransformBy.z); xmlTree.SetItemText(posItem, strText); } posItem = xmlTree.Insert(__T("Diameter"), posItem4, posItem); { xmlTree.SetAttribute(posItem, _T("name"), _T("直径")); strText.Format(_T("%f"), ptPara.y); xmlTree.SetItemText(posItem, strText); } posItem = xmlTree.Insert(__T("Side_leng"), posItem4, posItem); { xmlTree.SetAttribute(posItem, _T("name"), _T("边长")); strText.Format(_T("%f"), ptPara.x); xmlTree.SetItemText(posItem, strText); } } break; } } // cet 2014.1.28 add 添加柱的插入点 POSITION posItemLoc = xmlTree.Insert(__T("Location"), posRoot, posItem3); { TADSGePoint3d ptTransformBy = GetLocation(); ptTransformBy.TransformBy(mat); xmlTree.SetAttribute(posItemLoc, _T("name"), _T("插入点")); strText.Format(_T("%f,%f,%f"), ptTransformBy.x, ptTransformBy.y, ptTransformBy.z); xmlTree.SetItemText(posItemLoc, strText); posItem3 = posItemLoc; } POSITION posItem5 = xmlTree.Insert(_T("Height"), posRoot, posItem3); { xmlTree.SetAttribute(posItem5, _T("name"), _T("高度参数")); posItem = NULL; posItem = xmlTree.Insert(_T("Net_height"), posItem5, posItem); { xmlTree.SetAttribute(posItem, _T("name"), _T("柱高")); xmlTree.SetAttribute(posItem, _T("comment"), _T("从柱底起算的柱高")); strText.Format(_T("%f"), GetHeight()); xmlTree.SetItemText(posItem, strText); } posItem = xmlTree.Insert(_T("Bottom_height"), posItem5, posItem); { xmlTree.SetAttribute(posItem, _T("name"), _T("底标高")); xmlTree.SetAttribute(posItem, _T("comment"), _T("柱底的相对标高")); strText.Format(_T("%f"), GetElevation()); xmlTree.SetItemText(posItem, strText); } } POSITION posItem6 = xmlTree.Insert(_T("Angle"), posRoot, posItem5); { xmlTree.SetAttribute(posItem6, _T("name"), _T("转角")); strText.Format(_T("%f"), GetRotation()); xmlTree.SetItemText(posItem6, strText); } CString strBase = TEntityBase::GetXml(mat); CString strXml = xmlTree.GetXml(); int nIndex = strXml.Find(_T("isKindOf(TDbPolyPathArray::desc())) ) { arpents.append(entSet[i]); } /*导出低版本不支持,否则与全局填充重叠 else if (pent->isKindOf(AcDbHatch::desc())) { BOOL bIsWallHatch = FALSE; m_XDataMap.GetAt(bKEY_COLUMN_FILLING_OP, bIsWallHatch); if (bIsWallHatch) {//只有是自定义的hatch才导出 if (pent->layerId() == m_idLayerHatch2d) { arpents.append(entSet[i]); } } } */ } entSet = (arpents); } } return TDbEntity::DownGradeSave(nDrawMode, entSet, bErase); /* Acad::ErrorStatus es = Acad::eOk; if (nDrawMode == DRAW_3D) { if (bErase) { *bErase = FALSE; } return es; } if (g_nSaveTArchVer <= 8) //TArch8之前版本 { if (GetInsulateThick() < 1.e-3 || !IsInsulateOnColumn()) //无保温 { if (bErase) { *bErase = FALSE; } } else { TDbColumn *pNewSet=NULL; { XPushMemVar vTemp(g_nSaveTArchVer,_TCH_VERSION); pNewSet=(TDbColumn*)clone(); } pNewSet->SetInsulateOnColumn(false); entSet.append(pNewSet); TGGiExplodeDraw dc(entSet); DrawInsulateLine(dc); if (bErase) { *bErase = TRUE; } } } else { if (bErase) { *bErase = FALSE; } } return es; */ } CString TDbColumn::GetT20ColMat() const { assertReadEnabled(); CString sMat = _T(""); m_XDataMap.GetAt(sKEY_COLUMN_FILLING_MATERIAL, sMat); return sMat; } void TDbColumn::SetT20ColMat(CString sMat) { assertWriteEnabled(); m_XDataMap.SetAt(sKEY_COLUMN_FILLING_MATERIAL, sMat); }