3199 lines
70 KiB
C++
3199 lines
70 KiB
C++
#include "stdafx.h"
|
|
#include "AecDbX3dGroup.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "AecDbShEarthWorm.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "CoreTools.h"
|
|
|
|
extern CString IDCreate();
|
|
extern double PixelToWcs(int nPixel);
|
|
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt, AcDbDatabase* pDb = NULL, bool bClose = true);
|
|
extern void FindConnectCurve(const AcGePoint3d& ptFrom,AcDbVoidPtrArray& arCurPtrs,AcGePoint3dArray& arPts);
|
|
|
|
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);
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
Adesk::UInt32 AecDbX3dGroup::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;
|
|
|
|
AecDbX3dGroup::AecDbX3dGroup(void)
|
|
{
|
|
m_sGUID = IDCreate();
|
|
m_vtMove.set(0,0,0);
|
|
memset(m_dAxisRotats,0,sizeof(double) * MAX_AXISROTATS);
|
|
|
|
for (int i = 0;i < MAX_AXISROTATS;i++)
|
|
{
|
|
m_arVtAxis.append(AcGeVector3d::kIdentity);
|
|
}
|
|
m_ptOrg.set(0,0,0);
|
|
|
|
m_bActive = false; //活动状态
|
|
m_pSolidDraw = NULL;
|
|
m_nPeelOff = -1;
|
|
m_nInfActive = -1;
|
|
m_ptActiveInf.x = -1;
|
|
m_ptActiveInf.y = -1;
|
|
m_nSubIndex = -1;
|
|
m_pSolidDraw2 = NULL;
|
|
#if ARX > 17
|
|
m_pSubDMesh = NULL;
|
|
#endif
|
|
}
|
|
|
|
AecDbX3dGroup::AecDbX3dGroup(const AecDbX3dGroup& group)
|
|
{
|
|
m_sGUID = group.m_sGUID;
|
|
m_vtMove = group.m_vtMove;
|
|
memcpy(m_dAxisRotats,group.m_dAxisRotats,sizeof(double) * MAX_AXISROTATS);
|
|
m_arVtAxis.append(group.m_arVtAxis);
|
|
|
|
m_ptOrg = group.m_ptOrg;
|
|
|
|
m_bActive = group.m_bActive; //活动状态
|
|
m_pSolidDraw = NULL;
|
|
m_pSolidDraw2 = NULL;
|
|
|
|
m_nPeelOff = group.m_nPeelOff;
|
|
m_nInfActive = group.m_nInfActive;
|
|
m_ptActiveInf = group.m_ptActiveInf;
|
|
m_nSubIndex = group.m_nSubIndex;
|
|
m_sName = group.m_sName;
|
|
|
|
for (int i = 0;i < group.m_arX3dSolidRecs.length();i++)
|
|
{
|
|
X3dSolidRec rec = group.m_arX3dSolidRecs.at(i);
|
|
|
|
if (rec.pXSolid != NULL)
|
|
{
|
|
AcDbX3dSolid* pXSolid = rec.pXSolid;
|
|
rec.pXSolid = new AcDbX3dSolid(*pXSolid);
|
|
}
|
|
m_arX3dSolidRecs.append(rec);
|
|
}
|
|
|
|
AecDbX3dGroup* pNewGrp = NULL,*pGroup = NULL;
|
|
for (int k = 0;k < group.m_arSubX3DGroups.length();k++)
|
|
{
|
|
pGroup = group.m_arSubX3DGroups.at(k);
|
|
pNewGrp = new AecDbX3dGroup(*pGroup);
|
|
m_arSubX3DGroups.append(pNewGrp);
|
|
}
|
|
#if ARX > 17
|
|
m_pSubDMesh = NULL;
|
|
if (group.IsFrom3JS())
|
|
{
|
|
if (!m_arX3dSolidRecs.isEmpty())
|
|
{
|
|
m_arX3dSolidRecs[0].pXSolid->CreateSubDMeshByMemory();
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
AecDbX3dGroup::~AecDbX3dGroup(void)
|
|
{
|
|
for (int i = 0;i < m_arX3dSolidRecs.length();i++)
|
|
{
|
|
X3dSolidRec& rec = m_arX3dSolidRecs.at(i);
|
|
if (rec.pXSolid != NULL)
|
|
{
|
|
DELETE_PTR(rec.pXSolid);
|
|
}
|
|
}
|
|
|
|
for (int i = 0;i < m_arSubX3DGroups.length();i++)
|
|
{
|
|
AecDbX3dGroup* pGroup = m_arSubX3DGroups.at(i);
|
|
if (pGroup != NULL)
|
|
DELETE_PTR(pGroup);
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
#if ARX > 17
|
|
if (m_pSubDMesh)
|
|
{
|
|
m_pSubDMesh->erase();
|
|
m_pSubDMesh->close();
|
|
DELETE_PTR(m_pSubDMesh);
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void AecDbX3dGroup::SetName(LPCTSTR pszName)
|
|
{
|
|
m_sName = pszName;
|
|
}
|
|
|
|
void AecDbX3dGroup::GetName(CString& sName) const
|
|
{
|
|
sName = m_sName;
|
|
}
|
|
|
|
LPCTSTR AecDbX3dGroup::GetGUID() const
|
|
{
|
|
return (LPCTSTR)m_sGUID;
|
|
}
|
|
|
|
void AecDbX3dGroup::ReCreateGUID()
|
|
{
|
|
m_sGUID = IDCreate();
|
|
}
|
|
|
|
void AecDbX3dGroup::AddX3dSolidRec(X3dSolidRec& rec)
|
|
{
|
|
m_arX3dSolidRecs.append(rec);
|
|
}
|
|
|
|
bool AecDbX3dGroup::IsPipeLine() const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
AcGePoint3d pt;
|
|
if (sName.CompareNoCase(_T("管道")) == 0 ||
|
|
sName.CompareNoCase(_T("弯头")) == 0 ||
|
|
sName.CompareNoCase(_T("三通")) == 0 ||
|
|
sName.CompareNoCase(_T("四通")) == 0 )
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetInterface(AcArray<AecInterface>& arInfs) const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
AcGePoint3d pt;
|
|
if (sName.CompareNoCase(_T("管道")) == 0 ||
|
|
sName.CompareNoCase(_T("弯头")) == 0 ||
|
|
sName.CompareNoCase(_T("三通")) == 0 ||
|
|
sName.CompareNoCase(_T("四通")) == 0 )
|
|
{
|
|
for (int i = 0;i < m_arX3dSolidRecs.length();i++)
|
|
{
|
|
const X3dSolidRec& rec = m_arX3dSolidRecs.at(i);
|
|
|
|
//rxtxh
|
|
AcArray<AecInterface> arInf2;
|
|
if (rec.pXSolid != NULL)
|
|
{
|
|
rec.pXSolid->GetInterface(arInf2);
|
|
}
|
|
|
|
for( int ii = 0;ii < arInf2.length();ii++)
|
|
{
|
|
Transformby(arInf2.at(ii).ptPos);
|
|
Transformby(arInf2.at(ii).vtDir);
|
|
}
|
|
|
|
double dRot = 0.0;
|
|
CString sIndex;
|
|
AcGeMatrix3d xform;
|
|
|
|
AcArray<AcGeMatrix3d> arXforms;
|
|
for( int ii = 0;ii < arInf2.length();ii++)
|
|
{
|
|
sIndex.Format(_T("%d"),ii);
|
|
if (m_mapXData.GetAt(sIndex,dRot))
|
|
{
|
|
AecInterface& inf = arInf2.at(ii);
|
|
xform.setToIdentity();
|
|
xform.setToRotation(dRot,inf.vtDir,inf.ptPos);
|
|
arXforms.append(xform);
|
|
}
|
|
}
|
|
|
|
for( int ii = 0;ii < arInf2.length();ii++)
|
|
{
|
|
for (int j = 0;j < arXforms.length();j++)
|
|
{
|
|
AcGeMatrix3d& xform2 = arXforms.at(j);
|
|
|
|
arInf2.at(ii).ptPos.transformBy(xform2);
|
|
arInf2.at(ii).vtDir.transformBy(xform2);
|
|
}
|
|
}
|
|
|
|
if (!arInf2.isEmpty())
|
|
arInfs.append(arInf2);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetInterface(int nRow,int nCol,AecInterface& inf) const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("开孔")) == 0)
|
|
{
|
|
//来自CYXKKDlg 和 CYXKKDlg::GetX3dSolidRecs
|
|
double dlg_m_dL1;
|
|
double dlg_m_dL2;
|
|
double dlg_m_dL3;
|
|
int dlg_m_nShape;
|
|
int dlg_m_nPos;
|
|
BOOL dlg_m_bAllEw;
|
|
double dlg_m_dW1;
|
|
int dlg_m_idxRoom;
|
|
CString dlg_m_sCrossSectionScr;
|
|
int dlg_m_nH;
|
|
int dlg_m_nV;
|
|
double dlg_m_dHSpace;
|
|
double dlg_m_dVSpace;
|
|
BOOL dlg_m_bSpecThick;
|
|
double dlg_m_dSpecThick;
|
|
BOOL dlg_m_bAddHoleCase;
|
|
|
|
//序列化BIM数据
|
|
GetSpecialtyData()->GetAt(_T("m_dL1"),dlg_m_dL1);
|
|
GetSpecialtyData()->GetAt(_T("m_dL2"),dlg_m_dL2);
|
|
GetSpecialtyData()->GetAt(_T("m_dL3"),dlg_m_dL3);
|
|
GetSpecialtyData()->GetAt(_T("m_nShape"),dlg_m_nShape);
|
|
GetSpecialtyData()->GetAt(_T("m_nPos"),dlg_m_nPos);
|
|
GetSpecialtyData()->GetAt(_T("m_bAllEw"),dlg_m_bAllEw);
|
|
GetSpecialtyData()->GetAt(_T("m_dW1"),dlg_m_dW1);
|
|
GetSpecialtyData()->GetAt(_T("m_nH"),dlg_m_nH);
|
|
GetSpecialtyData()->GetAt(_T("m_nV"),dlg_m_nV);
|
|
GetSpecialtyData()->GetAt(_T("m_dHSpace"),dlg_m_dHSpace);
|
|
GetSpecialtyData()->GetAt(_T("m_dVSpace"),dlg_m_dVSpace);
|
|
GetSpecialtyData()->GetAt(_T("m_idxRoom"),dlg_m_idxRoom);
|
|
GetSpecialtyData()->GetAt(_T("m_bSpecThick"),dlg_m_bSpecThick);
|
|
GetSpecialtyData()->GetAt(_T("m_dSpecThick"),dlg_m_dSpecThick);
|
|
GetSpecialtyData()->GetAt(_T("m_bAddHoleCase"),dlg_m_bAddHoleCase);
|
|
GetSpecialtyData()->GetAt(_T("m_sCrossSectionScr"),dlg_m_sCrossSectionScr);
|
|
|
|
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
|
|
AecDbEarthWorm worm;
|
|
worm.SetCrossSectionScr(dlg_m_sCrossSectionScr);
|
|
worm.SetChamferInter(100.0);
|
|
|
|
ESection eType = eRect;
|
|
AcGePoint2dArray arDatas;
|
|
eType = worm.ExtractEarthWormScr(arDatas);
|
|
|
|
//外壁厚,内隔壁厚
|
|
double dOutW = 0.0,dIntW = 0.0;
|
|
if (arDatas.length() > 0)
|
|
{
|
|
dOutW = arDatas.last().x;
|
|
dIntW = arDatas.last().y;
|
|
}
|
|
|
|
//总高度
|
|
double dHeight = arDatas.first().y;
|
|
dHeight += 2 * arDatas.last().x;
|
|
|
|
//总宽度
|
|
double dWidth = 0.0;
|
|
for (int i = 0;i < arDatas.length()-1;i++)
|
|
{
|
|
dWidth += arDatas.at(i).x;
|
|
}
|
|
|
|
dWidth += (arDatas.length() - 2) * dIntW;
|
|
dWidth += dOutW * 2.0;
|
|
|
|
double dThick = dIntW;
|
|
AcGeVector3d vtZ,vtStep;
|
|
AcGePoint3d ptOrg;
|
|
|
|
AcArray<ERoom> arRooms;
|
|
ERoom room;
|
|
AcGePoint2d ptThick;
|
|
AcGeLineSeg3d ln(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0.0,0));
|
|
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
|
|
|
|
if (dlg_m_bAllEw)
|
|
{
|
|
if (dlg_m_nShape == 0)//矩形孔
|
|
{
|
|
switch(dlg_m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,0,dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,-1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,0,-dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,dWidth / 2.0 - 0.5 * dThick,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,-1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,-dWidth / 2.0 + 0.5 * dThick,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else//圆孔
|
|
{
|
|
switch(dlg_m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,0,dHeight / 2.0 - dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,-1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,0,-dHeight / 2.0 + dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,dWidth / 2.0 - 0.5 * dThick,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,-1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,-dWidth / 2.0 - 0.5 * dThick,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
room = arRooms.at(dlg_m_idxRoom);
|
|
|
|
if (dlg_m_nShape == 0)//矩形孔
|
|
{
|
|
switch(dlg_m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,(room.ptGe[2].y + room.ptGe[3].y) / 2.0,dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,-1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,(room.ptGe[2].y + room.ptGe[3].y) / 2.0,-dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = (dlg_m_idxRoom > 0 && dlg_m_idxRoom < arRooms.length()) ? dIntW : dOutW;
|
|
vtZ.set(0,1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0, room.ptGe[0].y + 0.5 * dThick,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = (dlg_m_idxRoom > 0 && dlg_m_idxRoom < arRooms.length()) ? dIntW : dOutW;
|
|
vtZ.set(0,-1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0, room.ptGe[1].y - 0.5 * dThick,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
return 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else//圆孔
|
|
{
|
|
switch(dlg_m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,(room.ptGe[2].y + room.ptGe[3].y) / 2.0,dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0,0,-1);
|
|
vtStep.set(0,1,0);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0,(room.ptGe[2].y + room.ptGe[3].y) / 2.0,-dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = (dlg_m_idxRoom > 0 && dlg_m_idxRoom < arRooms.length()) ? dIntW : dOutW;
|
|
vtZ.set(0,1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0, room.ptGe[0].y + 0.5 * dThick ,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = (dlg_m_idxRoom > 0 && dlg_m_idxRoom < arRooms.length()) ? dIntW : dOutW;
|
|
vtZ.set(0,-1,0);
|
|
vtStep.set(0,0,1);
|
|
ptOrg.set(dlg_m_dL2 + dlg_m_dL1 / 2.0, room.ptGe[1].y - 0.5 * dThick,-dHeight / 2.0 + dOutW + dlg_m_dL3 + dlg_m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
return 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dlg_m_bSpecThick)
|
|
{
|
|
dThick = dlg_m_dSpecThick;
|
|
}
|
|
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
AcGePoint3d ptNewOrg = ptOrg;
|
|
|
|
for(int i = 0;i < dlg_m_nH;i++)//列
|
|
{
|
|
ptNewOrg = ptOrg + i * AcGeVector3d::kXAxis * dlg_m_dHSpace;
|
|
for (int j = 0;j < dlg_m_nV;j++)//行
|
|
{
|
|
if (dlg_m_nShape == 0)//矩形孔
|
|
{
|
|
//外部套管 方管子LxWxtxH 示意
|
|
//if (dlg_m_bAddHoleCase)
|
|
{
|
|
if ( nCol == i && nRow == j)
|
|
{
|
|
inf.dSize1 = dlg_m_dL1;
|
|
inf.dSize2 = dlg_m_dW1;
|
|
inf.ptPos = ptNewOrg - vtZ * 0.5 * dThick;
|
|
inf.vtDir = vtZ;
|
|
|
|
Transformby(inf.ptPos);
|
|
Transformby(inf.vtDir);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//外部套管 圆管rxtxH
|
|
//if (dlg_m_bAddHoleCase)
|
|
{
|
|
if ( nCol == i && nRow == j)
|
|
{
|
|
inf.dSize1 = dlg_m_dL1;
|
|
inf.dSize2 = dlg_m_dL1;
|
|
inf.ptPos = ptNewOrg - vtZ * 0.5 * dThick;
|
|
inf.vtDir = vtZ;
|
|
|
|
Transformby(inf.ptPos);
|
|
Transformby(inf.vtDir);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
ptNewOrg += vtStep * dlg_m_dVSpace;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetInterface(int nIndex,AecInterface& inf) const
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
if ( GetInterface( arInfs ) )
|
|
{
|
|
if (nIndex > -1 && nIndex < arInfs.length())
|
|
{
|
|
inf = arInfs.at(nIndex);
|
|
if (nIndex == 0)
|
|
{
|
|
inf.vtDir;
|
|
}
|
|
return true;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
CPoint ptRW,ptPos;
|
|
GetInterfaceCount(ptRW);
|
|
|
|
ptPos.x = nIndex / ptRW.y;
|
|
ptPos.y = nIndex - ptPos.x * ptRW.y;
|
|
|
|
if ( GetInterface(ptPos.x,ptPos.y,inf) )
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetInterfaceCount(CPoint& ptRC) const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("开孔")) == 0)
|
|
{
|
|
int dlg_m_nH;
|
|
int dlg_m_nV;
|
|
|
|
GetSpecialtyData()->GetAt(_T("m_nH"),dlg_m_nH);
|
|
GetSpecialtyData()->GetAt(_T("m_nV"),dlg_m_nV);
|
|
|
|
ptRC.x = dlg_m_nV;
|
|
ptRC.y = dlg_m_nH;
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::SetActiveInf(const CPoint& ptRC)
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("开孔")) != 0)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (ptRC.x >= -1 && ptRC.y >= -1)
|
|
{
|
|
m_ptActiveInf = ptRC;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetActiveInf(CPoint& ptRC) const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("开孔")) != 0)
|
|
{
|
|
return false;
|
|
}
|
|
ptRC = m_ptActiveInf;
|
|
return true;
|
|
}
|
|
|
|
int AecDbX3dGroup::GetActiveInf() const
|
|
{
|
|
if (m_nInfActive == -1)
|
|
{
|
|
CPoint ptPos,ptRW;
|
|
if ( GetActiveInf(ptPos))
|
|
{
|
|
GetInterfaceCount(ptRW);
|
|
|
|
int nPos = ptPos.x * ptRW.y + ptPos.y;
|
|
return nPos;
|
|
}
|
|
return -1;
|
|
}
|
|
return m_nInfActive;
|
|
}
|
|
|
|
void AecDbX3dGroup::SetActiveInf(int nIndex)
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
int nDir = 0;
|
|
GetSpecialtyData()->GetAt(_T("Dir"),nDir);
|
|
|
|
if (nDir == 0)
|
|
nDir = 1;
|
|
else if (nDir == 1)
|
|
nDir = 0;
|
|
|
|
GetSpecialtyData()->SetAt(_T("Dir"),nDir);
|
|
return;
|
|
}
|
|
|
|
m_nInfActive = nIndex;
|
|
|
|
CPoint ptRW,ptPos;
|
|
if ( GetInterfaceCount(ptRW) )
|
|
{
|
|
ptPos.x = nIndex / ptRW.y;
|
|
ptPos.y = nIndex - ptPos.x * ptRW.y;
|
|
m_ptActiveInf = ptPos;
|
|
}
|
|
}
|
|
|
|
bool AecDbX3dGroup::RemoveAll3dSolidRec()
|
|
{
|
|
while(!m_arX3dSolidRecs.isEmpty())
|
|
{
|
|
X3dSolidRec& rec = m_arX3dSolidRecs.last();
|
|
if (rec.pXSolid != NULL)
|
|
{
|
|
//已经参与了bool运算,已经无效
|
|
DELETE_PTR(rec.pXSolid);
|
|
}
|
|
m_arX3dSolidRecs.removeLast();
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
|
|
return true;
|
|
}
|
|
|
|
int AecDbX3dGroup::GetRecCount() const
|
|
{
|
|
return m_arX3dSolidRecs.length();
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetX3dSolidRec(int nPos,X3dSolidRec& rec) const
|
|
{
|
|
if (nPos >= 0 && nPos < m_arX3dSolidRecs.length())
|
|
{
|
|
rec = m_arX3dSolidRecs.at(nPos);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetX3dSolidRecs(AcArray<X3dSolidRec>& arRecs) const
|
|
{
|
|
if (m_arX3dSolidRecs.length() > 0)
|
|
{
|
|
arRecs.append(m_arX3dSolidRecs);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AecDbX3dGroup::AddSubX3dGroup(AecDbX3dGroup* pGroup)
|
|
{
|
|
m_arSubX3DGroups.append(pGroup);
|
|
}
|
|
|
|
bool AecDbX3dGroup::RemoveAllSubX3dGroup()
|
|
{
|
|
while(m_arSubX3DGroups.length() > 0)
|
|
{
|
|
AecDbX3dGroup* pGroup = m_arSubX3DGroups.first();
|
|
DELETE_PTR(pGroup);
|
|
m_arSubX3DGroups.removeFirst();
|
|
}
|
|
return true;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetSubX3dGroup(int nPos,AecDbX3dGroup*& pGroup) const
|
|
{
|
|
if (nPos > -1 && nPos < m_arSubX3DGroups.length())
|
|
{
|
|
pGroup = m_arSubX3DGroups.at(nPos);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int AecDbX3dGroup::GetSubX3dGroupCount() const
|
|
{
|
|
return m_arSubX3DGroups.length();
|
|
}
|
|
|
|
void AecDbX3dGroup::SetOrgPoint(const AcGePoint3d& ptOrg)
|
|
{
|
|
m_ptOrg = ptOrg;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
AcGePoint3d AecDbX3dGroup::GetOrgPoint() const
|
|
{
|
|
return m_ptOrg;
|
|
}
|
|
|
|
AcGePoint3d AecDbX3dGroup::GetBasePoint() const
|
|
{
|
|
return m_ptOrg;// 待定
|
|
}
|
|
|
|
bool AecDbX3dGroup::SetAxis(int nIndex,const AcGeVector3d& vtAxis)
|
|
{
|
|
if (nIndex >= 0 && nIndex < MAX_AXISROTATS)
|
|
{
|
|
m_arVtAxis.setAt(nIndex,vtAxis);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetAxis(int nIndex,AcGeVector3d& vtAxis) const
|
|
{
|
|
if (nIndex >= 0 && nIndex < MAX_AXISROTATS)
|
|
{
|
|
vtAxis = m_arVtAxis.at(nIndex);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AecDbX3dGroup::SetHideShow()
|
|
{
|
|
bool bHide = IsHide();
|
|
SetHide(!bHide);
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
void AecDbX3dGroup::SetHide(bool bHide)
|
|
{
|
|
m_mapXData.SetAt(_T("Hide"),bHide ? 1 : 0);
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
bool AecDbX3dGroup::IsHide() const
|
|
{
|
|
int nVal = 0;
|
|
if ( m_mapXData.GetAt(_T("Hide"),nVal) )
|
|
{
|
|
return nVal > 0 ? true : false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
void AecDbX3dGroup::SetActive(bool bActive,int nSubIndex/* = -1*/)
|
|
{
|
|
m_bActive = bActive;
|
|
m_nSubIndex = nSubIndex;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
void AecDbX3dGroup::PeelOffTheSkin( int nPos )
|
|
{
|
|
m_nPeelOff = nPos;
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
bool AecDbX3dGroup::IsPeelOffTheSkin() const
|
|
{
|
|
return m_nPeelOff > -1 ? true : false;
|
|
}
|
|
|
|
void AecDbX3dGroup::AddMove(const AcGeVector3d& vtMove)
|
|
{
|
|
m_vtMove += vtMove;
|
|
|
|
#if ARX > 17
|
|
if (IsFrom3JS())
|
|
{
|
|
CreateSubDMesh();
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
void AecDbX3dGroup::AddMove(const AcGeMatrix3d& xMirror)
|
|
{
|
|
m_vtMove += xMirror.translation();//>??>
|
|
#if ARX > 17
|
|
if (IsFrom3JS())
|
|
{
|
|
CreateSubDMesh();
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
void AecDbX3dGroup::ResetMove()
|
|
{
|
|
m_vtMove = AcGeVector3d::kIdentity;
|
|
|
|
#if ARX > 17
|
|
if (IsFrom3JS())
|
|
{
|
|
CreateSubDMesh();
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
void AecDbX3dGroup::AddRotate(int nAxisIndex,double dRot)
|
|
{
|
|
if (nAxisIndex >= 0 && nAxisIndex <= m_arVtAxis.length() )
|
|
{
|
|
m_dAxisRotats[nAxisIndex] += dRot;
|
|
#if ARX > 17
|
|
if (IsFrom3JS())
|
|
{
|
|
CreateSubDMesh();
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
}
|
|
|
|
void AecDbX3dGroup::AddInfRotate(int nActiveInf,double dRot)
|
|
{
|
|
CString sInf;
|
|
sInf.Format(_T("%d"),nActiveInf);
|
|
|
|
double dRotOld = 0.0;
|
|
if (m_mapXData.GetAt(sInf,dRotOld))
|
|
{
|
|
dRot += dRotOld;
|
|
}
|
|
m_mapXData.SetAt(sInf,dRot);
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
void AecDbX3dGroup::ResetRotate(int nAxisIndex)
|
|
{
|
|
if (nAxisIndex >= 0 && nAxisIndex < m_arVtAxis.length())
|
|
{
|
|
m_dAxisRotats[nAxisIndex] = 0.0;
|
|
}
|
|
|
|
if (nAxisIndex == -1)
|
|
{
|
|
memset(m_dAxisRotats,0,sizeof(double) * MAX_AXISROTATS);
|
|
}
|
|
#if ARX > 17
|
|
if (IsFrom3JS())
|
|
{
|
|
CreateSubDMesh();
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
m_pSolidDraw->erase();
|
|
m_pSolidDraw->close();
|
|
DELETE_PTR(m_pSolidDraw);
|
|
}
|
|
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
m_pSolidDraw2->erase();
|
|
m_pSolidDraw2->close();
|
|
DELETE_PTR(m_pSolidDraw2);
|
|
}
|
|
m_pSolidDraw2 = NULL;
|
|
m_pSolidDraw = NULL;
|
|
}
|
|
|
|
AcDb3dSolid* AecDbX3dGroup::CreateSubDraw3dSolid() const
|
|
{
|
|
AcDb3dSolid* pSolidAll = NULL,*pSolid = NULL;
|
|
AcDbExtents ext,extAll;
|
|
|
|
BOOL bIsEWormSeg = FALSE;
|
|
GetSpecialtyData()->GetAt(_T("IsEWormSeg"),bIsEWormSeg);
|
|
|
|
Acad::ErrorStatus es;
|
|
for (int i = 0;i < m_arX3dSolidRecs.length();i++)
|
|
{
|
|
const X3dSolidRec& rec = m_arX3dSolidRecs.at(i);
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
|
|
//子级别
|
|
if ( rec.pXSolid->GetGSMarkerID() != m_nSubIndex)
|
|
continue;
|
|
|
|
if (rec.bType == AcDb::kBoolUnite)
|
|
{
|
|
if (pSolidAll == NULL)
|
|
{
|
|
pSolidAll = pSolid;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (rec.bType == AcDb::kBoolUnite)
|
|
{
|
|
if (pSolidAll != NULL && pSolid != NULL)
|
|
{
|
|
es = pSolidAll->booleanOper(rec.bType,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\nX3dGroup::CreateDraw3dSolid boolean oper error!"));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( bIsEWormSeg )
|
|
{
|
|
if (pSolidAll != NULL && pSolid != NULL)
|
|
{
|
|
es = pSolidAll->booleanOper(rec.bType,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
acutPrintf(_T("\nX3dGroup::CreateDraw3dSolid boolean oper error!"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return pSolidAll;
|
|
}
|
|
#if ARX > 17
|
|
AcDbSubDMesh* AecDbX3dGroup::CreateSubDMesh(AcArray<AcGeLineSeg3d> *pArr)
|
|
{
|
|
if (!IsFrom3JS()) return NULL;
|
|
if (m_arX3dSolidRecs.isEmpty()) return NULL;
|
|
|
|
if (m_pSubDMesh)
|
|
{
|
|
m_pSubDMesh->erase();
|
|
m_pSubDMesh->close();
|
|
DELETE_PTR(m_pSubDMesh);
|
|
}
|
|
|
|
m_pSubDMesh2Ds.removeAll();
|
|
|
|
if (!m_pSubDMesh)
|
|
{
|
|
m_pSubDMesh = m_arX3dSolidRecs[0].pXSolid->GetDrawSubDMesh();
|
|
}
|
|
|
|
if (!m_pSubDMesh) return NULL;
|
|
|
|
m_arX3dSolidRecs[0].pXSolid->GetDrawSubDMesh2D(m_pSubDMesh2Ds);
|
|
|
|
if (m_bActive)
|
|
m_pSubDMesh->setColorIndex(kMagenta);
|
|
else
|
|
m_pSubDMesh->setColorIndex(0);
|
|
|
|
AcDbExtents ext;
|
|
m_pSubDMesh->getGeomExtents(ext);
|
|
m_ptOrg = Mid(ext.minPoint(), ext.maxPoint());
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(m_vtMove);
|
|
m_pSubDMesh->transformBy(xform);
|
|
|
|
for (int i = 0; i < m_pSubDMesh2Ds.length(); ++i)
|
|
m_pSubDMesh2Ds[i].transformBy(xform);
|
|
|
|
|
|
AcGePoint3d ptOrg = m_ptOrg;
|
|
ptOrg += m_vtMove;
|
|
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
AcGeVector3d vtAxis;
|
|
for (int i = 0; i < m_arVtAxis.length(); i++)
|
|
{
|
|
vtAxis = m_arVtAxis.at(i);
|
|
if (!vtAxis.isZeroLength() && fabs(m_dAxisRotats[i]) > 1.e-10)
|
|
{
|
|
xform.setToIdentity();
|
|
xform.setToRotation(m_dAxisRotats[i], vtAxis, ptOrg);
|
|
es = m_pSubDMesh->transformBy(xform);
|
|
for (int i = 0; i < m_pSubDMesh2Ds.length(); ++i)
|
|
m_pSubDMesh2Ds[i].transformBy(xform);
|
|
}
|
|
}
|
|
|
|
if (pArr)
|
|
{
|
|
pArr->removeAll();
|
|
pArr->append(m_pSubDMesh2Ds);
|
|
}
|
|
|
|
return m_pSubDMesh;
|
|
}
|
|
#endif
|
|
|
|
AcDb3dSolid* AecDbX3dGroup::CreateDraw3dSolid() const
|
|
{
|
|
AcDb3dSolid* pSolidAll = NULL,*pSolid = NULL;
|
|
AcDbExtents ext,extAll;
|
|
|
|
BOOL bIsEWormSeg = FALSE;
|
|
GetSpecialtyData()->GetAt(_T("IsEWormSeg"),bIsEWormSeg);
|
|
|
|
Acad::ErrorStatus es;
|
|
for (int i = 0;i < m_arX3dSolidRecs.length();i++)
|
|
{
|
|
const X3dSolidRec& rec = m_arX3dSolidRecs.at(i);
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
|
|
if (rec.bType == AcDb::kBoolUnite)
|
|
{
|
|
if (pSolidAll == NULL)
|
|
{
|
|
pSolidAll = pSolid;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (rec.bType == AcDb::kBoolUnite)
|
|
{
|
|
if (pSolidAll != NULL && pSolid != NULL)
|
|
{
|
|
// AcDb3dSolid* pSolidAllCln = (AcDb3dSolid*)pSolidAll->clone();
|
|
// pSolidAllCln->setColorIndex(kGreen);
|
|
//
|
|
// AcDb3dSolid* pSolidCln = (AcDb3dSolid*)pSolid->clone();
|
|
// pSolidCln->setColorIndex(kGreen);
|
|
|
|
es = pSolidAll->booleanOper(rec.bType,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
//AddToModelSpace(pSolidAllCln);
|
|
//AddToModelSpace(pSolidCln);
|
|
acutPrintf(_T("\nX3dGroup::CreateDraw3dSolid boolean oper error!"));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( bIsEWormSeg )
|
|
{
|
|
if (pSolidAll != NULL && pSolid != NULL)
|
|
{
|
|
// AcDb3dSolid* pSolidAllCln = (AcDb3dSolid*)pSolidAll->clone();
|
|
// pSolidAllCln->setColorIndex(kGreen);
|
|
//
|
|
// AcDb3dSolid* pSolidCln = (AcDb3dSolid*)pSolid->clone();
|
|
// pSolidCln->setColorIndex(kGreen);
|
|
|
|
es = pSolidAll->booleanOper(rec.bType,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
//AddToModelSpace(pSolidAllCln);
|
|
//AddToModelSpace(pSolidCln);
|
|
acutPrintf(_T("\nX3dGroup::CreateDraw3dSolid boolean oper error!"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//子级别
|
|
if (m_arSubX3DGroups.length() > 0)
|
|
{
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arSubX3DGroups.length();i++)
|
|
{
|
|
pGroup = (AecDbX3dGroup*)m_arSubX3DGroups.at(i);
|
|
pSolid = pGroup->CreateDraw3dSolid();
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pGroup->Transformby(pSolid);
|
|
|
|
es = pSolidAll->booleanOper(AcDb::kBoolUnite,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return pSolidAll;
|
|
}
|
|
|
|
|
|
AcDb3dSolid* AecDbX3dGroup::CreateDraw3dSolidNoBJ() const
|
|
{
|
|
AcDb3dSolid* pSolidAll = NULL,*pSolid = NULL;
|
|
AcDbExtents ext,extAll;
|
|
|
|
BOOL bIsEWormSeg = FALSE;
|
|
GetSpecialtyData()->GetAt(_T("IsEWormSeg"),bIsEWormSeg);
|
|
|
|
Acad::ErrorStatus es;
|
|
for (int i = 0;i < m_arX3dSolidRecs.length();i++)
|
|
{
|
|
const X3dSolidRec& rec = m_arX3dSolidRecs.at(i);
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
|
|
if (rec.pXSolid->GetGSMarkerID() > -1 && rec.pXSolid->GetGSMarkerID() < 2000)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (rec.bType == AcDb::kBoolUnite)
|
|
{
|
|
if (pSolidAll == NULL)
|
|
{
|
|
pSolidAll = pSolid;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
if (rec.bType == AcDb::kBoolUnite)
|
|
{
|
|
if (pSolidAll != NULL && pSolid != NULL)
|
|
{
|
|
// AcDb3dSolid* pSolidAllCln = (AcDb3dSolid*)pSolidAll->clone();
|
|
// pSolidAllCln->setColorIndex(kGreen);
|
|
//
|
|
// AcDb3dSolid* pSolidCln = (AcDb3dSolid*)pSolid->clone();
|
|
// pSolidCln->setColorIndex(kGreen);
|
|
|
|
es = pSolidAll->booleanOper(rec.bType,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
//AddToModelSpace(pSolidAllCln);
|
|
//AddToModelSpace(pSolidCln);
|
|
acutPrintf(_T("\nX3dGroup::CreateDraw3dSolid boolean oper error!"));
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( bIsEWormSeg )
|
|
{
|
|
if (pSolidAll != NULL && pSolid != NULL)
|
|
{
|
|
// AcDb3dSolid* pSolidAllCln = (AcDb3dSolid*)pSolidAll->clone();
|
|
// pSolidAllCln->setColorIndex(kGreen);
|
|
//
|
|
// AcDb3dSolid* pSolidCln = (AcDb3dSolid*)pSolid->clone();
|
|
// pSolidCln->setColorIndex(kGreen);
|
|
|
|
es = pSolidAll->booleanOper(rec.bType,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
//AddToModelSpace(pSolidAllCln);
|
|
//AddToModelSpace(pSolidCln);
|
|
acutPrintf(_T("\nX3dGroup::CreateDraw3dSolid boolean oper error!"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
//子级别
|
|
if (m_arSubX3DGroups.length() > 0)
|
|
{
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < m_arSubX3DGroups.length();i++)
|
|
{
|
|
pGroup = (AecDbX3dGroup*)m_arSubX3DGroups.at(i);
|
|
pSolid = pGroup->CreateDraw3dSolid();
|
|
|
|
if (pSolid != NULL)
|
|
{
|
|
pGroup->Transformby(pSolid);
|
|
|
|
es = pSolidAll->booleanOper(AcDb::kBoolUnite,pSolid);
|
|
if (es != Acad::eOk)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return pSolidAll;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetEwormLine(AcDbLine& ln)
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("管廊段")) == 0)
|
|
{
|
|
CString sCrossSectionScr;
|
|
double dYXLen = 0.0;
|
|
double dG = 0.0;
|
|
AcGePoint3d ptOrg;
|
|
|
|
m_mapXData.GetAt(_T("CrossSectionScr"),sCrossSectionScr);
|
|
m_mapXData.GetAt(_T("m_dYXLen"),dYXLen);
|
|
m_mapXData.GetAt(_T("m_dG"),dG);
|
|
m_mapXData.GetAt(_T("Org"),ptOrg);
|
|
|
|
if (dYXLen < 1.e-3 && sCrossSectionScr.IsEmpty())
|
|
{
|
|
return false;
|
|
}
|
|
|
|
AcGeVector3d vtZ = -AcGeVector3d::kYAxis;
|
|
vtZ.z -= vtZ.length() * dYXLen * dG * 0.01;
|
|
|
|
AcGePoint3d ptFr = ptOrg - vtZ * 0.5 * dYXLen;
|
|
AcGePoint3d ptEnd = ptFr + vtZ * dYXLen;
|
|
|
|
Transformby(ptFr);
|
|
Transformby(ptEnd);
|
|
|
|
ln.setStartPoint(ptFr);
|
|
ln.setEndPoint(ptEnd);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::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
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("管廊段")) != 0)
|
|
return false;
|
|
|
|
double dYXLen = 0.0;
|
|
double dG = 0.0;
|
|
AcGePoint3d ptOrg;
|
|
|
|
CString sCrossSectionScr;
|
|
m_mapXData.GetAt(_T("CrossSectionScr"),sCrossSectionScr);
|
|
if (sCrossSectionScr.Find(_T("RECT")) != -1)//标准管廊段
|
|
{
|
|
m_mapXData.GetAt(_T("m_dYXLen"),dYXLen);
|
|
m_mapXData.GetAt(_T("m_dG"),dG);
|
|
m_mapXData.GetAt(_T("Org"),ptOrg);
|
|
|
|
AcGeVector3d vtZ = -AcGeVector3d::kYAxis;
|
|
vtZ.z -= vtZ.length() * dYXLen * dG * 0.01;
|
|
|
|
AcGePoint3d ptFr = ptOrg - vtZ * 0.5 * dYXLen;
|
|
AcGePoint3d ptEnd = ptFr + vtZ * dYXLen;
|
|
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(sCrossSectionScr);
|
|
dbEW.SetStartPoint(AcGePoint2d(ptFr.x,ptFr.y));
|
|
dbEW.SetEndPoint(AcGePoint2d(ptEnd.x,ptEnd.y));
|
|
dbEW.SetStartElevation(0.0);
|
|
dbEW.AddSegment(0,0.0,dYXLen,_T("001"));
|
|
|
|
bool bRelt = dbEW.GetCableLineSegsForHolder(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
|
|
//再把 arLnSegs变换一下
|
|
for (int k = 0;k < arLnSegs.length();k++)
|
|
{
|
|
LineSeg& lnSg = arLnSegs.at(k);
|
|
Transformby(lnSg.ptFr);
|
|
Transformby(lnSg.ptTo);
|
|
}
|
|
return bRelt;
|
|
}
|
|
else//盾构管廊段
|
|
{
|
|
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("m_dYXLen"),dYXLen);
|
|
m_mapXData.GetAt(_T("m_dG"),dG);
|
|
m_mapXData.GetAt(_T("Org"),ptOrg);
|
|
|
|
AcGeVector3d vtZ = -AcGeVector3d::kYAxis;
|
|
vtZ.z -= vtZ.length() * dYXLen * dG * 0.01;
|
|
|
|
AcGePoint3d ptFr = ptOrg - vtZ * 0.5 * dYXLen;
|
|
AcGePoint3d ptEnd = ptFr + vtZ * dYXLen;
|
|
|
|
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 = sCrossSectionScr;
|
|
int nPos = sCrossSectionScr.Find(_T("<ELAGN:") );
|
|
if (nPos != -1)
|
|
{
|
|
sScr = sCrossSectionScr.Mid(0,nPos);
|
|
}
|
|
file.WriteString(sScr);
|
|
file.Close();
|
|
|
|
CString sX,sY;
|
|
CString sPt = 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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
if (pSection->pReg != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcDbLine ln(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;
|
|
delete pRoadLn;
|
|
|
|
return dbEW.GetCableLineSegsForHolder(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::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
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("管廊段")) != 0)
|
|
return false;
|
|
|
|
CString sCrossSectionScr;
|
|
double dYXLen = 0.0;
|
|
double dG = 0.0;
|
|
AcGePoint3d ptOrg;
|
|
|
|
m_mapXData.GetAt(_T("CrossSectionScr"),sCrossSectionScr);
|
|
if (sCrossSectionScr.Find(_T("RECT")) != -1)
|
|
{
|
|
m_mapXData.GetAt(_T("m_dYXLen"),dYXLen);
|
|
m_mapXData.GetAt(_T("m_dG"),dG);
|
|
m_mapXData.GetAt(_T("Org"),ptOrg);
|
|
|
|
AcGeVector3d vtZ = -AcGeVector3d::kYAxis;
|
|
vtZ.z -= vtZ.length() * dYXLen * dG * 0.01;
|
|
|
|
AcGePoint3d ptFr = ptOrg - vtZ * 0.5 * dYXLen;
|
|
AcGePoint3d ptEnd = ptFr + vtZ * dYXLen;
|
|
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(sCrossSectionScr);
|
|
dbEW.SetStartPoint(AcGePoint2d(ptFr.x,ptFr.y));
|
|
dbEW.SetEndPoint(AcGePoint2d(ptEnd.x,ptEnd.y));
|
|
dbEW.SetStartElevation(0.0);
|
|
dbEW.AddSegment(0,0.0,dYXLen,_T("001"));
|
|
|
|
bool bRlt = dbEW.GetCableLineSegsForHanger(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
|
|
//再把 arLnSegs变换一下
|
|
for (int k = 0;k < arLnSegs.length();k++)
|
|
{
|
|
LineSeg& lnSg = arLnSegs.at(k);
|
|
Transformby(lnSg.ptFr);
|
|
Transformby(lnSg.ptTo);
|
|
}
|
|
return bRlt;
|
|
}
|
|
else
|
|
{
|
|
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("m_dYXLen"),dYXLen);
|
|
m_mapXData.GetAt(_T("m_dG"),dG);
|
|
m_mapXData.GetAt(_T("Org"),ptOrg);
|
|
|
|
AcGeVector3d vtZ = -AcGeVector3d::kYAxis;
|
|
vtZ.z -= vtZ.length() * dYXLen * dG * 0.01;
|
|
|
|
AcGePoint3d ptFr = ptOrg - vtZ * 0.5 * dYXLen;
|
|
AcGePoint3d ptEnd = ptFr + vtZ * dYXLen;
|
|
|
|
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 = sCrossSectionScr;
|
|
int nPos = sCrossSectionScr.Find(_T("<ELAGN:") );
|
|
if (nPos != -1)
|
|
{
|
|
sScr = sCrossSectionScr.Mid(0,nPos);
|
|
}
|
|
file.WriteString(sScr);
|
|
file.Close();
|
|
|
|
CString sX,sY;
|
|
CString sPt = 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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
if (pSection->pReg != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
AcDbLine ln(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;
|
|
delete pRoadLn;
|
|
|
|
return dbEW.GetCableLineSegsForHolder(nRoomIndex
|
|
, arLnSegs
|
|
, idx
|
|
, nFloor
|
|
, nCount
|
|
, dDD
|
|
, nClr
|
|
, ltypeString
|
|
, dSpace
|
|
, bAllRoom
|
|
, bByWholeLine);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool AecDbX3dGroup::GetSlicePlan(AcGePlane& plan) const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("剖切")) == 0)
|
|
{
|
|
int nPlan = 0;
|
|
GetSpecialtyData()->GetAt(_T("m_nPlan"),nPlan);
|
|
|
|
int nDir = 0;
|
|
GetSpecialtyData()->GetAt(_T("Dir"),nDir);
|
|
|
|
AcGePoint3d ptOrg = GetOrgPoint();
|
|
Transformby(ptOrg);
|
|
|
|
switch(nPlan)
|
|
{
|
|
case 0://xz
|
|
{
|
|
if (nDir == 0)
|
|
plan.set(ptOrg,AcGeVector3d::kYAxis);
|
|
else
|
|
plan.set(ptOrg,-AcGeVector3d::kYAxis);
|
|
break;
|
|
}
|
|
case 1://yz
|
|
{
|
|
if (nDir == 0)
|
|
plan.set(ptOrg,AcGeVector3d::kXAxis);
|
|
else
|
|
plan.set(ptOrg,-AcGeVector3d::kXAxis);
|
|
break;
|
|
}
|
|
case 2://xy
|
|
{
|
|
if (nDir == 0)
|
|
plan.set(ptOrg,AcGeVector3d::kZAxis);
|
|
else
|
|
plan.set(ptOrg,-AcGeVector3d::kZAxis);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
// 来自 CGLBJDlg::GetX3dSolidRecs
|
|
int AecDbX3dGroup::GetBJX3dSolidRecs(AecDbX3dGroup*& pGroup,GLBJRecord& rc,const AcGePoint3d& ptFr,const AcGeVector3d& vtDir) const
|
|
{
|
|
if (pGroup != NULL)
|
|
{
|
|
pGroup->RemoveAll3dSolidRec();
|
|
}
|
|
else
|
|
{
|
|
pGroup = new AecDbX3dGroup;
|
|
}
|
|
|
|
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
|
|
AecDbEarthWorm worm;
|
|
worm.SetCrossSectionScr(rc.szCrossSectionScr);
|
|
worm.SetChamferInter(0.0);
|
|
|
|
ESection eType = eRect;
|
|
AcGePoint2dArray arDatas;
|
|
eType = worm.ExtractEarthWormScr(arDatas);
|
|
|
|
//外壁厚,内隔壁厚
|
|
double dOutW = 0.0,dIntW = 0.0;
|
|
if (arDatas.length() > 0)
|
|
{
|
|
dOutW = arDatas.last().x;
|
|
dIntW = arDatas.last().y;
|
|
}
|
|
|
|
//总高度
|
|
double dHeight = arDatas.first().y;
|
|
dHeight += 2 * arDatas.last().x;
|
|
|
|
//底部壁厚增加
|
|
double dBomAdd = worm.GetBomThickAdd();
|
|
|
|
//总宽度
|
|
double dWidth = 0.0;
|
|
for (int i = 0;i < arDatas.length()-1;i++)
|
|
{
|
|
dWidth += arDatas.at(i).x;
|
|
}
|
|
|
|
dWidth += (arDatas.length() - 2) * dIntW;
|
|
dWidth += dOutW * 2.0;
|
|
|
|
AcArray<ERoom> arRooms;
|
|
ERoom room;
|
|
AcGePoint2d ptThick;
|
|
AcGeLineSeg3d ln(ptFr,ptFr + 10.0 * vtDir);
|
|
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
|
|
|
|
AcGeVector3d vtX = vtDir;
|
|
vtX.rotateBy(PI / 2.0,AcGeVector3d::kZAxis);
|
|
|
|
if (fabs(vtX.x) < 1.e-6)
|
|
vtX.x = 0.0;
|
|
|
|
if (fabs(vtX.y) < 1.e-6)
|
|
vtX.y = 0.0;
|
|
|
|
CString sIndex;
|
|
//for (int n = 0; n < m_arRecord.length();n++)
|
|
{
|
|
//GLBJRecord& rc = m_arRecord.at(n);
|
|
|
|
double n_dCurRoomW = rc.m_dCurRoomW;
|
|
double n_dWAdd = rc.m_dWAdd;
|
|
double n_dOpenL = rc.m_dOpenL;
|
|
double n_dB = rc.m_dB;
|
|
double n_dAngle = rc.m_dAngle;
|
|
double n_dA2 = rc.m_dA2;
|
|
BOOL n_bAllRoom = rc.m_bAllRoom;
|
|
int n_idxRoom = rc.m_idxRoom;
|
|
CString n_sCrossSectionScr = rc.szCrossSectionScr;
|
|
int n_nPos = rc.m_nPos;
|
|
double n_dLen = rc.m_dLen;
|
|
double n_dZOff = rc.m_dZOff;
|
|
|
|
room = arRooms.at(n_idxRoom);
|
|
|
|
AcGePoint3d ptOrg = ptFr;
|
|
AcGeVector3d vtZ;
|
|
X3dSolidRec rec;
|
|
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
if (n_bAllRoom)//整体
|
|
{
|
|
int nDir = (n_nPos == 0 ) ? -1 : 1;
|
|
|
|
//取侧墙中心
|
|
ptOrg = (n_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
|
|
ptOrg += ( nDir * ( (n_idxRoom == 0 || n_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
|
|
ptOrg += ( n_dLen / 2.0 ) * vtDir;
|
|
ptOrg.z = 0.0;
|
|
ptOrg.z += n_dZOff;
|
|
ptOrg.z -= 0.5 * dBomAdd;
|
|
vtZ = nDir * vtX;
|
|
|
|
if ( (n_idxRoom == 0 && n_nPos == 0 ) ||
|
|
(n_idxRoom == arRooms.length() - 1 && n_nPos == 1) )//左外/右外
|
|
{
|
|
//原地挖掉
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,n_dLen,dHeight - 2.0 * dOutW, dOutW);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
//pGroup->AddX3dSolidRec(rec);
|
|
|
|
ptOrg -= vtZ * dOutW * 0.5;
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,n_dLen,dHeight + dBomAdd,n_dWAdd + dOutW,PI / 2.0);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
ptOrg += vtZ * n_dWAdd;
|
|
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,n_dLen,dHeight - 2 * dOutW,n_dWAdd,PI / 2.0);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
else//内部
|
|
{
|
|
//原地挖掉
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,n_dLen,dHeight - 2 * dOutW, dIntW);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
//创建一新的
|
|
ptOrg += vtZ * n_dWAdd;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,n_dLen,dHeight - 2 * dOutW, dIntW);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
}
|
|
else//局部
|
|
{
|
|
int nDir = (n_nPos == 0 ) ? 1 : -1;
|
|
|
|
//取侧墙中心
|
|
ptOrg = (n_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
|
|
ptOrg += ( nDir * ( ( n_idxRoom == 0 || n_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
|
|
ptOrg += ( n_dB + n_dOpenL * 0.5 ) * vtDir;
|
|
ptOrg.z = 0.0;//中心
|
|
ptOrg.z += n_dZOff;
|
|
ptOrg.z -= 0.5 * dBomAdd;
|
|
vtZ = nDir * vtX;
|
|
|
|
double dB = ( ( n_idxRoom == 0 || n_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
|
|
double dT = dB;
|
|
|
|
//内部原地挖掉
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,n_dOpenL,dHeight - 2 * dB, dB );
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
//pGroup->AddX3dSolidRec(rec);
|
|
|
|
double dAng = n_dAngle * PI / 180.0;
|
|
double dAng2 = n_dA2 * PI / 180.0;
|
|
|
|
if (n_nPos == 0)
|
|
dB /= sin(dAng2);
|
|
else
|
|
dB /= sin(dAng);
|
|
|
|
double dB2 = ( ( n_idxRoom == 0 || n_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
|
|
|
|
//外
|
|
pXSolid = new AcDbX3dSolid;
|
|
ptOrg -= ( nDir * ( ( n_idxRoom == 0 || n_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
|
|
double dRoomH = room.ptGe[0].distanceTo(room.ptGe[1]);
|
|
|
|
double dH = dHeight;//( n_idxRoom == 0 || n_idxRoom == arRooms.length() - 1 ) ? dHeight : dHeight - 2.0 * dOutW;
|
|
|
|
if (fabs(n_dAngle - n_dA2) < 1.e-3)
|
|
{
|
|
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,n_dOpenL + 2.0 * dB, dH + dBomAdd,n_dWAdd + dT,dAng);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
//AcDb3dSolid* pSolidT = pXSolid->GetDraw3dSolid();
|
|
//pSolidT->setColorIndex(kRed);
|
|
//AddToModelSpace(pSolidT);
|
|
|
|
//挖去
|
|
pXSolid = new AcDbX3dSolid;
|
|
ptOrg.z += 0.5 * dBomAdd;
|
|
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,n_dOpenL,dH - dB2 * 2.0 ,n_dWAdd,dAng);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
//pSolidT = pXSolid->GetDraw3dSolid();
|
|
//pSolidT->setColorIndex(kRed);
|
|
//AddToModelSpace(pSolidT);
|
|
}
|
|
else
|
|
{
|
|
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,n_dOpenL + 2.0 * dB, dH + dBomAdd,n_dWAdd + dT,dAng,dAng2);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
//挖去
|
|
pXSolid = new AcDbX3dSolid;
|
|
ptOrg += vtZ * n_dWAdd;
|
|
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,n_dOpenL,dH - dB2 * 2.0 ,n_dWAdd,dAng,dAng2);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
int AecDbX3dGroup::GetGLBJSideLine(int nPos,int nSubIndex,AcGePoint3dArray& arLinePts,AcGeVector3d& vtDir,GLBJRecord& rc) const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
AcDb3dSolid* pDraw3dSolid = NULL;
|
|
if (sName.CompareNoCase(_T("变径")) == 0 ||
|
|
sName.CompareNoCase(_T("管廊段")) == 0)
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
vtDir = AcGeVector3d::kXAxis;
|
|
if (sName.CompareNoCase(_T("变径")) == 0)
|
|
{
|
|
pDraw3dSolid = CreateDraw3dSolid();
|
|
|
|
//memset(&rc,0,sizeof(GLBJRecord));
|
|
m_mapXData.GetAt(_T("m_dCurRoomW"),rc.m_dCurRoomW);
|
|
m_mapXData.GetAt(_T("m_dWAdd"),rc.m_dWAdd);
|
|
m_mapXData.GetAt(_T("m_dOpenL"),rc.m_dOpenL);
|
|
m_mapXData.GetAt(_T("m_dB"),rc.m_dB);
|
|
m_mapXData.GetAt(_T("m_dAngle"),rc.m_dAngle);
|
|
|
|
m_mapXData.GetAt(_T("m_dA2"),rc.m_dA2);
|
|
m_mapXData.GetAt(_T("m_bAllRoom"),rc.m_bAllRoom);
|
|
m_mapXData.GetAt(_T("m_idxRoom"),rc.m_idxRoom);
|
|
m_mapXData.GetAt(_T("m_nPos"),rc.m_nPos);
|
|
m_mapXData.GetAt(_T("m_dZOff"),rc.m_dZOff);
|
|
m_mapXData.GetAt(_T("m_dTAdd"),rc.m_dTAdd);
|
|
rc.m_nIndex = nSubIndex;
|
|
|
|
CString sScr = _T("");
|
|
m_mapXData.GetAt(_T("m_sCrossSectionScr"),sScr);
|
|
rc.szCrossSectionScr = sScr;
|
|
m_mapXData.GetAt(_T("m_dLen"),rc.m_dLen);
|
|
}
|
|
else
|
|
{
|
|
AecDbObjXDataMap rcXDataMap;
|
|
if (m_mapXData.GetAt(_T("CGLBJDlg"),nSubIndex,rcXDataMap))
|
|
{
|
|
CString sCrossSectionScr;
|
|
rcXDataMap.GetAt(_T("m_sCrossSectionScr"),sCrossSectionScr);
|
|
|
|
double dYXLen;
|
|
rcXDataMap.GetAt(_T("m_dLen"),dYXLen);
|
|
|
|
AcGePoint3d ptOrg(0,0,0);
|
|
ptOrg.y += 0.5 * dYXLen;
|
|
|
|
//memset(&rc,0,sizeof(GLBJRecord));
|
|
rcXDataMap.GetAt(_T("m_dCurRoomW"),rc.m_dCurRoomW);
|
|
rcXDataMap.GetAt(_T("m_dWAdd"),rc.m_dWAdd);
|
|
rcXDataMap.GetAt(_T("m_dOpenL"),rc.m_dOpenL);
|
|
rcXDataMap.GetAt(_T("m_dB"),rc.m_dB);
|
|
rcXDataMap.GetAt(_T("m_dAngle"),rc.m_dAngle);
|
|
|
|
rcXDataMap.GetAt(_T("m_dA2"),rc.m_dA2);
|
|
rcXDataMap.GetAt(_T("m_bAllRoom"),rc.m_bAllRoom);
|
|
rcXDataMap.GetAt(_T("m_idxRoom"),rc.m_idxRoom);
|
|
rcXDataMap.GetAt(_T("m_nPos"),rc.m_nPos);
|
|
rcXDataMap.GetAt(_T("m_dZOff"),rc.m_dZOff);
|
|
rcXDataMap.GetAt(_T("m_dTAdd"),rc.m_dTAdd);
|
|
rc.m_nIndex = nSubIndex;
|
|
|
|
CString sScr = _T("");
|
|
rcXDataMap.GetAt(_T("m_sCrossSectionScr"),sScr);
|
|
rc.szCrossSectionScr = sScr;
|
|
rcXDataMap.GetAt(_T("m_dLen"),rc.m_dLen);
|
|
|
|
AecDbX3dGroup* pGroupBJ = NULL;
|
|
GetBJX3dSolidRecs(pGroupBJ,rc,ptOrg,-AcGeVector3d::kYAxis);
|
|
|
|
vtDir = -AcGeVector3d::kYAxis;
|
|
|
|
if (pGroupBJ != NULL)
|
|
{
|
|
pGroupBJ->GetSpecialtyData()->SetAt(_T("IsEWormSeg"),TRUE);
|
|
pDraw3dSolid = pGroupBJ->CreateDraw3dSolid();
|
|
}
|
|
}
|
|
}
|
|
|
|
if (pDraw3dSolid != NULL)
|
|
{
|
|
Transformby(pDraw3dSolid);
|
|
Transformby(vtDir);
|
|
|
|
double dVol = 0.0,momInertia[3],prodInertia[3],prinMoments[3],radiiGyration[3];
|
|
AcGeVector3d prinAxes[3];
|
|
AcDbExtents extents;
|
|
|
|
AcGePoint3d ptMid;
|
|
pDraw3dSolid->getMassProp(dVol,ptMid,momInertia,prodInertia,prinMoments,prinAxes,radiiGyration,extents);
|
|
|
|
AcGePlane plan;
|
|
AcGeVector3d vtLookDir;
|
|
|
|
switch(nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kXAxis);// 垂直面
|
|
vtLookDir = AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kXAxis);// 垂直面
|
|
vtLookDir = -AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = -AcGeVector3d::kXAxis;
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = AcGeVector3d::kXAxis;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
pDraw3dSolid->getSection(plan,pRegion);
|
|
if (pRegion != NULL)
|
|
{
|
|
AcDbVoidPtrArray arCurPtrs;
|
|
pRegion->explode(arCurPtrs);
|
|
|
|
AcDbVoidPtrArray arpResult;
|
|
AcDbCurve* pNewCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arpResult);
|
|
if (pNewCurve != NULL)
|
|
{
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pNewCurve);
|
|
if (pPl != NULL)
|
|
{
|
|
AcGePoint3d pt3d;
|
|
for (int k = 0;k < pPl->numVerts();k++)
|
|
{
|
|
pPl->getPointAt(k,pt3d);
|
|
arLinePts.append(pt3d);
|
|
}
|
|
|
|
pPl->setColorIndex(kRed);
|
|
AddToModelSpace(pPl,NULL,true);
|
|
}
|
|
}
|
|
FreeBuffer(0,arpResult);
|
|
DELETE_PTR(pRegion);
|
|
}
|
|
|
|
DELETE_PTR(pDraw3dSolid);
|
|
//pDraw3dSolid->setColorIndex(kRed);
|
|
//AddToModelSpace(pDraw3dSolid,NULL,true);
|
|
}
|
|
return arLinePts.length();
|
|
}
|
|
|
|
int AecDbX3dGroup::GetInnerWallLine(int nRoomIndex,int nPos,AcGePoint3dArray& arLinePts) const
|
|
{
|
|
CString sName;
|
|
GetName(sName);
|
|
|
|
if (sName.CompareNoCase(_T("管廊段")) != 0)
|
|
return FALSE;
|
|
|
|
CString sCrossSectionScr;
|
|
m_mapXData.GetAt(_T("CrossSectionScr"),sCrossSectionScr);
|
|
|
|
double dYXLen = 0.0;
|
|
double dG = 0.0;
|
|
AcGePoint3d ptOrg;
|
|
|
|
m_mapXData.GetAt(_T("m_dYXLen"),dYXLen);
|
|
m_mapXData.GetAt(_T("m_dG"),dG);
|
|
m_mapXData.GetAt(_T("Org"),ptOrg);
|
|
|
|
AcGeVector3d vtZ = -AcGeVector3d::kYAxis;
|
|
vtZ.z -= vtZ.length() * dYXLen * dG * 0.01;
|
|
|
|
AcGePoint3d ptFr = ptOrg - vtZ * 0.5 * dYXLen;
|
|
AcGePoint3d ptEnd = ptFr + vtZ * dYXLen;
|
|
AcGePoint3d ptMid;
|
|
|
|
AcGePlane plan;
|
|
AcGeVector3d vtLookDir;
|
|
|
|
if (sCrossSectionScr.Find(_T("RECT")) != -1)
|
|
{
|
|
AecDbEarthWorm dbEW;
|
|
dbEW.SetCrossSectionScr(sCrossSectionScr);
|
|
|
|
AcGeLineSeg3d ln(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::kXAxis);// 垂直面
|
|
vtLookDir = AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kXAxis);// 垂直面
|
|
vtLookDir = -AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = -AcGeVector3d::kXAxis;
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = AcGeVector3d::kXAxis;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
STSection* pSection = GetShEwSection();
|
|
if (pSection != NULL)
|
|
{
|
|
AecDbShEarthWorm dbEW;
|
|
|
|
AcDbLine ln(ptFr,ptEnd);
|
|
AcGeLineSeg3d ln3d(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::kXAxis);// 垂直面
|
|
vtLookDir = AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kXAxis);// 垂直面
|
|
vtLookDir = -AcGeVector3d::kZAxis;
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = -AcGeVector3d::kXAxis;
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
plan.set(ptMid,AcGeVector3d::kZAxis);// 水平面
|
|
vtLookDir = AcGeVector3d::kXAxis;
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
delete pRoadLn;//after delete
|
|
delete pSection->pReg;
|
|
pSection->pReg = NULL;
|
|
delete pSection;
|
|
}
|
|
}
|
|
|
|
AcDb3dSolid* pDraw3dSolid = CreateDraw3dSolidNoBJ();//CreateDraw3dSolid();
|
|
if (pDraw3dSolid != NULL)
|
|
{
|
|
//测试
|
|
/*AcDb3dSolid* pSolidCln = (AcDb3dSolid*)pDraw3dSolid->clone();
|
|
pSolidCln->setColorIndex(kGreen);
|
|
AddToModelSpace(pSolidCln);*/
|
|
|
|
AcDbRegion* pRegion = NULL;
|
|
pDraw3dSolid->getSection(plan,pRegion);
|
|
|
|
AcDbExtents ext;
|
|
pDraw3dSolid->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::kYAxis);
|
|
|
|
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.y - ptEnd.y) < 1.e-2 && fabs(ptSta.y - ext.minPoint().y) < 1.e-2)//左侧垂线
|
|
{
|
|
arCurPtrs2.removeAt(i);
|
|
DELETE_PTR(pCurve);
|
|
i -= 1;
|
|
continue;
|
|
}
|
|
|
|
if ( fabs(ptSta.y - ptEnd.y) < 1.e-2 && fabs(ptSta.y - ext.maxPoint().y) < 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(pDraw3dSolid);
|
|
}
|
|
|
|
//再把 arLinePts变换一下
|
|
for (int k = 0;k < arLinePts.length();k++)
|
|
{
|
|
AcGePoint3d& ptT = arLinePts.at(k);
|
|
Transformby(ptT);
|
|
}
|
|
return arLinePts.length();
|
|
}
|
|
|
|
STSection* AecDbX3dGroup::GetShEwSection() const
|
|
{
|
|
CString sCrossSectionScr;
|
|
m_mapXData.GetAt(_T("CrossSectionScr"),sCrossSectionScr);
|
|
|
|
if (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 = sCrossSectionScr;
|
|
int nPos = sCrossSectionScr.Find(_T("<ELAGN:") );
|
|
if (nPos != -1)
|
|
{
|
|
sScr = sCrossSectionScr.Mid(0,nPos);
|
|
}
|
|
file.WriteString(sScr);
|
|
file.Close();
|
|
|
|
CString sX,sY;
|
|
CString sPt = 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));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
void AecDbX3dGroup::DrawSubAxis(AcGiDraw &dc) const
|
|
{
|
|
AcDb3dSolid* pSolidAll = NULL,*pSolid = NULL;
|
|
AcDbExtents ext,extAll;
|
|
|
|
BOOL bIsEWormSeg = FALSE;
|
|
GetSpecialtyData()->GetAt(_T("IsEWormSeg"),bIsEWormSeg);
|
|
|
|
for (int ii = 0;ii < m_arX3dSolidRecs.length();ii++)
|
|
{
|
|
const X3dSolidRec& rec = m_arX3dSolidRecs.at(ii);
|
|
pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
|
|
//子级别
|
|
if ( rec.pXSolid->GetGSMarkerID() == m_nSubIndex)
|
|
{
|
|
AcGePoint3d ptOrg = rec.pXSolid->GetOrgPoint();
|
|
Transformby(ptOrg);
|
|
|
|
AcGeVector3d vtDir;
|
|
for (int i = 0;i < m_arVtAxis.length();i++)
|
|
{
|
|
vtDir = m_arVtAxis.at(i);
|
|
|
|
if (vtDir.isZeroLength())
|
|
continue;
|
|
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
if (i == 0)
|
|
dc.SetColor(1);//red
|
|
else if (i == 1)
|
|
dc.SetColor(3);//gree
|
|
else if (i == 2)
|
|
dc.SetColor(5);//blue
|
|
else
|
|
dc.SetColor(i+1);
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(20);
|
|
|
|
//clinder
|
|
AcGePoint3d ptGeFr = ptOrg;
|
|
AcGePoint3d ptGeTo = ptGeFr + vtDir;
|
|
AcDbEntity* p3d = dc.DrawCone(ptGeFr,PixelToWcs(1),ptGeTo,PixelToWcs(1));
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
|
|
//arrow
|
|
ptGeFr = ptGeTo;
|
|
vtDir.normalize();
|
|
ptGeTo += vtDir * PixelToWcs(15);
|
|
p3d = dc.DrawCone(ptGeFr,PixelToWcs(5),ptGeTo,0.001);
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
dc.SetColor(nCr);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbX3dGroup::DrawAxis(AcGiDraw &dc) const
|
|
{
|
|
if (m_pSolidDraw == NULL)
|
|
{
|
|
m_pSolidDraw = CreateDraw3dSolid();
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
Transformby(m_pSolidDraw);
|
|
}
|
|
}
|
|
|
|
if (m_pSolidDraw != NULL)
|
|
{
|
|
if (m_bActive )
|
|
{
|
|
if (m_nSubIndex == -1)
|
|
{
|
|
m_pSolidDraw->setColorIndex(kMagenta);
|
|
}
|
|
else
|
|
{
|
|
//子级别
|
|
m_pSolidDraw->setColorIndex(kMagenta);
|
|
|
|
m_pSolidDraw2 = CreateSubDraw3dSolid();
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
Transformby(m_pSolidDraw2);
|
|
//m_pSolidDraw2->setColorIndex(kGreen);
|
|
//绘制坐标系
|
|
DrawSubAxis(dc);
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( !IsHide() && m_pSolidDraw != NULL)
|
|
{
|
|
dc.DrawEntity(*m_pSolidDraw);
|
|
if (m_pSolidDraw2 != NULL)
|
|
{
|
|
dc.draw(m_pSolidDraw2);
|
|
}
|
|
}
|
|
}
|
|
|
|
AcGePoint3d ptOrg = m_ptOrg;
|
|
ptOrg += m_vtMove;
|
|
|
|
AcGeVector3d vtDir;
|
|
for (int i = 0;i < m_arVtAxis.length();i++)
|
|
{
|
|
vtDir = m_arVtAxis.at(i);
|
|
|
|
if (vtDir.isZeroLength())
|
|
continue;
|
|
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
if (i == 0)
|
|
dc.SetColor(1);//red
|
|
else if (i == 1)
|
|
dc.SetColor(3);//gree
|
|
else if (i == 2)
|
|
dc.SetColor(5);//blue
|
|
else
|
|
dc.SetColor(i+1);
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(20);
|
|
|
|
//clinder
|
|
AcGePoint3d ptGeFr = ptOrg;
|
|
AcGePoint3d ptGeTo = ptGeFr + vtDir;
|
|
AcDbEntity* p3d = dc.DrawCone(ptGeFr,PixelToWcs(1),ptGeTo,PixelToWcs(1));
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
|
|
//arrow
|
|
ptGeFr = ptGeTo;
|
|
vtDir.normalize();
|
|
ptGeTo += vtDir * PixelToWcs(15);
|
|
p3d = dc.DrawCone(ptGeFr,PixelToWcs(5),ptGeTo,0.001);
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
dc.SetColor(nCr);
|
|
}
|
|
}
|
|
|
|
void AecDbX3dGroup::DrawInf(AcGiDraw &dc) const
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface(arInfs);
|
|
|
|
if (m_nInfActive >= 0 && m_nInfActive < arInfs.length() )
|
|
{
|
|
AecInterface& inf = arInfs.at(m_nInfActive);
|
|
|
|
AcGeVector3d vtDir = inf.vtDir;
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
dc.SetColor(kYellow);//red
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(30);
|
|
|
|
//clinder
|
|
AcGePoint3d ptGeFr = inf.ptPos;
|
|
AcGePoint3d ptGeTo = ptGeFr + vtDir;
|
|
AcDbEntity* p3d = dc.DrawCone(ptGeFr,PixelToWcs(1),ptGeTo,PixelToWcs(1));
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
|
|
//arrow
|
|
ptGeFr = ptGeTo;
|
|
vtDir.normalize();
|
|
ptGeTo += vtDir * PixelToWcs(15);
|
|
p3d = dc.DrawCone(ptGeFr,PixelToWcs(5),ptGeTo,1.e-3);
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
dc.SetColor(nCr);
|
|
}
|
|
|
|
if (m_ptActiveInf.x > -1 && m_ptActiveInf.y > -1)
|
|
{
|
|
AecInterface inf;
|
|
if ( GetInterface(m_ptActiveInf.x,m_ptActiveInf.y,inf) )
|
|
{
|
|
AcGeVector3d vtDir = inf.vtDir;
|
|
vtDir.normalize();
|
|
|
|
Adesk::Int16 nCr = dc.GetColor();
|
|
|
|
dc.SetColor(kYellow);//red
|
|
|
|
vtDir.normalize();
|
|
vtDir *= PixelToWcs(30);
|
|
|
|
//clinder
|
|
AcGePoint3d ptGeFr = inf.ptPos;
|
|
AcGePoint3d ptGeTo = ptGeFr + vtDir;
|
|
AcDbEntity* p3d = dc.DrawCone(ptGeFr,PixelToWcs(1),ptGeTo,PixelToWcs(1));
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
|
|
//arrow
|
|
ptGeFr = ptGeTo;
|
|
vtDir.normalize();
|
|
ptGeTo += vtDir * PixelToWcs(15);
|
|
p3d = dc.DrawCone(ptGeFr,PixelToWcs(5),ptGeTo,1.e-3);
|
|
if (p3d != NULL)
|
|
{
|
|
|
|
}
|
|
dc.SetColor(nCr);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbX3dGroup::Transformby(AcDbEntity* pSolid) const
|
|
{
|
|
if (pSolid == NULL)
|
|
return;
|
|
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(m_vtMove);
|
|
pSolid->transformBy(xform);
|
|
|
|
AcGePoint3d ptOrg = m_ptOrg;
|
|
ptOrg += m_vtMove;
|
|
|
|
Acad::ErrorStatus es = Acad::eOk;
|
|
AcGeVector3d vtAxis;
|
|
for (int i = 0;i < m_arVtAxis.length();i++)
|
|
{
|
|
vtAxis = m_arVtAxis.at(i);
|
|
if ( !vtAxis.isZeroLength() && fabs(m_dAxisRotats[i]) > 1.e-10)
|
|
{
|
|
xform.setToIdentity();
|
|
xform.setToRotation(m_dAxisRotats[i],vtAxis,ptOrg);
|
|
es = pSolid->transformBy(xform);
|
|
}
|
|
}
|
|
|
|
AcArray<AecInterface> arInfs;
|
|
GetInterface( arInfs );
|
|
|
|
double dRot = 0.0;
|
|
CString sIndex;
|
|
for (int i = 0;i < arInfs.length();i++)
|
|
{
|
|
sIndex.Format(_T("%d"),i);
|
|
if (m_mapXData.GetAt(sIndex,dRot))
|
|
{
|
|
AecInterface& inf = arInfs.at(i);
|
|
|
|
xform.setToIdentity();
|
|
xform.setToRotation(dRot,inf.vtDir,inf.ptPos);
|
|
pSolid->transformBy(xform);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbX3dGroup::Transformby(AcGePoint3d& pt) const
|
|
{
|
|
AcGeMatrix3d xform;
|
|
xform.setToTranslation(m_vtMove);
|
|
pt += m_vtMove;
|
|
|
|
AcGePoint3d ptOrg = m_ptOrg;
|
|
ptOrg += m_vtMove;
|
|
|
|
AcGeVector3d vtAxis;
|
|
for (int i = 0;i < m_arVtAxis.length();i++)
|
|
{
|
|
vtAxis = m_arVtAxis.at(i);
|
|
if ( !vtAxis.isZeroLength() && fabs(m_dAxisRotats[i]) > 1.e-10)
|
|
{
|
|
xform.setToIdentity();
|
|
xform.setToRotation(m_dAxisRotats[i],vtAxis,ptOrg);
|
|
pt.transformBy(xform);
|
|
}
|
|
}
|
|
}
|
|
|
|
void AecDbX3dGroup::Transformby(AcGeVector3d& vt) const
|
|
{
|
|
AcGeMatrix3d xform;
|
|
AcGeVector3d vtAxis;
|
|
for (int i = 0;i < m_arVtAxis.length();i++)
|
|
{
|
|
vtAxis = m_arVtAxis.at(i);
|
|
if ( !vtAxis.isZeroLength() && fabs(m_dAxisRotats[i]) > 1.e-10)
|
|
{
|
|
xform.setToIdentity();
|
|
xform.setToRotation(m_dAxisRotats[i],vtAxis,m_ptOrg);
|
|
vt.transformBy(xform);
|
|
}
|
|
}
|
|
}
|
|
|
|
AecDbObjXDataMap* AecDbX3dGroup::GetSpecialtyData()
|
|
{
|
|
return &m_mapXData;
|
|
}
|
|
|
|
const AecDbObjXDataMap* AecDbX3dGroup::GetSpecialtyData() const
|
|
{
|
|
return &m_mapXData;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbX3dGroup::getOsnapPoints( AcDb::OsnapMode osnapMode,
|
|
INT_PTR gsSelectionMark,
|
|
const AcGePoint3d& pickPoint,
|
|
const AcGePoint3d& lastPoint,
|
|
const AcGeMatrix3d& viewXform,
|
|
AcGePoint3dArray& snapPoints,
|
|
AcDbIntArray& geomIds) const
|
|
{
|
|
for (int j = 0;j < m_arX3dSolidRecs.length();j++)
|
|
{
|
|
const X3dSolidRec& rec = m_arX3dSolidRecs.at(j);
|
|
|
|
AcDb3dSolid* pSolid = rec.pXSolid->GetDraw3dSolid();
|
|
if (pSolid != NULL)
|
|
{
|
|
Transformby(pSolid);
|
|
pSolid->getOsnapPoints(osnapMode,gsSelectionMark,pickPoint,lastPoint,viewXform,snapPoints,geomIds);
|
|
DELETE_PTR(pSolid);
|
|
}
|
|
}
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbX3dGroup::dwgInFields (AcDbDwgFiler* pFiler)
|
|
{
|
|
Acad::ErrorStatus es;
|
|
Adesk::UInt32 version =0 ;
|
|
if ( (es =pFiler->readUInt32 (&version)) != Acad::eOk )
|
|
return (es) ;
|
|
if ( version > AecDbX3dGroup::kCurrentVersionNumber )
|
|
return (Acad::eMakeMeProxy) ;
|
|
|
|
TCHAR* pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
if (pszTemp != NULL)
|
|
{
|
|
m_sName = pszTemp;
|
|
acutDelString(pszTemp);
|
|
}
|
|
|
|
pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
if (pszTemp != NULL)
|
|
{
|
|
m_sGUID = pszTemp;
|
|
acutDelString(pszTemp);
|
|
}
|
|
|
|
Adesk::Int32 nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
Adesk::Int16 nVal = 0;
|
|
X3dSolidRec rc;
|
|
for (int i = 0; i < nLen;i++)
|
|
{
|
|
rc.pXSolid = new AcDbX3dSolid;
|
|
rc.pXSolid->dwgInFields(pFiler);
|
|
|
|
pFiler->readInt16(&nVal);
|
|
rc.bType = (AcDb::BoolOperType)nVal;
|
|
|
|
pszTemp = NULL;
|
|
pFiler->readString(&pszTemp);
|
|
if (pszTemp != NULL)
|
|
{
|
|
_tcscpy(rc.szLockId,pszTemp);
|
|
acutDelString(pszTemp);
|
|
}
|
|
m_arX3dSolidRecs.append(rc);
|
|
}
|
|
|
|
if (version >= 2)
|
|
{
|
|
nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pGroup = new AecDbX3dGroup;
|
|
pGroup->dwgInFields(pFiler);
|
|
AddSubX3dGroup(pGroup);
|
|
}
|
|
}
|
|
|
|
pFiler->readVector3d(&m_vtMove);
|
|
pFiler->readPoint3d(&m_ptOrg);
|
|
|
|
nLen = 0;
|
|
pFiler->readInt32(&nLen);
|
|
|
|
m_arVtAxis.removeAll();
|
|
AcGeVector3d vt;
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pFiler->readVector3d(&vt);
|
|
m_arVtAxis.append(vt);
|
|
}
|
|
|
|
memset(m_dAxisRotats,0,sizeof(double) * MAX_AXISROTATS);
|
|
pFiler->readBytes(m_dAxisRotats,sizeof(double) * MAX_AXISROTATS);
|
|
|
|
m_mapXData.dwgInFields(pFiler);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
Acad::ErrorStatus AecDbX3dGroup::dwgOutFields(AcDbDwgFiler* pFiler) const
|
|
{
|
|
Acad::ErrorStatus es;
|
|
//----- Object version number needs to be saved first
|
|
if ( (es = pFiler->writeUInt32 (AecDbX3dGroup::kCurrentVersionNumber)) != Acad::eOk )
|
|
return (es);
|
|
|
|
pFiler->writeString((LPCTSTR)m_sName);
|
|
pFiler->writeString((LPCTSTR)m_sGUID);
|
|
|
|
Adesk::Int32 nLen = m_arX3dSolidRecs.length();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
const X3dSolidRec& rc = m_arX3dSolidRecs.at(i);
|
|
rc.pXSolid->dwgOutFields(pFiler);
|
|
|
|
pFiler->writeInt16((Adesk::Int16)rc.bType);
|
|
pFiler->writeString((LPCTSTR)rc.szLockId);
|
|
}
|
|
|
|
if (AecDbX3dGroup::kCurrentVersionNumber >= 2)
|
|
{
|
|
nLen = m_arSubX3DGroups.length();
|
|
pFiler->writeInt32(nLen);
|
|
|
|
AecDbX3dGroup* pGroup = NULL;
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pGroup = m_arSubX3DGroups.at(i);
|
|
pGroup->dwgOutFields(pFiler);
|
|
}
|
|
}
|
|
|
|
pFiler->writeVector3d(m_vtMove);
|
|
pFiler->writePoint3d(m_ptOrg);
|
|
|
|
nLen = m_arVtAxis.length();
|
|
pFiler->writeInt32(nLen);
|
|
for (int i = 0;i < nLen;i++)
|
|
{
|
|
pFiler->writeVector3d(m_arVtAxis.at(i));
|
|
}
|
|
|
|
pFiler->writeBytes(m_dAxisRotats,sizeof(double) * MAX_AXISROTATS);
|
|
|
|
m_mapXData.dwgOutFields(pFiler);
|
|
|
|
return Acad::eOk;
|
|
}
|
|
|
|
bool AecDbX3dGroup::IsFrom3JS() const
|
|
{
|
|
if (m_arX3dSolidRecs.length() == 1)
|
|
{
|
|
const X3dSolidRec& rc = m_arX3dSolidRecs.at(0);
|
|
if (rc.pXSolid->GetPrimitive() == AcDbX3dSolid::kFrom3JS)
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|