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

325 lines
5.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#include "stdafx.h"
#include "TInterface.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
TInterface::TInterface()
{
m_ptGePos.set(0,0,0);
m_vtOutDir.set(0,0,0);
m_idConnect.setNull();
m_idOwner.setNull();
m_nCompareRule = 0;
m_nNotCompareRule = 0;
m_pszDescr = NULL;
m_dSize = 0.0f;
m_dSize1 = 0.0f;
m_nType = 0;
}
TInterface::TInterface(const TInterface& iSrc)
{
m_ptGePos = iSrc.m_ptGePos;
m_vtOutDir = iSrc.m_vtOutDir;
m_idConnect = iSrc.m_idConnect;
m_idOwner = iSrc.m_idOwner;
m_nCompareRule = iSrc.m_nCompareRule;
m_nNotCompareRule = iSrc.m_nNotCompareRule;
m_dSize = iSrc.m_dSize;
m_dSize1 = iSrc.m_dSize1;
m_pszDescr = NULL;
m_nType = iSrc.m_nType;
//BEGIN=========================================================
if (iSrc.m_pszDescr != NULL)
{
INT_PTR nLen = 0;
try
{
nLen = _tcslen(iSrc.m_pszDescr) + 1;
m_pszDescr = new TCHAR[nLen];
_tcscpy(m_pszDescr,iSrc.m_pszDescr);
}
catch (...)
{
}
}
//修改时间:2010-02-11
//修改人 :mcl
//修改原因:支持接口描述拷贝
//END===========================================================
}
TInterface::~TInterface()
{
if (m_pszDescr != NULL)
delete [] m_pszDescr;
}
void TInterface::Reset()
{
m_ptGePos.set(0,0,0);
m_vtOutDir.set(0,0,0);
m_idConnect.setNull();
m_idOwner.setNull();
m_nCompareRule = 0;
if (m_pszDescr != NULL)
delete [] m_pszDescr;
m_pszDescr = NULL;
m_dSize = 0.0f;
m_dSize1 = 0.0f;
}
void TInterface::SetPosition(const AcGePoint3d& ptPos)
{
m_ptGePos = ptPos;
}
AcGePoint3d TInterface::GetPosition() const
{
return m_ptGePos;
}
AcGePoint3d& TInterface::GetPosition()
{
return m_ptGePos;
}
void TInterface::SetMidPoint(const AcGePoint3d& ptPos)
{
m_ptGeMid = ptPos;
}
AcGePoint3d TInterface::GetMidPoint() const
{
return m_ptGeMid;
}
AcGePoint3d& TInterface::GetMidPoint()
{
return m_ptGeMid;
}
void TInterface::SetOutDir(const AcGeVector3d& vtDir)
{
m_vtOutDir = vtDir;
}
AcGeVector3d TInterface::GetOutDir() const
{
return m_vtOutDir;
}
AcGeVector3d& TInterface::GetOutDir()
{
return m_vtOutDir;
}
void TInterface::SetConnectObject(const AcDbObjectId& idCon)
{
m_idConnect = idCon;
}
AcDbObjectId TInterface::GetConnectObject() const
{
AcDbObjectId id;
id.setFromOldId(m_idConnect.asOldId());
return id;
}
void TInterface::SetOwnerId(const AcDbObjectId& idOwner)
{
m_idOwner = idOwner;
}
AcDbObjectId TInterface::GetOwnerId() const
{
AcDbObjectId id;
id.setFromOldId(m_idOwner.asOldId());
return id;
}
TInterface& TInterface::operator = (const TInterface& iSrc)
{
if (this != &iSrc)
{
m_ptGePos = iSrc.m_ptGePos;
m_vtOutDir = iSrc.m_vtOutDir;
m_idConnect = iSrc.m_idConnect;
m_idOwner = iSrc.m_idOwner;
m_nCompareRule = iSrc.m_nCompareRule;
m_nNotCompareRule = iSrc.m_nNotCompareRule;
m_dSize = iSrc.m_dSize;
m_dSize1 = iSrc.m_dSize1;
if (m_pszDescr != NULL) // mcl add,2010.02.11
{
delete [] m_pszDescr;
m_pszDescr = NULL;
}
if (iSrc.m_pszDescr != NULL)
{
m_pszDescr = new TCHAR[_tcslen(iSrc.m_pszDescr) + 1];
_tcscpy(m_pszDescr,iSrc.m_pszDescr);
}
m_nType = iSrc.m_nType;
}
return *this;
}
void TInterface::CopyFrom(const TInterface& iSrc)
{
m_ptGePos = iSrc.m_ptGePos;
m_vtOutDir = iSrc.m_vtOutDir;
m_idConnect = iSrc.m_idConnect;
m_idOwner = iSrc.m_idOwner;
m_nCompareRule = iSrc.m_nCompareRule;
m_nNotCompareRule = iSrc.m_nNotCompareRule;
m_dSize = iSrc.m_dSize;
m_dSize1 = iSrc.m_dSize1;
if (m_pszDescr != NULL) // mcl add,2010.02.11
{
delete [] m_pszDescr;
m_pszDescr = NULL;
}
if (iSrc.m_pszDescr != NULL)
{
m_pszDescr = new TCHAR[_tcslen(iSrc.m_pszDescr) + 1];
_tcscpy(m_pszDescr,iSrc.m_pszDescr);
}
m_nType = iSrc.m_nType;
}
void TInterface::TransformBy(const AcGeMatrix3d& xform)
{
m_ptGePos.transformBy(xform);
m_vtOutDir.transformBy(xform);
}
void TInterface::OtherBeforeTransformBy(const TInterfaceModifyMsg& msg)
{
AcDbObjectId idOwner = m_idOwner;
AcDbObjectId idCon = m_idConnect;
AcGeMatrix3d xform = msg.GetTransform();
xform.invert();
AcGePoint3d ptGe = m_ptGePos;
ptGe.transformBy(xform);
AcGeVector3d vtDir = m_vtOutDir;
vtDir.transformBy(xform);
SetOutDir(vtDir);
SetPosition(ptGe);
SetOwnerId(idCon);
SetConnectObject(idOwner);
}
void TInterface::SetCompareRule(int nCompareRule,int nNotCompareRule)
{
m_nCompareRule = nCompareRule;
m_nNotCompareRule = nNotCompareRule;
}
int TInterface::GetNotCompareRule() const
{
return m_nNotCompareRule;
}
int TInterface::GetCompareRule() const
{
return m_nCompareRule;
}
void TInterface::SetSize(double dSize,double dSize1)
{
m_dSize = (float)dSize;
m_dSize1 = (float)dSize1;
}
void TInterface::GetSize(double& dSize,double& dSize1) const
{
dSize = m_dSize;
dSize1 = m_dSize1;
}
void TInterface::SetDescr(LPCTSTR pszDescr)
{
if (pszDescr != NULL)
{
if (m_pszDescr != NULL) delete [] m_pszDescr;
m_pszDescr = new TCHAR[_tcslen(pszDescr) + 1];
_tcscpy(m_pszDescr,pszDescr);
}
else
{
if (m_pszDescr != NULL) // mcl add,2010.02.11
{
delete [] m_pszDescr;
m_pszDescr = NULL;
}
}
}
void TInterface::GetDescr(CString& sDescr) const
{
if (m_pszDescr != NULL)
sDescr = m_pszDescr;
}
void TInterface::SetType(short nType)
{
m_nType = nType;
}
short TInterface::GetType() const
{
return m_nType;
}
TInterfaces::TInterfaces()
{
}
TInterfaces::~TInterfaces()
{
}
int TInterfaces::append( TInterface& value )
{
return (int)m_arInterfaces.Add(value);
}
TInterface TInterfaces::at(int index) const
{
ASSERT(index > -1 && index < m_arInterfaces.GetSize());
return m_arInterfaces.GetAt(index);
}
int TInterfaces::length() const
{
return (int)m_arInterfaces.GetSize();
}
void TInterfaces::removeAt(int iIndex)
{
m_arInterfaces.RemoveAt(iIndex);
}
TInterface TInterfaces::operator[](int nIndex) const
{
return m_arInterfaces.GetAt(nIndex);
}
TInterface& TInterfaces::operator[](int nIndex)
{
return m_arInterfaces[nIndex];
}