Files
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

718 lines
16 KiB
C++

#include "stdafx.h"
#include "TImpSpecPart.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
TImpSpecPart::TImpSpecPart()
{
m_pXDataMap = NULL;
m_pOwnerEnt = NULL;
}
TImpSpecPart::~TImpSpecPart()
{
}
void TImpSpecPart::Destroy()
{
delete this;
}
BOOL TImpSpecPart::GetInterface(int nIndex,TInterface& pipeInterface) const
{
return FALSE;
}
BOOL TImpSpecPart::GetInterface(const AcGePoint3d& ptCon,TInterface& pipeInterface) const
{
return FALSE;
}
BOOL TImpSpecPart::HasInterface(const AcGePoint3d& ptCon,const AcGeVector3d& vtDir)
{
return FALSE;
}
int TImpSpecPart::GetInterfaceCount() const
{
return 0;
}
BOOL TImpSpecPart::SetInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
return FALSE;
}
BOOL TImpSpecPart::RemoveInterfaceRelation(const AcGePoint3d& ptConnect,const AcDbObjectId& idConnect)
{
return FALSE;
}
BOOL TImpSpecPart::NotifyInterfaceToModify(const TInterfaceModifyMsg& iModiMsg,TInterfaceModifyMsgs& iModiMsgs)
{
return FALSE;
}
BOOL TImpSpecPart::AddCoverEdge(AcDbObjectId& id,TComplexCurve& curEdge)
{
return FALSE;
}
BOOL TImpSpecPart::RemoveCoverEdge(AcDbObjectId& id)
{
return FALSE;
}
BOOL TImpSpecPart::GetGeomExtentsEdge(TComplexCurve& crLoop)
{
return FALSE;
}
Acad::ErrorStatus TImpSpecPart::ExplodeOrDraw3d(XExplodeDraw &mode) const
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecPart::ExplodeOrDraw2d(XExplodeDraw &mode) const
{
return Acad::eOk;
}
void TImpSpecPart::GetKindName(CString& sName)
{
m_pXDataMap->GetAt(KEY_DXF,sName);
}
Acad::ErrorStatus TImpSpecPart::transformBy(const AcGeMatrix3d& xform)
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecPart::moveStretchPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecPart::moveGripPointsAt(const AcDbIntArray& indices,
const AcGeVector3d& offset)
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::getStretchPoints(AcGePoint3dArray& stretchPoints) const
{
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecPart::getStartPoint(AcGePoint3d& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getStartPoint(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::getStartParam(double& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getStartParam(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::getSplitCurves( const AcGePoint3dArray& points,
AcDbVoidPtrArray& curveSegments) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::getSplitCurves( const AcGeDoubleArray& params,
AcDbVoidPtrArray& curveSegments) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::getGripPoints(AcGePoint3dArray& gripPoints,
AcDbIntArray& osnapModes,
AcDbIntArray& geomIds) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::getGeomExtents(AcDbExtents& extents) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getGeomExtents(extents);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::getEndPoint(AcGePoint3d& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getEndPoint(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::getEndParam(double& x0) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
pPl->getEndParam(x0);
delete pPl;
return Acad::eOk;
}
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::getClassID(CLSID* pClsid) const
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::extend(double newParam)
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::extend(Adesk::Boolean extendStart,const AcGePoint3d& toPoint)
{
return Acad::eNotImplemented;
}
Acad::ErrorStatus TImpSpecPart::explode(AcDbVoidPtrArray& entitySet) const
{
AcDbPolyline* pPl = MakePolyCurve();
if (pPl != NULL)
{
entitySet.append(pPl);
}
return Acad::eOk;
}
Acad::ErrorStatus TImpSpecPart::copyFrom(const TImpSpecPart* pSrc)
{
m_pXDataMap->CopyFrom(pSrc->m_pXDataMap);
return Acad::eOk;
}
void TImpSpecPart::list() const
{
}
BOOL TImpSpecPart::MakeCurves(TComplexCurve& cplCurve) const
{
return FALSE;
}
AcDbPolyline* TImpSpecPart::MakePolyCurve() const
{
return NULL;
}
BOOL TImpSpecPart::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 TImpSpecPart::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 TImpSpecPart::ExplainGripIndex(int nIndex) const
{
return TDb::eStart;
}
BOOL TImpSpecPart::UpdateInterfaceRec(const AcDbObjectId& idOwner,const AcGeMatrix3d& xform,AcGePoint3d* ppOld)
{
//到命名对象字典中找;
BOOL bSuccess = FALSE;
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
//如果没有注册接口,注册接口
if (!pIntfRec->Find(idOwner))
{
TInterface pipeInterface;
for (int i = 0;i < GetInterfaceCount();i++)
{
pipeInterface.Reset();
if (GetInterface(i,pipeInterface))
{
pIntfRec->Add(pipeInterface);
}
}
}
else
{
if (ppOld == NULL)
bSuccess = pIntfRec->TransformBy(idOwner,xform);
else
bSuccess = pIntfRec->TransformBy(idOwner,*ppOld,xform);
}
pIntfRec->downgradeOpen();
}
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::kForWrite))
{
pDict->close();
//如果没有注册接口,注册接口
if (!pInterfaceRec->Find(idOwner))
{
TInterface pipeInterface;
for (int i = 0;i < GetInterfaceCount();i++)
{
pipeInterface.Reset();
if (GetInterface(i,pipeInterface))
{
pInterfaceRec->Add(pipeInterface);
}
}
}
else
{
if (ppOld == NULL)
{
bSuccess = pInterfaceRec->TransformBy(idOwner,xform);
}
else
{
bSuccess = pInterfaceRec->TransformBy(idOwner,*ppOld,xform);
}
}
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
return bSuccess;
}
BOOL TImpSpecPart::UpdateInterfaceRec(const AcDbObjectId& idOwner,const AcGePoint3d ptGeOld,const AcGePoint3d& ptGeNew)
{
//到命名对象字典中找;
BOOL bSuccess = FALSE;
// add by hh 2011-08-09 接口记录从字典移动到数据库中
TDbInterfaceRecord* pIntfRec = TAuxTools::GetIntfPtrFromDB();
if(NULL != pIntfRec)
{
if(Acad::eOk == pIntfRec->upgradeOpen())
{
pIntfRec->Update(idOwner,ptGeOld,ptGeNew);
pIntfRec->downgradeOpen();
}
pIntfRec->close();
return TRUE;
}
// 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::kForWrite))
{
pDict->close();
pInterfaceRec->Update(idOwner,ptGeOld,ptGeNew);
pInterfaceRec->close();
}
else
{
pDict->close();
}
}
else
{
pNamedDict->close();
}
}
return bSuccess;
}
BOOL TImpSpecPart::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;
}