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

334 lines
6.7 KiB
C++

//-----------------------------------------------------------------------------+
// Copyright (C), 1998-2007, Beijing Tangent Software Co. Ltd.
// = FileName : TColumnData.cpp
// = Version : ver2.0
// = Author : xlc
// = CreateDate : 2002-09-09
// = Description: 柱子数据类的定义
// = Maintainers:
//
//-----------------------------------------------------------------------------+
#include "StdAfx.h"
#include "TColumnData.h"
#include "DbConfig.h"
TColumnData::TColumnData() : m_nSectionShape(TColumnData::kPoly)
{
m_nHeight = DocGetLHeight();
m_material = kConcrete;
}
TColumnData::TColumnData(const TColumnData &src)
{
*this = src;
}
TColumnData & TColumnData::operator = (const TColumnData &src)
{
m_ptLocation = src.m_ptLocation;
m_nHeight = src.m_nHeight;
m_material = src.m_material;
m_nSectionShape = src.m_nSectionShape;
m_polyOutline = src.m_polyOutline;
return *this;
}
// 取得截面积
double TColumnData::GetSectionArea() const
{
return m_polyOutline.Area();
}
///////////////////////////////////////////////////////////////
// 取得点取的段
// ptPick--点取位置
// 注:ptPick必须准确的命中边界才可以
Acad::ErrorStatus TColumnData::GetPickSegment(const TADSGePoint3d &ptPick, TGGeCurveSegment &res) const
{
ASSERT(0);
TGGePoly2D poly(1);
GetOutline(poly);
int nSeg = poly.TotalSegments();
for(int i = 0; i<nSeg; i++)
{
TGGeCurveSegment seg;
poly.Nth(i, seg);
int nPrFlag = (ptPick&seg);
if(nPrFlag==PR_INSIDE || nPrFlag==PR_ONPT1 || nPrFlag==PR_ONPT2)
{
res = seg;
return Acad::eOk;
}
}
return Acad::eInvalidInput;
}
//第一边的转角
double TColumnData::GetRotation() const
{
double nRot = 0.0;
if (m_nSectionShape!=kCircle&&m_nSectionShape!=kPoly)
{
if (m_polyOutline.TotalSegments()>0)
{
TGGeCurveSegment segFirst;
m_polyOutline.Nth(0, segFirst);
nRot = segFirst.TGGeLine::Direction();
}
}
return nRot;
}
///////////////////////////////////////////////////////////////
// 取得柱子的边界
// 没有改变原始边界的性质,即没有做线性化的处理
// V2.0: 一定是逆时针方向
void TColumnData::GetOutline(TGGePoly2D &poly) const
{
poly = m_polyOutline;
}
// x--宽度, y--宽度, z--转角
TADSGePoint3d TColumnData::GetParameters() const
{
ASSERT(!!m_polyOutline && m_polyOutline.Length() >= 2 && m_polyOutline.IsClosed());
double nRot = GetRotation();
double nx = 0, ny = 0;
if(m_nSectionShape==kCircle)
{
TGGeCurveSegment seg;
m_polyOutline.Nth(0, seg);
nx = ny = seg.GetArc().GetRadius() * 2;
}
else if(m_nSectionShape==kRect)
{
TGGeCurveSegment seg1, seg2;
m_polyOutline.Nth(0, seg1);
m_polyOutline.Nth(1, seg2);
nx = seg1.GetLength();
ny = seg2.GetLength();
}
else if(m_nSectionShape==kPoly)
{
TGGePoly poly;
((TGGePoly2D &)m_polyOutline).MapToPolygon(poly);
TADSGePoint3d pt = m_polyOutline[0];
ads_matrix mat;
pt.GetRotationMatrix(nRot, mat);
poly.TransUCS(mat);
TADSGePoint3d pt1, pt2;
poly.GetExtend(pt1, pt2);
nx = pt2.x-pt1.x;
ny = pt2.y-pt1.y;
}
else if(m_nSectionShape == kIBeam)
{
nRot -= PI*0.5;
TGGeCurveSegment seg1, seg2,seg3;
m_polyOutline.Nth(5, seg1);
m_polyOutline.Nth(1, seg2);
nx = max(seg1.GetLength(),seg2.GetLength());
m_polyOutline.Nth(0, seg1);
m_polyOutline.Nth(2, seg2);
m_polyOutline.Nth(4, seg3);
ny =seg1.GetLength()+seg2.GetLength()+seg3.GetLength();
}
else
{
int nNumSides = 3;
switch(m_nSectionShape)
{
case kStd3:
nNumSides = 3;
break;
case kStd5:
nNumSides = 5;
break;
case kStd6:
nNumSides = 6;
break;
case kStd8:
nNumSides = 8;
break;
case kStd12:
nNumSides = 12;
break;
}
TGGeCurveSegment seg1, seg2;
m_polyOutline.Nth(0, seg1);
nx = seg1.GetLength();
ny = nx / cos(PI / 2 - PI / nNumSides);
}
return TADSGePoint3d(nx,ny,nRot);
}
const TCHAR * TColumnData::GetSectionShapeText() const
{
const TCHAR *coluTypeArray[] = {_T("矩形"), _T("圆形"), _T("正三角形"),
_T("正五边形"), _T("正六边形"),
_T("正八边形"), _T("正十二边形") };
TColumnData::TSectionShape coluShapeArray[] = { TColumnData::kRect,
TColumnData::kCircle, TColumnData::kStd3, TColumnData::kStd5,
TColumnData::kStd6, TColumnData::kStd8, TColumnData::kStd12};
int idx = -1;
for(int i = 0; i < ELEMENTS(coluTypeArray); i++)
{
if(coluShapeArray[i] == GetSectionShape())
{
idx = i;
break;
}
}
const TCHAR *pDesc = _T("未知");
if (idx >= 0)
{
pDesc = coluTypeArray[idx];
}
return pDesc;
}
int TColumnData::CompareByLocForFind(const TColumnData *p1, const void *p2 /* TADSGePoint3d pointer */)
{
const TADSGePoint3d *pt2 = (const TADSGePoint3d *)p2;
return (p1->m_ptLocation == *pt2) ? 0:1;
}
double TColumnData::GetHeight() const
{
return m_nHeight;
}
double TColumnData::GetElevation() const
{
return m_ptLocation.z;
}
TADSGePoint3d TColumnData::GetLocation() const
{
return m_ptLocation;
}
double TColumnData::GetVolume() const
{
return GetSectionArea()*GetHeight();
}
// 形状
TColumnData::TSectionShape TColumnData::GetSectionShape() const
{
return m_nSectionShape;
}
const TGGePoly2D & TColumnData::GetOutlinePoly() const
{
return m_polyOutline;
}
TColumnData::TColumnMaterial TColumnData::GetMaterial() const
{
return m_material;
}
void TColumnData::SetHeight(double nH)
{
m_nHeight = nH;
}
void TColumnData::SetElevation(double nZ)
{
m_ptLocation.z = nZ;
}
void TColumnData::SetLocation(const TADSGePoint3d &pt)
{
m_ptLocation = pt;
}
void TColumnData::SetSectionShape(TColumnData::TSectionShape nUsage)
{
m_nSectionShape = nUsage;
}
void TColumnData::SetOutlinePoly(const TGGePoly2D &poly)
{
m_polyOutline = poly;
if (m_polyOutline.PathArea() > 0)
{
m_polyOutline.Reverse(); //确保按逆时针方向
}
}
void TColumnData::SetMaterial(TColumnData::TColumnMaterial mater)
{
m_material = mater;
}
BOOL TColumnData::Has3D() const
{
return (m_nHeight > _DIST_SNAP);
}
//add by xlc on 101110 柱子形状字符串
CString TColumnData::GetSectionShape(TColumnData::TSectionShape nUsage) const
{
CString strShape(_T("异形柱"));
switch (nUsage)
{
case kRect:
strShape = _T("矩形");
break;
case kCircle:
strShape = _T("圆形");
break;
case kStd3:
strShape = _T("正三角形");
break;
case kStd5:
strShape = _T("正五边形");
break;
case kStd6:
strShape = _T("正六边形");
break;
case kStd8:
strShape = _T("正八边形");
break;
case kStd12:
strShape = _T("正十二边形");
break;
case kIBeam:
strShape = _T("工字形");
break;
}
return strShape;
}
//材料字符串
CString TColumnData::GetMaterial(TColumnData::TColumnMaterial mater) const
{
CString strMaterial(_T("其它"));
switch (mater)
{
case kBrick:
strMaterial = _T("砖");
break;
case kRocket:
strMaterial = _T("石材");
break;
case kConcrete:
strMaterial = _T("钢筋混凝土");
break;
case kSteel:
strMaterial = _T("金属");
break;
}
return strMaterial;
}