Files
envi-code/SourceCode/Code2026/tg_shs/shs_pipebase/TImpSpecFitting.cpp
T
2026-09-28 15:28:50 +08:00

763 lines
17 KiB
C++

#include "stdafx.h"
#include "TImpSpecFitting.h"
#include "TDbInterfaceRecord.h"
#include "TDbXDataMap.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
TImpSpecFitting::TImpSpecFitting()
{
m_pXDataMap = NULL;
m_pOwnerEnt = NULL;
}
TImpSpecFitting::~TImpSpecFitting()
{
}
void TImpSpecFitting::Destroy()
{
delete this;
}
BOOL TImpSpecFitting::GetInterface(int nIndex,TInterface& pipeInterface) const
{
return FALSE;
}
BOOL TImpSpecFitting::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
{
return FALSE;
}
BOOL TImpSpecFitting::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
{
return FALSE;
}
int TImpSpecFitting::GetInterfaceCount() const
{
return 0;
}
BOOL TImpSpecFitting::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
return FALSE;
}
BOOL TImpSpecFitting::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect1,const AcDbObjectId& idConnect2)
{
return FALSE;
}
BOOL TImpSpecFitting::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
return FALSE;
}
BOOL TImpSpecFitting::NotifyInterfaceToModify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
return FALSE;
}
Acad::ErrorStatus TImpSpecFitting::ExplodeOrDraw3d(XExplodeDraw &dc) const
{
return Acad::eNotImplementedYet;
}
Acad::ErrorStatus TImpSpecFitting::ExplodeOrDraw2d(XExplodeDraw &dc) const
{
return Acad::eNotImplementedYet;
}
void TImpSpecFitting::GetKindName(CString& sName)
{
m_pXDataMap->GetAt(KEY_DXF,sName);
}
Acad::ErrorStatus TImpSpecFitting::transformBy(const AcGeMatrix3d& xform)
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecFitting::moveStretchPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
return Acad::eNotImplementedYet;
}
Acad::ErrorStatus TImpSpecFitting::moveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecFitting::intersectWith(const AcDbEntity* pEnt,
AcDb::Intersect intType,
const AcGePlane& projPlane,
AcGePoint3dArray& points,
INT_PTR thisGsMarker,
INT_PTR otherGsMarker) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->intersectWith(pEnt,intType,projPlane,points,thisGsMarker,otherGsMarker);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::intersectWith( const AcDbEntity* pEnt,
AcDb::Intersect intType,
AcGePoint3dArray& points,
INT_PTR thisGsMarker,
INT_PTR otherGsMarker) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->intersectWith(pEnt,intType,points,thisGsMarker,otherGsMarker);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getStretchPoints(AcGePoint3dArray& stretchPoints) const
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecFitting::getStartPoint(AcGePoint3d& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getStartPoint(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getStartParam(double& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getStartParam(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getSplitCurves( const AcGePoint3dArray& points,
AcDbVoidPtrArray& curveSegments) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getSplitCurves( const AcGeDoubleArray& params,
AcDbVoidPtrArray& curveSegments) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getPointAtParam(double x0,AcGePoint3d& x1) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getPointAtParam(x0,x1);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getPointAtDist(double x0,AcGePoint3d& x1) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getPointAtDist(x0,x1);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getParamAtPoint(const AcGePoint3d& x0,double& x1)const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getParamAtPoint(x0,x1);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getParamAtDist(double dist,double& param) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getParamAtDist(dist,param);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getOsnapPoints(AcDb::OsnapMode osnapMode,
INT_PTR gsSelectionMark,
const AcGePoint3d& pickPoint,
const AcGePoint3d& lastPoint,
const AcGeMatrix3d& viewXform,
AcGePoint3dArray& snapPoints,
AcDbIntArray& geomIds) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getOffsetCurves(double offsetDist,
AcDbVoidPtrArray& offsetCurves) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getOffsetCurves(offsetDist,offsetCurves);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getGeomExtents(AcDbExtents& extents) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getGeomExtents(extents);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getFirstDeriv(double param,AcGeVector3d& firstDeriv) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getFirstDeriv(param,firstDeriv);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getFirstDeriv(const AcGePoint3d& x0,AcGeVector3d& firstDeriv) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getFirstDeriv(x0,firstDeriv);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getEndPoint(AcGePoint3d& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getEndPoint(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getEndParam(double& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getEndParam(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getDistAtPoint(const AcGePoint3d& x0,double& x1) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getDistAtPoint(x0,x1);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getDistAtParam(double param,double& dist) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getDistAtParam(param,dist);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getClosestPointTo(const AcGePoint3d& givenPnt,
const AcGeVector3d& direction,
AcGePoint3d& pointOnCurve,
Adesk::Boolean extend) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getClosestPointTo(givenPnt,direction,pointOnCurve,extend);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getClosestPointTo(const AcGePoint3d& givenPnt,
AcGePoint3d& pointOnCurve,
Adesk::Boolean extend) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getClosestPointTo(givenPnt,pointOnCurve,extend);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::getClassID(CLSID* pClsid) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::extend(double newParam)
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::extend(Adesk::Boolean extendStart,const AcGePoint3d& toPoint)
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecFitting::explode(AcDbVoidPtrArray& entitySet) const
{
BOOL nSingleLine = FALSE;
m_pXDataMap->GetAt(KEY_SINGLE,nSingleLine);
if (nSingleLine)
{
//中心线
AcDbObjectId idLayT;
AcDbObjectId idLay = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId();
AcDbObjectId idCen = ((TDbInterfacesObj*)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 = ((TDbInterfacesObj*)m_pOwnerEnt)->layerId();
AcDbObjectId idCen = ((TDbInterfacesObj*)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 TImpSpecFitting::copyFrom(const TImpSpecFitting* pSrc)
{
m_pXDataMap->CopyFrom(pSrc->m_pXDataMap);
return Acad::eOk;
}
AcGeVector3d TImpSpecFitting::normal() const
{
AcGeVector3d vt = AcGeVector3d::kZAxis;
if (!m_pXDataMap->GetAt(KEY_NORMAL,vt))
{
m_pXDataMap->GetAt(KEY_MAJBR,vt);
}
return vt;
}
void TImpSpecFitting::list() const
{
}
BOOL TImpSpecFitting::MakeCurves(TComplexCurve& cplCurve) const
{
return FALSE;
}
BOOL TImpSpecFitting::NoneConectLineIfNeed(TComplexCurve& cplCurve) const
{
return FALSE;
}
BOOL TImpSpecFitting::GetCurvesInSide(TComplexCurve& compCurve) const
{
return false;
}
AcDbPolyline* TImpSpecFitting::MakePolyCurve() const
{
return NULL;
}
BOOL TImpSpecFitting::MakePolyCurveFaces(AcDbVoidPtrArray& arFaces)
{
return FALSE;
}
BOOL TImpSpecFitting::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 TImpSpecFitting::MakesureInterfaceValidate(const AcDbObjectId& id,const AcGePoint3d& ptCon,
const AcGeVector3d& vtDir) const
{
//到命名对象字典中找;
BOOL bSuccess = FALSE;
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
TInterface pipeInterface;
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();
TInterface pipeInterface;
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;
}
TDb::Position TImpSpecFitting::ExplainGripIndex(int nIndex) const
{
return TDb::eStart;
}
BOOL TImpSpecFitting::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->PairFind(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->PairFind(ptGePos,vtDir,idOwner,iInterface))
{
idInterface = iInterface.GetConnectObject();
bSuccess = TRUE;
}
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
return bSuccess;
}
void TImpSpecFitting::GetTips(CMapStringToString& mapLable2Tip) const
{
}
void TImpSpecFitting::CopyPropertiesFrom(AcDbEntity *pSrc,unsigned gMatchFlag)
{
}
void TImpSpecFitting::CopyPropertiesTo(AcDbObjectId& idTgr,unsigned gMatchFlag)
{
}
void TImpSpecFitting::CopyPropertiesTo(AcDbObjectIdArray& arIds,unsigned gMatchFlag)
{
}
BOOL TImpSpecFitting::OPMInfo(LPCTSTR pszName, TDb::OPMInfo* pInfo)
{
return FALSE;
}
BOOL TImpSpecFitting::IsValid(TDbXDataMap* pXMap)
{
return FALSE;
}
void TImpSpecFitting::OnSubErase( Adesk::Boolean erasing )
{
}
int TImpSpecFitting::GetXBaseShell(TXShell& xShell)
{
return 0;
}
int TImpSpecFitting::GetBodyBox(AcDbExtents& ext)
{
return 0;
}
LRESULT TImpSpecFitting::UserCall( long i,LPVOID pData )
{
return 0l;
}
CString TImpSpecFitting::GetXml(const AcGeMatrix3d& mat) const
{
return _T("");
}
bool TImpSpecFitting::GetSection(const AcDbFace &face, const AcGeVector3d &vtPlaneSecDir,
std::vector<TObjSectionRecord> &sectionRecord, AcDbVoidPtrArray& arFillPtrs) const
{
return false;
}
Acad::ErrorStatus TImpSpecFitting::GetExtents(TADSGePoint3d &ptLow, TADSGePoint3d &ptUp) const
{
return Acad::eNotImplementedYet;
}
// add by hh 2014-08-06 支持管件与水管遮挡
Acad::ErrorStatus TImpSpecFitting::GetClipBoundary(TGGePoly2D& poly)const
{
return Acad::eNotImplementedYet;
}
bool TImpSpecFitting::IsMeClip() const
{
return false;
}
bool TImpSpecFitting::IsClipMe(const TEntityBase* pEn)const//ok是否被裁剪
{
return false;
}