5434 lines
114 KiB
C++
5434 lines
114 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbEarthWormFitting.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "AecDbX3dGroup.h"
|
|
#include "MFCDbDwgFiler.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "AecDbEwPipe.h"
|
|
#include "AecDbEwCable.h"
|
|
#include "AecDbEwFitting.h"
|
|
#include "AecDbEwEquipment.h"
|
|
#include "AecMInterfaces.h"
|
|
#include "KTCadUtility.h"
|
|
#include "AecUnknownViewportDraw.h"
|
|
#include "AecGripCback.h"
|
|
#include "AecDbShEarthWorm.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "CoreTools.h"
|
|
#include "AecCoverBooleanOper.h"
|
|
#include "AcGiViewDraw.h"
|
|
|
|
#define KEY_HIDEEW _T("HideEw")
|
|
|
|
extern double PixelToWcs(int nPixel);
|
|
extern BOOL Is2DView();
|
|
extern CString IDCreate();
|
|
extern AcGeVector3d GetUcsZvt();
|
|
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt, AcDbDatabase* pDb = NULL, bool bClose = true);
|
|
void DLLIMPEXP OrthoProjected3DSolid(AcDb3dSolid* pSolidClone,const AcGePlane& plan,AcGeMatrix3d& xformPlanToWorld,AcDbVoidPtrArray& arEntPtrs);
|
|
void DLLIMPEXP OrthoProjected3DSolid2(AcDb3dSolid* pSolidClone,const AcGePlane& plan,const AcGePlane& planCut,AcGeMatrix3d& xformPlanToWorld,AcDbVoidPtrArray& arEntPtrs);
|
|
|
|
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1,const AcGePoint3d& pt2);
|
|
|
|
static AcGePoint3d Mid(const AcGePoint3d& ptGe1, const AcGePoint3d& ptGe2)
|
|
{
|
|
return AcGePoint3d((ptGe1.x + ptGe2.x) / 2.0,
|
|
(ptGe1.y + ptGe2.y) / 2.0,
|
|
(ptGe1.z + ptGe2.z) / 2.0);
|
|
}
|
|
|
|
namespace
|
|
{
|
|
bool isBuildingJs(LPCTSTR psz)
|
|
{
|
|
if (!psz) return false;
|
|
|
|
CString rType(psz);
|
|
rType.MakeLower();
|
|
|
|
if (
|
|
rType.Find(_T("walls")) != -1
|
|
|| rType.Find(_T("floors")) != -1
|
|
|| rType.Find(_T("columns")) != -1
|
|
|| rType.Find(_T("framing")) != -1
|
|
)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
AcDbObjectId makeTableRecord(AcDbVoidPtrArray &ar
|
|
, LPCTSTR pszName
|
|
, AcDbDatabase *pDb = NULL)
|
|
{
|
|
AcDbObjectId bkID(AcDbObjectId::kNull);
|
|
|
|
if (!pDb) pDb = acdbHostApplicationServices()->workingDatabase();
|
|
|
|
if (!pDb) return bkID;
|
|
|
|
AcDbBlockTable *pTbl(NULL);
|
|
Acad::ErrorStatus es = pDb->getBlockTable(pTbl, AcDb::kForWrite);
|
|
if (es != Acad::eOk) return bkID;
|
|
|
|
AcDbBlockTableRecord *pRc = new AcDbBlockTableRecord;
|
|
|
|
pRc->setName(pszName ? pszName : _T("*U"));
|
|
|
|
for (int i = 0; i < ar.length(); ++i)
|
|
{
|
|
AcDbEntity *p((AcDbEntity*)ar[i]);
|
|
pRc->appendAcDbEntity(p);
|
|
}
|
|
|
|
if (pTbl->add(pRc) != Acad::eOk)
|
|
{
|
|
DELETE_PTR(pRc);
|
|
pTbl->close();
|
|
return bkID;
|
|
}
|
|
|
|
pRc->setOrigin(AcGePoint3d::kOrigin);
|
|
|
|
bkID = pRc->objectId();
|
|
|
|
pRc->close();
|
|
|
|
pTbl->close();
|
|
|
|
return bkID;
|
|
}
|
|
|
|
AcDbObjectId makeTableRecord(const AcArray<AcGeLineSeg3d>& ar
|
|
, LPCTSTR pszName
|
|
, AcDbDatabase *pDb = NULL)
|
|
{
|
|
AcDbVoidPtrArray arr;
|
|
for (int i = 0; i < ar.length(); ++i)
|
|
arr.append(new AcDbLine(ar[i].startPoint(), ar[i].endPoint()));
|
|
|
|
return makeTableRecord(arr, pszName, pDb);
|
|
}
|
|
|
|
AcDbBlockReference* makeBlockReference(const AcArray<AcGeLineSeg3d> &ar
|
|
, LPCTSTR pszName
|
|
, const AcGePoint3d &ptPos
|
|
, AcDbDatabase *pDb = NULL)
|
|
{
|
|
AcDbObjectId id = makeTableRecord(ar, pszName, pDb);
|
|
if (!id.isValid()) return NULL;
|
|
|
|
AcDbBlockReference *pRef = new AcDbBlockReference(ptPos, id);
|
|
|
|
return pRef;
|
|
}
|
|
|
|
AcDbObjectId findTableRecord(LPCTSTR pszName, AcDbDatabase *pDb = NULL)
|
|
{
|
|
AcDbObjectId bkID(AcDbObjectId::kNull);
|
|
|
|
if (!pszName) return bkID;
|
|
|
|
if (!pDb) pDb = acdbHostApplicationServices()->workingDatabase();
|
|
if (!pDb) return bkID;
|
|
|
|
AcDbBlockTable* pTable(NULL);
|
|
pDb->getBlockTable(pTable, AcDb::kForRead);
|
|
if (!pTable) return bkID;
|
|
|
|
pTable->getAt(pszName, bkID);
|
|
|
|
pTable->close();
|
|
|
|
return bkID;
|
|
}
|
|
}
|
|
|
|
Adesk::UInt32 AecDbEarthWormFitting::kCurrentVersionNumber = 2;
|
|
static const Adesk::UInt16 kColorByBlock = 0;
|
|
static const Adesk::UInt16 kRed = 1;
|
|
static const Adesk::UInt16 kYellow = 2;
|
|
static const Adesk::UInt16 kGreen = 3;
|
|
static const Adesk::UInt16 kCyan = 4;
|
|
static const Adesk::UInt16 kBlue = 5;
|
|
static const Adesk::UInt16 kMagenta = 6;
|
|
static const Adesk::UInt16 kWhite = 7;
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
static const Adesk::UInt16 kXDataColor = 137;
|
|
|
|
#ifndef GRIPPT_RESP_FROM_EWFIT
|
|
#define GRIPPT_RESP_FROM_EWFIT 1394
|
|
#endif
|
|
|
|
ACRX_DXF_DEFINE_MEMBERS (AecDbEarthWormFitting, AecDbEntityBase,
|
|
AcDb::kDHL_CURRENT, AcDb::kMReleaseCurrent,
|
|
AcDbProxyEntity::kNoOperation | AcDbProxyEntity::kDisableProxyWarning,
|
|
AEC_EWFIT,
|
|
"AecDbEarthWormFitting"
|
|
"|Product Desc: shanghua earthworm app obj"
|
|
"|Company: shanghua inc"
|
|
"|WEB Address: www.shanghuasoft.com")
|
|
|
|
|
|
AecDbEarthWormFitting::AecDbEarthWormFitting(void)
|
|
{
|
|
m_dLen = 10.0;
|
|
m_pDbEWSolid = NULL;
|
|
m_pDraw3dSolid = NULL;
|
|
m_nActiveGroup = -1;
|
|
m_ptFr.set(0,0,0);
|
|
m_vtDir.set(1,0,0);
|
|
m_pDraw3dPipeLine = NULL;
|
|
m_pGripAppData = new AecGripData[2048];//
|
|
}
|
|
|
|
AecDbEarthWormFitting::~AecDbEarthWormFitting(void)
|
|
{
|
|
#if ARX > 17
|
|
//for (size_t i = 0; i < m_arSubDMeshs.length(); ++i)
|
|
//{
|
|
// AcDbEntity *pEnt((AcDbEntity *)m_arSubDMeshs[i]);
|
|
// pEnt->erase();
|
|
// pEnt->close();
|
|
// DELETE_PTR(pEnt);
|
|
//}
|
|
// 此处注意,已经不需要删除 m_arSubDMeshes 缓存,因为在 m_arAddX3dGroupPtrs 析构的时候已经做了
|
|
#endif
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pGroup != NULL)
|
|
{
|
|
DELETE_PTR(pGroup);
|
|
}
|
|
}
|
|
|
|
if ( m_pDbEWSolid != NULL)
|
|
{
|
|
m_pDbEWSolid->erase();
|
|
m_pDbEWSolid->close();
|
|
DELETE_PTR(m_pDbEWSolid);
|
|
}
|
|
|
|
if ( m_pDraw3dSolid != NULL)
|
|
{
|
|
m_pDraw3dSolid->erase();
|
|
m_pDraw3dSolid->close();
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
m_pDraw3dPipeLine->erase();
|
|
m_pDraw3dPipeLine->close();
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
delete[] m_pGripAppData;
|
|
m_pGripAppData = NULL;
|
|
}
|
|
|
|
static void FreeBuffer(int n, AcDbVoidPtrArray& arEntPtrs)
|
|
{
|
|
AcDbEntity* pEnt = NULL;
|
|
while (arEntPtrs.length() > n)
|
|
{
|
|
pEnt = (AcDbEntity*)arEntPtrs.last();
|
|
if (pEnt != NULL)
|
|
{
|
|
pEnt->erase();
|
|
pEnt->close();
|
|
arEntPtrs.removeLast();
|
|
DELETE_PTR(pEnt);
|
|
}
|
|
}
|
|
}
|
|
|
|
AecDbObjXDataMap* AecDbEarthWormFitting::GetSpecialtyData(AcDb::OpenMode eOpen)
|
|
{
|
|
if (eOpen == AcDb::kForWrite)
|
|
{
|
|
if (!isWriteEnabled())
|
|
{
|
|
upgradeOpen();
|
|
}
|
|
assertWriteEnabled();
|
|
}
|
|
else
|
|
{
|
|
assertReadEnabled();
|
|
}
|
|
return &m_mapXData;
|
|
}
|
|
|
|
const AecDbObjXDataMap* AecDbEarthWormFitting::GetSpecialtyData() const
|
|
{
|
|
assertReadEnabled();
|
|
return &m_mapXData;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::SetMainEarthDir(const AcGeVector3d& vtMain)
|
|
{
|
|
|
|
}
|
|
|
|
AcGeVector3d AecDbEarthWormFitting::GetMainEarthDi() const
|
|
{
|
|
assertReadEnabled();
|
|
return AcGeVector3d::kXAxis;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::SetEarthWormSeg(const AcGePoint3d& ptFr,const AcGeVector3d& vtDir)
|
|
{
|
|
assertWriteEnabled();
|
|
m_ptFr = ptFr;
|
|
m_vtDir = vtDir;
|
|
m_vtDir.normalize();
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDbEWSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDbEWSolid);
|
|
}
|
|
|
|
CreateFromSectionScr(m_sCrossSectionScr,m_dLen);
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
}
|
|
|
|
void AecDbEarthWormFitting::GetEarthWromSeg(AcGePoint3d& ptFr,AcGeVector3d& vtDir) const
|
|
{
|
|
assertReadEnabled();
|
|
ptFr = m_ptFr;
|
|
vtDir = m_vtDir;
|
|
vtDir *= m_dLen;
|
|
}
|
|
|
|
// 提取线缆位置分段[支架处]
|
|
bool AecDbEarthWormFitting::GetCableLineSegsForHolder(int nRoomIndex
|
|
, AcArray<LineSeg>& arLnSegs
|
|
, int idx // 编号
|
|
, int nFloor // 第几层
|
|
, int nCount // 此层画几条线缆
|
|
, double dDD // 每条线缆外径
|
|
, int nClr // 线缆颜色
|
|
, LPCTSTR ltypeString // 线缆线型
|
|
, double dSpace // 线缆间距
|
|
, bool bAllRoom/* = false*/
|
|
, bool bByWholeLine/* = false*/) const
|
|
{
|
|
if (m_sCrossSectionScr.Find(_T("RECT:")) != -1)
|
|
{
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(m_sCrossSectionScr);
|
|
dbEW.SetStartPoint(AcGePoint2d(0, 0));
|
|
dbEW.SetEndPoint(AcGePoint2d(m_dLen, 0));
|
|
dbEW.SetStartElevation(0.0);
|
|
dbEW.AddSegment(0, 0.0, m_dLen, _T("001"));
|
|
|
|
return dbEW.GetCableLineSegsForHolder(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
}
|
|
else
|
|
{
|
|
STSection* pSection = GetShEwSection();
|
|
if (pSection != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcDbLine ln(m_ptFr,ptEnd);
|
|
|
|
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
|
|
pRoadLn->AppendCurveSeg(&ln);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
dbEW.SetSection(pSection->pReg, pSection->pt);
|
|
dbEW.SetBaseCurve(pRoadLn);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT1,AS_MUNIT(pSection->dThick[0]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT2,AS_MUNIT(pSection->dThick[1]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT4,AS_MUNIT(pSection->dThick[2]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT5,AS_MUNIT(pSection->dThick[3]));
|
|
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
delete pRoadLn;
|
|
|
|
return dbEW.GetCableLineSegsForHolder(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
|
|
bool AecDbEarthWormFitting::GetCableLineSegsForHanger(int nRoomIndex
|
|
, AcArray<LineSeg>& arLnSegs
|
|
, int idx // 编号
|
|
, int nFloor // 第几层
|
|
, int nCount // 此层画几条线缆
|
|
, double dDD // 每条线缆外径
|
|
, int nClr // 线缆颜色
|
|
, LPCTSTR ltypeString // 线缆线型
|
|
, double dSpace // 线缆间距
|
|
, bool bAllRoom/* = false*/
|
|
, bool bByWholeLine/* = false*/) const
|
|
{
|
|
if (m_sCrossSectionScr.Find(_T("RECT:")) != -1)
|
|
{
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(m_sCrossSectionScr);
|
|
dbEW.SetStartPoint(AcGePoint2d(0, 0));
|
|
dbEW.SetEndPoint(AcGePoint2d(m_dLen, 0));
|
|
dbEW.SetStartElevation(0.0);
|
|
dbEW.AddSegment(0,0.0,m_dLen,_T("001"));
|
|
|
|
return dbEW.GetCableLineSegsForHanger(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
}
|
|
else
|
|
{
|
|
STSection* pSection = GetShEwSection();
|
|
if (pSection != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcDbLine ln(m_ptFr,ptEnd);
|
|
|
|
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
|
|
pRoadLn->AppendCurveSeg(&ln);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
dbEW.SetSection(pSection->pReg, pSection->pt);
|
|
dbEW.SetBaseCurve(pRoadLn);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT1,AS_MUNIT(pSection->dThick[0]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT2,AS_MUNIT(pSection->dThick[1]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT4,AS_MUNIT(pSection->dThick[2]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT5,AS_MUNIT(pSection->dThick[3]));
|
|
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
delete pRoadLn;
|
|
|
|
return dbEW.GetCableLineSegsForHanger(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::GetPipeLineSegs(int nRoomIndex,AcArray<LineSeg>& arLnSegs, bool bAllRoom/* = false*/, bool bByWholeLine/* = false*/) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_sCrossSectionScr.Find(_T("RECT:")) != -1)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
STSection* pSection = GetShEwSection();
|
|
if (pSection != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcDbLine ln(m_ptFr,ptEnd);
|
|
|
|
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
|
|
pRoadLn->AppendCurveSeg(&ln);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
dbEW.SetSection(pSection->pReg, pSection->pt);
|
|
dbEW.SetBaseCurve(pRoadLn);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT1,AS_MUNIT(pSection->dThick[0]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT2,AS_MUNIT(pSection->dThick[1]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT4,AS_MUNIT(pSection->dThick[2]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT5,AS_MUNIT(pSection->dThick[3]));
|
|
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
delete pRoadLn;
|
|
|
|
return dbEW.GetPipeLineSegs(nRoomIndex
|
|
, arLnSegs
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::CreateFromSectionScr(LPCTSTR pszCrossSectionScr,double dLen)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (pszCrossSectionScr == NULL)
|
|
return false;
|
|
|
|
if (_tcslen(pszCrossSectionScr) == 0)
|
|
return false;
|
|
|
|
if (m_pDbEWSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDbEWSolid);
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
int bHideEw = false;
|
|
GetSpecialtyData()->GetAt(KEY_HIDEEW, bHideEw);
|
|
if (bHideEw) return true;
|
|
|
|
if (dLen < 1.0 )//至少1米
|
|
return false;
|
|
|
|
m_dLen = dLen;
|
|
m_sCrossSectionScr = pszCrossSectionScr;
|
|
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(pszCrossSectionScr);
|
|
//dbEW.SetChamferInter(0.0);
|
|
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcGeLineSeg3d ln(m_ptFr,ptEnd);
|
|
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
AcDb3dSolid* pEwSolid = dbEW.CreateEarthWorm3DSeg(ln, pRegion);
|
|
if (pEwSolid != NULL)
|
|
{
|
|
m_pDbEWSolid = pEwSolid;
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
DELETE_PTR(pRegion);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
CString GetSectionScr(AcDbRegion* pReg)
|
|
{
|
|
CString sRegionScrp = _T("");
|
|
if (pReg != NULL)
|
|
{
|
|
CString sFullPath = FilePath::GetSysDir();
|
|
sFullPath.MakeLower();
|
|
sFullPath += _T("\\DGJM.sat");
|
|
|
|
CString sLine;
|
|
AcDbVoidPtrArray arBodyPtrs;
|
|
arBodyPtrs.append(pReg);
|
|
|
|
if ( Acad::eOk == AcDbBody::acisOut(sFullPath,arBodyPtrs) )
|
|
{
|
|
CFile file;
|
|
if (file.Open(sFullPath,CFile::modeRead))
|
|
{
|
|
ULONGLONG dwFileLength = file.GetLength();
|
|
char* pszTxt = new char[dwFileLength];
|
|
|
|
file.Read(pszTxt,(UINT)dwFileLength);
|
|
|
|
sRegionScrp = pszTxt;
|
|
delete [] pszTxt;
|
|
|
|
file.Close();
|
|
}
|
|
}
|
|
}
|
|
return sRegionScrp;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::CreateFromSectionReg(STSection* pSection,double dLen,BOOL bShowAddtion3d,BOOL bBHShortDraw)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
int bHideEw = false;
|
|
GetSpecialtyData()->GetAt(KEY_HIDEEW, bHideEw);
|
|
if (bHideEw) return true;
|
|
|
|
if (m_pDbEWSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDbEWSolid);
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (pSection == NULL || pSection->pReg == NULL)
|
|
{
|
|
acutPrintf(_T("\n盾构界面选择选择错误!"));
|
|
return false;
|
|
}
|
|
|
|
if (dLen < 1.0 )//至少1米
|
|
return false;
|
|
|
|
m_dLen = dLen;
|
|
m_sCrossSectionScr = GetSectionScr(pSection->pReg);
|
|
m_mapXData.SetAt(_T("SECTIONPT"),pSection->pt);
|
|
m_mapXData.SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
|
|
AecDbShEarthWorm dbEW;
|
|
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcDbLine ln(m_ptFr,ptEnd);
|
|
|
|
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
|
|
pRoadLn->AppendCurveSeg(&ln);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSHOW,bShowAddtion3d);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSHOW_SHORT,bBHShortDraw);
|
|
dbEW.SetSection(pSection->pReg, pSection->pt);
|
|
dbEW.SetBaseCurve(pRoadLn);
|
|
|
|
AcDb3dSolid* pEwSolid = dbEW.GetCreatPipe3dSolid();
|
|
if (pEwSolid != NULL)
|
|
{
|
|
if (bShowAddtion3d)
|
|
{
|
|
AcDbVoidPtrArray arOther3dPtrs;
|
|
dbEW.CreateAddtion3d(arOther3dPtrs);
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDb3dSolid* pSolid = NULL;
|
|
for (int ii = 0;ii < arOther3dPtrs.length();ii++)
|
|
{
|
|
pSolid = (AcDb3dSolid*)arOther3dPtrs.at(ii);
|
|
if (pSolid != NULL)
|
|
{
|
|
es = pEwSolid->booleanOper(AcDb::kBoolUnite,pSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
m_pDbEWSolid = pEwSolid;
|
|
DELETE_PTR(pSection->pReg);
|
|
DELETE_PTR(pRoadLn);
|
|
return true;
|
|
}
|
|
|
|
DELETE_PTR(pSection->pReg);
|
|
DELETE_PTR(pRoadLn);
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::CreateFromSectionScr() const
|
|
{
|
|
if (m_pDbEWSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDbEWSolid);
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
int bHideEw = false;
|
|
GetSpecialtyData()->GetAt(KEY_HIDEEW, bHideEw);
|
|
if (bHideEw) return true;
|
|
|
|
if (m_sCrossSectionScr.Find(_T("RECT:")) != -1)
|
|
{
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(m_sCrossSectionScr);
|
|
//dbEW.SetChamferInter(0.0);
|
|
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcGeLineSeg3d ln(m_ptFr,ptEnd);
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
AcDb3dSolid* pEwSolid = dbEW.CreateEarthWorm3DSeg(ln, pRegion);
|
|
if (pEwSolid != NULL)
|
|
{
|
|
m_pDbEWSolid = pEwSolid;
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
DELETE_PTR(pRegion);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
STSection* pSection = GetShEwSection();
|
|
if (pSection != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcDbLine ln(m_ptFr,ptEnd);
|
|
|
|
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
|
|
pRoadLn->AppendCurveSeg(&ln);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
dbEW.SetSection(pSection->pReg, pSection->pt);
|
|
dbEW.SetBaseCurve(pRoadLn);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT1,AS_MUNIT(pSection->dThick[0]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT2,AS_MUNIT(pSection->dThick[1]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT4,AS_MUNIT(pSection->dThick[2]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT5,AS_MUNIT(pSection->dThick[3]));
|
|
|
|
AcDb3dSolid* pEwSolid = dbEW.GetCreatPipe3dSolid();
|
|
if (pEwSolid != NULL)
|
|
{
|
|
m_pDbEWSolid = pEwSolid;
|
|
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
delete pRoadLn;
|
|
|
|
return true;
|
|
}
|
|
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
delete pRoadLn;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
double AecDbEarthWormFitting::GetCrossSectionScr(CString& sCrossSectionScr) const
|
|
{
|
|
assertReadEnabled();
|
|
sCrossSectionScr = m_sCrossSectionScr;
|
|
return m_dLen;
|
|
}
|
|
|
|
double AecDbEarthWormFitting::GetLen() const
|
|
{
|
|
assertReadEnabled();
|
|
return m_dLen;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::SetLen(const double & dLen)
|
|
{
|
|
assertWriteEnabled();
|
|
m_dLen = dLen;
|
|
}
|
|
|
|
AcDb3dSolid* AecDbEarthWormFitting::GetMainEarthWorm() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pDbEWSolid != NULL)
|
|
{
|
|
return (AcDb3dSolid*)m_pDbEWSolid->clone();
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::AppendJsGroup(AcArray<AecDbX3dGroup*> &arr)
|
|
{
|
|
assertWriteEnabled();
|
|
m_arAddX3dGroupPtrs.append(arr);
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::AppendX3dGroup(AecDbX3dGroup* pGroup)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
m_arAddX3dGroupPtrs.append(pGroup);
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
return true;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::RemoveAllGroup(bool bDelete)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
if (m_pDbEWSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDbEWSolid);
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
while(m_arAddX3dGroupPtrs.length() > 0)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.last();
|
|
if (pGroup != NULL && bDelete)
|
|
{
|
|
DELETE_PTR(pGroup);
|
|
}
|
|
m_arAddX3dGroupPtrs.removeLast();
|
|
}
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::RemoveX3dGroup(LPCTSTR pszID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bSuccess = false;
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
m_arAddX3dGroupPtrs.removeAt(i);
|
|
DELETE_PTR(pGroup);
|
|
bSuccess = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
|
|
|
|
return bSuccess;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::HideGroup(LPCTSTR pszGUID,bool bHide)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bSuccess = false;
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
|
|
if (pszGUID == NULL)
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
//if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHide(bHide);
|
|
}
|
|
}
|
|
bSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHide(bHide);
|
|
bSuccess = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
|
|
return bSuccess;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::HideOrShowGroup(LPCTSTR pszGUID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bSuccess = false;
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
|
|
if (pszGUID == NULL)
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
//if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHideShow();
|
|
}
|
|
}
|
|
bSuccess = true;
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->SetHideShow();
|
|
bSuccess = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
|
|
return bSuccess;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::PeelOffTheSkin(LPCTSTR pszGUID,int nPos)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bSuccess = false;
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (pszGUID != NULL && _tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->PeelOffTheSkin(nPos);
|
|
|
|
bSuccess = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
//添加对管廊段的剥开
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
|
|
return bSuccess;
|
|
}
|
|
|
|
//管线
|
|
bool AecDbEarthWormFitting::AddPipeLine(AecDbEwPipe* pPipe)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
m_arAddtionPtrs.append(pPipe);
|
|
pPipe->setOwnerId(objectId());
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::AddPipeLine(AcDbVoidPtrArray & Pipes)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
for (int i = 0; i < Pipes.length(); ++i)
|
|
{
|
|
AcDbEntity *pEnt((AcDbEntity*)Pipes[i]);
|
|
m_arAddtionPtrs.append(pEnt);
|
|
pEnt->setOwnerId(objectId());
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::RemovePipe(LPCTSTR pszID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
m_arAddtionPtrs.removeAt(i);
|
|
DELETE_PTR(pPipe);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
AecDbEwPipe* AecDbEarthWormFitting::GetPipe(LPCTSTR pszID) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
return pPipe;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::AddFitting(AecDbEwFitting* pFit)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
m_arAddtionPtrs.append(pFit);
|
|
pFit->setOwnerId(objectId());
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::AddFitting(AecDbEwFitting* pFit,AecDbEwPipe*& pPipeNew)
|
|
{
|
|
EFittingType eType = pFit->GetFittingType();
|
|
if (eType == eTee || eType == eCross)
|
|
{
|
|
AcGeVector3d vtMaj,vt1,vt2;
|
|
AcGePoint3d ptMid,ptSta,ptEnd;
|
|
double dLen1 = 0.0,dMid = 0.0;
|
|
|
|
pFit->GetSpecialtyData()->GetAt(KEY_L,dLen1);
|
|
pFit->GetSpecialtyData()->GetAt(KEY_MAJBR,vtMaj);
|
|
pFit->GetSpecialtyData()->GetAt(KEY_MID,ptMid);
|
|
|
|
//查找所有的管,是否落在其上并打断
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
if ( Acad::eOk == pPipe->getParamAtPoint(ptMid,dMid) )
|
|
{
|
|
pPipe->getStartPoint(ptSta);
|
|
pPipe->getEndPoint(ptEnd);
|
|
|
|
vt1 = ptMid - ptSta;
|
|
vt2 = ptMid - ptEnd;
|
|
|
|
if (vt1.isParallelTo(vt2))//说明落在管子上
|
|
{
|
|
vt1 = ptEnd - ptSta;
|
|
vt1.normalize();
|
|
|
|
AcGePoint3d ptEnd1 = ptMid - vt1 * 0.5 * dLen1;
|
|
AcGePoint3d ptSta1 = ptMid + vt1 * 0.5 * dLen1;
|
|
|
|
pPipe->SetEndPoint(ptEnd1);
|
|
|
|
pPipeNew = new AecDbEwPipe;
|
|
pPipeNew->copyFrom(pPipe);
|
|
pPipeNew->SetStartPoint(ptSta1);
|
|
pPipeNew->SetEndPoint(ptEnd);
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
AddFitting(pFit);
|
|
|
|
return true;
|
|
}
|
|
|
|
AecDbEwFitting* AecDbEarthWormFitting::GetFitting(LPCTSTR pszID) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwFitting* pPipe = AecDbEwFitting::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
return pPipe;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::RemoveFitting(LPCTSTR pszID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwFitting* pPipe = AecDbEwFitting::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
m_arAddtionPtrs.removeAt(i);
|
|
DELETE_PTR(pPipe);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::AddEquipment(AecDbEwEquipment* pEqu)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
m_arAddtionPtrs.append(pEqu);
|
|
|
|
return true;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::RemoveEquipment(LPCTSTR pszID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwEquipment* pPipe = AecDbEwEquipment::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
m_arAddtionPtrs.removeAt(i);
|
|
DELETE_PTR(pPipe);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
AecDbEwEquipment* AecDbEarthWormFitting::GetEquipment(LPCTSTR pszID) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwEquipment* pPipe = AecDbEwEquipment::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
return pPipe;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
//线缆
|
|
bool AecDbEarthWormFitting::AddCableLine(AecDbEwCable* pCable)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_arAddtionPtrs.append(pCable);
|
|
return true;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::AddCableLine(AcDbVoidPtrArray & arr)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_arAddtionPtrs.append(arr);
|
|
return true;
|
|
}
|
|
|
|
AecDbEwCable* AecDbEarthWormFitting::GetCableLine(LPCTSTR pszID) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwCable* pPipe = AecDbEwCable::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
return pPipe;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::SetAddtionHide(LPCTSTR pszClasName,int bHide)
|
|
{
|
|
AssertWriteEnabled();
|
|
m_mapXData.SetAt(pszClasName,bHide);
|
|
}
|
|
|
|
BOOL AecDbEarthWormFitting::IsAddtionHide(LPCTSTR pszClasName) const
|
|
{
|
|
BOOL bHide = 0;
|
|
if ( m_mapXData.GetAt(pszClasName,bHide) )
|
|
{
|
|
return bHide;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::RemoveCable(LPCTSTR pszID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
CString sID;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwCable* pPipe = AecDbEwCable::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
sID = pPipe->GetGUID();
|
|
if (sID.CompareNoCase(pszID) == 0)
|
|
{
|
|
m_arAddtionPtrs.removeAt(i);
|
|
DELETE_PTR(pPipe);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
BOOL AecDbEarthWormFitting::GetAddtion(int& nPos,AcDbEntity*& pPipeNext,int& nType) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
if (nPos > -1 && nPos < m_arAddtionPtrs.length() )
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(nPos);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
pPipeNext = pEnt;
|
|
nType = ePipe;
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
pPipeNext = pEnt;
|
|
nType = eEquipment;
|
|
}
|
|
|
|
AecDbEwFitting* pFit = AecDbEwFitting::cast(pEnt);
|
|
if (pFit != NULL)
|
|
{
|
|
pPipeNext = pEnt;
|
|
nType = eFitting;
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
pPipeNext = pEnt;
|
|
nType = eCable;
|
|
}
|
|
|
|
nPos += 1;
|
|
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::TransformAssocInf(AecInterface& inf,const AcGeMatrix3d& xform,AcDbEntity* pMsgFrom)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
bool bOnHitThis = false;
|
|
AecMInterfaces* pInf = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
int nHitInf = -1;
|
|
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
if (pEnt == pMsgFrom)//源对象不处理
|
|
continue;
|
|
|
|
pInf = NULL;
|
|
if (pEnt->isKindOf(AecDbEwPipe::desc()))
|
|
{
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
pInf = static_cast<AecMInterfaces*>(pPipe);
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwFitting::desc()))
|
|
{
|
|
AecDbEwFitting* pFitting = AecDbEwFitting::cast(pEnt);
|
|
pInf = static_cast<AecMInterfaces*>(pFitting);
|
|
}
|
|
|
|
//??需要特殊处理某些大型设备不能动
|
|
if (pEnt->isKindOf(AecDbEwEquipment::desc()))//阀门或小型附件可以移动
|
|
{
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
pInf = static_cast<AecMInterfaces*>(pEqu);
|
|
}
|
|
|
|
if (pInf != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pInf->GetInterface(arInfs);
|
|
|
|
bOnHitThis = false;
|
|
for (int j = 0;j < arInfs.length();j++)
|
|
{
|
|
AecInterface& infTmp = arInfs.at(j);
|
|
|
|
if (infTmp.ptPos.distanceTo(inf.ptPos) < 1.e-2)//误差0.01米
|
|
{
|
|
bOnHitThis = true;
|
|
nHitInf = j;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (bOnHitThis)
|
|
{
|
|
bool bContinueSend = pInf->TransformAssocInf(nHitInf,xform);
|
|
if (bContinueSend)//继续发送消息
|
|
{
|
|
//作用在旧的接口上继续传递接口消息
|
|
arInfs.removeAt(nHitInf);
|
|
for (int k = 0;k < arInfs.length();k++)
|
|
{
|
|
AecInterface& infK = arInfs.at(k);
|
|
TransformAssocInf(infK,xform,pMsgFrom);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::TransformAddtion(LPCTSTR pszGUID,const AcGeMatrix3d& xform)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//接口传递
|
|
AecDbEwPipe* pPipe = GetPipe(pszGUID);
|
|
if (pPipe != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pPipe->GetInterface(arInfs);
|
|
|
|
//先变换
|
|
pPipe->TransformBy(xform);
|
|
|
|
//根据旧的接口传递变换
|
|
int nCount = arInfs.length();
|
|
for (int i = 0;i < arInfs.length();i++)
|
|
{
|
|
AecInterface& inf = arInfs.at(i);
|
|
TransformAssocInf(inf,xform,pPipe);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
AecDbEwFitting* pFitting = GetFitting(pszGUID);
|
|
if (pFitting != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pFitting->GetInterface(arInfs);
|
|
|
|
//先变换
|
|
pFitting->TransformBy(xform);
|
|
|
|
//根据旧的接口传递变换
|
|
int nCount = arInfs.length();
|
|
for (int i = 0;i < arInfs.length();i++)
|
|
{
|
|
AecInterface& inf = arInfs.at(i);
|
|
TransformAssocInf(inf,xform,pFitting);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
AecDbEwCable* pCable = GetCableLine(pszGUID);
|
|
if (pCable != NULL)
|
|
{
|
|
if ( pCable->GetActiveInf() != -1)
|
|
{
|
|
pCable->TransformAssocInf(pCable->GetActiveInf(),xform);
|
|
}
|
|
else
|
|
{
|
|
pCable->TransformBy(xform);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = GetEquipment(pszGUID);
|
|
if (pEqu != NULL)
|
|
{
|
|
pEqu->AddTransform(xform);
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::SetAddtionActiveInf(LPCTSTR pszGUID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbEwPipe* pPipe = NULL;
|
|
AecDbEwFitting* pFitting = NULL;
|
|
AecDbEwCable* pCable = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
AecDbEwEquipment* pEqu = NULL;
|
|
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
if (pEnt->isKindOf(AecDbEwPipe::desc()))
|
|
{
|
|
pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pPipe->GetGUID()) != 0)
|
|
{
|
|
pPipe->SetActiveInf(-1);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwFitting::desc()))
|
|
{
|
|
pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pFitting->GetGUID()) != 0)
|
|
{
|
|
pFitting->SetActiveInf(-1);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwCable::desc()))
|
|
{
|
|
pCable = AecDbEwCable::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pCable->GetGUID()) != 0)
|
|
{
|
|
pCable->SetActiveInf(-1);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwEquipment::desc()))
|
|
{
|
|
pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pEqu->GetGUID()) != 0)
|
|
{
|
|
pEqu->SetActiveInf(-1);
|
|
}
|
|
}
|
|
}
|
|
|
|
//调整接口
|
|
pPipe = GetPipe(pszGUID);
|
|
if (pPipe != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pPipe->GetInterface(arInfs);
|
|
|
|
int nPos = pPipe->GetActiveInf();
|
|
if (nPos >= -1 && nPos < arInfs.length() )
|
|
{
|
|
nPos += 1;
|
|
}
|
|
if (nPos >= arInfs.length() )
|
|
{
|
|
nPos = 0;
|
|
}
|
|
pPipe->SetActiveInf(nPos);
|
|
}
|
|
|
|
pFitting = GetFitting(pszGUID);
|
|
if (pFitting != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pFitting->GetInterface(arInfs);
|
|
|
|
int nPos = pFitting->GetActiveInf();
|
|
if (nPos >= -1 && nPos < arInfs.length() )
|
|
{
|
|
nPos += 1;
|
|
}
|
|
if (nPos >= arInfs.length() )
|
|
{
|
|
nPos = 0;
|
|
}
|
|
pFitting->SetActiveInf(nPos);
|
|
}
|
|
|
|
pCable = GetCableLine(pszGUID);
|
|
if (pCable != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pCable->GetInterface(arInfs);
|
|
|
|
int nPos = pCable->GetActiveInf();
|
|
if (nPos >= -1 && nPos < arInfs.length() )
|
|
{
|
|
nPos += 1;
|
|
}
|
|
if (nPos >= arInfs.length() )
|
|
{
|
|
nPos = 0;
|
|
}
|
|
pCable->SetActiveInf(nPos);
|
|
}
|
|
|
|
pEqu = GetEquipment(pszGUID);
|
|
if (pEqu != NULL)
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
pEqu->GetInterface(arInfs);
|
|
|
|
int nPos = pEqu->GetActiveInf();
|
|
if (nPos >= -1 && nPos < arInfs.length() )
|
|
{
|
|
nPos += 1;
|
|
}
|
|
if (nPos >= arInfs.length() )
|
|
{
|
|
nPos = 0;
|
|
}
|
|
pEqu->SetActiveInf(nPos);
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::AddMove(const AcGeVector3d& vtMove,LPCTSTR pszGUID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
if (pszGUID == NULL)//整体移动
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->AddMove(vtMove);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->AddMove(vtMove);
|
|
break;
|
|
}
|
|
}
|
|
|
|
AecDbEwPipe* pPipe = NULL;
|
|
AecDbEwFitting* pFitting = NULL;
|
|
AecDbEwCable* pCable = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
AecDbEwEquipment* pEqu = NULL;
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(vtMove);
|
|
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
if (pEnt->isKindOf(AecDbEwPipe::desc()))
|
|
{
|
|
pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pPipe->GetGUID()) == 0)
|
|
{
|
|
pPipe->TransformBy(xform);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwFitting::desc()))
|
|
{
|
|
pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pFitting->GetGUID()) == 0)
|
|
{
|
|
pFitting->TransformBy(xform);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwCable::desc()))
|
|
{
|
|
pCable = AecDbEwCable::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pCable->GetGUID()) == 0)
|
|
{
|
|
pCable->TransformBy(xform);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwEquipment::desc()))
|
|
{
|
|
pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pEqu->GetGUID()) == 0)
|
|
{
|
|
pEqu->TransformBy(xform);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
}
|
|
|
|
void AecDbEarthWormFitting::AddMove(const AcGeMatrix3d& xMirror,LPCTSTR pszGUID)
|
|
{
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
if (pszGUID == NULL)//整体移动
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->AddMove(xMirror);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->AddMove(xMirror);
|
|
break;
|
|
}
|
|
}
|
|
|
|
AecDbEwPipe* pPipe = NULL;
|
|
AecDbEwFitting* pFitting = NULL;
|
|
AecDbEwCable* pCable = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
AecDbEwEquipment* pEqu = NULL;
|
|
|
|
//AcGeMatrix3d xform;
|
|
//xform.setToTranslation(vtMove);
|
|
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
if (pEnt->isKindOf(AecDbEwPipe::desc()))
|
|
{
|
|
pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pPipe->GetGUID()) == 0)
|
|
{
|
|
pPipe->TransformBy(xMirror);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwFitting::desc()))
|
|
{
|
|
pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pFitting->GetGUID()) == 0)
|
|
{
|
|
pFitting->TransformBy(xMirror);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwCable::desc()))
|
|
{
|
|
pCable = AecDbEwCable::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pCable->GetGUID()) == 0)
|
|
{
|
|
pCable->TransformBy(xMirror);
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwEquipment::desc()))
|
|
{
|
|
pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pEqu->GetGUID()) == 0)
|
|
{
|
|
pEqu->TransformBy(xMirror);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
}
|
|
|
|
void AecDbEarthWormFitting::ResetMove(LPCTSTR pszID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->ResetMove();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
}
|
|
|
|
AecDbX3dGroup* AecDbEarthWormFitting::GetX3dGroup(LPCTSTR pszID) const
|
|
{
|
|
assertReadEnabled();
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (pszID != NULL && _tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
return pGroup;
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
BOOL AecDbEarthWormFitting::GetX3dGroup(int& nPos,AecDbX3dGroup*& pGroupNext) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (nPos > -1 && nPos < m_arAddX3dGroupPtrs.length() )
|
|
{
|
|
pGroupNext = m_arAddX3dGroupPtrs.at(nPos);
|
|
nPos += 1;
|
|
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
//旋转
|
|
void AecDbEarthWormFitting::AddRotate(int nAxisIndex,double dRot,LPCTSTR pszID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
if ( pszID == NULL )//整体选装
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->AddRotate(nAxisIndex,dRot);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->AddRotate(nAxisIndex,dRot);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
}
|
|
|
|
void AecDbEarthWormFitting::AddInfRotate(int nActiveInf,double dRot,LPCTSTR pszGUID)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
if ( pszGUID != NULL )//整体选装
|
|
{
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pGroup->AddInfRotate(nActiveInf,dRot);
|
|
break;
|
|
}
|
|
}
|
|
|
|
|
|
AcGeMatrix3d xformR;
|
|
|
|
AecDbEwPipe* pPipe = NULL;
|
|
AecDbEwFitting* pFitting = NULL;
|
|
AecDbEwCable* pCable = NULL;
|
|
AcDbEntity* pEnt = NULL;
|
|
AecDbEwEquipment* pEqu = NULL;
|
|
AecMInterfaces* pInf = NULL;
|
|
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
if (pEnt->isKindOf(AecDbEwPipe::desc()))
|
|
{
|
|
pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pPipe->GetGUID()) != 0)
|
|
{
|
|
pInf = (AecMInterfaces*)pPipe;
|
|
}
|
|
}
|
|
|
|
if (pEnt->isKindOf(AecDbEwFitting::desc()))
|
|
{
|
|
pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pFitting->GetGUID()) != 0)
|
|
{
|
|
pInf = (AecMInterfaces*)pFitting;
|
|
}
|
|
}
|
|
|
|
/*if (pEnt->isKindOf(AecDbEwCable::desc()))
|
|
{
|
|
pCable = AecDbEwCable::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pCable->GetGUID()) != 0)
|
|
{
|
|
pInf = (AecMInterfaces*)pCable;
|
|
}
|
|
}*/
|
|
|
|
if (pEnt->isKindOf(AecDbEwEquipment::desc()))
|
|
{
|
|
pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (_tcscmp(pszGUID,pEqu->GetGUID()) != 0)
|
|
{
|
|
pInf = (AecMInterfaces*)pEqu;
|
|
}
|
|
}
|
|
|
|
if (pInf != NULL && pEnt != NULL)
|
|
{
|
|
AecInterface inf;
|
|
if ( pInf->GetInterface(nActiveInf,inf ) )
|
|
{
|
|
xformR.setToRotation(dRot,inf.vtDir,inf.ptPos);
|
|
pEnt->transformBy(xformR);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
}
|
|
|
|
void AecDbEarthWormFitting::ResetRotate(int nAxisIndex,LPCTSTR pszID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if (_tcscmp(pGroup->GetGUID(),pszID) == 0)
|
|
{
|
|
pGroup->ResetRotate(nAxisIndex);
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
}
|
|
|
|
AcDb3dSolid* AecDbEarthWormFitting::CreateDraw3dSolid(int nFlag,bool bWriteBimInfo) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDb3dSolid* pDraw3dSolid = NULL;
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
pDraw3dSolid = (AcDb3dSolid*)m_pDraw3dSolid->clone();
|
|
return pDraw3dSolid;
|
|
}
|
|
|
|
if (m_pDbEWSolid == NULL)
|
|
{
|
|
CreateFromSectionScr();
|
|
|
|
if (m_pDbEWSolid == NULL)
|
|
return NULL;
|
|
}
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDb::BoolOperType bType;
|
|
|
|
pDraw3dSolid = (AcDb3dSolid*)m_pDbEWSolid->clone();
|
|
pDraw3dSolid->setColorIndex(kColorByLayer);
|
|
|
|
CString sName;
|
|
AcArray<const AecDbX3dGroup*> arKCGroups;//开窗
|
|
AcArray<const AecDbX3dGroup*> arSliceGrps;//剖切
|
|
|
|
AcDb3dSolid* pSolid = NULL;
|
|
const AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pGroup->IsHide())
|
|
continue;
|
|
|
|
if ( pGroup->IsPipeLine() )
|
|
continue;
|
|
|
|
pGroup->GetName(sName);
|
|
if (sName.CompareNoCase(_T("开窗")) == 0)
|
|
{
|
|
arKCGroups.append(pGroup);
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
arSliceGrps.append(pGroup);
|
|
continue;
|
|
}
|
|
|
|
AcArray<X3dSolidRec> arRecs;
|
|
pGroup->GetX3dSolidRecs(arRecs);
|
|
|
|
AecDbObjXDataMap* pXDataMap = (AecDbObjXDataMap*)&m_mapXData;
|
|
pXDataMap->SetAt(sName,i+1,*pGroup->GetSpecialtyData());
|
|
|
|
int nCr = kColorByLayer;
|
|
for (int j = 0;j < arRecs.length();j++)
|
|
{
|
|
X3dSolidRec& rec = arRecs.at(j);
|
|
bType = rec.bType;
|
|
|
|
if (rec.bType == AcDb::kBoolIntersect)
|
|
{
|
|
if ( pGroup->IsPeelOffTheSkin() )
|
|
{
|
|
//剖开...
|
|
bType = AcDb::kBoolSubtract;
|
|
}
|
|
else
|
|
{
|
|
continue;//不处理
|
|
}
|
|
}
|
|
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
if ( pGroup->GetSpecialtyData()->GetAt(_T("COLOR"),nCr) )
|
|
{
|
|
if (pSolid != NULL)
|
|
pSolid->setColorIndex(nCr);
|
|
}
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pGroup->Transformby(pSolid);
|
|
|
|
MakeVerSection2d(pSolid,0);
|
|
MakeVerSection2d(pSolid,1);
|
|
|
|
if (Acad::eOk != (es = pDraw3dSolid->booleanOper(bType,pSolid )))
|
|
{
|
|
acutPrintf(_T("\nCreate from rec error:%d:%d"),i,es);
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pDraw3dSolid != NULL)
|
|
{
|
|
MakeVerSection2d(pDraw3dSolid,1);
|
|
}
|
|
|
|
//开窗
|
|
if (nFlag == 0)//默认
|
|
{
|
|
for (int i = 0;i < arKCGroups.length();i++)
|
|
{
|
|
pGroup = arKCGroups.at(i);
|
|
|
|
AcArray<X3dSolidRec> arRecs;
|
|
pGroup->GetX3dSolidRecs(arRecs);
|
|
|
|
for (int j = 0;j < arRecs.length();j++)
|
|
{
|
|
X3dSolidRec& rec = arRecs.at(j);
|
|
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
if (pSolid != NULL)
|
|
{
|
|
pGroup->Transformby(pSolid);
|
|
|
|
if (Acad::eOk != (es = pDraw3dSolid->booleanOper(AcDb::kBoolSubtract,pSolid )))
|
|
{
|
|
acutPrintf(_T("\nCreate from rec error:%d:%d"),i,es);
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//剖切
|
|
int nPartRetain = 0;
|
|
for (int i = 0;i < arSliceGrps.length();i++)
|
|
{
|
|
pGroup = arSliceGrps.at(i);
|
|
|
|
AcGePlane plan;
|
|
pGroup->GetSlicePlan(plan);
|
|
|
|
pGroup->GetSpecialtyData()->GetAt(_T("m_nPartRetain"),nPartRetain);
|
|
|
|
AcDb3dSolid* pSolidNew = NULL;
|
|
if ( Acad::eOk == (es = pDraw3dSolid->getSlice(plan,nPartRetain > 0 ? Adesk::kTrue : Adesk::kFalse,pSolidNew) ) )
|
|
{
|
|
if (nPartRetain > 0 && pSolidNew != NULL)
|
|
{
|
|
DELETE_PTR(pDraw3dSolid);
|
|
pDraw3dSolid = pSolidNew;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (bWriteBimInfo && pDraw3dSolid != NULL)
|
|
{
|
|
m_mapXData.Write(pDraw3dSolid,_T("BIMDATA"));
|
|
}
|
|
return pDraw3dSolid;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::GetAddtionDraw3dSolid(AcDbVoidPtrArray& arSolidPtrs,bool bWriteBimInfo) const
|
|
{
|
|
assertReadEnabled();
|
|
AcDbEntity* pEnt = NULL;
|
|
BOOL bHide = 0;
|
|
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwPipe"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
pPipe->GetDraw3dables(arSolidPtrs,bWriteBimInfo);
|
|
}
|
|
|
|
AecDbEwFitting* pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (pFitting != NULL)
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwFitting"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
pFitting->GetDraw3dables(arSolidPtrs,bWriteBimInfo);
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwCable"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
pCable->GetDraw3dables(arSolidPtrs,bWriteBimInfo);
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwEquipment"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
pEqu->GetDraw3dables(arSolidPtrs,bWriteBimInfo);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDb3dSolid* AecDbEarthWormFitting::Create3dSolidNoGLBJ() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcDb3dSolid* pDraw3dSolid = NULL;
|
|
|
|
int bHideEw = false;
|
|
GetSpecialtyData()->GetAt(KEY_HIDEEW, bHideEw);
|
|
if (bHideEw) return NULL;
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDb::BoolOperType bType;
|
|
|
|
pDraw3dSolid = (AcDb3dSolid*)m_pDbEWSolid->clone();
|
|
pDraw3dSolid->setColorIndex(kColorByLayer);
|
|
|
|
CString sName;
|
|
const AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pGroup->IsHide())
|
|
continue;
|
|
|
|
if ( pGroup->IsPipeLine() )
|
|
continue;
|
|
|
|
//让开变径,铺管铺线变径处U弯手动处理
|
|
pGroup->GetName(sName);
|
|
if (sName.CompareNoCase(_T("变径")) != 0)
|
|
continue;
|
|
|
|
AcArray<X3dSolidRec> arRecs;
|
|
pGroup->GetX3dSolidRecs(arRecs);
|
|
|
|
int nCr = kColorByLayer;
|
|
AcDb3dSolid* pSolid = NULL;
|
|
|
|
for (int j = 0;j < arRecs.length();j++)
|
|
{
|
|
X3dSolidRec& rec = arRecs.at(j);
|
|
bType = rec.bType;
|
|
|
|
if (rec.bType == AcDb::kBoolIntersect)
|
|
{
|
|
if ( pGroup->IsPeelOffTheSkin() )
|
|
{
|
|
//剖开...
|
|
bType = AcDb::kBoolSubtract;
|
|
}
|
|
else
|
|
{
|
|
continue;//不处理
|
|
}
|
|
}
|
|
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
if (pSolid != NULL)
|
|
{
|
|
pGroup->Transformby(pSolid);
|
|
|
|
if (Acad::eOk != (es = pDraw3dSolid->booleanOper(bType,pSolid )))
|
|
{
|
|
acutPrintf(_T("\nCreate from rec error:%d:%d"),i,es);
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return pDraw3dSolid;
|
|
}
|
|
|
|
AcDb3dSolid* AecDbEarthWormFitting::CreateDraw3dPipeLine() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
FreeBuffer(0,m_arDraw3dPipeLine);
|
|
|
|
AcDb3dSolid* pDraw3dSolid = NULL;
|
|
const AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pGroup->IsHide())
|
|
continue;
|
|
|
|
if ( !pGroup->IsPipeLine() )
|
|
continue;
|
|
|
|
AcArray<X3dSolidRec> arRecs;
|
|
pGroup->GetX3dSolidRecs(arRecs);
|
|
|
|
int nCr = kColorByLayer;
|
|
for (int j = 0;j < arRecs.length();j++)
|
|
{
|
|
X3dSolidRec& rec = arRecs.at(j);
|
|
|
|
AcDb3dSolid* pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
if ( pGroup->GetSpecialtyData()->GetAt(_T("COLOR"),nCr) )
|
|
{
|
|
if (pSolid != NULL)
|
|
pSolid->setColorIndex(nCr);
|
|
}
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pGroup->Transformby(pSolid);
|
|
|
|
MakeVerSection2d(pSolid,0);
|
|
MakeVerSection2d(pSolid,1);
|
|
|
|
m_arDraw3dPipeLine.append(pSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
return NULL;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::GetDraw2d(AcDbVoidPtrArray& ar2DEntPtr,int nSectionDrawStyle)
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nCor = 0;
|
|
struct resbuf* pRb2 = NULL;
|
|
AcDbEntity* pEnt = NULL,*pEntClone = NULL;
|
|
const AcDbVoidPtrArray &ar2D = Get2DBuffer();
|
|
for (int i = 0;i < ar2D.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)ar2D.at(i);
|
|
if (pEnt != NULL)
|
|
{
|
|
nCor = pEnt->colorIndex();
|
|
|
|
if (nSectionDrawStyle == nCor || kXDataColor == nCor)
|
|
{
|
|
pEntClone = (AcDbEntity*)pEnt->clone();
|
|
|
|
if ( kXDataColor == nCor )//特殊实体,设置扩展数据
|
|
{
|
|
AecDbObjXDataMap map;
|
|
map.SetAt(_T("CenterPoint"), 1);
|
|
pEntClone->setColorIndex(nSectionDrawStyle);//设置纵断颜色
|
|
map.Write(pEntClone, _T("DIM_DATA"));
|
|
|
|
pRb2 = pEntClone->xData(_T("DIM_DATA"));
|
|
}
|
|
|
|
AcDbCurve* pCurve = AcDbCurve::cast(pEntClone);
|
|
if (pCurve != NULL)
|
|
{
|
|
AcDbCurve* pProjCrv = NULL;
|
|
pCurve->getOrthoProjectedCurve(AcGePlane::kXYPlane,pProjCrv);
|
|
|
|
if (pProjCrv != NULL)
|
|
{
|
|
pProjCrv->setColorIndex(nSectionDrawStyle);
|
|
if (pRb2)
|
|
pProjCrv->setXData(pRb2);
|
|
ar2DEntPtr.append(pProjCrv);
|
|
continue;
|
|
}
|
|
}
|
|
|
|
AcDb3dSolid* pSolid = AcDb3dSolid::cast(pEntClone);
|
|
if (pSolid != NULL)
|
|
{
|
|
AcGePlane plan = AcGePlane::kXYPlane;
|
|
AcGeMatrix3d xformId = AcGeMatrix3d::kIdentity;
|
|
OrthoProjected3DSolid(pSolid,plan,xformId,ar2DEntPtr);
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::SaveAs(CFile* pFile) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CMFCDbDwgFiler mfcFiler(pFile);
|
|
AcDbDwgFiler* pFiler = &mfcFiler;
|
|
|
|
Acad::ErrorStatus es = dwgOutFields(pFiler);
|
|
|
|
return es == Acad::eOk ? true : false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::ReadFrom(LPCTSTR pszFile) throw()
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
m_nActiveGroup = -1;
|
|
|
|
try
|
|
{
|
|
CFile file;
|
|
if (file.Open(pszFile,CFile::modeRead ))
|
|
{
|
|
CMFCDbDwgFiler mfcFiler(&file);
|
|
Acad::ErrorStatus es = dwgInFields(&mfcFiler);
|
|
file.Close();
|
|
|
|
return es == Acad::eOk ? true : false;
|
|
}
|
|
}
|
|
catch (...)
|
|
{
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::MergeReadFrom(LPCTSTR pszFile) throw()
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
m_nActiveGroup = -1;
|
|
|
|
try
|
|
{
|
|
CFile file;
|
|
if (file.Open(pszFile,CFile::modeRead ))
|
|
{
|
|
CMFCDbDwgFiler mfcFiler(&file);
|
|
Acad::ErrorStatus es = mergedwgInFields(&mfcFiler);
|
|
file.Close();
|
|
|
|
return es == Acad::eOk ? true : false;
|
|
}
|
|
}
|
|
catch (...)
|
|
{
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::ReadFrom(CFile* pFile) throw()
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
m_nActiveGroup = -1;
|
|
|
|
try
|
|
{
|
|
CMFCDbDwgFiler mfcFiler(pFile);
|
|
Acad::ErrorStatus es = dwgInFields(&mfcFiler);
|
|
return es == Acad::eOk ? true : false;
|
|
}
|
|
catch (...)
|
|
{
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::UpdateDrawGroupAxis(LPCTSTR pszGUID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->SetActive(false);
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pPipe->GetGUID(),pszGUID) != 0)
|
|
{
|
|
pPipe->SetActive(false);
|
|
}
|
|
}
|
|
|
|
AecDbEwFitting* pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (pFitting != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pFitting->GetGUID(),pszGUID) != 0)
|
|
{
|
|
pFitting->SetActive(false);
|
|
}
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pCable->GetGUID(),pszGUID) != 0)
|
|
{
|
|
pCable->SetActive(false);
|
|
}
|
|
}
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pEqu->GetGUID(),pszGUID) != 0)
|
|
{
|
|
pEqu->SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pszGUID != NULL && _tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
m_nActiveGroup = i;
|
|
pGroup->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
//管道和线缆
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pPipe->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pPipe->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
AecDbEwFitting* pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (pFitting != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pFitting->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pFitting->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pCable->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pCable->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pEqu->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pEqu->SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
|
|
m_nActiveGroup = -1;
|
|
return false;
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::UpdateDrawGroupAxis(LPCTSTR pszGUID,LPCTSTR pszSubGUID)
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->SetActive(false);
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
pPipe->SetActive(false);
|
|
}
|
|
|
|
AecDbEwFitting* pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (pFitting != NULL)
|
|
{
|
|
pFitting->SetActive(false);
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
pCable->SetActive(false);
|
|
}
|
|
}
|
|
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pszGUID != NULL && _tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
m_nActiveGroup = i;
|
|
if (pszSubGUID != NULL)
|
|
{
|
|
pGroup->SetActive(true,_ttoi(pszSubGUID));
|
|
}
|
|
else
|
|
{
|
|
pGroup->SetActive(true);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
|
|
for(int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pszGUID != NULL && _tcscmp(pGroup->GetGUID(),pszGUID) == 0)
|
|
{
|
|
m_nActiveGroup = i;
|
|
pGroup->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
//管道和线缆
|
|
for (int i = 0;i < m_arAddtionPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(i);
|
|
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pPipe->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pPipe->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
AecDbEwFitting* pFitting = AecDbEwFitting::cast(pEnt);
|
|
if (pFitting != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pFitting->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pFitting->SetActive(true);
|
|
return true;
|
|
}
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
if (pszGUID != NULL && _tcscmp(pCable->GetGUID(),pszGUID) == 0)
|
|
{
|
|
pCable->SetActive(true);
|
|
if (pszSubGUID != NULL)
|
|
{
|
|
pCable->SetActiveInf(_ttoi(pszSubGUID) * 2);
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
m_nActiveGroup = -1;
|
|
return false;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::Draw2d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (objectId().isValid())
|
|
{
|
|
if (dc.IsDragging())
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
//dc.SetSelectionMarker(1);
|
|
|
|
if (NULL != m_pDraw3dSolid)
|
|
dc.DrawEntity(*m_pDraw3dSolid);
|
|
|
|
if (NULL != m_pDraw3dPipeLine)
|
|
dc.DrawEntity(*m_pDraw3dPipeLine);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int k = 0;k < m_arDraw3dPipeLine.length();k++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arDraw3dPipeLine.at(k);
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
//绘制新的管线线缆和设备2017-12-1
|
|
for (int k = 0;k < m_arAddtionPtrs.length();k++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(k);
|
|
AecDbEwPipeBase* pPipeBase = AecDbEwPipeBase::cast(pEnt);
|
|
if (pPipeBase != NULL)//管线,线缆,管件
|
|
{
|
|
AecUnknownViewportDraw* pAecDraw = AecUnknownViewportDraw::cast(dc.GetCommonDraw());
|
|
if (pAecDraw != NULL)
|
|
{
|
|
pPipeBase->viewportDraw(pAecDraw);
|
|
}
|
|
else
|
|
{
|
|
pPipeBase->Draw2d(dc);
|
|
}
|
|
}
|
|
|
|
AecDbEwFitting* pFitt = AecDbEwFitting::cast(pEnt);
|
|
if (pFitt != NULL)
|
|
{
|
|
AecUnknownViewportDraw* pAecDraw = AecUnknownViewportDraw::cast(dc.GetCommonDraw());
|
|
if (pAecDraw != NULL)
|
|
{
|
|
pFitt->viewportDraw(pAecDraw);
|
|
}
|
|
else
|
|
{
|
|
pFitt->Draw2d(dc);
|
|
}
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
AecUnknownViewportDraw* pAecDraw = AecUnknownViewportDraw::cast(dc.GetCommonDraw());
|
|
if (pAecDraw != NULL)
|
|
{
|
|
pEqu->viewportDraw(pAecDraw);
|
|
}
|
|
else
|
|
{
|
|
pEqu->Draw2d(dc);
|
|
}
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
AecUnknownViewportDraw* pAecDraw = AecUnknownViewportDraw::cast(dc.GetCommonDraw());
|
|
if (pAecDraw != NULL)
|
|
{
|
|
pCable->viewportDraw(pAecDraw);
|
|
}
|
|
else
|
|
{
|
|
pCable->Draw2d(dc);
|
|
}
|
|
}
|
|
}
|
|
|
|
dc.SetLayer(idLay);
|
|
DrawActiveXYZArrow(dc);
|
|
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
AecDbX3dGroup* pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->DrawInf(dc);
|
|
}
|
|
|
|
if (objectId().isValid())
|
|
{
|
|
double dLeft = 0.0;
|
|
if ( GetSpecialtyData()->GetAt(_T("dLeft"),dLeft) )
|
|
{
|
|
AcGePoint3d ptGe[2];
|
|
ptGe[0].set(dLeft,-20.0,0.0);
|
|
ptGe[1].set(dLeft,20.0,0.0);
|
|
|
|
AcDbLine ln(ptGe[0],ptGe[1]);
|
|
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(kYellow);
|
|
dc.DrawEntity(&ln);
|
|
dc.SetColor(nOld);
|
|
}
|
|
}
|
|
#if ARX > 17
|
|
DrawSubDMesh(dc, true);
|
|
#endif
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::DrawActiveXYZArrow(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_nActiveGroup >= 0 && m_nActiveGroup < m_arAddX3dGroupPtrs.length() )
|
|
{
|
|
AecDbX3dGroup* pGroup = m_arAddX3dGroupPtrs.at(m_nActiveGroup);
|
|
pGroup->DrawAxis(dc);
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::GetRoomNames(CStringArray& arRoomNames) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sKey,sName;
|
|
for (int i = 0;i < 20;i++)
|
|
{
|
|
sKey.Format(_T("room-%d"),i);
|
|
if (m_mapXData.GetAt(sKey,sName))
|
|
{
|
|
arRoomNames.Add(sName);
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::SetRoomNames(CStringArray& arRoomNames)
|
|
{
|
|
assertWriteEnabled();
|
|
m_mapXData.Empty();
|
|
CString sKey;
|
|
for (int i = 0;i < arRoomNames.GetSize();i++)
|
|
{
|
|
sKey.Format(_T("room-%d"),i);
|
|
m_mapXData.SetAt(sKey,arRoomNames.GetAt(i));
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::SetRoomNameMap(CMapStringToString& mapRoomSet)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
CString sKey,sVal;
|
|
for (POSITION ps = mapRoomSet.GetStartPosition();ps != NULL;)
|
|
{
|
|
mapRoomSet.GetNextAssoc(ps,sKey,sVal);
|
|
m_mapXData.SetAt(sKey,sVal);
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::GetRoomNameMap(CMapStringToString& mapRoomSet) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
CString sKey,sName,sVal, _sKey;
|
|
for (int i = 0;i < 20;i++)
|
|
{
|
|
sKey.Format(_T("room-%d"),i);
|
|
|
|
sName = _T("");
|
|
if ( m_mapXData.GetAt(sKey,sName) )
|
|
{
|
|
if ( m_mapXData.GetAt(sName,sVal) )
|
|
{
|
|
mapRoomSet.SetAt(sName, sVal);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bool AecDbEarthWormFitting::ReCreateDraw3d()
|
|
{
|
|
AssertWriteEnabled();
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
|
|
if (m_pDraw3dPipeLine != NULL)
|
|
{
|
|
DELETE_PTR(m_pDraw3dPipeLine);
|
|
}
|
|
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
|
|
return true;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::Transformby(AcDbEntity *pSolid,const AcGePoint3d& ptPos,const AcGeVector3d& vtDir)
|
|
{
|
|
if (pSolid == NULL) return;
|
|
AcGeVector3d vtMove = ptPos.asVector();
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtMove);
|
|
|
|
AcGeVector3d vtDirXY = vtDir.orthoProject(AcGeVector3d::kZAxis);
|
|
|
|
AcGeVector3d vtNorm = vtDirXY.crossProduct(vtDir);
|
|
double dRot = vtDirXY.angleTo(vtDir,vtNorm);
|
|
AcGeMatrix3d xformRz;
|
|
xformRz.setToRotation(dRot,vtNorm,ptPos);
|
|
|
|
dRot = AcGeVector3d::kXAxis.angleTo(vtDirXY,AcGeVector3d::kZAxis);
|
|
AcGeMatrix3d xformRx;
|
|
xformRx.setToRotation(dRot,AcGeVector3d::kZAxis,ptPos);
|
|
|
|
pSolid->transformBy(xformM);
|
|
pSolid->transformBy(xformRx);
|
|
pSolid->transformBy(xformRz);
|
|
}
|
|
|
|
void AecDbEarthWormFitting::Transformby(AcDbVoidPtrArray& arDraw2d, const AcGePoint3d& ptPos,const AcGeVector3d& vtDir)
|
|
{
|
|
AcGeVector3d vtMove = ptPos.asVector();
|
|
AcGeMatrix3d xformM, xformR;
|
|
xformM.setToTranslation(vtMove);
|
|
|
|
AcGeVector3d vtNorm = AcGeVector3d::kXAxis.crossProduct(vtDir);
|
|
double dRot = AcGeVector3d::kXAxis.angleTo(vtDir, vtNorm);
|
|
xformR.setToRotation(dRot, vtNorm, ptPos);
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDbEntity* pEnt = NULL;
|
|
for(int i = 0;i < arDraw2d.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arDraw2d.at(i);
|
|
|
|
es = pEnt->transformBy(xformM);
|
|
es = pEnt->transformBy(xformR);
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::Transformby(AcDbBlockReference * pRef , const AcGePoint3d & ptPos , const AcGeVector3d & vtDir, bool b3D)
|
|
{
|
|
if (!pRef) return;
|
|
pRef->setPosition(ptPos);
|
|
double dRot = AcGeVector3d::kXAxis.angleTo(vtDir, AcGeVector3d::kZAxis);
|
|
pRef->setRotation(dRot);
|
|
if (!b3D)
|
|
{
|
|
}
|
|
else
|
|
{
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::GetDraw3dables(AcDbVoidPtrArray& arEntPtrs, bool bWriteBimInfo)
|
|
{
|
|
AcDb3dSolid* pSolid = CreateDraw3dSolid(1, bWriteBimInfo);
|
|
arEntPtrs.append(pSolid);
|
|
GetAddtionDraw3dSolid(arEntPtrs, bWriteBimInfo);
|
|
#if ARX > 17
|
|
AcDbVoidPtrArray arr;
|
|
GetSubDMeshClone(arr, bWriteBimInfo);
|
|
arEntPtrs.append(arr);
|
|
#endif
|
|
}
|
|
|
|
void AecDbEarthWormFitting::MakeVerSection2d(AcDb3dSolid* pSolid,int nSectionDrawStyle) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
//通风口符号
|
|
AcGePoint3d ptPos(0,0,0);
|
|
AcGeVector2d vtDir = AcGeVector2d::kXAxis;
|
|
AcGePoint2d ptSize;
|
|
double dVol = 0.0,momInertia[3],prodInertia[3],prinMoments[3],radiiGyration[3];
|
|
AcGePoint3d ptCen;
|
|
AcGeVector3d prinAxes[3];
|
|
AcDbExtents extents;
|
|
|
|
if ( nSectionDrawStyle == 1)//纵断 1
|
|
{
|
|
AcGeVector3d vtDir3d(vtDir.x,vtDir.y,0.0);
|
|
AcGeVector3d vtDir3dv = vtDir3d;
|
|
vtDir3dv.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGeMatrix3d xformV;
|
|
vtDir3dv.normalize();
|
|
xformV.setToTranslation(vtDir3dv * 0.5 * ptSize.y);
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->getMassProp(dVol,ptCen,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extents);
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptCen,vtDir3dv);
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
pSolid->getSection(plan,pRegion);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
//投影到中心面
|
|
AcGePlane planV;
|
|
planV.set(ptPos,vtDir3dv);
|
|
|
|
AcGePoint3d ptCen2 = ptCen.orthoProject(planV);
|
|
AcGeVector3d vtMove = ptCen2 - ptCen;
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtMove);
|
|
pRegion->transformBy(xformM);
|
|
|
|
//移动到最外边
|
|
pRegion->transformBy(xformV);
|
|
|
|
//翻转
|
|
AcGeMatrix3d xformR;
|
|
xformR.setToRotation(-PI / 2.0,vtDir3d,ptPos);
|
|
pRegion->transformBy(xformR);
|
|
|
|
AddToSection2dDraw(pRegion,1);
|
|
DELETE_PTR(pRegion);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pSolid != NULL)
|
|
{
|
|
MakeHorSection2d(pSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
/*void AecDbEarthWormFitting::MakeVerSection2d(AcDb3dSolid* pSolid,const AcGePoint3d& ptCen,int nSectionDrawStyle) const
|
|
{
|
|
assertReadEnabled();
|
|
//通风口符号
|
|
AcGePoint3d ptPos;
|
|
AcGeVector2d vtDir = AcGeVector2d::kXAxis;
|
|
AcGePoint2d ptSize;
|
|
double dVol = 0.0,momInertia[3],prodInertia[3],prinMoments[3],radiiGyration[3];
|
|
AcGeVector3d prinAxes[3];
|
|
AcDbExtents extents;
|
|
AcGePoint3d ptCen1;
|
|
|
|
if ( nSectionDrawStyle == 1)//纵断 1
|
|
{
|
|
AcGeVector3d vtDir3d(vtDir.x,vtDir.y,0.0);
|
|
AcGeVector3d vtDir3dv = vtDir3d;
|
|
vtDir3dv.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
AcGeMatrix3d xformV;
|
|
vtDir3dv.normalize();
|
|
xformV.setToTranslation(vtDir3dv * 0.5 * ptSize.y);
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pSolid->getMassProp(dVol,ptCen1,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extents);
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptCen,vtDir3dv);
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
pSolid->getSection(plan,pRegion);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
//投影到中心面
|
|
AcGePlane planV;
|
|
planV.set(ptPos,vtDir3dv);
|
|
|
|
AcGePoint3d ptCen2 = ptCen.orthoProject(planV);
|
|
AcGeVector3d vtMove = ptCen2 - ptCen;
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtMove);
|
|
pRegion->transformBy(xformM);
|
|
|
|
//移动到最外边
|
|
pRegion->transformBy(xformV);
|
|
|
|
//翻转
|
|
AcGeMatrix3d xformR;
|
|
xformR.setToRotation(-PI / 2.0,vtDir3d,ptPos);
|
|
pRegion->transformBy(xformR);
|
|
|
|
AddToSection2dDraw(pRegion,1);
|
|
DELETE_PTR(pRegion);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (pSolid != NULL)
|
|
{
|
|
MakeHorSection2d(pSolid);
|
|
}
|
|
}
|
|
}*/
|
|
|
|
void AecDbEarthWormFitting::AddToSection2dDraw(AcDbEntity* pComEnt,int nSectionDrawtyle) const
|
|
{
|
|
if (pComEnt == NULL)
|
|
return;
|
|
|
|
//assertWriteEnabled();
|
|
AcDbRegion* pRegAll = AcDbRegion::cast(pComEnt);
|
|
AcDbBlockReference *pRef = AcDbBlockReference::cast(pComEnt);
|
|
if (pRegAll != NULL)
|
|
{
|
|
AcDbVoidPtrArray arSubEntPtrs;
|
|
pRegAll->explode(arSubEntPtrs);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arSubEntPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arSubEntPtrs.at(i);
|
|
pEnt->setColorIndex( nSectionDrawtyle);
|
|
Add2DBuffer(pEnt);
|
|
}
|
|
}
|
|
else if (pRef)
|
|
{
|
|
pComEnt->setColorIndex( nSectionDrawtyle);
|
|
Add2DBuffer((AcDbBlockReference*)pComEnt->clone());
|
|
}
|
|
else
|
|
{
|
|
pComEnt->setColorIndex( nSectionDrawtyle);
|
|
Add2DBuffer(pComEnt);
|
|
}
|
|
// 放入插入点(节点造族中的定位线)
|
|
|
|
double dLeft(.5 * GetLen());
|
|
GetSpecialtyData()->GetAt(_T("dLeft"), dLeft);
|
|
|
|
AcGePoint3d ptCenter(dLeft, .0, .0);
|
|
AcDbLine *pPt = new AcDbLine(ptCenter, ptCenter + AcGeVector3d::kYAxis * .001);
|
|
pPt->setColorIndex(kXDataColor);//nSectionDrawtyle
|
|
|
|
//特殊颜色,以确定后期放扩展数据。 设置扩展数据导致实体和当前数据库绑定。
|
|
//如果现在设置扩展数据,用到这个族的图纸关闭后,再打开pPt关联的数据库失效,导致xdata()崩溃
|
|
//因此放到用的地方设置扩展数据!!!!!!!!!!!!!!!!!!!
|
|
/*
|
|
AecDbObjXDataMap map;
|
|
map.SetAt(_T("CenterPoint"), 1);
|
|
map.Write(pPt, _T("DIM_DATA"));
|
|
*/
|
|
Add2DBuffer(pPt);
|
|
}
|
|
|
|
void AecDbEarthWormFitting::MakeHorSection2d(AcDb3dSolid* pSolid) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (pSolid == NULL)
|
|
return;
|
|
|
|
AcDbVoidPtrArray arRegPtrs;
|
|
pSolid->explode(arRegPtrs);
|
|
|
|
AcGeVector3d vtNorm;
|
|
AcDbEntity* pEnt = NULL;
|
|
AcDbRegion* pRegAll = NULL;
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
|
|
for(int i = 0;i < arRegPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arRegPtrs.at(i);
|
|
|
|
AcDbRegion* pReg = AcDbRegion::cast(pEnt);
|
|
if (pReg != NULL)
|
|
{
|
|
pReg->getNormal(vtNorm);
|
|
if (vtNorm.isParallelTo(AcGeVector3d::kZAxis))
|
|
{
|
|
//投影到XY 面
|
|
AcGePlane plan;
|
|
pReg->getPlane(plan);
|
|
|
|
AcGePoint3d ptOnNN = plan.pointOnPlane();
|
|
AcGePoint3d ptOnXY = AcGePlane::kXYPlane.closestPointTo(ptOnNN);
|
|
|
|
AcGeVector3d vtMove = ptOnXY - ptOnNN;
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(vtMove);
|
|
es = pReg->transformBy(xform);
|
|
|
|
AddToSection2dDraw(pReg,0);
|
|
DELETE_PTR(pReg);
|
|
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pReg);
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::Draw3d(AcGiDraw &dc) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
#if ARX > 17
|
|
AcGiRegenType type(kAcGiStandardDisplay);
|
|
if (dc.GetCommonDraw())
|
|
type = dc.GetCommonDraw()->regenType();
|
|
DrawSubDMesh(dc, type == kAcGiStandardDisplay ? true : false);
|
|
#endif
|
|
|
|
if (m_pDraw3dSolid == NULL)
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
|
|
if (m_pDraw3dPipeLine == NULL)
|
|
m_pDraw3dPipeLine = CreateDraw3dPipeLine();
|
|
|
|
//if (m_pDraw3dSolid == NULL) return Acad::eOk;
|
|
|
|
if (dc.IsDragging())
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int nGsMarker = 1000;
|
|
|
|
//图层
|
|
AcDbObjectId idLay = dc.GetLayerId();
|
|
dc.SetLayer(layerId());
|
|
|
|
if (NULL != m_pDraw3dSolid)
|
|
{
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
dc.DrawEntity(*m_pDraw3dSolid);
|
|
}
|
|
|
|
if (NULL != m_pDraw3dPipeLine)
|
|
{
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
dc.DrawEntity(*m_pDraw3dPipeLine);
|
|
}
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int k = 0;k < m_arDraw3dPipeLine.length();k++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arDraw3dPipeLine.at(k);
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
dc.DrawEntity(*pEnt);
|
|
}
|
|
|
|
//绘制新的管线线缆和设备2017-12-1
|
|
BOOL bHide = 0;
|
|
for (int k = 0;k < m_arAddtionPtrs.length();k++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(k);
|
|
AecDbEwPipe* pPipeBase = AecDbEwPipe::cast(pEnt);
|
|
if (pPipeBase != NULL)//管线,线缆,管件
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwPipe"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
pPipeBase->Draw3d(dc);
|
|
}
|
|
|
|
AecDbEwFitting* pFitt = AecDbEwFitting::cast(pEnt);
|
|
if (pFitt != NULL)
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwFitting"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
pFitt->Draw3d(dc);
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwEquipment"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
pEqu->Draw3d(dc);
|
|
}
|
|
|
|
AecDbEwCable* pCable = AecDbEwCable::cast(pEnt);
|
|
if (pCable != NULL)
|
|
{
|
|
bHide = 0;
|
|
if ( m_mapXData.GetAt(_T("AecDbEwCable"),bHide) )
|
|
{
|
|
if (bHide)
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
pCable->Draw3d(dc);
|
|
}
|
|
}
|
|
|
|
dc.SetSelectionMarker(++nGsMarker);
|
|
dc.SetLayer(idLay);
|
|
|
|
DrawActiveXYZArrow(dc);
|
|
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
AecDbX3dGroup* pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->DrawInf(dc);
|
|
}
|
|
|
|
if (objectId().isValid())
|
|
{
|
|
double dLeft = 0.0;
|
|
if ( GetSpecialtyData()->GetAt(_T("dLeft"),dLeft) )
|
|
{
|
|
AcGePoint3d ptGe[2];
|
|
ptGe[0].set(dLeft,-20.0,0.0);
|
|
ptGe[1].set(dLeft,20.0,0.0);
|
|
|
|
AcDbLine ln(ptGe[0],ptGe[1]);
|
|
|
|
int nOld = dc.GetColor();
|
|
dc.SetColor(kYellow);
|
|
dc.DrawEntity(&ln);
|
|
dc.SetColor(nOld);
|
|
}
|
|
}
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
int AecDbEarthWormFitting::GetSectionDraw(const AcGePoint3d& ptFr,const AcGePoint3d& ptTo,const AcGeVector3d& vtViewDir,const AcGeVector3d& vtTo, AcDbVoidPtrArray& arRegionPtrs) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
int nCount = 0;
|
|
AcGePlane plan;
|
|
AcGeVector3d vtU = ptTo - ptFr;
|
|
|
|
Acad::ErrorStatus es;
|
|
plan.set(ptFr,vtU,vtViewDir);
|
|
|
|
AcGePlane plan2;
|
|
plan2.set( ptFr,vtTo);
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToPlaneToWorld(plan);
|
|
xform.invert();
|
|
|
|
if (m_pDraw3dSolid == NULL)
|
|
{
|
|
AcGiViewDraw dc(NULL,NULL);
|
|
Draw3d(dc);
|
|
}
|
|
|
|
AcDbExtents ext;
|
|
m_pDraw3dSolid->getGeomExtents(ext);
|
|
|
|
double dX = ext.maxPoint().x - ext.minPoint().x;
|
|
double dY = ext.maxPoint().y - ext.minPoint().y;
|
|
double dz = ext.maxPoint().z - ext.minPoint().z;
|
|
double dMaxL = __max(dX,dY);
|
|
dMaxL = __max(dMaxL,dz);
|
|
|
|
AcGePoint3d ptGe[5];
|
|
|
|
ptGe[0] = ptFr;
|
|
ptGe[1] = ptTo;
|
|
ptGe[2] = ptTo + vtTo;
|
|
ptGe[3] = ptFr + vtTo;
|
|
ptGe[4] = ptGe[0];
|
|
|
|
AcGeVector3d vtLook = vtViewDir;
|
|
|
|
//提取8个点
|
|
AcGePoint3d ptGeT[8];
|
|
AcGePoint3dArray arBoxPts;
|
|
|
|
ptGeT[0] = ext.minPoint();
|
|
|
|
ptGeT[1] = ptGeT[0];
|
|
ptGeT[1].x = ext.maxPoint().x;
|
|
|
|
ptGeT[2] = ptGeT[1];
|
|
ptGeT[2].y = ext.maxPoint().y;
|
|
|
|
ptGeT[3] = ptGeT[0];
|
|
ptGeT[3].y = ext.maxPoint().y;
|
|
|
|
for (int i = 0;i < 4;i++)
|
|
{
|
|
arBoxPts.append(ptGeT[i]);
|
|
ptGeT[i].z = ext.maxPoint().z;
|
|
arBoxPts.append(ptGeT[i]);
|
|
}
|
|
|
|
AcDbLine ln3d;
|
|
ln3d.setStartPoint(arBoxPts.first());
|
|
AcGePoint3d ptE = arBoxPts.first() + vtViewDir * 1.5;
|
|
ln3d.setEndPoint(ptE);
|
|
|
|
AecCoverBooleanOper::SortPoints(arBoxPts,&ln3d,true);
|
|
|
|
AcGePoint3d ptNear = arBoxPts.last();
|
|
AcGePoint3d ptFar = arBoxPts.first();
|
|
AcGePoint3d ptMid = MidPoint(ptNear,ptFar);
|
|
|
|
AcGeVector3d vtN2F = ptFar - ptNear;
|
|
vtN2F *= 0.6;
|
|
ptFar = ptMid + vtN2F;
|
|
ptNear = ptMid - vtN2F;
|
|
vtN2F *= 2.0;
|
|
|
|
AcGePlane planNear(ptNear,vtLook);
|
|
AcGePoint3d ptOnMin;
|
|
ptOnMin = planNear.closestPointTo(ptGe[0]);
|
|
|
|
//调整到Near面
|
|
AcGeVector3d vtM = ptOnMin - ptGe[0];
|
|
for (int k = 0;k < 5;k++)
|
|
{
|
|
ptGe[k] += vtM;
|
|
}
|
|
|
|
//Near-->Far 拉伸路径
|
|
AcDbLine lnPath;
|
|
lnPath.setStartPoint(ptGe[0]);
|
|
ptE = ptGe[0] + vtN2F;
|
|
lnPath.setEndPoint(ptE);
|
|
|
|
struct resbuf rb;
|
|
acedGetVar(_T("useri3"),&rb);
|
|
|
|
AcDbRegion* pRegionT = AecDbEarthWorm::CreatePolygonRegionOnly(ptGe,5);
|
|
if (pRegionT != NULL)
|
|
{
|
|
AcDb3dSolid* pSolidBox = new AcDb3dSolid;
|
|
if ( Acad::eOk == pSolidBox->extrudeAlongPath(pRegionT,&lnPath) )
|
|
{
|
|
pSolidBox->setColorIndex(kRed);
|
|
|
|
if (rb.resval.rint == 1358)//特定情况下
|
|
{
|
|
//TEST
|
|
AcDb3dSolid* pSolidBoxCn = (AcDb3dSolid*)pSolidBox->clone();
|
|
pSolidBoxCn->setColorIndex(kRed);
|
|
AddToModelSpace(pSolidBoxCn);
|
|
}
|
|
}
|
|
AcDb3dSolid* pSolidBoxCln = (AcDb3dSolid*)pSolidBox->clone();
|
|
|
|
AcDb3dSolid* pSolidCln = (AcDb3dSolid*)m_pDraw3dSolid->clone();
|
|
pSolidCln->booleanOper(AcDb::kBoolIntersect,pSolidBox);
|
|
pSolidCln->setRecordHistory(true);
|
|
OrthoProjected3DSolid(pSolidCln,plan,xform,arRegionPtrs);
|
|
|
|
AcDbVoidPtrArray arSolidPtrs;
|
|
GetAddtionDraw3dSolid(arSolidPtrs,false);
|
|
|
|
Acad::ErrorStatus esT;
|
|
AcDb3dSolid* pSolidT = NULL;
|
|
for (int k = 0;k < arSolidPtrs.length();k++)
|
|
{
|
|
pSolidT = (AcDb3dSolid*)arSolidPtrs.at(k);
|
|
|
|
pSolidBox = (AcDb3dSolid*)pSolidBoxCln->clone();
|
|
esT = pSolidT->booleanOper(AcDb::kBoolIntersect,pSolidBox);
|
|
pSolidT->setRecordHistory(true);
|
|
if (esT == Acad::eOk)
|
|
{
|
|
OrthoProjected3DSolid2(pSolidT,plan2,plan,xform,arRegionPtrs);
|
|
|
|
if (rb.resval.rint == 1358)//特定情况下
|
|
{
|
|
pSolidT->setColorIndex(kRed);
|
|
AddToModelSpace(pSolidT);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (rb.resval.rint == 1358)//特定情况下
|
|
{
|
|
//TEST
|
|
pSolidCln->setColorIndex(kRed);
|
|
AddToModelSpace(pSolidCln);
|
|
}
|
|
else
|
|
{
|
|
DELETE_PTR(pSolidCln);
|
|
}
|
|
DELETE_PTR(pRegionT);
|
|
DELETE_PTR(pSolidBox);
|
|
}
|
|
return arRegionPtrs.length();
|
|
|
|
//old version
|
|
AcDb3dSolid* pSolid = NULL;
|
|
AcDbRegion* pRegion = NULL;
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
pSolid = m_pDraw3dSolid;
|
|
if (pSolid != NULL)
|
|
{
|
|
es = pSolid->getSection(plan,pRegion);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
pRegion->transformBy(xform);
|
|
arRegionPtrs.append(pRegion);
|
|
nCount += 1;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
AcDb3dSolid* pSolidClone = (AcDb3dSolid*)pSolid->clone();
|
|
if (pSolidClone != NULL)
|
|
{
|
|
AcGePlane plan2;
|
|
plan2.set( ptFr,vtTo);
|
|
|
|
AcDb3dSolid* pNegHalfSolid = NULL;
|
|
es = pSolidClone->getSlice(plan2,false,pNegHalfSolid);//获取法向的结果
|
|
if (es == Acad::eOk)
|
|
{
|
|
AcGeMatrix3d xMove;
|
|
xMove.setToTranslation(vtTo);
|
|
|
|
plan2.transformBy(xMove);
|
|
|
|
es = pSolidClone->getSlice(plan2,true,pNegHalfSolid);
|
|
if (es == Acad::eOk)
|
|
{
|
|
if (pNegHalfSolid != NULL)
|
|
{
|
|
OrthoProjected3DSolid(pNegHalfSolid,plan,xform,arRegionPtrs);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pNegHalfSolid != NULL)
|
|
{
|
|
//pNegHalfSolid->setColorIndex(1);
|
|
//AddToModelSpace(pNegHalfSolid);
|
|
DELETE_PTR(pNegHalfSolid);
|
|
}
|
|
|
|
//pSolidClone->setColorIndex(kRed);
|
|
//AddToModelSpace(pSolidClone);
|
|
DELETE_PTR(pSolidClone);
|
|
}
|
|
return nCount;
|
|
}
|
|
|
|
void FindConnectCurve(const AcGePoint3d& ptFrom,AcDbVoidPtrArray& arCurPtrs,AcGePoint3dArray& arPts)
|
|
{
|
|
AcGePoint3d ptSta,ptEnd;
|
|
AcDbCurve* pCurve = NULL;
|
|
for (int i = 0;i < arCurPtrs.length();i++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs.at(i);
|
|
|
|
pCurve->getStartPoint(ptSta);
|
|
pCurve->getEndPoint(ptEnd);
|
|
|
|
if (ptSta.distanceTo(ptFrom) < 1.e-2) //找到
|
|
{
|
|
arPts.append(ptEnd);
|
|
arCurPtrs.removeAt(i);
|
|
|
|
//继续下一连接
|
|
FindConnectCurve(ptEnd,arCurPtrs,arPts);
|
|
break;
|
|
}
|
|
|
|
if (ptEnd.distanceTo(ptFrom) < 1.e-2)//找到
|
|
{
|
|
arPts.append(ptSta);
|
|
arCurPtrs.removeAt(i);
|
|
|
|
//继续下一连接
|
|
FindConnectCurve(ptSta,arCurPtrs,arPts);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
AcDb3dSolid* AecDbEarthWormFitting::CreateEarthWormHideBossAndHolder() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_sCrossSectionScr.Find(_T("RECT")) != -1)
|
|
{
|
|
int nHide = 1;
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.GetSpecialtyData()->SetAt(_T("HIDEBOSS"),nHide);
|
|
dbEW.GetSpecialtyData()->SetAt(_T("HIDEHDG"),nHide);
|
|
dbEW.SetCrossSectionScr(m_sCrossSectionScr);
|
|
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcGeLineSeg3d ln(m_ptFr,ptEnd);
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
AcDb3dSolid* pEwSolid = dbEW.CreateEarthWorm3DSeg(ln,pRegion);
|
|
if (pEwSolid != NULL)
|
|
{
|
|
return pEwSolid;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
STSection* pSection = GetShEwSection();
|
|
if (pSection != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcDbLine ln(m_ptFr,ptEnd);
|
|
AcGeLineSeg3d ln3d(m_ptFr,ptEnd);
|
|
|
|
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
|
|
pRoadLn->AppendCurveSeg(&ln);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
dbEW.SetSection(pSection->pReg, pSection->pt);
|
|
dbEW.SetBaseCurve(pRoadLn);
|
|
|
|
//dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT1,AS_MUNIT(pSection->dThick[0]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT2,AS_MUNIT(pSection->dThick[1]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT4,AS_MUNIT(pSection->dThick[2]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT5,AS_MUNIT(pSection->dThick[3]));
|
|
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
delete pRoadLn;
|
|
|
|
AcDb3dSolid* pEwSolid = dbEW.GetCreatPipe3dSolid();
|
|
if (pEwSolid != NULL)
|
|
{
|
|
return pEwSolid;
|
|
}
|
|
}
|
|
}
|
|
return NULL;
|
|
}
|
|
|
|
AcDb3dSolid* AecDbEarthWormFitting::Create3dSolidNoBossAndHolder() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
Acad::ErrorStatus es;
|
|
AcDb::BoolOperType bType;
|
|
|
|
AcDb3dSolid* pDraw3dSolid = NULL;
|
|
pDraw3dSolid = CreateEarthWormHideBossAndHolder();
|
|
if (pDraw3dSolid == NULL)
|
|
return NULL;
|
|
|
|
pDraw3dSolid->setColorIndex(kColorByLayer);
|
|
|
|
CString sName;
|
|
AcDb3dSolid* pSolid = NULL;
|
|
const AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pGroup->IsHide())
|
|
continue;
|
|
|
|
if ( pGroup->IsPipeLine() )
|
|
continue;
|
|
|
|
pGroup->GetName(sName);
|
|
if (sName.CompareNoCase(_T("开窗")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("开孔")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("变径")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("集水井")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("坡道")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("梯子")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
AcArray<X3dSolidRec> arRecs;
|
|
pGroup->GetX3dSolidRecs(arRecs);
|
|
|
|
int nCr = kColorByLayer;
|
|
for (int j = 0;j < arRecs.length();j++)
|
|
{
|
|
X3dSolidRec& rec = arRecs.at(j);
|
|
bType = rec.bType;
|
|
|
|
if (rec.bType == AcDb::kBoolIntersect)
|
|
{
|
|
if ( pGroup->IsPeelOffTheSkin() )
|
|
{
|
|
//剖开...
|
|
bType = AcDb::kBoolSubtract;
|
|
}
|
|
else
|
|
{
|
|
continue;//不处理
|
|
}
|
|
}
|
|
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
if ( pGroup->GetSpecialtyData()->GetAt(_T("COLOR"),nCr) )
|
|
{
|
|
if (pSolid != NULL)
|
|
pSolid->setColorIndex(nCr);
|
|
}
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pGroup->Transformby(pSolid);
|
|
|
|
if (Acad::eOk != (es = pDraw3dSolid->booleanOper(bType,pSolid )))
|
|
{
|
|
acutPrintf(_T("\nCreate from rec error:%d:%d"),i,es);
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return pDraw3dSolid;
|
|
}
|
|
|
|
int AecDbEarthWormFitting::GetInnerWallLine(int nRoomIndex,int nPos,AcGePoint3dArray& arLinePts) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePoint3d ptMid;
|
|
AcGePlane plan;
|
|
AcGeVector3d vtLookDir;
|
|
|
|
if (m_sCrossSectionScr.Find(_T("RECT")) != -1)
|
|
{
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(m_sCrossSectionScr);
|
|
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcGeLineSeg3d ln(m_ptFr,ptEnd);
|
|
|
|
int nRooms = dbEW.GetRoomCount();
|
|
if (nRoomIndex > -1 && nRoomIndex < nRooms)
|
|
{
|
|
ERoom room;
|
|
dbEW.GetRoom(nRoomIndex,room);
|
|
|
|
AcArray<ERoom> arRooms;
|
|
arRooms.append(room);
|
|
|
|
AecDbEarthWorm::TransformRegionPerpToLine(arRooms,ln);
|
|
room = arRooms.first();
|
|
|
|
ptMid = Mid(room.ptGe[0],room.ptGe[2]);
|
|
|
|
switch(nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kYAxis);// 垂直面
|
|
vtLookDir = AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kYAxis);// 垂直面
|
|
vtLookDir = -AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = AcGeVector3d::kYAxis;
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = -AcGeVector3d::kYAxis;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else//盾构管廊
|
|
{
|
|
STSection* pSection = GetShEwSection();
|
|
if (pSection != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcGePoint3d ptEnd = m_ptFr + m_vtDir * m_dLen;
|
|
AcDbLine ln(m_ptFr,ptEnd);
|
|
AcGeLineSeg3d ln3d(m_ptFr,ptEnd);
|
|
|
|
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
|
|
pRoadLn->AppendCurveSeg(&ln);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
|
|
dbEW.SetSection(pSection->pReg, pSection->pt);
|
|
dbEW.SetBaseCurve(pRoadLn);
|
|
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT1,AS_MUNIT(pSection->dThick[0]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT2,AS_MUNIT(pSection->dThick[1]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT4,AS_MUNIT(pSection->dThick[2]));
|
|
dbEW.GetSpecialtyData()->SetAt(KEY_THICKT5,AS_MUNIT(pSection->dThick[3]));
|
|
|
|
int nRooms = dbEW.GetRoomCount();
|
|
if (nRoomIndex > -1 && nRoomIndex < nRooms)
|
|
{
|
|
ERoom room;
|
|
dbEW.GetRoom(nRoomIndex,room);
|
|
|
|
AcArray<ERoom> arRooms;
|
|
arRooms.append(room);
|
|
|
|
AecDbEarthWorm::TransformRegionPerpToLine(arRooms,ln3d);
|
|
room = arRooms.first();
|
|
|
|
ptMid = Mid(room.ptGe[0],room.ptGe[2]);
|
|
|
|
switch(nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kYAxis);// 垂直面
|
|
vtLookDir = AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kYAxis);// 垂直面
|
|
vtLookDir = -AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = AcGeVector3d::kYAxis;
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = -AcGeVector3d::kYAxis;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
delete pRoadLn;//after delete
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
}
|
|
}
|
|
|
|
AcDb3dSolid* pSolidDraw = Create3dSolidNoBossAndHolder();
|
|
if (pSolidDraw != NULL)
|
|
{
|
|
AcDbRegion* pRegion = NULL;
|
|
pSolidDraw->getSection(plan,pRegion);
|
|
|
|
AcDbExtents ext;
|
|
pSolidDraw->getGeomExtents(ext);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
pRegion->setColorIndex(kRed);
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pRegion->explode(arCurPtrs);
|
|
|
|
//AddToModelSpace(pRegion);
|
|
DELETE_PTR(pRegion);
|
|
|
|
//去掉两头的线,使之开
|
|
AcDbXline ln;
|
|
ln.setBasePoint(ptMid);
|
|
ln.setUnitDir(AcGeVector3d::kXAxis);
|
|
|
|
AcDbVoidPtrArray arCurPtrs2;
|
|
|
|
//提纯curve
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arCurPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arCurPtrs.at(i);
|
|
AcDbRegion* pReg = AcDbRegion::cast(pEnt);
|
|
if (pReg != NULL)
|
|
{
|
|
pReg->explode(arCurPtrs2);
|
|
DELETE_PTR(pReg);
|
|
}
|
|
else
|
|
{
|
|
arCurPtrs2.append(pEnt);
|
|
}
|
|
}
|
|
|
|
//找到最小距离的交线
|
|
AcDbRay ray;
|
|
ray.setBasePoint(ptMid);
|
|
ray.setUnitDir(vtLookDir);
|
|
|
|
//找最近ptMid 的线
|
|
double dRefMinDist = -1.0,dDist = 0.0;
|
|
AcGePoint3d pt;
|
|
AcGePoint3dArray arPts;
|
|
AcDbCurve* pCurve = NULL,*pCurveNear = NULL;
|
|
for (int i = 0;i < arCurPtrs2.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arCurPtrs2.at(i);
|
|
|
|
pCurve = AcDbCurve::cast(pEnt);
|
|
if (pCurve != NULL)
|
|
{
|
|
arPts.removeAll();
|
|
if ( Acad::eOk == ray.intersectWith(pCurve,AcDb::kOnBothOperands,arPts) )
|
|
{
|
|
for (int k = 0;k < arPts.length();k++)
|
|
{
|
|
pt = arPts.at(k);
|
|
|
|
dDist = ptMid.distanceTo(pt);
|
|
if (dRefMinDist < 1.e-3)
|
|
{
|
|
dRefMinDist = dDist;
|
|
pCurveNear = pCurve;
|
|
}
|
|
else
|
|
{
|
|
if (dRefMinDist - dDist > 1.e-3)
|
|
{
|
|
dRefMinDist = dDist;
|
|
pCurveNear = pCurve;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//去除左右竖线,防止获取外侧闭合线
|
|
AcGePoint3d ptSta,ptEnd;
|
|
for (int i = 0;i < arCurPtrs2.length();i++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs2.at(i);
|
|
|
|
pCurve->getStartPoint(ptSta);
|
|
pCurve->getEndPoint(ptEnd);
|
|
|
|
if ( fabs(ptSta.x - ptEnd.x) < 1.e-2 && fabs(ptSta.x - ext.minPoint().x) < 1.e-2)//左侧垂线
|
|
{
|
|
arCurPtrs2.removeAt(i);
|
|
DELETE_PTR(pCurve);
|
|
i -= 1;
|
|
continue;
|
|
}
|
|
|
|
if ( fabs(ptSta.x - ptEnd.x) < 1.e-2 && fabs(ptSta.x - ext.maxPoint().x) < 1.e-2)//右侧垂线
|
|
{
|
|
arCurPtrs2.removeAt(i);
|
|
DELETE_PTR(pCurve);
|
|
i -= 1;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
//找连续的内墙壁线
|
|
if (pCurveNear != NULL)
|
|
{
|
|
int nPos = arCurPtrs2.find(pCurveNear);
|
|
if (nPos != -1)
|
|
arCurPtrs2.removeAt(nPos);
|
|
|
|
pCurveNear->getStartPoint(ptSta);
|
|
pCurveNear->getEndPoint(ptEnd);
|
|
DELETE_PTR(pCurveNear);
|
|
|
|
AcGePoint3dArray arPts1,arPts2;
|
|
AcDbVoidPtrArray arCurPtrs11,arCurPtrs22;
|
|
|
|
arPts1.append(ptSta);
|
|
arCurPtrs11.append(arCurPtrs2);
|
|
FindConnectCurve(ptSta,arCurPtrs11,arPts1);
|
|
|
|
arPts2.append(ptEnd);
|
|
arCurPtrs22.append(arCurPtrs2);
|
|
FindConnectCurve(ptEnd,arCurPtrs22,arPts2);
|
|
|
|
arPts1.reverse();
|
|
if (!arPts2.isEmpty())
|
|
arPts1.append(arPts2);
|
|
|
|
if (!arPts1.isEmpty())
|
|
arLinePts.append(arPts1);
|
|
|
|
FreeBuffer(0,arCurPtrs2);
|
|
}
|
|
}
|
|
DELETE_PTR(pSolidDraw);
|
|
}
|
|
return arLinePts.length();
|
|
}
|
|
|
|
STSection* AecDbEarthWormFitting::GetShEwSection() const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_sCrossSectionScr.Find(_T("RECT")) != -1)
|
|
{
|
|
return NULL;
|
|
}
|
|
|
|
AcGePoint3d pt;
|
|
m_mapXData.GetAt(_T("SECTIONPT"),pt);
|
|
|
|
CString sFullPath = FilePath::GetSysDir();
|
|
sFullPath.MakeLower();
|
|
sFullPath += _T("\\DGJM.sat");
|
|
|
|
STSection* pSection = new STSection;
|
|
pSection->pt = pt;
|
|
|
|
m_mapXData.GetAt(_T("SECTIONPT"),pt);
|
|
m_mapXData.GetAt(KEY_ADDTIONSCR,pSection->sAddtionScr);
|
|
|
|
CStdioFile file;
|
|
if (file.Open(sFullPath,CFile::modeCreate |CFile::modeWrite ))
|
|
{
|
|
CString sScr = m_sCrossSectionScr;
|
|
int nPos = m_sCrossSectionScr.Find(_T("<ELAGN:") );
|
|
if (nPos != -1)
|
|
{
|
|
sScr = m_sCrossSectionScr.Mid(0,nPos);
|
|
}
|
|
file.WriteString(sScr);
|
|
file.Close();
|
|
|
|
CString sX,sY;
|
|
CString sPt = m_sCrossSectionScr.Mid(nPos);
|
|
sPt.TrimLeft(_T("<ELAGN:"));
|
|
sPt.TrimRight(_T(">"));
|
|
nPos = sPt.Find(_T(','));
|
|
if (nPos != -1)
|
|
{
|
|
CStringArray arInfo;
|
|
CoreTools::SplitStrintToArray(sPt,arInfo,_T(','));
|
|
|
|
if (arInfo.GetSize() >= 2)
|
|
{
|
|
sX = arInfo.GetAt(0);
|
|
sY = arInfo.GetAt(1);
|
|
pSection->pt.set(_ttof(sX),_ttof(sY),0.0);
|
|
|
|
if (arInfo.GetSize() >= 6)
|
|
{
|
|
pSection->dThick[0] = _ttof(arInfo.GetAt(2));
|
|
pSection->dThick[1] = _ttof(arInfo.GetAt(3));
|
|
pSection->dThick[2] = _ttof(arInfo.GetAt(4));
|
|
pSection->dThick[3] = _ttof(arInfo.GetAt(5));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CString sThickFile = FilePath::GetSysDir();
|
|
sThickFile.MakeLower();
|
|
sThickFile += _T("\\DGJM.ext");
|
|
|
|
CString sLine;
|
|
CStdioFile filet;
|
|
if (filet.Open(sThickFile,CFile::modeRead | CFile::typeText))
|
|
{
|
|
sLine = _T("");
|
|
filet.ReadString(sLine);
|
|
|
|
sLine.TrimRight(_T('\n'));
|
|
CStringArray arInfo;
|
|
CoreTools::SplitStrintToArray(sLine,arInfo,_T(','));
|
|
|
|
if (arInfo.GetSize() >= 6)
|
|
{
|
|
pSection->dThick[0] = _ttof(arInfo.GetAt(2));
|
|
pSection->dThick[1] = _ttof(arInfo.GetAt(3));
|
|
pSection->dThick[2] = _ttof(arInfo.GetAt(4));
|
|
pSection->dThick[3] = _ttof(arInfo.GetAt(5));
|
|
}
|
|
filet.Close();
|
|
}
|
|
}
|
|
}
|
|
|
|
pSection->pReg = NULL;
|
|
|
|
AcDbVoidPtrArray arBodyPtrs;
|
|
if ( Acad::eOk == AcDbBody::acisIn(sFullPath,arBodyPtrs) )
|
|
{
|
|
if (arBodyPtrs.length() > 0)
|
|
{
|
|
AcDbEntity* pEnt = (AcDbEntity*)arBodyPtrs.first();
|
|
AcDbRegion* pRegion = AcDbRegion::cast(pEnt);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
pSection->pReg = pRegion;
|
|
}
|
|
}
|
|
}
|
|
return pSection;
|
|
}
|
|
|
|
int AecDbEarthWormFitting::GetInnerWallLine(LPCTSTR pszGUID,int nRoomIndex,int nPos,AcGePoint3dArray& arLinePts) const
|
|
{
|
|
AecDbX3dGroup* pGroup = GetX3dGroup(pszGUID);
|
|
if (pGroup != NULL)
|
|
{
|
|
pGroup->GetInnerWallLine(nRoomIndex,nPos,arLinePts);
|
|
}
|
|
return arLinePts.length();
|
|
}
|
|
|
|
//加厚用
|
|
int AecDbEarthWormFitting::GetOutWallLine(int nPos,AcGePoint3dArray& arLinePts) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
AcGePlane plan;
|
|
AcGeVector3d vtLookDir;
|
|
|
|
AcGePoint3d ptMid(0.5,0,0);
|
|
switch(nPos)
|
|
{
|
|
case 0://左
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);
|
|
vtLookDir = AcGeVector3d::kYAxis;
|
|
break;
|
|
}
|
|
case 1://右
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);
|
|
vtLookDir = -AcGeVector3d::kYAxis;
|
|
break;
|
|
}
|
|
case 2://底
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kYAxis);
|
|
vtLookDir = -AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//有倒虹,以底面为准
|
|
//有变径,以左右为准
|
|
//倒虹起到主约束作用
|
|
AcDb3dSolid* pSolidMain = Create3dSolidNoGLBJ();
|
|
if (pSolidMain != NULL)
|
|
{
|
|
AcDbRegion* pRegion = NULL;
|
|
pSolidMain->getSection(plan,pRegion);
|
|
|
|
AcDbExtents ext;
|
|
pSolidMain->getGeomExtents(ext);
|
|
|
|
if (pRegion != NULL)
|
|
{
|
|
pRegion->setColorIndex(kRed);
|
|
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pRegion->explode(arCurPtrs);
|
|
|
|
//AddToModelSpace(pRegion);
|
|
DELETE_PTR(pRegion);
|
|
|
|
//去掉两头的线,使之开
|
|
AcDbXline ln;
|
|
ln.setBasePoint(ptMid);
|
|
ln.setUnitDir(AcGeVector3d::kXAxis);
|
|
|
|
AcDbVoidPtrArray arCurPtrs2;
|
|
|
|
//提纯curve
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int i = 0;i < arCurPtrs.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arCurPtrs.at(i);
|
|
AcDbRegion* pReg = AcDbRegion::cast(pEnt);
|
|
if (pReg != NULL)
|
|
{
|
|
pReg->explode(arCurPtrs2);
|
|
DELETE_PTR(pReg);
|
|
}
|
|
else
|
|
{
|
|
arCurPtrs2.append(pEnt);
|
|
}
|
|
}
|
|
|
|
//找到最小距离的交线
|
|
AcDbRay ray;
|
|
ray.setBasePoint(ptMid);
|
|
ray.setUnitDir(vtLookDir);
|
|
|
|
//找最远ptMid 的线
|
|
double dRefMinDist = -1.0,dDist = 0.0;
|
|
AcGePoint3d pt;
|
|
AcGePoint3dArray arPts;
|
|
AcDbCurve* pCurve = NULL,*pCurveNear = NULL;
|
|
for (int i = 0;i < arCurPtrs2.length();i++)
|
|
{
|
|
pEnt = (AcDbEntity*)arCurPtrs2.at(i);
|
|
|
|
pCurve = AcDbCurve::cast(pEnt);
|
|
if (pCurve != NULL)
|
|
{
|
|
arPts.removeAll();
|
|
if ( Acad::eOk == ray.intersectWith(pCurve,AcDb::kOnBothOperands,arPts) )
|
|
{
|
|
for (int k = 0;k < arPts.length();k++)
|
|
{
|
|
pt = arPts.at(k);
|
|
|
|
dDist = ptMid.distanceTo(pt);
|
|
if (dRefMinDist < 1.e-3)
|
|
{
|
|
dRefMinDist = dDist;
|
|
pCurveNear = pCurve;
|
|
}
|
|
else
|
|
{
|
|
if (dRefMinDist - dDist < 1.e-3)//取最远
|
|
{
|
|
dRefMinDist = dDist;
|
|
pCurveNear = pCurve;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//去除左右竖线,防止获取外侧闭合线
|
|
AcGePoint3d ptSta,ptEnd;
|
|
for (int i = 0;i < arCurPtrs2.length();i++)
|
|
{
|
|
pCurve = (AcDbCurve*)arCurPtrs2.at(i);
|
|
|
|
pCurve->getStartPoint(ptSta);
|
|
pCurve->getEndPoint(ptEnd);
|
|
|
|
if ( fabs(ptSta.x - ptEnd.x) < 1.e-2 && fabs(ptSta.x - ext.minPoint().x) < 1.e-2)//左侧垂线
|
|
{
|
|
arCurPtrs2.removeAt(i);
|
|
DELETE_PTR(pCurve);
|
|
i -= 1;
|
|
continue;
|
|
}
|
|
|
|
if ( fabs(ptSta.x - ptEnd.x) < 1.e-2 && fabs(ptSta.x - ext.maxPoint().x) < 1.e-2)//右侧垂线
|
|
{
|
|
arCurPtrs2.removeAt(i);
|
|
DELETE_PTR(pCurve);
|
|
i -= 1;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
//找连续的内墙壁线
|
|
if (pCurveNear != NULL)
|
|
{
|
|
int nPos = arCurPtrs2.find(pCurveNear);
|
|
if (nPos != -1)
|
|
arCurPtrs2.removeAt(nPos);
|
|
|
|
pCurveNear->getStartPoint(ptSta);
|
|
pCurveNear->getEndPoint(ptEnd);
|
|
DELETE_PTR(pCurveNear);
|
|
|
|
AcGePoint3dArray arPts1,arPts2;
|
|
AcDbVoidPtrArray arCurPtrs11,arCurPtrs22;
|
|
|
|
arPts1.append(ptSta);
|
|
arCurPtrs11.append(arCurPtrs2);
|
|
FindConnectCurve(ptSta,arCurPtrs11,arPts1);
|
|
|
|
arPts2.append(ptEnd);
|
|
arCurPtrs22.append(arCurPtrs2);
|
|
FindConnectCurve(ptEnd,arCurPtrs22,arPts2);
|
|
|
|
arPts1.reverse();
|
|
if (!arPts2.isEmpty())
|
|
arPts1.append(arPts2);
|
|
|
|
if (!arPts1.isEmpty())
|
|
arLinePts.append(arPts1);
|
|
|
|
FreeBuffer(0,arCurPtrs2);
|
|
}
|
|
}
|
|
DELETE_PTR(pSolidMain);
|
|
}
|
|
return arLinePts.length();
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::mergedwgInFields(AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
//CString sFileHeader = _T("shanghuasoft xxx 3d model file");
|
|
TCHAR* pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
CString sFileHeader;
|
|
if (pszTemp != NULL)
|
|
{
|
|
sFileHeader = pszTemp;
|
|
acutDelString(pszTemp);
|
|
|
|
if (sFileHeader.CompareNoCase(_T("shanghuasoft xxx 3d model file")) != 0)
|
|
{
|
|
acutPrintf(_T("\nshanghuasoft efe header read error!"));
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
}
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es =pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
if ( version > AecDbEarthWormFitting::kCurrentVersionNumber )
|
|
{
|
|
acedAlert(_T("族为新版本族,当前软件版本过低,打开新版本失败!"));
|
|
return (Acad::eMakeMeProxy) ;
|
|
}
|
|
|
|
pFiler->readPoint3d(&m_ptFr);
|
|
pFiler->readVector3d(&m_vtDir);
|
|
pFiler->readDouble(&m_dLen);
|
|
|
|
pFiler->readString(&pszTemp);
|
|
if (pszTemp != NULL)
|
|
{
|
|
//merge
|
|
if (m_sCrossSectionScr.IsEmpty())
|
|
m_sCrossSectionScr = pszTemp;
|
|
|
|
acutDelString(pszTemp);
|
|
}
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
//merge
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
//RemoveAllGroup(true);
|
|
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
pGroup = new AecDbX3dGroup;
|
|
pGroup->dwgInFields(pFiler);
|
|
m_arAddX3dGroupPtrs.append(pGroup);
|
|
#if ARX > 17
|
|
pGroup->CreateSubDMesh();
|
|
#endif
|
|
}
|
|
|
|
CreateFromSectionScr();
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
|
|
//新版本序列化,旧版本version == 1
|
|
//merge
|
|
//m_arAddtionPtrs.removeAll();
|
|
|
|
if ( version >= 2 ) //新版本数据
|
|
{
|
|
nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int n = 0;n < nLen;n++)
|
|
{
|
|
//rxclass
|
|
pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
|
|
if (pszTemp != NULL)
|
|
{
|
|
AcRxObject* pRxObj = acrxClassDictionary->at(pszTemp);
|
|
AcRxClass* pRxClass = AcRxClass::cast(pRxObj);
|
|
if (pRxClass != NULL)
|
|
{
|
|
pEnt = (AcDbEntity*)pRxClass->create();
|
|
pEnt->dwgInFields(pFiler);
|
|
m_arAddtionPtrs.append(pEnt);
|
|
}
|
|
acutDelString(pszTemp);
|
|
}
|
|
}
|
|
}
|
|
|
|
AecDbObjXDataMap xdata;
|
|
xdata.dwgInFields(pFiler);
|
|
m_mapXData.AppendFrom(&xdata);
|
|
|
|
int bHideEw = FALSE;
|
|
GetSpecialtyData()->GetAt(KEY_HIDEEW, bHideEw);
|
|
CleanEwSolid(bHideEw ? true : false );
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::dwgInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
//CString sFileHeader = _T("shanghuasoft xxx 3d model file");
|
|
TCHAR* pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
CString sFileHeader;
|
|
if (pszTemp != NULL)
|
|
{
|
|
sFileHeader = pszTemp;
|
|
acutDelString(pszTemp);
|
|
|
|
if (sFileHeader.CompareNoCase(_T("shanghuasoft xxx 3d model file")) != 0)
|
|
{
|
|
acutPrintf(_T("\nshanghuasoft efe header read error!"));
|
|
return Acad::eMakeMeProxy;
|
|
}
|
|
}
|
|
|
|
//----- Object version number needs to be read first
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es =pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
if ( version > AecDbEarthWormFitting::kCurrentVersionNumber )
|
|
{
|
|
acedAlert(_T("族为新版本族,当前软件版本过低,打开新版本失败!"));
|
|
return (Acad::eMakeMeProxy) ;
|
|
}
|
|
|
|
pFiler->readPoint3d(&m_ptFr);
|
|
pFiler->readVector3d(&m_vtDir);
|
|
pFiler->readDouble(&m_dLen);
|
|
|
|
pFiler->readString(&pszTemp);
|
|
if (pszTemp != NULL)
|
|
{
|
|
m_sCrossSectionScr = pszTemp;
|
|
acutDelString(pszTemp);
|
|
}
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
RemoveAllGroup(true);
|
|
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
pGroup = new AecDbX3dGroup;
|
|
pGroup->dwgInFields(pFiler);
|
|
m_arAddX3dGroupPtrs.append(pGroup);
|
|
#if ARX > 17
|
|
pGroup->CreateSubDMesh();
|
|
#endif
|
|
}
|
|
|
|
CreateFromSectionScr();
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
|
|
//新版本序列化,旧版本version == 1
|
|
m_arAddtionPtrs.removeAll();
|
|
|
|
if ( version >= 2 ) //新版本数据
|
|
{
|
|
nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int n = 0;n < nLen;n++)
|
|
{
|
|
//rxclass
|
|
pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
|
|
if (pszTemp != NULL)
|
|
{
|
|
AcRxObject* pRxObj = acrxClassDictionary->at(pszTemp);
|
|
AcRxClass* pRxClass = AcRxClass::cast(pRxObj);
|
|
if (pRxClass != NULL)
|
|
{
|
|
pEnt = (AcDbEntity*)pRxClass->create();
|
|
pEnt->dwgInFields(pFiler);
|
|
m_arAddtionPtrs.append(pEnt);
|
|
}
|
|
acutDelString(pszTemp);
|
|
}
|
|
}
|
|
}
|
|
|
|
m_mapXData.dwgInFields(pFiler);
|
|
|
|
int bHideEw = FALSE;
|
|
GetSpecialtyData()->GetAt(KEY_HIDEEW, bHideEw);
|
|
CleanEwSolid(bHideEw ? true : false );
|
|
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
assertReadEnabled () ;
|
|
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
if ( !pFiler->isKindOf(CMFCDbDwgFiler::desc()))
|
|
{
|
|
es = AecDbEntityBase::dwgOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
}
|
|
|
|
CString sFileHeader = _T("shanghuasoft xxx 3d model file");
|
|
pFiler->writeString((LPCTSTR)sFileHeader);
|
|
|
|
//----- Object version number needs to be saved first
|
|
if ( (es = pFiler->writeUInt32 (AecDbEarthWormFitting::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es);
|
|
|
|
pFiler->writePoint3d(m_ptFr);
|
|
pFiler->writeVector3d(m_vtDir);
|
|
pFiler->writeDouble(m_dLen);
|
|
|
|
pFiler->writeString((LPCTSTR)m_sCrossSectionScr);
|
|
|
|
Adesk::Int32 nLen = m_arAddX3dGroupPtrs.length();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for(int i = 0;i < nLen;i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
pGroup->dwgOutFields(pFiler);
|
|
}
|
|
|
|
nLen = m_arAddtionPtrs.length();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int n = 0;n < nLen;n++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(n);
|
|
//rxclass
|
|
pFiler->writeString(pEnt->isA()->name());
|
|
pEnt->dwgOutFields(pFiler);
|
|
}
|
|
|
|
m_mapXData.dwgOutFields(pFiler);
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::dxfInFields (AcDbDxfFiler* pFiler)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
//----- Read parent class information first.
|
|
Acad::ErrorStatus es = AecDbEntityBase::dxfInFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es) ;
|
|
|
|
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::dxfOutFields(AcDbDxfFiler* pFiler) const
|
|
{
|
|
assertReadEnabled () ;
|
|
//----- Save parent class information first.
|
|
Acad::ErrorStatus es = AecDbEntityBase::dxfOutFields (pFiler) ;
|
|
if ( es != Acad::eOk )
|
|
return (es);
|
|
|
|
|
|
|
|
return (pFiler->filerStatus ());
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::copyFrom(const AcRxObject* pSrc)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecDbEarthWormFitting* pFit = AecDbEarthWormFitting::cast(pSrc);
|
|
if (pFit != NULL)
|
|
{
|
|
m_dLen = pFit->m_dLen;
|
|
m_ptFr = pFit->m_ptFr;
|
|
m_vtDir = pFit->m_vtDir;
|
|
m_sCrossSectionScr = pFit->m_sCrossSectionScr;
|
|
|
|
AecDbX3dGroup* pGroup = NULL,*pGroupNew = NULL;
|
|
for (int i = 0;i < pFit->m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = pFit->m_arAddX3dGroupPtrs.at(i);
|
|
pGroupNew = new AecDbX3dGroup(*pGroup);
|
|
m_arAddX3dGroupPtrs.append(pGroupNew);
|
|
}
|
|
|
|
m_arAddtionPtrs.removeAll();
|
|
if (!pFit->m_arAddtionPtrs.isEmpty())
|
|
{
|
|
m_arAddtionPtrs.append(pFit->m_arAddtionPtrs);
|
|
}
|
|
m_mapXData.CopyFrom(&pFit->m_mapXData);
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
extern void Get3dSolidOutSideFaces(AcDb3dSolid* pSolid,AcGePoint3dArray& arPts);
|
|
extern void Get3dSolidOutSideFacesEx(AcDb3dSolid* pSolid,AcGePoint3dArray& arPts);
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::subGetOsnapPoints( AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
AcGePoint3dArray arPts1;
|
|
AcGePoint3dArray arPts2;
|
|
m_pDraw3dSolid->getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,arPts1,geomIds);
|
|
|
|
if (arPts1.isEmpty())
|
|
{
|
|
//通过边界分析
|
|
AcDbIntArray osnapModes;
|
|
AcDbIntArray geomIds;
|
|
m_pDraw3dSolid->getGripPoints(arPts1,osnapModes,geomIds);
|
|
}
|
|
|
|
AcDbEntity* pEntT = NULL;
|
|
for (int k = 0;k < m_arAddtionPtrs.length();k++)
|
|
{
|
|
pEntT = (AcDbEntity*)m_arAddtionPtrs.at(k);
|
|
pEntT->getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,arPts1,geomIds);
|
|
}
|
|
|
|
if (!arPts2.isEmpty())
|
|
{
|
|
arPts1.append(arPts2);
|
|
}
|
|
|
|
snapPoints.append(arPts1);
|
|
#if ARX > 17
|
|
CString rType(_T(""));
|
|
for (int i = 0; i < m_arAddX3dGroupPtrs.length(); ++i)
|
|
{
|
|
AecDbX3dGroup *pGrp(m_arAddX3dGroupPtrs[i]);
|
|
if (!pGrp) continue;
|
|
if (!pGrp->GetSpecialtyData()->GetAt(_T("RevitType"), rType)) continue;
|
|
|
|
if (isBuildingJs(rType))
|
|
{
|
|
AcArray<AcGeLineSeg3d> arr;
|
|
AcDbEntity *pEnt = m_arAddX3dGroupPtrs[i]->CreateSubDMesh(&arr);
|
|
for (int j = 0; j < arr.length(); j++)
|
|
{
|
|
AcDbLine ln(arr[j].startPoint(), arr[j].endPoint());
|
|
ln.getOsnapPoints(
|
|
osnapMode
|
|
, gsSelectionMark
|
|
, pickPoint
|
|
, lastPoint
|
|
, viewXform
|
|
, snapPoints
|
|
, geomIds);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::subIntersectWith( const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pDraw3dSolid != NULL && pEnt != NULL)
|
|
{
|
|
pEnt->intersectWith(m_pDraw3dSolid,intType,points,thisGsMarker,otherGsMarker);
|
|
|
|
AcDbEntity* pEntT = NULL;
|
|
for (int k = 0;k < m_arAddtionPtrs.length();k++)
|
|
{
|
|
pEntT = (AcDbEntity*)m_arAddtionPtrs.at(k);
|
|
pEnt->intersectWith(pEntT,intType,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::subIntersectWith( const AcDbEntity* pEnt,
|
|
AcDb::Intersect intType,
|
|
const AcGePlane& projPlane,
|
|
AcGePoint3dArray& points,
|
|
INT_PTR thisGsMarker,
|
|
INT_PTR otherGsMarker) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
pEnt->intersectWith(m_pDraw3dSolid,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
|
|
AcDbEntity* pEntT = NULL;
|
|
for (int k = 0;k < m_arAddtionPtrs.length();k++)
|
|
{
|
|
pEntT = (AcDbEntity*)m_arAddtionPtrs.at(k);
|
|
pEnt->intersectWith(pEntT,intType,projPlane,points,thisGsMarker,otherGsMarker);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::subGetGeomExtents(AcDbExtents& extents) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (m_pDraw3dSolid == NULL)
|
|
m_pDraw3dSolid = CreateDraw3dSolid();
|
|
|
|
if (m_pDraw3dSolid == NULL)
|
|
return Acad::eOk;
|
|
|
|
return m_pDraw3dSolid->getGeomExtents(extents);
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::subGetGripPoints( AcDbGripDataPtrArray& grips,
|
|
const double curViewUnitSize,
|
|
const int gripSize,
|
|
const AcGeVector3d& curViewDir,
|
|
const int bitflags) const
|
|
{
|
|
assertReadEnabled();
|
|
|
|
if (!objectId().isValid()) return Acad::eOk;
|
|
|
|
//自身夹点
|
|
CString sName,sTip;
|
|
AcGePoint3d ptOrg;
|
|
|
|
double dCmd = PixelToWcs(20);
|
|
|
|
AcDbGripData* pGripData = NULL;
|
|
const AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (pGroup->IsHide())
|
|
continue;
|
|
|
|
if ( pGroup->IsPipeLine() )
|
|
continue;
|
|
|
|
pGroup->GetName(sName);
|
|
if (sName.CompareNoCase(_T("开窗")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
ptOrg = pGroup->GetOrgPoint();
|
|
pGroup->Transformby(ptOrg);
|
|
|
|
//定位用
|
|
memset(&m_pGripAppData[2 * i],NULL,sizeof(AecGripData));
|
|
m_pGripAppData[2 * i].nIndex = 0;
|
|
m_pGripAppData[2 * i].ePos = eFlag;
|
|
m_pGripAppData[2 * i].ptGrip = ptOrg;
|
|
m_pGripAppData[2 * i].nColor = kWhite;
|
|
m_pGripAppData[2 * i].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(ptOrg);
|
|
pGripData->setAppData((void*)&m_pGripAppData[2 * i]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
|
|
sTip.Format(_T("点击定位造族组件<%s>记录"),sName);
|
|
_tcscpy(m_pGripAppData[2 * i].szTip,sTip);
|
|
_tcscpy(m_pGripAppData[2 * i].szID,pGroup->GetGUID());
|
|
grips.append(pGripData);
|
|
|
|
//修改用
|
|
ptOrg.x += dCmd;
|
|
memset(&m_pGripAppData[2 * i + 1],NULL,sizeof(AecGripData));
|
|
m_pGripAppData[2 * i + 1].nIndex = 0;
|
|
m_pGripAppData[2 * i + 1].ePos = eEdit;
|
|
m_pGripAppData[2 * i + 1].ptGrip = ptOrg;
|
|
m_pGripAppData[2 * i + 1].nColor = kWhite;
|
|
m_pGripAppData[0].pOwner = (AcDbEntity*)this;
|
|
|
|
pGripData = new AcDbGripData;
|
|
pGripData->setGripPoint(ptOrg);
|
|
pGripData->setAppData((void*)&m_pGripAppData[2 * i + 1]);
|
|
pGripData->setWorldDraw(AecGripCback::WorldDrawfunc);
|
|
pGripData->setToolTipFunc(AecGripCback::GripToolTipFunc);
|
|
|
|
sTip.Format(_T("点击修改造族组件<%s>记录"),sName);
|
|
_tcscpy(m_pGripAppData[2 * i + 1].szTip,sTip);
|
|
_tcscpy(m_pGripAppData[2 * i + 1].szID,pGroup->GetGUID());
|
|
grips.append(pGripData);
|
|
}
|
|
|
|
//管线设备夹点
|
|
const int nStbitflags = GRIPPT_RESP_FROM_EWFIT;
|
|
AcDbEntity* pEnt = NULL;
|
|
for (int k = 0;k < m_arAddtionPtrs.length();k++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(k);
|
|
AecDbEwPipe* pPipe = AecDbEwPipe::cast(pEnt);
|
|
if (pPipe != NULL)//管线,线缆,管件
|
|
{
|
|
//if ( pPipeBase->IsActive() )
|
|
{
|
|
pPipe->getGripPoints(grips,curViewUnitSize,gripSize,curViewDir,nStbitflags);
|
|
//return Acad::eOk;
|
|
}
|
|
}
|
|
|
|
/*AecDbEwFitting* pFitt = AecDbEwFitting::cast(pEnt);
|
|
if (pFitt != NULL)
|
|
{
|
|
if ( pFitt->IsActive() )
|
|
{
|
|
pFitt->getGripPoints(grips,curViewUnitSize,gripSize,curViewDir,nStbitflags);
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
}*/
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbEarthWormFitting::subMoveGripPointsAt(const AcDbVoidPtrArray& appData, const AcGeVector3d& offset, const int bitflags)
|
|
{
|
|
assertWriteEnabled();
|
|
|
|
AecGripData* pAppData = NULL;
|
|
AcDbIntArray arIndex;
|
|
|
|
if ( !appData.isEmpty() )
|
|
{
|
|
pAppData = (AecGripData*)appData.first();
|
|
}
|
|
else
|
|
{
|
|
return Acad::eOk;
|
|
}
|
|
|
|
AcGeVector3d vtOffset = offset;
|
|
if(Is2DView())
|
|
{
|
|
vtOffset = offset.orthoProject(GetUcsZvt());
|
|
}
|
|
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtOffset);
|
|
|
|
AcDbEntity* pEnt = NULL;
|
|
|
|
const AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arAddX3dGroupPtrs.length();i++)
|
|
{
|
|
pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
|
|
if ( _tcscmp(pAppData->szID,pGroup->GetGUID()) == 0 )
|
|
{
|
|
if (pAppData->ePos == eFlag)//定位
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
|
|
CKTCadUtility::SetSystemVar(_T("users5"),pAppData->szID);
|
|
|
|
CString sID;
|
|
CKTCadUtility::GetSystemVar(_T("users5"),sID);
|
|
|
|
if (sID.CompareNoCase(pAppData->szID) == 0)
|
|
{
|
|
acedPostCommand(_T("EW_JDDW "));
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
else if (pAppData->ePos == eEdit)
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
|
|
CKTCadUtility::SetSystemVar(_T("users5"),pAppData->szID);
|
|
|
|
CString sID;
|
|
CKTCadUtility::GetSystemVar(_T("users5"),sID);
|
|
|
|
if (sID.CompareNoCase(pAppData->szID) == 0)
|
|
{
|
|
acedPostCommand(_T("EW_JDMO "));
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
for (int k = 0;k < m_arAddtionPtrs.length();k++)
|
|
{
|
|
pEnt = (AcDbEntity*)m_arAddtionPtrs.at(k);
|
|
AecDbEwPipeBase* pPipeBase = AecDbEwPipeBase::cast(pEnt);
|
|
if (pPipeBase != NULL)//管线,线缆,管件
|
|
{
|
|
LPCTSTR pszGUID = pPipeBase->GetGUID();
|
|
if ( _tcscmp(pAppData->szID,pszGUID) == 0 )//定位
|
|
{
|
|
if (pAppData->ePos == eFlag)
|
|
{
|
|
acedPostCommand(_T("\x03"));
|
|
|
|
CKTCadUtility::SetSystemVar(_T("users5"),pAppData->szID);
|
|
|
|
CString sID;
|
|
CKTCadUtility::GetSystemVar(_T("users5"),sID);
|
|
if (sID.CompareNoCase(pAppData->szID) == 0)
|
|
{
|
|
acedPostCommand(_T("EW_JDDW "));
|
|
return Acad::eOk;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//旧的接口集合
|
|
AcArray<AecInterface> arInfs;
|
|
pPipeBase->GetInterface(arInfs);
|
|
|
|
//修改接口为新
|
|
pPipeBase->moveGripPointsAt(appData,vtOffset,GRIPPT_RESP_FROM_EWFIT);
|
|
|
|
//根据旧的接口传递变换
|
|
int nCount = arInfs.length();
|
|
for (int i = 0;i < arInfs.length();i++)
|
|
{
|
|
AecInterface& inf = arInfs.at(i);
|
|
TransformAssocInf(inf,xformM,pPipeBase);
|
|
}
|
|
return Acad::eOk;//结束
|
|
}
|
|
}
|
|
}
|
|
|
|
/*AecDbEwFitting* pFitt = AecDbEwFitting::cast(pEnt);
|
|
if (pFitt != NULL)
|
|
{
|
|
}
|
|
|
|
AecDbEwEquipment* pEqu = AecDbEwEquipment::cast(pEnt);
|
|
if (pEqu != NULL)
|
|
{
|
|
}*/
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
#if ARX > 17
|
|
void AecDbEarthWormFitting::GetSubDMeshClone(AcDbVoidPtrArray &arrPtrs, bool bWriteBim)
|
|
{
|
|
arrPtrs.removeAll();
|
|
for (int i = 0; i < m_arAddX3dGroupPtrs.length(); ++i)
|
|
{
|
|
AecDbX3dGroup *pGroup = m_arAddX3dGroupPtrs[i];
|
|
if (!pGroup) continue;
|
|
|
|
AcDbSubDMesh *pSubD = pGroup->CreateSubDMesh();
|
|
if (!pSubD) continue;
|
|
|
|
AcDbSubDMesh *p((AcDbSubDMesh*)pSubD->clone());
|
|
|
|
pGroup->GetSpecialtyData()->Write(p, _T("BIMDATA"));
|
|
|
|
arrPtrs.append(p);
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::GetSubDMeshClone2D(AcArray<AcGeLineSeg3d> &arrPtrs) const
|
|
{
|
|
arrPtrs.removeAll();
|
|
AcArray<AcGeLineSeg3d> arr;
|
|
for (int i = 0; i < m_arAddX3dGroupPtrs.length(); ++i)
|
|
{
|
|
AcDbSubDMesh *pSubD = m_arAddX3dGroupPtrs[i]->CreateSubDMesh(&arr);
|
|
if (pSubD)
|
|
arrPtrs.append(arr);
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::DrawSubDMesh(AcGiDraw &dc, bool b2D) const
|
|
{
|
|
AcArray<AcGeLineSeg3d> arr(0);
|
|
for (int i = 0; i < m_arAddX3dGroupPtrs.length(); ++i)
|
|
{
|
|
AcDbSubDMesh *pSubD = m_arAddX3dGroupPtrs[i]->CreateSubDMesh(b2D ? &arr : NULL);
|
|
|
|
if (!b2D)
|
|
{
|
|
if (pSubD)
|
|
{
|
|
dc.DrawEntity(pSubD);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
AcGeLineSeg3d ln;
|
|
for (int i = 0; i < arr.length(); ++i)
|
|
{
|
|
dc.DrawLine(arr[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
|
|
AcGePoint2d AecDbEarthWormFitting::GetEarthwormSize()
|
|
{
|
|
CString ss(_T(""));
|
|
GetCrossSectionScr(ss);
|
|
AecDbEarthWorm ew;
|
|
ew.SetCrossSectionScr(ss);
|
|
return ew.GetSize();
|
|
}
|
|
|
|
//AcDbBlockReference* AecDbEarthWormFitting::GetSubDMeshVer2d()
|
|
//{
|
|
//#if ARX <= 17
|
|
// return NULL;
|
|
//#else
|
|
//
|
|
// AcDbBlockReference *pRef(NULL);
|
|
//
|
|
// if (m_arAddX3dGroupPtrs.isEmpty()) return pRef;
|
|
// CString guid = m_arAddX3dGroupPtrs[0]->GetGUID();
|
|
// guid += _T("ver");
|
|
//
|
|
// AcDbObjectId id = findTableRecord(guid);
|
|
// if (id.isValid())
|
|
// {
|
|
// pRef = new AcDbBlockReference(AcGePoint3d::kOrigin, id);
|
|
// return pRef;
|
|
// }
|
|
//
|
|
// return pRef;
|
|
//
|
|
//#endif
|
|
//}
|
|
//
|
|
//AcDbBlockReference* AecDbEarthWormFitting::GetSubDMeshHor2d()
|
|
//{
|
|
//#if ARX <= 17
|
|
// return NULL;
|
|
//#else
|
|
//
|
|
// AcDbBlockReference *pRef(NULL);
|
|
// if (m_arAddX3dGroupPtrs.isEmpty()) return pRef;
|
|
//
|
|
// CString guid = m_arAddX3dGroupPtrs[0]->GetGUID();
|
|
// guid += _T("hor");
|
|
//
|
|
// AcDbObjectId id = findTableRecord(guid);
|
|
// if (id.isValid())
|
|
// {
|
|
// pRef = new AcDbBlockReference(AcGePoint3d::kOrigin, id);
|
|
// return pRef;
|
|
// }
|
|
//
|
|
// return pRef;
|
|
//#endif
|
|
//}
|
|
//
|
|
//AcDbBlockReference * AecDbEarthWormFitting::GetSubDMesh3d()
|
|
//{
|
|
//#if ARX <= 17
|
|
// return NULL;
|
|
//#else
|
|
//
|
|
// AcDbBlockReference *pRef(NULL);
|
|
// if (m_arAddX3dGroupPtrs.isEmpty()) return pRef;
|
|
//
|
|
// CString guid = m_arAddX3dGroupPtrs[0]->GetGUID();
|
|
// guid += _T("3d");
|
|
//
|
|
// AcDbObjectId id = findTableRecord(guid);
|
|
// if (id.isValid())
|
|
// {
|
|
// pRef = new AcDbBlockReference(AcGePoint3d::kOrigin, id);
|
|
// return pRef;
|
|
// }
|
|
//
|
|
// return pRef;
|
|
//#endif
|
|
//}
|
|
|
|
bool AecDbEarthWormFitting::HasGroupItem(LPCTSTR pszGUID)
|
|
{
|
|
for (int i = 0; i < m_arAddX3dGroupPtrs.length(); ++i)
|
|
{
|
|
AecDbX3dGroup *pGroup = m_arAddX3dGroupPtrs.at(i);
|
|
if (!pGroup) continue;
|
|
if (CString(pGroup->GetGUID()).CompareNoCase(pszGUID) == 0)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AecDbEarthWormFitting::CleanEwSolid(bool bClean)
|
|
{
|
|
assertWriteEnabled();
|
|
GetSpecialtyData()->SetAt(KEY_HIDEEW, bClean ? 1 : 0);
|
|
|
|
if (bClean)
|
|
{
|
|
if (m_pDbEWSolid != NULL)
|
|
{
|
|
m_pDbEWSolid->erase();
|
|
m_pDbEWSolid->close();
|
|
DELETE_PTR(m_pDbEWSolid);
|
|
}
|
|
if (m_pDraw3dSolid != NULL)
|
|
{
|
|
m_pDraw3dSolid->erase();
|
|
m_pDraw3dSolid->close();
|
|
DELETE_PTR(m_pDraw3dSolid);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbEarthWormFitting::InitSubDMeshTableRecord()
|
|
{
|
|
#if ARX > 17
|
|
CreateSubDMeshHor2DTableRecord();
|
|
CreateSubDMeshVer2DTableRecord();
|
|
CreateSubDMesh3DTableRecord();
|
|
#endif
|
|
}
|
|
|
|
void AecDbEarthWormFitting::CreateSubDMeshHor2DTableRecord()
|
|
{
|
|
#if ARX > 17
|
|
if (m_arAddX3dGroupPtrs.isEmpty()) return;
|
|
|
|
CString guid = m_arAddX3dGroupPtrs[0]->GetGUID();
|
|
guid += _T("hor");
|
|
|
|
AcDbObjectId id = findTableRecord(guid);
|
|
if (id.isValid()) return;
|
|
|
|
AcArray<AcGeLineSeg3d> ar2d;
|
|
GetSubDMeshClone2D(ar2d);
|
|
if (ar2d.isEmpty()) return;
|
|
id = makeTableRecord(ar2d, guid);
|
|
#endif
|
|
}
|
|
|
|
void AecDbEarthWormFitting::CreateSubDMeshVer2DTableRecord()
|
|
{
|
|
#if ARX > 17
|
|
if (m_arAddX3dGroupPtrs.isEmpty()) return;
|
|
|
|
CString guid = m_arAddX3dGroupPtrs[0]->GetGUID();
|
|
guid += _T("ver");
|
|
|
|
AcDbObjectId id = findTableRecord(guid);
|
|
if (id.isValid()) return;
|
|
|
|
//通风口符号
|
|
AcGePoint3d ptPos(0, 0, 0);
|
|
AcGeVector2d vtDir = AcGeVector2d::kXAxis;
|
|
AcGePoint2d ptSize;
|
|
AcGePoint3d ptCen;
|
|
AcGeVector3d prinAxes[3];
|
|
AcDbExtents extents;
|
|
|
|
AcArray<AcGeLineSeg3d> ar2d;
|
|
GetSubDMeshClone2D(ar2d);
|
|
if (ar2d.isEmpty()) return;
|
|
|
|
AcDbExtents ext, extAll;
|
|
for (int i = 0; i < ar2d.length(); ++i)
|
|
{
|
|
AcGeLineSeg3d ln(ar2d[i]);
|
|
extAll.addPoint(ln.startPoint());
|
|
extAll.addPoint(ln.endPoint());
|
|
}
|
|
|
|
ptCen = Mid(extAll.minPoint(), extAll.maxPoint());
|
|
|
|
AcGeVector3d vtDir3d(vtDir.x, vtDir.y, 0.0);
|
|
AcGeVector3d vtDir3dv = vtDir3d;
|
|
vtDir3dv.rotateBy(PI / 2.0, AcGeVector3d::kZAxis);
|
|
|
|
AcGeMatrix3d xformV;
|
|
vtDir3dv.normalize();
|
|
xformV.setToTranslation(vtDir3dv * 0.5 * ptSize.y);
|
|
|
|
AcGePlane plan;
|
|
plan.set(ptCen, vtDir3dv);
|
|
|
|
AcGePlane planV;
|
|
planV.set(ptPos, vtDir3dv);
|
|
|
|
AcGePoint3d ptCen2 = ptCen.orthoProject(planV);
|
|
AcGeVector3d vtMove = ptCen2 - ptCen;
|
|
AcGeMatrix3d xformM;
|
|
xformM.setToTranslation(vtMove);
|
|
|
|
AcGeMatrix3d xformR;
|
|
xformR.setToRotation(-PI / 2.0, vtDir3d, ptPos);
|
|
|
|
for (int i = 0; i < ar2d.length(); ++i)
|
|
{
|
|
AcGeLineSeg3d &ln(ar2d[i]);
|
|
ln.transformBy(xformM);
|
|
ln.transformBy(xformV);
|
|
ln.transformBy(xformR);
|
|
}
|
|
id = makeTableRecord(ar2d, guid);
|
|
#endif
|
|
}
|
|
|
|
void AecDbEarthWormFitting::CreateSubDMesh3DTableRecord()
|
|
{
|
|
#if ARX > 17
|
|
if (m_arAddX3dGroupPtrs.isEmpty()) return;
|
|
|
|
CString guid = m_arAddX3dGroupPtrs[0]->GetGUID();
|
|
guid += _T("3d");
|
|
|
|
AcDbObjectId id = findTableRecord(guid);
|
|
if (id.isValid()) return;
|
|
|
|
AcDbVoidPtrArray ar3d;
|
|
GetSubDMeshClone(ar3d);
|
|
if (ar3d.isEmpty()) return;
|
|
id = makeTableRecord(ar3d, guid);
|
|
#endif
|
|
}
|
|
|
|
AcDbBlockReference * AecDbEarthWormFitting::GetSubDMeshReference(LPCTSTR pszName)
|
|
{
|
|
#if ARX <= 17
|
|
return NULL;
|
|
#else
|
|
if (m_arAddX3dGroupPtrs.isEmpty()) return NULL;
|
|
|
|
CString guid = m_arAddX3dGroupPtrs[0]->GetGUID();
|
|
guid += pszName;
|
|
|
|
AcDbObjectId id = findTableRecord(guid);
|
|
if (!id.isValid()) return NULL;
|
|
|
|
AcDbBlockReference *pRef = new AcDbBlockReference(AcGePoint3d::kOrigin, id);
|
|
return pRef;
|
|
#endif
|
|
}
|
|
|