1093 lines
26 KiB
C++
1093 lines
26 KiB
C++
#include "stdafx.h"
|
|
#include "TDbImpPipeBase.h"
|
|
#include "TDbXDataMap.h"
|
|
#include "TDbInterfaceMsgWrite.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
TDbImpPipeBase::TDbImpPipeBase()
|
|
{
|
|
m_pOwnerEnt = NULL;
|
|
m_pXDataMap = NULL;
|
|
}
|
|
|
|
TDbImpPipeBase::TDbImpPipeBase(TDbPipeBase* pOwner)
|
|
{
|
|
m_pOwnerEnt = pOwner;
|
|
m_pXDataMap = NULL;
|
|
}
|
|
|
|
TDbImpPipeBase::~TDbImpPipeBase()
|
|
{
|
|
}
|
|
|
|
void TDbImpPipeBase::SetStartPoint(const AcGePoint3d& ptSta)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
m_pXDataMap->SetAt(KEY_START,ptSta);
|
|
}
|
|
|
|
AcGePoint3d TDbImpPipeBase::StartPoint() const
|
|
{
|
|
AcGePoint3d ptSta;
|
|
if (m_pXDataMap != NULL)
|
|
m_pXDataMap->GetAt(KEY_START,ptSta);
|
|
return ptSta;
|
|
}
|
|
|
|
void TDbImpPipeBase::SetEndPoint(const AcGePoint3d& ptEnd)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
m_pXDataMap->SetAt(KEY_END,ptEnd);
|
|
}
|
|
|
|
AcGePoint3d TDbImpPipeBase::EndPoint() const
|
|
{
|
|
AcGePoint3d ptEnd;
|
|
if (m_pXDataMap != NULL)
|
|
m_pXDataMap->GetAt(KEY_END,ptEnd);
|
|
return ptEnd;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::GetInterface(int nIndex,TInterface& pipeInterface) const
|
|
{
|
|
if (m_pXDataMap == NULL)
|
|
return FALSE;
|
|
|
|
BOOL bIndexValidate = FALSE;
|
|
AcDbObjectId id1,id2;
|
|
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
|
|
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
|
|
int nCalbe = 0;
|
|
m_pXDataMap->GetAt(KEY_CABLE,nCalbe);
|
|
|
|
switch (nIndex)
|
|
{
|
|
case 0: //start
|
|
{
|
|
AcGeVector3d vtDir = StartPoint() - EndPoint();
|
|
if (nCalbe == TDb::eArcCabletray)
|
|
{
|
|
AcGePoint3d ptS,ptE,ptM,ptCenter;
|
|
m_pXDataMap->GetAt(KEY_MID,ptM);
|
|
XArc arc(StartPoint(),ptM,EndPoint());
|
|
vtDir = StartPoint() - arc.GetCenterPt().AsAcGePoint3d();
|
|
double dStrAng = arc.GetStarAngle();
|
|
if (fabs(dStrAng - vtDir.angleTo(AcGeVector3d::kXAxis,AcGeVector3d::kZAxis)) < 1e-6)
|
|
{
|
|
vtDir.rotateBy(PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
vtDir.rotateBy(-1 * PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
pipeInterface.SetPosition(StartPoint());
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetConnectObject(id1);
|
|
bIndexValidate = TRUE;
|
|
break;
|
|
}
|
|
case 1: //end
|
|
{
|
|
AcGeVector3d vtDir = EndPoint() - StartPoint();
|
|
if (nCalbe == TDb::eArcCabletray)
|
|
{
|
|
AcGePoint3d ptS,ptE,ptM,ptCenter;
|
|
m_pXDataMap->GetAt(KEY_MID,ptM);
|
|
XArc arc(StartPoint(),ptM,EndPoint());
|
|
vtDir = EndPoint() - arc.GetCenterPt().AsAcGePoint3d();
|
|
double dStrAng = arc.GetStarAngle();
|
|
if (fabs(dStrAng - vtDir.angleTo(AcGeVector3d::kXAxis,AcGeVector3d::kZAxis)) < 1e-6)
|
|
{
|
|
vtDir.rotateBy(PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
vtDir.rotateBy(-1 * PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
pipeInterface.SetPosition(EndPoint());
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetConnectObject(id2);
|
|
bIndexValidate = TRUE;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return bIndexValidate;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
|
|
{
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
double dDist1 = ptCon.distanceTo(ptSta);
|
|
double dDist2 = ptCon.distanceTo(ptEnd);
|
|
|
|
if (dDist1 < 1.e-3 || dDist2 < 1.e-3)
|
|
{
|
|
//判断点是否在接口对象上
|
|
AcGeVector3d vtDir = ptEnd - ptSta;
|
|
AcDbObjectId id1,id2;
|
|
int nCable = 0;
|
|
m_pXDataMap->GetAt(KEY_CABLE,nCable);
|
|
if (nCable == TDb::eArcCabletray)
|
|
{
|
|
AcGePoint3d ptS,ptE,ptM,ptCenter;
|
|
m_pXDataMap->GetAt(KEY_MID,ptM);
|
|
XArc arc(StartPoint(),ptM,EndPoint());
|
|
if (dDist1 < 1.e-3)
|
|
{
|
|
vtDir = EndPoint() - arc.GetCenterPt().AsAcGePoint3d();
|
|
}
|
|
if (dDist2 < 1e-3)
|
|
{
|
|
vtDir = StartPoint() - arc.GetCenterPt().AsAcGePoint3d();
|
|
}
|
|
|
|
double dStrAng = arc.GetStarAngle();
|
|
if (fabs(dStrAng - vtDir.angleTo(AcGeVector3d::kXAxis,AcGeVector3d::kZAxis)) < 1e-6)
|
|
{
|
|
vtDir.rotateBy(PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
vtDir.rotateBy(-1 * PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
|
|
BOOL bSuc = FALSE;
|
|
|
|
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
|
|
{
|
|
bSuc = MakesureInterfaceValidate(id1,ptCon,vtDir,pipeInterface);
|
|
if (!bSuc)
|
|
{
|
|
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
|
|
{
|
|
bSuc = MakesureInterfaceValidate(id2,ptCon,vtDir,pipeInterface);
|
|
}
|
|
}
|
|
return bSuc;
|
|
}
|
|
|
|
if (m_pXDataMap->GetAt(KEY_IDCNT2,id2))
|
|
{
|
|
bSuc = MakesureInterfaceValidate(id2,ptCon,vtDir,pipeInterface);
|
|
if (!bSuc)
|
|
{
|
|
if (m_pXDataMap->GetAt(KEY_IDCNT1,id1))
|
|
{
|
|
bSuc = MakesureInterfaceValidate(id1,ptCon,vtDir,pipeInterface);
|
|
}
|
|
}
|
|
return bSuc;
|
|
}
|
|
|
|
if (dDist1 < 1.e-3)
|
|
{
|
|
vtDir = ptSta - ptEnd;
|
|
if (nCable == TDb::eArcCabletray)
|
|
{
|
|
AcGePoint3d ptS,ptE,ptM,ptCenter;
|
|
m_pXDataMap->GetAt(KEY_MID,ptM);
|
|
XArc arc(StartPoint(),ptM,EndPoint());
|
|
vtDir = StartPoint() - arc.GetCenterPt().AsAcGePoint3d();
|
|
double dStrAng = arc.GetStarAngle();
|
|
if (fabs(dStrAng - vtDir.angleTo(AcGeVector3d::kXAxis,AcGeVector3d::kZAxis)) < 1e-6)
|
|
{
|
|
vtDir.rotateBy(PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
vtDir.rotateBy(-1 * PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetPosition(ptSta);
|
|
}
|
|
|
|
if (dDist2 < 1.e-3)
|
|
{
|
|
vtDir = ptEnd - ptSta;
|
|
if (nCable == TDb::eArcCabletray)
|
|
{
|
|
AcGePoint3d ptS,ptE,ptM,ptCenter;
|
|
m_pXDataMap->GetAt(KEY_MID,ptM);
|
|
XArc arc(StartPoint(),ptM,EndPoint());
|
|
vtDir = EndPoint() - arc.GetCenterPt().AsAcGePoint3d();
|
|
double dStrAng = arc.GetStarAngle();
|
|
if (fabs(dStrAng - vtDir.angleTo(AcGeVector3d::kXAxis,AcGeVector3d::kZAxis)) < 1e-6)
|
|
{
|
|
vtDir.rotateBy(PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
else
|
|
vtDir.rotateBy(-1 * PI * 0.5,AcGeVector3d::kZAxis);
|
|
}
|
|
pipeInterface.SetOutDir(vtDir);
|
|
pipeInterface.SetOwnerId(m_pOwnerEnt->objectId());
|
|
pipeInterface.SetPosition(ptEnd);
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
|
|
{
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
double dDist1 = ptCon.distanceTo(ptSta);
|
|
double dDist2 = ptCon.distanceTo(ptEnd);
|
|
|
|
if (dDist1 < 1.e-3 ||
|
|
dDist2 < 1.e-3)
|
|
{
|
|
AcGeVector3d vtT = ptEnd - ptSta;
|
|
if (vtT.isParallelTo(vtDir))
|
|
{
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
int TDbImpPipeBase::GetInterfaceCount() const
|
|
{
|
|
return 2;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::MakesureInterfaceValidate(const AcDbObjectId& id,const AcGePoint3d& ptCon,
|
|
const AcGeVector3d& vtDir,TInterface& pipeInterface) const
|
|
{
|
|
//到命名对象字典中找;
|
|
BOOL bSuccess = FALSE;
|
|
// add by hh 2011-08-09 接口记录从字典移动到数据库中
|
|
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
|
|
if(NULL != pIntfRec)
|
|
{
|
|
if (pIntfRec->Find(ptCon,vtDir,m_pOwnerEnt->objectId(),pipeInterface))
|
|
{
|
|
if (pipeInterface.GetConnectObject().asOldId() == id.asOldId())
|
|
{
|
|
bSuccess = TRUE;
|
|
}
|
|
}
|
|
pIntfRec->close();
|
|
return bSuccess;
|
|
}
|
|
// add end
|
|
|
|
AcDbDictionary* pNamedDict = NULL;
|
|
if (Acad::eOk == acdbCurDwg()->getNamedObjectsDictionary(pNamedDict,AcDb::kForRead))
|
|
{
|
|
AcDbDictionary* pDict = NULL;
|
|
if (Acad::eOk == pNamedDict->getAt(KEY_IRECORD,(AcDbObject*&)pDict,AcDb::kForRead))
|
|
{
|
|
pNamedDict->close();
|
|
TDbInterfaceRecord* pInterfaceRec = NULL;
|
|
if (Acad::eOk == pDict->getAt(KEY_IRECORD,(AcDbObject*&)pInterfaceRec,AcDb::kForRead))
|
|
{
|
|
pDict->close();
|
|
if (pInterfaceRec->Find(ptCon,vtDir,m_pOwnerEnt->objectId(),pipeInterface))
|
|
{
|
|
if (pipeInterface.GetConnectObject().asOldId() == id.asOldId())
|
|
{
|
|
bSuccess = TRUE;
|
|
}
|
|
}
|
|
pInterfaceRec->close();
|
|
}
|
|
else
|
|
{
|
|
pDict->close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pNamedDict->close();
|
|
}
|
|
}
|
|
return bSuccess;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
|
|
{
|
|
double dDist = ptConnect.distanceTo(StartPoint());
|
|
if (dDist < 1.e-3)
|
|
{
|
|
m_pXDataMap->SetAt(KEY_IDCNT1,idConnect);
|
|
return TRUE;
|
|
}
|
|
|
|
dDist = ptConnect.distanceTo(EndPoint());
|
|
if (dDist < 1.e-3)
|
|
{
|
|
m_pXDataMap->SetAt(KEY_IDCNT2,idConnect);
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
|
|
{
|
|
if (m_pXDataMap == NULL) return FALSE;
|
|
|
|
//浅层次删除; 命名字典中的关系,需要外面移除关系,只移除内部关系
|
|
AcDbObjectId id1,id2;
|
|
m_pXDataMap->GetAt(KEY_IDCNT1,id1);
|
|
m_pXDataMap->GetAt(KEY_IDCNT2,id2);
|
|
AcDbObjectId idNull;
|
|
|
|
BOOL bRemoved = FALSE;
|
|
if (id1 == idConnect)
|
|
{
|
|
m_pXDataMap->SetAt(KEY_IDCNT1,idNull);
|
|
bRemoved = TRUE;
|
|
}
|
|
|
|
if (id2 == idConnect)
|
|
{
|
|
m_pXDataMap->SetAt(KEY_IDCNT2,idNull);
|
|
bRemoved = TRUE;
|
|
}
|
|
return bRemoved;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::NotifyInterfaceToModify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
TDbXDataMap* TDbImpPipeBase::GetSpecialtyData()
|
|
{
|
|
return m_pXDataMap;
|
|
}
|
|
|
|
TDb::Position TDbImpPipeBase::ExplainGripIndex(int nIndex) const
|
|
{
|
|
return TDb::eStart;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::setNormal(const AcGeVector3d& vtNorm)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
m_pXDataMap->SetAt(KEY_NORMAL,vtNorm);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void TDbImpPipeBase::UpdateNormal(const AcGePoint3d& ptOld,const AcGePoint3d& ptNew)
|
|
{
|
|
|
|
}
|
|
|
|
AcGeVector3d TDbImpPipeBase::normal() const
|
|
{
|
|
AcGeVector3d vt = AcGeVector3d::kZAxis;
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
m_pXDataMap->GetAt(KEY_NORMAL,vt);
|
|
}
|
|
return vt.normalize();// Lixl add 返回标准化向量
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::copyFrom(const TDbImpPipeBase* pSrc)
|
|
{
|
|
if (pSrc != NULL)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
m_pXDataMap->CopyFrom(pSrc->m_pXDataMap);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::dwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
m_pXDataMap->dwgInFields(pFiler);
|
|
}
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
if (m_pXDataMap != NULL)
|
|
{
|
|
m_pXDataMap->dwgOutFields(pFiler);
|
|
}
|
|
return pFiler->filerStatus();
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::dxfInFields(AcDbDxfFiler* pFiler)
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::explode(AcDbVoidPtrArray& entitySet) const
|
|
{
|
|
BOOL nSingleLine = FALSE;
|
|
m_pXDataMap->GetAt(KEY_SINGLE,nSingleLine);
|
|
if (nSingleLine)
|
|
{
|
|
//中心线
|
|
AcDbObjectId idLayT;
|
|
AcDbObjectId idLay = ((TDbPipeBase*)m_pOwnerEnt)->layerId();
|
|
AcDbObjectId idCen = ((TDbPipeBase*)m_pOwnerEnt)->CenterLayer();
|
|
|
|
// 获取实体自身原来的pl边界对象[源];
|
|
TComplexCurve compInside;
|
|
GetCurvesInSide(compInside);
|
|
compInside.setSubElementGsMark(0);
|
|
|
|
TDb::TCurveElement el;
|
|
memset(&el,0,sizeof(TDb::TCurveElement));
|
|
|
|
for (int i = 0;i < compInside.length();i++)
|
|
{
|
|
el = compInside.at(i);
|
|
idLayT = idLay;
|
|
if (el.gsMark == -1) idLayT = idCen;
|
|
|
|
//if (el.ptGe[1].distanceTo(el.ptGe[2]) < AcGeContext::gTol.equalPoint()) //直线
|
|
if (el.ptGe[1].distanceTo(el.ptGe[2]) < g_globalTol.equalPoint()) // modify by cq TFS8208
|
|
{
|
|
AcDbLine* pLine = new AcDbLine(el.ptGe[0],el.ptGe[1]);
|
|
pLine->setLayer(idLayT);
|
|
entitySet.append(pLine);
|
|
}
|
|
else
|
|
{
|
|
AcDbArc* pArc = TSupportFunc::FormatArc(el.ptGe[0],el.ptGe[1],el.ptGe[2]);
|
|
if (pArc != NULL)
|
|
{
|
|
pArc->setLayer(idLayT);
|
|
entitySet.append(pArc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//1. 外线
|
|
AcDbPolyline* pPl = MakePolyCurve();
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->setLayer(m_pOwnerEnt->layerId());
|
|
entitySet.append(pPl);
|
|
}
|
|
|
|
//中心线
|
|
AcDbObjectId idLayT;
|
|
AcDbObjectId idLay = ((TDbPipeBase*)m_pOwnerEnt)->layerId();
|
|
AcDbObjectId idCen = ((TDbPipeBase*)m_pOwnerEnt)->CenterLayer();
|
|
|
|
TComplexCurve compInside;
|
|
GetCurvesInSide(compInside);
|
|
|
|
TDb::TCurveElement el;
|
|
memset(&el,0,sizeof(TDb::TCurveElement));
|
|
|
|
for (int i = 0;i < compInside.length();i++)
|
|
{
|
|
el = compInside.at(i);
|
|
idLayT = idLay;
|
|
if (el.gsMark == -1) idLayT = idCen;
|
|
|
|
//if (el.ptGe[1].distanceTo(el.ptGe[2]) < AcGeContext::gTol.equalPoint()) //直线
|
|
if (el.ptGe[1].distanceTo(el.ptGe[2]) < g_globalTol.equalPoint()) // modify by cq TFS8208
|
|
{
|
|
AcDbLine* pLine = new AcDbLine(el.ptGe[0],el.ptGe[1]);
|
|
pLine->setLayer(idLayT);
|
|
entitySet.append(pLine);
|
|
}
|
|
else
|
|
{
|
|
AcDbArc* pArc = TSupportFunc::FormatArc(el.ptGe[0],el.ptGe[1],el.ptGe[2]);
|
|
if (pArc != NULL)
|
|
{
|
|
pArc->setLayer(idLayT);
|
|
entitySet.append(pArc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::extend(Adesk::Boolean extendStart,const AcGePoint3d& toPoint)
|
|
{
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
AcDbLine line;
|
|
line.setStartPoint(ptSta);
|
|
line.setEndPoint(ptEnd);
|
|
|
|
AcGePoint3d ptOn;
|
|
line.getClosestPointTo(toPoint,ptOn,Adesk::kTrue);
|
|
|
|
if (extendStart)
|
|
{
|
|
//if (ptOn.distanceTo(ptEnd) > AcGeContext::gTol.equalPoint())
|
|
if (ptOn.distanceTo(ptEnd) > g_globalTol.equalPoint()) // modify by cq TFS8208
|
|
{
|
|
SetStartPoint(ptOn);
|
|
if (m_pOwnerEnt != NULL && !m_pOwnerEnt->objectId().isNull())
|
|
{
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),ptSta,ptOn);
|
|
((TDbPipeBase*)m_pOwnerEnt)->UpdateCoverDisplay();
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//if (ptOn.distanceTo(ptSta) > AcGeContext::gTol.equalPoint())
|
|
if (ptOn.distanceTo(ptSta) > g_globalTol.equalPoint()) // modify by cq TFS8208
|
|
{
|
|
SetEndPoint(ptOn);
|
|
if (m_pOwnerEnt != NULL && !m_pOwnerEnt->objectId().isNull())
|
|
{
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),ptEnd,ptOn);
|
|
((TDbPipeBase*)m_pOwnerEnt)->UpdateCoverDisplay();
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::extend(double newParam)
|
|
{
|
|
Acad::ErrorStatus es;
|
|
AcGePoint3d ptSta = StartPoint();
|
|
AcGePoint3d ptEnd = EndPoint();
|
|
|
|
AcDbLine line;
|
|
line.setStartPoint(ptSta);
|
|
line.setEndPoint(ptEnd);
|
|
|
|
es = line.extend(newParam);
|
|
if (es == Acad::eOk)
|
|
{
|
|
SetStartPoint(line.startPoint());
|
|
SetEndPoint(line.endPoint());
|
|
|
|
if (m_pOwnerEnt != NULL && !m_pOwnerEnt->objectId().isNull())
|
|
{
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),ptSta,line.startPoint());
|
|
UpdateInterfaceRec(m_pOwnerEnt->objectId(),ptEnd,line.endPoint());
|
|
((TDbPipeBase*)m_pOwnerEnt)->UpdateCoverDisplay();
|
|
}
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getArea(double& x0) const
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getClassID(CLSID* pClsid) const
|
|
{
|
|
return Acad::eInvalidInput;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getClosestPointTo(const AcGePoint3d& givenPnt,
|
|
AcGePoint3d& pointOnCurve,
|
|
Adesk::Boolean extend) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getClosestPointTo(givenPnt,pointOnCurve,extend);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getClosestPointTo( const AcGePoint3d& givenPnt,
|
|
const AcGeVector3d& direction,
|
|
AcGePoint3d& pointOnCurve,
|
|
Adesk::Boolean extend) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getClosestPointTo(givenPnt,direction,pointOnCurve,extend);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getDistAtPoint(const AcGePoint3d& x0,double& x1)const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
Acad::ErrorStatus es = line.getDistAtPoint(x0,x1);
|
|
if ( es != Acad::eOk)
|
|
{
|
|
AcGeLine3d lineGe(StartPoint(),EndPoint());
|
|
if ( lineGe.isOn(x0) )
|
|
{
|
|
es = Acad::eOk;
|
|
}
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getDistAtParam( double param, double& dist ) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
Acad::ErrorStatus es = line.getDistAtParam(param, dist);
|
|
|
|
if ( es != Acad::eOk)
|
|
{
|
|
AcGeLine3d lineGe(StartPoint(),EndPoint());
|
|
if ( lineGe.isOn(param) )
|
|
{
|
|
es = Acad::eOk;
|
|
}
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getEndParam(double& x0) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getEndParam(x0);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getEndPoint(AcGePoint3d& x0) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getEndPoint(x0);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getFirstDeriv(const AcGePoint3d& x0,AcGeVector3d& firstDeriv) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getFirstDeriv(x0,firstDeriv);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getFirstDeriv(double param,AcGeVector3d& firstDeriv) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getFirstDeriv(param,firstDeriv);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getGeomExtents(AcDbExtents& extents) const
|
|
{
|
|
AcDbPolyline* pPl = MakePolyCurve();
|
|
if (pPl != NULL)
|
|
{
|
|
pPl->getGeomExtents(extents);
|
|
delete pPl;
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getGripPoints(AcGePoint3dArray& gripPoints,
|
|
AcDbIntArray& osnapModes,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getOffsetCurves(double offsetDist,AcDbVoidPtrArray& offsetCurves) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getOffsetCurves(offsetDist,offsetCurves);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getOffsetCurvesGivenPlaneNormal(const AcGeVector3d& normal,
|
|
double offsetDist,
|
|
AcDbVoidPtrArray& offsetCurves) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getOffsetCurvesGivenPlaneNormal(normal,offsetDist,offsetCurves);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getOsnapPoints(AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,snapPoints,geomIds);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getParamAtDist(double dist,double& param) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getParamAtDist(dist,param);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getParamAtPoint(const AcGePoint3d& x0,double& x1)const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
Acad::ErrorStatus es = line.getParamAtPoint(x0,x1);
|
|
if (es != Acad::eOk)
|
|
{
|
|
AcGeLine3d lineGe(StartPoint(),EndPoint());
|
|
if ( lineGe.isOn(x0) )
|
|
{
|
|
es = Acad::eOk;
|
|
}
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getPointAtDist(double x0,AcGePoint3d& x1) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
Acad::ErrorStatus es = line.getPointAtDist(x0,x1);
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getPointAtParam(double x0,AcGePoint3d& x1) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
Acad::ErrorStatus es = line.getPointAtParam(x0,x1);
|
|
|
|
if (es != Acad::eOk)
|
|
{
|
|
AcGeLine3d lineGe(StartPoint(),EndPoint());
|
|
if ( lineGe.isOn(x0) )
|
|
{
|
|
es = Acad::eOk;
|
|
}
|
|
}
|
|
return es;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getProjectedCurve(const AcGePlane& x0,
|
|
const AcGeVector3d& projDir,
|
|
AcDbCurve*& projCrv) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getProjectedCurve(x0,projDir,projCrv);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getSplitCurves(const AcGeDoubleArray& params,
|
|
AcDbVoidPtrArray& curveSegments) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getSplitCurves(params,curveSegments);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getSplitCurves(const AcGePoint3dArray& points,
|
|
AcDbVoidPtrArray& curveSegments) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getSplitCurves(points,curveSegments);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getStartParam(double& x0) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getStartParam(x0);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getStartPoint(AcGePoint3d& x0) const
|
|
{
|
|
AcDbLine line(StartPoint(),EndPoint());
|
|
return line.getStartPoint(x0);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::intersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane& projPlane,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
AcDbLine line;
|
|
line.setStartPoint(StartPoint());
|
|
line.setEndPoint(EndPoint());
|
|
line.intersectWith(pEnt,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
|
|
if (pEnt->isKindOf(AcDbLine::desc()) ||
|
|
pEnt->isKindOf(AcDbArc::desc()) ||
|
|
pEnt->isKindOf(AcDbPolyline::desc()) ||
|
|
pEnt->isKindOf(AcDbCircle::desc()))
|
|
{
|
|
TComplexCurve cplCurve;
|
|
MakeCurves(cplCurve);
|
|
TDb::TCurveElement el;
|
|
for (int i = 0;i < cplCurve.logicalLength();i++)
|
|
{
|
|
el = cplCurve.at(i);
|
|
|
|
//if (el.ptGe[1].distanceTo(el.ptGe[2]) < AcGeContext::gTol.equalPoint()) //直线
|
|
if (el.ptGe[1].distanceTo(el.ptGe[2]) < g_globalTol.equalPoint()) // modify by cq TFS8208
|
|
{
|
|
line.setStartPoint(el.ptGe[0]);
|
|
line.setEndPoint(el.ptGe[1]);
|
|
line.intersectWith(pEnt,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::intersectWith(const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
AcDbLine line;
|
|
//1. 中心求交
|
|
line.setStartPoint(StartPoint());
|
|
line.setEndPoint(EndPoint());
|
|
line.intersectWith(pEnt,intType,points,thisGsMarker,otherGsMarker);
|
|
|
|
if (pEnt->isKindOf(AcDbLine::desc()) ||
|
|
pEnt->isKindOf(AcDbArc::desc()) ||
|
|
pEnt->isKindOf(AcDbPolyline::desc()) ||
|
|
pEnt->isKindOf(AcDbCircle::desc()))
|
|
{
|
|
TComplexCurve cplCurve;
|
|
MakeCurves(cplCurve);
|
|
TDb::TCurveElement el;
|
|
for (int i = 0;i < cplCurve.logicalLength();i++)
|
|
{
|
|
el = cplCurve.at(i);
|
|
|
|
//if (el.ptGe[1].distanceTo(el.ptGe[2]) < AcGeContext::gTol.equalPoint()) //直线
|
|
if (el.ptGe[1].distanceTo(el.ptGe[2]) < g_globalTol.equalPoint()) // modify by cq TFS8208
|
|
{
|
|
line.setStartPoint(el.ptGe[0]);
|
|
line.setEndPoint(el.ptGe[1]);
|
|
line.intersectWith(pEnt,intType,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::getStretchPoints(AcGePoint3dArray& stretchPoints) const
|
|
{
|
|
AcDbIntArray osNapModes,geomIds;
|
|
getGripPoints(stretchPoints,osNapModes,geomIds);
|
|
|
|
if (stretchPoints.length() == 6)
|
|
{
|
|
//去掉两头的命令夹点
|
|
stretchPoints.removeLast();
|
|
stretchPoints.removeLast();
|
|
//去掉中间命令节点
|
|
stretchPoints.removeLast();
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::moveStretchPointsAt( const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
//根据 getstretchpoints 设定的点,拉伸
|
|
return moveGripPointsAt(indices,offset);
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::moveGripPointsAt(const AcDbIntArray& indices,
|
|
const AcGeVector3d& offset)
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::transformBy(const AcGeMatrix3d& xform)
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
void TDbImpPipeBase::list() const
|
|
{
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::ExplodeOrDraw2d(XExplodeDraw &mode) const
|
|
{
|
|
if (m_pOwnerEnt != NULL)
|
|
{
|
|
//边界实体
|
|
TComplexCurve cplCurve;
|
|
MakeCurves(cplCurve);
|
|
|
|
TDbExtentsEdge edage;
|
|
edage.SetEdage(cplCurve);
|
|
|
|
BOOL bWeight = FALSE;
|
|
m_pXDataMap->GetAt(KEY_EDAGEWEIGHT,bWeight);
|
|
|
|
AcDbObjectId idReal = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId();
|
|
AcDbObjectId idDash = ((TDbInterfacesObj*)m_pOwnerEnt)->DashLayer();
|
|
AcDbObjectId idCent = ((TDbInterfacesObj*)m_pOwnerEnt)->CenterLayer();
|
|
|
|
edage.ExplodeOrDraw2d(mode,idReal,idDash,idCent,NULL,bWeight,FALSE);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::ExplodeOrDraw3d(XExplodeDraw &mode) const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::MakeCurves(TComplexCurve& cplCurve) const
|
|
{
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::GetCurvesInSide(TComplexCurve& compCurve) const
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AcDbPolyline* TDbImpPipeBase::MakePolyCurve() const
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::FindConnect(const AcGePoint3d& ptGePos,const AcGeVector3d& vtDir,const AcDbObjectId& idOwner,AcDbObjectId& idInterface)
|
|
{
|
|
//到命名对象字典中找;
|
|
BOOL bSuccess = FALSE;
|
|
// add by hh 2011-08-09 接口记录从字典移动到数据库中
|
|
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
|
|
if(NULL != pIntfRec)
|
|
{
|
|
TInterface iInterface;
|
|
if (pIntfRec->Find(ptGePos,vtDir,idOwner,iInterface))
|
|
{
|
|
idInterface = iInterface.GetConnectObject();
|
|
bSuccess = TRUE;
|
|
}
|
|
pIntfRec->close();
|
|
return bSuccess;
|
|
}
|
|
// add end
|
|
|
|
AcDbDictionary* pNamedDict = NULL;
|
|
if (Acad::eOk == acdbCurDwg()->getNamedObjectsDictionary(pNamedDict,AcDb::kForRead))
|
|
{
|
|
AcDbDictionary* pDict = NULL;
|
|
if (Acad::eOk == pNamedDict->getAt(KEY_IRECORD,(AcDbObject*&)pDict,AcDb::kForRead))
|
|
{
|
|
pNamedDict->close();
|
|
TDbInterfaceRecord* pInterfaceRec = NULL;
|
|
if (Acad::eOk == pDict->getAt(KEY_IRECORD,(AcDbObject*&)pInterfaceRec,AcDb::kForRead))
|
|
{
|
|
pDict->close();
|
|
TInterface iInterface;
|
|
if (pInterfaceRec->Find(ptGePos,vtDir,idOwner,iInterface))
|
|
{
|
|
idInterface = iInterface.GetConnectObject();
|
|
bSuccess = TRUE;
|
|
}
|
|
pInterfaceRec->close();
|
|
}
|
|
else
|
|
{
|
|
pDict->close();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
pNamedDict->close();
|
|
}
|
|
}
|
|
return bSuccess;
|
|
}
|
|
|
|
void TDbImpPipeBase::FreeBuffer(AcDbVoidPtrArray& arCurvePtrs)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arCurvePtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arCurvePtrs.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
delete pEnt;
|
|
}
|
|
}
|
|
}
|
|
|
|
void TDbImpPipeBase::Destroy()
|
|
{
|
|
delete this;
|
|
}
|
|
|
|
void TDbImpPipeBase::GetTips(CMapStringToString& mapLable2Tip) const
|
|
{
|
|
}
|
|
|
|
void TDbImpPipeBase::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
|
|
{
|
|
|
|
}
|
|
|
|
void TDbImpPipeBase::CopyPropertiesTo(AcDbObjectId& idTgr,unsigned gMatchFlag)
|
|
{
|
|
}
|
|
|
|
void TDbImpPipeBase::CopyPropertiesTo(AcDbObjectIdArray& arIds,unsigned gMatchFlag)
|
|
{
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::OPMInfo(LPCTSTR pszName, TDb::OPMInfo* pInfo)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL TDbImpPipeBase::IsValid(TDbXDataMap* pXMap)
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
int TDbImpPipeBase::GetXBaseShell(TXShell& xShell)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int TDbImpPipeBase::GetBodyBox(AcDbExtents& ext)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
CString TDbImpPipeBase::GetXml(const AcGeMatrix3d& mat) const
|
|
{
|
|
return _T("");
|
|
}
|
|
|
|
bool TDbImpPipeBase::GetSection( const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir,
|
|
std::vector<TObjSectionRecord> §ionRecord, AcDbVoidPtrArray& arFillPtrs ) const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::GetExtents( TADSGePoint3d &ptLow, TADSGePoint3d &ptUp ) const
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
Acad::ErrorStatus TDbImpPipeBase::GetClipBoundary(TGGePoly2D& poly) const
|
|
{
|
|
return Acad::eNotImplementedYet;
|
|
}
|
|
|
|
bool TDbImpPipeBase::IsMeClip() const
|
|
{
|
|
return false;
|
|
}
|
|
|
|
bool TDbImpPipeBase::IsClipMe(const TEntityBase* pEnt)const//ok是否被裁剪
|
|
{
|
|
return false;
|
|
}
|