2163 lines
41 KiB
C++
2163 lines
41 KiB
C++
#include "stdafx.h"
|
|
#include "KTExtractDwgFiler.h"
|
|
#include "comdef.h"
|
|
#include "base64.h"
|
|
|
|
ACRX_CONS_DEFINE_MEMBERS(KTExtractDwgFiler, AcDbDwgFiler, 0);
|
|
|
|
namespace
|
|
{
|
|
void FormatPoint(TCHAR szBuff[], ads_point pt)
|
|
{
|
|
_stprintf(szBuff, _T("(%d,%d,%d)"), (int)(pt[X] + 0.5), (int)(pt[Y] + 0.5), (int)(pt[Z] + 0.5));
|
|
}
|
|
|
|
double __ttof(LPCTSTR pszString)
|
|
{
|
|
bool bSign = false;
|
|
bool bPowerSign = false;
|
|
bool bExponent = true;
|
|
bool bMantissa = false;
|
|
|
|
int nPower = 0;
|
|
double dExponent = 0.0;
|
|
double dMantissa = 0.0;
|
|
double dScale = 1.0;
|
|
TCHAR* pIn = (TCHAR*)pszString;
|
|
|
|
if (*pIn == _T('-'))
|
|
{
|
|
*pIn++;
|
|
bSign = true;
|
|
}
|
|
|
|
while (*pIn != 0)
|
|
{
|
|
// capture digits
|
|
if ((*pIn >= _T('0')) && (*pIn <= _T('9')))
|
|
{
|
|
if (bExponent)
|
|
{
|
|
dExponent *= 10.0;
|
|
dExponent += (*pIn - _T('0'));
|
|
}
|
|
else if (bMantissa)
|
|
{
|
|
dMantissa *= 10.0;
|
|
dMantissa += (*pIn - _T('0'));
|
|
|
|
dScale *= 10.0;
|
|
}
|
|
else
|
|
{
|
|
nPower *= 10;
|
|
nPower += (*pIn - _T('0'));
|
|
}
|
|
}
|
|
else if ((*pIn == _T('e')) || (*pIn == _T('E')))// power
|
|
{
|
|
// sign
|
|
if (*(++pIn) == _T('-'))
|
|
{
|
|
bPowerSign = true;
|
|
}
|
|
|
|
bMantissa = false;
|
|
}
|
|
else
|
|
{
|
|
// the first character that hasn't been accounted for already,
|
|
// is assumed to be the separator
|
|
// cross over
|
|
if (bExponent)
|
|
{
|
|
bExponent = false;
|
|
bMantissa = true;
|
|
}
|
|
// white space (including null) or bad char
|
|
// we're done either way
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
pIn++;
|
|
}
|
|
|
|
double dVal = dExponent + (dMantissa / dScale);
|
|
if (nPower > 0)
|
|
{
|
|
for (; nPower > 0; nPower--)
|
|
{
|
|
if (bPowerSign)
|
|
{
|
|
dVal /= 10.0;
|
|
}
|
|
else
|
|
{
|
|
dVal *= 10.0;
|
|
}
|
|
}
|
|
}
|
|
if (bSign)
|
|
{
|
|
dVal *= -1.0;
|
|
}
|
|
return dVal;
|
|
}
|
|
}
|
|
|
|
KTExtractDwgFiler::KTExtractDwgFiler()
|
|
: m_filerType(AcDb::kCopyFiler)
|
|
{
|
|
m_pxDataMap = NULL;
|
|
}
|
|
|
|
KTExtractDwgFiler::~KTExtractDwgFiler()
|
|
{
|
|
if (m_pxDataMap != NULL)
|
|
{
|
|
delete m_pxDataMap;
|
|
}
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::filerStatus() const
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcDb::FilerType KTExtractDwgFiler::filerType() const
|
|
{
|
|
return m_filerType;
|
|
}
|
|
|
|
void KTExtractDwgFiler::setFilerStatus(Acad::ErrorStatus es)
|
|
{
|
|
}
|
|
|
|
void KTExtractDwgFiler::resetFilerStatus()
|
|
{
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeHardOwnershipId(const AcDbHardOwnershipId& id)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("HardOwnershipId"));
|
|
|
|
CString sText;
|
|
|
|
|
|
#ifdef _WIN64
|
|
sText.Format(_T("%lld"),id.asOldId());
|
|
#else
|
|
sText.Format(_T("%d"),id.asOldId());
|
|
#endif
|
|
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeSoftOwnershipId(const AcDbSoftOwnershipId& id)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("SoftOwnershipId"));
|
|
|
|
//不涉及到用户数据
|
|
CString sText;
|
|
|
|
#ifdef _WIN64
|
|
sText.Format(_T("%lld"),id.asOldId());
|
|
#else
|
|
sText.Format(_T("%d"),id.asOldId());
|
|
#endif
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeHardPointerId(const AcDbHardPointerId& id)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("HardPointerId"));
|
|
|
|
//不涉及到用户数据
|
|
CString sText;
|
|
|
|
#ifdef _WIN64
|
|
sText.Format(_T("%lld"),id.asOldId());
|
|
#else
|
|
sText.Format(_T("%d"),id.asOldId());
|
|
#endif
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeSoftPointerId(const AcDbSoftPointerId& id)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("SoftPointerId"));
|
|
|
|
//不涉及到用户数据
|
|
CString sText;
|
|
|
|
#ifdef _WIN64
|
|
sText.Format(_T("%lld"),id.asOldId());
|
|
#else
|
|
sText.Format(_T("%d"),id.asOldId());
|
|
#endif
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeInt8(Adesk::Int8 nInt8)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::Int8"));
|
|
|
|
//不涉及到用户数据
|
|
CString sText;
|
|
sText.Format(_T("%d"),nInt8);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeChar(Adesk::Int8 ch)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::Int8"));
|
|
|
|
//不涉及到用户数据
|
|
CString sText;
|
|
sText.Format(_T("%d"),ch);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeString(const ACHAR * pACHAR)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("String"));
|
|
|
|
m_arItemLines.Add(pACHAR);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX>15
|
|
#include "acstring.h"
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeString(const AcString& str)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("String"));
|
|
|
|
m_arItemLines.Add(str);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
#endif
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeBChunk(const ads_binary& binar)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("binary"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),m_arBinaryBufs.GetSize());
|
|
m_arItemLines.Add(sText);
|
|
|
|
binary_buf buf;
|
|
buf.nLen = binar.clen;
|
|
buf.pBuf = new byte[binar.clen];
|
|
memcpy(buf.pBuf,binar.buf,binar.clen);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeAcDbHandle(const AcDbHandle& dbhdl)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Handle"));
|
|
|
|
TCHAR szText[256];
|
|
memset(szText,0,sizeof(szText));
|
|
dbhdl.getIntoAsciiBuffer(szText);
|
|
|
|
m_arItemLines.Add(szText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeInt32(Adesk::Int32 nInt32)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::Int32"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),nInt32);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeInt16(Adesk::Int16 nInt16)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::Int16"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),nInt16);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeUInt32(Adesk::UInt32 nUInt32)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::UInt32"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),nUInt32);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeUInt16(Adesk::UInt16 nUInt16)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::UInt16"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),nUInt16);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeUInt8(Adesk::UInt8 nUInt8)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::UInt8"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),nUInt8);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeBool(bool bVal)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("bool"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),bVal ? TRUE : FALSE);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeBoolean(Adesk::Boolean bVal)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::Boolean"));
|
|
CString sText;
|
|
sText.Format(_T("%d"),bVal);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeDouble(double dVal)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("double"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%g"),dVal);
|
|
m_arItemLines.Add(sText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writePoint2d(const AcGePoint2d& pt2d)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Point2d"));
|
|
|
|
TCHAR szText[256];
|
|
memset(szText,0,sizeof(szText));
|
|
FormatPoint(szText,asDblArray(pt2d));
|
|
|
|
m_arItemLines.Add(szText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writePoint3d(const AcGePoint3d& pt3d)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Point3d"));
|
|
|
|
TCHAR szText[256];
|
|
memset(szText,0,sizeof(szText));
|
|
|
|
FormatPoint(szText,asDblArray(pt3d));
|
|
m_arItemLines.Add(szText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeVector2d(const AcGeVector2d& vec2d)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Vector2d"));
|
|
|
|
TCHAR szText[256];
|
|
memset(szText,0,sizeof(szText));
|
|
|
|
FormatPoint(szText,asDblArray(vec2d));
|
|
m_arItemLines.Add(szText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeVector3d(const AcGeVector3d& vec3d)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Vector3d"));
|
|
|
|
TCHAR szText[256];
|
|
memset(szText,0,sizeof(szText));
|
|
|
|
FormatPoint(szText,asDblArray(vec3d));
|
|
m_arItemLines.Add(szText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeScale3d(const AcGeScale3d& scl3d)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Scale3d"));
|
|
|
|
TCHAR szText[256];
|
|
memset(szText,0,sizeof(szText));
|
|
|
|
FormatPoint(szText,asDblArray(AcGePoint3d(scl3d.sx,scl3d.sy,scl3d.sz)) );
|
|
m_arItemLines.Add(szText);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
#if ARX<18
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeBytes(const void* pByte, Adesk::UInt32 nLen)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Bytes"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),m_arBinaryBufs.GetSize() );
|
|
m_arItemLines.Add(sText);
|
|
|
|
binary_buf buf;
|
|
buf.nLen = nLen;
|
|
buf.pBuf = new byte[buf.nLen];
|
|
memcpy(buf.pBuf,pByte,nLen);
|
|
|
|
m_arBinaryBufs.Add(buf);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
#endif
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeAddress(const void* pAddr)
|
|
{
|
|
//不涉及到用户数据
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcDbHardOwnershipId& id)
|
|
{
|
|
return writeHardOwnershipId(id);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcDbSoftOwnershipId& id)
|
|
{
|
|
return writeSoftOwnershipId(id);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcDbHardPointerId& id)
|
|
{
|
|
return writeHardPointerId(id);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcDbSoftPointerId& id)
|
|
{
|
|
return writeSoftPointerId(id);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const ACHAR * pStr)
|
|
{
|
|
return writeString(pStr);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const ads_binary& binar)
|
|
{
|
|
return writeBChunk(binar);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcDbHandle& hdl)
|
|
{
|
|
return writeAcDbHandle(hdl);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(Adesk::Int32 nInt32)
|
|
{
|
|
return writeInt32(nInt32);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(Adesk::Int16 nInt16)
|
|
{
|
|
return writeInt16(nInt16);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(Adesk::Int8 nInt8)
|
|
{
|
|
return writeInt8(nInt8);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(Adesk::UInt32 nUInt32)
|
|
{
|
|
return writeUInt32(nUInt32);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(Adesk::UInt16 nUInt16)
|
|
{
|
|
return writeUInt16(nUInt16);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(Adesk::UInt8 nUInt8)
|
|
{
|
|
return writeUInt8(nUInt8);
|
|
}
|
|
|
|
#ifndef Adesk_Boolean_is_bool
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(Adesk::Boolean bVal)
|
|
{
|
|
return writeBoolean(bVal);
|
|
}
|
|
#else
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(bool bVal)
|
|
{
|
|
return writeBool(bVal);
|
|
}
|
|
#endif
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(double dVal)
|
|
{
|
|
return writeDouble(dVal);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcGePoint2d& pt2d)
|
|
{
|
|
return writePoint2d(pt2d);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcGePoint3d& pt3d)
|
|
{
|
|
return writePoint3d(pt3d);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcGeVector2d& pt2d)
|
|
{
|
|
return writeVector2d(pt2d);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcGeVector3d& pt3d)
|
|
{
|
|
return writeVector3d(pt3d);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const AcGeScale3d& pt3d)
|
|
{
|
|
return writeScale3d(pt3d);
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const void* pBuf, Adesk::UInt32 nLen)
|
|
{
|
|
return Acad::eOk;;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeItem(const void * pBuf)
|
|
{
|
|
return writeAddress(pBuf);
|
|
}
|
|
|
|
//取所有autocad 平台的相同的部分,所以下面64位不处理
|
|
#if ARX>17
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeInt64(Adesk::Int64 nVal)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::Int64"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),nVal);
|
|
m_arItemLines.Add(sText);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeUInt64(Adesk::UInt64 nVal)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Adesk::UInt64"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),nVal);
|
|
m_arItemLines.Add(sText);
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus KTExtractDwgFiler::writeBytes(const void * pbuf, Adesk::UIntPtr nLen)
|
|
{
|
|
//占位
|
|
m_arSerialDNA.Add(_T("Bytes"));
|
|
|
|
CString sText;
|
|
sText.Format(_T("%d"),m_arBinaryBufs.GetSize() );
|
|
m_arItemLines.Add(sText);
|
|
|
|
binary_buf buf;
|
|
buf.nLen = nLen;
|
|
buf.pBuf = new byte[buf.nLen];
|
|
memcpy(buf.pBuf,pbuf,nLen);
|
|
|
|
m_arBinaryBufs.Add(buf);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
#endif
|
|
|
|
int KTExtractDwgFiler::ReadLinesByLockedSerialDNA(CStringArray& arLockDNA,CStringArray& arLines)
|
|
{
|
|
BOOL bFind = FALSE;
|
|
int nIndex = 0,nCount = 0;
|
|
CString sLockDNA,sDNA;
|
|
|
|
for (int i = 0;i < arLockDNA.GetSize();i++)
|
|
{
|
|
sLockDNA = arLockDNA.GetAt(i);
|
|
if (nIndex + i > m_arSerialDNA.GetSize() - 1)
|
|
{
|
|
break;
|
|
}
|
|
sDNA = m_arSerialDNA.GetAt(nIndex + i);
|
|
|
|
if (sDNA.CompareNoCase(sLockDNA) != 0)
|
|
{
|
|
nIndex += 1;
|
|
i = -1;
|
|
nCount = 0;
|
|
bFind = FALSE;
|
|
}
|
|
else
|
|
{
|
|
nCount += 1;
|
|
}
|
|
|
|
if (nCount == arLockDNA.GetSize())
|
|
{
|
|
bFind = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bFind)
|
|
{
|
|
for (int ii = 0;ii < arLockDNA.GetSize();ii++)
|
|
{
|
|
arLines.Add(m_arItemLines.GetAt(nIndex + ii));
|
|
}
|
|
return (nIndex + ii);
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
int KTExtractDwgFiler::FindPositionByDNATypes(CStringArray& arLockDNA)
|
|
{
|
|
BOOL bFind = FALSE;
|
|
int nIndex = 0,nCount = 0;
|
|
CString sLockDNA,sDNA;
|
|
|
|
for (int i = 0;i < arLockDNA.GetSize();i++)
|
|
{
|
|
sLockDNA = arLockDNA.GetAt(i);
|
|
if (nIndex + i > m_arSerialDNA.GetSize() - 1)
|
|
{
|
|
break;
|
|
}
|
|
sDNA = m_arSerialDNA.GetAt(nIndex + i);
|
|
|
|
if (sDNA.CompareNoCase(sLockDNA) != 0)
|
|
{
|
|
nIndex += 1;
|
|
i = -1;
|
|
nCount = 0;
|
|
bFind = FALSE;
|
|
}
|
|
else
|
|
{
|
|
nCount += 1;
|
|
}
|
|
|
|
if (nCount == arLockDNA.GetSize())
|
|
{
|
|
bFind = TRUE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bFind)
|
|
{
|
|
/*for (int ii = 0;ii < arLockDNA.GetSize();ii++)
|
|
{
|
|
arLines.Add(m_arItemLines.GetAt(nIndex + ii));
|
|
}
|
|
return (nIndex + ii);
|
|
*/
|
|
return nIndex;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
BOOL KTExtractDwgFiler::ReadDNASegmentInSection(CStringArray& arLockDNA,CStringArray& arLines,LPCTSTR pszDNAType,LPCTSTR pszDNATypeBefor)
|
|
{
|
|
CStringArray arTLines;
|
|
int nIndex = ReadLinesByLockedSerialDNA(arLockDNA,arTLines);
|
|
BOOL bFind = FALSE;
|
|
|
|
if (nIndex != -1 && nIndex < m_arItemLines.GetSize())
|
|
{
|
|
CString sType;
|
|
while(TRUE)
|
|
{
|
|
//找到第一次出现的DNA
|
|
sType = m_arSerialDNA.GetAt(nIndex);
|
|
if (sType.CompareNoCase(pszDNAType) == 0)
|
|
{
|
|
bFind = TRUE;
|
|
arLines.Add(m_arItemLines.GetAt(nIndex));
|
|
}
|
|
else
|
|
{
|
|
if (sType.CompareNoCase(pszDNATypeBefor) == 0)//止
|
|
{
|
|
break;
|
|
}
|
|
|
|
if (bFind)//结束
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
nIndex += 1;
|
|
if (nIndex >= m_arSerialDNA.GetSize())
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return bFind;
|
|
}
|
|
|
|
BOOL KTExtractDwgFiler::ReadDNAAtPosition(int& nIndex,CString& sDNAType,CString& sLine)
|
|
{
|
|
if (nIndex != -1 && nIndex < m_arItemLines.GetSize())
|
|
{
|
|
sDNAType = m_arSerialDNA.GetAt(nIndex);
|
|
sLine = m_arItemLines.GetAt(nIndex);
|
|
nIndex += 1;
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
AecXDataMap* KTExtractDwgFiler::FormatDataMap()
|
|
{
|
|
if (m_pxDataMap != NULL)
|
|
delete m_pxDataMap;
|
|
|
|
m_pxDataMap = new AecXDataMap;
|
|
m_pxDataMap->FormatDataMap(m_arItemLines);
|
|
|
|
return m_pxDataMap;
|
|
}
|
|
|
|
|
|
#define MAP_BLOCK_BEGIN _T("TDBXDATAMAP_BLOCK_BEGIN_")
|
|
#define MAP_BLOCK_END _T("TDBXDATAMAP_BLOCK_END_")
|
|
#define DIF_VT_PT _T("$vector3d")
|
|
|
|
AecXDataMap::AecXDataMap()
|
|
{
|
|
}
|
|
|
|
AecXDataMap::~AecXDataMap()
|
|
{
|
|
//释放 xData 是自符串的元素
|
|
std::map<CString, XData>::iterator itor;
|
|
for (itor = m_xData.begin(); itor != m_xData.end(); ++itor)
|
|
{
|
|
|
|
if (itor->second.nVt == VT_BSTR ||
|
|
itor->second.nVt == (VT_BYREF | VT_R8 + 4))
|
|
{
|
|
if (itor->second.pszVal != NULL && itor->second.npszLen > 0)
|
|
{
|
|
delete[] itor->second.pszVal;
|
|
itor->second.pszVal = NULL;
|
|
itor->second.npszLen = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, int nVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(xdata));
|
|
xdata.nVt = VT_I4;
|
|
xdata.nVal = nVal;
|
|
|
|
It it = m_xData.find(pszKey);
|
|
if (it != m_xData.end())
|
|
{
|
|
(*it).second = xdata;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString, XData> pa(pszKey, xdata);
|
|
m_xData.insert(pa);
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, double dVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(xdata));
|
|
xdata.nVt = VT_R8;
|
|
xdata.dVal[0] = dVal;
|
|
|
|
It it = m_xData.find(pszKey);
|
|
if (it != m_xData.end())
|
|
{
|
|
(*it).second = xdata;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString, XData> pa(pszKey, xdata);
|
|
m_xData.insert(pa);
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, const AcGeDoubleArray& arVal)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sSubKey;
|
|
for (int i = 0; i < arVal.length(); ++i)
|
|
{
|
|
sSubKey.Format(_T("%s%d"), pszKey, i);
|
|
SetAt(sSubKey, arVal[i]);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, const AcGeVector3d& vt, BOOL bTransformBy)
|
|
{
|
|
/*
|
|
设置向量是在键值pszkey后增加字符串"$vector3d",与点进行区分
|
|
bTransformBy标识向量是否随cad实体所变化
|
|
*/
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sTmpKey = pszKey;
|
|
sTmpKey += DIF_VT_PT;
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(xdata));
|
|
xdata.nVt = (VT_BYREF | VT_R8 + 2);
|
|
if (bTransformBy)
|
|
{
|
|
// 向量随cad实体变化而改变
|
|
xdata.nVt = (VT_BYREF | VT_R8 + 3);
|
|
}
|
|
xdata.dVal[0] = vt.x;
|
|
xdata.dVal[1] = vt.y;
|
|
xdata.dVal[2] = vt.z;
|
|
|
|
It it = m_xData.find(sTmpKey);
|
|
if (it != m_xData.end())
|
|
{
|
|
(*it).second = xdata;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString, XData> pa(sTmpKey, xdata);
|
|
m_xData.insert(pa);
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, const AcGePoint3d& ptGe, BOOL bTransformBy)
|
|
{
|
|
/*
|
|
bTransformBy标识点是否随cad实体所变化
|
|
*/
|
|
if (pszKey != NULL)
|
|
{
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(xdata));
|
|
xdata.nVt = VT_BYREF | VT_R8;
|
|
if (bTransformBy)
|
|
{
|
|
// 点随cad实体变化而改变
|
|
xdata.nVt = (VT_BYREF | VT_R8 + 1);
|
|
}
|
|
|
|
xdata.dVal[0] = ptGe.x;
|
|
xdata.dVal[1] = ptGe.y;
|
|
xdata.dVal[2] = ptGe.z;
|
|
|
|
It it = m_xData.find(pszKey);
|
|
if (it != m_xData.end())
|
|
{
|
|
(*it).second = xdata;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString, XData> pa(pszKey, xdata);
|
|
m_xData.insert(pa);
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, const AcGePoint3dArray& arPt, BOOL bTransformBy)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sSubKey;
|
|
for (int i = 0; i < arPt.length(); ++i)
|
|
{
|
|
sSubKey.Format(_T("%s%d"), pszKey, i);
|
|
SetAt(sSubKey, arPt[i], bTransformBy);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, const AcGeMatrix3d& xform)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(xdata));
|
|
xdata.nVt = (VT_BYREF | VT_R8 + 4);
|
|
|
|
CString sText = _T(""), sTemp;
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
for (int j = 0; j < 4; j++)
|
|
{
|
|
sTemp.Format(_T("%g"), xform.entry[i][j]);
|
|
sText += _T(",") + sTemp;
|
|
}
|
|
}
|
|
sText.TrimLeft(_T(","));
|
|
|
|
xdata.npszLen = sText.GetLength() + 1;
|
|
xdata.pszVal = new TCHAR[xdata.npszLen];
|
|
_tcscpy(xdata.pszVal, sText);
|
|
|
|
It it = m_xData.find(pszKey);
|
|
if (it != m_xData.end()) //找到
|
|
{
|
|
if ((*it).second.nVt == VT_BSTR ||
|
|
(*it).second.nVt == (VT_BYREF | VT_R8 + 4))
|
|
{
|
|
if ((*it).second.npszLen > 0 && (*it).second.pszVal != NULL)
|
|
{
|
|
delete[](*it).second.pszVal;
|
|
}
|
|
}
|
|
|
|
(*it).second = xdata;
|
|
}
|
|
else //未找到
|
|
{
|
|
std::pair<CString, XData> pa(pszKey, xdata);
|
|
m_xData.insert(pa);
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
static BOOL Script2StringArray(const CString& sScript, TCHAR tSpace, CStringArray& arTexts)
|
|
{
|
|
//x,y,z,d,a
|
|
int nPos = -1, nStart = 0;
|
|
CString sText;
|
|
|
|
while (TRUE)
|
|
{
|
|
nPos = sScript.Find(tSpace, nStart);
|
|
if (nPos != -1)
|
|
{
|
|
sText = sScript.Mid(nStart, nPos - nStart);
|
|
arTexts.Add(sText);
|
|
nStart = nPos + 1;
|
|
}
|
|
else
|
|
{
|
|
if (nStart <= sScript.GetLength() - 1)
|
|
{
|
|
sText = sScript.Mid(nStart);
|
|
arTexts.Add(sText);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return arTexts.GetSize() > 0;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, AcGeMatrix3d& xform) const
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(pszKey)) != m_xData.end())
|
|
{
|
|
XData xdata = (*it).second;
|
|
if (xdata.nVt == (VT_BYREF | VT_R8 + 4))
|
|
{
|
|
CString sText = xdata.pszVal;
|
|
CStringArray arTexts;
|
|
|
|
Script2StringArray(sText, _T(','), arTexts);
|
|
if (arTexts.GetSize() == 16)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
for (int j = 0; j < 4; j++)
|
|
{
|
|
xform.entry[i][j] = __ttof(arTexts.GetAt(i * 4 + j));
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, LPCTSTR pszValue)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sTmp = pszValue;
|
|
if (sTmp.GetLength() >= MAX_PATH)
|
|
return FALSE;
|
|
|
|
if (_tcslen(pszValue) < 0)
|
|
return FALSE;
|
|
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(xdata));
|
|
|
|
xdata.nVt = VT_BSTR;
|
|
xdata.npszLen = _tcslen(pszValue) + 1;
|
|
xdata.pszVal = new TCHAR[xdata.npszLen];
|
|
memset(xdata.pszVal, 0, xdata.npszLen);
|
|
_tcscpy(xdata.pszVal, pszValue);
|
|
|
|
It it = m_xData.find(pszKey);
|
|
if (it != m_xData.end())
|
|
{
|
|
// Rem:.2010.7.23 原来的要删除
|
|
if ((*it).second.npszLen > 0 && (*it).second.pszVal != NULL)
|
|
delete[](*it).second.pszVal;
|
|
|
|
//(*it).second = xdata;
|
|
(*it).second.pszVal = new TCHAR[xdata.npszLen];
|
|
memset((*it).second.pszVal, 0, xdata.npszLen);
|
|
_tcscpy((*it).second.pszVal, pszValue);
|
|
|
|
delete[] xdata.pszVal;
|
|
xdata.pszVal = NULL;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString, XData> pa(pszKey, xdata);
|
|
m_xData.insert(pa);
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, int iIndex, LPCTSTR pszValue)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sKey;
|
|
sKey.Format(_T("%s_%d"), pszKey, iIndex);
|
|
return SetAt(sKey, pszValue);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, int iIndex, CString &sValue)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sKey;
|
|
sKey.Format(_T("%s_%d"), pszKey, iIndex);
|
|
return GetAt(sKey, sValue);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, int iIndex, const AecXDataMap& xDataMap)
|
|
{
|
|
//{key | type | inf}个隔开
|
|
CString sKey, sType, sInfo, sRecord, sText;
|
|
sText = _T("");
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(XData));
|
|
|
|
typedef std::map<CString, XData>::const_iterator It;
|
|
for (It it = xDataMap.m_xData.begin(); it != xDataMap.m_xData.end(); ++it)
|
|
{
|
|
xdata = (*it).second;
|
|
sKey = (*it).first;
|
|
sType = _T("");
|
|
sInfo = _T("");
|
|
|
|
switch (xdata.nVt)
|
|
{
|
|
case VT_I4: // 整型
|
|
{
|
|
sType.Format(_T("%d"), VT_I4);
|
|
sInfo.Format(_T("%d"), xdata.nVal);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case VT_UI4:
|
|
{
|
|
sType.Format(_T("%d"), VT_UI4);
|
|
sInfo.Format(_T("%d"), xdata.nVal);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case VT_UI8:
|
|
{
|
|
sType.Format(_T("%d"), VT_UI8);
|
|
sInfo.Format(_T("%d"), xdata.nVal);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case VT_R8: // 浮点
|
|
{
|
|
sType.Format(_T("%d"), VT_R8);
|
|
sInfo.Format(_T("%g"), xdata.dVal[0]);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8): // 点
|
|
{
|
|
sType.Format(_T("%d"), (VT_BYREF | VT_R8));
|
|
sInfo.Format(_T("%.4f,%.4f,%.4f"), xdata.dVal[0], xdata.dVal[1], xdata.dVal[2]);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 1): // cad变化点
|
|
{
|
|
sType.Format(_T("%d"), (VT_BYREF | VT_R8 + 1));
|
|
sInfo.Format(_T("%g,%g,%g"), xdata.dVal[0], xdata.dVal[1], xdata.dVal[2]);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 2): // 向量
|
|
{
|
|
sType.Format(_T("%d"), (VT_BYREF | VT_R8 + 2));
|
|
sInfo.Format(_T("%g,%g,%g"), xdata.dVal[0], xdata.dVal[1], xdata.dVal[2]);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 3): // 变化向量
|
|
{
|
|
sType.Format(_T("%d"), (VT_BYREF | VT_R8 + 3));
|
|
sInfo.Format(_T("%g,%g,%g"), xdata.dVal[0], xdata.dVal[1], xdata.dVal[2]);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 4): // 矩阵
|
|
{
|
|
sType.Format(_T("%d"), VT_BYREF | VT_R8 + 4);
|
|
sInfo.Format(_T("%s"), xdata.pszVal);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
case VT_BSTR: // 字符串
|
|
{
|
|
sType.Format(_T("%d"), VT_BSTR);
|
|
sInfo.Format(_T("%s"), xdata.pszVal);
|
|
sRecord.Format(_T("{%s|%s|%s}"), sKey, sType, sInfo);
|
|
sText += sRecord;
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
if (!sText.IsEmpty())
|
|
return SetAt(pszKey, iIndex, sText);
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::ParseToRecords(CString& sText, CStringArray& arRecords)
|
|
{
|
|
CString sRecord;
|
|
int nFr = 0, nTo = 0;
|
|
//{Key|Type|Info}...
|
|
while (TRUE)
|
|
{
|
|
nFr = sText.Find(_T("{"), 0);
|
|
nTo = sText.Find(_T("}"), 0);
|
|
if (nFr == 0 && nTo > 0)
|
|
{
|
|
sRecord = sText.Mid(nFr, nTo + 1);
|
|
sRecord.TrimLeft(_T("{"));
|
|
sRecord.TrimRight(_T("}"));
|
|
arRecords.Add(sRecord);
|
|
|
|
if (nTo + 1 < sText.GetLength())
|
|
{
|
|
sRecord = sText.Mid(nTo + 1);
|
|
sText = sRecord;
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
return arRecords.GetSize() > 0;
|
|
}
|
|
|
|
BOOL AecXDataMap::ExtractRecord(CString& sRecord, CString& sKey, CString& sType, CString& sInfo)
|
|
{
|
|
//Key|int|Info
|
|
int nFr = sRecord.Find(_T("|"), 0);
|
|
if (nFr != -1)
|
|
{
|
|
CString sTemp;
|
|
sKey = sRecord.Mid(0, nFr);
|
|
if (nFr + 1 < sRecord.GetLength())
|
|
{
|
|
sTemp = sRecord.Mid(nFr + 1);
|
|
sRecord = sTemp;
|
|
|
|
nFr = sRecord.Find(_T("|"), 0);
|
|
if (nFr != -1)
|
|
{
|
|
sType = sRecord.Mid(0, nFr);
|
|
if (nFr + 1 < sRecord.GetLength())
|
|
{
|
|
sInfo = sRecord.Mid(nFr + 1);
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::StringToAcGePoint3d(CString& sText, AcGePoint3d& ptGe)
|
|
{
|
|
//x,y,z
|
|
CString sX, sY, sZ;
|
|
|
|
int nFr = sText.Find(_T(","), 0);
|
|
if (nFr != -1)
|
|
{
|
|
CString sTemp;
|
|
sX = sText.Mid(0, nFr);
|
|
if (nFr + 1 < sText.GetLength())
|
|
{
|
|
sTemp = sText.Mid(nFr + 1);
|
|
sText = sTemp;
|
|
|
|
nFr = sText.Find(_T(","), 0);
|
|
if (nFr != -1)
|
|
{
|
|
sY = sText.Mid(0, nFr);
|
|
if (nFr + 1 < sText.GetLength())
|
|
{
|
|
sZ = sText.Mid(nFr + 1);
|
|
ptGe.set(__ttof(sX), __ttof(sY), __ttof(sZ));
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::StringToAcGeVector3d(CString& sText, AcGeVector3d& vt)
|
|
{
|
|
//x,y,z
|
|
AcGePoint3d ptGe;
|
|
if (StringToAcGePoint3d(sText, ptGe))
|
|
{
|
|
vt = ptGe.asVector();
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, int iIndex, AecXDataMap& xDataMap)
|
|
{
|
|
CString sKey, sType, sInfo, sText, sRecord;
|
|
AcGePoint3d ptGe;
|
|
AcGeVector3d vt;
|
|
BOOL bSuccess = FALSE;
|
|
AcDbObjectId id;
|
|
XData xDat;
|
|
|
|
if (GetAt(pszKey, iIndex, sText))
|
|
{
|
|
sText.TrimLeft();
|
|
sText.TrimRight();
|
|
|
|
if (sText.GetLength() > 1)
|
|
{
|
|
CStringArray arRecords;
|
|
bSuccess = ParseToRecords(sText, arRecords);
|
|
|
|
for (int i = 0; i < arRecords.GetSize(); i++)
|
|
{
|
|
sRecord = arRecords.GetAt(i);
|
|
if (ExtractRecord(sRecord, sKey, sType, sInfo))
|
|
{
|
|
int nVt = _ttoi(sType);
|
|
switch (nVt)
|
|
{
|
|
case VT_I4: // 整型
|
|
{
|
|
xDataMap.SetAt(sKey, _ttoi(sInfo));
|
|
break;
|
|
}
|
|
case VT_UI4:
|
|
{
|
|
#ifdef _WIN64
|
|
id.setFromOldId((INT_PTR)_ttoi64(sInfo));
|
|
#else
|
|
id.setFromOldId((INT_PTR)_ttoi(sInfo));
|
|
#endif
|
|
|
|
xDataMap.SetAt(sKey, id);
|
|
break;
|
|
}
|
|
case VT_UI8:
|
|
{
|
|
#ifdef _WIN64
|
|
id.setFromOldId((INT_PTR)_ttoi64(sInfo));
|
|
#else
|
|
id.setFromOldId((INT_PTR)_ttoi(sInfo));
|
|
#endif
|
|
|
|
xDataMap.SetAt(sKey, id, FALSE);
|
|
break;
|
|
}
|
|
case VT_R8: // 浮点
|
|
{
|
|
xDataMap.SetAt(sKey, __ttof(sInfo));
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8): // 点
|
|
{
|
|
if (StringToAcGePoint3d(sInfo, ptGe))
|
|
{
|
|
xDataMap.SetAt(sKey, ptGe);
|
|
}
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 1): // cad变化点
|
|
{
|
|
if (StringToAcGePoint3d(sInfo, ptGe))
|
|
{
|
|
xDataMap.SetAt(sKey, ptGe, TRUE);
|
|
}
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 2): // 向量
|
|
{
|
|
if (StringToAcGeVector3d(sInfo, vt))
|
|
{
|
|
sKey.Replace(DIF_VT_PT, _T(" "));
|
|
sKey.TrimRight();
|
|
xDataMap.SetAt(sKey, vt);
|
|
}
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 3): // 变化向量
|
|
{
|
|
if (StringToAcGeVector3d(sInfo, vt))
|
|
{
|
|
sKey.Replace(DIF_VT_PT, _T(" "));
|
|
sKey.TrimRight();
|
|
xDataMap.SetAt(sKey, vt, TRUE);
|
|
}
|
|
break;
|
|
}
|
|
case (VT_BYREF | VT_R8 + 4): //矩阵
|
|
{
|
|
memset(&xDat, 0, sizeof(XData));
|
|
xDat.npszLen = sInfo.GetLength() + 1;
|
|
xDat.pszVal = new TCHAR[xDat.npszLen];
|
|
_tcscpy(xDat.pszVal, sInfo);
|
|
xDataMap.SetAt(sKey, xDat);
|
|
delete[] xDat.pszVal;
|
|
break;
|
|
}
|
|
case VT_BSTR: // 字符串
|
|
{
|
|
xDataMap.SetAt(sKey, sInfo);
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//按照常规处理
|
|
xDataMap.SetAt(pszKey, iIndex, sText);
|
|
bSuccess = TRUE;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//按照常规处理
|
|
xDataMap.SetAt(pszKey, iIndex, sText);
|
|
bSuccess = TRUE;
|
|
}
|
|
}
|
|
return bSuccess;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, const AcDbObjectId& id, BOOL bIsSoft)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
XData xdata;
|
|
memset(&xdata, 0, sizeof(xdata));
|
|
xdata.nVt = VT_UI4;
|
|
if (!bIsSoft) xdata.nVt = VT_UI8;
|
|
xdata.nVal = id.asOldId();
|
|
It it = m_xData.find(pszKey);
|
|
if (it != m_xData.end())
|
|
{
|
|
(*it).second = xdata;
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString, XData> pa(pszKey, xdata);
|
|
m_xData.insert(pa);
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::SetAt(LPCTSTR pszKey, const XData& xData)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
It it = m_xData.find(pszKey);
|
|
if (it != m_xData.end()) //找到
|
|
{
|
|
if ((*it).second.nVt == xData.nVt) //判断类型相同
|
|
{
|
|
if ((*it).second.nVt == VT_BSTR ||
|
|
(*it).second.nVt == (VT_BYREF | VT_R8 + 4)) //字符串特殊处理
|
|
{
|
|
// 重新分配空间赋值
|
|
if (xData.npszLen > 0 && xData.pszVal != NULL)
|
|
{
|
|
if ((*it).second.npszLen > 0 && (*it).second.pszVal != NULL) //清空原来的
|
|
delete[](*it).second.pszVal;
|
|
|
|
(*it).second = xData;
|
|
(*it).second.pszVal = new TCHAR[xData.npszLen];
|
|
memset((*it).second.pszVal, 0, xData.npszLen);
|
|
_tcscpy((*it).second.pszVal, xData.pszVal);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
(*it).second = xData;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (xData.nVt == VT_BSTR ||
|
|
xData.nVt == (VT_BYREF | VT_R8 + 4))
|
|
{
|
|
SetAt(pszKey, xData.pszVal);
|
|
}
|
|
else
|
|
{
|
|
std::pair<CString, XData> pa(pszKey, xData);
|
|
m_xData.insert(pa);
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, XData& xData)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(pszKey)) != m_xData.end())
|
|
{
|
|
xData = (*it).second;
|
|
return TRUE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, int& nVal) const
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(pszKey)) != m_xData.end())
|
|
{
|
|
XData xdata = (*it).second;
|
|
|
|
if (xdata.nVt == VT_I4)
|
|
{
|
|
nVal = (int)xdata.nVal;
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, double& dVal) const
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(pszKey)) != m_xData.end())
|
|
{
|
|
XData xdata = (*it).second;
|
|
|
|
if (xdata.nVt == VT_R8)
|
|
{
|
|
dVal = xdata.dVal[0];
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, AcGeDoubleArray& arVal) const
|
|
{
|
|
arVal.setLogicalLength(0);
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sSubKey;
|
|
double dVal;
|
|
|
|
int nIndex = 0;
|
|
sSubKey.Format(_T("%s%d"), pszKey, nIndex++);
|
|
while (GetAt(sSubKey, dVal))
|
|
{
|
|
arVal.append(dVal);
|
|
sSubKey.Format(_T("%s%d"), pszKey, nIndex++);
|
|
}
|
|
}
|
|
|
|
return (arVal.length() > 0);
|
|
}
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, AcGeVector3d& vt) const
|
|
{
|
|
/*
|
|
由于设置向量是将键值pszkey后增加字符串"$vector3d",
|
|
故获取向量时在键值pszkey后增加字符串"$vector3d"
|
|
*/
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sTmpKey = pszKey;
|
|
sTmpKey += DIF_VT_PT;
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(sTmpKey)) != m_xData.end())
|
|
{
|
|
XData xdata = (*it).second;
|
|
|
|
if ((xdata.nVt == (VT_BYREF | VT_R8) + 2)
|
|
|| (xdata.nVt == ((VT_BYREF | VT_R8) + 3)))
|
|
{
|
|
vt.x = xdata.dVal[0];
|
|
vt.y = xdata.dVal[1];
|
|
vt.z = xdata.dVal[2];
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, AcGePoint3d& ptGe) const
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(pszKey)) != m_xData.end())
|
|
{
|
|
XData xdata = (*it).second;
|
|
|
|
if ((xdata.nVt == (VT_BYREF | VT_R8))
|
|
|| (xdata.nVt == (VT_BYREF | VT_R8 + 1)))
|
|
{
|
|
ptGe.x = xdata.dVal[0];
|
|
ptGe.y = xdata.dVal[1];
|
|
ptGe.z = xdata.dVal[2];
|
|
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, AcGePoint3dArray& arPt) const
|
|
{
|
|
arPt.setLogicalLength(0);
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sSubKey;
|
|
AcGePoint3d pt;
|
|
|
|
int nIndex = 0;
|
|
sSubKey.Format(_T("%s%d"), pszKey, nIndex++);
|
|
while (GetAt(sSubKey, pt))
|
|
{
|
|
arPt.append(pt);
|
|
sSubKey.Format(_T("%s%d"), pszKey, nIndex++);
|
|
}
|
|
}
|
|
|
|
return (arPt.length() > 0);
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, CString &sValue) const
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(pszKey)) != m_xData.end())
|
|
{
|
|
XData xdata = (*it).second;
|
|
|
|
if (xdata.nVt == VT_BSTR ||
|
|
xdata.nVt == (VT_BYREF | VT_R8 + 4))
|
|
{
|
|
sValue = xdata.pszVal;
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::GetAt(LPCTSTR pszKey, AcDbObjectId& id) const
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
std::map<CString, XData>::const_iterator it;
|
|
if ((it = m_xData.find(pszKey)) != m_xData.end())
|
|
{
|
|
XData xdata = (*it).second;
|
|
|
|
if (xdata.nVt == VT_UI4 ||
|
|
xdata.nVt == VT_UI8)
|
|
{
|
|
id.setFromOldId(xdata.nVal);
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::HasKey(LPCTSTR pszKey, int& nVt)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sTmpKey = pszKey;
|
|
sTmpKey += DIF_VT_PT;
|
|
|
|
if (m_xData.find(pszKey) != m_xData.end())
|
|
{
|
|
XData xdata = m_xData[pszKey];
|
|
nVt = xdata.nVt;
|
|
return TRUE;
|
|
}
|
|
else if (m_xData.find(sTmpKey) != m_xData.end())
|
|
{
|
|
XData xdata = m_xData[sTmpKey];
|
|
nVt = xdata.nVt;
|
|
return TRUE;
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
void AecXDataMap::Empty()
|
|
{
|
|
m_xData.clear();
|
|
}
|
|
|
|
BOOL AecXDataMap::RemoveAt(LPCTSTR pszKey)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sTmpKey = pszKey;
|
|
sTmpKey += DIF_VT_PT;
|
|
It it = m_xData.find(pszKey);
|
|
It it1 = m_xData.find(sTmpKey);
|
|
if (it != m_xData.end())
|
|
{
|
|
if ((*it).second.nVt == VT_BSTR ||
|
|
(*it).second.nVt == (VT_BYREF | VT_R8 + 4))
|
|
{
|
|
if ((*it).second.npszLen > 0 && (*it).second.pszVal != NULL)
|
|
{
|
|
delete[](*it).second.pszVal;
|
|
}
|
|
(*it).second.pszVal = NULL;
|
|
}
|
|
m_xData.erase(it);
|
|
//m_xData.clear();
|
|
return TRUE;
|
|
}
|
|
else if (it1 != m_xData.end())
|
|
{
|
|
if ((*it1).second.nVt == VT_BSTR ||
|
|
(*it1).second.nVt == (VT_BYREF | VT_R8 + 4))
|
|
{
|
|
if ((*it1).second.pszVal != NULL)
|
|
{
|
|
delete[](*it1).second.pszVal;
|
|
}
|
|
(*it1).second.pszVal = NULL;
|
|
}
|
|
m_xData.erase(it1);
|
|
//m_xData.clear();
|
|
return TRUE;
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
BOOL AecXDataMap::RemoveAt(LPCTSTR pszKey, int nIndex)
|
|
{
|
|
if (pszKey != NULL)
|
|
{
|
|
CString sKey;
|
|
sKey.Format(_T("%s_%d"), pszKey, nIndex);
|
|
return RemoveAt(sKey);
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
std::map<CString, XData>::iterator AecXDataMap::Begin()
|
|
{
|
|
return m_xData.begin();
|
|
}
|
|
|
|
BOOL AecXDataMap::GetNext(It& it, XData& xData)
|
|
{
|
|
if (it != m_xData.end())
|
|
{
|
|
xData = (*it).second;
|
|
++it;
|
|
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
std::map<CString, XData>::iterator AecXDataMap::End()
|
|
{
|
|
return m_xData.end();
|
|
}
|
|
|
|
BOOL AecXDataMap::Write(CFile* pFileOut, BOOL bWriteUserData)
|
|
{
|
|
CString sTemp = MAP_BLOCK_BEGIN;
|
|
_bstr_t bst((LPCTSTR)sTemp);
|
|
std::string str;
|
|
str.append((const char*)bst);
|
|
std::string str2 = Base64::Encode(str);
|
|
pFileOut->Write(str2.c_str(), strlen(str2.c_str()));
|
|
|
|
XData xdata;
|
|
int nVt = -1;
|
|
AcGePoint3d ptVal;
|
|
AcGeVector3d vt;
|
|
AcDbSoftPointerId id;
|
|
int nSize = 0;
|
|
CString sText, sVal;
|
|
|
|
if (bWriteUserData)
|
|
{
|
|
CMapStringToString mapStr2Str;
|
|
for (int i = 0; i < 1000; i++) //1000条用户数据
|
|
{
|
|
sText.Format(_T("user%d"), i);
|
|
if (GetAt(sText, sVal))
|
|
{
|
|
mapStr2Str.SetAt(sText, sVal);
|
|
}
|
|
}
|
|
|
|
nSize = mapStr2Str.GetCount();
|
|
pFileOut->Write(&nSize, sizeof(int));
|
|
|
|
for (POSITION ps = mapStr2Str.GetStartPosition(); ps != NULL;)
|
|
{
|
|
mapStr2Str.GetNextAssoc(ps, sText, sVal);
|
|
|
|
bst = (LPCTSTR)sText;
|
|
|
|
//key
|
|
nSize = strlen((const char*)bst);
|
|
pFileOut->Write(&nSize, sizeof(int));
|
|
pFileOut->Write((const char*)bst, nSize);
|
|
|
|
//vt
|
|
nVt = VT_BSTR;
|
|
pFileOut->Write(&nVt, sizeof(int));
|
|
|
|
//val
|
|
bst = (LPCTSTR)sVal;
|
|
nSize = strlen((const char*)bst);
|
|
pFileOut->Write(&nSize, sizeof(int));
|
|
pFileOut->Write((const char*)bst, nSize);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//多少个
|
|
nSize = m_xData.size();
|
|
pFileOut->Write(&nSize, sizeof(int));
|
|
|
|
typedef std::map<CString, XData>::const_iterator It;
|
|
for (It it = m_xData.begin(); it != m_xData.end(); ++it)
|
|
{
|
|
xdata = (*it).second;
|
|
nVt = xdata.nVt;
|
|
|
|
sText = (*it).first;
|
|
bst = (LPCTSTR)sText;
|
|
|
|
//key
|
|
nSize = strlen((const char*)bst);
|
|
pFileOut->Write(&nSize, sizeof(int));
|
|
pFileOut->Write((const char*)bst, nSize);
|
|
|
|
//vt
|
|
pFileOut->Write(&nVt, sizeof(int));
|
|
|
|
switch (nVt)
|
|
{
|
|
case VT_I4: // 整型
|
|
pFileOut->Write(&xdata.nVal, sizeof(int));
|
|
break;
|
|
case VT_UI4:
|
|
pFileOut->Write(&xdata.nVal, sizeof(int));
|
|
break;
|
|
case VT_UI8:
|
|
pFileOut->Write(&xdata.nVal, sizeof(int));
|
|
break;
|
|
case VT_R8: // 浮点
|
|
pFileOut->Write(&xdata.dVal[0], sizeof(double));
|
|
break;
|
|
case (VT_BYREF | VT_R8): // 点
|
|
case (VT_BYREF | VT_R8 + 1):
|
|
pFileOut->Write(xdata.dVal, sizeof(double) * 3);
|
|
break;
|
|
case (VT_BYREF | VT_R8 + 2): // 向量
|
|
case (VT_BYREF | VT_R8 + 3):
|
|
pFileOut->Write(xdata.dVal, sizeof(double) * 3);
|
|
break;
|
|
case (VT_BYREF | VT_R8 + 4): //矩阵
|
|
{
|
|
nSize = (int)xdata.npszLen;
|
|
pFileOut->Write(&nSize, sizeof(int));
|
|
pFileOut->Write(xdata.pszVal, nSize);
|
|
}
|
|
break;
|
|
case VT_BSTR: // 字符串
|
|
{
|
|
bst = xdata.pszVal;
|
|
nSize = strlen((const char*)bst);
|
|
pFileOut->Write(&nSize, sizeof(int));
|
|
pFileOut->Write((const char*)bst, nSize);
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
sTemp = MAP_BLOCK_END;
|
|
bst = (LPCTSTR)sTemp;
|
|
str = std::string();
|
|
str.append((const char*)bst);
|
|
str2 = Base64::Encode(str);
|
|
pFileOut->Write(str2.c_str(), strlen(str2.c_str()));
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL AecXDataMap::Read(CFile* pFileOut, BOOL bWriteUserData)
|
|
{
|
|
CString sTemp = MAP_BLOCK_BEGIN;
|
|
_bstr_t bst((LPCTSTR)sTemp);
|
|
std::string str;
|
|
str.append((const char*)bst);
|
|
std::string str2 = Base64::Encode(str);
|
|
|
|
char* pszBuf = new char[str2.length() + 1];
|
|
memset(pszBuf, 0, str2.length() + 1);
|
|
pFileOut->Read(pszBuf, str2.length());
|
|
|
|
int nCount = 0;
|
|
pFileOut->Read(&nCount, sizeof(int));
|
|
|
|
int nLen = 0;
|
|
for (int i = 0; i < nCount; i++)
|
|
{
|
|
pFileOut->Read(&nLen, sizeof(int));
|
|
if (nLen > 0)
|
|
{
|
|
char* pszKey = new char[nLen + 1];
|
|
memset(pszKey, 0, nLen + 1);
|
|
pFileOut->Read(pszKey, nLen);
|
|
|
|
//VT
|
|
int nVt = VT_BSTR;
|
|
pFileOut->Read(&nVt, sizeof(int));
|
|
|
|
nLen = 0;
|
|
pFileOut->Read(&nLen, sizeof(int));
|
|
|
|
//KEY:VAL
|
|
char* pszVal = new char[nLen + 1];
|
|
memset(pszVal, 0, nLen + 1);
|
|
pFileOut->Read(pszVal, nLen);
|
|
|
|
CString sText = pszVal;
|
|
CString sKey = pszKey;
|
|
SetAt(sKey, sText);
|
|
|
|
delete[] pszKey;
|
|
delete[] pszVal;
|
|
}
|
|
}
|
|
delete[] pszBuf;
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL AecXDataMap::FormatDataMap(CStringArray& arItemLines)
|
|
{
|
|
BOOL bFind = FALSE;
|
|
CString sDNAType, sLine, sKey, sValue;
|
|
long nVt = 0, i = 0;
|
|
AcGePoint3d ptGe;
|
|
CStringArray arTexts;
|
|
AcGeMatrix3d xform;
|
|
|
|
while (i <= (arItemLines.GetSize() - 3))
|
|
{
|
|
sLine = arItemLines.GetAt(i);
|
|
|
|
if (sLine.CompareNoCase(MAP_BLOCK_BEGIN) == 0)
|
|
{
|
|
bFind = TRUE;
|
|
i += 1;
|
|
continue;
|
|
}
|
|
|
|
if (sLine.CompareNoCase(MAP_BLOCK_END) == 0)
|
|
{
|
|
break;
|
|
}
|
|
|
|
if (bFind)
|
|
{
|
|
//KEY
|
|
sKey = sLine;
|
|
|
|
//VT
|
|
nVt = _ttoi(arItemLines.GetAt(i + 1));
|
|
|
|
//VALUE
|
|
sValue = arItemLines.GetAt(i + 2);
|
|
|
|
AcDbSoftPointerId id;
|
|
AcDbHardPointerId idh;
|
|
|
|
switch (nVt)
|
|
{
|
|
case VT_I4: // 整型
|
|
SetAt(sKey, _ttoi(sValue));
|
|
break;
|
|
case VT_UI4:
|
|
#ifdef _WIN64
|
|
id.setFromOldId((Adesk::IntDbId)_ttoi64(sValue));
|
|
#else
|
|
id.setFromOldId(_ttoi(sValue));
|
|
#endif
|
|
SetAt(sKey, id);
|
|
break;
|
|
case VT_UI8:
|
|
#ifdef _WIN64
|
|
id.setFromOldId((Adesk::IntDbId)_ttoi64(sValue));
|
|
#else
|
|
id.setFromOldId(_ttoi(sValue));
|
|
#endif
|
|
SetAt(sKey, idh, FALSE);
|
|
break;
|
|
case VT_R8: // 浮点
|
|
SetAt(sKey, __ttof(sValue));
|
|
break;
|
|
case (VT_BYREF | VT_R8): // 点
|
|
StringToAcGePoint3d(sValue, ptGe);
|
|
SetAt(sKey, ptGe);
|
|
break;
|
|
case (VT_BYREF | VT_R8 + 1): // cad变化点
|
|
StringToAcGePoint3d(sValue, ptGe);
|
|
SetAt(sKey, ptGe, TRUE);
|
|
break;
|
|
case (VT_BYREF | VT_R8 + 2): // 向量
|
|
StringToAcGePoint3d(sValue, ptGe);
|
|
sKey.Replace(DIF_VT_PT, _T(" "));
|
|
sKey.TrimRight();
|
|
SetAt(sKey, ptGe.asVector());
|
|
break;
|
|
case (VT_BYREF | VT_R8 + 3): // cad变化向量
|
|
StringToAcGePoint3d(sValue, ptGe);
|
|
sKey.Replace(DIF_VT_PT, _T(" "));
|
|
sKey.TrimRight();
|
|
SetAt(sKey, ptGe.asVector(), TRUE);
|
|
break;
|
|
case (VT_BYREF | VT_R8 + 4): //矩阵
|
|
arTexts.RemoveAll();
|
|
Script2StringArray(sValue, _T(','), arTexts);
|
|
if (arTexts.GetSize() == 16)
|
|
{
|
|
for (int i = 0; i < 4; i++)
|
|
{
|
|
for (int j = 0; j < 4; j++)
|
|
{
|
|
xform.entry[i][j] = __ttof(arTexts.GetAt(i * 4 + j));
|
|
}
|
|
}
|
|
}
|
|
SetAt(sKey, xform);
|
|
break;
|
|
case VT_BSTR: // 字符串
|
|
SetAt(sKey, sValue);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
i += 3;
|
|
}
|
|
else
|
|
{
|
|
i += 1;
|
|
}
|
|
}
|
|
return m_xData.empty() ? FALSE : TRUE;
|
|
} |