Files
envi-code/SourceCode/Code2026/tg_shs/shs_pipewire/PipeLine.cpp
T
2026-09-28 15:28:50 +08:00

181 lines
3.8 KiB
C++

// PipeLine.cpp: implementation of the CPipeLine class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "PipeLine.h"
#include "math.h"
#include "geassign.h"
//#include "dbentity.h"
#include "PipeTools.h"
#include "GlobalFunction.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CPipeLine::CPipeLine()
{
m_PtStart[X] = 0;
m_PtStart[Y] = 0;
m_PtStart[Z] = 0;
m_PtEnd[X] = 0;
m_PtEnd[Y] = 0;
m_PtEnd[Z] = 0;
m_dbAngle = 0.0;
m_dbLength = 0.0;
}
CPipeLine::CPipeLine(ads_point PtStart, double dbPGAngle, double dbLength,
double dbAssisAng, double dbNormAng)
{
m_PtStart[X] = PtStart[X];
m_PtStart[Y] = PtStart[Y];
m_PtStart[Z] = PtStart[Z];
m_dbLength = dbLength;
m_dbAngle = dbPGAngle + dbAssisAng + dbNormAng;
acutPolar(m_PtStart, m_dbAngle, m_dbLength, m_PtEnd);
}
CPipeLine::~CPipeLine()
{
}
//////////////////////////////////////////////////////////////////////
// Set/Get函数
//////////////////////////////////////////////////////////////////////
// 角度
void CPipeLine::SetAngle(double dbAngle)
{
m_dbAngle = dbAngle;
}
double CPipeLine::GetAngle( )
{
m_dbAngle = acutAngle(m_PtStart, m_PtEnd);
return m_dbAngle;
}
// 起点
void CPipeLine::SetStartPt(ads_point PtStart)
{
m_PtStart[X] = PtStart[X];
m_PtStart[Y] = PtStart[Y];
m_PtStart[Z] = PtStart[Z];
}
void CPipeLine::GetStartPt(ads_point& PtStart)
{
PtStart[X] = m_PtStart[X];
PtStart[Y] = m_PtStart[Y];
PtStart[Z] = m_PtStart[Z];
}
// 终点
void CPipeLine::SetEndPt(ads_point PtEnd)
{
m_PtEnd[X] = PtEnd[X];
m_PtEnd[Y] = PtEnd[Y];
m_PtEnd[Z] = PtEnd[Z];
}
void CPipeLine::GetEndPt(ads_point& PtEnd)
{
PtEnd[X] = m_PtEnd[X];
PtEnd[Y] = m_PtEnd[Y];
PtEnd[Z] = m_PtEnd[Z];
}
// 长度
double CPipeLine::GetLength( )
{
m_dbLength = fabs(acutDistance(m_PtStart, m_PtEnd));
return m_dbLength;
}
//////////////////////////////////////////////////////////////////////
// 绘制函数
//////////////////////////////////////////////////////////////////////
// sg modify,增加了颜色和线宽
bool CPipeLine::DrawTheLine(XExplodeDraw &dc, const BOOL &bWeight,
const int &nColorIndex, const double &dLineWeight)
{
XLine pLine(m_PtStart,m_PtEnd, LS_FINITE);
if (pLine.GetLength() < 0.1)
{
return true;
}
// dc.DrawLine(pLine, 0);
XCurveSegment seg;
seg = pLine;
// if (bWeight)
// if (g_bPipeWeight)
if (g_bFloorPipeWeight)
{
double dWeight = DocGetPScale() * dLineWeight;
DrawWeight(dc, dWeight, seg, nColorIndex, 1.0);
}
else
{
dc << seg;
}
return true;
}
bool CPipeLine::DrawTheLine()
{
XLine pLine(m_PtStart, m_PtEnd, LS_FINITE);
if (pLine.GetLength() < 0.1)
{
return true;
}
pLine.Make();
return true;
}
/*----------------------------------------------------------------------------*
* 函数名称: GetArcRadius
* 功能描述: 获得曲率半径
* 参 数: [in] dbInput:管线间距
* 返 回 值: 曲率半径值
* 历 史:
* 备 注: 不再使用,而变成实体的属性,由用户设置
-----------------------------------------------------------------------------*/
double GetArcRadius(double dbInput)
{
double dbRadius = dbInput/2;
return dbRadius;
}
/*----------------------------------------------------------------------------*
* 函数名称: TransAngTo2PI
* 功能描述: 将角度值转换到2PI以内
* 参 数: [in] dbAng:输入的角度值
* 返 回 值: 2PI以内的角度值
* 历 史:
* 备 注: 改:准备不再使用,而调用T7Platform中的函数
-----------------------------------------------------------------------------*/
double TransAngTo2PI(double dbAng)
{
int n = int(dbAng/(2*PI));
double dAng = dbAng - n*2*PI;
if (dAng < 0)
{
dAng += 2*PI;
}
return dAng;
}