89 lines
2.0 KiB
C++
89 lines
2.0 KiB
C++
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "ThunderCaculate.h"
|
|
#include "LightningRodData.h"
|
|
|
|
#ifdef _DEBUG
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[]=__FILE__;
|
|
#define new DEBUG_NEW
|
|
#endif
|
|
|
|
|
|
TGThunderCaculate::TGThunderCaculate()
|
|
{
|
|
|
|
}
|
|
|
|
TGThunderCaculate::~TGThunderCaculate()
|
|
{
|
|
|
|
}
|
|
|
|
//通过避雷针数据进行计算
|
|
void TGThunderCaculate::CaculateThunderData(const TGLightningRodData *pData)
|
|
{
|
|
if (pData == NULL)
|
|
return;
|
|
|
|
m_result.m_dGroundRadius = pData->GetGroundRadius();
|
|
m_result.m_dHeight = pData->GetHeight();
|
|
m_result.m_nNumber = pData->GetNumber();
|
|
m_result.m_nGroupNO = pData->GetGroupNO();
|
|
|
|
m_result.m_arProHeight.setLogicalLength(0);
|
|
m_result.m_arProHeight.append(pData->m_arProtecedHeight);
|
|
|
|
pData->GetInsertPoint(m_result.m_ptInsert);
|
|
pData->GetObjectID(m_result.m_id);
|
|
|
|
//建筑物高度为0的保护高度
|
|
m_result.m_dProRadius = pow(m_result.m_dHeight*(2*m_result.m_dGroundRadius - m_result.m_dHeight),0.5);
|
|
|
|
//得到滚球圆心坐标 ptCen为返回值,其他为输入值
|
|
GetGroundCenter(m_result.m_ptInsert,m_result.m_dHeight,m_result.m_dGroundRadius,m_result.m_ptGroundCenter);
|
|
}
|
|
|
|
bool TGThunderCaculate::DocGetMeterUnitDraw()
|
|
{
|
|
struct resbuf rb;
|
|
acedGetVar(_T("INSUNITS"),&rb);
|
|
|
|
if (rb.resval.rint == AcDb::kUnitsMeters)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
//得到滚球圆心坐标 ptCen为返回值,其他为输入值
|
|
void TGThunderCaculate::GetGroundCenter(const AcGePoint3d ptInsert,double dHeight,double dGroundRadius,AcGePoint3d& ptCen)
|
|
{
|
|
if (!DocGetMeterUnitDraw())
|
|
{
|
|
dHeight = dHeight * 1000;
|
|
dGroundRadius = dGroundRadius * 1000;
|
|
}
|
|
|
|
AcGePoint3d ptPin,ptStart,ptEnd;
|
|
ptPin = ptInsert;
|
|
ptPin.z = dHeight;
|
|
ptStart = ptInsert;
|
|
|
|
ptStart.z = dGroundRadius;
|
|
|
|
ptEnd = ptStart;
|
|
ptEnd.y += dGroundRadius;
|
|
|
|
AcDbLine line(ptStart,ptEnd);
|
|
AcGePoint3dArray arPt;
|
|
AcDbCircle circle(ptPin,AcGeVector3d::kXAxis,dGroundRadius);
|
|
line.intersectWith(&circle,AcDb::kExtendThis,arPt);
|
|
|
|
if (arPt.length() > 0)
|
|
{
|
|
ptCen = arPt[0];
|
|
}
|
|
|
|
}
|