2545 lines
61 KiB
C++
2545 lines
61 KiB
C++
#include "stdafx.h"
|
|
#include "YXKKDlg.h"
|
|
#include "AecDbEarthWorm.h"
|
|
#include "AecDbShEarthWorm.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "AcDbX3dSolid.h"
|
|
#include "AecDbX3dGroup.h"
|
|
#include "axlock.h"
|
|
#include "CCSYDlg.h"
|
|
#include "UITools.h"
|
|
#include "AecDbEarthWormFitting.h"
|
|
#include "AecDb3dRoadAxisLine.h"
|
|
#include "coretools.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(CYXKKDlg, CDialog)
|
|
|
|
CYXKKDlg::CYXKKDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CYXKKDlg::IDD, pParent)
|
|
, m_dL1(5.0)
|
|
, m_dL2(3.0)
|
|
, m_dL3(0.5)
|
|
, m_nShape(0)
|
|
, m_nPos(2)
|
|
, m_bAllEw(FALSE)
|
|
, m_idxRoom(-1)
|
|
, m_dW1(2)
|
|
, m_nH(1)
|
|
, m_nV(1)
|
|
, m_dHSpace(0.5)
|
|
, m_dVSpace(0.5)
|
|
, m_bSpecThick(FALSE)
|
|
, m_dSpecThick(0.4)
|
|
, m_bAddHoleCase(TRUE)
|
|
, m_sMaterial(_T("PVC套管"))
|
|
, m_bAddHoop(FALSE)
|
|
, m_dX(5.1)
|
|
, m_dY(5.1)
|
|
, m_dZ(0.1)
|
|
, m_dt(0.1)
|
|
, m_dHoleH(0.4)
|
|
{
|
|
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%d%i%i%i%d%i%s%i%i%d%d%i%d%i"), _T("CYXKKDlg")
|
|
, &m_dL1 , &m_dL2 , &m_dL3
|
|
, &m_nShape , &m_nPos , &m_bAllEw
|
|
, &m_dW1
|
|
, &m_idxRoom
|
|
, &m_sCrossSectionScr
|
|
, &m_nH
|
|
, &m_nV
|
|
, &m_dHSpace
|
|
, &m_dVSpace
|
|
, &m_bSpecThick
|
|
, &m_dSpecThick
|
|
, &m_bAddHoleCase
|
|
);
|
|
m_sPoints = _T("");
|
|
m_sPointsIn = _T("");
|
|
|
|
m_dX = m_dL1 + 0.1;
|
|
m_dY = m_dL2 + 0.1;
|
|
|
|
m_curSection.pReg = NULL;
|
|
m_curSection.pt.set(0,0,0);
|
|
m_sCrossSectionScr = _T("");
|
|
m_sAddtionScr = _T("");
|
|
m_idxRoom = 0;
|
|
m_pRegionRoom = NULL;
|
|
}
|
|
|
|
CYXKKDlg::~CYXKKDlg()
|
|
{
|
|
}
|
|
|
|
void CYXKKDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT1, m_dL1);
|
|
DDX_Text(pDX, IDC_EDIT34, m_dL2);
|
|
DDX_Text(pDX, IDC_EDIT35, m_dL3);
|
|
DDX_Radio(pDX, IDC_RADIO1, m_nShape);
|
|
DDX_Radio(pDX, IDC_RADIO2, m_nPos);
|
|
DDX_Check(pDX, IDC_CHECK1, m_bAllEw);
|
|
DDX_Text(pDX, IDC_EDIT3, m_dW1);
|
|
DDX_Text(pDX, IDC_EDIT8, m_nH);
|
|
DDX_Text(pDX, IDC_EDIT9, m_nV);
|
|
DDX_Text(pDX, IDC_EDIT19, m_dHSpace);
|
|
DDX_Text(pDX, IDC_EDIT20, m_dVSpace);
|
|
DDX_Check(pDX, IDC_CHECK2, m_bSpecThick);
|
|
DDX_Text(pDX, IDC_EDIT2, m_dSpecThick);
|
|
DDX_Check(pDX, IDC_CHECK3, m_bAddHoleCase);
|
|
DDX_Text(pDX, IDC_EDIT10, m_sMaterial);
|
|
DDX_Check(pDX, IDC_CHECK4, m_bAddHoop);
|
|
DDX_Text(pDX, IDC_EDIT21, m_dX);
|
|
DDX_Text(pDX, IDC_EDIT22, m_dY);
|
|
DDX_Text(pDX, IDC_EDIT23, m_dZ);
|
|
DDX_Text(pDX, IDC_EDIT25, m_dt);
|
|
DDX_Text(pDX, IDC_EDIT4, m_dHoleH);
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CYXKKDlg, CDialog)
|
|
ON_BN_CLICKED(IDC_RADIO1, &CYXKKDlg::OnBnClickedRadio1)
|
|
ON_BN_CLICKED(IDC_RADIO13, &CYXKKDlg::OnBnClickedRadio13)
|
|
ON_BN_CLICKED(IDOK, &CYXKKDlg::OnBnClickedOk)
|
|
ON_MESSAGE(WM_VIEW_LBUTTONDOWN, &CYXKKDlg::OnViewLButtonDown)
|
|
ON_BN_CLICKED(IDC_BUTTON1, &CYXKKDlg::OnBnClickedButton1)
|
|
ON_BN_CLICKED(IDC_BUTTON2, &CYXKKDlg::OnBnClickedButton2)
|
|
ON_BN_CLICKED(IDC_BUTTON3, &CYXKKDlg::OnBnClickedButton3)
|
|
ON_BN_CLICKED(IDC_BUTTON4, &CYXKKDlg::OnBnClickedButton4)
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CYXKKDlg::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);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CYXKKDlg::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 CYXKKDlg::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);
|
|
|
|
//外壁厚,内隔壁厚
|
|
if (arDatas.length() > 0)
|
|
{
|
|
m_dHoleH = 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 CYXKKDlg::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));
|
|
|
|
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 CYXKKDlg::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 CYXKKDlg::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 CYXKKDlg::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 CYXKKDlg::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 CYXKKDlg::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 CYXKKDlg::ExtractRegionRooms()
|
|
{
|
|
if (m_curSection.pReg != NULL)
|
|
{
|
|
AecDbShEarthWorm::ExtractRegionRooms(m_arRegionRooms,m_curSection.pReg);
|
|
}
|
|
}
|
|
|
|
//矩形
|
|
void CYXKKDlg::OnBnClickedRadio1()
|
|
{
|
|
UpdateData();
|
|
}
|
|
|
|
//圆
|
|
void CYXKKDlg::OnBnClickedRadio13()
|
|
{
|
|
UpdateData();
|
|
}
|
|
|
|
void CYXKKDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
if (m_dL1 < 1.e-10)
|
|
{
|
|
AfxMessageBox(_T("开孔尺寸L1太小"));
|
|
return;
|
|
}
|
|
|
|
if (m_dL2 < 1.e-10)
|
|
{
|
|
AfxMessageBox(_T("开孔尺寸L2太小"));
|
|
return;
|
|
}
|
|
|
|
if (m_dHSpace - m_dL1 < 1.e-3 && m_nH > 1)
|
|
{
|
|
AfxMessageBox(_T("水平间距尺寸必须大于开口长度尺寸或直径!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dVSpace - m_dL1 < 1.e-3 && m_nV > 1)
|
|
{
|
|
AfxMessageBox(_T("垂直间距尺寸必须大于开口长度尺寸或直径!"));
|
|
return;
|
|
}
|
|
|
|
if (m_idxRoom == -1)
|
|
{
|
|
AfxMessageBox(_T("请选择舱室开洞!"));
|
|
return;
|
|
}
|
|
|
|
if (m_bSpecThick && m_dSpecThick < 0.1)
|
|
{
|
|
AfxMessageBox(_T("指定开孔所在墙板壁厚太薄!请重新输入壁厚!"));
|
|
return;
|
|
}
|
|
|
|
if (m_bAddHoop)
|
|
{
|
|
if (m_dX - m_dL1 < -1.e-6)
|
|
{
|
|
AfxMessageBox(_T("矩形孔加环扣结构长小于洞口L1!请重新输入尺寸!"));
|
|
return;
|
|
}
|
|
if (m_dY - m_dW1 < -1.e-6)
|
|
{
|
|
AfxMessageBox(_T("矩形孔加环扣结构宽小于洞口W1!请重新输入尺寸!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dt < 1.e-3 || m_dZ < 1.e-3)
|
|
{
|
|
AfxMessageBox(_T("环扣结构垛宽或高度尺寸不合理!请重新输入尺寸!"));
|
|
return;
|
|
}
|
|
}
|
|
|
|
UIDataCache::Write(_T("%d%d%d%i%i%i%d%i%s%i%i%d%d%i%d%i"), _T("CYXKKDlg")
|
|
, &m_dL1 , &m_dL2 , &m_dL3
|
|
, &m_nShape , &m_nPos , &m_bAllEw
|
|
, &m_dW1
|
|
, &m_idxRoom
|
|
, &m_sCrossSectionScr
|
|
, &m_nH
|
|
, &m_nV
|
|
, &m_dHSpace
|
|
, &m_dVSpace
|
|
, &m_bSpecThick
|
|
, &m_dSpecThick
|
|
, &m_bAddHoleCase);
|
|
|
|
OnOK();
|
|
}
|
|
|
|
int CYXKKDlg::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 dSideAdd(.0);
|
|
int nSideLR = worm.GetLeftOrRightThickAdd(dSideAdd);
|
|
double dR((nSideLR == 1 ? dSideAdd : .0));
|
|
double dL((nSideLR == 0 ? dSideAdd : .0));
|
|
|
|
//外壁厚,内隔壁厚
|
|
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;
|
|
dWidth += dSideAdd;
|
|
|
|
double dThick = dIntW;
|
|
AcGeVector3d vtZ,vtStep;
|
|
AcGePoint3d ptOrg;
|
|
|
|
AcArray<ERoom> arRooms;
|
|
ERoom room;
|
|
AcGePoint2d ptThick;
|
|
AcGeLineSeg3d ln(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0.0,0));
|
|
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
|
|
|
|
|
|
if (m_bAllEw)
|
|
{
|
|
if (m_nShape == 0)//矩形孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, -dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = dOutW + dL;
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, dWidth / 2.0 - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = dOutW + dR;
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, -dWidth / 2.0 + 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else//圆孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, dHeight / 2.0 - dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, -dHeight / 2.0 + dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = dOutW + dL;
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, dWidth / 2.0 - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = dOutW + dR;
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, -dWidth / 2.0 - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
room = arRooms.at(m_idxRoom);
|
|
|
|
if (m_nShape == 0)//矩形孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, -dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dL);
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[0].y + 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dR);
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[1].y - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
return 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else//圆孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, -dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dL);
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[0].y + 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dR);
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[1].y - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
return 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_bSpecThick)
|
|
{
|
|
dThick = m_dSpecThick;
|
|
}
|
|
|
|
if (pGroup != NULL)
|
|
{
|
|
pGroup->RemoveAll3dSolidRec();
|
|
}
|
|
else
|
|
{
|
|
pGroup = new AecDbX3dGroup;
|
|
}
|
|
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
AcGePoint3d ptNewOrg = ptOrg;
|
|
X3dSolidRec rec;
|
|
|
|
if ( !m_sPoints.IsEmpty() )
|
|
{
|
|
if (m_bAddHoleCase)
|
|
{
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->CreateExtrude(ptOrg,vtZ,m_sPoints,dThick,0.0);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->CreateExtrude(ptOrg,vtZ,m_sPointsIn,dThick + 0.01,0.0);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
else
|
|
{
|
|
AcGePoint3d ptOrgHoop;
|
|
for(int i = 0;i < m_nH;i++)
|
|
{
|
|
ptNewOrg = ptOrg + i * AcGeVector3d::kXAxis * m_dHSpace;
|
|
for (int j = 0;j < m_nV;j++)
|
|
{
|
|
if (m_nShape == 0)//矩形孔
|
|
{
|
|
//外部套管 方管子LxWxtxH 示意
|
|
if (m_bAddHoleCase)
|
|
{
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kRectTube,ptNewOrg,vtZ,4,m_dL1+0.04,m_dW1+0.04,0.02,dThick);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
|
|
//BOX LxWxH
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptNewOrg,vtZ,3,m_dL1,m_dW1,dThick);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
if (m_bAddHoop)
|
|
{
|
|
vtZ.normalize();
|
|
ptOrgHoop = ptNewOrg;
|
|
ptOrgHoop += vtZ * 0.5 * dThick;
|
|
ptOrgHoop += vtZ * 0.5 * m_dZ;
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrgHoop,vtZ,3,m_dX + 2.0 * m_dt,m_dY + 2.0 * m_dt,m_dZ);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrgHoop,vtZ,3,m_dX,m_dY,m_dZ);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//外部套管 圆管rxtxH
|
|
if (m_bAddHoleCase)
|
|
{
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kPipe,ptNewOrg,vtZ,3,m_dL1 / 2.0+0.04,0.02,dThick);//壁厚20
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
|
|
//CYL RxH
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kCylinder,ptNewOrg,vtZ,2,m_dL1 / 2.0,dThick);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
ptNewOrg += vtStep * m_dVSpace;
|
|
}
|
|
}
|
|
}
|
|
|
|
pGroup->SetOrgPoint( ptOrg );
|
|
pGroup->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pGroup->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pGroup->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
//序列化BIM数据
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dL1"),m_dL1);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dDn"),AS_M2MM(m_dL1));
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dL2"),m_dL2);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dL3"),m_dL3);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nShape"),m_nShape);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nPos"),m_nPos);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bAllEw"),m_bAllEw);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dW1"),m_dW1);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nH"),m_nH);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nV"),m_nV);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dHSpace"),m_dHSpace);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dVSpace"),m_dVSpace);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bSpecThick"),m_bSpecThick);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dSpecThick"),m_dSpecThick);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bAddHoleCase"),m_bAddHoleCase);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sMaterial"),m_sMaterial);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sPoints"),m_sPoints);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sPointsIn"),m_sPointsIn);
|
|
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bAddHoop"),m_bAddHoop);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dY"),m_dY);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dZ"),m_dZ);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dt"),m_dt);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dHoleH"),m_dHoleH);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
STSection* CYXKKDlg::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;
|
|
}
|
|
|
|
int CYXKKDlg::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]);
|
|
|
|
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 = ptrODtTop.x;
|
|
|
|
//总宽度
|
|
double dWidth = ptODt.x;
|
|
|
|
double dThick = dIntW;
|
|
AcGeVector3d vtZ,vtStep;
|
|
AcGePoint3d ptOrg;
|
|
|
|
AcArray<ERoom> arRooms;
|
|
ERoom room;
|
|
AcGePoint2d ptThick;
|
|
AcGeLineSeg3d ln3d(ptSta,ptEnd);
|
|
dbEW.GetSectionRoomsTo(ln3d,arRooms,ptThick);
|
|
|
|
if (m_bAllEw)
|
|
{
|
|
if (m_nShape == 0)//矩形孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, -dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = dOutW + dL;
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, dWidth / 2.0 - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = dOutW + dR;
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, -dWidth / 2.0 + 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
else//圆孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, dHeight / 2.0 - dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, 0, -dHeight / 2.0 + dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = dOutW + dL;
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, dWidth / 2.0 - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = dOutW + dR;
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, -dWidth / 2.0 - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
room = arRooms.at(m_idxRoom);
|
|
|
|
if (m_nShape == 0)//矩形孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, -dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dL);
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[0].y + 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dR);
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[1].y - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dW1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
return 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else//圆孔
|
|
{
|
|
switch (m_nPos)
|
|
{
|
|
case 0://上
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, 1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, dHeight / 2.0 - 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 1://下
|
|
{
|
|
dThick = dOutW;
|
|
vtZ.set(0, 0, -1);
|
|
vtStep.set(0, 1, 0);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, (room.ptGe[2].y + room.ptGe[3].y) / 2.0, -dHeight / 2.0 + 0.5 * dThick);
|
|
break;
|
|
}
|
|
case 2://左
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dL);
|
|
vtZ.set(0, 1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[0].y + 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
case 3://右
|
|
{
|
|
dThick = (m_idxRoom > 0 && m_idxRoom < arRooms.length()) ? dIntW : (dOutW + dR);
|
|
vtZ.set(0, -1, 0);
|
|
vtStep.set(0, 0, 1);
|
|
ptOrg.set(m_dL2 + m_dL1 / 2.0, room.ptGe[1].y - 0.5 * dThick, -dHeight / 2.0 + dOutW + m_dL3 + m_dL1 / 2.0);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
return 0;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (m_bSpecThick)
|
|
{
|
|
dThick = m_dSpecThick;
|
|
}
|
|
|
|
if (pGroup != NULL)
|
|
{
|
|
pGroup->RemoveAll3dSolidRec();
|
|
}
|
|
else
|
|
{
|
|
pGroup = new AecDbX3dGroup;
|
|
}
|
|
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
AcGePoint3d ptNewOrg = ptOrg;
|
|
X3dSolidRec rec;
|
|
|
|
if ( !m_sPoints.IsEmpty() )
|
|
{
|
|
if (m_bAddHoleCase)
|
|
{
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->CreateExtrude(ptOrg,vtZ,m_sPoints,dThick,0.0);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->CreateExtrude(ptOrg,vtZ,m_sPointsIn,dThick + 0.01,0.0);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
else
|
|
{
|
|
AcGePoint3d ptOrgHoop;
|
|
for(int i = 0;i < m_nH;i++)
|
|
{
|
|
ptNewOrg = ptOrg + i * AcGeVector3d::kXAxis * m_dHSpace;
|
|
for (int j = 0;j < m_nV;j++)
|
|
{
|
|
if (m_nShape == 0)//矩形孔
|
|
{
|
|
//外部套管 方管子LxWxtxH 示意
|
|
if (m_bAddHoleCase)
|
|
{
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kRectTube,ptNewOrg,vtZ,4,m_dL1+0.04,m_dW1+0.04,0.02,dThick);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
|
|
//BOX LxWxH
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptNewOrg,vtZ,3,m_dL1,m_dW1,dThick);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
if (m_bAddHoop)
|
|
{
|
|
vtZ.normalize();
|
|
ptOrgHoop = ptNewOrg;
|
|
ptOrgHoop += vtZ * 0.5 * dThick;
|
|
ptOrgHoop += vtZ * 0.5 * m_dZ;
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrgHoop,vtZ,3,m_dX + 2.0 * m_dt,m_dY + 2.0 * m_dt,m_dZ);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kBox,ptOrgHoop,vtZ,3,m_dX,m_dY,m_dZ);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//外部套管 圆管rxtxH
|
|
if (m_bAddHoleCase)
|
|
{
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kPipe,ptNewOrg,vtZ,3,m_dL1 / 2.0+0.04,0.02,dThick);//壁厚20
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolUnite;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
|
|
//CYL RxH
|
|
pXSolid = new AcDbX3dSolid;
|
|
pXSolid->Create(AcDbX3dSolid::kCylinder,ptNewOrg,vtZ,2,m_dL1 / 2.0,dThick);
|
|
rec.pXSolid = pXSolid;
|
|
rec.bType = AcDb::kBoolSubtract;
|
|
_tcscpy(rec.szLockId,IDCreate());
|
|
pGroup->AddX3dSolidRec(rec);
|
|
}
|
|
ptNewOrg += vtStep * m_dVSpace;
|
|
}
|
|
}
|
|
}
|
|
|
|
pGroup->SetOrgPoint( ptOrg );
|
|
pGroup->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pGroup->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pGroup->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
//序列化BIM数据
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dL1"),m_dL1);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dDn"),AS_M2MM(m_dL1));
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dL2"),m_dL2);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dL3"),m_dL3);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nShape"),m_nShape);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nPos"),m_nPos);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bAllEw"),m_bAllEw);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dW1"),m_dW1);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nH"),m_nH);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nV"),m_nV);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dHSpace"),m_dHSpace);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dVSpace"),m_dVSpace);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bSpecThick"),m_bSpecThick);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dSpecThick"),m_dSpecThick);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bAddHoleCase"),m_bAddHoleCase);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sMaterial"),m_sMaterial);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sPoints"),m_sPoints);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sPointsIn"),m_sPointsIn);
|
|
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_bAddHoop"),m_bAddHoop);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dY"),m_dY);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dZ"),m_dZ);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dt"),m_dt);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dHoleH"),m_dHoleH);
|
|
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
LRESULT CYXKKDlg::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 CYXKKDlg::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 CYXKKDlg::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 CYXKKDlg::OnBnClickedButton1()
|
|
{
|
|
//尺寸示意图
|
|
CCCSYDlg dlg;
|
|
dlg.SetBmpFileName(_T("YXKK.bmp"));
|
|
dlg.DoModal();
|
|
}
|
|
|
|
void CYXKKDlg::OnBnClickedButton2()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
ads_point pt;
|
|
int nRes = acedGetPoint(NULL,_T("\n选择管道接口点:"),pt);
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcGePoint3d ptInf = asPnt3d(pt);
|
|
|
|
//选择管道,弯头等
|
|
AcAxDocLock lock;
|
|
AecDbEarthWormFitting* pFit = NULL;
|
|
if ( Acad::eOk == acdbOpenAcDbEntity((AcDbEntity*&)pFit,m_idEWFit,AcDb::kForRead))
|
|
{
|
|
AecDbX3dGroup* pGroupNext = NULL;
|
|
int nPos = 0;
|
|
double dDn = 0.0,dSpace = 0.0;
|
|
|
|
while( pFit->GetX3dGroup(nPos,pGroupNext) )
|
|
{
|
|
AcArray<AecInterface> arInfs;
|
|
if ( pGroupNext->GetInterface(arInfs) )
|
|
{
|
|
pGroupNext->GetSpecialtyData()->GetAt(_T("m_dDn"),dDn);
|
|
for (int i = 0;i < arInfs.length();i++)
|
|
{
|
|
dSpace = ptInf.distanceTo(arInfs.at(i).ptPos);
|
|
if ( fabs( dSpace - 0.5 * AS_MUNIT(dDn) ) < 1.e-1) //10mm
|
|
{
|
|
AcGePoint3d ptInf = arInfs.at(i).ptPos;
|
|
AcGeVector3d vtDir = arInfs.at(i).vtDir;
|
|
|
|
m_dL2 = ptInf.x - 0.5 * AS_MUNIT(dDn);//位置
|
|
|
|
//复制pGroup的材料信息和管径
|
|
double dDn;
|
|
int idxRoom = -1;
|
|
pGroupNext->GetSpecialtyData()->GetAt(_T("m_dDn"),dDn);
|
|
pGroupNext->GetSpecialtyData()->GetAt(_T("m_idxRoom"),idxRoom);
|
|
|
|
m_dL1 = AS_MUNIT(dDn);
|
|
if (vtDir.isCodirectionalTo( AcGeVector3d::kZAxis) )
|
|
{
|
|
m_nPos = 0;
|
|
}
|
|
if (vtDir.isCodirectionalTo( -AcGeVector3d::kZAxis) )
|
|
{
|
|
m_nPos = 1;
|
|
}
|
|
if (vtDir.isCodirectionalTo( AcGeVector3d::kYAxis) )
|
|
{
|
|
m_nPos = 2;
|
|
}
|
|
if (vtDir.isCodirectionalTo( -AcGeVector3d::kXAxis) )
|
|
{
|
|
m_nPos = 3;
|
|
}
|
|
|
|
if (idxRoom > -1)
|
|
{
|
|
m_idxRoom = idxRoom;
|
|
HitEarthWorm(m_idxRoom);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
pFit->close();
|
|
}
|
|
}
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CYXKKDlg::OnBnClickedButton3()
|
|
{
|
|
UpdateData();
|
|
|
|
m_sPoints = _T("");
|
|
EnableWindow(FALSE);
|
|
CWnd* pFrame = acedGetAcadFrame();
|
|
pFrame->EnableWindow(TRUE);
|
|
ShowWindow(SW_HIDE);
|
|
pFrame->SetFocus();
|
|
|
|
AcAxDocLock lock;
|
|
ads_point pt;
|
|
ads_name ent;
|
|
int nRes = acedEntSel(_T("\n请选择闭合pline线:"),ent,pt);
|
|
if (nRes == RTNORM)
|
|
{
|
|
AcDbObjectId id;
|
|
acdbGetObjectId(id,ent);
|
|
|
|
CString sText;
|
|
AcDbEntity* pEnt = NULL;
|
|
if (Acad::eOk == acdbOpenAcDbEntity(pEnt,id,AcDb::kForRead))
|
|
{
|
|
AcDbPolyline* pPl = AcDbPolyline::cast(pEnt);
|
|
if (pPl != NULL)
|
|
{
|
|
AcGePoint2d ptSta;
|
|
pPl->getPointAt(0,ptSta);
|
|
|
|
AcGeVector2d vtMove = ptSta.asVector();
|
|
vtMove.negate();
|
|
|
|
m_sPoints = _T("");
|
|
double dBulge = 0.0;
|
|
AcGePoint2d pt2d;
|
|
AcGePoint2dArray arPt2ds;
|
|
for (int i = 0;i < pPl->numVerts();i++)
|
|
{
|
|
pPl->getPointAt(i,pt2d);
|
|
pPl->getBulgeAt(i,dBulge);
|
|
|
|
pt2d += vtMove;
|
|
|
|
//if (arPt2ds.find(pt2d) == -1)
|
|
{
|
|
arPt2ds.append(pt2d);
|
|
|
|
sText.Format(_T("%g,%g@%g,"),pt2d.x,pt2d.y,dBulge);
|
|
m_sPoints += sText;
|
|
}
|
|
}
|
|
|
|
if ( arPt2ds.last().distanceTo(arPt2ds.first()) > 1.e-2)
|
|
{
|
|
pt2d = arPt2ds.first();
|
|
sText.Format(_T("%g,%g@0.0,"),pt2d.x,pt2d.y);
|
|
m_sPoints += sText;
|
|
}
|
|
m_sPoints.TrimRight(_T(","));
|
|
|
|
|
|
AcDbVoidPtrArray arOffPtrs,arOffPtrs2;
|
|
pPl->getOffsetCurves(0.01,arOffPtrs);
|
|
pPl->getOffsetCurves(-0.01,arOffPtrs2);
|
|
|
|
if (arOffPtrs.length() == 1 && arOffPtrs2.length() == 1)
|
|
{
|
|
AcDbEntity* pEntt = (AcDbEntity*)arOffPtrs.at(0);
|
|
AcDbPolyline* pPl2 = AcDbPolyline::cast(pEntt);
|
|
|
|
AcDbEntity* pEntt2 = (AcDbEntity*)arOffPtrs2.at(0);
|
|
AcDbPolyline* pPl22 = AcDbPolyline::cast(pEntt2);
|
|
|
|
if (pPl2 != NULL && pPl22 != NULL)
|
|
{
|
|
double dArea1 = 0.0,dArea2 = 0.0;
|
|
pPl2->getArea(dArea1);
|
|
pPl22->getArea(dArea2);
|
|
|
|
AcDbPolyline* pPlMin = ( fabs(dArea2) - fabs(dArea1) ) < 1.e-10 ? pPl22 : pPl2;
|
|
arPt2ds.removeAll();
|
|
|
|
for (int i = 0;i < pPlMin->numVerts();i++)
|
|
{
|
|
pPlMin->getPointAt(i,pt2d);
|
|
pPlMin->getBulgeAt(i,dBulge);
|
|
|
|
pt2d += vtMove;
|
|
|
|
//if (arPt2ds.find(pt2d) == -1)
|
|
{
|
|
arPt2ds.append(pt2d);
|
|
|
|
sText.Format(_T("%g,%g@%g,"),pt2d.x,pt2d.y,dBulge);
|
|
m_sPointsIn += sText;
|
|
}
|
|
}
|
|
|
|
if ( arPt2ds.last().distanceTo(arPt2ds.first()) > 1.e-2)
|
|
{
|
|
pt2d = arPt2ds.first();
|
|
sText.Format(_T("%g,%g@0.0,"),pt2d.x,pt2d.y);
|
|
m_sPointsIn += sText;
|
|
}
|
|
m_sPointsIn.TrimRight(_T(","));
|
|
|
|
DELETE_PTR(pPl2);
|
|
DELETE_PTR(pPl22);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
acutPrintf(_T("\n选择的实体不是pline线实体!"));
|
|
}
|
|
pEnt->close();
|
|
}
|
|
}
|
|
|
|
pFrame->EnableWindow(FALSE);
|
|
ShowWindow(SW_SHOW);
|
|
EnableWindow(TRUE);
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
void CYXKKDlg::OnBnClickedButton4()
|
|
{
|
|
//尺寸示意图
|
|
CCCSYDlg dlg;
|
|
dlg.SetBmpFileName(_T("HOLEHOOP.bmp"));
|
|
dlg.DoModal();
|
|
}
|