2577 lines
64 KiB
C++
2577 lines
64 KiB
C++
// DuanSlopeRoofDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
|
|
#include "DuanSlopeRoofDlg.h"
|
|
#include "resource.h"
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
BOOL GetIntersect(XLine &xLine1,const TDbDualSlopeRoof *pDualSlopeRoof,BOOL &m_bFlag1,XPoly3D &poly);
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDuanSlopeRoofDlg dialog
|
|
void GetRoofAllPoly(AcDbObjectId id, DList<X3DFace> &lstFace);
|
|
BOOL GetIntPoint(AcDbCurve *projLine,AcGePoint3d ptStart,AcGePoint3d ptEnd,AcGePoint3d &ptInt);
|
|
BOOL GetIntSectPoly(DList<X3DFace> &lstFace,XLine xLine,XPoly3D &poly);
|
|
void ColumnAlignSlopeRoof(TDbColumn *pColumn,DList<X3DFace> &lstFace);
|
|
void GetIntSectPoint(DList<X3DFace> &lstFace,XLine xLine,XPoly3D &poly);
|
|
BOOL GetEndIntSectPoint(DList<X3DFace> &lstFace,XLine xLine,XPoint &start,XPoint &end,BOOL bWall=TRUE);
|
|
//modified by whl on 070129,屋顶高度去檐板厚
|
|
CDuanSlopeRoofDlg::CDuanSlopeRoofDlg(CWnd* pParent /*=NULL*/)
|
|
: CAcUiDialog(CDuanSlopeRoofDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CDuanSlopeRoofDlg)
|
|
/*m_dElevation = 2500.0;
|
|
m_dHeight = 3000.0;*/
|
|
// [11/9/2007 nsh]
|
|
//初始化适应米单位绘图
|
|
m_dElevation =_AS_SYS_UNIT(2500.0);
|
|
m_dHeight =_AS_SYS_UNIT (3000.0);
|
|
//------------------------------------
|
|
m_dLpojiao = 30.0;
|
|
m_dRpojiao = 30.0;
|
|
|
|
m_bXiandinggaodu = FALSE;
|
|
m_bFlag = FALSE;
|
|
m_pRoof = NULL;
|
|
//}}AFX_DATA_INIT
|
|
m_bbFlag = FALSE;
|
|
}
|
|
CDuanSlopeRoofDlg::CDuanSlopeRoofDlg(TDbDualSlopeRoof *pRoof,CWnd* pParent)
|
|
: CAcUiDialog(CDuanSlopeRoofDlg::IDD, pParent)
|
|
{
|
|
m_pRoof = pRoof;
|
|
m_dElevation = m_pRoof->GetElevation();
|
|
/*m_dHeight = 3000.0;*/
|
|
// [11/9/2007 nsh]
|
|
//初始化适应米单位绘图
|
|
m_dHeight =_AS_SYS_UNIT(3000.0);
|
|
//----------------------------
|
|
m_dLpojiao = (m_pRoof->GetAngleLeft()*180.0) / PI;
|
|
m_dRpojiao = (m_pRoof->GetAngleRight()*180.0) / PI;
|
|
m_bXiandinggaodu = FALSE;
|
|
m_bFlag = TRUE;
|
|
m_bbFlag = FALSE;
|
|
}
|
|
// [2/20/2008 nsh]
|
|
//------------------------begin--------------------
|
|
CDuanSlopeRoofDlg::CDuanSlopeRoofDlg(BOOL bForTSun,CWnd* pParent)
|
|
: CAcUiDialog(bForTSun?CDuanSlopeRoofDlg::IDD2:CDuanSlopeRoofDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CDuanSlopeRoofDlg)
|
|
/*m_dElevation = 2500.0;
|
|
m_dHeight = 3000.0;*/
|
|
// [11/9/2007 nsh]
|
|
//初始化适应米单位绘图
|
|
m_dElevation =_AS_SYS_UNIT(27000.0);// [2/27/2008 nsh]
|
|
m_dHeight =_AS_SYS_UNIT (3000.0);
|
|
//------------------------------------
|
|
m_dLpojiao = 30.0;
|
|
m_dRpojiao = 30.0;
|
|
|
|
m_bXiandinggaodu = FALSE;
|
|
m_bFlag = FALSE;
|
|
m_pRoof = NULL;
|
|
//}}AFX_DATA_INIT
|
|
m_bbFlag = FALSE;
|
|
}
|
|
//-------------------------end---------------------
|
|
void CDuanSlopeRoofDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CAcUiDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CDuanSlopeRoofDlg)
|
|
DDX_Text(pDX, IDC_EDIT_ELEVATION, m_dElevation);
|
|
DDX_Text(pDX, IDC_EDIT_HEIGHT, m_dHeight);
|
|
DDX_Text(pDX, IDC_EDIT_LPOJIAO, m_dLpojiao);
|
|
DDX_Text(pDX, IDC_EDIT_RPOJIAO, m_dRpojiao);
|
|
DDX_Check(pDX, IDC_CHECK_XIANDINGJIAODU, m_bXiandinggaodu);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CDuanSlopeRoofDlg, CAcUiDialog)
|
|
//{{AFX_MSG_MAP(CDuanSlopeRoofDlg)
|
|
ON_BN_CLICKED(IDC_CHECK_XIANDINGJIAODU, OnCheckXiandingjiaodu)
|
|
ON_EN_CHANGE(IDC_EDIT_ELEVATION, OnChangeEditElevation)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_LPOJIAO, OnChangeEditLpojiao)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_RPOJIAO, OnChangeEditRpojiao)
|
|
ON_EN_KILLFOCUS(IDC_EDIT_HEIGHT, OnChangeEditHeight)
|
|
ON_BN_CLICKED(IDC_BT_CANKAOBIAOGAO, OnBtCankaobiaogao)
|
|
ON_WM_CTLCOLOR()
|
|
ON_WM_DESTROY()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CDuanSlopeRoofDlg message handlers
|
|
|
|
BOOL CDuanSlopeRoofDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
if (m_bFlag)
|
|
{
|
|
m_ptFirst = m_pRoof->GetRidgeStart();
|
|
m_ptSecond = m_pRoof->GetRidgeEnd();
|
|
}
|
|
m_ctrlPreview.SubclassDlgItem(IDC_STATIC_PRE,this);
|
|
m_ctrlPreview.SetOrbitFlag(OBF_ZOOM|OBF_PAN|OBF_ORBIT);
|
|
|
|
//modify by xlc on 081223
|
|
if (m_bXiandinggaodu)
|
|
{
|
|
GetDlgItem(IDC_EDIT_LPOJIAO)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_EDIT_RPOJIAO)->EnableWindow(FALSE);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_EDIT_HEIGHT)->EnableWindow(FALSE);
|
|
}
|
|
// ywb 090904 判断是否日照软件
|
|
if (g_bIsSunProduct)
|
|
{
|
|
CWnd* pBtn = GetDlgItem(IDC_BT_CANKAOBIAOGAO);
|
|
assert(pBtn != NULL);
|
|
pBtn->ShowWindow(SW_HIDE);
|
|
|
|
SetWindowText(_T("人字坡顶"));
|
|
}
|
|
|
|
PreView();
|
|
UpdateData(FALSE);
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
void CDuanSlopeRoofDlg::GetLowRandL(XPoly2D &poly)
|
|
{
|
|
XLine xLine(m_ptFirst,m_ptSecond);
|
|
|
|
//add by xlc on 090108
|
|
xLine.SetElevation(0);
|
|
poly.SetElevation(0);
|
|
|
|
XPoint pt;
|
|
double dLowLeft = 0.0,dLowRight = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
if (!xLine.OnWhichSide(pt))
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
else if (dLowLeft < dTemp)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
else if (dLowRight < dTemp)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
}
|
|
}
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < m_pXpoly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowRight = dLowRight - dTempLow;
|
|
{
|
|
//double dTemp = (m_dHeight - 200) / dLowRight;
|
|
double dTemp = m_dHeight / dLowRight;
|
|
|
|
dTemp = atan(dTemp);
|
|
m_dLpojiao =m_dRpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < m_pXpoly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowLeft = dLowLeft - dTempLow;
|
|
{
|
|
//double dTemp = (m_dHeight - 200) / dLowLeft;
|
|
double dTemp = m_dHeight/ dLowLeft;
|
|
|
|
dTemp = atan(dTemp);
|
|
m_dRpojiao = m_dLpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dTemp;
|
|
{
|
|
//dTemp = (m_dHeight - 200) / dLowLeft;
|
|
dTemp = m_dHeight / dLowLeft;
|
|
|
|
dTemp = atan(dTemp);
|
|
m_dLpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
{
|
|
//dTemp = (m_dHeight - 200) / dLowRight;
|
|
dTemp = m_dHeight / dLowRight;
|
|
|
|
dTemp = atan(dTemp);
|
|
m_dRpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
}
|
|
void CDuanSlopeRoofDlg::PreView()
|
|
{
|
|
AcDbBlockTable *pBlockTab=NULL;
|
|
VERIFY(dbPreview.getSymbolTable(pBlockTab, AcDb::kForWrite)==Acad::eOk);
|
|
AcDbBlockTableRecord *pMspace = new AcDbBlockTableRecord;
|
|
pMspace->setName(_T("*U"));
|
|
pBlockTab->add(pMspace);
|
|
pBlockTab->close();
|
|
|
|
double dLSlant;
|
|
double dRSlant;
|
|
if (m_bXiandinggaodu)
|
|
{
|
|
if (!m_bFlag)
|
|
GetLowRandL(m_pXpoly);
|
|
else
|
|
{
|
|
XPoly2D poly;
|
|
m_pRoof->GetPolyPath(poly);
|
|
GetLowRandL(poly);
|
|
}
|
|
}
|
|
|
|
dLSlant = m_dLpojiao;
|
|
dRSlant = m_dRpojiao;
|
|
CString str;
|
|
str.Format(_T("%.2f"),m_dLpojiao);
|
|
m_dLpojiao = _tstof(LPCTSTR(str));
|
|
str.Format(_T("%.2f"),m_dRpojiao);
|
|
m_dRpojiao = _tstof(LPCTSTR(str));
|
|
UpdateData(FALSE);
|
|
|
|
if (dLSlant > 89.999 || dRSlant > 89.9999)
|
|
{
|
|
AfxMessageBox(_T("\n坡度范围为0~90度!"));
|
|
}
|
|
double elev=m_dElevation;
|
|
if (elev < 1E-6)
|
|
{
|
|
if (fabs(elev - 0.0) <=1E-6);
|
|
else
|
|
{
|
|
AfxMessageBox(_T("\n标高不能小于0"));
|
|
}
|
|
}
|
|
if (!m_bFlag)
|
|
{
|
|
if (m_pXpoly.PathArea()>0)
|
|
{//确保逆时针
|
|
m_pXpoly.Reverse();
|
|
}
|
|
m_pXpoly.Compress();
|
|
m_pXpoly.SetElevation(0);
|
|
|
|
TDbDualSlopeRoof *pRoof = new TDbDualSlopeRoof;
|
|
pRoof->SetPolyPath(m_pXpoly);
|
|
pRoof->SetRidge(m_ptFirst,m_ptSecond);
|
|
pRoof->SetEqualAngle(Adesk::kFalse);
|
|
pRoof->SetAngle(dLSlant*PI/180,dRSlant*PI/180);
|
|
m_pRoof = pRoof;
|
|
}
|
|
else
|
|
{
|
|
if (m_pRoof->upgradeOpen()!=Acad::eOk)
|
|
return ;
|
|
m_pRoof->assertWriteEnabled();
|
|
m_pRoof->SetElevation(0);
|
|
m_pRoof->SetEqualAngle(Adesk::kFalse);
|
|
m_pRoof->SetAngle(dLSlant*PI/180,dRSlant*PI/180);
|
|
m_pRoof->downgradeOpen();
|
|
}
|
|
|
|
AcDbVoidPtrArray entSet;
|
|
XExplodeStream dc(entSet);
|
|
XPoint ptRidge2 = m_pRoof->GetRidgeEnd(),ptRidge1 = m_pRoof->GetRidgeStart();
|
|
XPoint vt = ptRidge2 - ptRidge1;
|
|
vt.Normalize();
|
|
vt.Scale(5E6);
|
|
XCurveSegment line(ptRidge1-vt,ptRidge2+vt,0);
|
|
line.SetElevation(0);
|
|
|
|
DList<XPoly2D> lstLeft,lstRight;
|
|
m_pRoof->Split(lstLeft,lstRight);
|
|
AcGeVector3d vtAxis=(ptRidge2-ptRidge1).AsAcGeVector3d();
|
|
{
|
|
AcGeVector3d vt(AcGeVector3d::kZAxis);
|
|
vt.rotateBy(-m_pRoof->GetAngleLeft(),vtAxis);
|
|
AcGePlane planeLeft(XPoint(ptRidge1.x,ptRidge1.y,m_pRoof->GetElevation()),vt);
|
|
double a,b,c,d;
|
|
planeLeft.getCoefficients(a,b,c,d);
|
|
for(long i=0;i<lstLeft.Length();i++)
|
|
{
|
|
XPoly2D* pPoly=lstLeft[i];
|
|
XPoly2D poly1=*pPoly;
|
|
for(long j=0;j<pPoly->Length();j++)
|
|
{
|
|
XPoint *pPt=(*pPoly)[j];
|
|
pPt->z=-1*(a*pPt->x+b*pPt->y+d)/c;
|
|
|
|
//modify by xlc on 090120 檐板厚可调
|
|
//poly1[j]->z=pPt->z-_AS_SYS_UNIT(200) ;// [11/14/2007 nsh]
|
|
poly1[j]->z=pPt->z-m_pRoof->GetSlabThick() ;
|
|
}
|
|
dc.SetColor(3);
|
|
dc.DrawShell(*pPoly,DList<XPoly2D>());
|
|
|
|
for(long k=0;k<poly1.TotalSegments();k++)
|
|
{
|
|
XCurveSegment e0,e1;
|
|
pPoly->Nth(k,e0);
|
|
poly1.Nth(k,e1);
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=e1.StartPoint();
|
|
face.GetVertex(1)=e1.EndPoint();
|
|
face.GetVertex(2)=e0.EndPoint();
|
|
face.GetVertex(3)=e0.StartPoint();
|
|
|
|
e0.SetElevation(0);
|
|
int nRet0=line.HitTest2d(e0.StartPoint());
|
|
int nRet1=line.HitTest2d(e0.EndPoint());
|
|
if (nRet0==1||nRet0==2||nRet1==1||nRet1==2||lstRight.Length()==0)
|
|
dc.DrawFace(face);
|
|
}
|
|
|
|
poly1.Reverse();
|
|
dc.DrawShell(poly1,DList<XPoly2D>());
|
|
}
|
|
}
|
|
{
|
|
AcGeVector3d vt(AcGeVector3d::kZAxis);
|
|
vt.rotateBy(m_pRoof->GetAngleRight(),vtAxis);
|
|
AcGePlane planeRight(XPoint(ptRidge1.x,ptRidge1.y,m_pRoof->GetElevation()),vt);
|
|
double a,b,c,d;
|
|
planeRight.getCoefficients(a,b,c,d);
|
|
for(long i=0;i<lstRight.Length();i++)
|
|
{
|
|
XPoly2D* pPoly=lstRight[i];
|
|
XPoly2D poly1=*pPoly;
|
|
for(long j=0;j<pPoly->Length();j++)
|
|
{
|
|
XPoint *pPt=(*pPoly)[j];
|
|
pPt->z=-1*(a*pPt->x+b*pPt->y+d)/c;
|
|
|
|
//modify by xlc on 090120 檐板厚可调
|
|
//poly1[j]->z=pPt->z-_AS_SYS_UNIT(200);
|
|
poly1[j]->z=pPt->z-m_pRoof->GetSlabThick();
|
|
}
|
|
dc.SetColor(6);
|
|
dc.DrawShell(*pPoly,DList<XPoly2D>());
|
|
|
|
for(long k=0;k<poly1.TotalSegments();k++)
|
|
{
|
|
XCurveSegment e0,e1;
|
|
pPoly->Nth(k,e0);
|
|
poly1.Nth(k,e1);
|
|
X3DFace face;
|
|
face.SetFlag(0);
|
|
face.GetVertex(0)=e1.StartPoint();
|
|
face.GetVertex(1)=e1.EndPoint();
|
|
face.GetVertex(2)=e0.EndPoint();
|
|
face.GetVertex(3)=e0.StartPoint();
|
|
|
|
e0.SetElevation(0);
|
|
int nRet0=line.HitTest2d(e0.StartPoint());
|
|
int nRet1=line.HitTest2d(e0.EndPoint());
|
|
if (nRet0==1||nRet0==2||nRet1==1||nRet1==2||lstLeft.Length()==0)
|
|
dc.DrawFace(face);
|
|
}
|
|
|
|
poly1.Reverse();
|
|
dc.DrawShell(poly1,DList<XPoly2D>());
|
|
}
|
|
}
|
|
for(long i=0;i<entSet.length();i++)
|
|
{
|
|
AcDbEntity *pEnt = (AcDbEntity*)entSet[i];
|
|
//modify by xlc on 090916 2010平台线型等属性信息导致预览无法显示
|
|
#if ADS<18
|
|
pMspace->appendAcDbEntity(pEnt);
|
|
pEnt->close();
|
|
#else
|
|
AcDbEntity *pClone=(AcDbEntity*)pEnt->clone();
|
|
delete pEnt;
|
|
pClone->setDatabaseDefaults(&dbPreview);
|
|
pMspace->appendAcDbEntity(pClone);
|
|
pClone->recordGraphicsModified();
|
|
pClone->close();
|
|
#endif
|
|
}
|
|
XPoint ptMax,ptMin;
|
|
XPoint ptCenter;
|
|
double x,y;
|
|
int nOldMode=DocGetDrawMode();
|
|
DocSetDrawMode(DRAW_3D);
|
|
m_pRoof->GetExtents(ptMin,ptMax);
|
|
DocSetDrawMode(nOldMode);
|
|
y = ptMax.z - ptMin.z;
|
|
ptCenter.x = (ptMax.x + ptMin.x) / 2;
|
|
ptCenter.y = (ptMax.y + ptMin.y) / 2;
|
|
ptCenter.z = (ptMax.z + ptMin.z) / 2;
|
|
|
|
XPoint pt0=m_pRoof->GetRidgeStart(),pt1=m_pRoof->GetRidgeEnd();
|
|
if (!m_bFlag)
|
|
m_pRoof->close();
|
|
XVector3D vtNormal=pt0-pt1;
|
|
|
|
//modified by whl on 070129,解决预览显示不全的问题
|
|
vtNormal.Scale(0.51);
|
|
XPoint ptView=ptCenter+vtNormal;
|
|
AcGeMatrix3d mat;
|
|
vtNormal.Reverse();
|
|
mat.setToWorldToPlane(vtNormal.AsAcGeVector3d());
|
|
vtNormal.TransformBy(mat);
|
|
ptMin.TransformBy(mat);
|
|
ptMax.TransformBy(mat);
|
|
x = fabs(ptMax.x - ptMin.x)*1.1;
|
|
|
|
//add by xlc on 070720
|
|
y = fabs(ptMax.z - ptMin.z);
|
|
|
|
y*=1.1;
|
|
{
|
|
AcGePoint3d ptPosition,ptTarget;
|
|
if (m_ctrlPreview.view() != NULL)
|
|
ptPosition = m_ctrlPreview.view()->position(), ptTarget = m_ctrlPreview.view()->target();
|
|
m_ctrlPreview.clearAll();
|
|
m_ctrlPreview.init(true);
|
|
|
|
//modify by xlc on 090806 R18移植
|
|
#if ADS<18
|
|
m_ctrlPreview.view()->setMode(AcGsView::kWireframe);
|
|
#else
|
|
m_ctrlPreview.view()->setVisualStyle(AcGiVisualStyle::k3DWireframe);
|
|
#endif
|
|
|
|
if (m_bbFlag==FALSE)
|
|
{
|
|
if (m_ptViewAuto.AsAcGePoint3d()!=ptPosition||m_ptTargeAuto.AsAcGePoint3d()!=ptTarget)
|
|
m_bbFlag=TRUE;
|
|
}
|
|
|
|
if (!m_bbFlag)
|
|
{
|
|
m_ctrlPreview.view()->setView(ptView.AsAcGePoint3d(),ptCenter.AsAcGePoint3d(),
|
|
AcGeVector3d(0.0, 0.0, 1.0),x,y);
|
|
m_ptViewAuto=ptView;
|
|
m_ptTargeAuto=pt0;
|
|
}
|
|
else
|
|
{
|
|
m_ctrlPreview.view()->setView(ptPosition,ptTarget,AcGeVector3d(0.0, 0.0, 1.0),x,y);
|
|
}
|
|
m_ctrlPreview.view()->add(pMspace,m_ctrlPreview.model());
|
|
m_ctrlPreview.Invalidate();
|
|
}
|
|
pMspace->close();
|
|
}
|
|
void CDuanSlopeRoofDlg::OnCheckXiandingjiaodu()
|
|
{
|
|
UpdateData();
|
|
if (m_bXiandinggaodu)
|
|
{
|
|
GetDlgItem(IDC_EDIT_HEIGHT)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_EDIT_LPOJIAO)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_EDIT_RPOJIAO)->EnableWindow(FALSE);
|
|
}
|
|
else
|
|
{
|
|
GetDlgItem(IDC_EDIT_HEIGHT)->EnableWindow(FALSE);
|
|
GetDlgItem(IDC_EDIT_LPOJIAO)->EnableWindow(TRUE);
|
|
GetDlgItem(IDC_EDIT_RPOJIAO)->EnableWindow(TRUE);
|
|
}
|
|
UpdateData(FALSE);
|
|
PreView();
|
|
}
|
|
|
|
void CDuanSlopeRoofDlg::OnChangeEditElevation()
|
|
{
|
|
UpdateData();
|
|
//PreView();
|
|
}
|
|
|
|
void CDuanSlopeRoofDlg::OnChangeEditLpojiao()
|
|
{
|
|
double d = m_dLpojiao;
|
|
UpdateData();
|
|
if (m_dLpojiao > 89.999)
|
|
{
|
|
AfxMessageBox(_T("\n坡度范围为0~90度!"));
|
|
m_dLpojiao = d;
|
|
UpdateData(FALSE);
|
|
}
|
|
PreView();
|
|
}
|
|
|
|
void CDuanSlopeRoofDlg::OnChangeEditRpojiao()
|
|
{
|
|
double d = m_dRpojiao;
|
|
UpdateData();
|
|
if (m_dRpojiao > 89.9999)
|
|
{
|
|
AfxMessageBox(_T("\n坡度范围为0~90度!"));
|
|
m_dRpojiao = d;
|
|
UpdateData(FALSE);
|
|
}
|
|
PreView();
|
|
}
|
|
|
|
void CDuanSlopeRoofDlg::OnChangeEditHeight()
|
|
{
|
|
UpdateData();
|
|
PreView();
|
|
}
|
|
|
|
HBRUSH CDuanSlopeRoofDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
|
|
// TODO: Change any attributes of the DC here
|
|
int nID=pWnd->GetDlgCtrlID();
|
|
if (nID==IDC_STATIC_L)
|
|
pDC->SetTextColor(acdbGetRGB(3));
|
|
else if (nID==IDC_STATIC_R)
|
|
pDC->SetTextColor(acdbGetRGB(6));
|
|
// TODO: Return a different brush if the default is not desired
|
|
return hbr;
|
|
}
|
|
|
|
void CDuanSlopeRoofDlg::OnBtCankaobiaogao()
|
|
{
|
|
if (!m_pRoof->isWriteEnabled())
|
|
if (m_pRoof->upgradeOpen()!=Acad::eOk)
|
|
return;
|
|
|
|
m_pRoof->SetElevation(m_dElevation);
|
|
m_pRoof->downgradeOpen();
|
|
ads_redraw(NULL,NULL);
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
Entity ent;
|
|
ShowWindow(SW_HIDE);
|
|
BeginEditorCommand();
|
|
int nRetCode = SelectEntity(_T("\n请选择墙:"), ent, rbMask);
|
|
CompleteEditorCommand();
|
|
if (nRetCode!=RTNORM)
|
|
return;
|
|
{
|
|
BOOL m_bFlag1 = FALSE,m_bFlag2 = FALSE;
|
|
XPoly3D poly;
|
|
XPoly3D poly1;
|
|
XDbObject obj(ent,AcDb::kForRead);
|
|
TDbWall *pWall = TDbWall::cast(obj.m_pObject);
|
|
if (!pWall)
|
|
return;
|
|
|
|
XCurveSegment lCurveSegment,rCurveSegment;
|
|
pWall->GetSideCurve(lCurveSegment,rCurveSegment,0.0,TRUE);
|
|
XLine xLine1(lCurveSegment.StartPoint(),lCurveSegment.EndPoint());
|
|
|
|
//modify by xlc on 070517
|
|
/*double dTemp;
|
|
if (fabs(xLine1.StartPoint().y - xLine1.EndPoint().y) > 1E-6 && fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) > 1E-6)
|
|
{
|
|
dTemp = 1.0 / xLine1.Direction();
|
|
dTemp = -dTemp;
|
|
}
|
|
else if (fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) <= 1E-6)
|
|
dTemp = 0.0;
|
|
else
|
|
dTemp = PI / 2.0;
|
|
XLine xLine(xLine1.StartPoint(),dTemp);
|
|
AcGePlane wallPlane(xLine1.StartPoint(),xLine.Direction3d());
|
|
// XPlane LeftTempPlane,RightTempPLane;
|
|
TDbDualSlopeRoof *pDualSlopeRoof = m_pRoof;
|
|
if (!pDualSlopeRoof)
|
|
return;
|
|
AcGeVector3d vtAxis=(pDualSlopeRoof->GetRidgeEnd()-pDualSlopeRoof->GetRidgeStart()).AsAcGeVector3d();
|
|
AcGeVector3d vt1(AcGeVector3d::kZAxis);
|
|
vt1.rotateBy(-pDualSlopeRoof->GetAngleLeft(),vtAxis);
|
|
AcGePlane LeftPlane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() - 200),vt1);
|
|
AcGeVector3d vt2(AcGeVector3d::kZAxis);
|
|
vt2.rotateBy(pDualSlopeRoof->GetAngleRight(),vtAxis);
|
|
AcGePlane RightPLane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() - 200),vt2);
|
|
AcGeLine3d xLineLeft,xLineRight;
|
|
if (!wallPlane.intersectWith(LeftPlane,xLineLeft))
|
|
return;
|
|
if (!wallPlane.intersectWith(RightPLane,xLineRight))
|
|
return;
|
|
AcGePoint3d pt;
|
|
Adesk::Boolean bHasThirdPt1=xLineLeft.intersectWith(xLineRight,pt);
|
|
AcGePoint3d point = pt;
|
|
XLine xLineTemp;
|
|
xLineTemp.StartPoint() = pt = xLine1.StartPoint();
|
|
pt.z += 1000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGePoint3d ptTemp1,ptTemp2;
|
|
AcGeLine3d acgeLine(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine,ptTemp1))
|
|
return;
|
|
if (!RightPLane.intersectWith(acgeLine,ptTemp2))
|
|
return;
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly.AppendNode(ptTemp1);
|
|
else
|
|
poly.AppendNode(ptTemp2);
|
|
if (bHasThirdPt1)
|
|
poly.AppendNode(point);
|
|
else
|
|
m_bFlag1 = TRUE;
|
|
pt = xLineTemp.StartPoint() = xLine1.EndPoint();
|
|
pt.z += 1000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGeLine3d acgeLine1(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
LeftPlane.intersectWith(acgeLine1,ptTemp1);
|
|
RightPLane.intersectWith(acgeLine1,ptTemp2);
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly.AppendNode(ptTemp1);
|
|
else
|
|
poly.AppendNode(ptTemp2);
|
|
{
|
|
int n = poly.Length();
|
|
poly.Compress();
|
|
if (poly.Length() != n)
|
|
{
|
|
m_bFlag1 = TRUE;
|
|
bHasThirdPt1 = FALSE;
|
|
}
|
|
}
|
|
if (bHasThirdPt1)
|
|
{
|
|
AcGeVector3d v1 = poly[1]->AsAcGePoint3d() - poly[0]->AsAcGePoint3d(),v2 = poly[1]->AsAcGePoint3d() - poly[2]->AsAcGePoint3d();
|
|
AcGeVector3d vt = poly[2]->AsAcGePoint3d() - poly[0]->AsAcGePoint3d();
|
|
double d1 = v1.angleTo(vt);
|
|
vt = poly[0]->AsAcGePoint3d() - poly[2]->AsAcGePoint3d();
|
|
double d2 =v2.angleTo(vt);
|
|
if (d1 > PI/2.0 || d2 > PI/2.0 || fabs(d1 - PI/2.0)<= 1E-2 || fabs(d2 - PI/2.0)<= 1E-2)
|
|
{
|
|
poly.Remove(1);
|
|
m_bFlag1 = TRUE;
|
|
}
|
|
}
|
|
xLine1.SetPoints(rCurveSegment.StartPoint(),rCurveSegment.EndPoint());
|
|
if (fabs(xLine1.StartPoint().y - xLine1.EndPoint().y) > 1E-6 && fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) > 1E-6)
|
|
{
|
|
dTemp = 1.0 / xLine1.Direction();
|
|
dTemp = -dTemp;
|
|
}
|
|
else if (fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) <= 1E-6)
|
|
dTemp = 0.0;
|
|
else
|
|
dTemp = PI / 2.0;
|
|
XLine xLine0(xLine1.StartPoint(),dTemp);
|
|
AcGePlane wallPlane0(xLine1.StartPoint(),xLine0.Direction3d());
|
|
if (!wallPlane0.intersectWith(LeftPlane,xLineLeft))
|
|
return;
|
|
if (!wallPlane0.intersectWith(RightPLane,xLineRight))
|
|
return;
|
|
Adesk::Boolean bHasThirdPt2=xLineLeft.intersectWith(xLineRight,pt);
|
|
point = pt;
|
|
xLineTemp.StartPoint() = pt = xLine1.StartPoint();
|
|
pt.z += 1000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGeLine3d acgeLine2(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine2,ptTemp1))
|
|
return;
|
|
if (!RightPLane.intersectWith(acgeLine2,ptTemp2))
|
|
return;
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly1.AppendNode(ptTemp1);
|
|
else
|
|
poly1.AppendNode(ptTemp2);
|
|
if (bHasThirdPt2)
|
|
poly1.AppendNode(point);
|
|
else
|
|
m_bFlag2 = TRUE;
|
|
pt = xLineTemp.StartPoint() = xLine1.EndPoint();
|
|
pt.z += 1000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGeLine3d acgeLine3(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine3,ptTemp1))
|
|
return;
|
|
if (!RightPLane.intersectWith(acgeLine3,ptTemp2))
|
|
return;
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly1.AppendNode(ptTemp1);
|
|
else
|
|
poly1.AppendNode(ptTemp2);
|
|
{
|
|
int n = poly1.Length();
|
|
poly1.Compress();
|
|
if (poly1.Length() != n)
|
|
{
|
|
m_bFlag2 = TRUE;
|
|
bHasThirdPt2 = FALSE;
|
|
}
|
|
}
|
|
if (bHasThirdPt2)
|
|
{
|
|
AcGeVector3d v1 = poly1[1]->AsAcGePoint3d() - poly1[0]->AsAcGePoint3d(),v2 = poly1[1]->AsAcGePoint3d() - poly1[2]->AsAcGePoint3d();
|
|
AcGeVector3d vt = poly1[2]->AsAcGePoint3d()- poly1[0]->AsAcGePoint3d();
|
|
double d1 = v1.angleTo(vt);
|
|
vt = poly1[0]->AsAcGePoint3d() - poly1[2]->AsAcGePoint3d();
|
|
double d2 =v2.angleTo(vt);
|
|
if (d1 > PI/2.0 || d2 > PI/2.0 || fabs(d1 - PI/2.0)<= 1E-2 || fabs(d2 - PI/2.0)<= 1E-2)
|
|
{
|
|
poly1.Remove(1);
|
|
m_bFlag2 = TRUE;
|
|
}
|
|
}*/
|
|
TDbDualSlopeRoof *pDualSlopeRoof = m_pRoof;
|
|
if (!pDualSlopeRoof)
|
|
return;
|
|
if (!GetIntersect(xLine1,pDualSlopeRoof,m_bFlag1,poly))
|
|
{
|
|
return;
|
|
}
|
|
|
|
xLine1.SetPoints(rCurveSegment.StartPoint(),rCurveSegment.EndPoint());//右边线
|
|
if (!GetIntersect(xLine1,pDualSlopeRoof,m_bFlag2,poly1))
|
|
{
|
|
return;
|
|
}
|
|
|
|
|
|
XPoly3D poly3d;
|
|
if (poly[0]->z < poly1[0]->z)
|
|
poly3d.AppendNode(*poly[0]);
|
|
else
|
|
poly3d.AppendNode(*poly1[0]);
|
|
if (!m_bFlag1 && !m_bFlag2)
|
|
{
|
|
if (poly[1]->z < poly1[1]->z)
|
|
poly3d.AppendNode(*poly[1]);
|
|
else
|
|
poly3d.AppendNode(*poly1[1]);
|
|
if (poly[2]->z < poly1[2]->z)
|
|
poly3d.AppendNode(*poly[2]);
|
|
else
|
|
poly3d.AppendNode(*poly1[2]);
|
|
}
|
|
else if (!m_bFlag1 && m_bFlag2)
|
|
{
|
|
poly3d.AppendNode(*poly[1]);
|
|
poly3d.AppendNode(*poly[2]);
|
|
}
|
|
else if (m_bFlag1 && !m_bFlag2)
|
|
{
|
|
poly3d.AppendNode(*poly1[1]);
|
|
poly3d.AppendNode(*poly1[2]);
|
|
}
|
|
else
|
|
{
|
|
if (poly[1]->z < poly1[1]->z)
|
|
poly3d.AppendNode(*poly[1]);
|
|
else
|
|
poly3d.AppendNode(*poly1[1]);
|
|
}
|
|
double dForNextUse = poly3d[0]->z;
|
|
if (poly3d[1]->z < dForNextUse)
|
|
dForNextUse = poly3d[1]->z;
|
|
if (!m_bFlag1 || !m_bFlag2)
|
|
{
|
|
if (poly3d[2]->z < dForNextUse)
|
|
dForNextUse = poly3d[2]->z;
|
|
}
|
|
|
|
//modify by xlc on 090108
|
|
//add by xlc on 070720
|
|
//修改限定标高精度
|
|
// if (m_bXiandinggaodu)
|
|
// {
|
|
// m_dElevation = m_dHeight + (pWall->GetHeight() + pWall->GetElevation()) + _AS_SYS_UNIT(200);// [11/13/2007 nsh]
|
|
// }
|
|
// else
|
|
|
|
{
|
|
double d = dForNextUse - (pWall->GetHeight() + pWall->GetElevation());
|
|
m_dElevation = m_dElevation - d;
|
|
}
|
|
CString str;
|
|
str.Format(_T("%.2f"),m_dElevation);
|
|
m_dElevation = _tstof(LPCTSTR(str));
|
|
}
|
|
UpdateData(FALSE);
|
|
if (m_pRoof->upgradeOpen()==Acad::eOk)
|
|
{
|
|
m_pRoof->SetElevation(0.0);
|
|
m_pRoof->downgradeOpen();
|
|
}
|
|
PreView();
|
|
ShowWindow(SW_SHOW);
|
|
}
|
|
//双坡屋顶
|
|
void DualSlopeRoof()
|
|
{
|
|
Entity ent;
|
|
RBList rbMask(RTDXF0, _T("POLYLINE,LWPOLYLINE"), 70, 1, NULL);
|
|
if (SelectEntity(_T("\n请选择一封闭的多段线<退出>:"), ent, rbMask)==RTNORM)
|
|
{
|
|
XPoly2D poly(ent);
|
|
if (!!poly)
|
|
{
|
|
XPoint ptFirst,ptSecond;
|
|
if (acedGetPoint(NULL,_T("\n请输入屋脊线的起点<退出>:"),ptFirst)!=RTNORM||
|
|
acedGetPoint(ptFirst,_T("\n请输入屋脊线的终点<退出>:"),ptSecond)!=RTNORM)
|
|
return;
|
|
|
|
//add by whl on 070608
|
|
ptFirst=Ucs2Wcs(ptFirst);
|
|
ptSecond=Ucs2Wcs(ptSecond);
|
|
|
|
CAcModuleResourceOverride vTemp;
|
|
CDuanSlopeRoofDlg dlg;
|
|
dlg.m_pXpoly = poly;
|
|
dlg.m_ptFirst = ptFirst;
|
|
dlg.m_ptSecond = ptSecond;
|
|
while(dlg.DoModal() == IDOK)
|
|
{
|
|
double dLSlant;
|
|
double dRSlant;
|
|
if (dlg.m_bXiandinggaodu)
|
|
{
|
|
XLine xLine(ptFirst,ptSecond);
|
|
|
|
//modify by xlc on 090108
|
|
xLine.SetElevation(0);
|
|
poly.SetElevation(0);
|
|
|
|
XPoint pt;
|
|
double dLowLeft = 0.0,dLowRight = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
if (!xLine.OnWhichSide(pt))
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
else if (dLowLeft < dTemp)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
else if (dLowRight < dTemp)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
}
|
|
}
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowRight = dLowRight - dTempLow;
|
|
{
|
|
//double dTemp = (dlg.m_dHeight- 200) / dLowRight;
|
|
double dTemp = dlg.m_dHeight / dLowRight;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dLpojiao =dlg.m_dRpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowLeft = dLowLeft - dTempLow;
|
|
{
|
|
//double dTemp = (dlg.m_dHeight - 200) / dLowLeft;
|
|
double dTemp = dlg.m_dHeight/ dLowLeft;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dRpojiao = dlg.m_dLpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dTemp;
|
|
{
|
|
//dTemp = (dlg.m_dHeight - 200) / dLowLeft;
|
|
dTemp = dlg.m_dHeight / dLowLeft;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dLpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
{
|
|
//dTemp = (dlg.m_dHeight - 200) / dLowRight;
|
|
dTemp = dlg.m_dHeight / dLowRight;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dRpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
}
|
|
dLSlant = dlg.m_dLpojiao;
|
|
dRSlant = dlg.m_dRpojiao;
|
|
if (dLSlant > 89.999 || dRSlant > 89.9999)
|
|
{
|
|
adsout << _T("\n坡度范围为0~90度!");
|
|
continue;
|
|
}
|
|
double elev=dlg.m_dElevation;
|
|
if (elev < 1E-6)
|
|
{
|
|
if (fabs(elev - 0.0) <=1E-6);
|
|
else
|
|
{
|
|
adsout << _T("\n标高不能小于0");
|
|
continue;
|
|
}
|
|
}
|
|
ent.Erase();
|
|
if (poly.PathArea()>0)
|
|
{//确保逆时针
|
|
poly.Reverse();
|
|
}
|
|
poly.Compress();
|
|
poly.SetElevation(elev);
|
|
TDbDualSlopeRoof *pRoof = new TDbDualSlopeRoof;
|
|
pRoof->SetPolyPath(poly);
|
|
pRoof->SetRidge(ptFirst,ptSecond);
|
|
pRoof->SetEqualAngle(Adesk::kFalse);
|
|
pRoof->SetAngle(dLSlant*PI/180,dRSlant*PI/180);
|
|
pRoof->SetHeightLim(dlg.m_bXiandinggaodu);
|
|
if (dlg.m_bXiandinggaodu)
|
|
{
|
|
pRoof->SetRoofHeight(dlg.m_dHeight);
|
|
}
|
|
pRoof->AddToMSpace(Adesk::kTrue);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
// [2/19/2008 nsh]
|
|
//-------------begin--------------------
|
|
void DualSlopeRoof2()
|
|
{
|
|
Entity ent;
|
|
RBList rbMask(RTDXF0, _T("POLYLINE,LWPOLYLINE"), 70, 1, NULL);
|
|
if (SelectEntity(_T("\n请选择一封闭的多段线<退出>:"), ent, rbMask)==RTNORM)
|
|
{
|
|
XPoly2D poly(ent);
|
|
if (!!poly)
|
|
{
|
|
XPoint ptFirst,ptSecond;
|
|
if (acedGetPoint(NULL,_T("\n请输入屋脊线的起点<退出>:"),ptFirst)!=RTNORM||
|
|
acedGetPoint(ptFirst,_T("\n请输入屋脊线的终点<退出>:"),ptSecond)!=RTNORM)
|
|
return;
|
|
|
|
//add by whl on 070608
|
|
ptFirst=Ucs2Wcs(ptFirst);
|
|
ptSecond=Ucs2Wcs(ptSecond);
|
|
|
|
CAcModuleResourceOverride vTemp;
|
|
// [2/20/2008 nsh]
|
|
//添加Dlg的创建
|
|
CDuanSlopeRoofDlg dlg(TRUE,NULL);
|
|
dlg.m_pXpoly = poly;
|
|
dlg.m_ptFirst = ptFirst;
|
|
dlg.m_ptSecond = ptSecond;
|
|
while(dlg.DoModal() == IDOK)
|
|
{
|
|
double dLSlant;
|
|
double dRSlant;
|
|
if (dlg.m_bXiandinggaodu)
|
|
{
|
|
XLine xLine(ptFirst,ptSecond);
|
|
|
|
// ywb 090916
|
|
xLine.SetElevation(0);
|
|
poly.SetElevation(0);
|
|
XPoint pt;
|
|
double dLowLeft = 0.0,dLowRight = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
if (!xLine.OnWhichSide(pt))
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
else if (dLowLeft < dTemp)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
else if (dLowRight < dTemp)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
}
|
|
}
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowRight = dLowRight - dTempLow;
|
|
{
|
|
//double dTemp = (dlg.m_dHeight- 200) / dLowRight;
|
|
double dTemp = dlg.m_dHeight / dLowRight;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dLpojiao =dlg.m_dRpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowLeft = dLowLeft - dTempLow;
|
|
{
|
|
//double dTemp = (dlg.m_dHeight - 200) / dLowLeft;
|
|
double dTemp = dlg.m_dHeight/ dLowLeft;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dRpojiao = dlg.m_dLpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
double dTemp;
|
|
{
|
|
//dTemp = (dlg.m_dHeight - 200) / dLowLeft;
|
|
dTemp = dlg.m_dHeight / dLowLeft;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dLpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
{
|
|
//dTemp = (dlg.m_dHeight - 200) / dLowRight;
|
|
dTemp = dlg.m_dHeight / dLowRight;
|
|
|
|
dTemp = atan(dTemp);
|
|
dlg.m_dRpojiao = (dTemp * 180.0) / PI;
|
|
}
|
|
}
|
|
}
|
|
dLSlant = dlg.m_dLpojiao;
|
|
dRSlant = dlg.m_dRpojiao;
|
|
if (dLSlant > 89.999 || dRSlant > 89.9999)
|
|
{
|
|
adsout << _T("\n坡度范围为0~90度!");
|
|
continue;
|
|
}
|
|
double elev=dlg.m_dElevation;
|
|
if (elev < 1E-6)
|
|
{
|
|
if (fabs(elev - 0.0) <=1E-6);
|
|
else
|
|
{
|
|
adsout << _T("\n标高不能小于0");
|
|
continue;
|
|
}
|
|
}
|
|
ent.Erase();
|
|
if (poly.PathArea()>0)
|
|
{//确保逆时针
|
|
poly.Reverse();
|
|
}
|
|
poly.Compress();
|
|
poly.SetElevation(elev);
|
|
TDbDualSlopeRoof *pRoof = new TDbDualSlopeRoof;
|
|
pRoof->SetPolyPath(poly);
|
|
pRoof->SetRidge(ptFirst,ptSecond);
|
|
pRoof->SetEqualAngle(Adesk::kFalse);
|
|
pRoof->SetAngle(dLSlant*PI/180,dRSlant*PI/180);
|
|
|
|
// ywb 090916
|
|
pRoof->SetHeightLim(dlg.m_bXiandinggaodu);
|
|
if (dlg.m_bXiandinggaodu)
|
|
{
|
|
pRoof->SetRoofHeight(dlg.m_dHeight);
|
|
}
|
|
|
|
pRoof->AddToMSpace(Adesk::kTrue);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//--------------end---------------------
|
|
int EditDualSlopeRoof(AcDbObjectId id_DualSlopeRoof)
|
|
{
|
|
XDbObject obj(id_DualSlopeRoof,AcDb::kForRead);
|
|
TDbDualSlopeRoof *pRoof;
|
|
if (!!obj)
|
|
pRoof = TDbDualSlopeRoof::cast(obj.m_pObject);
|
|
if (!pRoof)
|
|
return RTERROR;
|
|
CAcModuleResourceOverride vTemp;
|
|
CWnd *pWnd = acedGetAcadFrame();
|
|
double dLtemp=pRoof->GetAngleLeft(),dRtemp=pRoof->GetAngleRight();
|
|
double dElevation=pRoof->GetElevation();
|
|
|
|
//add by xlc on 081223
|
|
BOOL bHeightLim=pRoof->IsHeightLim();
|
|
double dRoofHeight=pRoof->GetRoofHeight();
|
|
|
|
CDuanSlopeRoofDlg dlg(pRoof,pWnd);
|
|
|
|
//add by xlc on 081223
|
|
dlg.m_bXiandinggaodu=bHeightLim;
|
|
if (bHeightLim)
|
|
{
|
|
XPoint ptFirst,ptSecond;
|
|
ptFirst=pRoof->GetRidgeStart();
|
|
ptSecond=pRoof->GetRidgeEnd();
|
|
|
|
XPoly2D poly;
|
|
pRoof->GetPolyPath(poly);
|
|
poly.SetElevation(0);
|
|
|
|
XLine xLine(ptFirst,ptSecond);
|
|
xLine.SetElevation(0);
|
|
|
|
XPoint pt;
|
|
double dLowLeft = 0.0,dLowRight = 0.0;
|
|
double dHeight=0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
if (!xLine.OnWhichSide(pt))
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
else if (dLowLeft < dTemp)
|
|
{
|
|
dLowLeft = dTemp;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
else if (dLowRight < dTemp)
|
|
{
|
|
dLowRight = dTemp;
|
|
}
|
|
}
|
|
}
|
|
if (fabs(dLowLeft-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowRight = dLowRight - dTempLow;
|
|
dHeight=dLowRight*tan(dLtemp);
|
|
}
|
|
else if (fabs(dLowRight-0.0) <= 1E-6)
|
|
{
|
|
double dTempLow = 0.0;
|
|
for (long i = 0;i < poly.Length();i++)
|
|
{
|
|
pt = *poly[i];
|
|
double dTemp;
|
|
dTemp = pt.Distance(&xLine);
|
|
if (fabs(dTempLow-0.0) <= 1E-6)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
else if (dTempLow > dTemp)
|
|
{
|
|
dTempLow = dTemp;
|
|
}
|
|
}
|
|
dLowLeft = dLowLeft - dTempLow;
|
|
dHeight=dLowLeft*tan(dLtemp);
|
|
}
|
|
else
|
|
{
|
|
dHeight=dLowLeft*tan(dLtemp);
|
|
}
|
|
CString str;
|
|
str.Format(_T("%.2f"),dHeight);
|
|
// dlg.m_dHeight = _tstof(LPCTSTR(str));
|
|
dlg.m_dHeight = dRoofHeight;
|
|
}
|
|
|
|
if (dlg.DoModal() ==IDCANCEL)
|
|
{
|
|
if (pRoof->upgradeOpen()!=Acad::eOk)
|
|
return RTERROR;
|
|
pRoof->assertWriteEnabled();
|
|
pRoof->SetElevation(dElevation);
|
|
pRoof->SetAngle(dLtemp,dRtemp);
|
|
|
|
//add by xlc on 081223
|
|
pRoof->SetHeightLim(bHeightLim);
|
|
pRoof->SetRoofHeight(dRoofHeight);
|
|
|
|
pRoof->downgradeOpen();
|
|
ads_redraw(NULL,NULL);
|
|
}
|
|
else
|
|
{
|
|
if (pRoof->upgradeOpen()!=Acad::eOk)
|
|
return RTERROR;
|
|
pRoof->assertWriteEnabled();
|
|
pRoof->SetElevation(dlg.m_dElevation);
|
|
|
|
//add by xlc on 081223
|
|
pRoof->SetHeightLim(dlg.m_bXiandinggaodu);
|
|
if (dlg.m_bXiandinggaodu)
|
|
pRoof->SetRoofHeight(dlg.m_dHeight);
|
|
|
|
ads_redraw(NULL,NULL);
|
|
}
|
|
return RTNORM;
|
|
}
|
|
|
|
|
|
//add by cwk on 061210
|
|
//modify by xlc on 070517
|
|
/*void WallAlignRoof()
|
|
{
|
|
RBList rbMask1(RTDXF0, _T("TCH_DUALROOF"), NULL);
|
|
Entity ent;
|
|
int nRetCode=SelectEntity(_T("\n请选择人字屋顶:"), ent, rbMask1);
|
|
if (nRetCode!=RTNORM)
|
|
return;
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
PickSet ssWalls(SS_FREE);
|
|
nRetCode=SelectEntities(_T("\n请选择墙:"), ssWalls, rbMask);
|
|
if (nRetCode!=RTNORM)
|
|
return;
|
|
long n = 0;
|
|
do
|
|
{
|
|
BOOL m_bFlag1 = FALSE,m_bFlag2 = FALSE;
|
|
XPoly3D poly;
|
|
XPoly3D poly1;
|
|
XDbObject obj(ssWalls[n],AcDb::kForWrite);
|
|
TDbWall *pWall = TDbWall::cast(obj.m_pObject);
|
|
if (!pWall)
|
|
return;
|
|
XCurveSegment lCurveSegment,rCurveSegment;
|
|
|
|
pWall->GetSideCurve(lCurveSegment,rCurveSegment,0.0,TRUE);
|
|
XLine xLine1(lCurveSegment.StartPoint(),lCurveSegment.EndPoint());
|
|
double dTemp;
|
|
if (fabs(xLine1.StartPoint().y - xLine1.EndPoint().y) > 1E-6 && fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) > 1E-6)
|
|
{
|
|
dTemp = 1.0 / xLine1.Direction();
|
|
dTemp = -dTemp;
|
|
}
|
|
else if (fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) <= 1E-6)
|
|
dTemp = 0.0;
|
|
else
|
|
dTemp = PI / 2.0;
|
|
|
|
XLine xLine(xLine1.StartPoint(),dTemp);
|
|
AcGePlane wallPlane(xLine1.StartPoint(),xLine.Direction3d().AsAcGeVector3d());
|
|
XPlane LeftTempPlane,RightTempPLane;
|
|
XDbObject obj1(ent,AcDb::kForRead);
|
|
TDbDualSlopeRoof *pDualSlopeRoof = TDbDualSlopeRoof::cast(obj1.m_pObject);
|
|
if (!pDualSlopeRoof)
|
|
return;
|
|
|
|
|
|
AcGeVector3d vtAxis=(pDualSlopeRoof->GetRidgeEnd()-pDualSlopeRoof->GetRidgeStart()).AsAcGeVector3d();
|
|
AcGeVector3d vt1(AcGeVector3d::kZAxis);
|
|
vt1.rotateBy(-pDualSlopeRoof->GetAngleLeft(),vtAxis);
|
|
AcGePlane LeftPlane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() - 200),vt1);
|
|
AcGeVector3d vt2(AcGeVector3d::kZAxis);
|
|
vt2.rotateBy(pDualSlopeRoof->GetAngleRight(),vtAxis);
|
|
AcGePlane RightPLane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() - 200),vt2);
|
|
|
|
AcGeLine3d xLineLeft,xLineRight;
|
|
if (!wallPlane.intersectWith(LeftPlane,xLineLeft))
|
|
{ n++;continue;}
|
|
if (!wallPlane.intersectWith(RightPLane,xLineRight))
|
|
{ n++;continue;}
|
|
AcGePoint3d pt;
|
|
Adesk::Boolean bHasThirdPt1=xLineLeft.intersectWith(xLineRight,pt);
|
|
AcGePoint3d point = pt;
|
|
|
|
XLine xLineTemp;
|
|
xLineTemp.StartPoint() = pt = xLine1.StartPoint();
|
|
pt.z += 100000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGePoint3d ptTemp1,ptTemp2;
|
|
|
|
AcGeLine3d acgeLine(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine,ptTemp1))
|
|
{ n++;continue;}
|
|
if (!RightPLane.intersectWith(acgeLine,ptTemp2))
|
|
{ n++;continue;}
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly.AppendNode(ptTemp1);
|
|
else
|
|
poly.AppendNode(ptTemp2);
|
|
|
|
if (bHasThirdPt1)
|
|
poly.AppendNode(point);
|
|
else
|
|
m_bFlag1 = TRUE;
|
|
|
|
pt = xLineTemp.StartPoint() = xLine1.EndPoint();
|
|
pt.z += 100000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGeLine3d acgeLine1(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine1,ptTemp1))
|
|
{ n++;continue;}
|
|
if (!RightPLane.intersectWith(acgeLine1,ptTemp2))
|
|
{ n++;continue;}
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly.AppendNode(ptTemp1);
|
|
else
|
|
poly.AppendNode(ptTemp2);
|
|
{
|
|
int n = poly.Length();
|
|
poly.Compress(FALSE);
|
|
if (poly.Length() != n)
|
|
{
|
|
m_bFlag1 = TRUE;
|
|
bHasThirdPt1 = FALSE;
|
|
}
|
|
}
|
|
|
|
if (bHasThirdPt1)
|
|
{
|
|
AcGeVector3d v1 = poly[1]->AsAcGePoint3d() - poly[0]->AsAcGePoint3d(),v2 = poly[1]->AsAcGePoint3d() - poly[2]->AsAcGePoint3d();
|
|
AcGeVector3d vt = poly[2]->AsAcGePoint3d() - poly[0]->AsAcGePoint3d();
|
|
double d1 = v1.angleTo(vt);
|
|
vt = poly[0]->AsAcGePoint3d() - poly[2]->AsAcGePoint3d();
|
|
double d2 =v2.angleTo(vt);
|
|
if (d1 > PI/2.0 || d2 > PI/2.0 || fabs(d1 - PI/2.0)<= 1E-6 || fabs(d2 - PI/2.0)<= 1E-6)
|
|
{
|
|
poly.Remove(1);
|
|
m_bFlag1 = TRUE;
|
|
}
|
|
}
|
|
|
|
xLine1.SetPoints(rCurveSegment.StartPoint(),rCurveSegment.EndPoint());
|
|
if (fabs(xLine1.StartPoint().y - xLine1.EndPoint().y) > 1E-6 && fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) > 1E-6)
|
|
{
|
|
dTemp = 1.0 / xLine1.Direction();
|
|
dTemp = -dTemp;
|
|
}
|
|
else if (fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) <= 1E-6)
|
|
dTemp = 0.0;
|
|
else
|
|
dTemp = PI / 2.0;
|
|
|
|
XLine xLine0(xLine1.StartPoint(),dTemp);
|
|
AcGePlane wallPlane0(xLine1.StartPoint(),xLine0.Direction3d());
|
|
if (!wallPlane0.intersectWith(LeftPlane,xLineLeft))
|
|
{ n++;continue;}
|
|
if (!wallPlane0.intersectWith(RightPLane,xLineRight))
|
|
{ n++;continue;}
|
|
Adesk::Boolean bHasThirdPt2=xLineLeft.intersectWith(xLineRight,pt);
|
|
point = pt;
|
|
|
|
xLineTemp.StartPoint() = pt = xLine1.StartPoint();
|
|
pt.z += 100000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGeLine3d acgeLine2(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine2,ptTemp1))
|
|
{ n++;continue;}
|
|
if (!RightPLane.intersectWith(acgeLine2,ptTemp2))
|
|
{ n++;continue;}
|
|
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly1.AppendNode(ptTemp1);
|
|
else
|
|
poly1.AppendNode(ptTemp2);
|
|
|
|
if (bHasThirdPt2)
|
|
poly1.AppendNode(point);
|
|
else
|
|
m_bFlag2 = TRUE;
|
|
|
|
pt = xLineTemp.StartPoint() = xLine1.EndPoint();
|
|
pt.z += 100000;
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGeLine3d acgeLine3(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine3,ptTemp1))
|
|
{ n++;continue;}
|
|
if (!RightPLane.intersectWith(acgeLine3,ptTemp2))
|
|
{ n++;continue;}
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly1.AppendNode(ptTemp1);
|
|
else
|
|
poly1.AppendNode(ptTemp2);
|
|
{
|
|
int n = poly1.Length();
|
|
poly1.Compress(FALSE);
|
|
if (poly1.Length() != n)
|
|
{
|
|
m_bFlag2 = TRUE;
|
|
bHasThirdPt2 = FALSE;
|
|
}
|
|
}
|
|
|
|
if (bHasThirdPt2)
|
|
{
|
|
AcGeVector3d v1 = poly1[1]->AsAcGePoint3d() - poly1[0]->AsAcGePoint3d(),v2 = poly1[1]->AsAcGePoint3d() - poly1[2]->AsAcGePoint3d();
|
|
AcGeVector3d vt = poly1[2]->AsAcGePoint3d()- poly1[0]->AsAcGePoint3d();
|
|
double d1 = v1.angleTo(vt);
|
|
vt = poly1[0]->AsAcGePoint3d() - poly1[2]->AsAcGePoint3d();
|
|
double d2 =v2.angleTo(vt);
|
|
if (d1 > PI/2.0 || d2 > PI/2.0 || fabs(d1 - PI/2.0)<= 1E-6 || fabs(d2 - PI/2.0)<= 1E-6)
|
|
{
|
|
poly1.Remove(1);
|
|
m_bFlag2 = TRUE;
|
|
}
|
|
}
|
|
XPoly3D poly3d;
|
|
|
|
if (poly[0]->z < poly1[0]->z)
|
|
poly3d.AppendNode(*poly[0]);
|
|
else
|
|
poly3d.AppendNode(*poly1[0]);
|
|
if (!m_bFlag1 && !m_bFlag2)
|
|
{
|
|
if (poly[1]->z < poly1[1]->z)
|
|
poly3d.AppendNode(*poly[1]);
|
|
else
|
|
poly3d.AppendNode(*poly1[1]);
|
|
if (poly[2]->z < poly1[2]->z)
|
|
poly3d.AppendNode(*poly[2]);
|
|
else
|
|
poly3d.AppendNode(*poly1[2]);
|
|
}
|
|
else if (!m_bFlag1 && m_bFlag2)
|
|
{
|
|
poly3d.AppendNode(*poly[1]);
|
|
poly3d.AppendNode(*poly[2]);
|
|
}
|
|
else if (m_bFlag1 && !m_bFlag2)
|
|
{
|
|
poly3d.AppendNode(*poly1[1]);
|
|
poly3d.AppendNode(*poly1[2]);
|
|
}
|
|
else
|
|
{
|
|
if (poly[1]->z < poly1[1]->z)
|
|
poly3d.AppendNode(*poly[1]);
|
|
else
|
|
poly3d.AppendNode(*poly1[1]);
|
|
}
|
|
|
|
double d = poly3d[0]->z;
|
|
if (poly3d[1]->z > d)
|
|
d = poly3d[1]->z;
|
|
if (!m_bFlag1 || !m_bFlag2)
|
|
{
|
|
if (poly3d[2]->z > d)
|
|
d = poly3d[2]->z;
|
|
}
|
|
ads_matrix matTo2d;
|
|
pWall->GetPlanarMatrix(matTo2d);
|
|
poly3d.TransUCS(matTo2d);
|
|
pWall->assertWriteEnabled();
|
|
{
|
|
XPoly2D poly2d;
|
|
poly3d.AsPoly2D(poly2d);
|
|
pWall->SetPolyShape(poly2d);
|
|
}
|
|
if (d > fabs(pWall->GetHeight() - pWall->GetElevation()))
|
|
{
|
|
if (!m_bFlag1 || !m_bFlag2)
|
|
pWall->SetHeight(d - pWall->GetElevation());
|
|
else
|
|
pWall->SetHeight(d - pWall->GetElevation() + 200);
|
|
}
|
|
n++;
|
|
} while(n < ssWalls.Length());
|
|
}*/
|
|
//modify by xlc on 070712
|
|
/*
|
|
void WallAlignRoof()
|
|
{
|
|
RBList rbMask1(RTDXF0, _T("TCH_DUALROOF"), NULL);
|
|
Entity ent;
|
|
int nRetCode=SelectEntity(_T("\n请选择人字屋顶:"), ent, rbMask1);
|
|
if (nRetCode!=RTNORM)
|
|
return;
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL"), NULL);
|
|
PickSet ssWalls(SS_FREE);
|
|
nRetCode=SelectEntities(_T("\n请选择墙:"), ssWalls, rbMask);
|
|
if (nRetCode!=RTNORM)
|
|
return;
|
|
|
|
//modify by xlc on 070517
|
|
XDbObject obj1(ent,AcDb::kForRead);
|
|
TDbDualSlopeRoof *pDualSlopeRoof = TDbDualSlopeRoof::cast(obj1.m_pObject);
|
|
if (!pDualSlopeRoof)
|
|
return;
|
|
|
|
long n = 0;
|
|
do
|
|
{
|
|
BOOL m_bFlag1 = FALSE,m_bFlag2 = FALSE;
|
|
XPoly3D poly;
|
|
XPoly3D poly1;
|
|
XDbObject obj(ssWalls[n],AcDb::kForWrite);
|
|
TDbWall *pWall = TDbWall::cast(obj.m_pObject);
|
|
if (!pWall)
|
|
return;
|
|
|
|
XCurveSegment lCurveSegment,rCurveSegment;//墙左右边线
|
|
pWall->GetSideCurve(lCurveSegment,rCurveSegment,0.0,TRUE);
|
|
|
|
XLine xLine1(lCurveSegment.StartPoint(),lCurveSegment.EndPoint());//左边线
|
|
if (!GetIntersect(xLine1,pDualSlopeRoof,m_bFlag1,poly))
|
|
{
|
|
n++;
|
|
continue;
|
|
}
|
|
|
|
xLine1.SetPoints(rCurveSegment.StartPoint(),rCurveSegment.EndPoint());//右边线
|
|
if (!GetIntersect(xLine1,pDualSlopeRoof,m_bFlag2,poly1))
|
|
{
|
|
n++;
|
|
continue;
|
|
}
|
|
|
|
//add by xlc on 070608
|
|
//墙的两面截面不同
|
|
if (poly.Length() != poly1.Length())
|
|
{
|
|
if (poly.Length() == 3)
|
|
{
|
|
poly.RemoveNode(1);
|
|
m_bFlag1 = TRUE;
|
|
}
|
|
|
|
if (poly1.Length() == 3)
|
|
{
|
|
poly1.RemoveNode(1);
|
|
m_bFlag2 = TRUE;
|
|
}
|
|
}
|
|
|
|
XPoly3D poly3d;//墙立面
|
|
if (poly[0]->z < poly1[0]->z)
|
|
poly3d.AppendNode(*poly[0]);
|
|
else
|
|
poly3d.AppendNode(*poly1[0]);
|
|
if (!m_bFlag1 && !m_bFlag2)
|
|
{
|
|
if (poly[1]->z < poly1[1]->z)
|
|
poly3d.AppendNode(*poly[1]);
|
|
else
|
|
poly3d.AppendNode(*poly1[1]);
|
|
if (poly[2]->z < poly1[2]->z)
|
|
poly3d.AppendNode(*poly[2]);
|
|
else
|
|
poly3d.AppendNode(*poly1[2]);
|
|
}
|
|
else if (!m_bFlag1 && m_bFlag2)
|
|
{
|
|
poly3d.AppendNode(*poly[1]);
|
|
poly3d.AppendNode(*poly[2]);
|
|
}
|
|
else if (m_bFlag1 && !m_bFlag2)
|
|
{
|
|
poly3d.AppendNode(*poly1[1]);
|
|
poly3d.AppendNode(*poly1[2]);
|
|
}
|
|
else
|
|
{
|
|
if (poly[1]->z < poly1[1]->z)
|
|
poly3d.AppendNode(*poly[1]);
|
|
else
|
|
poly3d.AppendNode(*poly1[1]);
|
|
}
|
|
|
|
double d = poly3d[0]->z;
|
|
if (poly3d[1]->z > d)
|
|
d = poly3d[1]->z;
|
|
if (!m_bFlag1 || !m_bFlag2)
|
|
{
|
|
if (poly3d[2]->z > d)
|
|
d = poly3d[2]->z;
|
|
}
|
|
ads_matrix matTo2d;
|
|
pWall->GetPlanarMatrix(matTo2d);
|
|
poly3d.TransUCS(matTo2d);
|
|
pWall->assertWriteEnabled();
|
|
{
|
|
XPoly2D poly2d;
|
|
poly3d.AsPoly2D(poly2d);
|
|
pWall->SetPolyShape(poly2d);
|
|
}
|
|
if (d > fabs(pWall->GetHeight() - pWall->GetElevation()))
|
|
{
|
|
if (!m_bFlag1 || !m_bFlag2)
|
|
pWall->SetHeight(d - pWall->GetElevation());
|
|
else
|
|
pWall->SetHeight(d - pWall->GetElevation() + 1000);
|
|
}
|
|
n++;
|
|
} while(n < ssWalls.Length());
|
|
}
|
|
*/
|
|
|
|
//任意坡顶和柱子都适用
|
|
void WallAlignRoof()
|
|
{
|
|
RBList rbMask1(RTDXF0, _T("TCH_MOUNTROOF,TCH_SLOPEROOF,TCH_CUSPROOF,TCH_DUALROOF,POLYLINE,3DFACE"), NULL);
|
|
PickSet ssRoofs(SS_FREE);
|
|
int nRetCode=SelectEntities(_T("\n请选择屋顶:"), ssRoofs, rbMask1);
|
|
if (nRetCode!=RTNORM)
|
|
return;
|
|
RBList rbMask(RTDXF0, _T("TCH_WALL,TCH_COLUMN"), NULL);
|
|
PickSet ssWalls(SS_FREE);
|
|
nRetCode=SelectEntities(_T("\n请选择墙或柱子:"), ssWalls, rbMask);
|
|
if (nRetCode!=RTNORM)
|
|
return;
|
|
|
|
DList<X3DFace> lstFace;
|
|
long m = 0;
|
|
do
|
|
{
|
|
AcDbObjectId id; //任意屋顶id
|
|
if (acdbGetObjectId(id, ssRoofs[m]) != Acad::eOk)
|
|
{
|
|
m++;
|
|
continue;
|
|
}
|
|
|
|
GetRoofAllPoly(id, lstFace); //获得屋顶的下表面
|
|
m++;
|
|
}while(m < ssRoofs.Length());
|
|
|
|
if (lstFace.Length() < 1)
|
|
return;
|
|
|
|
acedSetStatusBarProgressMeter(_T("正在处理中,请稍候..."),1,ssWalls.Length());
|
|
long n = 0;
|
|
do
|
|
{
|
|
acedSetStatusBarProgressMeterPos(n+1);
|
|
|
|
XPoly3D poly;
|
|
XPoly3D poly1;
|
|
XDbObject obj(ssWalls[n],AcDb::kForWrite);
|
|
TDbWall *pWall = TDbWall::cast(obj.m_pObject);
|
|
|
|
TDbColumn *pColumn = NULL;
|
|
if (!pWall)
|
|
{
|
|
pColumn = TDbColumn::cast(obj.m_pObject);
|
|
if (!pColumn)
|
|
{
|
|
n++;
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
ColumnAlignSlopeRoof(pColumn,lstFace);
|
|
n++;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
//modify by xlc on 090602 取消弧墙的限制,按直墙算会产生问题!!
|
|
//if (pWall->GetCurveType() != CURVE_LINE)
|
|
//{
|
|
// n++;
|
|
// continue;
|
|
//}
|
|
|
|
XCurveSegment lCurveSegment,rCurveSegment;
|
|
pWall->GetSideCurve(lCurveSegment,rCurveSegment,0.0,TRUE);
|
|
|
|
XPoint ptStart = lCurveSegment.StartPoint();
|
|
XPoint ptEnd = lCurveSegment.EndPoint();
|
|
XLine line(ptStart,ptEnd);
|
|
if (!GetIntSectPoly(lstFace,line,poly)) //墙左边线
|
|
{
|
|
n++;
|
|
continue;
|
|
}
|
|
|
|
ptStart = rCurveSegment.StartPoint();
|
|
ptEnd = rCurveSegment.EndPoint();
|
|
XLine rLine(ptStart,ptEnd);
|
|
if (!GetIntSectPoly(lstFace,rLine,poly1)) //墙右边线
|
|
{
|
|
n++;
|
|
continue;
|
|
}
|
|
|
|
AcGeVector3d dir = rCurveSegment.EndPoint() - rCurveSegment.StartPoint();
|
|
double angle = AcGeVector3d::kXAxis.angleTo(dir,AcGeVector3d::kZAxis);
|
|
AcGeMatrix3d mat = AcGeMatrix3d::rotation(-angle,AcGeVector3d::kZAxis,AcGePoint3d(rCurveSegment.StartPoint()));
|
|
poly.TransformBy(mat);
|
|
poly1.TransformBy(mat);
|
|
|
|
//拟和边线
|
|
XPoly3D poly3d;
|
|
if (poly[0]->z < poly1[0]->z)
|
|
poly3d.AppendNode(*poly[0]);
|
|
else
|
|
poly3d.AppendNode(*poly1[0]);
|
|
|
|
for(int i=1,j=1;i<poly.Length()-1,j<poly1.Length()-1;)
|
|
{
|
|
if (i >= poly.Length()-1 && j >= poly1.Length()-1)
|
|
{
|
|
break;
|
|
}
|
|
else if (fabs(poly[i]->x- poly1[j]->x) < 1e-6)//
|
|
{
|
|
if (poly[i]->z < poly1[j]->z)
|
|
{
|
|
poly3d.AppendNode(*poly[i]);
|
|
}
|
|
else
|
|
{
|
|
poly3d.AppendNode(*poly1[j]);
|
|
}
|
|
i++;
|
|
j++;
|
|
}
|
|
else if (poly[i]->x- poly1[j]->x < 0)
|
|
{
|
|
if ( i >= poly.Length()-1)
|
|
{
|
|
j++;
|
|
continue;
|
|
}
|
|
AcGePoint3d p1(poly[i]->x,poly[i]->y,poly[i]->z);
|
|
AcGePlane plane(p1,AcGeVector3d::kXAxis);
|
|
AcGePoint3d p2(poly1[j-1]->x,poly1[j-1]->y,poly1[j-1]->z);
|
|
AcGePoint3d p3(poly1[j]->x,poly1[j]->y,poly1[j]->z);
|
|
AcGeLine3d tmpLine(p2,p3);
|
|
|
|
AcGePoint3d pt;
|
|
tmpLine.intersectWith(plane,pt);
|
|
if (pt.x < poly1[0]->x || pt.x > poly1[poly1.Length()-1]->x)
|
|
{
|
|
i++;
|
|
continue;
|
|
}
|
|
|
|
if (poly[i]->z < pt.z)
|
|
{
|
|
poly3d.AppendNode(*poly[i]);
|
|
}
|
|
else
|
|
{
|
|
poly3d.AppendNode(pt);
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
else if (poly[i]->x- poly1[j]->x > 0)
|
|
{
|
|
if ( j >= poly1.Length()-1)
|
|
{
|
|
i++;
|
|
continue;
|
|
}
|
|
AcGePoint3d p1(poly1[j]->x,poly1[j]->y,poly1[j]->z);
|
|
AcGePlane plane(p1,AcGeVector3d::kXAxis);
|
|
AcGePoint3d p2(poly[i-1]->x,poly[i-1]->y,poly[i-1]->z);
|
|
AcGePoint3d p3(poly[i]->x,poly[i]->y,poly[i]->z);
|
|
AcGeLine3d tmpLine(p2,p3);
|
|
|
|
AcGePoint3d pt;
|
|
tmpLine.intersectWith(plane,pt);
|
|
|
|
if (pt.x < poly[0]->x || pt.x > poly[poly.Length()-1]->x)
|
|
{
|
|
j++;
|
|
continue;
|
|
}
|
|
|
|
if (poly1[j]->z < pt.z)
|
|
{
|
|
poly3d.AppendNode(*poly1[j]);
|
|
}
|
|
else
|
|
{
|
|
poly3d.AppendNode(pt);
|
|
}
|
|
|
|
j++;
|
|
}
|
|
}
|
|
|
|
if (poly[poly.Length()-1]->z < poly1[poly1.Length()-1]->z)
|
|
poly3d.AppendNode(*poly[poly.Length()-1]);
|
|
else
|
|
poly3d.AppendNode(*poly1[poly1.Length()-1]);
|
|
|
|
AcGeMatrix3d mat1 = AcGeMatrix3d::rotation(angle,AcGeVector3d::kZAxis,AcGePoint3d(rCurveSegment.StartPoint()));
|
|
poly3d.TransformBy(mat1);
|
|
|
|
double d = poly3d[0]->z;
|
|
for(i = 1; i < poly3d.Length(); i++)
|
|
{
|
|
if (poly3d[i]->z > d)
|
|
d = poly3d[i]->z;
|
|
}
|
|
|
|
//modify by xlc on 070801
|
|
BOOL bFlag = TRUE; //墙与屋顶平行
|
|
// if (poly3d.Length() == 2)
|
|
// {
|
|
// if (fabs(poly3d[0]->z - poly3d[1]->z) < 1e-6)
|
|
// bFlag = TRUE;
|
|
// }
|
|
for(i = 1; i < poly3d.Length(); i++)
|
|
{
|
|
if (fabs(poly3d[0]->z - poly3d[i]->z) > 1e-6)
|
|
{
|
|
bFlag = FALSE;
|
|
break;
|
|
}
|
|
}
|
|
|
|
ads_matrix matTo2d;
|
|
pWall->GetPlanarMatrix(matTo2d);
|
|
poly3d.TransUCS(matTo2d);
|
|
|
|
pWall->assertWriteEnabled();
|
|
{
|
|
XPoly2D poly2d;
|
|
poly3d.AsPoly2D(poly2d);
|
|
pWall->SetPolyShape(poly2d);
|
|
}
|
|
if (d > fabs(pWall->GetHeight() - pWall->GetElevation()))
|
|
{
|
|
if (bFlag) //墙与屋顶面平行
|
|
pWall->SetHeight(d - pWall->GetElevation());
|
|
else
|
|
pWall->SetHeight(d - pWall->GetElevation() + _AS_SYS_UNIT(400));
|
|
}
|
|
|
|
n++;
|
|
} while(n < ssWalls.Length());
|
|
acedRestoreStatusBar();
|
|
}
|
|
|
|
|
|
//modify by xlc on 070517
|
|
BOOL GetIntersect(XLine &xLine1,const TDbDualSlopeRoof *pDualSlopeRoof,BOOL &m_bFlag1,XPoly3D &poly)
|
|
{
|
|
//modify by xlc on 070608
|
|
//减小计算误差
|
|
/* double dTemp;//墙立面的法向角度
|
|
if (fabs(xLine1.StartPoint().y - xLine1.EndPoint().y) > 1E-6 && fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) > 1E-6)
|
|
{
|
|
dTemp = 1.0 / xLine1.Direction();
|
|
dTemp = -dTemp;
|
|
}
|
|
else if (fabs(xLine1.StartPoint().x - xLine1.EndPoint().x) <= 1E-6)
|
|
dTemp = 0.0;
|
|
else
|
|
dTemp = PI / 2.0;
|
|
|
|
XLine xLine(xLine1.StartPoint(),dTemp);
|
|
AcGePlane wallPlane(xLine1.StartPoint(),xLine.Direction3d().AsAcGeVector3d());*/
|
|
AcGePlane wallPlane(xLine1.StartPoint(),xLine1.EndPoint(),AcGePoint3d(xLine1.StartPoint().x,xLine1.StartPoint().y,xLine1.StartPoint().z + _AS_SYS_UNIT(100.0)));
|
|
|
|
//构造屋顶平面
|
|
AcGeVector3d vtAxis=(pDualSlopeRoof->GetRidgeEnd()-pDualSlopeRoof->GetRidgeStart()).AsAcGeVector3d();
|
|
AcGeVector3d vt1(AcGeVector3d::kZAxis);
|
|
double left=-pDualSlopeRoof->GetAngleLeft();
|
|
vt1.rotateBy(left,vtAxis);
|
|
|
|
//modify by xlc on 090120 檐板厚可调
|
|
//AcGePlane LeftPlane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() - _AS_SYS_UNIT(200)),vt1);
|
|
AcGePlane LeftPlane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() - pDualSlopeRoof->GetSlabThick()),vt1);
|
|
|
|
AcGeVector3d vt2(AcGeVector3d::kZAxis);
|
|
double right=pDualSlopeRoof->GetAngleRight();
|
|
vt2.rotateBy(right,vtAxis);
|
|
|
|
//modify by xlc on 090120 檐板厚可调
|
|
//AcGePlane RightPLane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() -_AS_SYS_UNIT(200)),vt2);
|
|
AcGePlane RightPLane(XPoint(pDualSlopeRoof->GetRidgeStart().x,pDualSlopeRoof->GetRidgeStart().y,pDualSlopeRoof->GetElevation() -pDualSlopeRoof->GetSlabThick()),vt2);
|
|
|
|
//墙与屋顶的交线
|
|
AcGeLine3d xLineLeft,xLineRight;
|
|
if (!wallPlane.intersectWith(LeftPlane,xLineLeft))
|
|
{
|
|
return FALSE;
|
|
}
|
|
if (!wallPlane.intersectWith(RightPLane,xLineRight))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
AcGePoint3d pt;//墙与屋顶交线的交点
|
|
Adesk::Boolean bHasThirdPt1=xLineLeft.intersectWith(xLineRight,pt);
|
|
|
|
AcGePoint3d point = pt;//中间点
|
|
XLine xLineTemp;
|
|
xLineTemp.StartPoint() = pt = xLine1.StartPoint();
|
|
pt.z +=_AS_SYS_UNIT(100000);// [11/15/2007 nsh]
|
|
xLineTemp.EndPoint() = pt;
|
|
|
|
AcGePoint3d ptTemp1,ptTemp2;//墙点与屋顶左右平面的的交点
|
|
AcGeLine3d acgeLine(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine,ptTemp1))
|
|
{
|
|
return FALSE;
|
|
}
|
|
if (!RightPLane.intersectWith(acgeLine,ptTemp2))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly.AppendNode(ptTemp1);
|
|
else
|
|
poly.AppendNode(ptTemp2);
|
|
|
|
if (bHasThirdPt1)
|
|
poly.AppendNode(point);
|
|
else
|
|
m_bFlag1 = TRUE;
|
|
|
|
pt = xLineTemp.StartPoint() = xLine1.EndPoint();
|
|
pt.z += _AS_SYS_UNIT(10000);// [11/15/2007 nsh]
|
|
xLineTemp.EndPoint() = pt;
|
|
AcGeLine3d acgeLine1(AcGePoint3d(xLineTemp.StartPoint().x,xLineTemp.StartPoint().y,xLineTemp.StartPoint().z),
|
|
AcGePoint3d(xLineTemp.EndPoint().x,xLineTemp.EndPoint().y,xLineTemp.EndPoint().z));
|
|
if (!LeftPlane.intersectWith(acgeLine1,ptTemp1))
|
|
{
|
|
return FALSE;
|
|
}
|
|
if (!RightPLane.intersectWith(acgeLine1,ptTemp2))
|
|
{
|
|
return FALSE;
|
|
}
|
|
|
|
if (ptTemp1.z < ptTemp2.z)
|
|
poly.AppendNode(ptTemp1);
|
|
else
|
|
poly.AppendNode(ptTemp2);
|
|
{
|
|
int n = poly.Length();
|
|
poly.Compress(FALSE);
|
|
if (poly.Length() != n)
|
|
{
|
|
m_bFlag1 = TRUE;
|
|
bHasThirdPt1 = FALSE;
|
|
}
|
|
}
|
|
|
|
if (bHasThirdPt1)
|
|
{
|
|
AcGeVector3d v1 = poly[1]->AsAcGePoint3d() - poly[0]->AsAcGePoint3d(),v2 = poly[1]->AsAcGePoint3d() - poly[2]->AsAcGePoint3d();
|
|
AcGeVector3d vt = poly[2]->AsAcGePoint3d() - poly[0]->AsAcGePoint3d();
|
|
double d1 = v1.angleTo(vt);
|
|
vt = poly[0]->AsAcGePoint3d() - poly[2]->AsAcGePoint3d();
|
|
double d2 =v2.angleTo(vt);
|
|
|
|
//modify by xlc on 070516
|
|
if (d1 > PI/2.0 || d2 > PI/2.0 || fabs(d1 - PI/2.0)<= 1E-6 || fabs(d2 - PI/2.0)<= 1E-6)
|
|
//if (d1 > PI/2.0 || d2 > PI/2.0 || fabs(d1 - PI/2.0)<= 1E-2 || fabs(d2 - PI/2.0)<= 1E-2)
|
|
{
|
|
poly.Remove(1);
|
|
m_bFlag1 = TRUE;
|
|
}
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
//add by xlc on 070712
|
|
//柱子对齐屋顶
|
|
void ColumnAlignSlopeRoof(TDbColumn *pColumn, //[in]柱子对象
|
|
DList<X3DFace> &lstFace //[in]屋顶面
|
|
)
|
|
{
|
|
XPoly2D polyColu;
|
|
pColumn->GetOutline(polyColu);
|
|
if (pColumn->GetSectionShape() == TColumnData::kCircle)
|
|
{
|
|
polyColu.Disperse(polyColu);
|
|
}
|
|
|
|
double height = 0.0;
|
|
XPoint start,end;
|
|
XLine xLine1(*polyColu[0],*polyColu[polyColu.Length()-1]);
|
|
|
|
//modify by xlc on 080303 解决部分柱子在屋顶面外边
|
|
BOOL bFlag = TRUE; //bFlag为TRUE时,初始化height
|
|
if (GetEndIntSectPoint(lstFace,xLine1,start,end,FALSE)) //获得线端点的投影点
|
|
{
|
|
if (bFlag)
|
|
{
|
|
height = start.z;
|
|
bFlag = FALSE;
|
|
}
|
|
|
|
if (height > end.z)
|
|
height = end.z;
|
|
|
|
XPoly3D poly;
|
|
GetIntSectPoint(lstFace,xLine1,poly); //获得线平面与face平面边线的交点
|
|
|
|
for(int j = 0; j < poly.Length(); j++)
|
|
{
|
|
//modify by xlc on 080303
|
|
if (bFlag)
|
|
{
|
|
height = poly[j]->z;
|
|
bFlag=FALSE;
|
|
continue;
|
|
}
|
|
|
|
if (height > poly[j]->z)
|
|
{
|
|
height = poly[j]->z;
|
|
}
|
|
}
|
|
}
|
|
|
|
for(int i = 0; i < polyColu.Length()-1; i++)
|
|
{
|
|
XPoly3D poly1;
|
|
XLine xLine(*polyColu[i],*polyColu[i+1]);
|
|
GetIntSectPoint(lstFace,xLine,poly1);
|
|
|
|
for(int j = 0; j < poly1.Length(); j++)
|
|
{
|
|
if (height > poly1[j]->z)
|
|
{
|
|
height = poly1[j]->z;
|
|
}
|
|
}
|
|
|
|
//modify by xlc on 080303
|
|
//if (!GetEndIntSectPoint(lstFace,xLine,start,end))
|
|
// return;
|
|
if (!GetEndIntSectPoint(lstFace,xLine,start,end,FALSE))
|
|
continue;
|
|
|
|
if (height > start.z)
|
|
height = start.z;
|
|
if (height > end.z)
|
|
height = end.z;
|
|
}
|
|
|
|
if (height > pColumn->GetElevation())
|
|
{
|
|
pColumn->assertWriteEnabled();
|
|
pColumn->SetHeight(height);
|
|
}
|
|
}
|
|
|
|
//add by xlc on 070712
|
|
//求线与线的交点
|
|
BOOL GetIntPoint(AcDbCurve *projLine,AcGePoint3d ptStart,AcGePoint3d ptEnd,AcGePoint3d &ptInt)
|
|
{
|
|
AcDbLine line(ptStart,ptEnd);
|
|
|
|
AcGePoint3dArray points;
|
|
if (projLine != NULL)
|
|
projLine->intersectWith(&line, AcDb::kOnBothOperands, points);
|
|
|
|
if (points.length() > 0)
|
|
{
|
|
ptInt = points.at(0);
|
|
return TRUE;
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
//add by xlc on 070712
|
|
//获得屋顶向内的面
|
|
void GetRoofAllPoly(AcDbObjectId id, //[in]屋顶对象ID
|
|
DList<X3DFace> &lstFace //[out]屋顶向内的面
|
|
)
|
|
{
|
|
OPENOBJ_BEGIN(id, AcDb::kForRead, AcDbEntity, pRoof);
|
|
if (pRoof)
|
|
{
|
|
int nFlag = 0; //是否屋顶对象,0:非屋顶对象;1:人字屋顶或攒尖屋顶,矩形屋顶;2:任意屋顶(有内侧缺面)
|
|
BOOL bRoof = FALSE; //是否可视为屋顶
|
|
if (pRoof->isKindOf(TDbDualSlopeRoof::desc())
|
|
|| pRoof->isKindOf(TDbCuspRoof::desc())
|
|
|| pRoof->isKindOf(TDbMountRoof::desc())
|
|
)
|
|
{
|
|
nFlag = 1;
|
|
bRoof = TRUE;
|
|
}
|
|
else if (pRoof->isKindOf(TDbSlopeRoof::desc()))
|
|
{
|
|
nFlag = 2;
|
|
bRoof = TRUE;
|
|
}
|
|
else if (pRoof->isKindOf(AcDbPolyFaceMesh::desc())
|
|
|| pRoof->isKindOf(AcDbPolygonMesh::desc())
|
|
|| pRoof->isKindOf(AcDbFace::desc())
|
|
)
|
|
{
|
|
bRoof = TRUE;
|
|
}
|
|
|
|
if (bRoof)
|
|
{
|
|
TMasterProperties prop;
|
|
AcDbVoidPtrArray entSet;
|
|
int nOldMode=DocGetDrawMode();
|
|
DocSetDrawMode(DRAW_3D);
|
|
if (nFlag == 2)
|
|
{
|
|
AcDbEntity *pEnt = (AcDbEntity*)pRoof->clone();
|
|
if (pEnt)
|
|
{
|
|
double height = _AS_SYS_UNIT(200.0);// [11/15/2007 nsh]
|
|
|
|
AcGeMatrix3d mat;
|
|
mat.setToTranslation(AcGeVector3d(0,0,-height));
|
|
|
|
pEnt->upgradeOpen();
|
|
pEnt->transformBy(mat);
|
|
|
|
InitModel(prop, pEnt, NULL, entSet);
|
|
|
|
delete pEnt;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
InitModel(prop, pRoof, NULL, entSet);
|
|
}
|
|
DocSetDrawMode(nOldMode);
|
|
|
|
int nLen=entSet.length();
|
|
for(int n=0; n<nLen; n++)
|
|
{
|
|
AcDbEntity *pEnt=(AcDbEntity *)entSet[n];
|
|
if (pEnt->isKindOf(AcDbFace::desc()))
|
|
{
|
|
AcDbFace *pFace = AcDbFace::cast(pEnt);
|
|
if (pFace != NULL)
|
|
{
|
|
X3DFace p3DFace(*pFace);
|
|
XVector3D vtNormal = p3DFace.GetNormal();
|
|
|
|
if (fabs(vtNormal.z) < 1.0e-6) //立面
|
|
continue;
|
|
|
|
if (nFlag == 1)
|
|
{
|
|
if (vtNormal.z > 1.0e-6) //人字坡顶或攒尖屋顶向下的面
|
|
continue;
|
|
}
|
|
else if (nFlag == 2)
|
|
{
|
|
if (vtNormal.z < 1.0e-6) //任意坡顶向上的面
|
|
continue;
|
|
}
|
|
|
|
lstFace.Append(new X3DFace(p3DFace));
|
|
}
|
|
}
|
|
}
|
|
ReleaseEntSet(entSet);
|
|
}
|
|
}
|
|
OPENOBJ_END();
|
|
}
|
|
|
|
//add by xlc on 070712
|
|
//获得线段与屋顶面边线的投影交点
|
|
void GetIntSectPoint(DList<X3DFace> &lstFace, //[in]屋顶面
|
|
XLine xLine, //[in]线段
|
|
XPoly3D &poly //[out]投影点数组
|
|
)
|
|
{
|
|
int num = lstFace.Length();
|
|
for(int i = 0; i < lstFace.Length(); i++) //获得直线所在平面与投影面的交点
|
|
{
|
|
AcDbLine line(xLine.StartPoint(),xLine.EndPoint());
|
|
X3DFace face(*lstFace[i]);
|
|
face.MakeBetter();
|
|
AcGePlane roof(AcGePoint3d(face.GetVertex(0)),AcGePoint3d(face.GetVertex(1)),AcGePoint3d(face.GetVertex(2)));
|
|
|
|
AcDbCurve *projLine = NULL; //在face平面上的投影线
|
|
line.getProjectedCurve(roof, AcGeVector3d::kZAxis, projLine);
|
|
|
|
if (projLine != NULL)
|
|
{
|
|
//modify by xlc on 070801 消除隐藏线的影响
|
|
AcGePoint3d ptInt; //平面与face面交线与face边的交点
|
|
//if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(0)),AcGePoint3d(face.GetVertex(1)),ptInt))
|
|
if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(0)),AcGePoint3d(face.GetVertex(1)),ptInt) && face.IsVisible(0))
|
|
poly.AppendNode(ptInt);
|
|
|
|
//if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(1)),AcGePoint3d(face.GetVertex(2)),ptInt))
|
|
if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(1)),AcGePoint3d(face.GetVertex(2)),ptInt) && face.IsVisible(1))
|
|
poly.AppendNode(ptInt);
|
|
|
|
if (!face.IsTriangle(2))
|
|
{
|
|
//if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(2)),AcGePoint3d(face.GetVertex(3)),ptInt))
|
|
if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(2)),AcGePoint3d(face.GetVertex(3)),ptInt) && face.IsVisible(2))
|
|
poly.AppendNode(ptInt);
|
|
//if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(3)),AcGePoint3d(face.GetVertex(0)),ptInt))
|
|
if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(3)),AcGePoint3d(face.GetVertex(0)),ptInt) && face.IsVisible(3))
|
|
poly.AppendNode(ptInt);
|
|
}
|
|
else
|
|
{
|
|
//if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(2)),AcGePoint3d(face.GetVertex(0)),ptInt))
|
|
if (GetIntPoint(projLine,AcGePoint3d(face.GetVertex(2)),AcGePoint3d(face.GetVertex(0)),ptInt) && face.IsVisible(2))
|
|
poly.AppendNode(ptInt);
|
|
}
|
|
delete projLine;
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
//add by xlc on 070712
|
|
//获得墙端点在屋顶面上的投影点
|
|
//返回值:TRUE,成功;FALSE,失败
|
|
BOOL GetEndIntSectPoint(DList<X3DFace> &lstFace, //[in]屋顶面
|
|
XLine xLine, //[in]线段
|
|
XPoint &start, //[out]xLine线起点的投影点
|
|
XPoint &end, //[out]xLine线终点的投影点
|
|
BOOL bWall //[in]是否是墙线段
|
|
)
|
|
{
|
|
int posS = 0,posE = 0; //face在链表中的位置
|
|
XPoint ptStart(xLine.StartPoint().x,xLine.StartPoint().y,0),
|
|
ptEnd(xLine.EndPoint().x,xLine.EndPoint().y,0);
|
|
BOOL bFindS = FALSE,bFindE = FALSE; //是否找到起始点所在的face
|
|
|
|
//找墙点所在的face
|
|
for(int i = 0; i < lstFace.Length(); i++)
|
|
{
|
|
AcGePoint3d pt;
|
|
XPoly2D polyFace(1);
|
|
|
|
X3DFace face(*lstFace[i]);
|
|
face.MakeBetter();
|
|
|
|
for(int j = 0; j < 3; j++)
|
|
{
|
|
pt = face.GetVertex(j);
|
|
polyFace.AppendNode(pt);
|
|
}
|
|
if (!face.IsTriangle(2))//四边形
|
|
{
|
|
pt = face.GetVertex(3);
|
|
polyFace.AppendNode(pt);
|
|
}
|
|
|
|
polyFace.SetElevation(0.0); //投影到z=0的平面上
|
|
if (!bFindS)
|
|
{
|
|
if ( (ptStart & polyFace) != PR_OUTSIDE)
|
|
{
|
|
posS = i;
|
|
bFindS = TRUE;
|
|
}
|
|
}
|
|
|
|
if (!bFindE)
|
|
{
|
|
if ( (ptEnd & polyFace) != PR_OUTSIDE)
|
|
{
|
|
posE = i;
|
|
bFindE = TRUE;
|
|
}
|
|
}
|
|
if (bFindS && bFindE)
|
|
break;
|
|
}
|
|
|
|
//墙端点上的face面
|
|
if (bFindS)
|
|
{
|
|
X3DFace pFace(*lstFace[posS]);
|
|
pFace.MakeBetter();
|
|
AcGePlane sPlane(AcGePoint3d(pFace.GetVertex(0)),
|
|
AcGePoint3d(pFace.GetVertex(1)),AcGePoint3d(pFace.GetVertex(2)));
|
|
AcGePoint3d tmp = xLine.StartPoint();
|
|
tmp.z += _AS_SYS_UNIT(1000.0);// [11/15/2007 nsh]
|
|
AcGeLine3d sLine(AcGePoint3d(xLine.StartPoint()),tmp);
|
|
sLine.intersectWith(sPlane,start);
|
|
|
|
//modify by xlc on 080303
|
|
if ((!bWall) && (!bFindE))
|
|
{
|
|
end = xLine.EndPoint();
|
|
end.z=start.z;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (!bFindE)
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
if (bFindE)
|
|
{
|
|
X3DFace pFace(*lstFace[posE]);
|
|
pFace.MakeBetter();
|
|
|
|
AcGePlane ePlane(AcGePoint3d(pFace.GetVertex(0)),
|
|
AcGePoint3d(pFace.GetVertex(1)),AcGePoint3d(pFace.GetVertex(2)));
|
|
|
|
AcGePoint3d tmp = xLine.EndPoint();
|
|
tmp.z +=_AS_SYS_UNIT(1000.0);// [11/15/2007 nsh]
|
|
AcGeLine3d eLine(AcGePoint3d(xLine.EndPoint()),tmp);
|
|
|
|
eLine.intersectWith(ePlane,end);
|
|
|
|
//modify by xlc on 080303
|
|
if ((!bWall) && (!bFindS))
|
|
{
|
|
start = xLine.StartPoint();
|
|
start.z=end.z;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (bWall)
|
|
{
|
|
return FALSE;
|
|
}
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
//add by xlc on 070712
|
|
//墙与屋顶的交线
|
|
BOOL GetIntSectPoly(DList<X3DFace> &lstFace, //[in]屋顶面
|
|
XLine xLine, //[in]墙线
|
|
XPoly3D &poly //[out]交线
|
|
)
|
|
{
|
|
GetIntSectPoint(lstFace,xLine,poly); //获得线段平面在face平面上的交点
|
|
|
|
//删除重合点
|
|
int ptNum = poly.Length();
|
|
for(int i = 0; i < ptNum-1; i++)
|
|
{
|
|
for(int j = i+1;j < ptNum;)
|
|
{
|
|
if (*poly[i] == *poly[j])
|
|
{
|
|
poly.RemoveNode(j);
|
|
ptNum--;
|
|
continue;
|
|
}
|
|
j++;
|
|
}
|
|
}
|
|
|
|
//排序
|
|
Array<XPoint> ptArray; //交点
|
|
if (ptNum > 0)
|
|
{
|
|
ptArray.Realloc(ptNum);
|
|
for(long i = 0; i < ptNum; i++)
|
|
{
|
|
ptArray[i] = *poly[i];
|
|
}
|
|
bool bIncrease = true;
|
|
if (fabs(xLine.StartPoint().x - xLine.EndPoint().x) < 1e-6)
|
|
{
|
|
if (xLine.StartPoint().y - xLine.EndPoint().y > 0)
|
|
bIncrease = false;
|
|
}
|
|
else
|
|
{
|
|
if (xLine.StartPoint().x - xLine.EndPoint().x > 0)
|
|
bIncrease = false;
|
|
}
|
|
ptArray.Arrange(bIncrease); //按墙钱起点到终点的顺序排序
|
|
|
|
for(i = 0; i < ptNum; i++)
|
|
{
|
|
*poly[i] = ptArray[i];
|
|
}
|
|
}
|
|
|
|
//求墙线的起点和终点与face的交点
|
|
XPoint start,end;
|
|
if (!GetEndIntSectPoint(lstFace,xLine,start,end))
|
|
return FALSE;
|
|
|
|
//添加墙的端点
|
|
if (poly.Length() > 0)
|
|
{
|
|
if (start != *poly[0])
|
|
{
|
|
poly.InsertNodeAt(0,start);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
poly.InsertNodeAt(0,start);
|
|
}
|
|
|
|
if (end != *poly[poly.Length()-1])
|
|
{
|
|
poly.AppendNode(end);
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
BOOL CDuanSlopeRoofDlg::DestroyWindow()
|
|
{
|
|
m_ctrlPreview.clearAll();
|
|
return CAcUiDialog::DestroyWindow();
|
|
} |