Files
envi-code/SourceCode/Code2026/EarthWormCmd/TJTZDlg.cpp
T
2026-09-28 15:28:50 +08:00

1859 lines
43 KiB
C++

#include "stdafx.h"
#include "TJTZDlg.h"
#include "AecDbEarthWorm.h"
#include "AecDbShEarthWorm.h"
#include "AecDbX3dGroup.h"
#include "KTCADUtilityEx.h"
#include "AecDbX3dPart.h"
#include "UITools.h"
#include "BimInfoDlg.h"
#include "coreTools.h"
#include "AecDb3dRoadAxisLine.h"
extern Acad::ErrorStatus AddToModelSpace(AcDbEntity* pEnt,AcDbDatabase* pDb ,bool bClose );
extern void SplitStrintToArray(LPCTSTR pszDescr,CStringArray& arInfo,TCHAR tcSpace);
extern CString IDCreate();
static void FreeBuffer(AcDbVoidPtrArray& arTextPtrs)
{
AcDbEntity* pEnt = NULL;
while (arTextPtrs.length() > 0)
{
pEnt = (AcDbEntity*)arTextPtrs.first();
arTextPtrs.removeFirst();
DELETE_PTR(pEnt);
}
}
IMPLEMENT_DYNAMIC(CTJTZDlg, CDialog)
CTJTZDlg::CTJTZDlg(CWnd* pParent /*=NULL*/)
: CDialog(CTJTZDlg::IDD, pParent)
, m_dW(0.8)
, m_dH(3.0)
, m_nKind(0)
, m_dX(2.0)
, m_dA(0)
{
m_idxRoom = -1;
m_pRectCell = new AcDbPolyline;
m_pRectCell->addVertexAt(0, AcGePoint2d::kOrigin);
m_pRectCell->addVertexAt(1, AcGePoint2d(1, 0));
m_pRectCell->addVertexAt(1, AcGePoint2d(1, 1));
m_pRectCell->addVertexAt(1, AcGePoint2d(0, 1));
m_pRectCell->setColorIndex(6);
m_pRectCell->setClosed(Adesk::kTrue);
m_pRectCell->setConstantWidth(0.1);
UIDataCache::Read(_T("%d%d%i%d%d%i%s"), _T("CTJTZDlg")
, &m_dW , &m_dH
, &m_nKind
, &m_dX , &m_dA
, &m_idxRoom
, &m_sCrossSectionScr);
m_curSection.pReg = NULL;
m_curSection.pt.set(0,0,0);
m_sCrossSectionScr = _T("");
m_sAddtionScr = _T("");
m_idxRoom = 0;
m_pRegionRoom = NULL;
}
CTJTZDlg::~CTJTZDlg()
{
}
void CTJTZDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_dW);
DDX_Text(pDX, IDC_EDIT3, m_dH);
DDX_Radio(pDX, IDC_RADIO1, m_nKind);
DDX_Text(pDX, IDC_EDIT5, m_dX);
DDX_Text(pDX, IDC_EDIT6, m_dA);
}
BEGIN_MESSAGE_MAP(CTJTZDlg, CDialog)
ON_BN_CLICKED(IDOK, &CTJTZDlg::OnBnClickedOk)
ON_MESSAGE(WM_VIEW_LBUTTONDOWN, &CTJTZDlg::OnViewLButtonDown)
ON_BN_CLICKED(IDC_BUTTON1, &CTJTZDlg::OnBnClickedButton1)
END_MESSAGE_MAP()
BOOL CTJTZDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 子类化控件对象
if (!m_wndViewCtrl.SubclassDlgItem(IDC_STATIC_EW, this))
{
// 错误时,结束对话框
EndDialog(IDCANCEL);
return FALSE;
}
ShowEarthWorm();
if (m_idxRoom > -1)
{
HitEarthWorm(m_idxRoom);
}
UpdateData(FALSE);
CBimInfoDlg::SetDefaultBimInfo(&m_mapBimData,_T("梯子"));
return TRUE;
}
LRESULT CTJTZDlg::OnViewLButtonDown(WPARAM wp, LPARAM lp)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
return OnViewShEwLButtonDown(wp,lp);
}
AcGePoint3d* pPt = (AcGePoint3d*)lp;
pPt->z = 0.0;
//判断 点落在 room 内
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0);
ESection eType = eRect;
AcGePoint2dArray arDatas;
eType = worm.ExtractEarthWormScr(arDatas);
AcGeLineSeg3d ln;
AcGePoint3d pt2(1000.0, 0, 0);
ln.set(AcGePoint3d::kOrigin, pt2);
AcGePoint3d ptGe[4];
AcDbVoidPtrArray arRegPtrs;
int nRooms = worm.CreateSectionRoomRegion(ln, eType, arDatas, arRegPtrs);
if (nRooms > 0)
{
AcDbRegion* pReg = NULL;
for (int i = 0; i < arRegPtrs.length(); i++)
{
pReg = (AcDbRegion*)arRegPtrs.at(i);
if (pReg != NULL)
{
AcDbExtents ext;
pReg->getGeomExtents(ext);
ptGe[0] = ext.minPoint();
ptGe[1] = ptGe[0];
ptGe[1].x = ext.maxPoint().x;
ptGe[2] = ext.maxPoint();
ptGe[3] = ptGe[0];
ptGe[3].y = ext.maxPoint().y;
if (KTCADUtilityEx::IsPointInBoundary(*pPt, ptGe[0], ptGe[2]))
{
m_idxRoom = i;
AcGsView* pView = m_wndViewCtrl.view();
AcGsModel* pModel = m_wndViewCtrl.model();
if (pView != NULL)
{
if (m_pRectCell != NULL)
pView->erase(m_pRectCell);
}
if (m_pRectCell != NULL)
{
for (int i = 0; i < 4; i++)
{
m_pRectCell->setPointAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
}
}
if (pView != NULL)
{
pView->add(m_pRectCell, pModel);
}
break;
}
}
}
if (m_idxRoom == -1)
{
m_pRectCell->setPointAt(0, AcGePoint2d::kOrigin);
m_pRectCell->setPointAt(1, AcGePoint2d(1, 0));
m_pRectCell->setPointAt(2, AcGePoint2d(1, 1));
m_pRectCell->setPointAt(3, AcGePoint2d(0, 1));
}
FreeBuffer(arRegPtrs);
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.RedrawWindow();
}
return 0L;
}
void CTJTZDlg::ShowEarthWorm()
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
ShowShEarthWorm();
return;
}
m_wndViewCtrl.clearAll();
m_wndViewCtrl.init(true);
m_wndViewCtrl.SetOrbitFlag(OBF_PAN | OBF_ZOOM | OBF_COTE);
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0f);
ESection eType = eRect;
AcGePoint2dArray arDatas;
eType = worm.ExtractEarthWormScr(arDatas);
AcGeLineSeg3d ln;
AcGePoint3d pt2(1000.0,0,0);
ln.set(AcGePoint3d::kOrigin,pt2);
AcDbRegion* pEWRegion = worm.CreateSectionRegion(ln,eType,arDatas);
if (pEWRegion != NULL)
{
AcDbExtents exts;
pEWRegion->getGeomExtents(exts);
AcGeMatrix3d xform;
xform.setToScaling(0.95);
pEWRegion->transformBy(xform);
m_wndViewCtrl.InitFromCurrentView2D(exts,true);
AcDbVoidPtrArray arr;
int rooms = worm.CreateSectionRoomRegion(ln, eType, arDatas, arr);
AcDbEntity* pEnt = NULL;
AcDbVoidPtrArray arr2;
worm.CreateSectionRoomAddition(ln,eType,arr2);
for (int i = 0; i < arr2.length(); i++)
{
pEnt = (AcDbEntity*)arr2.at(i);
m_wndViewCtrl.Add(pEnt);
}
m_wndViewCtrl.Add(pEWRegion);
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.Invalidate();
m_wndViewCtrl.RedrawWindow();
}
}
void CTJTZDlg::OnBnClickedOk()
{
UpdateData();
if (m_dW < 0.1 || m_dH < 0.3)
{
AfxMessageBox(_T("梯子宽高尺寸太小!请重新输入数据!"));
return;
}
if (m_idxRoom == -1)
{
AfxMessageBox(_T("请选择定位舱室!"));
return;
}
UIDataCache::Write(_T("%d%d%i%d%d%i%s"), _T("CTJTZDlg")
, &m_dW , &m_dH
, &m_nKind
, &m_dX , &m_dA
, &m_idxRoom
, &m_sCrossSectionScr);
OnOK();
}
void CTJTZDlg::HitShEarthWorm(int idxRoom)
{
if (m_curSection.pReg != NULL)
{
AcGsView* pView = m_wndViewCtrl.view();
AcGsModel* pModel = m_wndViewCtrl.model();
//判断点落在region内
AcDbExtents ext;
AcDbCurve* pPl = NULL;
AcDbRegion* pRegion = NULL;
AcDbRay rayx1,rayx2;
AcDbCurve* pCurve = NULL;
AcGePoint3dArray arPts1,arPts2;
AcDbVoidPtrArray arCurPtrs,arSubEntPtrs;
if (idxRoom > -1 && idxRoom < m_arRegionRooms.length())
{
pRegion = (AcDbRegion*)m_arRegionRooms.at(idxRoom);
arCurPtrs.removeAll();
pRegion->explode(arCurPtrs);
arSubEntPtrs.removeAll();
pCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arSubEntPtrs);
pPl = AcDbCurve::cast(pCurve);
if (pPl != NULL)
{
pPl->intersectWith(&rayx1,AcDb::kOnBothOperands,arPts1);
pPl->intersectWith(&rayx2,AcDb::kOnBothOperands,arPts2);
if (!arPts1.isEmpty() && !arPts2.isEmpty())
{
if (pView != NULL && m_pRegionRoom != NULL)
{
pView->erase(m_pRegionRoom);
}
m_pRegionRoom = pRegion;
m_pRegionRoom->setColorIndex(6);
if (pView != NULL)
{
pView->add(m_pRegionRoom, pModel);
}
delete pPl;
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.RedrawWindow();
return;
}
}
}
}
}
LRESULT CTJTZDlg::OnViewShEwLButtonDown(WPARAM wp, LPARAM lp)
{
//鼠标点击的点
AcGePoint3d* pPt = (AcGePoint3d*)lp;
pPt->z = 0.0;
if (m_curSection.pReg != NULL)
{
AcGsView* pView = m_wndViewCtrl.view();
AcGsModel* pModel = m_wndViewCtrl.model();
//判断点落在region内
AcDbExtents ext;
AcDbCurve* pPl = NULL;
AcDbRegion* pRegion = NULL;
AcDbRay rayx1,rayx2;
AcDbCurve* pCurve = NULL;
AcGePoint3dArray arPts1,arPts2;
rayx1.setBasePoint(*pPt);
rayx1.setUnitDir(AcGeVector3d::kXAxis);
rayx2.setBasePoint(*pPt);
rayx2.setUnitDir(-AcGeVector3d::kXAxis);
AcDbVoidPtrArray arCurPtrs,arSubEntPtrs;
for (int i = 0;i < m_arRegionRooms.length();i++)
{
pRegion = (AcDbRegion*)m_arRegionRooms.at(i);
arCurPtrs.removeAll();
pRegion->explode(arCurPtrs);
arSubEntPtrs.removeAll();
pCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arSubEntPtrs);
pPl = AcDbCurve::cast(pCurve);
if (pPl != NULL)
{
pPl->intersectWith(&rayx1,AcDb::kOnBothOperands,arPts1);
pPl->intersectWith(&rayx2,AcDb::kOnBothOperands,arPts2);
if (!arPts1.isEmpty() && !arPts2.isEmpty())
{
if (pView != NULL && m_pRegionRoom != NULL)
{
pView->erase(m_pRegionRoom);
}
m_pRegionRoom = pRegion;
m_pRegionRoom->setColorIndex(6);
if (pView != NULL)
{
pView->add(m_pRegionRoom, pModel);
}
delete pPl;
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.RedrawWindow();
break;
}
delete pPl;
}
}
}
return 0L;
}
void CTJTZDlg::HitEarthWorm(int idxRoom)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
HitShEarthWorm(idxRoom);
return;
}
//判断 点落在 room 内
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0);
ESection eType = eRect;
AcGePoint2dArray arDatas;
eType = worm.ExtractEarthWormScr(arDatas);
AcGeLineSeg3d ln;
AcGePoint3d pt2(1000.0, 0, 0);
ln.set(AcGePoint3d::kOrigin, pt2);
AcGePoint3d ptGe[4];
AcDbVoidPtrArray arRegPtrs;
int nRooms = worm.CreateSectionRoomRegion(ln, eType, arDatas, arRegPtrs);
if (nRooms > 0)
{
if (idxRoom > -1 && idxRoom < arRegPtrs.length() )
{
AcDbRegion* pReg = (AcDbRegion*)arRegPtrs.at(idxRoom);
if (pReg != NULL)
{
AcDbExtents ext;
pReg->getGeomExtents(ext);
ptGe[0] = ext.minPoint();
ptGe[1] = ptGe[0];
ptGe[1].x = ext.maxPoint().x;
ptGe[2] = ext.maxPoint();
ptGe[3] = ptGe[0];
ptGe[3].y = ext.maxPoint().y;
AcGsView* pView = m_wndViewCtrl.view();
AcGsModel* pModel = m_wndViewCtrl.model();
if (pView != NULL)
{
if (m_pRectCell != NULL)
pView->erase(m_pRectCell);
}
if (m_pRectCell != NULL)
{
for (int i = 0; i < 4; i++)
{
m_pRectCell->setPointAt(i, ptGe[i].convert2d(AcGePlane::kXYPlane));
}
}
if (pView != NULL)
{
pView->add(m_pRectCell, pModel);
}
}
}
FreeBuffer(arRegPtrs);
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.RedrawWindow();
UpdateData(FALSE);
}
}
void CTJTZDlg::ShowShEarthWorm()
{
//1.截面
CString sFullPath = FilePath::GetSysDir();
sFullPath.MakeLower();
sFullPath += _T("\\DGJM.sat");
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)
{
m_curSection.pReg = pRegion;
}
if (m_curSection.pReg != NULL)
{
ExtractRegionRooms();
ShowEwSection();
}
}
}
//2.壁厚
sFullPath = FilePath::GetSysDir();
sFullPath.MakeLower();
sFullPath += _T("\\DGJM.ext");
CString sLine;
CStdioFile file;
if (file.Open(sFullPath,CFile::modeRead | CFile::typeText))
{
file.ReadString(sLine);
file.Close();
sLine.TrimRight(_T('\n'));
CStringArray arInf;
SplitStrintToArray(sLine,arInf,_T(','));
if (arInf.GetSize() >= 6)
{
m_curSection.pt.set(_ttof(arInf.GetAt(0)),_ttof(arInf.GetAt(1)),0.0);
m_curSection.dThick[0] = _ttof(arInf.GetAt(2));
m_curSection.dThick[1] = _ttof(arInf.GetAt(3));
m_curSection.dThick[2] = _ttof(arInf.GetAt(4));
m_curSection.dThick[3] = _ttof(arInf.GetAt(5));
}
}
//3.名称
sFullPath = FilePath::GetSysDir();
sFullPath.MakeLower();
sFullPath += _T("\\DGJM.nam");
CString sIndex,sName;
AcDbText* pText = NULL;
AcGePoint3d ptIns;
CStringArray arInf;
if (file.Open(sFullPath,CFile::modeRead | CFile::typeText))
{
sLine = _T("");
while(file.ReadString(sLine))
{
sLine.TrimRight(_T('\n'));
arInf.RemoveAll();
SplitStrintToArray(sLine,arInf,_T(','));
if (arInf.GetSize() >= 4)
{
sIndex = arInf.GetAt(0);
sName = arInf.GetAt(1);
m_mapIndexToName.SetAt(sIndex,sName);
}
}
file.Close();
}
ExtractRegionRooms();
//4.显示附件
sFullPath = FilePath::GetSysDir();
sFullPath.MakeLower();
sFullPath += _T("\\DGJM.adt");
if (file.Open(sFullPath,CFile::modeRead | CFile::typeText))
{
sLine = _T("");
file.ReadString(sLine);
sLine.TrimRight(_T('\n'));
m_sAddtionScr = sLine;
m_mapAddtion.RemoveAll();
ExtrAddtionToMap();
file.Close();
}
ShowAddtion();
ShowRoomName();
UpdateData(FALSE);
UpdateWindow();
}
void CTJTZDlg::ExtrAddtionToMap( )
{
m_mapAddtion.RemoveAll();
int nPos = m_sAddtionScr.Find(_T("EXT:"));
if (nPos != -1)
{
//EXT:
if (nPos + 4 < m_sAddtionScr.GetLength() )
{
CString sName;
CString sExt = m_sAddtionScr.Mid(nPos + 4);
//<><><><><><>.....
CString sScript,sScriptT,sScript2,sScriptNewVer;
CString sKey,sOld;
int nSta = 0,nPos2 = 0,nRoomIndex = 0,nLRPos = 0,nNo = 1;
nPos = sExt.Find(_T('<'),nSta);
while(nPos != -1)
{
nPos2 = sExt.Find(_T('>'),nPos + 1);
if (nPos2 == -1)
break;
//..<***>...
sScript = sExt.Mid(nPos + 1,nPos2 - nPos - 1);
if (sScript.Find( EW_HOLDER ) != -1)
{
//HOLDER:房间|左右位置|层数|垂直间隙|水平间隙|距顶D|长度|宽度|厚度|材料|用途|偏移=(,,,)|编号
sScriptT = sScript;
sScriptT.TrimLeft(EW_HOLDER);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 12)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
nLRPos = _ttoi(arInf.GetAt(1));
if (arInf.GetSize() > 12)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"),nNo);
sScriptNewVer =sScript + sOld;
m_sAddtionScr.Replace(sScript,sScriptNewVer);
sScript = sScriptNewVer;
}
sKey.Format(_T("%d-%d-%d-HOLDER"),nRoomIndex,nLRPos,nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_BOSS) != -1)
{
//<BOSS:房间|左右位置|侧间隙|水平间隙|宽|高|长|直径|用途>
sScriptT = sScript;
sScriptT.TrimLeft(EW_BOSS);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 9)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
if (arInf.GetSize() > 16)
nLRPos = _ttoi(arInf.GetAt(16));
sKey.Format(_T("%d-%d-BOSS"),nRoomIndex,nLRPos);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find( EW_HANGER ) != -1)
{
//HANGER:房间|层数|垂直间隙|水平间隙|左侧距离|距顶D|长度|宽度|厚度|材料|用途|偏移(,,,)
sScriptT = sScript;
sScriptT.TrimLeft(EW_HANGER);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 11)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-HANGER"),nRoomIndex,0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_RINGS) != -1)
{
//RINGS:房间|半径|长度|位置|材料|用途
sScriptT = sScript;
sScriptT.TrimLeft(EW_RINGS);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT,arInf,_T('|'));
if (arInf.GetSize() >= 9)
{
nNo = _ttoi(arInf.GetAt(8));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 7)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-RINGS"),nRoomIndex,0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_LAMPS) != -1)
{
//LAMPS:房间|长度|宽度|厚度|左侧定位|纵向间距|瓦数|名称|型好|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_LAMPS);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 12)
{
nNo = _ttoi(arInf.GetAt(11));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-LAMPS"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_FIREET) != -1)
{
//FIREET:房间|安装方式|安装位置|X直径L|Y直径H|上间隙TSP|下间隙DSP|填充量|工作温度|性能|型号|名称|类别|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_FIREET);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 16)
{
nNo = _ttoi(arInf.GetAt(15));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 13)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nSetup = _ttoi(arInf.GetAt(1));
int nHSetup = _ttoi(arInf.GetAt(2));
CString sTemp;
sTemp.Format(_T("1%d%d"),nSetup,nHSetup);
sKey.Format(_T("%d-%s-%d-FIREET"), nRoomIndex, sTemp, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_GUTTERWAY) != -1)
{
sKey.Format(_T("%d-%d-GUTTERWAY"), 0, 0);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript);
}
else if (sScript.Find(EW_FIREDOOR) != -1)
{
//FIREDOOR:房间|宽|高|位置|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_FIREDOOR);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 8)
{
nNo = _ttoi(arInf.GetAt(7));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 5)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-FIREDOOR"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_SECURITY) != -1)
{
//SECURITY:房间|大径|小径|高度|定位|间距|名称|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_SECURITY);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 11)
{
nNo = _ttoi(arInf.GetAt(10));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 9)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-SECURITY"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_DRAFAN) != -1)
{
//DRAFAN:房间|外径|长度|吊高|间距|风量|功率|机号|名称|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_DRAFAN);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 11)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-DRAFAN"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_GASALARM) != -1)
{
//GASALARM:房间|位置|高度|长|宽|厚|间距|名称|等级|型号|厂家
sScriptT = sScript;
sScriptT.TrimLeft(EW_GASALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 11)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
nLRPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-GASALARM"), nRoomIndex, nLRPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if(sScript.Find(EW_ROOMSLAB) != -1)
{
//ROOMSLAB: 房间|位置方向|距离|子舱宽|板厚度|偏移x|偏移y|编号
sScriptT = sScript;
sScriptT.TrimLeft(EW_ROOMSLAB);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 8)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
CString sNo = arInf.GetAt(7);
sKey.Format(_T("%d-%s-ROOMSLAB"), nRoomIndex, sNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_SMOKALARM) != -1)
{
//SMOKALARM:房间|位置|间距|外径|高度|名称|编号|规格|厂家|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_SMOKALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 11)
{
nNo = _ttoi(arInf.GetAt(10));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
sKey.Format(_T("%d-%d-%d-SMOKALARM"), nRoomIndex, 0, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_TEMPALARM) != -1)
{
//TEMPALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|编号|规格|厂家|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_TEMPALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-TEMPALARM"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_COALARM) != -1)
{
//COALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|浓度|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_COALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 12)
{
nNo = _ttoi(arInf.GetAt(11));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-COALARM"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_OXALARM) != -1)
{
//OXALARM:房间|左右侧|位置|间距|宽度|高度|厚度|名称|采样方式|测量精度|厂家|偏移
sScriptT = sScript;
sScriptT.TrimLeft(EW_OXALARM);
sScriptT.TrimLeft(_T(':'));
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 13)
{
nNo = _ttoi(arInf.GetAt(12));
}
else//旧版本
{
static int nNum = 1;
nNo = nNum++;
sOld.Format(_T("|%d"), nNo);
sScriptNewVer = sScript + sOld;
m_sAddtionScr.Replace(sScript, sScriptNewVer);
sScript = sScriptNewVer;
}
if (arInf.GetSize() >= 10)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nPos = _ttoi(arInf.GetAt(1));
sKey.Format(_T("%d-%d-%d-OXALARM"), nRoomIndex, nPos, nNo);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
}
}
else if (sScript.Find(EW_ROOMNAME) != -1)
{
//ROOMNAME:房间|中心x|中心y|名称 -->x,y放大100倍
sScriptT = sScript;
sScriptT.TrimLeft(EW_ROOMNAME);
sScriptT.TrimLeft(_T(':'));
//判断是否分舱
//double dCenX = (pt[0].x + pt[2].x) / 2.0;
//double dCenY = (pt[0].y + pt[2].y) / 2.0;
//CString sKey,sVal;
//sKey.Format(_T("%d|%d|%d|ROOMNAME"), nRoomIndex, (int)( 100.0 * dCenX ),(int)(100.0 * dCenY) );//放大100倍
//sVal.Format(_T("<ROOMNAME:%d|%d|%d|%s>"),nRoomIndex,(int)( 100.0 * dCenX ),(int)(100.0 * dCenY),m_sRoomName);
//m_mapAddtion.SetAt(sKey,sVal);
CStringArray arInf;
SplitStrintToArray(sScriptT, arInf, _T('|'));
if (arInf.GetSize() >= 4)
{
nRoomIndex = _ttoi(arInf.GetAt(0));
int nCenX = _ttoi(arInf.GetAt(1));
int nCenY = _ttoi(arInf.GetAt(2));
sName = arInf.GetAt(3);
sKey.Format(_T("%d|%d|%d|ROOMNAME"),nRoomIndex,nCenX,nCenY);
sScript2.Format(_T("<%s>"),sScript);
m_mapAddtion.SetAt(sKey,sScript2);
m_mapIndexToName.SetAt(arInf.GetAt(0),sName);
}
}
else if (sScript.Find(EW_CHARMNO) != -1)
{
//盾构没有倒角
}
nSta += sScript.GetLength();
nPos = sExt.Find(_T('<'),nSta);
}
}
}
}
void CTJTZDlg::ShowEwSection()
{
if (m_curSection.pReg != NULL)
{
m_arDrawBuffer.removeAll();
m_wndViewCtrl.clearAll();
m_wndViewCtrl.init(true);
m_wndViewCtrl.SetOrbitFlag(OBF_PAN | OBF_ZOOM | OBF_COTE);
AcDbExtents exts;
m_curSection.pReg->getGeomExtents(exts);
m_wndViewCtrl.InitFromCurrentView2D(exts,true);
m_wndViewCtrl.Add(m_curSection.pReg);
m_arDrawBuffer.append(m_curSection.pReg);
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.Invalidate();
m_wndViewCtrl.RedrawWindow();
}
}
void CTJTZDlg::FormatAddtionScr()
{
m_sAddtionScr = _T("");
CString sExt = _T("EXT:"),sKey,sExtVal;
for (POSITION ps = m_mapAddtion.GetStartPosition();ps != NULL;)
{
m_mapAddtion.GetNextAssoc(ps,sKey,sExtVal);
sExt += sExtVal;
}
if (sExt.CompareNoCase(_T("EXT:")) != 0)
{
m_sAddtionScr += sExt;
}
}
void CTJTZDlg::ShowAddtion()
{
//合成脚本
FormatAddtionScr();
if (!m_sAddtionScr.IsEmpty())
{
AecDbShEarthWorm shWorm;
AcGePoint3d ptEnd(100,0,0);
AcDbLine ln(AcGePoint3d(0,0,0),ptEnd);
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
pRoadLn->AppendCurveSeg(&ln);
shWorm.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 2);
shWorm.SetSection(m_curSection.pReg,m_curSection.pt);
shWorm.SetBaseCurve(pRoadLn);
shWorm.SetAddtionScr(m_sAddtionScr);
AcDbVoidPtrArray arCurPtrs;
shWorm.GetAddtionSection(arCurPtrs);
AcGsView* pView = m_wndViewCtrl.view();
AcGsModel* pModel = m_wndViewCtrl.model();
AcDbEntity* pEnt = NULL;
for (int i = 0;i < arCurPtrs.length();i++)
{
pEnt = (AcDbEntity*)arCurPtrs.at(i);
pView->add(pEnt, pModel);
m_arDrawBuffer.append(pEnt);
}
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.RedrawWindow();
}
}
STSection* CTJTZDlg::GetShEwSection() const
{
if (m_sCrossSectionScr.Find(_T("RECT")) != -1)
{
return NULL;
}
AcGePoint3d pt(0,0,0);
CString sFullPath = FilePath::GetSysDir();
sFullPath.MakeLower();
sFullPath += _T("\\DGJM.sat");
STSection* pSection = new STSection;
pSection->pt = pt;
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;
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;
}
void CTJTZDlg::ShowRoomName()
{
CString sKey,sName;
AcDbRegion* pRegion = NULL;
AcDbText* pText = NULL;
//延着整体圆排序
double perimeter;
double area;
AcGePoint2d centroid;
double momInertia[2];
double prodInertia;
double prinMoments[2];
AcGeVector2d prinAxes[2];
double radiiGyration[2];
AcGePoint2d extentsLow;
AcGePoint2d extentsHigh;
AcGePoint3d ptIns;
for (int i = 0;i < m_arRegionRooms.length();i++)
{
pRegion = (AcDbRegion*)m_arRegionRooms.at(i);
pRegion->getAreaProp(AcGePoint3d::kOrigin,AcGeVector3d::kXAxis,AcGeVector3d::kYAxis,
perimeter,
area,
centroid,
momInertia,
prodInertia,
prinMoments,
prinAxes,
radiiGyration,
extentsLow,
extentsHigh);
sKey.Format(_T("%d"),i);
ptIns.set(centroid.x,centroid.y,0.0);
if (m_mapIndexToName.Lookup(sKey,sName))
{
pText = NULL;
if (m_mapIndexToDbText.Lookup(sKey,(void*&)pText))
{
pText->setPosition(ptIns);
pText->setTextString(sName);
}
else
{
ptIns.set(centroid.x,centroid.y,0.0);
pText = new AcDbText(ptIns,sName,acdbCurDwg()->textstyle(),0.15,0.0);
pText->setHeight(.15);
pText->setColorIndex(1);
pText->setTextStyle(acdbCurDwg()->textstyle());
pText->setHorizontalMode(AcDb::kTextLeft);
m_mapIndexToDbText.SetAt(sKey,pText);
}
if (pText != NULL)
{
m_wndViewCtrl.view()->erase(pText);
m_wndViewCtrl.Add(pText);
if (m_arDrawBuffer.find(pText) == -1)
m_arDrawBuffer.append(pText);
}
}
}
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.Invalidate();
m_wndViewCtrl.RedrawWindow();
}
void CTJTZDlg::ExtractRegionRooms()
{
if (m_curSection.pReg != NULL)
{
AecDbShEarthWorm::ExtractRegionRooms(m_arRegionRooms,m_curSection.pReg);
}
}
int CTJTZDlg::GetX3dSolidRecs( AecDbX3dGroup*& pGroup)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
return GetX3dSolidRecsShEw(pGroup);
}
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
AecDbEarthWorm worm;
worm.SetCrossSectionScr(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;
if (pGroup != NULL)
{
pGroup->RemoveAll3dSolidRec();
}
else
{
pGroup = new AecDbX3dGroup;
}
AcArray<ERoom> arRooms;
ERoom room;
AcGePoint2d ptThick;
AcGeLineSeg3d ln(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0.0,0));
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
if (m_idxRoom < 0)
{
AfxMessageBox(_T("没有选择舱室,请选择舱室!"));
return FALSE;
}
room = arRooms.at(m_idxRoom);
AcGePoint3d ptFr;
Midpoint(room.ptGe[0],room.ptGe[1],ptFr);
ptFr.x = m_dX;
//vtDirX 梯子踏脚钢管方向 人两脚连线方向;
//vtDirXY 踏脚凸起方向 人背法向量 ptGe ptGe 开始中点
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
double dAng = m_dA * PI / 180.0;
vtDirX.rotateBy(dAng,AcGeVector3d::kZAxis);
AcGeVector3d vtDirXY = vtDirX;
vtDirXY.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
AcDbX3dSolid* pXSolid = NULL;
pXSolid = new AcDbX3dSolid;
pXSolid->CreateLadder(ptFr,vtDirX,vtDirXY,1000.0 * m_dH,1000.0 * m_dW,m_nKind);//毫米
X3dSolidRec rec;
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
pGroup->SetOrgPoint( ptFr );
pGroup->SetAxis(X,AcGeVector3d::kXAxis);
pGroup->SetAxis(Y,AcGeVector3d::kYAxis);
pGroup->SetAxis(Z,AcGeVector3d::kZAxis);
//序列化BIM数据
pGroup->GetSpecialtyData()->SetAt(_T("m_dW"),m_dW);
pGroup->GetSpecialtyData()->SetAt(_T("m_dH"),m_dH);
pGroup->GetSpecialtyData()->SetAt(_T("m_nKind"),m_nKind);
pGroup->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
pGroup->GetSpecialtyData()->SetAt(_T("m_dA"),m_dA);
pGroup->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pGroup->GetSpecialtyData()->SetAt(_T("BIMDATA"),1,m_mapBimData);
return TRUE;
}
int CTJTZDlg::GetX3dSolidRecsShEw(AecDbX3dGroup*& pGroup)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
AecDbShEarthWorm dbEW;
AcGePoint3d ptSta(0,0,0);
AcGePoint3d ptEnd(10,0,0);
AcDbLine ln(ptSta,ptEnd);
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
pRoadLn->AppendCurveSeg(&ln);
STSection* pSection = GetShEwSection();
if (pSection == NULL )
{
return 0;
}
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;
//外壁厚,内隔壁厚
double dOutW = 0.0,dIntW = 0.0;
dOutW = AS_MUNIT(pSection->dThick[0]);
dIntW = AS_MUNIT(pSection->dThick[1]);
double dSideAdd(.0);
double dR = 0.0;
double dL = 0.0;
AcGePoint2d ptrODtTop,ptrODtBom,ptODt;
dbEW.GetODAndID(ptrODtTop,ptrODtBom);
dbEW.GetODAndThick(ptODt);
//总高度
double dHeight = ptrODtTop.x;
//总宽度
double dWidth = ptODt.x;
if (pGroup != NULL)
{
pGroup->RemoveAll3dSolidRec();
}
else
{
pGroup = new AecDbX3dGroup;
}
AcArray<ERoom> arRooms;
ERoom room;
AcGePoint2d ptThick;
AcGeLineSeg3d ln3d(ptSta,ptEnd);
dbEW.GetSectionRoomsTo(ln3d,arRooms,ptThick);
if (m_idxRoom < 0)
{
AfxMessageBox(_T("没有选择舱室,请选择舱室!"));
return FALSE;
}
room = arRooms.at(m_idxRoom);
AcGePoint3d ptFr;
Midpoint(room.ptGe[0],room.ptGe[1],ptFr);
ptFr.x = m_dX;
//vtDirX 梯子踏脚钢管方向 人两脚连线方向;
//vtDirXY 踏脚凸起方向 人背法向量 ptGe ptGe 开始中点
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
double dAng = m_dA * PI / 180.0;
vtDirX.rotateBy(dAng,AcGeVector3d::kZAxis);
AcGeVector3d vtDirXY = vtDirX;
vtDirXY.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
AcDbX3dSolid* pXSolid = NULL;
pXSolid = new AcDbX3dSolid;
pXSolid->CreateLadder(ptFr,vtDirX,vtDirXY,1000.0 * m_dH,1000.0 * m_dW,m_nKind);//毫米
X3dSolidRec rec;
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
pGroup->SetOrgPoint( ptFr );
pGroup->SetAxis(X,AcGeVector3d::kXAxis);
pGroup->SetAxis(Y,AcGeVector3d::kYAxis);
pGroup->SetAxis(Z,AcGeVector3d::kZAxis);
//序列化BIM数据
pGroup->GetSpecialtyData()->SetAt(_T("m_dW"),m_dW);
pGroup->GetSpecialtyData()->SetAt(_T("m_dH"),m_dH);
pGroup->GetSpecialtyData()->SetAt(_T("m_nKind"),m_nKind);
pGroup->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
pGroup->GetSpecialtyData()->SetAt(_T("m_dA"),m_dA);
pGroup->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pGroup->GetSpecialtyData()->SetAt(_T("BIMDATA"),1,m_mapBimData);
return TRUE;
}
return TRUE;
}
int CTJTZDlg::GetX3dPart( AecDbX3dPart*& pPart)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
return GetX3dPartShEw(pPart);
}
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
AecDbEarthWorm worm;
worm.SetCrossSectionScr(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;
if (pPart != NULL)
{
pPart->RemoveAll3dSolidRec();
}
else
{
pPart = new AecDbX3dPart;
}
AcArray<ERoom> arRooms;
ERoom room;
AcGePoint2d ptThick;
AcGeLineSeg3d ln(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0.0,0));
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
if (m_idxRoom < 0)
{
AfxMessageBox(_T("没有选择舱室,请选择舱室!"));
return FALSE;
}
room = arRooms.at(m_idxRoom);
AcGePoint3d ptFr;
Midpoint(room.ptGe[0],room.ptGe[1],ptFr);
ptFr.x = m_dX;
//vtDirX 梯子踏脚钢管方向 人两脚连线方向;
//vtDirXY 踏脚凸起方向 人背法向量 ptGe ptGe 开始中点
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
double dAng = m_dA * PI / 180.0;
vtDirX.rotateBy(dAng,AcGeVector3d::kZAxis);
AcGeVector3d vtDirXY = vtDirX;
vtDirXY.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
AcDbX3dSolid* pXSolid = NULL;
pXSolid = new AcDbX3dSolid;
pXSolid->CreateLadder(ptFr,vtDirX,vtDirXY,1000.0 * m_dH,1000.0 * m_dW,m_nKind);//毫米
pPart->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
pPart->SetOrgPoint( ptFr );
pPart->SetAxis(X,AcGeVector3d::kXAxis);
pPart->SetAxis(Y,AcGeVector3d::kYAxis);
pPart->SetAxis(Z,AcGeVector3d::kZAxis);
//序列化BIM数据
pPart->GetSpecialtyData()->SetAt(_T("m_dW"),m_dW);
pPart->GetSpecialtyData()->SetAt(_T("m_dH"),m_dH);
pPart->GetSpecialtyData()->SetAt(_T("m_nKind"),m_nKind);
pPart->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
pPart->GetSpecialtyData()->SetAt(_T("m_dA"),m_dA);
pPart->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pPart->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pPart->GetSpecialtyData()->SetAt(_T("BIMDATA"),1,m_mapBimData);
return TRUE;
}
int CTJTZDlg::GetX3dPartShEw( AecDbX3dPart*& pPart)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
AecDbShEarthWorm dbEW;
AcGePoint3d ptSta(0,0,0);
AcGePoint3d ptEnd(10,0,0);
AcDbLine ln(ptSta,ptEnd);
AecDb3dRoadAxisLine* pRoadLn = new AecDb3dRoadAxisLine;
pRoadLn->AppendCurveSeg(&ln);
STSection* pSection = GetShEwSection();
if (pSection == NULL )
{
return 0;
}
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;
//外壁厚,内隔壁厚
double dOutW = 0.0,dIntW = 0.0;
dOutW = AS_MUNIT(pSection->dThick[0]);
dIntW = AS_MUNIT(pSection->dThick[1]);
double dSideAdd(.0);
double dR = 0.0;
double dL = 0.0;
AcGePoint2d ptrODtTop,ptrODtBom,ptODt;
dbEW.GetODAndID(ptrODtTop,ptrODtBom);
dbEW.GetODAndThick(ptODt);
//总高度
double dHeight = ptrODtTop.x;
//总宽度
double dWidth = ptODt.x;
if (pPart != NULL)
{
pPart->RemoveAll3dSolidRec();
}
else
{
pPart = new AecDbX3dPart;
}
AcArray<ERoom> arRooms;
ERoom room;
AcGePoint2d ptThick;
AcGeLineSeg3d ln3d(ptSta,ptEnd);
dbEW.GetSectionRoomsTo(ln3d,arRooms,ptThick);
if (m_idxRoom < 0)
{
AfxMessageBox(_T("没有选择舱室,请选择舱室!"));
return FALSE;
}
room = arRooms.at(m_idxRoom);
AcGePoint3d ptFr;
Midpoint(room.ptGe[0],room.ptGe[1],ptFr);
ptFr.x = m_dX;
//vtDirX 梯子踏脚钢管方向 人两脚连线方向;
//vtDirXY 踏脚凸起方向 人背法向量 ptGe ptGe 开始中点
AcGeVector3d vtDirX = AcGeVector3d::kXAxis;
double dAng = m_dA * PI / 180.0;
vtDirX.rotateBy(dAng,AcGeVector3d::kZAxis);
AcGeVector3d vtDirXY = vtDirX;
vtDirXY.rotateBy(-PI / 2.0,AcGeVector3d::kZAxis);
AcDbX3dSolid* pXSolid = NULL;
pXSolid = new AcDbX3dSolid;
pXSolid->CreateLadder(ptFr,vtDirX,vtDirXY,1000.0 * m_dH,1000.0 * m_dW,m_nKind);//毫米
pPart->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
pPart->SetOrgPoint( ptFr );
pPart->SetAxis(X,AcGeVector3d::kXAxis);
pPart->SetAxis(Y,AcGeVector3d::kYAxis);
pPart->SetAxis(Z,AcGeVector3d::kZAxis);
//序列化BIM数据
pPart->GetSpecialtyData()->SetAt(_T("m_dW"),m_dW);
pPart->GetSpecialtyData()->SetAt(_T("m_dH"),m_dH);
pPart->GetSpecialtyData()->SetAt(_T("m_nKind"),m_nKind);
pPart->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
pPart->GetSpecialtyData()->SetAt(_T("m_dA"),m_dA);
pPart->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pPart->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pPart->GetSpecialtyData()->SetAt(_T("BIMDATA"),1,m_mapBimData);
}
return TRUE;
}
void CTJTZDlg::OnBnClickedButton1()
{
CBimInfoDlg::ShowBimInfo(&m_mapBimData,_T("梯子"));
}