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

3129 lines
78 KiB
C++

#include "stdafx.h"
#include "GLBJDlg.h"
#include "AecDbX3dGroup.h"
#include "AecDbEarthWorm.h"
#include "KTCADUtilityEx.h"
#include "AcDbX3dSolid.h"
#include "uitools.h"
#include "AecDbObjXDataMap.h"
#include "CCSYDlg.h"
#include "AecDbShEarthWorm.h"
#include "AecDb3dRoadAxisLine.h"
#include "coreTools.h"
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;
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(CGLBJDlg, CDialog)
CGLBJDlg::CGLBJDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGLBJDlg::IDD, pParent)
, m_dCurRoomW(0)
, m_dWAdd(2)//增加
, m_dOpenL(2)//开口
, m_dB(5)
, m_dAngle(90)
, m_bAllRoom(FALSE)
, m_nPos(0)
, m_dA2(90)
, m_dZOff(0)
, m_dTAdd(0.2)
, m_dHoleH(0.4)
, m_dH(0)
{
m_bIsAddRec = false;
m_dLen = 0.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);
m_pGLBJXDataMap = NULL;
UIDataCache::Read(_T("%d%d%d%d%d%i%i%s%i%d%d"), _T("CGLBJDlg")
, &m_dCurRoomW, &m_dWAdd, &m_dOpenL, &m_dB , &m_dAngle
, &m_bAllRoom, &m_idxRoom
, &m_sCrossSectionScr
, &m_nPos
, &m_dLen
, &m_dA2);
m_curSection.pReg = NULL;
m_curSection.pt.set(0,0,0);
m_sCrossSectionScr = _T("");
m_sAddtionScr = _T("");
m_idxRoom = 0;
m_pRegionRoom = NULL;
}
CGLBJDlg::~CGLBJDlg()
{
}
void CGLBJDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, m_dCurRoomW);
DDX_Text(pDX, IDC_EDIT2, m_dWAdd);
DDX_Text(pDX, IDC_EDIT10, m_dOpenL);
DDX_Text(pDX, IDC_EDIT34, m_dB);
DDX_Text(pDX, IDC_EDIT3, m_dAngle);
DDX_Check(pDX, IDC_CHECK1, m_bAllRoom);
DDX_Control(pDX, IDC_EDIT10, m_wndEditL);
DDX_Control(pDX, IDC_EDIT34, m_wndEditB);
DDX_Control(pDX, IDC_EDIT3, m_wndEditA);
DDX_Radio(pDX, IDC_RADIO1, m_nPos);
DDX_Text(pDX, IDC_EDIT4, m_dA2);
DDX_Control(pDX, IDOK, m_wndBtOk);
DDX_Control(pDX, IDC_BUTTON2, m_wndBtAdd);
DDX_Control(pDX, IDC_COMBO1, m_wndCombo);
DDX_Control(pDX, IDC_BUTTON11, m_wndBtUpdate);
DDX_Control(pDX, IDC_EDIT4, m_wndEditA2);
DDX_Control(pDX, IDC_LIST1, m_wndRecordList);
DDX_Control(pDX, IDC_BUTTON3, m_wndDelRecBt);
DDX_Control(pDX, IDC_STATIC_SP, m_wndStaticSP);
DDX_Control(pDX, IDCANCEL, m_wndBtCan);
DDX_Text(pDX, IDC_EDIT6, m_dZOff);
DDX_Text(pDX, IDC_EDIT35, m_dTAdd);
DDX_Text(pDX, IDC_EDIT36, m_dHoleH);
DDX_Text(pDX, IDC_EDITH5, m_dH);
DDX_Control(pDX, IDC_EDITH5, m_wndH5);
}
BEGIN_MESSAGE_MAP(CGLBJDlg, CDialog)
ON_BN_CLICKED(IDC_CHECK1, &CGLBJDlg::OnBnClickedCheck1)
ON_BN_CLICKED(IDOK, &CGLBJDlg::OnBnClickedOk)
ON_MESSAGE(WM_VIEW_LBUTTONDOWN, &CGLBJDlg::OnViewLButtonDown)
ON_BN_CLICKED(IDC_BUTTON2, &CGLBJDlg::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON1, &CGLBJDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON11, &CGLBJDlg::OnBnClickedButton11)
ON_NOTIFY(NM_CLICK, IDC_LIST1, &CGLBJDlg::OnNMClickList1)
ON_BN_CLICKED(IDC_BUTTON3, &CGLBJDlg::OnBnClickedButton3)
END_MESSAGE_MAP()
BOOL CGLBJDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 子类化控件对象
if (!m_wndViewCtrl.SubclassDlgItem(IDC_STATIC_EW, this))
{
// 错误时,结束对话框
EndDialog(IDCANCEL);
return FALSE;
}
m_ImageList.Create(IDB_BITMAP2,16,1,RGB(0, 255, 255));
m_wndRecordList.SetImageList(&m_ImageList,LVSIL_SMALL);
m_wndRecordList.InsertColumn(0,_T("记录"),LVCFMT_LEFT,300,300);
m_wndRecordList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
if (!m_bIsAddRec)
{
CRect rc;
m_wndRecordList.GetWindowRect(&rc);
ScreenToClient(rc);
m_wndBtAdd.EnableWindow(FALSE);
m_wndBtAdd.ShowWindow(SW_HIDE);
m_wndCombo.EnableWindow(FALSE);
m_wndCombo.ShowWindow(SW_HIDE);
m_wndBtUpdate.EnableWindow(FALSE);
m_wndBtUpdate.ShowWindow(SW_HIDE);
m_wndRecordList.EnableWindow(FALSE);
m_wndRecordList.ShowWindow(SW_HIDE);
m_wndDelRecBt.EnableWindow(FALSE);
m_wndDelRecBt.ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_V)->EnableWindow(FALSE);
GetDlgItem(IDC_STATIC_V)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_EDIT6)->EnableWindow(FALSE);
GetDlgItem(IDC_EDIT6)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_VM)->EnableWindow(FALSE);
GetDlgItem(IDC_STATIC_VM)->ShowWindow(SW_HIDE);
AdjustWindowsNoAddRec(rc);
}
else
{
ReloadFromXDataMap();
}
if (m_dA2 < 1.e-3)
m_dA2 = m_dAngle;
ShowEarthWorm();
if (m_idxRoom > -1)
{
HitEarthWorm(m_idxRoom);
}
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
m_wndH5.SetReadOnly(FALSE);
}
UpdateData(FALSE);
return TRUE;
}
void CGLBJDlg::AdjustWindowsNoAddRec(CRect& rcA)
{
CRect rc;
m_wndStaticSP.GetWindowRect(&rc);
ScreenToClient(&rc);
int nOffset = rcA.top - rc.top;
rc.OffsetRect(0,nOffset);
m_wndStaticSP.MoveWindow(rc);
m_wndDelRecBt.GetWindowRect(&rc);
ScreenToClient(&rc);
rc.OffsetRect(0,nOffset);
m_wndDelRecBt.MoveWindow(rc);
m_wndBtCan.GetWindowRect(&rc);
ScreenToClient(rc);
rc.OffsetRect(0,nOffset);
m_wndBtCan.MoveWindow(rc);
m_wndBtOk.GetWindowRect(&rc);
ScreenToClient(rc);
rc.OffsetRect(0,nOffset);
m_wndBtOk.MoveWindow(rc);
GetWindowRect(&rc);
rc.bottom += nOffset;
MoveWindow(&rc);
}
void CGLBJDlg::ReloadFromXDataMap()
{
if (m_pGLBJXDataMap != NULL)
{
for (int i = 0;i < 10;i++)
{
AecDbObjXDataMap rcXDataMap;
if ( !m_pGLBJXDataMap->GetAt(_T("CGLBJDlg"),i,rcXDataMap) )
{
break;
}
GLBJRecord rc;
//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 = i;
CString sScr = _T("");
rcXDataMap.GetAt(_T("m_sCrossSectionScr"),sScr);
rc.szCrossSectionScr = sScr;
rcXDataMap.GetAt(_T("m_dLen"),rc.m_dLen);
CString sRecord,sPos;
sPos = rc.m_nPos == 0 ? _T("舱室向左侧变径") : _T("舱室向右侧变径");
sRecord.Format(_T("记录[ 第%d舱室 %s]"), rc.m_idxRoom + 1,sPos);
//m_wndCombo.AddString(sRecord);
m_wndRecordList.InsertItem(m_wndRecordList.GetItemCount(),sRecord,0);
m_arRecord.append(rc);
}
}
}
void CGLBJDlg::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);
//总高度
m_dH = arDatas.first().y;
m_dH += 2 * arDatas.last().x;
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 CGLBJDlg::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;
AcDbExtents ext;
pRegion->getGeomExtents(ext);
m_dH = ext.maxPoint().y - ext.minPoint().y;
}
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));
m_dHoleH = AS_MUNIT(m_curSection.dThick[0]);
}
}
//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 CGLBJDlg::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 CGLBJDlg::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 CGLBJDlg::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 CGLBJDlg::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();
}
}
void CGLBJDlg::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 CGLBJDlg::ExtractRegionRooms()
{
if (m_curSection.pReg != NULL)
{
AecDbShEarthWorm::ExtractRegionRooms(m_arRegionRooms,m_curSection.pReg);
}
}
LRESULT CGLBJDlg::OnViewLButtonDown(WPARAM wp, LPARAM lp)
{
UpdateData();
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
return OnViewShEwLButtonDown(wp,lp);
}
AcGePoint3d* pPt = (AcGePoint3d*)lp;
pPt->z = 0.0;
m_idxRoom = - 1;
m_dCurRoomW = 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;
m_dCurRoomW = ptGe[0].distanceTo(ptGe[1]);
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();
UpdateData(FALSE);
}
return 0L;
}
void CGLBJDlg::OnBnClickedCheck1()
{
UpdateData();
m_wndEditL.EnableWindow(!m_bAllRoom);
m_wndEditB.EnableWindow(!m_bAllRoom);
m_wndEditA.EnableWindow(!m_bAllRoom);
m_wndEditA2.EnableWindow(!m_bAllRoom);
}
void CGLBJDlg::OnBnClickedOk()
{
UpdateData();
if (!m_bIsAddRec)
{
if (m_dAngle - 90.0 > 1.e-10)
{
AfxMessageBox(_T("底角必须小于等于90度!且大于0"));
return;
}
if (m_dA2 - 90.0 > 1.e-10)
{
AfxMessageBox(_T("底角必须小于等于90度!且大于0"));
return;
}
if (m_idxRoom == -1)
{
AfxMessageBox(_T("请选择要变径的舱室!"));
return;
}
if ( m_dWAdd < 1.e-10)
{
AfxMessageBox(_T("宽度增量太小!必须大于0.01米!"));
return;
}
double dX = m_dOpenL - m_dWAdd * cos(m_dAngle * PI / 180.0) / sin(m_dAngle * PI / 180.0) - m_dWAdd * cos(m_dA2 * PI / 180.0) / sin(m_dA2 * PI / 180.0);
if (dX < 0.5)
{
CString sTemp;
sTemp.Format(_T("在 %g %g 度的情况下,计算出L 尺寸太小!"),m_dAngle,m_dA2);
AfxMessageBox(sTemp);
return;
}
UIDataCache::Write(_T("%d%d%d%d%d%i%i%s%i%d%d"), _T("CGLBJDlg")
, &m_dCurRoomW, &m_dWAdd, &m_dOpenL, &m_dB , &m_dAngle
, &m_bAllRoom , &m_idxRoom
, &m_sCrossSectionScr
, &m_nPos
, &m_dLen
, &m_dA2);
}
OnOK();
}
int CGLBJDlg::GetX3dSolidRecs(AecDbX3dGroup*& pGroup)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
return GetX3dSolidRecsShEw(pGroup);
}
if (pGroup != NULL)
{
pGroup->RemoveAll3dSolidRec();
}
else
{
pGroup = new AecDbX3dGroup;
}
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
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 dTopAdd = worm.GetTopThickAdd();
double dLRAdd = 0.0,dLAdd = 0.0,dRAdd = 0.0,dTAdd = 0.0;
int nLRPos = worm.GetLeftOrRightThickAdd(dLRAdd);
if (nLRPos == 0)
{
dLAdd = dLRAdd;
}
if (nLRPos == 1)
{
dRAdd = dLRAdd;
}
double dCharm = worm.GetChamferInter();
//总宽度
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(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0.0,0));
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
room = arRooms.at(m_idxRoom);
AcGePoint3d ptOrg;
AcGeVector3d vtZ;
X3dSolidRec rec;
dTAdd = m_dTAdd;
double dTLAdd = dTAdd;
AcDbX3dSolid* pXSolid = NULL;
if (m_bAllRoom)//整体
{
int nDir = (m_nPos == 0 ) ? 1 : -1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg.y += nDir * ( (m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 );
ptOrg.x = m_dLen / 2.0;
ptOrg.z = 0.0;
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * AcGeVector3d::kYAxis;
if ( (m_idxRoom == 0 && m_nPos == 0 ) ||
(m_idxRoom == arRooms.length() - 1 && m_nPos == 1) )//左外/右外
{
//原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_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 + dBomAdd);
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
if (m_idxRoom == 0)
{
dTAdd += dLAdd;
}
else if (m_idxRoom == arRooms.length() - 1)
{
dTAdd += dRAdd;
}
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen + 2 * dTAdd,dHeight + dBomAdd + dTopAdd,m_dWAdd + dOutW + dTAdd,PI / 2.0);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
pXSolid = new AcDbX3dSolid;
//ptOrg.z += 0.5 * dBomAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen,dHeight - 2 * dOutW,m_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,m_dLen + 2 * dTAdd,dHeight - 2 * dOutW, dIntW + dTAdd);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
//创建一新的
ptOrg += vtZ * m_dWAdd;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen,dHeight - 2 * dOutW, dIntW);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
}
else//局部
{
int nDir = (m_nPos == 0 ) ? 1 : -1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg.y += nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 );
ptOrg.x = m_dB + m_dOpenL * 0.5;
ptOrg.z = 0.0;//
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * AcGeVector3d::kYAxis;
double dB = ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
double dT = dB;
//内部原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dOpenL,dHeight - 2 * dOutW, dB);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
double dAng = m_dAngle * PI / 180.0;
double dAng2 = m_dA2 * PI / 180.0;
if (m_nPos == 0)
dB /= sin(dAng2);
else
dB /= sin(dAng);
if (m_idxRoom == 0)
{
dTAdd += dLAdd;
}
else if (m_idxRoom == arRooms.length() - 1)
{
dTAdd += dRAdd;
}
dTLAdd = dTAdd;
if (m_nPos == 0)
dTLAdd /= sin(dAng2);
else
dTLAdd /= sin(dAng);
//外
pXSolid = new AcDbX3dSolid;
ptOrg.y -= nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 );
double dRoomH = room.ptGe[0].distanceTo(room.ptGe[1]);
double dH = dHeight;//( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1 ) ? dHeight : dHeight - 2.0 * dOutW;
if (fabs(m_dAngle - m_dA2) < 1.e-3)
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd ,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
//挖去 四方台 LxWxHxAng
pXSolid = new AcDbX3dSolid;
//ptOrg.z += 0.5 * dBomAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL,dH - dOutW * 2.0,m_dWAdd,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
else
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
//挖去
pXSolid = new AcDbX3dSolid;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL,dH - dOutW * 2.0 ,m_dWAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
}
pGroup->SetOrgPoint( ptOrg );
pGroup->SetAxis(X,AcGeVector3d::kXAxis);
pGroup->SetAxis(Y,AcGeVector3d::kYAxis);
pGroup->SetAxis(Z,AcGeVector3d::kZAxis);
//序列化BIM数据
pGroup->GetSpecialtyData()->SetAt(_T("m_dCurRoomW"),m_dCurRoomW);
pGroup->GetSpecialtyData()->SetAt(_T("m_dWAdd"),m_dWAdd);
pGroup->GetSpecialtyData()->SetAt(_T("m_dOpenL"),m_dOpenL);
pGroup->GetSpecialtyData()->SetAt(_T("m_dB"),m_dB);
pGroup->GetSpecialtyData()->SetAt(_T("m_dAngle"),m_dAngle);
pGroup->GetSpecialtyData()->SetAt(_T("m_dA2"),m_dA2);
pGroup->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pGroup->GetSpecialtyData()->SetAt(_T("m_nPos"),m_nPos);
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pGroup->GetSpecialtyData()->SetAt(_T("m_dLen"),m_dLen);
pGroup->GetSpecialtyData()->SetAt(_T("m_dZOff"),m_dZOff);
pGroup->GetSpecialtyData()->SetAt(_T("m_dTAdd"),m_dTAdd);
pGroup->GetSpecialtyData()->SetAt(_T("m_dHoleH"),m_dHoleH);
pGroup->GetSpecialtyData()->SetAt(_T("m_dH"),m_dH);
return TRUE;
}
int CGLBJDlg::GetX3dSolidRecsShEw(AecDbX3dGroup*& pGroup)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
if (pGroup != NULL)
{
pGroup->RemoveAll3dSolidRec();
}
else
{
pGroup = new AecDbX3dGroup;
}
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]);
if (dOutW < m_dHoleH)
dOutW = m_dHoleH;
double dSideAdd(.0);
double dR = 0.0;
double dL = 0.0;
AcGePoint2d ptrODtTop,ptrODtBom,ptODt;
dbEW.GetODAndID(ptrODtTop,ptrODtBom);
dbEW.GetODAndThick(ptODt);
//总高度
double dHeight = m_dH;
//总宽度
double dWidth = ptODt.x;
//底部壁厚增加
double dBomAdd = 0.0;
double dTopAdd = 0.0;
double dLRAdd = 0.0,dLAdd = 0.0,dRAdd = 0.0,dTAdd = 0.0;
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 ptOrg;
AcGeVector3d vtZ;
X3dSolidRec rec;
dTAdd = m_dTAdd;
double dTLAdd = dTAdd;
AcDbX3dSolid* pXSolid = NULL;
if (m_bAllRoom)//整体
{
int nDir = (m_nPos == 0 ) ? 1 : -1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg.y += nDir * ( (m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 );
ptOrg.x = m_dLen / 2.0;
ptOrg.z = 0.0;
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * AcGeVector3d::kYAxis;
if ( (m_idxRoom == 0 && m_nPos == 0 ) ||
(m_idxRoom == arRooms.length() - 1 && m_nPos == 1) )//左外/右外
{
//原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_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 + dBomAdd);
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
if (m_idxRoom == 0)
{
dTAdd += dLAdd;
}
else if (m_idxRoom == arRooms.length() - 1)
{
dTAdd += dRAdd;
}
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen + 2 * dTAdd,dHeight + dBomAdd + dTopAdd,m_dWAdd + dOutW + dTAdd,PI / 2.0);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
pXSolid = new AcDbX3dSolid;
//ptOrg.z += 0.5 * dBomAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen,dHeight - 2 * dOutW,m_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,m_dLen + 2 * dTAdd,dHeight - 2 * dOutW, dIntW + dTAdd);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
//创建一新的
ptOrg += vtZ * m_dWAdd;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen,dHeight - 2 * dOutW, dIntW);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
}
else//局部
{
int nDir = (m_nPos == 0 ) ? 1 : -1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg.y += nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 );
ptOrg.x = m_dB + m_dOpenL * 0.5;
ptOrg.z = 0.0;//
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * AcGeVector3d::kYAxis;
double dB = ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
double dT = dB;
//内部原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dOpenL,dHeight - 2 * dOutW, dB);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
double dAng = m_dAngle * PI / 180.0;
double dAng2 = m_dA2 * PI / 180.0;
if (m_nPos == 0)
dB /= sin(dAng2);
else
dB /= sin(dAng);
if (m_idxRoom == 0)
{
dTAdd += dLAdd;
}
else if (m_idxRoom == arRooms.length() - 1)
{
dTAdd += dRAdd;
}
dTLAdd = dTAdd;
if (m_nPos == 0)
dTLAdd /= sin(dAng2);
else
dTLAdd /= sin(dAng);
//外
pXSolid = new AcDbX3dSolid;
ptOrg.y -= nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 );
double dRoomH = room.ptGe[0].distanceTo(room.ptGe[1]);
double dH = dHeight;//( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1 ) ? dHeight : dHeight - 2.0 * dOutW;
if (fabs(m_dAngle - m_dA2) < 1.e-3)
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd ,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
//挖去 四方台 LxWxHxAng
pXSolid = new AcDbX3dSolid;
//ptOrg.z += 0.5 * dBomAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL,dH - dOutW * 2.0,m_dWAdd,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
else
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
//挖去
pXSolid = new AcDbX3dSolid;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL,dH - dOutW * 2.0 ,m_dWAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
}
pGroup->SetOrgPoint( ptOrg );
pGroup->SetAxis(X,AcGeVector3d::kXAxis);
pGroup->SetAxis(Y,AcGeVector3d::kYAxis);
pGroup->SetAxis(Z,AcGeVector3d::kZAxis);
//序列化BIM数据
pGroup->GetSpecialtyData()->SetAt(_T("m_dCurRoomW"),m_dCurRoomW);
pGroup->GetSpecialtyData()->SetAt(_T("m_dWAdd"),m_dWAdd);
pGroup->GetSpecialtyData()->SetAt(_T("m_dOpenL"),m_dOpenL);
pGroup->GetSpecialtyData()->SetAt(_T("m_dB"),m_dB);
pGroup->GetSpecialtyData()->SetAt(_T("m_dAngle"),m_dAngle);
pGroup->GetSpecialtyData()->SetAt(_T("m_dA2"),m_dA2);
pGroup->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pGroup->GetSpecialtyData()->SetAt(_T("m_nPos"),m_nPos);
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pGroup->GetSpecialtyData()->SetAt(_T("m_dLen"),m_dLen);
pGroup->GetSpecialtyData()->SetAt(_T("m_dZOff"),m_dZOff);
pGroup->GetSpecialtyData()->SetAt(_T("m_dTAdd"),m_dTAdd);
pGroup->GetSpecialtyData()->SetAt(_T("m_dHoleH"),m_dHoleH);
pGroup->GetSpecialtyData()->SetAt(_T("m_dH"),m_dH);
}
return TRUE;
}
//管廊段变径
int CGLBJDlg::GetX3dSolidRecs(AecDbX3dGroup*& pGroup,const AcGePoint3d& ptFr,const AcGeVector3d& vtDir)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
return GetX3dSolidRecsShEw(pGroup,ptFr,vtDir);
}
if (pGroup != NULL)
{
pGroup->RemoveAll3dSolidRec();
for (int i = 0;i < 100;i++)
{
if ( !pGroup->GetSpecialtyData()->RemoveAt(_T("CGLBJDlg"),i) )
{
break;
}
}
}
else
{
pGroup = new AecDbX3dGroup;
}
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
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 dTopAdd = worm.GetTopThickAdd();
double dLRAdd = 0.0,dLAdd = 0.0,dRAdd = 0.0,dTAdd = 0.0;
int nLRPos = worm.GetLeftOrRightThickAdd(dLRAdd);
if (nLRPos == 0)
{
dLAdd = dLRAdd;
}
if (nLRPos == 1)
{
dRAdd = dLRAdd;
}
//总宽度
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);
m_dCurRoomW = rc.m_dCurRoomW;
m_dWAdd = rc.m_dWAdd;
m_dOpenL = rc.m_dOpenL;
m_dB = rc.m_dB;
m_dAngle = rc.m_dAngle;
m_dA2 = rc.m_dA2;
m_bAllRoom = rc.m_bAllRoom;
m_idxRoom = rc.m_idxRoom;
m_sCrossSectionScr = rc.szCrossSectionScr;
m_nPos = rc.m_nPos;
m_dLen = rc.m_dLen;
m_dZOff = rc.m_dZOff;
m_dTAdd = rc.m_dTAdd;
room = arRooms.at(m_idxRoom);
AcGePoint3d ptOrg = ptFr;
AcGeVector3d vtZ;
X3dSolidRec rec;
dTAdd = m_dTAdd;
double dTLAdd = dTAdd;
AcDbX3dSolid* pXSolid = NULL;
if (m_bAllRoom)//整体
{
int nDir = (m_nPos == 0 ) ? -1 : 1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg += ( nDir * ( (m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
ptOrg += ( m_dLen / 2.0 ) * vtDir;
ptOrg.z = 0.0;
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * vtX;
if ( (m_idxRoom == 0 && m_nPos == 0 ) ||
(m_idxRoom == arRooms.length() - 1 && m_nPos == 1) )//左外/右外
{
//原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen,dHeight - 2.0 * dOutW, dOutW);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
ptOrg -= vtZ * dOutW * 0.5;
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen + 2 * m_dTAdd,dHeight + dBomAdd + dTopAdd,m_dWAdd + dOutW + m_dTAdd,PI / 2.0);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
pXSolid = new AcDbX3dSolid;
ptOrg += vtZ * m_dWAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen,dHeight - 2 * dOutW,m_dWAdd,PI / 2.0);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
rec.pXSolid->SetGSMarkerID(n);
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
else//内部
{
//原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen + 2 * m_dTAdd,dHeight - 2 * dOutW, dIntW + m_dTAdd);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//创建一新的
ptOrg += vtZ * m_dWAdd;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen,dHeight - 2 * dOutW, dIntW);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
rec.pXSolid->SetGSMarkerID(n);
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
}
else//局部
{
int nDir = (m_nPos == 0 ) ? 1 : -1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg += ( nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
ptOrg += ( m_dB + m_dOpenL * 0.5 ) * vtDir;
ptOrg.z = 0.0;//中心
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * vtX;
double dB = ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
double dT = dB;
//内部原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dOpenL,dHeight - 2 * dOutW, dB );
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
double dAng = m_dAngle * PI / 180.0;
double dAng2 = m_dA2 * PI / 180.0;
if (m_nPos == 0)
dB /= sin(dAng2);
else
dB /= sin(dAng);
if (m_idxRoom == 0)
{
dTAdd += dLAdd;
}
else if (m_idxRoom == arRooms.length() - 1)
{
dTAdd += dRAdd;
}
dTLAdd = dTAdd;
if (m_nPos == 0)
dTLAdd /= sin(dAng2);
else
dTLAdd /= sin(dAng);
double dB2 = ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
//外
pXSolid = new AcDbX3dSolid;
ptOrg -= ( nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
double dRoomH = room.ptGe[0].distanceTo(room.ptGe[1]);
double dH = dHeight;//( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1 ) ? dHeight : dHeight - 2.0 * dOutW;
if (fabs(m_dAngle - m_dA2) < 1.e-3)
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//AcAxDocLock lock;
//AcDb3dSolid* pSolidT = pXSolid->GetDraw3dSolid();
//pSolidT->setColorIndex(kRed);
//AddToModelSpace(pSolidT,NULL,true);
//挖去
pXSolid = new AcDbX3dSolid;
//ptOrg.z += 0.5 * dBomAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL,dH - dOutW * 2.0 ,m_dWAdd,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//pSolidT = pXSolid->GetDraw3dSolid();
//pSolidT->setColorIndex(kRed);
//AddToModelSpace(pSolidT,NULL,true);
}
else
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//挖去
pXSolid = new AcDbX3dSolid;
//ptOrg += vtZ * m_dWAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL,dH - dOutW * 2.0 ,m_dWAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
}
}
AecDbObjXDataMap rcXDataMap;
rcXDataMap.SetAt(_T("m_dCurRoomW"),rc.m_dCurRoomW);
rcXDataMap.SetAt(_T("m_dWAdd"),rc.m_dWAdd);
rcXDataMap.SetAt(_T("m_dOpenL"),rc.m_dOpenL);
rcXDataMap.SetAt(_T("m_dB"),rc.m_dB);
rcXDataMap.SetAt(_T("m_dAngle"),rc.m_dAngle);
rcXDataMap.SetAt(_T("m_dA2"),rc.m_dA2);
rcXDataMap.SetAt(_T("m_bAllRoom"),rc.m_bAllRoom);
rcXDataMap.SetAt(_T("m_idxRoom"),rc.m_idxRoom);
rcXDataMap.SetAt(_T("m_nPos"),rc.m_nPos);
rcXDataMap.SetAt(_T("m_sCrossSectionScr"),rc.szCrossSectionScr);
rcXDataMap.SetAt(_T("m_dLen"),rc.m_dLen);
rcXDataMap.SetAt(_T("m_dZOff"),m_dZOff);
rcXDataMap.SetAt(_T("m_dTAdd"),m_dTAdd);
rcXDataMap.SetAt(_T("m_dHoleH"),m_dHoleH);
rcXDataMap.SetAt(_T("m_dH"),m_dH);
pGroup->GetSpecialtyData()->SetAt(_T("CGLBJDlg"),n,rcXDataMap);
}
return TRUE;
}
int CGLBJDlg::GetX3dSolidRecsShEw(AecDbX3dGroup*& pGroup,const AcGePoint3d& ptFr,const AcGeVector3d& vtDir)
{
if (m_sCrossSectionScr.Find(_T("RECT")) == -1)
{
if (pGroup != NULL)
{
pGroup->RemoveAll3dSolidRec();
for (int i = 0;i < 100;i++)
{
if ( !pGroup->GetSpecialtyData()->RemoveAt(_T("CGLBJDlg"),i) )
{
break;
}
}
}
else
{
pGroup = new AecDbX3dGroup;
}
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]);
if (dOutW < m_dHoleH)
dOutW = m_dHoleH;
double dSideAdd(.0);
double dR = 0.0;
double dL = 0.0;
AcGePoint2d ptrODtTop,ptrODtBom,ptODt;
dbEW.GetODAndID(ptrODtTop,ptrODtBom);
dbEW.GetODAndThick(ptODt);
//总高度
double dHeight = m_dH;
//总宽度
double dWidth = ptODt.x;
//底部壁厚增加
double dBomAdd = 0.0;
double dTopAdd = 0.0;
double dLRAdd = 0.0,dLAdd = 0.0,dRAdd = 0.0,dTAdd = 0.0;
AcArray<ERoom> arRooms;
ERoom room;
AcGePoint2d ptThick;
AcGeLineSeg3d ln3d(ptFr,ptFr + 10.0 * vtDir);
dbEW.GetSectionRoomsTo(ln3d,arRooms,ptThick);
if (m_idxRoom < 0)
{
AfxMessageBox(_T("没有选择舱室,请选择舱室!"));
return FALSE;
}
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);
m_dCurRoomW = rc.m_dCurRoomW;
m_dWAdd = rc.m_dWAdd;
m_dOpenL = rc.m_dOpenL;
m_dB = rc.m_dB;
m_dAngle = rc.m_dAngle;
m_dA2 = rc.m_dA2;
m_bAllRoom = rc.m_bAllRoom;
m_idxRoom = rc.m_idxRoom;
m_sCrossSectionScr = rc.szCrossSectionScr;
m_nPos = rc.m_nPos;
m_dLen = rc.m_dLen;
m_dZOff = rc.m_dZOff;
m_dTAdd = rc.m_dTAdd;
room = arRooms.at(m_idxRoom);
AcGePoint3d ptOrg = ptFr;
AcGeVector3d vtZ;
X3dSolidRec rec;
dTAdd = m_dTAdd;
double dTLAdd = dTAdd;
AcDbX3dSolid* pXSolid = NULL;
if (m_bAllRoom)//整体
{
int nDir = (m_nPos == 0 ) ? -1 : 1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg += ( nDir * ( (m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
ptOrg += ( m_dLen / 2.0 ) * vtDir;
ptOrg.z = 0.0;
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * vtX;
if ( (m_idxRoom == 0 && m_nPos == 0 ) ||
(m_idxRoom == arRooms.length() - 1 && m_nPos == 1) )//左外/右外
{
//原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen,dHeight - 2.0 * dOutW, dOutW);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
ptOrg -= vtZ * dOutW * 0.5;
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen + 2 * m_dTAdd,dHeight + dBomAdd + dTopAdd,m_dWAdd + dOutW + m_dTAdd,PI / 2.0);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
pXSolid = new AcDbX3dSolid;
ptOrg += vtZ * m_dWAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dLen,dHeight - 2 * dOutW,m_dWAdd,PI / 2.0);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
rec.pXSolid->SetGSMarkerID(n);
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
else//内部
{
//原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen + 2 * m_dTAdd,dHeight - 2 * dOutW, dIntW + m_dTAdd);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//创建一新的
ptOrg += vtZ * m_dWAdd;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dLen,dHeight - 2 * dOutW, dIntW);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
rec.pXSolid->SetGSMarkerID(n);
_tcscpy(rec.szLockId,IDCreate());
pGroup->AddX3dSolidRec(rec);
}
}
else//局部
{
int nDir = (m_nPos == 0 ) ? 1 : -1;
//取侧墙中心
ptOrg = (m_nPos == 0 ) ? room.ptGe[0] : room.ptGe[1];
ptOrg += ( nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
ptOrg += ( m_dB + m_dOpenL * 0.5 ) * vtDir;
ptOrg.z = 0.0;//中心
ptOrg.z += m_dZOff;
ptOrg.z -= 0.5 * dBomAdd;
vtZ = nDir * vtX;
double dB = ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
double dT = dB;
//内部原地挖掉
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kBox,ptOrg,vtZ,3,m_dOpenL,dHeight - 2 * dOutW, dB );
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
double dAng = m_dAngle * PI / 180.0;
double dAng2 = m_dA2 * PI / 180.0;
if (m_nPos == 0)
dB /= sin(dAng2);
else
dB /= sin(dAng);
if (m_idxRoom == 0)
{
dTAdd += dLAdd;
}
else if (m_idxRoom == arRooms.length() - 1)
{
dTAdd += dRAdd;
}
dTLAdd = dTAdd;
if (m_nPos == 0)
dTLAdd /= sin(dAng2);
else
dTLAdd /= sin(dAng);
double dB2 = ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW : dIntW );
//外
pXSolid = new AcDbX3dSolid;
ptOrg -= ( nDir * ( ( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1) ? dOutW / 2.0 : dIntW / 2.0 ) ) * vtX;
double dRoomH = room.ptGe[0].distanceTo(room.ptGe[1]);
double dH = dHeight;//( m_idxRoom == 0 || m_idxRoom == arRooms.length() - 1 ) ? dHeight : dHeight - 2.0 * dOutW;
if (fabs(m_dAngle - m_dA2) < 1.e-3)
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//AcAxDocLock lock;
//AcDb3dSolid* pSolidT = pXSolid->GetDraw3dSolid();
//pSolidT->setColorIndex(kRed);
//AddToModelSpace(pSolidT,NULL,true);
//挖去
pXSolid = new AcDbX3dSolid;
//ptOrg.z += 0.5 * dBomAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kQPyramid,ptOrg,vtZ,4,m_dOpenL,dH - dOutW * 2.0 ,m_dWAdd,dAng);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//pSolidT = pXSolid->GetDraw3dSolid();
//pSolidT->setColorIndex(kRed);
//AddToModelSpace(pSolidT,NULL,true);
}
else
{
ptOrg.z += 0.5 * dBomAdd;
ptOrg.z -= (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL + 2.0 * dB + 2 * dTLAdd, dH + dBomAdd + dTopAdd,m_dWAdd + dT + dTAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
//挖去
pXSolid = new AcDbX3dSolid;
//ptOrg += vtZ * m_dWAdd;
ptOrg.z += (0.5 * dBomAdd - 0.5 * dTopAdd);
pXSolid->Create(AcDbX3dSolid::kWPyramid,ptOrg,vtZ,5,m_dOpenL,dH - dOutW * 2.0 ,m_dWAdd,dAng,dAng2);
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolSubtract;
_tcscpy(rec.szLockId,IDCreate());
rec.pXSolid->SetGSMarkerID(n);
pGroup->AddX3dSolidRec(rec);
}
}
AecDbObjXDataMap rcXDataMap;
rcXDataMap.SetAt(_T("m_dCurRoomW"),rc.m_dCurRoomW);
rcXDataMap.SetAt(_T("m_dWAdd"),rc.m_dWAdd);
rcXDataMap.SetAt(_T("m_dOpenL"),rc.m_dOpenL);
rcXDataMap.SetAt(_T("m_dB"),rc.m_dB);
rcXDataMap.SetAt(_T("m_dAngle"),rc.m_dAngle);
rcXDataMap.SetAt(_T("m_dA2"),rc.m_dA2);
rcXDataMap.SetAt(_T("m_bAllRoom"),rc.m_bAllRoom);
rcXDataMap.SetAt(_T("m_idxRoom"),rc.m_idxRoom);
rcXDataMap.SetAt(_T("m_nPos"),rc.m_nPos);
rcXDataMap.SetAt(_T("m_sCrossSectionScr"),rc.szCrossSectionScr);
rcXDataMap.SetAt(_T("m_dLen"),rc.m_dLen);
rcXDataMap.SetAt(_T("m_dZOff"),m_dZOff);
rcXDataMap.SetAt(_T("m_dTAdd"),m_dTAdd);
rcXDataMap.SetAt(_T("m_dHoleH"),m_dHoleH);
rcXDataMap.SetAt(_T("m_dH"),m_dH);
pGroup->GetSpecialtyData()->SetAt(_T("CGLBJDlg"),n,rcXDataMap);
}
}
return TRUE;
}
void CGLBJDlg::OnBnClickedButton2()
{
if (m_bIsAddRec)
{
UpdateData();
if (m_dAngle - 90.0 > 1.e-10)
{
AfxMessageBox(_T("底角必须小于等于90度!且大于0"));
return;
}
if (m_idxRoom == -1)
{
AfxMessageBox(_T("请选择要变径的舱室!"));
return;
}
if ( m_dWAdd < 1.e-10)
{
AfxMessageBox(_T("宽度增量太小!必须大于0.01米!"));
return;
}
double dX = m_dOpenL - 2.0 * m_dWAdd * cos(m_dAngle * PI / 180.0) / sin(m_dAngle * PI / 180.0);
if (dX < 0.5)
{
CString sTemp;
sTemp.Format(_T("在 %g 度的情况下,L 尺寸太小!"),m_dAngle);
AfxMessageBox(sTemp);
return;
}
GLBJRecord rc;
rc.m_dCurRoomW = m_dCurRoomW;
rc.m_dWAdd = m_dWAdd;
rc.m_dOpenL = m_dOpenL;
rc.m_dB = m_dB;
rc.m_dAngle = m_dAngle;
rc.m_dA2 = m_dA2;
rc.m_bAllRoom = m_bAllRoom;
rc.m_idxRoom = m_idxRoom;
//_tcscpy(rc.szCrossSectionScr,m_sCrossSectionScr);
rc.szCrossSectionScr = m_sCrossSectionScr;
rc.m_nPos = m_nPos;
rc.m_dLen = m_dLen;
rc.m_nIndex = m_wndRecordList.GetItemCount() + 1;
rc.m_dZOff = m_dZOff;
rc.m_dTAdd = m_dTAdd;
m_arRecord.append(rc);
CString sRecord,sPos;
sPos = rc.m_nPos == 0 ? _T("舱室向左侧变径") : _T("舱室向右侧变径");
sRecord.Format(_T("记录[ 第%d舱室 %s]"), rc.m_idxRoom + 1,sPos);
//int nPos = m_wndCombo.AddString(sRecord);
//m_wndCombo.SetCurSel(nPos);
int nPos = m_wndRecordList.InsertItem(m_wndRecordList.GetItemCount(),sRecord,0);
m_wndRecordList.SetItemState(nPos,LVIS_SELECTED,LVIS_SELECTED);
AddRecordPreview(m_nPos,m_idxRoom);
}
}
void CGLBJDlg::AddRecordPreview(int nPos,int idxRoom)
{
AcGsView* pView = m_wndViewCtrl.view();
AcGsModel* pModel = m_wndViewCtrl.model();
CString sPosRoom;
sPosRoom.Format(_T("%d-%d"),nPos,idxRoom);
AcDbEntity* pEnt = NULL;
m_mapPosRoom2Pl.Lookup(sPosRoom,(void*&)pEnt);
if (pEnt != NULL)
{
pView->erase(pEnt);
}
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);
AcGeVector3d vtDirX = nPos == 0 ? -AcGeVector3d::kXAxis : AcGeVector3d::kXAxis;
{
ERoom room;
worm.GetRoom(idxRoom,room);
AcGePoint2d ptIOW = arDatas.last();
AcGePoint3d ptGe = room.ptGe[m_nPos];//0 : 1
ptGe.y -= ptIOW.y;
AcDbPolyline* pPl = new AcDbPolyline;
pPl->addVertexAt(0,ptGe.convert2d(AcGePlane::kXYPlane));
ptGe += 2.0 * ptIOW.y * vtDirX;
pPl->addVertexAt(1,ptGe.convert2d(AcGePlane::kXYPlane));
ptGe.y += room.ptGe[0].distanceTo(room.ptGe[3]);
ptGe.y += 2.0 * ptIOW.y;
pPl->addVertexAt(2,ptGe.convert2d(AcGePlane::kXYPlane));
ptGe -= 2.0 * ptIOW.y * vtDirX;
pPl->addVertexAt(3,ptGe.convert2d(AcGePlane::kXYPlane));
pPl->setColorIndex(kRed);
pPl->setConstantWidth(0.1);
if (pView != NULL)
{
pView->add(pPl, pModel);
}
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.RedrawWindow();
m_mapPosRoom2Pl.SetAt(sPosRoom,pPl);
}
}
void CGLBJDlg::SetReloadGLBJ(AecDbObjXDataMap* pXDataMap)
{
m_pGLBJXDataMap = pXDataMap;
}
void CGLBJDlg::OnCbnSelchangeCombo1()
{
/*int nSel = m_wndCombo.GetCurSel();
if (nSel != -1)
{
GLBJRecord& rc = m_arRecord.at(nSel);
m_dCurRoomW = rc.m_dCurRoomW;
m_dWAdd = rc.m_dWAdd;
m_dOpenL = rc.m_dOpenL;
m_dB = rc.m_dB;
m_dAngle = rc.m_dAngle;
m_dA2 = rc.m_dA2;
m_bAllRoom = rc.m_bAllRoom;
m_idxRoom = rc.m_idxRoom;
m_sCrossSectionScr = rc.szCrossSectionScr;
m_nPos = rc.m_nPos;
m_dLen = rc.m_dLen;
HitEarthWorm(m_idxRoom);
UpdateData(FALSE);
}*/
}
void CGLBJDlg::OnBnClickedButton11()
{
POSITION ps = m_wndRecordList.GetFirstSelectedItemPosition();
int nSel = m_wndRecordList.GetNextSelectedItem(ps);//m_wndCombo.GetCurSel();
if (nSel != -1)
{
UpdateData();
GLBJRecord& rc = m_arRecord.at(nSel);
rc.m_dCurRoomW = m_dCurRoomW;
rc.m_dWAdd = m_dWAdd;
rc.m_dOpenL = m_dOpenL;
rc.m_dB = m_dB;
rc.m_dAngle = m_dAngle;
rc.m_dA2 = m_dA2;
rc.m_bAllRoom = m_bAllRoom;
rc.m_idxRoom = m_idxRoom;
//_tcscpy(rc.szCrossSectionScr,m_sCrossSectionScr);
rc.szCrossSectionScr = m_sCrossSectionScr;
rc.m_nPos = m_nPos;
rc.m_dLen = m_dLen;
rc.m_dZOff = 0.0;
rc.m_dTAdd = m_dTAdd;
m_arRecord.setAt(nSel,rc);
AddRecordPreview(m_nPos,m_idxRoom);
}
}
void CGLBJDlg::OnBnClickedButton1()
{
//尺寸示意图
CCCSYDlg dlg;
dlg.SetBmpFileName(_T("GLBJ.bmp"));
dlg.DoModal();
}
void CGLBJDlg::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);
}
}
STSection* CGLBJDlg::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 CGLBJDlg::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 CGLBJDlg::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 CGLBJDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
if (pNMItemActivate != NULL)
{
if ( pNMItemActivate->iItem != -1)
{
int nSel = pNMItemActivate->iItem;
GLBJRecord& rc = m_arRecord.at(nSel);
m_dCurRoomW = rc.m_dCurRoomW;
m_dWAdd = rc.m_dWAdd;
m_dOpenL = rc.m_dOpenL;
m_dB = rc.m_dB;
m_dAngle = rc.m_dAngle;
m_dA2 = rc.m_dA2;
m_bAllRoom = rc.m_bAllRoom;
m_idxRoom = rc.m_idxRoom;
m_sCrossSectionScr = rc.szCrossSectionScr;
m_nPos = rc.m_nPos;
m_dLen = rc.m_dLen;
m_dZOff = rc.m_dZOff;
HitEarthWorm(m_idxRoom);
UpdateData(FALSE);
}
}
*pResult = 0;
}
void CGLBJDlg::OnBnClickedButton3()
{
POSITION ps = m_wndRecordList.GetFirstSelectedItemPosition();
if (ps != NULL)
{
int nItem = m_wndRecordList.GetNextSelectedItem(ps);
if (nItem != -1)
{
int nRes = AfxMessageBox(_T("选择的记录即将删除,确认要删除吗?"),MB_YESNO);
if (nRes == IDYES)
{
GLBJRecord& rc = m_arRecord.at(nItem);
CString sPosRoom;
sPosRoom.Format(_T("%d-%d"),rc.m_nPos,rc.m_idxRoom);
AcDbEntity* pEnt = NULL;
if (m_mapPosRoom2Pl.Lookup(sPosRoom,(void*&)pEnt))
{
AcGsView* pView = m_wndViewCtrl.view();
AcGsModel* pModel = m_wndViewCtrl.model();
if (pView != NULL)
{
pView->erase(pEnt);
}
}
m_arRecord.removeAt(nItem);
m_wndRecordList.DeleteItem(nItem);
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.RedrawWindow();
}
}
}
}