#include "stdafx.h" #include "AcDbObjectPtr.h" #include "dbobjptr.h" #include "DbPool.h" #include "DbPipe.h" #include "DbWellDim.h" #include "globalFunc.h" #include "globalDefine.h" #include #include "AecDbMText.h" #include "DbRect.h" const Adesk::UInt8 CDbPool::g_nVersion = 1; ACRX_DXF_DEFINE_MEMBERS(CDbPool, CHDbEquipment, AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent, 1, AEC_ZT_POOL, "AEC_POOL图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com"); void InitDbPool(BOOL bTrue) { if (bTrue) { CDbPool::rxInit(); //CDbPool::InitMatchProtocol(TRUE); } else { //CDbPool::InitMatchProtocol(FALSE); deleteAcRxClass(CDbPool::desc()); } } CDbPool::CDbPool() { m_dBottomBanEle = 0.0; m_dGroundEle = 0.0; m_dTopBanEle = 0.0; m_dSpare = 0.0; m_nSpare = 0; m_sSpare = _T(""); m_bIsModify = false; } CDbPool::~CDbPool() { } //Acad::ErrorStatus CDbPool::subGetClassID(CLSID* pClsid) const //{ // return Acad::eOk; //} Acad::ErrorStatus CDbPool::dwgInFields (AcDbDwgFiler* pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = CHDbEquipment::dwgInFields(pFiler); if(es != Acad::eOk) return es; Adesk::UInt8 nVer = 0; pFiler->readItem(&nVer); if(nVer>g_nVersion) {// Version is too new return Acad::eMakeMeProxy; } pFiler->readItem(&m_dTopBanEle); pFiler->readItem(&m_dBottomBanEle); pFiler->readItem(&m_dGroundEle); pFiler->readItem(&m_dSpare); pFiler->readItem(&m_nSpare); GlobalFunc::ReadString(pFiler,m_sSpare); return pFiler->filerStatus(); } Acad::ErrorStatus CDbPool::dwgOutFields(AcDbDwgFiler *pFiler) const { assertReadEnabled(); Acad::ErrorStatus es = CHDbEquipment::dwgOutFields(pFiler); if(es != Acad::eOk) return es; pFiler->writeItem(g_nVersion); pFiler->writeItem(m_dTopBanEle); pFiler->writeItem(m_dBottomBanEle); pFiler->writeItem(m_dGroundEle); pFiler->writeItem(m_dSpare); pFiler->writeItem(m_nSpare); pFiler->writeString(m_sSpare); //写入起点个数 return pFiler->filerStatus(); } Acad::ErrorStatus CDbPool::dxfInFields (AcDbDxfFiler *pFiler) { assertWriteEnabled(); Acad::ErrorStatus es = CHDbEquipment::dxfInFields(pFiler); if(es!=Acad::eOk) return pFiler->filerStatus(); if (!pFiler->atSubclassData(_T("CDbPool"))) { return Acad::eBadDxfSequence; } return pFiler->filerStatus(); } Acad::ErrorStatus CDbPool::dxfOutFields(AcDbDxfFiler *pFiler) const { assertReadEnabled(); Acad::ErrorStatus es=CHDbEquipment::dxfOutFields(pFiler); assert(es == Acad::eOk); es = pFiler->writeItem(AcDb::kDxfSubclass,_T("CDbPool")); assert(es == Acad::eOk); return Acad::eOk; } AcGeScale3d CDbPool::GetInsert2dScale() const { assertReadEnabled(); AcGeScale3d scale(1); scale.sx *= m_dSizeX; scale.sy *= m_dSizeY; if (IsMirrorByY()) scale.sx *= -1; if (IsMirrorByX()) scale.sy *= -1; return scale; } Acad::ErrorStatus CDbPool::Draw2d(AcGiDraw &dc) const { // cet 2016.10.17 add 图层关闭时,实体不显示,不进行绘制(打印时,也不会绘制) AcDbLayerTableRecordPointer player(this->layerId(), AcDb::kForRead); if (player.openStatus() == Acad::eOk && player->isOff()) { return Acad::eOk; } if(!m_idBlock2d.isValid()) return Acad::eInvalidInput; if(fabs(m_vtDirection.x)<1.0E-6 && fabs(m_vtDirection.y)<1.0E-6) return Acad::eOk; //垂直设备 AcGeScale3d scale=GetInsert2dScale(); OPENOBJ_BEGIN(m_idBlock2d, AcDb::kForRead, AcDbBlockTableRecord, pBlock); if(pBlock != NULL) { XPoint ptLocation(m_ptLocation); ptLocation.z=0; double dAngle = ads_angle(XPoint(),m_vtDirection); // BOOL bNewMethod=(g_nAcadVer>15.0001 && g_bMakeBlock); // sg add 091105,强制打印时,不使用新方法 // if (_tcscmp(dc.Desc(), XAcGiViewDraw::Descriptor())==0 && dc.IsPlotGeneration()) // bNewMethod = FALSE; //2011-9-30 SBdc.DrawBlock(*pBlock,ptInsert,GetInsertScale(),dAngle,TRUE); 采用旧方法,从8.0版本开始,TRUE参数对于打印不起作用。关闭图层,仍然打印 //dc.DrawBlock(*pBlock,ptLocation,scale,dAngle,bNewMethod); dc.DrawBlock(*pBlock,ptLocation,scale,dAngle,TRUE); } OPENOBJ_END(); /* //绘制接口 for(int i=0; iGetStartPoint(ptS); pPipe->GetEndPoint(ptE); pPipe->close(); } double dEle = m_ptLocation.z; if (ptS.Distance2d(pt) < g_Option::instance()._DIST_SNAP) { dEle = ptS.z; } else if (ptE.Distance2d(pt) < g_Option::instance()._DIST_SNAP) { dEle = ptE.z; } AcGeVector3d vt = AcGeVector3d::kZAxis; if (dEle >= m_dBottomBanEle * dMeter && dEle <= m_dTopBanEle * dMeter) { vt *= (dEle - m_dBottomBanEle * dMeter) * (-1); } else if (dEle < m_dBottomBanEle * dMeter && dEle < m_dTopBanEle * dMeter) { double dMin = m_dBottomBanEle < m_dTopBanEle ? m_dBottomBanEle: m_dTopBanEle; vt *= (dMin * dMeter - dEle); } else if (dEle > m_dBottomBanEle * dMeter && dEle > m_dTopBanEle * dMeter) { double dMin = m_dBottomBanEle < m_dTopBanEle ? m_dBottomBanEle: m_dTopBanEle; vt *= (dMin * dMeter - dEle); } AcGeMatrix3d mat; AcGeVector3d vt2 = AcGeVector3d::kZAxis; vt2 *= (dEle - m_ptLocation.z); mat.setTranslation(vt2); poly2d2.TransformBy(mat); mat.setTranslation(vt); poly2d2.TransformBy(mat); } //dc.DrawBody(poly2d2, vt2); DrawPoly2D(dc, poly2d2); return Acad::eOk; } Acad::ErrorStatus CDbPool::subGetOsnapPoints(AcDb::OsnapMode osnapMode, INT_PTR gsSelectionMark, const AcGePoint3d& ptPick, const AcGePoint3d& lastPoint, const AcGeMatrix3d& viewXform, AcGePoint3dArray& snapPoints, AcDbIntArray& geomIds) const { assertReadEnabled(); Acad::ErrorStatus es=Acad::eOk; if (osnapMode == AcDb::kOsModeIns || osnapMode == AcDb::kOsModeCen) { snapPoints.append(m_ptLocation); } AcDbVoidPtrArray arEnts; AcDbVoidPtrArray arBlocks; AcDbBlockReference *pBlock = NULL; this->explode(arEnts); //第一次炸碎成图块和文字 for (int j = 0; j < arEnts.length(); ++j) { pBlock = AcDbBlockReference::cast((AcDbEntity*)arEnts[j]); if (pBlock != NULL) break; } if (pBlock != NULL) { pBlock->explode(arBlocks); for (int i = 0; i < arBlocks.length(); ++i) { AcDbEntity *pEnt = (AcDbEntity*)arBlocks[i]; pEnt->getOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds); } } es = CDbPipeNode::subGetOsnapPoints(osnapMode, gsSelectionMark, ptPick, lastPoint, viewXform, snapPoints, geomIds); GlobalFunc::ReleaseEntSet(arEnts); GlobalFunc::ReleaseEntSet(arBlocks); return es; } // 对st类型的接口进行重新连接 void CDbPool::UpdateLinkage(const XPoint &ptAt, TPipeSys::SysType st, const DList &idPipes) { // 更新接口 cet 2011.11.10 add std::vector vecId; for (int i = 0; i < m_lstInterface.Length(); ++i) { if (m_lstInterface[i]->m_idPipe.isValid() && !m_lstInterface[i]->m_idPipe.isErased()) { if (!CanLinkSide(m_lstInterface[i]->m_idPipe, 0) && !CanLinkSide(m_lstInterface[i]->m_idPipe, 1)) { m_lstInterface[i]->m_idPipe.setNull(); } } } XPoint ptFit; for (int j = 0; j < idPipes.Length(); ++j) { for (int i = 0; i < m_lstInterface.Length(); ++i) { OPENOBJ_BEGIN(idPipes[j], AcDb::kForRead, CDbPipePrototype, pPipe); if (pPipe != NULL) { ptFit = GetILocation(i); XPoint ptPipeS,ptPipeE; ptPipeS = pPipe->StartPoint(); ptPipeE = pPipe->EndPoint(); ptPipeS.z = 0; ptPipeE.z = 0; ptFit.z = 0; AcGeVector3d vtDir1 = ptFit - ptPipeE; AcGeVector3d vtDir2 = ptFit - ptPipeS; //判断连接点是否有管子 if (vtDir1.isParallelTo(vtDir2) || vtDir1.isZeroLength() || vtDir2.isZeroLength()) { if (ptFit.Distance(ptPipeS) <= ptPipeE.Distance(ptPipeS) && ptFit.Distance(ptPipeE) <= ptPipeS.Distance(ptPipeE)) { CPipeInterface &iFace = *m_lstInterface[i]; iFace.m_sysType = pPipe->GetSysType(); iFace.m_idPipe = pPipe->objectId(); iFace.m_faceType = CPipeInterface::kNodeLocation; break; } } else { XLine line(pPipe->GetStartPoint(),pPipe->GetEndPoint(), LS_FINITE); // cet 2013.3.6 modify 保证在直线内计算 //求得炸碎的实体 AcArray > arSegs; GetExplodeCurves(this,arSegs); //sr modify : GetExplodeCurves(this,arSegs); 091109 //判断是否连接 XPoint ptCon; BOOL bRet1 = CheckIsConnect(pPipe->StartPoint(),arSegs,line,ptCon); BOOL bRet2 = CheckIsConnect(pPipe->EndPoint(),arSegs,line,ptCon); if (bRet1 || bRet2) { // cet 2016.4.27 modify 先查找管道是否已存在接口点,不存在时,使用空闲接口 // int nIndex = GetFreeInterfaceIndex(); int nIndex = -1; for (int i = 0; i < m_lstInterface.Length(); ++i) { if (m_lstInterface[i]->m_idPipe.isValid() && m_lstInterface[i]->m_idPipe == pPipe->id()) { nIndex = i; break; } } if (nIndex < 0) { nIndex = GetFreeInterfaceIndex(); } if (nIndex < 0) { //没有空闲的接口则增加新的接口 if (!FindInterfaceByPt(ptCon)) { // cet 2016.4.27 modify 接口从1开始查找未使用的序号 // CString sCount; // sCount.Format(_T("%d"),m_lstInterface.Length()+1); // AddInterface(sCount,ptCon,m_vtDirection); std::set setIndex; CString sLabel; for (int i = 0; i < m_lstInterface.Length(); ++i) { const CPipeInterface& iFace= GetInterface(i); sLabel = TString(iFace.m_sSysLabel); setIndex.insert(sLabel); } int nNum = 1; CString sCount; sCount.Format(_T("%d"), nNum); while(setIndex.count(sCount) != 0) { ++nNum; sCount.Format(_T("%d"), nNum); } AddInterface(sCount,ptCon,m_vtDirection); FindInterface(sCount)->m_idPipe = pPipe->objectId(); FindInterface(sCount)->m_sysType = pPipe->GetSysType(); FindInterface(sCount)->m_faceType = CPipeInterface::kNodeLocation; } } else { //移动空闲接口到合适位置 m_lstInterface[nIndex]->m_idPipe = pPipe->objectId(); m_lstInterface[nIndex]->m_sysType = pPipe->GetSysType(); m_lstInterface[nIndex]->m_faceType = CPipeInterface::kNodeLocation; m_lstInterface[nIndex]->m_ptLocation = ptCon; } break; } } } OPENOBJ_END(); } } } // 判断节点是否可以连接管段. nPos: 0--start; 1--end BOOL CDbPool::CanLinkSide(const AcDbObjectId &idPipe, int nPos) const { BOOL bRet=FALSE; /* OPENOBJ_BEGIN(idPipe, AcDb::kForRead, CDbPipePrototype, pPipe); if(pPipe) { XPoint ptRef = nPos? pPipe->EndPoint() : pPipe->StartPoint(); ptRef.z = 0; XPoint ptLoc=GetLocation(); ptLoc.z = 0; // if(ptRef.Distance(ptLoc)EndPoint() : pPipe->StartPoint(); ptRef.z = 0; XLine line(pPipe->GetStartPoint(),pPipe->GetEndPoint()); //求得炸碎的实体 AcArray > arSegs; GetExplodeCurves(this->objectId(),arSegs); //判断是否连接 XPoint ptCon; bRet = CheckIsConnect(ptRef,arSegs,line,ptCon); for (int i = 0; i < m_lstInterface.Length(); ++i) { XPoint ptFit = GetILocation(i); ptFit.z = 0; if (ptRef.Distance(ptFit)StartPoint(); ptPipeE = pPipe->EndPoint(); ptPipeS.z = 0; ptPipeE.z = 0; ptFit.z = 0; AcGeVector3d vtDir1 = ptFit - ptPipeE; AcGeVector3d vtDir2 = ptFit - ptPipeS; if (vtDir1.isParallelTo(vtDir2) || vtDir1.isZeroLength() || vtDir2.isZeroLength()) { if (ptFit.Distance(ptPipeS) <= ptPipeE.Distance(ptPipeS) && ptFit.Distance(ptPipeE) <= ptPipeS.Distance(ptPipeE)) { //导线过长需要裁剪 if (ptPipeS.Distance(m_ptLocation) < ptPipeE.Distance(m_ptLocation)) { ptFit.z = pPipe->StartPoint().z; pPipe->SetStartPoint(ptFit); } else { ptFit.z = pPipe->EndPoint().z; pPipe->SetEndPoint(ptFit); } CPipeInterface &iFace = *m_lstInterface[i]; iFace.m_sysType = pPipe->GetSysType(); iFace.m_idPipe = pPipe->objectId(); iFace.m_faceType = CPipeInterface::kNodeLocation; } else { //导线过短,需要补上 XPoint ptLocation = GetLocation(); ptLocation.z = 0; AcGeVector3d vt = ptLocation - ptFit; AcGeVector3d vt1 = ptLocation - ptPipeS; AcGeVector3d vt2 = ptLocation - ptPipeE; if (vt.angleTo(vt1) < PI/2 || vt.angleTo(vt2) < PI/2) { if (ptPipeS.Distance(m_ptLocation) < ptPipeE.Distance(m_ptLocation)) { ptFit.z = pPipe->StartPoint().z; pPipe->SetStartPoint(ptFit); } else { ptFit.z = pPipe->EndPoint().z; pPipe->SetEndPoint(ptFit); } CPipeInterface &iFace = *m_lstInterface[i]; iFace.m_sysType = pPipe->GetSysType(); iFace.m_idPipe = pPipe->objectId(); iFace.m_faceType = CPipeInterface::kNodeLocation; } } } else { if (m_lstInterface[i]->m_idPipe == pPipe->objectId()) { if (ptPipeS.Distance(m_ptLocation) < ptPipeE.Distance(m_ptLocation)) { ptFit.z = pPipe->StartPoint().z; pPipe->SetStartPoint(ptFit); } else { ptFit.z = pPipe->EndPoint().z; pPipe->SetEndPoint(ptFit); } } } } OPENOBJ_END(); } } } //更新接口关系 void CDbPool::UpdataPipeInterface() { assertWriteEnabled(); AcDbObjectIdArray arIds; int nFind = 0; for (int k = 0; k < m_lstInterface.Length(); ++k) { if (m_lstInterface[k]->m_idPipe.isValid()) { if (!arIds.find(m_lstInterface[k]->m_idPipe,nFind)) arIds.append(m_lstInterface[k]->m_idPipe); } } UpdatePipes(arIds); } Acad::ErrorStatus CDbPool::MoveGSPointsAt(const AcDbIntArray& indices, const AcGeVector3d& offset) { AcGeMatrix3d mat; mat.setToTranslation(offset); BOOL bOutLabel=IsOutLabel(); int nNodeGrip=CDbPipeNode::GetGripNumber(); int nThisGrip=GetGripNumber(); int nCount = indices.length(); for(int i=0; i=nThisGrip) continue; if(indices[i]==nNodeGrip){ m_ptLocation.TransformBy(mat); m_ptLabel.TransformBy(mat); m_ptLabelOut.TransformBy(mat); m_bIsModify = true; // zxl 2013.09.29 add for(int j=0; jgetBlockTable(pBlockTable, AcDb::kForRead); if(pBlockTable == NULL) return; if(Acad::eOk != pBlockTable->getAt(ACDB_MODEL_SPACE, pRecord, AcDb::kForRead)) { pBlockTable->close(); return; } pBlockTable->close(); AcDbBlockTableRecordIterator *pIterator = NULL; pRecord->newIterator(pIterator); pRecord->close(); AcDbEntity *pEnt = NULL; CDbWellDim *pDim = NULL; for(pIterator->start(); !pIterator->done(); pIterator->step()) { pIterator->getEntity(pEnt, AcDb::kForRead); if (pEnt != NULL) { pDim = CDbWellDim::cast(pEnt); if(pDim != NULL && pDim->GetIsNewDim() && pDim->GetPipeId() == iFace.m_idPipe && pDim->GetWellId() == id()) { XPoint ptLoc = iFace.m_ptLocation; if (pDim->upgradeOpen() == Acad::eOk) { AcGeVector3d vt = ptLoc - pDim->GetStartPoint(); pDim->SetStartPoint(ptLoc); XPoint ptTurn = pDim->GetTurnPoint() + vt; pDim->SetTurnPoint(ptTurn); pDim->downgradeOpen(); } } pEnt->close(); } } delete pIterator; } SubText* CDbPool::HitTestText(XPoint pt) const { return CHDbEquipment::HitTestText(pt); } void CDbPool::SetSubText(long i, CString sText) { SetLabel(sText); } //zxl 2013.07.23 add Acad::ErrorStatus CDbPool::subClose() { Acad::ErrorStatus es = CHDbEquipment::subClose(); if (es != Acad::eOk) { return es; } if(m_bIsModify && !GlobalFunc::IsTransformCmd()) { m_bIsModify = false; if(isModified() && database()==acdbCurDwg()) { int nCount = m_lstInterface.Length(); for (int i=0; i > &arCurves) const { AcDbVoidPtrArray arEnts; AcDbVoidPtrArray arBlocks; AcDbBlockReference *pBlock = NULL; OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pEntPool); if (pEntPool != NULL) { //第一次炸碎成图块和文字 pEntPool->explode(arEnts); for (int j = 0; j < arEnts.length(); ++j) { pBlock = AcDbBlockReference::cast((AcDbEntity*)arEnts[j]); if (pBlock != NULL) break; } //第二次炸开图块 if (pBlock != NULL) { pBlock->explode(arBlocks); for (int i =0; i < arBlocks.length(); ++i) { AcDbEntity *pEnt = (AcDbEntity*)arBlocks[i]; if (pEnt != NULL) { AcDbLine *pLine = NULL; AcDbArc *pArc = NULL; AcDbCircle *pCir = NULL; XCurveSegment seg; if(pLine = AcDbLine::cast(pEnt)){ XLine line(XPoint(pLine->startPoint()), XPoint(pLine->endPoint())); seg = line; arCurves.append(seg); // break; } else if(pArc = AcDbArc::cast(pEnt)){ AcGePoint3d ptStart, ptEnd; pArc->getStartPoint(ptStart); pArc->getEndPoint(ptEnd); double dAng(0), dLen(0); pArc->getDistAtPoint(ptEnd, dLen); dAng = dLen / pArc->radius(); XArc arc(XPoint(ptStart), XPoint(ptStart), dAng); seg = arc; arCurves.append(seg); } else if(pCir = AcDbCircle::cast(pEnt)){ AcGePoint3d ptCen = pCir->center(); XCircle cir(XPoint(ptCen), pCir->radius()); seg = cir; arCurves.append(seg); } //sr 091109 del // AcDbObjectId idT = AddToCurrentSpace(pEnt,Adesk::kTrue); // ads_name ent; // if (acdbGetAdsName(ent,idT) == Acad::eOk) // { // Entity entSeg(ent); // XCurveSegment seg(entSeg); // arCurves.append(seg); // // if (!!entSeg) // entSeg.Erase(); // } } } } } OPENOBJ_END(); GlobalFunc::ReleaseEntSet(arBlocks);//SR MODIFY 091109 GlobalFunc::ReleaseEntSet(arEnts);//SR MODIFY 091109 //释放炸开后的内存 // while (arEnts.length() > 0) // { // delete (AcRxObject*)arEnts[0]; // arEnts.removeFirst(); // } } // sr 091109 del void CDbPool::GetExplodeCurves(AcDbEntity *pEnt,AcArray > &arCurves) const { if (pEnt != NULL) { AcDbVoidPtrArray arEnts; AcDbVoidPtrArray arBlocks; AcDbBlockReference *pBlock = NULL; //第一次炸碎成图块和文字 pEnt->explode(arEnts); for (int j = 0; j < arEnts.length(); ++j) { pBlock = AcDbBlockReference::cast((AcDbEntity*)arEnts[j]); if (pBlock != NULL) break; } //第二次炸开图块 if (pBlock != NULL) { pBlock->explode(arBlocks); for (int i =0; i < arBlocks.length(); ++i) { AcDbEntity *pEnt = (AcDbEntity*)arBlocks[i]; if (pEnt != NULL) { AcDbLine *pLine = NULL; AcDbArc *pArc = NULL; AcDbCircle *pCir = NULL; XCurveSegment seg; if(pLine = AcDbLine::cast(pEnt)){ XLine line(XPoint(pLine->startPoint()), XPoint(pLine->endPoint())); seg = line; arCurves.append(seg); } else if(pArc = AcDbArc::cast(pEnt)){ AcGePoint3d ptStart, ptEnd; pArc->getStartPoint(ptStart); pArc->getEndPoint(ptEnd); double dAng(0), dLen(0); pArc->getDistAtPoint(ptEnd, dLen); dAng = dLen / pArc->radius(); XArc arc(XPoint(ptStart), XPoint(ptStart), dAng); seg = arc; arCurves.append(seg); } else if(pCir = AcDbCircle::cast(pEnt)){ AcGePoint3d ptCen = pCir->center(); XCircle cir(XPoint(ptCen), pCir->radius()); seg = cir; arCurves.append(seg); } // AcDbObjectId idT = AddToCurrentSpace(pEnt,Adesk::kTrue); // ads_name ent; // if (acdbGetAdsName(ent,idT) == Acad::eOk) // { // Entity entSeg(ent); // XCurveSegment seg(entSeg); // arCurves.append(seg); // // if (!!entSeg) // entSeg.Erase(); // } } } } GlobalFunc::ReleaseEntSet(arBlocks);//SR MODIFY 091109 GlobalFunc::ReleaseEntSet(arEnts);//SR MODIFY 091109 //释放炸开后的内存 // while (arEnts.length() > 0) // { // delete (AcRxObject*)arEnts[0]; // arEnts.removeFirst(); // } } } //判断是否连接 BOOL CDbPool::CheckIsConnect(const XPoint &pt,const AcArray > &arSegs,const XLine &line,XPoint &ptCon) const { BOOL bTrue = FALSE; XCurveSegment seg; XPoint pt1,pt2; //找到管线与实体交点,并判断交点是否在实体表面 for (int i = 0; i < arSegs.length(); ++i) { seg = arSegs[i]; seg.SetLineFlag(LS_FINITE); // cet 2013.3.6 add 不在seg延长线上求交,保证交点在池子上 if (seg.Intersection(line,pt1,pt2) == 1) { if (pt1.Distance2d(pt) < 1E-3) { bTrue = TRUE; ptCon = pt1; break; } } } return bTrue; } //得到空闲的接口序号 int CDbPool::GetFreeInterfaceIndex() const { int nIndex = -1; for (int i = 0; i < m_lstInterface.Length(); ++i) { if (!m_lstInterface[i].m_idPipe.isValid() || m_lstInterface[i].m_idPipe.isErased()) { nIndex = i; break; } else { OPENOBJ_BEGIN(m_lstInterface[i].m_idPipe, AcDb::kForRead, CDbPipePrototype, pPipe); if(pPipe) { if (pPipe->StartPoint().Distance2d(m_lstInterface[i].m_ptLocation) > 1e-3 && pPipe->EndPoint().Distance2d(m_lstInterface[i].m_ptLocation) > 1e-3) { nIndex = i; break; } } OPENOBJ_END(); } } return nIndex; } Acad::ErrorStatus CDbPool::GetGripText(int idx, CString &cs) const { Acad::ErrorStatus es=Acad::eOk; CString sDes; if(idx>=0 && idx=nNodeGrip && idxm_ptLocation) < 1e-3) { bFind = true; break; } } return bFind; } CString CDbPool::GetName(bool *pRet) const { const EntityFields &fd = GetFields(); CString sName; bool bRet = fd.GFD(_T("POOL_NAME"), sName); if (pRet != NULL) { *pRet = bRet; // 是否设置了名称 } return sName; } void CDbPool::SetName(const CString &sName) { assertWriteEnabled(); EntityFields &fd = Fields(); fd.SFD(_T("POOL_NAME"), sName); }