221 lines
4.8 KiB
C++
221 lines
4.8 KiB
C++
#include "StdAfx.h"
|
|||
|
|
#include "dbproxy.h"
|
||
|
|
#include "geassign.h"
|
||
|
|
#include "acgi.h"
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
#define VERSION_CTCH3DSOLID 2
|
||
|
|
|
||
|
|
|
||
|
|
//{{AFX_ARX_MACRO
|
||
|
|
ACRX_DXF_DEFINE_MEMBERS(ATSTch3DSolid, AcDbObject,
|
||
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
||
|
|
AcDbProxyObject::kNoOperation,
|
||
|
|
ATS_3DSOLID, "ATS_3DSOLID图形无法解析, 请下载上华软件|网址: www.shanghuasoft.com"
|
||
|
|
);
|
||
|
|
//}}AFX_ARX_MACRO
|
||
|
|
|
||
|
|
|
||
|
|
// Constructor / Destructor
|
||
|
|
ATSTch3DSolid::ATSTch3DSolid()
|
||
|
|
{
|
||
|
|
m_pBakData = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
ATSTch3DSolid::~ATSTch3DSolid()
|
||
|
|
{
|
||
|
|
if (m_pBakData != NULL)
|
||
|
|
{
|
||
|
|
delete m_pBakData;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
void ATSTch3DSolid::GetData(CSolidData& data)
|
||
|
|
{
|
||
|
|
assertReadEnabled();
|
||
|
|
|
||
|
|
data = m_Data;
|
||
|
|
}
|
||
|
|
|
||
|
|
void ATSTch3DSolid::SetData(const CSolidData& data)
|
||
|
|
{
|
||
|
|
assertWriteEnabled();
|
||
|
|
|
||
|
|
m_Data = data;
|
||
|
|
}
|
||
|
|
|
||
|
|
void ATSTch3DSolid::modified(const AcDbObject* pDbObj)
|
||
|
|
{
|
||
|
|
AcDbEntity* pEnt = AcDbEntity::cast(pDbObj);
|
||
|
|
if (pEnt != NULL)
|
||
|
|
{
|
||
|
|
UINT nColor = pEnt->colorIndex();
|
||
|
|
if ((nColor == 0 || nColor == 256) &&
|
||
|
|
(m_Data.GetType() != CSolidData::eBoolean) &&
|
||
|
|
(m_Data.GetType() != CSolidData::eSlice))
|
||
|
|
{
|
||
|
|
nColor = GetLayerColor(pEnt->layerId());
|
||
|
|
/*
|
||
|
|
CAcDbObjectPtr<AcDbLayerTableRecord> pLayer;
|
||
|
|
if (pLayer.OpenObject(pEnt->layerId(), AcDb::kForRead) == Acad::eOk)
|
||
|
|
{
|
||
|
|
nColor = pLayer->color().colorIndex();
|
||
|
|
}
|
||
|
|
*/
|
||
|
|
}
|
||
|
|
m_Data.SetColorIndex(nColor);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
Acad::ErrorStatus ATSTch3DSolid::dwgInFields(AcDbDwgFiler* pFiler)
|
||
|
|
{
|
||
|
|
assertWriteEnabled();
|
||
|
|
Acad::ErrorStatus es;
|
||
|
|
|
||
|
|
// Read version number.
|
||
|
|
Adesk::UInt16 version;
|
||
|
|
pFiler->readItem(&version);
|
||
|
|
if (version > VERSION_CTCH3DSOLID)
|
||
|
|
return Acad::eMakeMeProxy;
|
||
|
|
|
||
|
|
// Call dwgInFields from AcDbObject
|
||
|
|
if ((es = AcDbObject::dwgInFields(pFiler)) != Acad::eOk)
|
||
|
|
{
|
||
|
|
return es;
|
||
|
|
}
|
||
|
|
|
||
|
|
// Read the data members.
|
||
|
|
switch (version)
|
||
|
|
{
|
||
|
|
case (1):
|
||
|
|
m_Data.dwgInFields(pFiler);
|
||
|
|
if (m_Data.GetType() == CSolidData::eExtrude)
|
||
|
|
{
|
||
|
|
CExtrudeData* pData = (CExtrudeData*)m_Data.GetData();
|
||
|
|
if (pData->m_eBaseType == CExtrudeData::ePath)
|
||
|
|
{
|
||
|
|
AcDbExtents extents;
|
||
|
|
pData->m_pProfile->getGeomExtents(extents);
|
||
|
|
if (extents.minPoint().x <= extents.maxPoint().x)
|
||
|
|
{
|
||
|
|
AcGePoint3d ptCenter;
|
||
|
|
ptCenter.set((extents.minPoint().x + extents.maxPoint().x) / 2.0,
|
||
|
|
(extents.minPoint().y + extents.maxPoint().y) / 2.0,
|
||
|
|
(extents.minPoint().z + extents.maxPoint().z) / 2.0);
|
||
|
|
AcGePoint3d ptStart, ptEnd;
|
||
|
|
pData->m_pPath->getStartPoint(ptStart);
|
||
|
|
pData->m_pPath->getEndPoint(ptEnd);
|
||
|
|
AcGeVector3d vecOffset;
|
||
|
|
if (ptCenter.distanceTo(ptStart) > ptCenter.distanceTo(ptEnd))
|
||
|
|
vecOffset = ptCenter - ptEnd;
|
||
|
|
else
|
||
|
|
vecOffset = ptCenter - ptStart;
|
||
|
|
AcGeMatrix3d mat;
|
||
|
|
mat.setTranslation(vecOffset);
|
||
|
|
pData->m_pPath->transformBy(mat);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
break;
|
||
|
|
case (2):
|
||
|
|
m_Data.dwgInFields(pFiler);
|
||
|
|
break;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (m_pBakData && _tcscmp(pFiler->isA()->name(), _T("AcDbDwgCopyFiler")) == 0)
|
||
|
|
{
|
||
|
|
m_Data.Copy(m_pBakData);
|
||
|
|
delete m_pBakData;
|
||
|
|
m_pBakData = NULL;
|
||
|
|
}
|
||
|
|
|
||
|
|
return pFiler->filerStatus();
|
||
|
|
}
|
||
|
|
|
||
|
|
Acad::ErrorStatus ATSTch3DSolid::dwgOutFields(AcDbDwgFiler* pFiler) const
|
||
|
|
{
|
||
|
|
assertReadEnabled();
|
||
|
|
Acad::ErrorStatus es;
|
||
|
|
|
||
|
|
// Write version number.
|
||
|
|
pFiler->writeItem((Adesk::UInt16) VERSION_CTCH3DSOLID);
|
||
|
|
|
||
|
|
// Call dwgOutFields from AcDbObject
|
||
|
|
if ((es = AcDbObject::dwgOutFields(pFiler)) != Acad::eOk) {
|
||
|
|
return es;
|
||
|
|
}
|
||
|
|
|
||
|
|
m_Data.dwgOutFields(pFiler);
|
||
|
|
#if ADS<17
|
||
|
|
if (_tcscmp(pFiler->isA()->name(), _T("AcDbDwgCopyFiler")) == 0)
|
||
|
|
{
|
||
|
|
if (m_pBakData == NULL)
|
||
|
|
{
|
||
|
|
CSolidData*& pTemp = (CSolidData*&)m_pBakData;
|
||
|
|
pTemp = new CSolidData;
|
||
|
|
}
|
||
|
|
m_pBakData->Copy(&m_Data);
|
||
|
|
}
|
||
|
|
#endif
|
||
|
|
|
||
|
|
return pFiler->filerStatus();
|
||
|
|
}
|
||
|
|
|
||
|
|
Acad::ErrorStatus ATSTch3DSolid::dxfInFields(AcDbDxfFiler* pFiler)
|
||
|
|
{
|
||
|
|
assertWriteEnabled();
|
||
|
|
struct resbuf rb;
|
||
|
|
|
||
|
|
// Read version number.
|
||
|
|
pFiler->readItem(&rb);
|
||
|
|
if (rb.restype != AcDb::kDxfInt16) {
|
||
|
|
pFiler->pushBackItem();
|
||
|
|
pFiler->setError(Acad::eInvalidDxfCode,
|
||
|
|
_T("nError: expected object version group code %d"),
|
||
|
|
AcDb::kDxfInt16);
|
||
|
|
return pFiler->filerStatus();
|
||
|
|
} else {
|
||
|
|
Adesk::UInt16 version = rb.resval.rint;
|
||
|
|
if (version > VERSION_CTCH3DSOLID)
|
||
|
|
return Acad::eMakeMeProxy;
|
||
|
|
}
|
||
|
|
|
||
|
|
if ((AcDbObject::dxfInFields(pFiler) != Acad::eOk) ||
|
||
|
|
!pFiler->atSubclassData(_T("Tch3DSolid")))
|
||
|
|
return pFiler->filerStatus();
|
||
|
|
|
||
|
|
m_Data.dxfInFields(pFiler);
|
||
|
|
|
||
|
|
return pFiler->filerStatus();
|
||
|
|
}
|
||
|
|
|
||
|
|
Acad::ErrorStatus ATSTch3DSolid::dxfOutFields(AcDbDxfFiler* pFiler) const
|
||
|
|
{
|
||
|
|
assertReadEnabled();
|
||
|
|
|
||
|
|
// Write version number.
|
||
|
|
pFiler->writeItem(AcDb::kDxfInt16, (Adesk::UInt16) VERSION_CTCH3DSOLID);
|
||
|
|
|
||
|
|
Acad::ErrorStatus es;
|
||
|
|
|
||
|
|
if ((es = AcDbObject::dxfOutFields(pFiler)) != Acad::eOk)
|
||
|
|
return es;
|
||
|
|
|
||
|
|
pFiler->writeItem(AcDb::kDxfSubclass, _T("Tch3DSolid"));
|
||
|
|
|
||
|
|
m_Data.dxfOutFields(pFiler);
|
||
|
|
|
||
|
|
return es;
|
||
|
|
}
|
||
|
|
|
||
|
|
void Init3DSolid(BOOL bTrue)
|
||
|
|
{
|
||
|
|
if (bTrue)
|
||
|
|
{
|
||
|
|
ATSTch3DSolid::rxInit();
|
||
|
|
acrxBuildClassHierarchy();
|
||
|
|
}
|
||
|
|
else
|
||
|
|
deleteAcRxClass(ATSTch3DSolid::desc());
|
||
|
|
}
|