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

1367 lines
33 KiB
C++

#include "stdafx.h"
#include "BZGDDlg.h"
#include "AecDbEarthWorm.h"
#include "KTCADUtilityEx.h"
#include "AcDbX3dSolid.h"
#include "AecDbX3dGroup.h"
#include "AecDbX3dPart.h"
#include "UITools.h"
#include "axlock.h"
#include "AecDbEarthWormFitting.h"
#include "AecDbXXXDoghouse.h"
#include "AecDbEwFitting.h"
#include "AecDbEwEquipment.h"
#include "KTSetting.h"
#include "AecPipeLineTool.h"
#ifndef Plumbing_DB
#define Plumbing_DB _T("\\Plumbing.db")
#endif
static const Adesk::UInt16 kColorByBlock = 0;
static const Adesk::UInt16 kRed = 1;
static const Adesk::UInt16 kYellow = 2;
static const Adesk::UInt16 kGreen = 3;
static const Adesk::UInt16 kCyan = 4;
static const Adesk::UInt16 kBlue = 5;
static const Adesk::UInt16 kMagenta = 6;
static const Adesk::UInt16 kWhite = 7;
static const Adesk::UInt16 kColorByLayer = 256;
static void FreeBuffer(AcDbVoidPtrArray& arEntPtrs)
{
AcDbEntity* pEnt = NULL;
while (arEntPtrs.length() > 0 )
{
pEnt = (AcDbEntity*)arEntPtrs.last();
DELETE_PTR(pEnt);
arEntPtrs.removeLast();
}
}
extern AcGePoint3d MidPoint(const AcGePoint3d& pt1, const AcGePoint3d& pt2);
extern CString IDCreate();
AecInterface* SelectLockInf(AcDbObjectId idEW,AecDbX3dGroup*& pGroupAt);
AecInterface* SelectLockInf(AcDbObjectId idEW,AecDbObjXDataMap*& pGroupMap);
AecInterface* SelectLockInfH(AcDbObjectId idHouse,AecDbObjXDataMap*& pGroupMap);
IMPLEMENT_DYNAMIC(CBZGDDlg, CDialog)
CBZGDDlg::CBZGDDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBZGDDlg::IDD, pParent)
, m_sMertial(_T(""))
, m_dX(0.5)
, m_dZ(0.6)
, m_nN(1)
, m_dLen(80.0)
, m_bRight(FALSE)
, m_sInfDir(_T(""))
, m_sPipeNo(_T("PIPE-001"))
{
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_nPipeColor = kRed;
m_sCurrSys = _T("");
m_sMertial = _T("");
m_dDn = 600.0;
m_sCrossSectionScr = _T("");
m_dt = 14;
m_bInfLast = FALSE;
m_vtDir = AcGeVector3d::kXAxis;
m_pInf = NULL;
m_bAllRoomPipes = false;
m_bByPath = true;
m_dRRato = 1.5;
}
CBZGDDlg::~CBZGDDlg()
{
if (m_pInf != NULL)
DELETE_PTR(m_pInf);
}
void CBZGDDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_LIST1, m_wndPipeList);
DDX_Control(pDX, IDC_LIST2, m_wndListBoxMaters);
DDX_LBString(pDX, IDC_LIST2, m_sMertial);
DDX_Control(pDX, IDC_LIST3, m_wndSysListBox);
DDX_Text(pDX, IDC_EDIT1, m_dX);
DDX_Text(pDX, IDC_EDIT3, m_dZ);
DDX_Text(pDX, IDC_EDIT4, m_nN);
DDX_Text(pDX, IDC_EDIT5, m_dLen);
DDX_Check(pDX, IDC_CHECK1, m_bRight);
DDX_Text(pDX, IDC_EDIT2, m_sInfDir);
DDX_Text(pDX, IDC_EDIT6, m_sPipeNo);
DDX_Control(pDX, IDC_LIST4, m_wndListBox);
}
BEGIN_MESSAGE_MAP(CBZGDDlg, CDialog)
ON_BN_CLICKED(IDOK, &CBZGDDlg::OnBnClickedOk)
ON_MESSAGE(WM_VIEW_LBUTTONDOWN, &CBZGDDlg::OnViewLButtonDown)
ON_STN_CLICKED(IDC_STATIC_COLOR, &CBZGDDlg::OnStnClickedStaticColor)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_BUTTON1, &CBZGDDlg::OnBnClickedButton1)
ON_BN_CLICKED(IDC_BUTTON2, &CBZGDDlg::OnBnClickedButton2)
ON_BN_CLICKED(IDC_BUTTON11, &CBZGDDlg::OnBnClickedButton11)
ON_BN_CLICKED(IDC_BUTTON52, &CBZGDDlg::OnBnClickedButton52)
END_MESSAGE_MAP()
BOOL CBZGDDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// 子类化控件对象
if (!m_wndViewCtrl.SubclassDlgItem(IDC_STATIC_EW, this))
{
// 错误时,结束对话框
EndDialog(IDCANCEL);
return FALSE;
}
ShowEarthWorm();
m_wndPipeList.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_wndPipeList.InsertColumn(0,_T("公称直径"),LVCFMT_LEFT,60);
m_wndPipeList.InsertColumn(1,_T("外径"),LVCFMT_LEFT,60);
m_wndPipeList.InsertColumn(2,_T("壁厚"),LVCFMT_LEFT,60);
m_wndPipeList.InsertColumn(3,_T("线比重"),LVCFMT_LEFT,100);
CString path = FilePath::GetSysDir() + Plumbing_DB;
if (!m_dbSQLite.InitADOServer(path))
{
AfxMessageBox(CString(_T("数据库初始化失败,请检查 sys")) + Plumbing_DB + _T("文件是否存在."));
return FALSE;
}
InitPipeList();
InitElbowCrt();
if (m_bAllRoomPipes)
{
GetDlgItem(IDC_STATIC_CR)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_STATIC_COLOR)->ShowWindow(SW_HIDE);
}
if (!m_bByPath)
{
GetDlgItem(IDC_BUTTON52)->ShowWindow(SW_HIDE);
}
UpdateData(FALSE);
return TRUE;
}
void CBZGDDlg::InitElbowCrt()
{
CString sSQL;
sSQL = _T("select [曲率半径] from AecElbowradius order by [曲率半径]");
bool bSet = false;
CStringArray arVals;
m_dbSQLite.GetSelData(sSQL,arVals);
for (int i = 0;i < arVals.GetSize();i++)
{
m_wndListBox.AddString(arVals.GetAt(i));
if ( fabs( m_dRRato - _ttof(arVals.GetAt(i) ) ) < 1.e-2)
{
m_wndListBox.SetCurSel(i);
bSet = true;
}
}
if (!bSet)
m_wndListBox.SetCurSel(0);
}
void CBZGDDlg::SetEWFittingId(AcDbObjectId& id,double dLen)
{
m_idEWFit = id;
m_dLen = dLen;
}
void CBZGDDlg::SetXXXHouseID(AcDbObjectId& id)
{
m_idHouse = id;
}
void CBZGDDlg::InitPipeList()
{
CString sSQL,sText;
sSQL = _T("select [公称直径],[外径],[壁厚],[重量] from AecOD order by [公称直径]");
CUIIValueTable table;
m_dbSQLite.GetSelData(sSQL,table);
table.ShowToListCtrl(&m_wndPipeList);
double dT = 0.0;
CString sDnold;
sDnold.Format(_T("%d"),(int)m_dDn);
bool bFind = false;
for (int i = 0;i < m_wndPipeList.GetItemCount();i++)
{
sText = m_wndPipeList.GetItemText(i,0);
dT = _ttof(m_wndPipeList.GetItemText(i,2));
if (sText.CompareNoCase(sDnold) == 0 && fabs(m_dt - dT) < 1.e-2)
{
m_wndPipeList.SetItemState(i,LVIS_SELECTED,LVIS_SELECTED);
m_wndPipeList.EnsureVisible(i,TRUE);
bFind = true;
break;
}
}
if (!bFind)
{
if (m_wndPipeList.GetItemCount() > 0)
m_wndPipeList.SetItemState(0,LVIS_SELECTED,LVIS_SELECTED);
}
//材质
CStringArray arVals;
sSQL = _T("select [材质] from AecMaterial where [类型]='管道'");
m_dbSQLite.GetSelData(sSQL,arVals);
int nCursel = 0;
for (i = 0;i < arVals.GetSize();i++)
{
m_wndListBoxMaters.AddString(arVals.GetAt(i));
if (m_sMertial.CompareNoCase(arVals.GetAt(i)) == 0)
{
nCursel = i;
}
}
m_wndListBoxMaters.SetCurSel(nCursel);
//系统
CString sStd,sTemp;
sSQL = _T("select tablename from wpipecfg where currstd=1");
m_dbSQLite.GetSelData(sSQL,sStd);
sSQL.Format(_T("select distinct system from %s"),sStd);
CStringArray arSyses;
m_dbSQLite.GetSelData(sSQL,arSyses);
nCursel = 0;
for (int i = 0;i < arSyses.GetSize();i++)
{
sTemp = arSyses.GetAt(i);
m_wndSysListBox.AddString(sTemp);
if (m_sCurrSys.CompareNoCase(sTemp) == 0)
{
nCursel = i;
}
}
m_wndSysListBox.SetCurSel(nCursel);
}
LRESULT CBZGDDlg::OnViewLButtonDown(WPARAM wp, LPARAM lp)
{
UpdateData();
AcGePoint3d* pPt = (AcGePoint3d*)lp;
pPt->z = 0.0;
//判断 点落在 room 内
AecDbEarthWorm worm;
worm.SetStartPoint(AcGePoint2d(0,0));
worm.SetEndPoint(AcGePoint2d(m_dLen,0));
worm.SetStartElevation(0.0);
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0);
worm.AddSegment(0, 0.0, m_dLen, _T("KZ001"));
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();
AcArray<LineSeg> arLnSegs;
worm.GetPipeLineSegs(m_idxRoom,arLnSegs);
if (!arLnSegs.isEmpty())
{
LineSeg& lnSg = arLnSegs.first();
double dDn = 0.0;
CString sMat;
for (int i = 0;i < m_wndPipeList.GetItemCount();i++)
{
dDn = _ttof( m_wndPipeList.GetItemText(i,0) );
if ( lnSg.dDn - AS_MUNIT(dDn) < 1.e-3)
{
m_wndPipeList.SetItemState(i,LVIS_SELECTED,LVIS_SELECTED);
m_wndPipeList.EnsureVisible(i,TRUE);
break;
}
}
int nSel = m_wndListBoxMaters.FindString(0,lnSg.szMat);
m_wndListBoxMaters.SetCurSel(nSel);
nSel = m_wndSysListBox.FindString(0,lnSg.szSys);
m_wndSysListBox.SetCurSel(nSel);
m_dX = lnSg.dX;
AcGePoint2d ptThick;
AcGePoint2d pt = worm.GetSize(ptThick);
m_dZ = lnSg.ptFr.z;
m_dZ = 0.5 * pt.y - fabs(m_dZ) - worm.GetBomThickAdd() - ptThick.x;
int nDZ = (int)(m_dZ * 1000.0);
m_dZ = nDZ / 1000.0;
}
UpdateData(FALSE);
}
return 0L;
}
void CBZGDDlg::ShowEarthWorm()
{
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.0);
ESection eType = eRect;
AcGePoint2dArray arDatas;
eType = worm.ExtractEarthWormScr(arDatas);
AcGeLineSeg3d ln;
AcGePoint3d pt2(1000.0, 0, 0);
ln.set(AcGePoint3d::kOrigin, pt2);
AcDbRegion* pEWRegion = worm.CreateSectionRegion(ln, eType, arDatas);
if (pEWRegion != NULL)
{
AcDbVoidPtrArray arr;
int rooms = worm.CreateSectionRoomRegion(ln, eType, arDatas, arr);
Acad::ErrorStatus es;
AcDbRegion* pRegIn = NULL;
AcDbEntity* pEnt = NULL;
AcDbVoidPtrArray arr2;
worm.CreateSectionRoomAddition(ln,eType,arr2);
for (int i = 0; i < arr2.length(); i++)
{
pEnt = (AcDbEntity*)arr2.at(i);
pRegIn = AcDbRegion::cast(pEnt);
if (pRegIn != NULL)
{
es = pEWRegion->booleanOper(AcDb::kBoolUnite,pRegIn);
}
else
{
m_wndViewCtrl.Add(pEnt);
}
}
AcDbExtents exts;
pEWRegion->getGeomExtents(exts);
m_wndViewCtrl.InitFromCurrentView2D(exts,true);
m_wndViewCtrl.Add(pEWRegion);
m_wndViewCtrl.view()->invalidate();
m_wndViewCtrl.Invalidate();
m_wndViewCtrl.RedrawWindow();
}
}
void CBZGDDlg::OnBnClickedOk()
{
UpdateData();
if (m_idxRoom < 0 && m_pInf == NULL)
{
if (!m_bInfLast)
{
AfxMessageBox(_T("请选择舱室定位管道或者管线管件接口定位管道!"));
return;
}
}
if (m_dLen < .01)
{
AfxMessageBox(_T("布置管道长度太短!"));
return;
}
int nItem = -1;
POSITION ps = m_wndPipeList.GetFirstSelectedItemPosition();
if (ps != NULL)
{
nItem = m_wndPipeList.GetNextSelectedItem(ps);
}
if (nItem == -1)
{
AfxMessageBox(_T("请选择管道规格!"));
return;
}
int nCurSel = m_wndListBox.GetCurSel();
if (nCurSel < 0)
{
AfxMessageBox(_T("没有选择弯头曲率半径,请选择曲率半径!"));
return;
}
CString sRato;
m_wndListBox.GetText(nCurSel,sRato);
m_dRRato = _ttof(sRato);
m_dDn = _ttof( m_wndPipeList.GetItemText(nItem,0) );
m_dOD = _ttof(m_wndPipeList.GetItemText(nItem,1));
m_dt = _ttof(m_wndPipeList.GetItemText(nItem,2));
int nSel = m_wndListBoxMaters.GetCurSel();
if (nSel == -1)
{
AfxMessageBox(_T("请选择管道材质!"));
return;
}
m_wndListBoxMaters.GetText(nSel,m_sMertial);
int nSys = m_wndSysListBox.GetCurSel();
if (nSys == -1)
{
AfxMessageBox(_T("请选择管道用途系统!"));
return;
}
m_wndSysListBox.GetText(nSys,m_sCurrSys);
OnOK();
}
void CBZGDDlg::OnStnClickedStaticColor()
{
acedSetColorDialog(m_nPipeColor,Adesk::kFalse,m_nPipeColor);
Invalidate();
}
HBRUSH CBZGDDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC)
{
if (pWnd != NULL && pWnd->GetDlgCtrlID() == IDC_STATIC_COLOR)
{
COLORREF crColor = RGB(255,255,255);
if (m_nPipeColor == kColorByLayer)
{
crColor = RGB(255,255,255);
}
else
{
crColor = acedGetRGB(m_nPipeColor);
}
CRect rc;
pWnd->GetClientRect(rc);
pDC->FillSolidRect(rc,crColor);
}
}
return hbr;
}
void CBZGDDlg::OnBnClickedButton1()
{
UpdateData(TRUE);
EnableWindow(FALSE);
CWnd* pFrame = acedGetAcadFrame();
pFrame->EnableWindow(TRUE);
ShowWindow(SW_HIDE);
pFrame->SetFocus();
ads_point pt1;
int nRes = acedGetPoint(NULL,_T("\n请选择第一点:"),pt1);
if (nRes == RTNORM)
{
nRes = acedGetDist(pt1,_T("\n请选择第二点:"),&m_dLen);
if (nRes == RTNORM)
{
UpdateData(FALSE);
}
}
pFrame->EnableWindow(FALSE);
ShowWindow(SW_SHOW);
EnableWindow(TRUE);
}
int CBZGDDlg::GetX3dSolidRecs( AecDbX3dGroup*& pGroup)
{
//_T("RECT:3900x3600|2900x3600|400x300|EXT:...");//EXT为扩充字段
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0);
AcGePoint3d ptOrg;
AcGePoint2d ptThick;
AcArray<ERoom> arRooms;
AcGeLineSeg3d ln(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0.0,0));
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
if (pGroup != NULL)
{
pGroup->RemoveAll3dSolidRec();
}
else
{
pGroup = new AecDbX3dGroup;
}
if (m_idxRoom > -1)
{
ERoom& room = arRooms.at(m_idxRoom);
ptOrg = m_bRight ? room.ptGe[1] : room.ptGe[0];
ptOrg.z += m_dZ;
AcGeVector3d vtDirX = room.ptGe[1] - room.ptGe[0];
if (m_bRight) vtDirX *= -1;
vtDirX.normalize();
ptOrg += vtDirX * m_dX;
}
if (m_pInf != NULL)
{
ptOrg = m_pInf->ptPos;
m_vtDir = m_pInf->vtDir;
}
if (m_bInfLast)
{
ptOrg = m_ptInfLast;
}
AcGeVector3d vtZ = m_vtDir;
AcDbX3dSolid* pXSolid = NULL;
double dR = 0.5 * AS_MUNIT ( m_dDn );
ptOrg += 0.5 * m_dLen * vtZ;
//pipe rxtxH
X3dSolidRec rec;
pXSolid = new AcDbX3dSolid;
pXSolid->Create(AcDbX3dSolid::kPipe,ptOrg,vtZ,3,dR,AS_MUNIT(m_dt),m_dLen );//米单位
rec.pXSolid = pXSolid;
rec.bType = AcDb::kBoolUnite;
_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);
//不需要BOOL并到Fit中的标志
pGroup->GetSpecialtyData()->SetAt(_T("COLOR"),m_nPipeColor);//系统默认KEY COLOR
//序列化BIM数据
pGroup->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
pGroup->GetSpecialtyData()->SetAt(_T("m_dZ"),m_dZ);
pGroup->GetSpecialtyData()->SetAt(_T("m_nN"),m_nN);
pGroup->GetSpecialtyData()->SetAt(_T("m_dLen"),m_dLen);
pGroup->GetSpecialtyData()->SetAt(_T("m_bRight"),m_bRight);
pGroup->GetSpecialtyData()->SetAt(_T("m_vtDir"),m_vtDir);
pGroup->GetSpecialtyData()->SetAt(_T("m_ptInfLast"),m_ptInfLast);
pGroup->GetSpecialtyData()->SetAt(_T("m_bInfLast"),m_bInfLast);
pGroup->GetSpecialtyData()->SetAt(_T("m_sCurrSys"),m_sCurrSys);
pGroup->GetSpecialtyData()->SetAt(_T("m_sMertial"),m_sMertial);
pGroup->GetSpecialtyData()->SetAt(_T("m_dDn"),m_dDn);
pGroup->GetSpecialtyData()->SetAt(_T("m_dt"),m_dt);
pGroup->GetSpecialtyData()->SetAt(_T("m_dOD"),m_dOD);
pGroup->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pGroup->GetSpecialtyData()->SetAt(_T("m_sPipeNo"),m_sPipeNo);
pGroup->GetSpecialtyData()->SetAt(_T("m_dRRato"),m_dRRato);
return TRUE;
}
int CBZGDDlg::GetPipe(AecDbEwPipe*& pPipe)
{
AecDbEarthWorm worm;
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0);
AcGePoint3d ptOrg;
AcGePoint2d ptThick;
AcArray<ERoom> arRooms;
AcGeLineSeg3d ln(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0.0,0));
worm.GetSectionRoomsTo(ln,arRooms,ptThick);
bool bIsModify = false;
if (pPipe == NULL)
{
pPipe = new AecDbEwPipe;
}
else
{
bIsModify = true;
}
if (m_idxRoom > -1)
{
ERoom& room = arRooms.at(m_idxRoom);
ptOrg = m_bRight ? room.ptGe[1] : room.ptGe[0];
ptOrg.z += m_dZ;
AcGeVector3d vtDirX = room.ptGe[1] - room.ptGe[0];
if (m_bRight) vtDirX *= -1;
vtDirX.normalize();
ptOrg += vtDirX * m_dX;
//抬高
ptOrg.z += 0.5 * AS_MUNIT(m_dDn);
}
if (m_pInf != NULL)
{
ptOrg = m_pInf->ptPos;
m_vtDir = m_pInf->vtDir;
}
if (m_bInfLast)
{
ptOrg = m_ptInfLast;
}
//ptOrg.z += 0.5 * AS_MUNIT(m_dDn);
AcGeVector3d vtZ = m_vtDir;
vtZ.normalize();
AcDbX3dSolid* pXSolid = NULL;
ptOrg += 0.5 * m_dLen * vtZ;
//设置半径和厚度
pPipe->SetSection(AS_MUNIT(m_dDn),0.0);//AS_MUNIT(m_dt)
//设置起始点,可以通过官位得到,后期改动
AcGePoint3d ptSta,ptEnd;
ptSta = ptOrg - vtZ * 0.5 * m_dLen;
ptEnd = ptOrg + vtZ * 0.5 * m_dLen;
if (!bIsModify)
{
pPipe->SetBaseCurve(ptSta,ptEnd);
}
AcDbObjectId layerSingleID(AcDbObjectId::kNull)
, layerDoubleID(AcDbObjectId::kNull)
, layerID(AcDbObjectId::kNull);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE_SINGLE, layerSingleID);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE_DOUBLE, layerDoubleID);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE, layerID);
pPipe->SetSingleLayer(layerSingleID);
pPipe->SetDoubleLayer(layerDoubleID);
pPipe->setLayer(layerID);
pPipe->setLinetype(KTSetting::InitLineStyle(_T("CENTER")));
//不需要BOOL并到Fit中的标志
pPipe->GetSpecialtyData()->SetAt(_T("COLOR"),m_nPipeColor);//系统默认KEY COLOR
//序列化BIM数据
pPipe->GetSpecialtyData()->SetAt(_T("m_dX"),m_dX);
pPipe->GetSpecialtyData()->SetAt(_T("m_dZ"),m_dZ);
pPipe->GetSpecialtyData()->SetAt(_T("m_nN"),m_nN);
pPipe->GetSpecialtyData()->SetAt(_T("m_dLen"),m_dLen);
pPipe->GetSpecialtyData()->SetAt(_T("m_bRight"),m_bRight);
if (!bIsModify)
{
pPipe->GetSpecialtyData()->SetAt(_T("m_vtDir"),m_vtDir);
}
pPipe->GetSpecialtyData()->SetAt(_T("m_ptInfLast"),m_ptInfLast);
pPipe->GetSpecialtyData()->SetAt(_T("m_bInfLast"),m_bInfLast);
pPipe->GetSpecialtyData()->SetAt(_T("m_sCurrSys"),m_sCurrSys);
pPipe->GetSpecialtyData()->SetAt(_T("m_sMertial"),m_sMertial);
pPipe->GetSpecialtyData()->SetAt(_T("m_dDn"),m_dDn);
pPipe->GetSpecialtyData()->SetAt(_T("m_dt"),m_dt);
pPipe->GetSpecialtyData()->SetAt(_T("m_dOD"),m_dOD);
pPipe->GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pPipe->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pPipe->GetSpecialtyData()->SetAt(_T("m_sPipeNo"),m_sPipeNo);
//统一管线接口
pPipe->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 1);
pPipe->GetSpecialtyData()->SetAt(PIPE_DN, AS_MUNIT(m_dDn));
pPipe->GetSpecialtyData()->SetAt(PIPE_OD, AS_MUNIT(m_dOD));
pPipe->GetSpecialtyData()->SetAt(PIPE_RATIO,m_dRRato);
pPipe->GetSpecialtyData()->SetAt(PIPE_THICK, AS_MUNIT(m_dt));
pPipe->GetSpecialtyData()->SetAt(PIPE_MATERIAL, m_sMertial);
pPipe->GetSpecialtyData()->SetAt(PIPE_SYS, m_sCurrSys);
return TRUE;
}
int CBZGDDlg::GetPathPipe(AcDbVoidPtrArray& arPipePtrs,AcDbVoidPtrArray& arFittPtrs)
{
if (!m_arPtsPath.isEmpty())
{
AcDbLine ln(AcGePoint3d::kOrigin,AcGePoint3d(10.0,0,0));
AecDbEwPipe pipe;
AcDbObjectId layerSingleID(AcDbObjectId::kNull)
, layerDoubleID(AcDbObjectId::kNull)
, layerID(AcDbObjectId::kNull);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE_SINGLE, layerSingleID);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE_DOUBLE, layerDoubleID);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE, layerID);
pipe.SetSection(AS_MUNIT(m_dDn),0.0);//AS_MUNIT(m_dt)
pipe.SetBaseCurve(&ln);
pipe.GetSpecialtyData()->SetAt(_T("COLOR"),m_nPipeColor);//系统默认KEY COLOR
pipe.GetSpecialtyData()->SetAt(_T("m_sCurrSys"),m_sCurrSys);
pipe.GetSpecialtyData()->SetAt(_T("m_sMertial"),m_sMertial);
pipe.GetSpecialtyData()->SetAt(_T("m_dDn"),m_dDn);
pipe.GetSpecialtyData()->SetAt(_T("m_dt"),m_dt);
pipe.GetSpecialtyData()->SetAt(_T("m_dOD"),m_dOD);
pipe.GetSpecialtyData()->SetAt(KEY_2DSTYLE, 1);
pipe.GetSpecialtyData()->SetAt(PIPE_DN, AS_MUNIT(m_dDn));
pipe.GetSpecialtyData()->SetAt(PIPE_OD, AS_MUNIT(m_dOD));
pipe.GetSpecialtyData()->SetAt(PIPE_THICK, AS_MUNIT(m_dt));
pipe.GetSpecialtyData()->SetAt(PIPE_MATERIAL, m_sMertial);
pipe.GetSpecialtyData()->SetAt(PIPE_SYS, m_sCurrSys);
pipe.GetSpecialtyData()->SetAt(PIPE_RATIO,m_dRRato);
pipe.GetSpecialtyData()->SetAt(_T("m_sPipeNo"),m_sPipeNo);
pipe.GetSpecialtyData()->SetAt(_T("m_idxRoom"),m_idxRoom);
pipe.GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pipe.GetSpecialtyData()->SetAt(_T("m_sPipeNo"),m_sPipeNo);
pipe.setLayer(layerID);
pipe.setLinetype(KTSetting::InitLineStyle(_T("CENTER")));
pipe.SetSingleLayer(layerSingleID);
pipe.SetDoubleLayer(layerDoubleID);
pipe.setLinetype(KTSetting::InitLineStyle(_T("CENTER")));
AecPipeLineTool::CreatePipe(&pipe,m_arPtsPath,arPipePtrs,arFittPtrs);
return TRUE;
}
return FALSE;
}
int CBZGDDlg::GetPipe(AcDbVoidPtrArray& arPipePtrs,AcDbLine* pLine)
{
AecDbEarthWorm worm;
if (pLine == NULL)
{
worm.SetStartPoint(AcGePoint2d(0,0));
worm.SetEndPoint(AcGePoint2d(m_dLen,0));
worm.SetStartElevation(0.0);
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0);
worm.AddSegment(0, 0.0, m_dLen, _T("KZ001"));
}
else
{
AcGePoint3d ptSta = pLine->startPoint();
AcGePoint3d ptEnd = pLine->endPoint();
worm.SetStartPoint(AcGePoint2d(ptSta.x,ptSta.y));
worm.SetEndPoint(AcGePoint2d(ptEnd.x,ptEnd.y));
worm.SetStartElevation(ptSta.z);
worm.SetCrossSectionScr(m_sCrossSectionScr);
worm.SetChamferInter(100.0);
worm.AddSegment(0, 0.0, m_dLen, _T("KZ001"));
}
AcDbObjectId layerSingleID(AcDbObjectId::kNull)
, layerDoubleID(AcDbObjectId::kNull)
, layerID(AcDbObjectId::kNull);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE_SINGLE, layerSingleID);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE_DOUBLE, layerDoubleID);
g_LayerMgr::instance().getLayer(GLTools::gLayer_PIPE, layerID);
AcGePoint2d ptThick;
AcGePoint2d pt = worm.GetSize(ptThick);
int nDZ = 0;
double dX = 0.0,dZ = 0.0,dTAdd = 0.0;
dTAdd = worm.GetBomThickAdd();
AcGeVector3d vtDir;
int nRooms = worm.GetRoomCount();
for (int k = 0;k < nRooms;k++)
{
AcArray<LineSeg> arLnSegs;
worm.GetPipeLineSegs(k,arLnSegs);
AecDbEwPipe* pPipe = NULL;
if (!arLnSegs.isEmpty())
{
for (int i = 0;i < arLnSegs.length();i++)
{
LineSeg& lnSg = arLnSegs.at(i);
vtDir = lnSg.ptTo - lnSg.ptFr;
dX = lnSg.dX;
dZ = lnSg.ptFr.z;
dZ = 0.5 * pt.y - fabs(dZ) - dTAdd - ptThick.x;
nDZ = (int)(dZ * 1000.0);
dZ = nDZ / 1000.0;
lnSg.ptFr.z += 0.5 * lnSg.dDn;
lnSg.ptTo.z += 0.5 * lnSg.dDn;
pPipe = new AecDbEwPipe;
pPipe->SetBaseCurve(lnSg.ptFr,lnSg.ptTo);
pPipe->SetSection(lnSg.dDn,0.0);
pPipe->SetSingleLayer(layerSingleID);
pPipe->SetDoubleLayer(layerDoubleID);
pPipe->SetSingleLineType(KTSetting::InitLineStyle(lnSg.szLntype));
pPipe->SetDoubleLineType(KTSetting::InitLineStyle(lnSg.szLntype));
pPipe->setLayer(layerID);
pPipe->setLinetype(KTSetting::InitLineStyle(_T("CENTER")));
//不需要BOOL并到Fit中的标志
pPipe->GetSpecialtyData()->SetAt(_T("COLOR"),lnSg.nColor);//系统默认KEY COLOR
//序列化BIM数据
pPipe->GetSpecialtyData()->SetAt(_T("m_dX"),dX);
pPipe->GetSpecialtyData()->SetAt(_T("m_dZ"),dZ);
pPipe->GetSpecialtyData()->SetAt(_T("m_nN"),0);
pPipe->GetSpecialtyData()->SetAt(_T("m_dLen"),m_dLen);
pPipe->GetSpecialtyData()->SetAt(_T("m_bRight"),FALSE);
pPipe->GetSpecialtyData()->SetAt(_T("m_vtDir"),vtDir);
pPipe->GetSpecialtyData()->SetAt(_T("m_ptInfLast"),lnSg.ptFr);
pPipe->GetSpecialtyData()->SetAt(_T("m_bInfLast"),FALSE);
pPipe->GetSpecialtyData()->SetAt(_T("m_sCurrSys"),lnSg.szSys);
pPipe->GetSpecialtyData()->SetAt(_T("m_sMertial"),lnSg.szMat);
pPipe->GetSpecialtyData()->SetAt(_T("m_dDn"),AS_M2MM(lnSg.dDn));
pPipe->GetSpecialtyData()->SetAt(_T("m_dt"),AS_M2MM(lnSg.dt));
pPipe->GetSpecialtyData()->SetAt(_T("m_dOD"),AS_M2MM(lnSg.dD));
pPipe->GetSpecialtyData()->SetAt(_T("m_idxRoom"),k);
pPipe->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
pPipe->GetSpecialtyData()->SetAt(_T("m_sPipeNo"),m_sPipeNo);
//统一管线接口
pPipe->GetSpecialtyData()->SetAt(KEY_2DSTYLE, 1);
pPipe->GetSpecialtyData()->SetAt(PIPE_DN, lnSg.dDn);
pPipe->GetSpecialtyData()->SetAt(PIPE_OD, lnSg.dD);
pPipe->GetSpecialtyData()->SetAt(PIPE_THICK, lnSg.dt);
pPipe->GetSpecialtyData()->SetAt(PIPE_MATERIAL, lnSg.szMat);
pPipe->GetSpecialtyData()->SetAt(PIPE_SYS, lnSg.szSys);
pPipe->GetSpecialtyData()->SetAt(PIPE_RATIO,m_dRRato);
arPipePtrs.append(pPipe);
}
}
}
return TRUE;
}
void CBZGDDlg::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) )
{
if ( !pGroupNext->GetSpecialtyData()->GetAt(_T("m_dDn"),dDn) )
{
pGroupNext->GetSpecialtyData()->GetAt(_T("m_dDn2"),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
{
m_ptInfLast = arInfs.at(i).ptPos;
m_bInfLast = TRUE;
m_vtDir = arInfs.at(i).vtDir;
m_vtDir.normalize();
//复制pGroup的材料信息和管径
pGroupNext->GetSpecialtyData()->GetAt(_T("m_sCurrSys"),m_sCurrSys);
pGroupNext->GetSpecialtyData()->GetAt(_T("m_sMertial"),m_sMertial);
pGroupNext->GetSpecialtyData()->GetAt(_T("m_idxRoom"),m_idxRoom);
m_dDn = dDn;
pGroupNext->GetSpecialtyData()->GetAt(_T("m_dt"),m_dt);
pGroupNext->GetSpecialtyData()->GetAt(_T("COLOR"),m_nPipeColor);//系统默认KEY COLOR
int nSel = m_wndSysListBox.FindString(0,m_sCurrSys);
if (nSel != -1 )
{
m_wndSysListBox.SetCurSel(nSel);
}
nSel = m_wndListBoxMaters.FindString(0,m_sMertial);
if (nSel != -1 )
{
m_wndListBoxMaters.SetCurSel(nSel);
}
break;
}
}
}
}
pFit->close();
}
}
pFrame->EnableWindow(FALSE);
ShowWindow(SW_SHOW);
EnableWindow(TRUE);
UpdateData(FALSE);
}
void CBZGDDlg::OnBnClickedButton11()
{
UpdateData();
if (m_pInf != NULL)
DELETE_PTR(m_pInf);
//AecDbX3dGroup* pGroupAt = NULL;
//m_pInf = SelectLockInf(m_idEWFit,pGroupAt);
AecDbObjXDataMap* pGroupMap = NULL;
m_pInf = SelectLockInf(m_idEWFit,pGroupMap);
if (m_pInf == NULL)
{
m_pInf = SelectLockInfH(m_idHouse,pGroupMap);
}
else
{
//尺寸,颜色
pGroupMap->GetAt(_T("m_sCurrSys"),m_sCurrSys);
pGroupMap->GetAt(_T("m_sMertial"),m_sMertial);
//pGroupMap->GetAt(_T("m_dDn"),m_dDn);
m_dDn = AS_M2MM(m_pInf->dSize1);
pGroupMap->GetAt(_T("m_dt"),m_dt);
//pGroupMap->GetAt(_T("m_dOD"),m_dOD);
pGroupMap->GetAt(_T("COLOR"),m_nPipeColor);
double dN = 0.0,dO = 0.0,dt = 0.0;
for (int i = 0;i < m_wndPipeList.GetItemCount();i++)
{
dN = _ttof(m_wndPipeList.GetItemText(i,0));
dO = _ttof(m_wndPipeList.GetItemText(i,1));
dt = _ttof(m_wndPipeList.GetItemText(i,2));
//按公称直径和壁厚定位系列
if ( fabs(dt - m_dt) < 1.e-2 && fabs(dN - m_dDn) < 1.e-2)
{
m_wndPipeList.SetItemState(i,LVIS_SELECTED,LVIS_SELECTED);
m_wndPipeList.EnsureVisible(i,TRUE);
break;
}
}
CString sSys;
for(int i = 0;i < m_wndSysListBox.GetCount();i++)
{
m_wndSysListBox.GetText(i,sSys);
if (sSys.CompareNoCase(m_sCurrSys) == 0)
{
m_wndSysListBox.SetCurSel(i);
break;
}
}
for(int i = 0;i < m_wndListBoxMaters.GetCount();i++)
{
m_wndListBoxMaters.GetText(i,sSys);
if (sSys.CompareNoCase(m_sMertial) == 0)
{
m_wndListBoxMaters.SetCurSel(i);
break;
}
}
}
m_bInfLast = m_pInf != NULL ? FALSE : TRUE;
if (m_pInf != NULL)
{
m_pInf->vtDir.normalize();
m_sInfDir.Format(_T("%g,%g,%g"),m_pInf->vtDir.x,m_pInf->vtDir.y,m_pInf->vtDir.z);
}
UpdateData(FALSE);
Invalidate();
RedrawWindow();
}
AecInterface* SelectLockInf(AcDbObjectId idEW,AecDbObjXDataMap*& pGroupMap)
{
//选择管道,弯头等
AecInterface* pInf = NULL;
AcAxDocLock lock;
AecDbEarthWormFitting* pFit = NULL;
if ( Acad::eOk == acdbOpenAcDbEntity((AcDbEntity*&)pFit,idEW,AcDb::kForRead))
{
int nIndex = 0,nPos = 0;
AcDbEntity* pGroupNext = NULL;
int nType = 0;
while( pFit->GetAddtion(nIndex,pGroupNext,nType) )
{
switch(nType)
{
case ePipe:
{
AecDbEwPipe* pPipe = (AecDbEwPipe*)pGroupNext;
nPos = pPipe->GetActiveInf();
if (nPos != -1)
{
pGroupMap = pPipe->GetSpecialtyData();
AecInterface inf;
if ( pPipe->GetInterface(nPos,inf) )
{
pInf = new AecInterface;
*pInf = inf;
AecInterface inf2;
pPipe->GetInterface(1-nPos,inf2);
pGroupMap->SetAt(KEY_MID,MidPoint(inf.ptPos,inf2.ptPos));
//pGroupAt = pGroupNext;
}
break;
}
break;
}
case eFitting:
{
AecDbEwFitting* pFitting = (AecDbEwFitting*)pGroupNext;
nPos = pFitting->GetActiveInf();
if (nPos != -1)
{
pGroupMap = pFitting->GetSpecialtyData();
AecInterface inf;
if ( pFitting->GetInterface(nPos,inf) )
{
pInf = new AecInterface;
*pInf = inf;
//pGroupAt = pGroupNext;
}
break;
}
break;
}
case eEquipment:
{
AecDbEwEquipment* pEqu = (AecDbEwEquipment*)pGroupNext;
nPos = pEqu->GetActiveInf();
if (nPos != -1)
{
pGroupMap = pEqu->GetSpecialtyData();
AecInterface inf;
if ( pEqu->GetInterface(nPos,inf) )
{
pInf = new AecInterface;
*pInf = inf;
//pGroupAt = pGroupNext;
}
break;
}
break;
}
}
}
//再查开孔
if (pInf == NULL)
{
AecDbX3dGroup* pGroupAt = NULL;
pInf = SelectLockInf(idEW,pGroupAt);
if (pGroupAt != NULL)
{
pGroupMap = pGroupAt->GetSpecialtyData();
double dDn = 0.0;
if ( !pGroupMap->GetAt(_T("m_dDn"),dDn) )
{
pGroupMap->SetAt(_T("m_dDn"),AS_M2MM(pInf->dSize1));
}
}
}
pFit->close();
}
return pInf;
}
AecInterface* SelectLockInf(AcDbObjectId idEW,AecDbX3dGroup*& pGroupAt)
{
//选择管道,弯头等
AecInterface* pInf = NULL;
AcAxDocLock lock;
AecDbEarthWormFitting* pFit = NULL;
if ( Acad::eOk == acdbOpenAcDbEntity((AcDbEntity*&)pFit,idEW,AcDb::kForRead))
{
int nIndex = 0,nPos = 0;
AecDbX3dGroup* pGroupNext = NULL;
while( pFit->GetX3dGroup(nIndex,pGroupNext) )
{
nPos = pGroupNext->GetActiveInf();
if (nPos != -1)
{
AecInterface inf;
if ( pGroupNext->GetInterface(nPos,inf) )
{
pInf = new AecInterface;
*pInf = inf;
pGroupAt = pGroupNext;
}
break;
}
}
pFit->close();
}
return pInf;
}
AecInterface* SelectLockInfH(AcDbObjectId idHouse,AecDbObjXDataMap*& pGroupMap)
{
AecInterface* pInf = NULL;
AcAxDocLock lock;
AecDbXXXDoghouse* pHouse = NULL;
if ( Acad::eOk == acdbOpenAcDbEntity((AcDbEntity*&)pHouse,idHouse,AcDb::kForRead))
{
int nIndex = 0,nPos = 0;
AecDbX3dPart* pGroupNext = NULL;
while( pHouse->GetX3dPartNext(nIndex,pGroupNext) )
{
nPos = pGroupNext->GetActiveInf();
if (nPos != -1)
{
AecInterface inf;
if ( pGroupNext->GetInterface(nPos,inf) )
{
pInf = new AecInterface;
*pInf = inf;
pGroupMap = pGroupNext->GetSpecialtyData();
double dDn = 0.0;
if ( !pGroupMap->GetAt(_T("m_dDn"),dDn) )
{
pGroupMap->SetAt(_T("m_dDn"),AS_M2MM(pInf->dSize1));
}
}
break;
}
}
pHouse->close();
}
return pInf;
}
void CBZGDDlg::OnBnClickedButton52()
{
// 选择pline线
UpdateData();
EnableWindow(FALSE);
CWnd* pFrame = acedGetAcadFrame();
pFrame->EnableWindow(TRUE);
ShowWindow(SW_HIDE);
pFrame->SetFocus();
m_arPtsPath.removeAll();
AcAxDocLock lock;
ads_point pt;
ads_name ent;
int nRes = acedEntSel(_T("\n请选择路径pline或3dpline线:"),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);
AcDb3dPolyline* pPl3d = AcDb3dPolyline::cast(pEnt);
AcGePoint3d ptGe;
if (pPl != NULL)
{
int nNum = pPl->numVerts();
for (int i = 0;i < nNum;i++)
{
pPl->getPointAt(i,ptGe);
m_arPtsPath.append(ptGe);
}
}
else if (pPl3d != NULL)
{
AcDbObjectIterator* pIt = pPl3d->vertexIterator();
if (pIt != NULL)
{
int nFoundAt = -1;
for (pIt->start(); !pIt->done(); pIt->step())
{
AcDb3dPolylineVertex* pVertx = NULL;
if (Acad::eOk == pPl3d->openVertex(pVertx, pIt->objectId(), AcDb::kForRead))
{
ptGe = pVertx->position();
if (!m_arPtsPath.find(ptGe, nFoundAt))
{
m_arPtsPath.append(ptGe);
}
pVertx->close();
}
}
DELETE_PTR(pIt);
}
}
else
{
acutPrintf(_T("\n选择的曲线不是pline或3dpline线!"));
}
pEnt->close();
}
}
pFrame->EnableWindow(FALSE);
ShowWindow(SW_SHOW);
EnableWindow(TRUE);
UpdateData(FALSE);
}