201 lines
3.9 KiB
C++
201 lines
3.9 KiB
C++
#include "stdafx.h"
|
|
#include "GLJHDlg.h"
|
|
|
|
#include "AecDbEarthWorm.h"
|
|
#include "AcDbX3dSolid.h"
|
|
#include "AecDbX3dGroup.h"
|
|
#include "KTCADUtilityEx.h"
|
|
#include "AecDbX3dPart.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CGLJHDlg, CDialog)
|
|
|
|
CGLJHDlg::CGLJHDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CGLJHDlg::IDD, pParent)
|
|
, m_dT(0.3)
|
|
, m_nPos(0)
|
|
{
|
|
}
|
|
|
|
CGLJHDlg::~CGLJHDlg()
|
|
{
|
|
}
|
|
|
|
void CGLJHDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Text(pDX, IDC_EDIT1, m_dT);
|
|
DDX_Radio(pDX, IDC_RADIO1, m_nPos);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CGLJHDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CGLJHDlg::OnBnClickedOk)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
BOOL CGLJHDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CGLJHDlg::OnBnClickedOk()
|
|
{
|
|
UpdateData();
|
|
|
|
if (m_dT < 1.e-2)
|
|
{
|
|
AfxMessageBox(_T("加厚尺寸太小!请输入加厚尺寸!"));
|
|
return;
|
|
}
|
|
OnOK();
|
|
}
|
|
|
|
int CGLJHDlg::GetX3dSolidRecs(AecDbX3dGroup*& pGroup,AcGePoint3dArray& arPts)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
int CGLJHDlg::GetX3dPart(AecDbX3dPart*& pGroup,AcGePoint3dArray& arPts)
|
|
{
|
|
if (pGroup != NULL)
|
|
{
|
|
pGroup->RemoveAll3dSolidRec();
|
|
}
|
|
else
|
|
{
|
|
pGroup = new AecDbX3dPart;
|
|
}
|
|
|
|
AecDbEarthWorm worm;
|
|
worm.SetCrossSectionScr(m_sCrossSectionScr);
|
|
AcGePoint2d ptSize = worm.GetSize();
|
|
|
|
AcGePlane plan;
|
|
AcGeVector3d vtZ;
|
|
double dEl = 0;
|
|
switch(m_nPos)
|
|
{
|
|
case 0://左
|
|
{
|
|
vtZ = AcGeVector3d::kZAxis;
|
|
plan.set( AcGePoint3d(0,0,-0.5 * ptSize.y),vtZ);
|
|
dEl = -0.5 * ptSize.y;
|
|
|
|
for (int i = 0;i < arPts.length();i++)
|
|
{
|
|
AcGePoint3d& pt3d = arPts.at(i);
|
|
pt3d.z = -0.5 * ptSize.y;
|
|
}
|
|
break;
|
|
}
|
|
case 1://右
|
|
{
|
|
vtZ = AcGeVector3d::kZAxis;
|
|
plan.set( AcGePoint3d(0,0,-0.5 * ptSize.y),vtZ);
|
|
dEl = -0.5 * ptSize.y;
|
|
|
|
for (int i = 0;i < arPts.length();i++)
|
|
{
|
|
AcGePoint3d& pt3d = arPts.at(i);
|
|
pt3d.z = -0.5 * ptSize.y;
|
|
}
|
|
break;
|
|
}
|
|
case 2://底
|
|
{
|
|
vtZ = AcGeVector3d::kYAxis;
|
|
plan.set( AcGePoint3d(0,-0.5 * ptSize.x,0.0),vtZ);
|
|
dEl = -0.5 * ptSize.x;
|
|
|
|
for (int i = 0;i < arPts.length();i++)
|
|
{
|
|
AcGePoint3d& pt3d = arPts.at(i);
|
|
pt3d.y = -0.5 * ptSize.x;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
break;
|
|
}
|
|
|
|
//偏移,得到拉伸体截面
|
|
AcGePoint2d pt2d;
|
|
AcDbPolyline pl;
|
|
pl.setNormal(plan.normal());
|
|
pl.setElevation(dEl);
|
|
for (int i = 0;i < arPts.length();i++)
|
|
{
|
|
pt2d = arPts.at(i).convert2d(plan);
|
|
pl.addVertexAt(i,pt2d);
|
|
}
|
|
|
|
//偏移最大
|
|
AcDbVoidPtrArray arOff1;
|
|
pl.getOffsetCurves(m_dT,arOff1);
|
|
|
|
if (!arOff1.isEmpty())
|
|
{
|
|
AcDbCurve* pCurve = (AcDbCurve*)arOff1.first();
|
|
|
|
AcGePoint3d ptSta1,ptEnd1;
|
|
AcGePoint3d ptSta2,ptEnd2;
|
|
|
|
pl.getStartPoint(ptSta1);
|
|
pl.getEndPoint(ptEnd1);
|
|
|
|
pCurve->getStartPoint(ptSta2);
|
|
pCurve->getEndPoint(ptEnd2);
|
|
|
|
AcDbLine ln2(ptEnd1,ptEnd2);
|
|
AcDbLine ln1(ptSta1,ptSta2);
|
|
|
|
AcDbVoidPtrArray arCurPtrs,arRegPtrs;
|
|
arCurPtrs.append(&pl);
|
|
arCurPtrs.append(&ln2);
|
|
arCurPtrs.append(pCurve);
|
|
arCurPtrs.append(&ln1);
|
|
|
|
//合成pl线;
|
|
AcDbVoidPtrArray arpResult;
|
|
AcDbCurve* pNewCurve = KTCADUtilityEx::ConvertBoundCurve(arCurPtrs,arpResult);
|
|
if (pNewCurve != NULL)
|
|
{
|
|
CString sPoints,sTemp;
|
|
AcDbPolyline* pPlNew = AcDbPolyline::cast(pNewCurve);
|
|
if (pPlNew != NULL)
|
|
{
|
|
for (int i = 0;i < pPlNew->numVerts();i++)
|
|
{
|
|
pPlNew->getPointAt(i,pt2d);
|
|
sTemp.Format(_T("%g,%g@0.0,"),pt2d.x,pt2d.y);
|
|
sPoints += sTemp;
|
|
}
|
|
sPoints.TrimRight(_T(','));
|
|
DELETE_PTR(pNewCurve);
|
|
|
|
|
|
AcDbX3dSolid* pXSolid = NULL;
|
|
pXSolid = new AcDbX3dSolid;
|
|
|
|
AcGePoint3d ptOrg = ptSta1;
|
|
pXSolid->CreateExtrude(ptOrg,plan.normal(),sPoints,m_dT,0.0);
|
|
pGroup->AddX3dSolid(pXSolid,AcDb::kBoolUnite);
|
|
|
|
pGroup->SetOrgPoint( ptOrg );
|
|
pGroup->SetAxis(X,AcGeVector3d::kXAxis);
|
|
pGroup->SetAxis(Y,AcGeVector3d::kYAxis);
|
|
pGroup->SetAxis(Z,AcGeVector3d::kZAxis);
|
|
|
|
//序列化BIM数据
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_dT"),m_dT);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_nPos"),m_nPos);
|
|
pGroup->GetSpecialtyData()->SetAt(_T("m_sCrossSectionScr"),m_sCrossSectionScr);
|
|
return TRUE;
|
|
}
|
|
}
|
|
}
|
|
return FALSE;
|
|
} |